Class: Duby::AST::Script
- Includes:
- Scope
- Defined in:
- lib/duby/compiler.rb,
lib/duby/ast/structure.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
Attributes inherited from Node
#children, #inferred_type, #newline, #parent, #position
Instance Method Summary collapse
- #compile(compiler, expression) ⇒ Object
- #infer(typer) ⇒ Object
-
#initialize(parent, line_number, &block) ⇒ Script
constructor
A new instance of Script.
Methods inherited from Node
#[], #each, #expr?, #inspect, #line_number, #log, #precompile, #resolve_if, #resolved!, #resolved?, #simple_name, #temp, #to_s
Constructor Details
#initialize(parent, line_number, &block) ⇒ Script
Returns a new instance of Script.
35 36 37 38 |
# File 'lib/duby/ast/structure.rb', line 35 def initialize(parent, line_number, &block) super(parent, line_number, children, &block) @body = children[0] end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
33 34 35 |
# File 'lib/duby/ast/structure.rb', line 33 def body @body end |
Instance Method Details
#compile(compiler, expression) ⇒ Object
96 97 98 99 |
# File 'lib/duby/compiler.rb', line 96 def compile(compiler, expression) # TODO: what does it mean for a script to be an expression? possible? compiler.define_main(body) end |
#infer(typer) ⇒ Object
40 41 42 |
# File 'lib/duby/ast/structure.rb', line 40 def infer(typer) @inferred_type ||= typer.infer(body) || (typer.defer(self); nil) end |