Skip to content

Commit 5a3e359

Browse files
committed
[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.
1 parent 80001d1 commit 5a3e359

28 files changed

+1265
-1133
lines changed

crypto/smartcont/mathlib.tolk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ int fixed248::pow(int x, int y) inline_ref {
676676
if (sq <= 0) {
677677
return - (sq == 0); ;; underflow
678678
}
679-
int y = expm1_f257(mulrshiftr256(ll, log2_const_f256()));
679+
y = expm1_f257(mulrshiftr256(ll, log2_const_f256()));
680680
return (y ~>> (9 - q)) - (-1 << sq);
681681
}
682682

tolk/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ set(TOLK_SOURCE
77
compiler-state.cpp
88
ast.cpp
99
ast-from-tokens.cpp
10-
ast-to-legacy.cpp
10+
pipe-discover-parse-sources.cpp
11+
pipe-handle-pragmas.cpp
12+
pipe-register-symbols.cpp
13+
pipe-ast-to-legacy.cpp
14+
pipe-find-unused-symbols.cpp
15+
pipe-generate-fif-output.cpp
1116
unify-types.cpp
1217
abscode.cpp
1318
gen-abscode.cpp

0 commit comments

Comments
 (0)