diff options
| author | Shinichiro Hamaji <shinichiro.hamaji@gmail.com> | 2016-02-18 18:18:54 +0900 |
|---|---|---|
| committer | Shinichiro Hamaji <shinichiro.hamaji@gmail.com> | 2016-02-22 16:19:42 +0900 |
| commit | c9b9e5eea8b477a103cdec951ef2a299f9cd49ba (patch) | |
| tree | e28f4e11d2e0e15a01082c10f05038f67d298946 /symtab.h | |
| parent | a67fba3bf217ece75b66cb9adb6539e9d098ce9c (diff) | |
[C++] Associate global variables with Symbols directly
Diffstat (limited to 'symtab.h')
| -rw-r--r-- | symtab.h | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -25,6 +25,7 @@ using namespace std; extern vector<string*>* g_symbols; class Symtab; +class Var; class Symbol { public: @@ -54,6 +55,9 @@ class Symbol { bool IsValid() const { return v_ >= 0; } + Var* GetGlobalVar() const; + void SetGlobalVar(Var* v) const; + private: explicit Symbol(int v); @@ -62,6 +66,16 @@ class Symbol { friend class Symtab; }; +class ScopedGlobalVar { + public: + ScopedGlobalVar(Symbol name, Var* var); + ~ScopedGlobalVar(); + + private: + Symbol name_; + Var* orig_; +}; + inline bool operator==(const Symbol& x, const Symbol& y) { return x.val() == y.val(); } |
