Class: Mirah::AST::Script
- Defined in:
- lib/mirah/ast/structure.rb,
lib/mirah/compiler/structure.rb
Class Attribute Summary collapse
-
.explicit_packages ⇒ Object
Returns the value of attribute explicit_packages.
Instance Attribute Summary collapse
-
#defining_class ⇒ Object
Returns the value of attribute defining_class.
-
#filename ⇒ Object
Returns the value of attribute filename.
Attributes included from Scope
Attributes inherited from Node
#children, #inferred_type, #newline, #parent, #position
Instance Method Summary collapse
- #compile(compiler, expression) ⇒ Object
- #infer(typer, expression) ⇒ Object
-
#initialize(parent, line_number, &block) ⇒ Script
constructor
A new instance of Script.
Methods included from Binding
#binding_type, #binding_type=, #has_binding?
Methods included from Scoped
Methods inherited from Node
#<<, ===, #[], #[]=, #_dump, _load, #_set_parent, child, child_name, #child_nodes, #each, #empty?, #expr?, #inferred_type!, #initialize_copy, #insert, #inspect, #inspect_children, #line_number, #log, #precompile, #resolve_if, #resolved!, #resolved?, #simple_name, #string_value, #temp, #to_s, #top_level?, #validate_child, #validate_children
Constructor Details
#initialize(parent, line_number, &block) ⇒ Script
Returns a new instance of Script.
295 296 297 298 |
# File 'lib/mirah/ast/structure.rb', line 295 def initialize(parent, line_number, &block) super(parent, line_number, &block) @package = "" end |
Class Attribute Details
.explicit_packages ⇒ Object
Returns the value of attribute explicit_packages.
322 323 324 |
# File 'lib/mirah/ast/structure.rb', line 322 def explicit_packages @explicit_packages end |
Instance Attribute Details
#defining_class ⇒ Object
Returns the value of attribute defining_class.
292 293 294 |
# File 'lib/mirah/ast/structure.rb', line 292 def defining_class @defining_class end |
#filename ⇒ Object
Returns the value of attribute filename.
293 294 295 |
# File 'lib/mirah/ast/structure.rb', line 293 def filename @filename end |
Instance Method Details
#compile(compiler, expression) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/mirah/compiler/structure.rb', line 48 def compile(compiler, expression) # TODO: what does it mean for a script to be an expression? possible? compiler.define_main(self) rescue Exception => ex raise Mirah::InternalCompilerError.wrap(ex, self) end |
#infer(typer, expression) ⇒ Object
300 301 302 303 304 305 306 307 308 |
# File 'lib/mirah/ast/structure.rb', line 300 def infer(typer, expression) resolve_if(typer) do typer.set_filename(self, filename) @defining_class ||= begin static_scope.self_type = typer.self_type end typer.infer(body, false) end end |