Class: Rubex::AST::Expression::Colon2

Inherits:
Base
  • Object
show all
Defined in:
lib/rubex/ast/expression/binary/colon2.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#entry, #type, #typecast

Instance Method Summary collapse

Methods inherited from Base

#allocate_temp, #allocate_temps, #analyse_for_target_type, #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

#initialize(lhs, rhs) ⇒ Colon2

Returns a new instance of Colon2.



7
8
9
10
# File 'lib/rubex/ast/expression/binary/colon2.rb', line 7

def initialize lhs, rhs
  @lhs = lhs
  @rhs = rhs
end

Instance Attribute Details

#lhsObject (readonly)

Returns the value of attribute lhs.



5
6
7
# File 'lib/rubex/ast/expression/binary/colon2.rb', line 5

def lhs
  @lhs
end

#rhsObject (readonly)

Returns the value of attribute rhs.



5
6
7
# File 'lib/rubex/ast/expression/binary/colon2.rb', line 5

def rhs
  @rhs
end

Instance Method Details

#analyse_types(local_scope) ⇒ Object



12
13
14
# File 'lib/rubex/ast/expression/binary/colon2.rb', line 12

def analyse_types local_scope
  @type = DataType::RubyObject.new
end

#c_code(local_scope) ⇒ Object



28
29
30
# File 'lib/rubex/ast/expression/binary/colon2.rb', line 28

def c_code local_scope
  super + @c_code
end

#generate_evaluation_code(code, local_scope) ⇒ Object



16
17
18
# File 'lib/rubex/ast/expression/binary/colon2.rb', line 16

def generate_evaluation_code code, local_scope
  @c_code = recursive_scoping_generation @lhs, @rhs, "rb_const_get(CLASS_OF(#{local_scope.self_name}), rb_intern(\"#{@lhs}\"))"
end

#recursive_scoping_generation(lhs, rhs, c_str) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/rubex/ast/expression/binary/colon2.rb', line 20

def recursive_scoping_generation lhs, rhs, c_str
  if rhs.is_a?(Colon2)
    recursive_scoping_generation rhs.lhs, rhs.rhs, "rb_const_get(#{c_str}, rb_intern(\"#{rhs.lhs}\"))"
  else
    "rb_const_get(#{c_str}, rb_intern(\"#{rhs}\"))"
  end
end