1 /* 2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7 #include "PointerToMemberValueNode.h" 8 9 #include <new> 10 11 #include "Architecture.h" 12 #include "IntegerValue.h" 13 #include "Tracing.h" 14 #include "Type.h" 15 #include "ValueLoader.h" 16 #include "ValueLocation.h" 17 18 19 PointerToMemberValueNode::PointerToMemberValueNode(ValueNodeChild* nodeChild, 20 PointerToMemberType* type) 21 : 22 ChildlessValueNode(nodeChild), 23 fType(type) 24 { 25 fType->AcquireReference(); 26 } 27 28 29 PointerToMemberValueNode::~PointerToMemberValueNode() 30 { 31 fType->ReleaseReference(); 32 } 33 34 35 Type* 36 PointerToMemberValueNode::GetType() const 37 { 38 return fType; 39 } 40 41 42 status_t 43 PointerToMemberValueNode::ResolvedLocationAndValue(ValueLoader* valueLoader, 44 ValueLocation*& _location, Value*& _value) 45 { 46 // get the location 47 ValueLocation* location = NodeChild()->Location(); 48 if (location == NULL) 49 return B_BAD_VALUE; 50 51 TRACE_LOCALS(" TYPE_POINTER_TO_MEMBER\n"); 52 53 // get the value type 54 type_code valueType; 55 if (valueLoader->GetArchitecture()->AddressSize() == 4) { 56 valueType = B_UINT32_TYPE; 57 TRACE_LOCALS(" -> 32 bit\n"); 58 } else { 59 valueType = B_UINT64_TYPE; 60 TRACE_LOCALS(" -> 64 bit\n"); 61 } 62 63 // load the value data 64 BVariant valueData; 65 status_t error = valueLoader->LoadValue(location, valueType, false, 66 valueData); 67 if (error != B_OK) 68 return error; 69 70 // create the type object 71 Value* value = new(std::nothrow) IntegerValue(valueData); 72 if (value == NULL) 73 return B_NO_MEMORY; 74 75 location->AcquireReference(); 76 _location = location; 77 _value = value; 78 return B_OK; 79 } 80