Class: Rubex::AST::Expression::ElementRef

Inherits:
Base
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/rubex/ast/expression/element_ref.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#type, #typecast

Instance Method Summary collapse

Methods inherited from Base

#allocate_temp, #allocate_temps, #analyse_for_target_type, #c_code, #expression?, #from_ruby_object, #generate_and_dispose_subexprs, #generate_assignment_code, #generate_disposal_code, #generate_evaluation_code, #has_temp, #possible_typecast, #release_temp, #release_temps, #to_ruby_object

Constructor Details

#initialize(name, pos) ⇒ ElementRef

Initialize an array_ref. Can be in an expression or variable decl.

Parameters:



19
20
21
22
23
# File 'lib/rubex/ast/expression/element_ref.rb', line 19

def initialize(name, pos)
  @name = name
  @pos = pos
  @subexprs = []
end

Instance Attribute Details

#entryObject (readonly)

Readers needed for accessing elements due to delegator classes.



6
7
8
# File 'lib/rubex/ast/expression/element_ref.rb', line 6

def entry
  @entry
end

#nameObject (readonly)

Readers needed for accessing elements due to delegator classes.



6
7
8
# File 'lib/rubex/ast/expression/element_ref.rb', line 6

def name
  @name
end

#posObject (readonly)

Readers needed for accessing elements due to delegator classes.



6
7
8
# File 'lib/rubex/ast/expression/element_ref.rb', line 6

def pos
  @pos
end

#subexprsObject (readonly)

Readers needed for accessing elements due to delegator classes.



6
7
8
# File 'lib/rubex/ast/expression/element_ref.rb', line 6

def subexprs
  @subexprs
end

Instance Method Details

#analyse_types(local_scope, struct_scope = nil) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/rubex/ast/expression/element_ref.rb', line 25

def analyse_types(local_scope, struct_scope = nil)
  @entry = struct_scope.nil? ? local_scope.find(@name) : struct_scope[@name]
  @type = @entry.type.object? ? @entry.type : @entry.type.type
  @element_ref = proper_analysed_type
  @element_ref.analyse_types local_scope
  super(local_scope)
end