Class: Duby::AST::EmptyArray

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

Instance Attribute Summary collapse

Attributes inherited from Node

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

Instance Method Summary collapse

Methods inherited from Node

#<<, ===, #[], #_set_parent, child, child_name, #each, #empty?, #expr?, #initialize_copy, #insert, #inspect, #line_number, #log, #precompile, #resolve_if, #resolved!, #resolved?, #simple_name, #temp, #to_s

Constructor Details

#initialize(parent, line_number, type, &block) ⇒ EmptyArray

Returns a new instance of EmptyArray.



78
79
80
81
82
83
84
85
# File 'lib/duby/ast/type.rb', line 78

def initialize(parent, line_number, type, &block)
  super(parent, line_number, [])
  @component_type = type
  @size = size
  @inferred_type = Duby::AST::type(type.name, true)

  @size = yield(self)
end

Instance Attribute Details

#component_typeObject

Returns the value of attribute component_type.



77
78
79
# File 'lib/duby/ast/type.rb', line 77

def component_type
  @component_type
end

#sizeObject

Returns the value of attribute size.



76
77
78
# File 'lib/duby/ast/type.rb', line 76

def size
  @size
end

Instance Method Details

#compile(compiler, expression) ⇒ Object



260
261
262
263
264
265
# File 'lib/duby/compiler.rb', line 260

def compile(compiler, expression)
  if expression
    compiler.line(line_number)
    compiler.empty_array(component_type, size)
  end
end

#infer(typer) ⇒ Object



87
88
89
90
91
# File 'lib/duby/ast/type.rb', line 87

def infer(typer)
  typer.infer(size)
  resolved!
  return @inferred_type
end