[C++] Implementing +=
diff --git a/var.cc b/var.cc
index 9bac8a2..ee708f4 100644
--- a/var.cc
+++ b/var.cc
@@ -1,5 +1,6 @@
#include "var.h"
+#include "log.h"
#include "value.h"
UndefinedVar kUndefinedBuf;
@@ -11,6 +12,10 @@
Var::~Var() {
}
+void Var::AppendVar(Evaluator*, Value*) {
+ CHECK(false);
+}
+
SimpleVar::SimpleVar(shared_ptr<string> v, const char* origin)
: v_(v), origin_(origin) {
}
@@ -19,6 +24,13 @@
*s += *v_;
}
+void SimpleVar::AppendVar(Evaluator* ev, Value* v) {
+ shared_ptr<string> s = make_shared<string>(*v_);
+ s->push_back(' ');
+ v->Eval(ev, s.get());
+ v_ = s;
+}
+
string SimpleVar::DebugString() const {
return *v_;
}
@@ -31,6 +43,10 @@
v_->Eval(ev, s);
}
+void RecursiveVar::AppendVar(Evaluator*, Value* v) {
+ v_ = NewExpr3(v_, NewLiteral(" "), v);
+}
+
string RecursiveVar::DebugString() const {
return v_->DebugString();
}