Class: Rubex::AST::Expression::RubyConstant
- Defined in:
- lib/rubex/ast/expression/ruby_constant.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #analyse_types(_local_scope) ⇒ Object
- #c_code(local_scope) ⇒ Object
-
#initialize(name) ⇒ RubyConstant
constructor
A new instance of RubyConstant.
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, #generate_evaluation_code, #has_temp, #possible_typecast, #release_temp, #release_temps, #to_ruby_object
Constructor Details
#initialize(name) ⇒ RubyConstant
Returns a new instance of RubyConstant.
5 6 7 |
# File 'lib/rubex/ast/expression/ruby_constant.rb', line 5 def initialize(name) @name = name end |
Instance Method Details
#analyse_types(_local_scope) ⇒ Object
9 10 11 12 13 |
# File 'lib/rubex/ast/expression/ruby_constant.rb', line 9 def analyse_types(_local_scope) @type = Rubex::DataType::RubyConstant.new @name c_name = Rubex::DEFAULT_CLASS_MAPPINGS[@name] @entry = Rubex::SymbolTable::Entry.new @name, c_name, @type, nil end |
#c_code(local_scope) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/rubex/ast/expression/ruby_constant.rb', line 15 def c_code(local_scope) if @entry.c_name # built-in constant. @entry.c_name else "rb_const_get(CLASS_OF(#{local_scope.self_name}), rb_intern(\"#{@entry.name}\"))" end end |