mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-26 22:02:30 +01:00
Implement static name resolution (#958)
This doesn't actually use the results of name resolution, but it does verify that they are present. Also ensures that name resolution and type checking are applied to deduced function parameters and the implicit call to `Main()`. Co-authored-by: Jon Meow <46229924+jonmeow@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
co-authored by
Jon Meow
parent
dc5e62fc7a
commit
17e0a1afb9
@@ -24,6 +24,10 @@ void ExecProgram(Nonnull<Arena*> arena, AST ast, bool trace) {
|
||||
}
|
||||
llvm::outs() << "********** type checking **********\n";
|
||||
}
|
||||
SourceLocation source_loc("<Main()>", 0);
|
||||
ast.main_call = arena->New<CallExpression>(
|
||||
source_loc, arena->New<IdentifierExpression>(source_loc, "Main"),
|
||||
arena->New<TupleLiteral>(source_loc));
|
||||
// Although name resolution is currently done once, generic programming
|
||||
// (particularly templates) may require more passes.
|
||||
ResolveNames(arena, ast);
|
||||
@@ -37,13 +41,8 @@ void ExecProgram(Nonnull<Arena*> arena, AST ast, bool trace) {
|
||||
}
|
||||
llvm::outs() << "********** starting execution **********\n";
|
||||
}
|
||||
|
||||
SourceLocation source_loc("<Main()>", 0);
|
||||
Nonnull<Expression*> call_main = arena->New<CallExpression>(
|
||||
source_loc, arena->New<IdentifierExpression>(source_loc, "Main"),
|
||||
arena->New<TupleLiteral>(source_loc));
|
||||
int result =
|
||||
Interpreter(arena, trace).InterpProgram(ast.declarations, call_main);
|
||||
Interpreter(arena, trace).InterpProgram(ast.declarations, *ast.main_call);
|
||||
llvm::outs() << "result: " << result << "\n";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user