Class: Mirah::AST::Array

Inherits:
Node
  • Object
show all
Defined in:
lib/mirah/ast/literal.rb,
lib/mirah/compiler/literal.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, line_number, &block) ⇒ Array

Returns a new instance of Array.



18
19
20
# File 'lib/mirah/ast/literal.rb', line 18

def initialize(parent, line_number, &block)
  super(parent, line_number, &block)
end

Instance Method Details

#compile(compiler, expression) ⇒ Object



90
91
92
93
94
# File 'lib/mirah/compiler/literal.rb', line 90

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

#infer(typer, expression) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/mirah/ast/literal.rb', line 22

def infer(typer, expression)
  resolve_if(typer) do
    children.each do |kid|
      kid.infer(typer, true)
    end
    @inferred_type = typer.array_type
  end
end