Class: AdLint::Cc1::ValueDomainNarrowing

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Conversion, InterpreterMediator, NotifierMediator
Defined in:
lib/adlint/cc1/ctrlexpr.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Conversion

#do_conversion, #do_default_argument_promotion, #do_integer_promotion, #do_usual_arithmetic_conversion, #untyped_pointer_conversion?

Methods included from InterpreterMediator

#constant_expression?, #current_branch, #object_to_pointer, #object_to_variable, #pointer_value_of, #reset_environment, #scalar_value_of, #scalar_value_of_arbitrary, #scalar_value_of_false, #scalar_value_of_null, #scalar_value_of_true, #value_of

Methods included from InterpSyntaxBridge

#_interp_syntax_bridge_

Methods included from InterpObjectBridge

#_interp_object_bridge_

Methods included from ArithmeticAccessor

#arithmetic, #logical_right_shift?

Methods included from FunctionTableMediator

#declare_explicit_function, #declare_implicit_function, #define_anonymous_function, #define_explicit_function

Methods included from VariableTableMediator

#create_tmpvar, #local_variables

Methods included from MemoryPoolMediator

#pointee_of

Constructor Details

#initialize(manip, node, *children) ⇒ ValueDomainNarrowing

Returns a new instance of ValueDomainNarrowing.



567
568
569
570
571
572
573
574
# File 'lib/adlint/cc1/ctrlexpr.rb', line 567

def initialize(manip, node, *children)
  @manipulator     = manip
  @node            = node
  @children        = children
  @original_values = {}
  @narrowed_values = {}
  @result          = nil
end

Instance Attribute Details

#narrowed_valuesObject (readonly)

Returns the value of attribute narrowed_values.



577
578
579
# File 'lib/adlint/cc1/ctrlexpr.rb', line 577

def narrowed_values
  @narrowed_values
end

#nodeObject (readonly)

Returns the value of attribute node.



576
577
578
# File 'lib/adlint/cc1/ctrlexpr.rb', line 576

def node
  @node
end

#resultObject (readonly)

Returns the value of attribute result.



578
579
580
# File 'lib/adlint/cc1/ctrlexpr.rb', line 578

def result
  @result
end

Instance Method Details

#ensure_result_equal_to(val) ⇒ Object



599
600
601
602
603
604
605
# File 'lib/adlint/cc1/ctrlexpr.rb', line 599

def ensure_result_equal_to(val)
  if @result.variable? && @result.designated_by_lvalue?
    if @result.value.scalar? && val.scalar?
      ensure_relation(@result, Operator::EQ, val)
    end
  end
end

#execute!Object



585
586
587
588
589
590
591
592
593
594
595
596
597
# File 'lib/adlint/cc1/ctrlexpr.rb', line 585

def execute!
  @result = do_narrowing
  @children.each do |manip|
    @narrowed_values = manip.narrowed_values.merge(@narrowed_values)
  end
ensure
  if @result && @result.variable?
    notify_variable_value_referred(node, @result)
  end
  if seqp = node.subsequent_sequence_point
    notify_sequence_point_reached(seqp)
  end
end

#load_original_values!(manip) ⇒ Object



580
581
582
583
# File 'lib/adlint/cc1/ctrlexpr.rb', line 580

def load_original_values!(manip)
  @original_values = manip.narrowed_values
  @children.each { |child| child.load_original_values!(manip) }
end