Implement 'final' assignments.
A variable cannot be assigned a new value after the final assignment.
The syntax of the final assignment is
<variable> =$=<value>
or for the rule-specific variables it is
<target>: <variable> =$=<value>
The effect is identical to having
.KATI_READONLY := <variable>
or
<target>: .KATI_READONLY := variable
that follows the assignment statement.
NOTE that if you still want to use `make`, please avoid having
whitespace after `=$=` (otherwise this whitespace will become
part of the variable's value).
Also, the change rearranges rule parsing and evaluation code.
diff --git a/stmt.cc b/stmt.cc
index 3ab9905..b558fcc 100644
--- a/stmt.cc
+++ b/stmt.cc
@@ -26,9 +26,9 @@
Stmt::~Stmt() {}
string RuleStmt::DebugString() const {
- return StringPrintf("RuleStmt(expr=%s term=%d after_term=%s loc=%s:%d)",
- Value::DebugString(expr).c_str(), term,
- Value::DebugString(after_term).c_str(), LOCF(loc()));
+ return StringPrintf("RuleStmt(lhs=%s sep=%d rhs=%s loc=%s:%d)",
+ Value::DebugString(lhs).c_str(), sep,
+ Value::DebugString(rhs).c_str(), LOCF(loc()));
}
string AssignStmt::DebugString() const {
@@ -122,8 +122,8 @@
}
RuleStmt::~RuleStmt() {
- delete expr;
- delete after_term;
+ delete lhs;
+ delete rhs;
}
void RuleStmt::Eval(Evaluator* ev) const {