Variable.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #if !defined(_Variable_h_)
00032 #define _Variable_h_
00033
00034 #include "Annotatable.h"
00035 #include "Serialization.h"
00036 #include "Symtab.h"
00037 #include "Aggregate.h"
00038 #include "dyn_regs.h"
00039 #include "VariableLocation.h"
00040
00041
00042 SYMTAB_EXPORT std::ostream &operator<<(std::ostream &os, const Dyninst::SymtabAPI::Variable &);
00043
00044 namespace Dyninst {
00045 namespace SymtabAPI {
00046
00047
00048 class Symbol;
00049 class Symtab;
00050 class Aggregate;
00051 class Function;
00052
00053 class Variable : public Aggregate, public Serializable, public AnnotatableSparse {
00054 friend class Symtab;
00055 friend std::ostream &::operator<<(std::ostream &os, const Dyninst::SymtabAPI::Variable &);
00056
00057 private:
00058 SYMTAB_EXPORT Variable(Symbol *sym);
00059 SYMTAB_EXPORT static Variable *createVariable(Symbol *sym);
00060
00061 public:
00062 SYMTAB_EXPORT Variable();
00063
00064 SYMTAB_EXPORT bool removeSymbol(Symbol *sym);
00065
00066 SYMTAB_EXPORT void setType(Type *type);
00067 SYMTAB_EXPORT Type *getType();
00068
00069 SYMTAB_EXPORT Serializable *serialize_impl(SerializerBase *sb,
00070 const char *tag = "Variable") THROW_SPEC (SerializerError);
00071 SYMTAB_EXPORT bool operator==(const Variable &v);
00072
00073 private:
00074
00075 Type *type_;
00076 };
00077
00078 class localVar : public Serializable, public AnnotatableSparse
00079 {
00080 friend class typeCommon;
00081 friend class localVarCollection;
00082
00083 std::string name_;
00084 Type *type_;
00085 std::string fileName_;
00086 int lineNum_;
00087 Function *func_;
00088 std::vector<VariableLocation> locs_;
00089
00090
00091
00092 bool locsExpanded_;
00093
00094
00095
00096 void expandLocation(const VariableLocation &var,
00097 std::vector<VariableLocation> &ret);
00098
00099 public:
00100 SYMTAB_EXPORT localVar() :
00101 type_(NULL), lineNum_(-1), func_(NULL), locsExpanded_(false) {}
00102
00103 localVar(std::string name, Type *typ, std::string fileName,
00104 int lineNum, Function *f,
00105 std::vector<VariableLocation> *locs = NULL);
00106
00107
00108 localVar(localVar &lvar);
00109 bool addLocation(VariableLocation &location);
00110 SYMTAB_EXPORT ~localVar();
00111 SYMTAB_EXPORT void fixupUnknown(Module *);
00112
00113 public:
00114
00115 SYMTAB_EXPORT std::string &getName();
00116 SYMTAB_EXPORT Type *getType();
00117 SYMTAB_EXPORT bool setType(Type *newType);
00118 SYMTAB_EXPORT int getLineNum();
00119 SYMTAB_EXPORT std::string &getFileName();
00120 SYMTAB_EXPORT std::vector<VariableLocation> &getLocationLists();
00121 SYMTAB_EXPORT bool operator==(const localVar &l);
00122 SYMTAB_EXPORT Serializable *serialize_impl(SerializerBase *,
00123 const char * = "localVar") THROW_SPEC(SerializerError);
00124 };
00125
00126 }
00127 }
00128
00129
00130 #endif