Class: Mirah::AST::Import
- Includes:
- Scoped
- Defined in:
- lib/mirah/ast/type.rb,
lib/mirah/compiler/type.rb
Instance Attribute Summary collapse
-
#long ⇒ Object
Returns the value of attribute long.
-
#short ⇒ Object
Returns the value of attribute short.
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, short, long) ⇒ Import
constructor
A new instance of Import.
- #to_s ⇒ Object
- #top_level? ⇒ Boolean
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, #validate_child, #validate_children
Constructor Details
#initialize(parent, line_number, short, long) ⇒ Import
Returns a new instance of Import.
21 22 23 24 25 |
# File 'lib/mirah/ast/type.rb', line 21 def initialize(parent, line_number, short, long) @short = short @long = long super(parent, line_number, []) end |
Instance Attribute Details
#long ⇒ Object
Returns the value of attribute long.
20 21 22 |
# File 'lib/mirah/ast/type.rb', line 20 def long @long end |
#short ⇒ Object
Returns the value of attribute short.
19 20 21 |
# File 'lib/mirah/ast/type.rb', line 19 def short @short end |
Instance Method Details
#compile(compiler, expression) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/mirah/compiler/type.rb', line 19 def compile(compiler, expression) # TODO: what does it mean for import to be an expression? compiler.import(short, long) rescue Exception => ex raise Mirah::InternalCompilerError.wrap(ex, self) end |
#infer(typer, expression) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/mirah/ast/type.rb', line 31 def infer(typer, expression) resolve_if(typer) do scope.static_scope.import(long, short) typer.type_reference(scope, @long) if short != '*' typer.no_type end end |
#to_s ⇒ Object
27 28 29 |
# File 'lib/mirah/ast/type.rb', line 27 def to_s "Import(#{short} = #{long})" end |