Class: Rubex::AST::Expression::ToRubyObject

Inherits:
CoerceObject show all
Defined in:
lib/rubex/ast/expression.rb

Overview

internal node for converting to ruby object.

Instance Attribute Summary collapse

Attributes inherited from CoerceObject

#expr

Attributes inherited from Base

#typecast

Instance Method Summary collapse

Methods inherited from Base

#allocate_temp, #allocate_temps, #analyse_for_target_type, #analyse_statement, #expression?, #from_ruby_object, #generate_assignment_code, #generate_disposal_code, #generate_evaluation_code, #possible_typecast, #release_temp, #release_temps, #to_ruby_object

Constructor Details

#initialize(expr) ⇒ ToRubyObject

Returns a new instance of ToRubyObject.



916
917
918
919
# File 'lib/rubex/ast/expression.rb', line 916

def initialize expr
  @expr = expr
  @type = Rubex::DataType::RubyObject.new
end

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



914
915
916
# File 'lib/rubex/ast/expression.rb', line 914

def type
  @type
end

Instance Method Details

#c_code(local_scope) ⇒ Object



921
922
923
924
925
# File 'lib/rubex/ast/expression.rb', line 921

def c_code local_scope
  t = @expr.type
  t = (t.c_function? || t.alias_type?) ? t.type : t
  "#{t.to_ruby_object(@expr.c_code(local_scope))}"
end