Class: Mirah::AST::Constant
- Defined in:
- lib/mirah/ast/class.rb,
lib/mirah/compiler/class.rb
Instance Attribute Summary collapse
-
#array ⇒ Object
Returns the value of attribute array.
Attributes included from Named
Attributes inherited from Node
#children, #inferred_type, #newline, #parent, #position
Instance Method Summary collapse
- #compile(compiler, expression) ⇒ Object
- #infer(typer, expression) ⇒ Object
-
#initialize(parent, position, name) ⇒ Constant
constructor
A new instance of Constant.
- #type_reference(typer) ⇒ Object
Methods included from Scoped
Methods included from Named
#string_value, #to_s, #validate_name
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, position, name) ⇒ Constant
Returns a new instance of Constant.
335 336 337 338 |
# File 'lib/mirah/ast/class.rb', line 335 def initialize(parent, position, name) self.name = name super(parent, position, []) end |
Instance Attribute Details
#array ⇒ Object
Returns the value of attribute array.
333 334 335 |
# File 'lib/mirah/ast/class.rb', line 333 def array @array end |
Instance Method Details
#compile(compiler, expression) ⇒ Object
71 72 73 74 75 76 77 78 |
# File 'lib/mirah/compiler/class.rb', line 71 def compile(compiler, expression) if expression compiler.line(line_number) compiler.constant(self) end rescue Exception => ex raise Mirah::InternalCompilerError.wrap(ex, self) end |
#infer(typer, expression) ⇒ Object
340 341 342 343 344 345 |
# File 'lib/mirah/ast/class.rb', line 340 def infer(typer, expression) @inferred_type ||= begin # TODO lookup constant, inline if we're supposed to. typer.type_reference(scope, name, @array, true) end end |
#type_reference(typer) ⇒ Object
347 348 349 |
# File 'lib/mirah/ast/class.rb', line 347 def type_reference(typer) typer.type_reference(scope, @name, @array) end |