Class: Mirah::AST::BindingReference

Inherits:
Node
  • Object
show all
Defined in:
lib/mirah/ast/structure.rb,
lib/mirah/compiler/structure.rb

Instance Attribute Summary

Attributes inherited from Node

#children, #inferred_type, #newline, #parent, #position

Instance Method Summary collapse

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, type) ⇒ BindingReference

Returns a new instance of BindingReference.



233
234
235
236
# File 'lib/mirah/ast/structure.rb', line 233

def initialize(parent, position, type)
  super(parent, position)
  @inferred_type = type
end

Instance Method Details

#compile(compiler, expression) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/mirah/compiler/structure.rb', line 37

def compile(compiler, expression)
  if expression
    compiler.line(line_number)
    compiler.binding_reference
  end
rescue Exception => ex
  raise Mirah::InternalCompilerError.wrap(ex, self)
end

#infer(typer, expression) ⇒ Object



238
239
240
241
# File 'lib/mirah/ast/structure.rb', line 238

def infer(typer, expression)
  resolved! unless resolved?
  @inferred_type
end