Class: Rubex::AST::Expression::UnarySub
- Defined in:
- lib/rubex/ast/expression/unary_base/unary_sub.rb
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from UnaryBase
#analyse_types, #generate_evaluation_code, #initialize
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
This class inherits a constructor from Rubex::AST::Expression::UnaryBase
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/rubex/ast/expression/unary_base/unary_sub.rb', line 5 def type @type end |
Instance Method Details
#c_code(local_scope) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/rubex/ast/expression/unary_base/unary_sub.rb', line 7 def c_code(local_scope) code = @expr.c_code(local_scope) if @type.object? "rb_funcall(#{code}, rb_intern(\"-\"), 0)" else "-#{code}" end end |