diff options
author | Shinichiro Hamaji <shinichiro.hamaji@gmail.com> | 2015-06-17 17:51:24 +0900 |
---|---|---|
committer | Shinichiro Hamaji <shinichiro.hamaji@gmail.com> | 2015-06-18 11:25:44 +0900 |
commit | d146f4c482adb0c51bfc1bef101361845f74407c (patch) | |
tree | bf2f649f66ce5ddbdb3fafbed6fbf12163c4b5a1 /eval.cc | |
parent | eb2b3d0a6a18e2eff96ba64abf5604011c2fbf2d (diff) | |
download | android_build_kati-d146f4c482adb0c51bfc1bef101361845f74407c.tar.gz android_build_kati-d146f4c482adb0c51bfc1bef101361845f74407c.tar.bz2 android_build_kati-d146f4c482adb0c51bfc1bef101361845f74407c.zip |
[C++] Implement ifeq
Diffstat (limited to 'eval.cc')
-rw-r--r-- | eval.cc | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -107,18 +107,20 @@ void Evaluator::EvalCommand(const CommandAST* ast) { void Evaluator::EvalIf(const IfAST* ast) { bool is_true; - StringPiece lhs = Intern(*ast->lhs->Eval(this)); switch (ast->op) { case CondOp::IFDEF: case CondOp::IFNDEF: { + StringPiece lhs = Intern(*ast->lhs->Eval(this)); Var* v = LookupVarInCurrentScope(lhs); shared_ptr<string> s = v->Eval(this); - is_true = s->empty() == (ast->op == CondOp::IFNDEF); + is_true = (s->empty() == (ast->op == CondOp::IFNDEF)); break; } case CondOp::IFEQ: case CondOp::IFNEQ: { - ERROR("TODO"); + shared_ptr<string> lhs = ast->lhs->Eval(this); + shared_ptr<string> rhs = ast->rhs->Eval(this); + is_true = ((*lhs == *rhs) == (ast->op == CondOp::IFEQ)); break; } default: |