Class: Rubex::AST::Expression::BinaryExpo
- Defined in:
- lib/rubex/ast/expression/binary/binary_expo.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Binary
Methods inherited from Base
#allocate_temp, #allocate_temps, #analyse_for_target_type, #c_code, #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
This class inherits a constructor from Rubex::AST::Expression::Binary
Instance Method Details
#analyse_types(local_scope) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/rubex/ast/expression/binary/binary_expo.rb', line 5 def analyse_types(local_scope) @left.analyse_types local_scope @right.analyse_types local_scope if type_of(@left).object? || type_of(@right).object? @left = @left.to_ruby_object @right = @right.to_ruby_object @subexprs << @left @subexprs << @right else @type = Rubex::DataType::F64.new end end |
#generate_evaluation_code(code, local_scope) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rubex/ast/expression/binary/binary_expo.rb', line 19 def generate_evaluation_code code, local_scope generate_and_dispose_subexprs(code, local_scope) do if @type.object? code << "#{@c_code} = rb_funcall(#{@left.c_code(local_scope)}," + "rb_intern(\"#{@operator}\")," + "1, #{@right.c_code(local_scope)});" code.nl else @c_code = "( pow(#{@left.c_code(local_scope)}, #{@right.c_code(local_scope)}) )" end end end |