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:
Geoff RomerandJon Meow authored and GitHub committed 2021-11-30 13:33:54 -08:00
1 parent dc5e62fc7a
commit 17e0a1afb9
12 files changed
+347 -22

No files matched your search

@@ -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";
}