Class: Rubex::AST::Expression::BinaryBooleanSpecialOp

Inherits:
BinaryBoolean show all
Defined in:
lib/rubex/ast/expression/binary/binary_boolean_special_op.rb

Direct Known Subclasses

BinaryBoolAnd, BinaryBoolOr

Instance Attribute Summary

Attributes inherited from Base

#entry, #type, #typecast

Instance Method Summary collapse

Methods inherited from BinaryBoolean

#analyse_types

Methods inherited from Binary

#==, #analyse_types, #c_code, #initialize

Methods inherited from Base

#allocate_temp, #allocate_temps, #analyse_for_target_type, #analyse_types, #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

#generate_evaluation_code(code, local_scope) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/rubex/ast/expression/binary/binary_boolean_special_op.rb', line 5

def generate_evaluation_code(code, local_scope)
  generate_and_dispose_subexprs(code, local_scope) do
    if @has_temp
      code << "#{@c_code} = " + Rubex::C_MACRO_INT2BOOL +
        "(RTEST(#{@left.c_code(local_scope)}) #{@operator} " \
        "RTEST(#{@right.c_code(local_scope)}));"
      code.nl
    else
      @c_code = "#{@left.c_code(local_scope)} #{@operator} #{@right.c_code(local_scope)}"
    end
  end
end