2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
5 #ifndef ATTRIBUTE_VALUE_H
6 #define ATTRIBUTE_VALUE_H
8 #include "AttributeClasses.h"
15 struct AttributeValue
{
17 target_addr_t address
;
25 DebugInfoEntry
* reference
;
35 attributeClass(ATTRIBUTE_CLASS_UNKNOWN
)
44 void SetToAddress(target_addr_t address
)
47 attributeClass
= ATTRIBUTE_CLASS_ADDRESS
;
48 this->address
= address
;
51 void SetToBlock(const void* data
, off_t length
)
54 attributeClass
= ATTRIBUTE_CLASS_BLOCK
;
56 block
.length
= length
;
59 void SetToConstant(uint64 value
, bool isSigned
)
62 attributeClass
= ATTRIBUTE_CLASS_CONSTANT
;
63 this->constant
= value
;
64 this->isSigned
= isSigned
;
67 void SetToFlag(bool value
)
70 attributeClass
= ATTRIBUTE_CLASS_FLAG
;
74 void SetToLinePointer(off_t value
)
77 attributeClass
= ATTRIBUTE_CLASS_LINEPTR
;
78 this->pointer
= value
;
81 void SetToLocationListPointer(off_t value
)
84 attributeClass
= ATTRIBUTE_CLASS_LOCLISTPTR
;
85 this->pointer
= value
;
88 void SetToMacroPointer(off_t value
)
91 attributeClass
= ATTRIBUTE_CLASS_MACPTR
;
92 this->pointer
= value
;
95 void SetToRangeListPointer(off_t value
)
98 attributeClass
= ATTRIBUTE_CLASS_RANGELISTPTR
;
99 this->pointer
= value
;
102 void SetToReference(DebugInfoEntry
* entry
)
105 attributeClass
= ATTRIBUTE_CLASS_REFERENCE
;
106 this->reference
= entry
;
109 void SetToString(const char* string
)
112 attributeClass
= ATTRIBUTE_CLASS_STRING
;
113 this->string
= string
;
118 attributeClass
= ATTRIBUTE_CLASS_UNKNOWN
;
121 const char* ToString(char* buffer
, size_t size
);
125 struct DynamicAttributeValue
{
128 DebugInfoEntry
* reference
;
134 uint8 attributeClass
;
136 DynamicAttributeValue()
138 attributeClass(ATTRIBUTE_CLASS_UNKNOWN
)
145 return attributeClass
!= ATTRIBUTE_CLASS_UNKNOWN
;
148 void SetTo(uint64 constant
)
150 this->constant
= constant
;
151 attributeClass
= ATTRIBUTE_CLASS_CONSTANT
;
154 void SetTo(DebugInfoEntry
* reference
)
156 this->reference
= reference
;
157 attributeClass
= ATTRIBUTE_CLASS_REFERENCE
;
160 void SetTo(const void* data
, off_t length
)
163 block
.length
= length
;
164 attributeClass
= ATTRIBUTE_CLASS_BLOCK
;
169 struct ConstantAttributeValue
{
178 uint8 attributeClass
;
180 ConstantAttributeValue()
182 attributeClass(ATTRIBUTE_CLASS_UNKNOWN
)
188 return attributeClass
!= ATTRIBUTE_CLASS_UNKNOWN
;
191 void SetTo(uint64 constant
)
193 this->constant
= constant
;
194 attributeClass
= ATTRIBUTE_CLASS_CONSTANT
;
197 void SetTo(const char* string
)
199 this->string
= string
;
200 attributeClass
= ATTRIBUTE_CLASS_STRING
;
203 void SetTo(const void* data
, off_t length
)
206 block
.length
= length
;
207 attributeClass
= ATTRIBUTE_CLASS_BLOCK
;
212 struct MemberLocation
{
221 uint8 attributeClass
;
225 attributeClass(ATTRIBUTE_CLASS_UNKNOWN
)
231 return attributeClass
!= ATTRIBUTE_CLASS_UNKNOWN
;
234 bool IsConstant() const
236 return attributeClass
== ATTRIBUTE_CLASS_CONSTANT
;
239 bool IsExpression() const
241 return attributeClass
== ATTRIBUTE_CLASS_BLOCK
242 && expression
.data
!= NULL
;
245 bool IsLocationList() const
247 return attributeClass
== ATTRIBUTE_CLASS_LOCLISTPTR
;
250 void SetToConstant(uint64 constant
)
252 this->constant
= constant
;
253 attributeClass
= ATTRIBUTE_CLASS_CONSTANT
;
256 void SetToExpression(const void* data
, off_t length
)
258 expression
.data
= data
;
259 expression
.length
= length
;
260 attributeClass
= ATTRIBUTE_CLASS_BLOCK
;
263 void SetToLocationList(off_t listOffset
)
265 this->listOffset
= listOffset
;
266 attributeClass
= ATTRIBUTE_CLASS_LOCLISTPTR
;
271 struct LocationDescription
{
273 off_t listOffset
; // location list
277 } expression
; // location expression
279 uint8 attributeClass
;
281 LocationDescription()
283 attributeClass(ATTRIBUTE_CLASS_BLOCK
)
285 expression
.data
= NULL
;
286 expression
.length
= 0;
289 bool IsExpression() const
291 return attributeClass
== ATTRIBUTE_CLASS_BLOCK
292 && expression
.data
!= NULL
;
295 bool IsLocationList() const
297 return attributeClass
== ATTRIBUTE_CLASS_LOCLISTPTR
;
302 return IsExpression() || IsLocationList();
305 void SetToLocationList(off_t offset
)
308 attributeClass
= ATTRIBUTE_CLASS_LOCLISTPTR
;
311 void SetToExpression(const void* data
, off_t length
)
313 expression
.data
= data
;
314 expression
.length
= length
;
315 attributeClass
= ATTRIBUTE_CLASS_BLOCK
;
320 struct DeclarationLocation
{
325 DeclarationLocation()
333 void SetFile(uint32 file
)
338 void SetLine(uint32 line
)
343 void SetColumn(uint32 column
)
345 this->column
= column
;
348 bool IsFileSet() const
350 return file
!= 0xffffffff;
353 bool IsLineSet() const
355 return line
!= 0xffffffff;
358 bool IsColumnSet() const
360 return column
!= 0xffffffff;
364 #endif // ATTRIBUTE_VALUE_H