Class: Rubex::AST::Expression::Literal::False

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

Instance Attribute Summary

Attributes inherited from Base

#entry, #type, #typecast

Instance Method Summary collapse

Methods inherited from Base

#==, #c_name, #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

#initialize(name) ⇒ False

Returns a new instance of False.



6
7
8
# File 'lib/rubex/ast/expression/literal/false.rb', line 6

def initialize(name)
  super
end

Instance Method Details

#analyse_for_target_type(target_type, _local_scope) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/rubex/ast/expression/literal/false.rb', line 10

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

#analyse_types(_local_scope) ⇒ Object



18
19
20
# File 'lib/rubex/ast/expression/literal/false.rb', line 18

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

#c_code(_local_scope) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/rubex/ast/expression/literal/false.rb', line 22

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