diff options
author | Shinichiro Hamaji <shinichiro.hamaji@gmail.com> | 2015-06-23 16:51:07 +0900 |
---|---|---|
committer | Shinichiro Hamaji <shinichiro.hamaji@gmail.com> | 2015-06-23 20:27:40 +0900 |
commit | ffc52c3c5bed9d696d0296c1674d2e75460bef40 (patch) | |
tree | 7364bea9749e3de9fcf308b9c4b825e7425b881a /var.h | |
parent | 9042b995db7f0b9499e0c3087269505e5e817a58 (diff) | |
download | kati-ffc52c3c5bed9d696d0296c1674d2e75460bef40.tar.gz |
[C++] Let target specific variable have its own scope
Diffstat (limited to 'var.h')
-rw-r--r-- | var.h | 39 |
1 files changed, 39 insertions, 0 deletions
@@ -19,6 +19,7 @@ #include <string> #include <unordered_map> +#include "ast.h" #include "string_piece.h" #include "value.h" @@ -118,6 +119,44 @@ class UndefinedVar : public Var { extern UndefinedVar* kUndefined; +class RuleVar : public Var { + public: + RuleVar(Var* v, AssignOp op) + : v_(v), op_(op) {} + virtual ~RuleVar() { + delete v_; + } + + virtual const char* Flavor() const { + return v_->Flavor(); + } + virtual const char* Origin() const { + return v_->Origin(); + } + virtual bool IsDefined() const { + return v_->IsDefined(); + } + virtual void Eval(Evaluator* ev, string* s) const { + v_->Eval(ev, s); + } + virtual void AppendVar(Evaluator* ev, Value* v) { + v_->AppendVar(ev, v); + } + virtual StringPiece String() const override { + return v_->String(); + } + virtual string DebugString() const override { + return v_->DebugString(); + } + + Var* v() const { return v_; } + AssignOp op() const { return op_; } + + private: + Var* v_; + AssignOp op_; +}; + class Vars : public unordered_map<StringPiece, Var*> { public: ~Vars(); |