Module: AdLint::Cc1::MemoryPoolMediator

Extended by:
Forwardable
Included in:
Environment, InterpreterMediator
Defined in:
lib/adlint/cc1/mediator.rb

Instance Method Summary collapse

Instance Method Details

#pointee_of(ptr) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/adlint/cc1/mediator.rb', line 70

def pointee_of(ptr)
  # FIXME: This method should return multiple objects, because domain of
  #        the pointer_value may have multiple address values.
  #
  # ptr.value.to_enum.map { |addr|
  #   mem = memory_at(addr) ? mem.binding.object : nil
  # }.compact

  if ptr.value.definite?
    if addr = ptr.value.to_enum.first and mem = memory_at(addr)
      obj = mem.binding.object
      if obj.variable? or
          obj.function? && ptr.type.unqualify.base_type.function?
        return obj
      end
    end
  end
  nil
end