aboutsummaryrefslogtreecommitdiff
path: root/eval.h
diff options
context:
space:
mode:
authorShinichiro Hamaji <shinichiro.hamaji@gmail.com>2015-06-06 03:52:48 +0900
committerShinichiro Hamaji <shinichiro.hamaji@gmail.com>2015-06-18 11:25:42 +0900
commit776ca3085c44e6570813270df75278849c37d400 (patch)
tree6dc3f2d468cfd860347f2f9d519f49c2a38d4c64 /eval.h
parenta3caa8166baeb348f817eb1b4fa2e81672b3d77f (diff)
downloadkati-776ca3085c44e6570813270df75278849c37d400.tar.gz
[C++] The first commit for C++ version
16 tests out of 169 are passing.
Diffstat (limited to 'eval.h')
-rw-r--r--eval.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/eval.h b/eval.h
new file mode 100644
index 0000000..78cc307
--- /dev/null
+++ b/eval.h
@@ -0,0 +1,62 @@
+#ifndef EVAL_H_
+#define EVAL_H_
+
+#include <unordered_map>
+#include <vector>
+
+#include "loc.h"
+#include "string_piece.h"
+
+using namespace std;
+
+class AssignAST;
+class CommandAST;
+class Makefile;
+class Rule;
+class RuleAST;
+class Var;
+class Vars;
+
+struct EvalResult {
+ ~EvalResult();
+ vector<Rule*> rules;
+ Vars* vars;
+ unordered_map<StringPiece, Vars*> rule_vars;
+ // TODO: read_mks
+ unordered_map<StringPiece, bool> exports;
+};
+
+class Evaluator {
+ public:
+ Evaluator(const Vars* vars);
+ ~Evaluator();
+
+ void EvalAssign(const AssignAST* ast);
+ void EvalRule(const RuleAST* ast);
+ void EvalCommand(const CommandAST* ast);
+
+ Var* LookupVar(StringPiece name);
+ // For target specific variables.
+ Var* LookupVarInCurrentScope(StringPiece name);
+
+ EvalResult* GetEvalResult();
+
+#if 0
+ const vector<Rule*>& rules() const { return rules_; }
+ const Vars* vars() const { return vars_; }
+ const unordered_map<StringPiece, Vars*>& rule_vars() const {
+ return rule_vars_;
+ }
+#endif
+
+ private:
+ const Vars* in_vars_;
+ Vars* vars_;
+ unordered_map<StringPiece, Vars*> rule_vars_;
+ vector<Rule*> rules_;
+ Rule* last_rule_;
+
+ Loc loc_;
+};
+
+#endif // EVAL_H_