Class: Alf::Compiler
- Inherits:
-
Object
show all
- Defined in:
- lib/alf/compiler.rb,
lib/alf/compiler/cog.rb,
lib/alf/compiler/plan.rb,
lib/alf/compiler/default.rb
Defined Under Namespace
Modules: Cog
Classes: Default, Plan
Instance Method Summary
collapse
-
#call(expr) ⇒ Object
-
#compile(plan, expr, compiled, usage_count) ⇒ Object
-
#join(plan) ⇒ Object
-
#on_leaf_operand(plan, expr) ⇒ Object
-
#on_missing(plan, expr, *compiled) ⇒ Object
-
#on_shortcut(plan, expr, *compiled) ⇒ Object
-
#on_unsupported(plan, expr, *args) ⇒ Object
-
#supports_reuse? ⇒ Boolean
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
20
21
22
|
# File 'lib/alf/compiler.rb', line 20
def on_leaf_operand(plan, expr)
expr.to_cog(plan)
end
|
#on_missing(plan, expr, *compiled) ⇒ Object
28
29
30
|
# File 'lib/alf/compiler.rb', line 28
def on_missing(plan, expr, *compiled)
raise NotSupportedError, "Unable to compile `#{expr}` (#{self})"
end
|
#on_shortcut(plan, expr, *compiled) ⇒ Object
24
25
26
|
# File 'lib/alf/compiler.rb', line 24
def on_shortcut(plan, expr, *compiled)
plan.__compile{|p| expr.expand }
end
|
#on_unsupported(plan, expr, *args) ⇒ Object
32
33
34
|
# File 'lib/alf/compiler.rb', line 32
def on_unsupported(plan, expr, *args)
raise NotSupportedError, "Unsupported expression `#{expr}`"
end
|
#supports_reuse? ⇒ Boolean
4
5
6
|
# File 'lib/alf/compiler.rb', line 4
def supports_reuse?
false
end
|