aboutsummaryrefslogtreecommitdiff
path: root/symtab.h
diff options
context:
space:
mode:
authorShinichiro Hamaji <shinichiro.hamaji@gmail.com>2016-02-18 18:18:54 +0900
committerShinichiro Hamaji <shinichiro.hamaji@gmail.com>2016-02-22 16:19:42 +0900
commitc9b9e5eea8b477a103cdec951ef2a299f9cd49ba (patch)
treee28f4e11d2e0e15a01082c10f05038f67d298946 /symtab.h
parenta67fba3bf217ece75b66cb9adb6539e9d098ce9c (diff)
[C++] Associate global variables with Symbols directly
Diffstat (limited to 'symtab.h')
-rw-r--r--symtab.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/symtab.h b/symtab.h
index 9d8a120..d1de4e1 100644
--- a/symtab.h
+++ b/symtab.h
@@ -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();
}