Class: Alf::Compiler

Inherits:
Object
  • Object
show all
Defined in:
lib/alf/compiler.rb,
lib/alf/compiler/cog.rb,
lib/alf/compiler/plan.rb,
lib/alf/compiler/default.rb

Direct Known Subclasses

Default

Defined Under Namespace

Modules: Cog Classes: Default, Plan

Instance Method Summary collapse

Instance Method Details

#call(expr) ⇒ Object


12
13
14
# File 'lib/alf/compiler.rb', line 12

def call(expr)
  Plan.new(self).compile(expr)
end

#compile(plan, expr, compiled, usage_count) ⇒ Object


16
17
18
# File 'lib/alf/compiler.rb', line 16

def compile(plan, expr, compiled, usage_count)
  send(to_method_name(expr), plan, expr, *compiled)
end

#join(plan) ⇒ Object


8
9
10
# File 'lib/alf/compiler.rb', line 8

def join(plan)
  nil
end

#on_leaf_operand(plan, expr) ⇒ Object


28
29
30
# File 'lib/alf/compiler.rb', line 28

def on_leaf_operand(plan, expr)
  expr.to_cog(plan)
end

#on_missing(plan, expr, *compiled) ⇒ Object

Raises:


36
37
38
# File 'lib/alf/compiler.rb', line 36

def on_missing(plan, expr, *compiled)
  raise NotSupportedError, "Unable to compile `#{expr}` (#{self})"
end

#on_relation(plan, expr) ⇒ Object


20
21
22
# File 'lib/alf/compiler.rb', line 20

def on_relation(plan, expr)
  expr.to_cog(plan)
end

#on_relvar(plan, expr) ⇒ Object


24
25
26
# File 'lib/alf/compiler.rb', line 24

def on_relvar(plan, expr)
  expr.to_cog(plan)
end

#on_shortcut(plan, expr, *compiled) ⇒ Object


32
33
34
# File 'lib/alf/compiler.rb', line 32

def on_shortcut(plan, expr, *compiled)
  plan.__compile{|p| expr.expand }
end

#on_unsupported(plan, expr, *args) ⇒ Object

Raises:


40
41
42
# File 'lib/alf/compiler.rb', line 40

def on_unsupported(plan, expr, *args)
  raise NotSupportedError, "Unsupported expression `#{expr}`"
end

#supports_reuse?Boolean

Returns:

  • (Boolean)

4
5
6
# File 'lib/alf/compiler.rb', line 4

def supports_reuse?
  false
end