Class: Rubex::AST::Expression::CVarElementRef
Instance Attribute Summary
Attributes inherited from Base
#entry, #type, #typecast
Instance Method Summary
collapse
#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_disposal_code, #has_temp, #possible_typecast, #release_temp, #release_temps, #to_ruby_object
Instance Method Details
#analyse_types(local_scope) ⇒ Object
5
6
7
8
9
10
11
|
# File 'lib/rubex/ast/expression/analysed_element_ref/c_var_element_ref.rb', line 5
def analyse_types(local_scope)
if @pos.size > 1
raise "C array can only accept 1 arg. Not #{@pos.size}"
end
@pos.analyse_types local_scope
@subexprs << @pos
end
|
#generate_assignment_code(rhs, code, local_scope) ⇒ Object
23
24
25
26
27
28
29
|
# File 'lib/rubex/ast/expression/analysed_element_ref/c_var_element_ref.rb', line 23
def generate_assignment_code(rhs, code, local_scope)
generate_and_dispose_subexprs(code, local_scope) do
code << "#{@entry.c_name}[#{@pos[0].c_code(local_scope)}] = "
code << "#{rhs.c_code(local_scope)};"
code.nl
end
end
|
#generate_element_ref_code(_expr, code, local_scope) ⇒ Object
19
20
21
|
# File 'lib/rubex/ast/expression/analysed_element_ref/c_var_element_ref.rb', line 19
def generate_element_ref_code(_expr, code, local_scope)
generate_evaluation_code code, local_scope
end
|
#generate_evaluation_code(code, local_scope) ⇒ Object
13
14
15
16
17
|
# File 'lib/rubex/ast/expression/analysed_element_ref/c_var_element_ref.rb', line 13
def generate_evaluation_code(code, local_scope)
generate_and_dispose_subexprs(code, local_scope) do
@c_code = "#{@entry.c_name}[#{@pos[0].c_code(local_scope)}]"
end
end
|