mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
[Tolk] v0.6 syntax: fun
, import
, var
, types on the right, etc.
Lots of changes, actually. Most noticeable are: - traditional //comments - #include -> import - a rule "import what you use" - ~ found -> !found (for -1/0) - null() -> null - is_null?(v) -> v == null - throw is a keyword - catch with swapped arguments - throw_if, throw_unless -> assert - do until -> do while - elseif -> else if - drop ifnot, elseifnot - drop rarely used operators A testing framework also appears here. All tests existed earlier, but due to significant syntax changes, their history is useless.
This commit is contained in:
parent
5a3e3595d6
commit
e2edadba92
133 changed files with 8196 additions and 2605 deletions
|
@ -32,7 +32,7 @@ namespace tolk {
|
|||
|
||||
bool SymValCodeFunc::does_need_codegen() const {
|
||||
// when a function is declared, but not referenced from code in any way, don't generate its body
|
||||
if (!is_really_used && G.pragma_remove_unused_functions.enabled()) {
|
||||
if (!is_really_used && G.settings.remove_unused_functions) {
|
||||
return false;
|
||||
}
|
||||
// when a function is referenced like `var a = some_fn;` (or in some other non-call way), its continuation should exist
|
||||
|
@ -137,6 +137,7 @@ void pipeline_generate_fif_output_to_std_cout() {
|
|||
std::cout << "// automatically generated from " << G.generated_from << std::endl;
|
||||
std::cout << "PROGRAM{\n";
|
||||
|
||||
bool has_main_procedure = false;
|
||||
for (SymDef* func_sym : G.all_code_functions) {
|
||||
SymValCodeFunc* func_val = dynamic_cast<SymValCodeFunc*>(func_sym->value);
|
||||
tolk_assert(func_val);
|
||||
|
@ -148,6 +149,10 @@ void pipeline_generate_fif_output_to_std_cout() {
|
|||
}
|
||||
|
||||
std::string name = G.symbols.get_name(func_sym->sym_idx);
|
||||
if (func_val->is_entrypoint() && (name == "main" || name == "onInternalMessage")) {
|
||||
has_main_procedure = true;
|
||||
}
|
||||
|
||||
std::cout << std::string(2, ' ');
|
||||
if (func_val->method_id.is_null()) {
|
||||
std::cout << "DECLPROC " << name << "\n";
|
||||
|
@ -156,10 +161,14 @@ void pipeline_generate_fif_output_to_std_cout() {
|
|||
}
|
||||
}
|
||||
|
||||
if (!has_main_procedure) {
|
||||
throw Fatal("the contract has no entrypoint; forgot `fun onInternalMessage(...)`?");
|
||||
}
|
||||
|
||||
for (SymDef* gvar_sym : G.all_global_vars) {
|
||||
auto* glob_val = dynamic_cast<SymValGlobVar*>(gvar_sym->value);
|
||||
tolk_assert(glob_val);
|
||||
if (!glob_val->is_really_used && G.pragma_remove_unused_functions.enabled()) {
|
||||
if (!glob_val->is_really_used && G.settings.remove_unused_functions) {
|
||||
if (G.is_verbosity(2)) {
|
||||
std::cerr << gvar_sym->name() << ": variable not generated, it's unused\n";
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue