Class: Mirah::AST::EmptyArray

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

Instance Attribute Summary collapse

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(*args) ⇒ EmptyArray

Returns a new instance of EmptyArray.



128
129
130
# File 'lib/mirah/ast/type.rb', line 128

def initialize(*args)
  super(*args)
end

Instance Attribute Details

#component_typeObject

Returns the value of attribute component_type.



124
125
126
# File 'lib/mirah/ast/type.rb', line 124

def component_type
  @component_type
end

#sizeObject

Returns the value of attribute size.



123
124
125
# File 'lib/mirah/ast/type.rb', line 123

def size
  @size
end

Instance Method Details

#compile(compiler, expression) ⇒ Object



109
110
111
112
113
114
115
116
# File 'lib/mirah/compiler/literal.rb', line 109

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

#infer(typer, expression) ⇒ Object



132
133
134
135
136
137
138
# File 'lib/mirah/ast/type.rb', line 132

def infer(typer, expression)
  resolve_if(typer) do
    @component_type = type_node.type_reference(typer)
    typer.infer(size, true)
    typer.type_reference(nil, @component_type, true)
  end
end