Class: Rubex::AST::Expression::RubyArrayElementRef

Inherits:
RubyObjectElementRef show all
Defined in:
lib/rubex/ast/expression/ruby_object_element_ref/ruby_array_element_ref.rb

Instance Attribute Summary

Attributes inherited from Base

#entry, #type, #typecast

Instance Method Summary collapse

Methods inherited from RubyObjectElementRef

#generate_assignment_code, #generate_element_ref_code

Methods inherited from AnalysedElementRef

#c_code, #initialize

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, #has_temp, #possible_typecast, #release_temp, #release_temps, #to_ruby_object

Constructor Details

This class inherits a constructor from Rubex::AST::Expression::AnalysedElementRef

Instance Method Details

#analyse_types(local_scope) ⇒ Object



5
6
7
8
9
# File 'lib/rubex/ast/expression/ruby_object_element_ref/ruby_array_element_ref.rb', line 5

def analyse_types(local_scope)
  @has_temp = true
  @pos.analyse_types local_scope
  @subexprs << @pos
end

#generate_evaluation_code(code, local_scope) ⇒ Object

FIXME: If there are multiple arguments specified for array_ref,

we cannot use RARRAY_REF.


13
14
15
16
17
18
19
# File 'lib/rubex/ast/expression/ruby_object_element_ref/ruby_array_element_ref.rb', line 13

def generate_evaluation_code(code, local_scope)
  generate_and_dispose_subexprs(code, local_scope) do
    code << "#{@c_code} = RARRAY_AREF(#{@entry.c_name},"
    code << "#{@pos[0].c_code(local_scope)});"
    code.nl
  end
end