/* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ #include "PointerToMemberValueNode.h" #include #include "Architecture.h" #include "IntegerValue.h" #include "Tracing.h" #include "Type.h" #include "ValueLoader.h" #include "ValueLocation.h" PointerToMemberValueNode::PointerToMemberValueNode(ValueNodeChild* nodeChild, PointerToMemberType* type) : ChildlessValueNode(nodeChild), fType(type) { fType->AcquireReference(); } PointerToMemberValueNode::~PointerToMemberValueNode() { fType->ReleaseReference(); } Type* PointerToMemberValueNode::GetType() const { return fType; } status_t PointerToMemberValueNode::ResolvedLocationAndValue(ValueLoader* valueLoader, ValueLocation*& _location, Value*& _value) { // get the location ValueLocation* location = NodeChild()->Location(); if (location == NULL) return B_BAD_VALUE; TRACE_LOCALS(" TYPE_POINTER_TO_MEMBER\n"); // get the value type type_code valueType; if (valueLoader->GetArchitecture()->AddressSize() == 4) { valueType = B_UINT32_TYPE; TRACE_LOCALS(" -> 32 bit\n"); } else { valueType = B_UINT64_TYPE; TRACE_LOCALS(" -> 64 bit\n"); } // load the value data BVariant valueData; status_t error = valueLoader->LoadValue(location, valueType, false, valueData); if (error != B_OK) return error; // create the type object Value* value = new(std::nothrow) IntegerValue(valueData); if (value == NULL) return B_NO_MEMORY; location->AcquireReference(); _location = location; _value = value; return B_OK; }