mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-28 13:50:10 +01:00
Refactor Interpreter/TypeChecker to classes to remove interpreter globals (#790)
Along with #789 this addresses most of #769 although global_arena is still a TODO (that's widespread and overlaps with other changes so I wanted to do it after these are in).
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
#include "executable_semantics/common/arena.h"
|
||||
#include "executable_semantics/common/tracing_flag.h"
|
||||
#include "executable_semantics/interpreter/interpreter.h"
|
||||
#include "executable_semantics/interpreter/typecheck.h"
|
||||
#include "executable_semantics/interpreter/type_checker.h"
|
||||
|
||||
namespace Carbon {
|
||||
|
||||
@@ -46,13 +46,13 @@ void ExecProgram(std::list<Ptr<const Declaration>> fs) {
|
||||
}
|
||||
llvm::outs() << "********** type checking **********\n";
|
||||
}
|
||||
state = global_arena->RawNew<State>(); // Compile-time state.
|
||||
TypeCheckContext p = TopLevel(fs);
|
||||
TypeChecker type_checker;
|
||||
TypeChecker::TypeCheckContext p = type_checker.TopLevel(fs);
|
||||
TypeEnv top = p.types;
|
||||
Env ct_top = p.values;
|
||||
std::list<Ptr<const Declaration>> new_decls;
|
||||
for (const auto decl : fs) {
|
||||
new_decls.push_back(MakeTypeChecked(decl, top, ct_top));
|
||||
new_decls.push_back(type_checker.MakeTypeChecked(decl, top, ct_top));
|
||||
}
|
||||
if (tracing_output) {
|
||||
llvm::outs() << "\n";
|
||||
@@ -62,7 +62,7 @@ void ExecProgram(std::list<Ptr<const Declaration>> fs) {
|
||||
}
|
||||
llvm::outs() << "********** starting execution **********\n";
|
||||
}
|
||||
int result = InterpProgram(new_decls);
|
||||
int result = Interpreter().InterpProgram(new_decls);
|
||||
llvm::outs() << "result: " << result << "\n";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user