My Project
type.hh
Go to the documentation of this file.
1 /* ###
2  * IP: GHIDRA
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
18 
19 #ifndef __CPUI_TYPE__
20 #define __CPUI_TYPE__
21 
22 #include "address.hh"
23 
25 extern void print_data(ostream &s,uint1 *buffer,int4 size,const Address &baseaddr);
26 //extern void print_char(ostream &s,int4 onechar);
27 //extern bool print_string(ostream &s,uint1 *buffer,int4 size);
28 
34  TYPE_VOID = 10,
37  TYPE_INT = 7,
38  TYPE_UINT = 6,
39  TYPE_BOOL = 5,
40  TYPE_CODE = 4,
41  TYPE_FLOAT = 3,
42 
43  TYPE_PTR = 2,
44  TYPE_ARRAY = 1,
46 };
47 
49 extern void metatype2string(type_metatype metatype,string &res);
50 
52 extern type_metatype string2metatype(const string &metastring);
53 
54 class Architecture; // Forward declarations
55 class Scope;
56 class TypeFactory;
57 struct DatatypeCompare;
58 
62 class Datatype {
63 protected:
65  enum {
66  coretype = 1,
67  // Bits above the first bit are considered a sub-metatype
68  // If the metatypes are equal, we compare on sub-metatype
69  // Currently this is only used to order int, char, and enum
70  // The order of the sub-metatype is reversed so that
71  // char comes before int1
72  chartype = 2,
73  enumtype = 4,
74  poweroftwo = 8,
75  utf16 = 16,
76  utf32 = 32
77  };
78  friend class TypeFactory;
79  friend struct DatatypeCompare;
80  int4 size;
81  string name;
83  uint4 flags;
84  uint8 id;
85  void restoreXmlBasic(const Element *el);
86  virtual void restoreXml(const Element *el,TypeFactory &typegrp);
87  static uint8 hashName(const string &nm);
88 public:
90  Datatype(const Datatype &op) { size = op.size; name=op.name; metatype=op.metatype; flags=op.flags; id=op.id; }
92  Datatype(int4 s,type_metatype m) { size=s; metatype=m; flags=0; id=0; }
94  Datatype(int4 s,type_metatype m,const string &n) { name=n; size=s; metatype=m; flags=0; id=0; }
95  virtual ~Datatype(void) {}
96  bool isCoreType(void) const { return ((flags&coretype)!=0); }
97  bool isCharPrint(void) const { return ((flags&(chartype|utf16|utf32))!=0); }
98  bool isEnumType(void) const { return ((flags&enumtype)!=0); }
99  bool isPowerOfTwo(void) const { return ((flags&poweroftwo)!=0); }
100  bool isASCII(void) const { return ((flags&chartype)!=0); }
101  bool isUTF16(void) const { return ((flags&utf16)!=0); }
102  bool isUTF32(void) const { return ((flags&utf32)!=0); }
103  uint4 getInheritable(void) const { return (flags & coretype); }
104  type_metatype getMetatype(void) const { return metatype; }
105  uint8 getId(void) const { return id; }
106  int4 getSize(void) const { return size; }
107  const string &getName(void) const { return name; }
108  virtual void printRaw(ostream &s) const;
109  virtual Datatype *getSubType(uintb off,uintb *newoff) const;
110  virtual int4 numDepend(void) const { return 0; }
111  virtual Datatype *getDepend(int4 index) const { return (Datatype *)0; }
112  virtual void printNameBase(ostream &s) const { if (!name.empty()) s<<name[0]; }
113  virtual int4 compare(const Datatype &op,int4 level) const;
114  virtual int4 compareDependency(const Datatype &op) const;
115  virtual Datatype *clone(void) const=0;
116  virtual void saveXml(ostream &s) const;
117  int4 typeOrder(const Datatype &op) const { if (this==&op) return 0; return compare(op,10); }
118  int4 typeOrderBool(const Datatype &op) const;
119  void saveXmlBasic(ostream &s) const;
120  void saveXmlRef(ostream &s) const;
121 };
122 
124 struct TypeField {
125  int4 offset;
126  string name;
128  bool operator<(const TypeField &op2) const { return (offset < op2.offset); }
129 };
130 
134  bool operator()(const Datatype *a,const Datatype *b) const {
135  int4 res = a->compareDependency(*b);
136  if (res != 0) return (res<0);
137  return a->getId() < b->getId(); }
138 };
139 
143  bool operator()(const Datatype *a,const Datatype *b) const {
144  int4 res = a->getName().compare( b->getName() );
145  if (res != 0) return (res < 0);
146  return a->getId() < b->getId(); }
147 };
148 
150 typedef set<Datatype *,DatatypeCompare> DatatypeSet;
151 
153 typedef set<Datatype *,DatatypeNameCompare> DatatypeNameSet;
154 
158 class TypeBase : public Datatype {
159 protected:
160  friend class TypeFactory;
161 public:
163  TypeBase(const TypeBase &op) : Datatype(op) {}
165  TypeBase(int4 s,type_metatype m) : Datatype(s,m) {}
167  TypeBase(int4 s,type_metatype m,const string &n) : Datatype(s,m,n) {}
168  virtual Datatype *clone(void) const { return new TypeBase(*this); }
169 };
170 
174 class TypeChar : public TypeBase {
175 protected:
176  friend class TypeFactory;
177 public:
181  TypeChar(const string &n) : TypeBase(1,TYPE_INT,n) { flags |= Datatype::chartype; }
182  virtual Datatype *clone(void) const { return new TypeChar(*this); }
183  virtual void saveXml(ostream &s) const;
184 };
185 
189 class TypeUnicode : public TypeBase { // Unicode character type
190  void setflags(void);
191 protected:
192  friend class TypeFactory;
193  virtual void restoreXml(const Element *el,TypeFactory &typegrp);
194 public:
196  TypeUnicode(const TypeUnicode &op) : TypeBase(op) {}
197  TypeUnicode(const string &nm,int4 sz,type_metatype m);
198  virtual Datatype *clone(void) const { return new TypeUnicode(*this); }
199  virtual void saveXml(ostream &s) const;
200 };
201 
206 class TypeVoid : public Datatype {
207 protected:
208  friend class TypeFactory;
209 public:
214  virtual Datatype *clone(void) const { return new TypeVoid(*this); }
215  virtual void saveXml(ostream &s) const;
216 };
217 
219 class TypePointer : public Datatype {
220 protected:
221  friend class TypeFactory;
223  uint4 wordsize;
224  virtual void restoreXml(const Element *el,TypeFactory &typegrp);
226  TypePointer(void) : Datatype(0,TYPE_PTR) { ptrto = (Datatype *)0; wordsize=1; }
227 public:
229  TypePointer(const TypePointer &op) : Datatype(op) { ptrto = op.ptrto; wordsize=op.wordsize; }
231  TypePointer(int4 s,Datatype *pt,uint4 ws) : Datatype(s,TYPE_PTR) { ptrto = pt; flags = ptrto->getInheritable(); wordsize=ws; }
232  Datatype *getPtrTo(void) const { return ptrto; }
233  uint4 getWordSize(void) const { return wordsize; }
234  virtual void printRaw(ostream &s) const;
235  virtual int4 numDepend(void) const { return 1; }
236  virtual Datatype *getDepend(int4 index) const { return ptrto; }
237  virtual void printNameBase(ostream &s) const { s << 'p'; ptrto->printNameBase(s); }
238  virtual int4 compare(const Datatype &op,int4 level) const; // For tree structure
239  virtual int4 compareDependency(const Datatype &op) const; // For tree structure
240  virtual Datatype *clone(void) const { return new TypePointer(*this); }
241  virtual void saveXml(ostream &s) const;
242 };
243 
245 class TypeArray : public Datatype {
246 protected:
247  friend class TypeFactory;
249  int4 arraysize;
250  virtual void restoreXml(const Element *el,TypeFactory &typegrp);
252  TypeArray(void) : Datatype(0,TYPE_ARRAY) { arraysize = 0; arrayof = (Datatype *)0; }
253 public:
255  TypeArray(const TypeArray &op) : Datatype(op) { arrayof = op.arrayof; arraysize = op.arraysize; }
257  TypeArray(int4 n,Datatype *ao) : Datatype(n*ao->getSize(),TYPE_ARRAY) {
258  arraysize = n; arrayof = ao; }
259  Datatype *getBase(void) const { return arrayof; }
260  int4 numElements(void) const { return arraysize; }
261  Datatype *getSubEntry(int4 off,int4 sz,int4 *newoff,int4 *el) const;
262  virtual void printRaw(ostream &s) const;
263  virtual Datatype *getSubType(uintb off,uintb *newoff) const;
264  virtual int4 numDepend(void) const { return 1; }
265  virtual Datatype *getDepend(int4 index) const { return arrayof; }
266  virtual void printNameBase(ostream &s) const { s << 'a'; arrayof->printNameBase(s); }
267  virtual int4 compare(const Datatype &op,int4 level) const; // For tree structure
268  virtual int4 compareDependency(const Datatype &op) const; // For tree structure
269  virtual Datatype *clone(void) const { return new TypeArray(*this); }
270  virtual void saveXml(ostream &s) const;
271 };
272 
277 class TypeEnum : public TypeBase {
278 protected:
279  friend class TypeFactory;
280  map<uintb,string> namemap;
281  vector<uintb> masklist;
282  void setNameMap(const map<uintb,string> &nmap);
283  virtual void restoreXml(const Element *el,TypeFactory &typegrp);
284 public:
286  TypeEnum(const TypeEnum &op);
288  TypeEnum(int4 s,type_metatype m) : TypeBase(s,m) { flags |= enumtype; }
290  TypeEnum(int4 s,type_metatype m,const string &nm) : TypeBase(s,m,nm) { flags |= enumtype; }
291  map<uintb,string>::const_iterator beginEnum(void) const { return namemap.begin(); }
292  map<uintb,string>::const_iterator endEnum(void) const { return namemap.end(); }
293  bool getMatches(uintb val,vector<string> &matchname) const;
294  virtual int4 compare(const Datatype &op,int4 level) const;
295  virtual int4 compareDependency(const Datatype &op) const;
296  virtual Datatype *clone(void) const { return new TypeEnum(*this); }
297  virtual void saveXml(ostream &s) const;
298 };
299 
301 class TypeStruct : public Datatype {
302 protected:
303  friend class TypeFactory;
304  vector<TypeField> field;
305  void setFields(const vector<TypeField> &fd);
306  int4 getFieldIter(int4 off) const;
307  virtual void restoreXml(const Element *el,TypeFactory &typegrp);
308 public:
309  TypeStruct(const TypeStruct &op);
310  TypeStruct(const string &n) : Datatype(0,TYPE_STRUCT,n) {}
311  vector<TypeField>::const_iterator beginField(void) const { return field.begin(); }
312  vector<TypeField>::const_iterator endField(void) const { return field.end(); }
313  const TypeField *getField(int4 off,int4 sz,int4 *newoff) const;
314  virtual Datatype *getSubType(uintb off,uintb *newoff) const;
315  virtual int4 numDepend(void) const { return field.size(); }
316  virtual Datatype *getDepend(int4 index) const { return field[index].type; }
317  virtual int4 compare(const Datatype &op,int4 level) const; // For tree structure
318  virtual int4 compareDependency(const Datatype &op) const; // For tree structure
319  virtual Datatype *clone(void) const { return new TypeStruct(*this); }
320  virtual void saveXml(ostream &s) const;
321 };
322 
323 class FuncProto; // Forward declaration
324 class ProtoModel;
325 
329 class TypeCode : public Datatype {
330 protected:
331  friend class TypeFactory;
333  void set(ProtoModel *model,
334  Datatype *outtype,const vector<Datatype *> &intypes,
335  bool dotdotdot,Datatype *voidtype);
336  virtual void restoreXml(const Element *el,TypeFactory &typegrp);
337 public:
338  TypeCode(const TypeCode &op);
339  TypeCode(const string &nm);
340  int4 compareBasic(const TypeCode *op) const;
341  const FuncProto *getPrototype(void) const { return proto; }
342  void setProperties(bool hasThisPtr,bool isConstructor,bool isDestructor);
343  virtual ~TypeCode(void);
344  virtual void printRaw(ostream &s) const;
345  virtual int4 compare(const Datatype &op,int4 level) const;
346  virtual int4 compareDependency(const Datatype &op) const;
347  virtual Datatype *clone(void) const { return new TypeCode(*this); }
348  virtual void saveXml(ostream &s) const;
349 };
350 
356 class TypeSpacebase : public Datatype {
357  friend class TypeFactory;
358  AddrSpace *spaceid;
359  Address localframe;
360  Architecture *glb;
361  virtual void restoreXml(const Element *el,TypeFactory &typegrp);
362 public:
365  spaceid = op.spaceid; localframe=op.localframe; glb=op.glb;
366  }
369  : Datatype(0,TYPE_SPACEBASE), localframe(frame) { spaceid = id; glb = g; }
370  Scope *getMap(void) const;
371  Address getAddress(uintb off,int4 sz,const Address &point) const;
372  virtual Datatype *getSubType(uintb off,uintb *newoff) const;
373  virtual int4 compare(const Datatype &op,int4 level) const;
374  virtual int4 compareDependency(const Datatype &op) const; // For tree structure
375  virtual Datatype *clone(void) const { return new TypeSpacebase(*this); }
376  virtual void saveXml(ostream &s) const;
377 };
378 
380 class TypeFactory {
381  int4 sizeOfInt;
382  int4 align;
383  int4 enumsize;
385  DatatypeSet tree;
386  DatatypeNameSet nametree;
387  Datatype *typecache[9][8];
388  Datatype *typecache10;
389  Datatype *typecache16;
390  Datatype *type_nochar;
391  Datatype *findNoName(Datatype &ct);
392  Datatype *findAdd(Datatype &ct);
393  void orderRecurse(vector<Datatype *> &deporder,DatatypeSet &mark,Datatype *ct) const;
394  Datatype *restoreXmlTypeNoRef(const Element *el,bool forcecore);
395  void clearCache(void);
396  TypeChar *getTypeChar(const string &n);
397  TypeUnicode *getTypeUnicode(const string &nm,int4 sz,type_metatype m);
398  TypeCode *getTypeCode(const string &n);
399 protected:
401  Datatype *findByIdLocal(const string &nm,uint8 id) const;
402  virtual Datatype *findById(const string &n,uint8 id);
403 public:
405  void setupSizes(void);
406  void clear(void);
407  void clearNoncore(void);
408  virtual ~TypeFactory(void);
409  void setStructAlign(int4 al) { align = al; }
410  int4 getStructAlign(void) const { return align; }
411  int4 getSizeOfInt(void) const { return sizeOfInt; }
412  Architecture *getArch(void) const { return glb; }
413  Datatype *findByName(const string &n);
414  Datatype *setName(Datatype *ct,const string &n);
415  bool setFields(vector<TypeField> &fd,TypeStruct *ot,int4 fixedsize);
416  bool setEnumValues(const vector<string> &namelist,
417  const vector<uintb> &vallist,
418  const vector<bool> &assignlist,
419  TypeEnum *te);
420  Datatype *restoreXmlType(const Element *el);
421  Datatype *restoreXmlTypeWithCodeFlags(const Element *el,bool hasThisPtr,bool isConstructor,bool isDestructor);
422  TypeVoid *getTypeVoid(void);
423  Datatype *getBaseNoChar(int4 s,type_metatype m);
424  Datatype *getBase(int4 s,type_metatype m);
425  Datatype *getBase(int4 s,type_metatype m,const string &n);
426  TypeCode *getTypeCode(void);
427  TypePointer *getTypePointer(int4 s,Datatype *pt,uint4 ws);
428  TypePointer *getTypePointerAbsolute(int4 s,Datatype *pt,uint4 ws);
429  TypePointer *getTypePointerNoDepth(int4 s,Datatype *pt,uint4 ws);
430  TypeArray *getTypeArray(int4 as,Datatype *ao);
431  TypeStruct *getTypeStruct(const string &n);
432  TypeEnum *getTypeEnum(const string &n);
433  TypeSpacebase *getTypeSpacebase(AddrSpace *id,const Address &addr);
434  TypeCode *getTypeCode(ProtoModel *model,Datatype *outtype,
435  const vector<Datatype *> &intypes,
436  bool dotdotdot);
437  void destroyType(Datatype *ct);
438  Datatype *downChain(Datatype *ptrtype,uintb &off);
439  Datatype *concretize(Datatype *ct);
440  void dependentOrder(vector<Datatype *> &deporder) const;
441  void saveXml(ostream &s) const;
442  void saveXmlCoreTypes(ostream &s) const;
443  void restoreXml(const Element *el);
444  void restoreXmlCoreTypes(const Element *el);
445  void parseDataOrganization(const Element *el);
446  void parseEnumConfig(const Element *el);
447  void setCoreType(const string &name,int4 size,type_metatype meta,bool chartp);
448  void cacheCoreTypes(void);
449 };
450 
457 inline int4 Datatype::typeOrderBool(const Datatype &op) const
458 
459 {
460  if (this == &op) return 0;
461  if (metatype == TYPE_BOOL) return 1; // Never prefer bool over other data-types
462  if (op.metatype == TYPE_BOOL) return -1;
463  return compare(op,10);
464 }
465 
466 #endif
virtual void printNameBase(ostream &s) const
Print name as short prefix.
Definition: type.hh:112
Data is actual executable code.
Definition: type.hh:40
A region where processor data is stored.
Definition: space.hh:73
virtual Datatype * getDepend(int4 index) const
Return the i-th component sub-type.
Definition: type.hh:265
bool isCharPrint(void) const
Does this print as a &#39;char&#39;.
Definition: type.hh:97
An unknown low-level type. Treated as an unsigned integer.
Definition: type.hh:36
string name
Name of type.
Definition: type.hh:81
virtual Datatype * clone(void) const
Clone the data-type.
Definition: type.hh:182
bool isUTF16(void) const
Does this print as UTF16 &#39;wchar&#39;.
Definition: type.hh:101
The base datatype class for the decompiler.
Definition: type.hh:62
bool operator<(const TypeField &op2) const
Compare based on offset.
Definition: type.hh:128
TypeSpacebase(const TypeSpacebase &op)
Construct from another TypeSpacebase.
Definition: type.hh:364
virtual Datatype * getDepend(int4 index) const
Return the i-th component sub-type.
Definition: type.hh:316
map< uintb, string > namemap
Map from integer to name.
Definition: type.hh:280
Signed integer. Signed is considered less specific than unsigned in C.
Definition: type.hh:37
uint4 flags
Boolean properties of the type.
Definition: type.hh:83
type_metatype getMetatype(void) const
Get the type meta-type.
Definition: type.hh:104
A composite Datatype object: A "structure" with component "fields".
Definition: type.hh:301
void metatype2string(type_metatype metatype, string &res)
Convert type meta-type to name.
Definition: type.cc:129
TypeSpacebase(AddrSpace *id, const Address &frame, Architecture *g)
Construct given an address space, scope, and architecture.
Definition: type.hh:368
Base class for the fundamental atomic types.
Definition: type.hh:158
void saveXmlRef(ostream &s) const
Write an XML reference of this to stream.
Definition: type.cc:257
virtual Datatype * getDepend(int4 index) const
Return the i-th component sub-type.
Definition: type.hh:236
virtual Datatype * clone(void) const
Clone the data-type.
Definition: type.hh:319
vector< TypeField >::const_iterator beginField(void) const
Beginning of fields.
Definition: type.hh:311
Datatype object representing a pointer.
Definition: type.hh:219
int4 typeOrder(const Datatype &op) const
Order this with -op- datatype.
Definition: type.hh:117
Pointer data-type.
Definition: type.hh:43
int4 numElements(void) const
Get the number of elements.
Definition: type.hh:260
A prototype model: a model for passing parameters between functions.
Definition: fspec.hh:615
virtual ~Datatype(void)
Destructor.
Definition: type.hh:95
virtual void saveXml(ostream &s) const
Serialize the data-type to XML.
Definition: type.cc:228
void print_data(ostream &s, uint1 *buffer, int4 size, const Address &baseaddr)
Print a hex dump of a data buffer to stream.
Definition: type.cc:27
map< uintb, string >::const_iterator endEnum(void) const
End of name map.
Definition: type.hh:292
set< Datatype *, DatatypeCompare > DatatypeSet
A set of data-types sorted by function.
Definition: type.hh:150
TypeEnum(int4 s, type_metatype m)
Construct from a size and meta-type (TYPE_INT or TYPE_UINT)
Definition: type.hh:288
Unsigned integer.
Definition: type.hh:38
16-bit wide chars in unicode UTF16
Definition: type.hh:75
int4 arraysize
Number of elements in the array.
Definition: type.hh:249
TypeArray(const TypeArray &op)
Construct from another TypeArray.
Definition: type.hh:255
uint4 getInheritable(void) const
Get properties pointers inherit.
Definition: type.hh:103
Specifies subfields of a structure or what a pointer points to.
Definition: type.hh:124
type_metatype
Definition: type.hh:33
TypeBase(int4 s, type_metatype m)
Construct TypeBase from a size and meta-type.
Definition: type.hh:165
Structure data-type, made up of component datatypes.
Definition: type.hh:45
virtual int4 numDepend(void) const
Return number of component sub-types.
Definition: type.hh:264
Floating-point.
Definition: type.hh:41
Datatype * getPtrTo(void) const
Get the pointed-to Datatype.
Definition: type.hh:232
Special Datatype object used to describe pointers that index into the symbol table.
Definition: type.hh:356
Boolean.
Definition: type.hh:39
int4 offset
Offset (into containing struct) of subfield.
Definition: type.hh:125
virtual Datatype * clone(void) const
Clone the data-type.
Definition: type.hh:198
void restoreXmlBasic(const Element *el)
Recover basic data-type properties.
Definition: type.cc:273
Datatype * ptrto
Type being pointed to.
Definition: type.hh:222
uint8 id
A unique id for the type (or 0 if an id is not assigned)
Definition: type.hh:84
vector< TypeField > field
The list of fields.
Definition: type.hh:304
int4 size
Size (of variable holding a value of this type)
Definition: type.hh:80
An enumeration type where all values are of 2^^n form.
Definition: type.hh:74
int4 getStructAlign(void) const
Get the default structure alignment.
Definition: type.hh:410
uint4 getWordSize(void) const
Get the wordsize of the pointer.
Definition: type.hh:233
static uint8 hashName(const string &nm)
Produce a data-type id by hashing the type name.
Definition: type.cc:313
virtual Datatype * clone(void) const
Clone the data-type.
Definition: type.hh:214
Datatype(int4 s, type_metatype m)
Construct the base data-type providing size and meta-type.
Definition: type.hh:92
FuncProto * proto
If non-null, this describes the prototype of the underlying function.
Definition: type.hh:332
type_metatype metatype
Meta-type - type disregarding size.
Definition: type.hh:82
32-bit wide chars in unicode UTF32
Definition: type.hh:76
bool isEnumType(void) const
Is this an enumerated type.
Definition: type.hh:98
bool operator()(const Datatype *a, const Datatype *b) const
Comparison operator.
Definition: type.hh:143
virtual Datatype * clone(void) const
Clone the data-type.
Definition: type.hh:168
const FuncProto * getPrototype(void) const
Get the function prototype.
Definition: type.hh:341
Array data-type, made up of a sequence of "element" datatype.
Definition: type.hh:44
int4 getSize(void) const
Get the type size.
Definition: type.hh:106
Datatype(int4 s, type_metatype m, const string &n)
Construct the base data-type providing size, meta-type, and name.
Definition: type.hh:94
Datatype(const Datatype &op)
Construct the base data-type copying low-level properties of another.
Definition: type.hh:90
bool setFields(vector< TypeField > &fd, TypeStruct *ot, int4 fixedsize)
Set fields on a TypeStruct.
Definition: type.cc:1487
bool isPowerOfTwo(void) const
Is this a flag-based enumeration.
Definition: type.hh:99
A low-level machine address for labelling bytes and data.
Definition: address.hh:46
TypeStruct(const string &n)
Construct empty TypeStruct from a name.
Definition: type.hh:310
virtual void printNameBase(ostream &s) const
Print name as short prefix.
Definition: type.hh:237
bool isUTF32(void) const
Does this print as UTF32 &#39;wchar&#39;.
Definition: type.hh:102
Classes for specifying addresses and other low-level constants.
Placeholder for symbol/type look-up calculations.
Definition: type.hh:35
TypeChar(const TypeChar &op)
Construct TypeChar copying properties from another data-type.
Definition: type.hh:179
Datatype * arrayof
type of which we have an array
Definition: type.hh:248
The unicode data-type: i.e. wchar.
Definition: type.hh:189
Standard "void" type, absence of type.
Definition: type.hh:34
Compare two Datatype pointers: first by name, then by id.
Definition: type.hh:141
Manager for all the major decompiler subsystems.
Definition: architecture.hh:117
TypeBase(int4 s, type_metatype m, const string &n)
Construct TypeBase from a size, meta-type, and name.
Definition: type.hh:167
This is a basic type which will never be redefined.
Definition: type.hh:66
Datatype object representing an array of elements.
Definition: type.hh:245
Compare two Datatype pointers for equivalence of their description.
Definition: type.hh:132
type_metatype string2metatype(const string &metastring)
Convert string to type meta-type.
Definition: type.cc:174
virtual Datatype * getSubType(uintb off, uintb *newoff) const
Recover component data-type one-level down.
Definition: type.cc:86
string name
Name of subfield.
Definition: type.hh:126
Architecture * glb
The Architecture object that owns this TypeFactory.
Definition: type.hh:400
const string & getName(void) const
Get the type name.
Definition: type.hh:107
An XML element. A node in the DOM tree.
Definition: xml.hh:150
void setStructAlign(int4 al)
Set the default structure alignment.
Definition: type.hh:409
uint8 getId(void) const
Get the type id.
Definition: type.hh:105
virtual Datatype * clone(void) const
Clone the data-type.
Definition: type.hh:240
vector< uintb > masklist
Masks for each bitfield within the enum.
Definition: type.hh:281
TypeUnicode(void)
For use with restoreXml.
Definition: type.hh:195
Datatype object representing executable code.
Definition: type.hh:329
virtual void printRaw(ostream &s) const
Print a description of the type to stream.
Definition: type.cc:69
virtual int4 compare(const Datatype &op, int4 level) const
Compare for functional equivalence.
Definition: type.cc:99
virtual Datatype * clone(void) const
Clone the data-type.
Definition: type.hh:347
void saveXmlBasic(ostream &s) const
Save basic data-type properties.
Definition: type.cc:239
bool operator()(const Datatype *a, const Datatype *b) const
Comparison operator.
Definition: type.hh:134
virtual Datatype * clone(void) const
Clone the data-type.
Definition: type.hh:296
virtual Datatype * getDepend(int4 index) const
Return the i-th component sub-type.
Definition: type.hh:111
TypeArray(int4 n, Datatype *ao)
Construct given an array size and element data-type.
Definition: type.hh:257
TypeVoid(const TypeVoid &op)
Construct from another TypeVoid.
Definition: type.hh:211
TypeBase(const TypeBase &op)
Construct TypeBase copying properties from another data-type.
Definition: type.hh:163
vector< TypeField >::const_iterator endField(void) const
End of fields.
Definition: type.hh:312
ASCII character data.
Definition: type.hh:72
virtual int4 numDepend(void) const
Return number of component sub-types.
Definition: type.hh:315
A function prototype.
Definition: fspec.hh:1147
Container class for all Datatype objects in an Architecture.
Definition: type.hh:380
Datatype * getBase(void) const
Get the element data-type.
Definition: type.hh:259
bool isCoreType(void) const
Is this a core data-type.
Definition: type.hh:96
virtual int4 compareDependency(const Datatype &op) const
Compare for storage in tree structure.
Definition: type.cc:110
TypeUnicode(const TypeUnicode &op)
Construct from another TypeUnicode.
Definition: type.hh:196
TypeVoid(void)
Constructor.
Definition: type.hh:213
TypeEnum(int4 s, type_metatype m, const string &nm)
Construct from a size, meta-type, and name.
Definition: type.hh:290
Base type for character data-types: i.e. char.
Definition: type.hh:174
map< uintb, string >::const_iterator beginEnum(void) const
Beginning of name map.
Definition: type.hh:291
virtual Datatype * clone(void) const =0
Clone the data-type.
virtual void restoreXml(const Element *el, TypeFactory &typegrp)
Restore data-type from XML.
Definition: type.cc:303
set< Datatype *, DatatypeNameCompare > DatatypeNameSet
A set of data-types sorted by name.
Definition: type.hh:153
int4 getSizeOfInt(void) const
Get the size of the default "int".
Definition: type.hh:411
TypeArray(void)
Internal constructor for restoreXml.
Definition: type.hh:252
An enumerated Datatype object: an integer with named values.
Definition: type.hh:277
bool isASCII(void) const
Does this print as an ASCII &#39;char&#39;.
Definition: type.hh:100
TypePointer(void)
Internal constructor for use with restoreXml.
Definition: type.hh:226
virtual void printNameBase(ostream &s) const
Print name as short prefix.
Definition: type.hh:266
TypePointer(int4 s, Datatype *pt, uint4 ws)
Construct from a size, pointed-to type, and wordsize.
Definition: type.hh:231
int4 typeOrderBool(const Datatype &op) const
Order this with -op-, treating bool data-type as special.
Definition: type.hh:457
virtual Datatype * clone(void) const
Clone the data-type.
Definition: type.hh:375
uint4 wordsize
What size unit does the pointer address.
Definition: type.hh:223
Formal "void" data-type object.
Definition: type.hh:206
virtual int4 numDepend(void) const
Return number of component sub-types.
Definition: type.hh:110
virtual int4 numDepend(void) const
Return number of component sub-types.
Definition: type.hh:235
An enumeration type (as well as an integer)
Definition: type.hh:73
Datatype * type
type of subfield
Definition: type.hh:127
virtual Datatype * clone(void) const
Clone the data-type.
Definition: type.hh:269
TypePointer(const TypePointer &op)
Construct from another TypePointer.
Definition: type.hh:229
TypeChar(const string &n)
Construct a char (always 1-byte) given a name.
Definition: type.hh:181
A collection of Symbol objects within a single (namespace or functional) scope.
Definition: database.hh:413
Architecture * getArch(void) const
Get the Architecture object.
Definition: type.hh:412