mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-25 14:20:19 +01:00
Pass the flag instead of using a global. (#893)
Arguably missed in #769 Note, this is reminding me we have more class members to rename for `_`, but I felt it's best to use the new naming instead of adding more to clean up.
This commit is contained in:
@@ -7,7 +7,6 @@
|
||||
#include "common/check.h"
|
||||
#include "common/ostream.h"
|
||||
#include "executable_semantics/common/arena.h"
|
||||
#include "executable_semantics/common/tracing_flag.h"
|
||||
#include "executable_semantics/interpreter/interpreter.h"
|
||||
#include "executable_semantics/interpreter/type_checker.h"
|
||||
|
||||
@@ -34,23 +33,23 @@ static void AddIntrinsics(Nonnull<Arena*> arena,
|
||||
declarations->insert(declarations->begin(), print);
|
||||
}
|
||||
|
||||
void ExecProgram(Nonnull<Arena*> arena, AST ast) {
|
||||
void ExecProgram(Nonnull<Arena*> arena, AST ast, bool trace) {
|
||||
AddIntrinsics(arena, &ast.declarations);
|
||||
if (tracing_output) {
|
||||
if (trace) {
|
||||
llvm::outs() << "********** source program **********\n";
|
||||
for (const auto decl : ast.declarations) {
|
||||
llvm::outs() << *decl;
|
||||
}
|
||||
llvm::outs() << "********** type checking **********\n";
|
||||
}
|
||||
TypeChecker type_checker(arena);
|
||||
TypeChecker type_checker(arena, trace);
|
||||
TypeChecker::TypeCheckContext p = type_checker.TopLevel(&ast.declarations);
|
||||
TypeEnv top = p.types;
|
||||
Env ct_top = p.values;
|
||||
for (const auto decl : ast.declarations) {
|
||||
type_checker.TypeCheck(decl, top, ct_top);
|
||||
}
|
||||
if (tracing_output) {
|
||||
if (trace) {
|
||||
llvm::outs() << "\n";
|
||||
llvm::outs() << "********** type checking complete **********\n";
|
||||
for (const auto decl : ast.declarations) {
|
||||
@@ -63,7 +62,8 @@ void ExecProgram(Nonnull<Arena*> arena, AST ast) {
|
||||
Nonnull<Expression*> call_main = arena->New<CallExpression>(
|
||||
source_loc, arena->New<IdentifierExpression>(source_loc, "main"),
|
||||
arena->New<TupleLiteral>(source_loc));
|
||||
int result = Interpreter(arena).InterpProgram(ast.declarations, call_main);
|
||||
int result =
|
||||
Interpreter(arena, trace).InterpProgram(ast.declarations, call_main);
|
||||
llvm::outs() << "result: " << result << "\n";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user