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

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

Overview

internal node for converting to ruby object.

Instance Attribute Summary collapse

Attributes inherited from CoerceObject

#expr

Attributes inherited from Base

#entry, #typecast

Instance Method Summary collapse

Methods inherited from Base

#allocate_temp, #allocate_temps, #analyse_for_target_type, #analyse_types, #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(expr) ⇒ ToRubyObject

Returns a new instance of ToRubyObject.



9
10
11
12
# File 'lib/rubex/ast/expression/to_ruby_object.rb', line 9

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

Instance Attribute Details

#typeObject (readonly)

attr_reader :expr



7
8
9
# File 'lib/rubex/ast/expression/to_ruby_object.rb', line 7

def type
  @type
end

Instance Method Details

#c_code(local_scope) ⇒ Object



14
15
16
17
18
# File 'lib/rubex/ast/expression/to_ruby_object.rb', line 14

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)).to_s
end