mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
[Tolk] Compilation pipeline, register global symbols in advance
Since I've implemented AST, now I can drop forward declarations. Instead, I traverse AST of all files and register global symbols (functions, constants, global vars) as a separate step, in advance. That's why, while converting AST to Expr/Op, all available symbols are already registered. This greatly simplifies "intermediate state" of yet unknown functions and checking them afterward. Redeclaration of local variables (inside the same scope) is now also prohibited.
This commit is contained in:
parent
80001d1756
commit
5a3e3595d6
28 changed files with 1266 additions and 1134 deletions
|
@ -40,18 +40,18 @@ td::Result<std::string> compile_internal(char *config_json) {
|
|||
TRY_RESULT(opt_level, td::get_json_object_int_field(config, "optimizationLevel", true, 2));
|
||||
TRY_RESULT(stdlib_tolk, td::get_json_object_string_field(config, "stdlibLocation", false));
|
||||
TRY_RESULT(stack_comments, td::get_json_object_bool_field(config, "withStackComments", true, false));
|
||||
TRY_RESULT(entrypoint_file_name, td::get_json_object_string_field(config, "entrypointFileName", false));
|
||||
TRY_RESULT(entrypoint_filename, td::get_json_object_string_field(config, "entrypointFileName", false));
|
||||
|
||||
G.settings.verbosity = 0;
|
||||
G.settings.optimization_level = std::max(0, opt_level);
|
||||
G.settings.stdlib_filename = stdlib_tolk;
|
||||
G.settings.stack_layout_comments = stack_comments;
|
||||
G.settings.entrypoint_filename = entrypoint_file_name;
|
||||
G.settings.entrypoint_filename = entrypoint_filename;
|
||||
|
||||
std::ostringstream outs, errs;
|
||||
std::cout.rdbuf(outs.rdbuf());
|
||||
std::cerr.rdbuf(errs.rdbuf());
|
||||
int tolk_res = tolk::tolk_proceed(entrypoint_file_name);
|
||||
int tolk_res = tolk::tolk_proceed(entrypoint_filename);
|
||||
if (tolk_res != 0) {
|
||||
return td::Status::Error("Tolk compilation error: " + errs.str());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue