Otawa  0.10
Symbol.h
Go to the documentation of this file.
1 /*
2  * $Id$
3  * Copyright (c) 2003-07, IRIT UPS.
4  *
5  * Symbol class interface
6  */
7 #ifndef OTAWA_PROG_SYMBOL_H
8 #define OTAWA_PROG_SYMBOL_H
9 
10 #include <elm/io.h>
11 #include <otawa/base.h>
12 #include <otawa/properties.h>
13 
14 namespace otawa {
15 
16 // External classes
17 class File;
18 class Inst;
19 
20 // Symbol class
21 class Symbol: public PropList {
22 public:
23 
24  typedef enum kind_t {
25  NONE = 0,
26  FUNCTION = 1,
27  LABEL = 2,
28  DATA = 3
29  } kind_t;
30 
32 
34  inline File& file(void) const { return _file; }
35  inline kind_t kind(void) const { return _kind; }
36  inline const String& name(void) const { return _name; }
37  inline address_t address(void) const { return _address; }
38  inline ot::size size(void) const { return _size; }
39  Inst *findInst(void) const;
40  inline bool doesNotReturn(void) const { return no_return; }
41  void setNoReturn(void);
42  void print(io::Output& out) const;
43 
44 private:
49  size_t _size;
50  bool no_return;
51 };
52 
53 // GenericIdentifier<Symbol_t *>::print Specialization
54 inline io::Output& operator<<(io::Output& out, Symbol *sym) { sym->print(out); return out; }
55 io::Output& operator<<(io::Output& out, Symbol::kind_t k);
56 
57 } // otawa
58 
59 #endif // OTAWA_SYMBOL_H
void setNoReturn(void)
Set the no-return property to this symbol.
Definition: prog_Symbol.cpp:154
Definition: Symbol.h:28
Unknown symbol.
Definition: Symbol.h:25
Inst * findInst(void) const
If the symbol points to code memory, return the matching instruction.
Definition: prog_Symbol.cpp:112
elm::io::Output & operator<<(elm::io::Output &out, Address addr)
Definition: base.cpp:188
size_t _size
Definition: Symbol.h:49
address_t address(void) const
Get the address of the location referenced by this symbol.
Definition: Symbol.h:37
bool no_return
Definition: Symbol.h:50
uint32 size
kind_t _kind
Definition: Symbol.h:47
This class represents a file involved in the building of a process.
Definition: File.h:43
bool doesNotReturn(void) const
Test if it is a no returning function.
Definition: Symbol.h:40
t::uint32 size
Definition: base.h:46
ot::size size(void) const
Get the size of the item referenced by this symbol.
Definition: Symbol.h:38
kind_t
This type describes the kind of existing symbol.
Definition: Symbol.h:24
Symbol(File &file, String name, kind_t kind, address_t address, ot::size size=0)
Build a symbol.
Definition: prog_Symbol.cpp:58
The representation of an address in OTAWA.
Definition: base.h:54
Denotes a function symbol.
Definition: Symbol.h:26
sys::SystemOutStream & out
static Identifier< Symbol * > ID
This property is used to attach a symbol to an instruction.
Definition: Symbol.h:31
Denotes a label symbol.
Definition: Symbol.h:27
This class represents identifier with a typed associated value.
Definition: Identifier.h:51
This class represents assembly instruction of a piece of code.
Definition: Inst.h:62
kind_t kind(void) const
Get the kind of the symbol.
Definition: Symbol.h:35
This a list of properties.
Definition: PropList.h:63
File & file(void) const
Get the owner file of the given symbol.
Definition: Symbol.h:34
const String & name(void) const
Get the name of the symbol.
Definition: Symbol.h:36
File & _file
Definition: Symbol.h:45
void print(io::Output &out) const
Definition: prog_Symbol.cpp:118
address_t _address
Definition: Symbol.h:48
String _name
Definition: Symbol.h:46
A symbol is a name of a location in a program.
Definition: Symbol.h:21