Class: Rubex::AST::Expression::Literal::True

Inherits:
Base
  • Object
show all
Defined in:
lib/rubex/ast/expression/literal/true.rb

Instance Attribute Summary

Attributes inherited from Base

#entry, #type, #typecast

Instance Method Summary collapse

Methods inherited from Base

#==, #c_name, #initialize, #literal?

Methods inherited from Base

#allocate_temp, #allocate_temps, #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::Literal::Base

Instance Method Details

#analyse_for_target_type(target_type, _local_scope) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/rubex/ast/expression/literal/true.rb', line 6

def analyse_for_target_type(target_type, _local_scope)
  @type = if target_type.object?
            Rubex::DataType::TrueType.new
          else
            Rubex::DataType::CBoolean.new
          end
end

#analyse_types(_local_scope) ⇒ Object



14
15
16
# File 'lib/rubex/ast/expression/literal/true.rb', line 14

def analyse_types(_local_scope)
  @type = Rubex::DataType::TrueType.new
end

#c_code(_local_scope) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/rubex/ast/expression/literal/true.rb', line 18

def c_code(_local_scope)
  if @type.object?
    @name
  else
    '1'
  end
end