mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
[Tolk] Embedded stdlib.tolk, CompilerState, strict includes
Several related changes: - stdlib.tolk is embedded into a distribution (deb package or tolk-js), the user won't have to download it and store as a project file; it's an important step to maintain correct language versioning - stdlib.tolk is auto-included, that's why all its functions are available out of the box - strict includes: you can't use symbol `f` from another file unless you've #include'd this file - drop all C++ global variables holding compilation state, merge them into a single struct CompilerState located at compiler-state.h; for instance, stdlib filename is also there
This commit is contained in:
parent
f0e6470d0b
commit
6c30e5a7eb
21 changed files with 604 additions and 506 deletions
|
@ -15,6 +15,7 @@
|
|||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "tolk.h"
|
||||
#include "compiler-state.h"
|
||||
|
||||
namespace tolk {
|
||||
using namespace std::literals::string_literals;
|
||||
|
@ -25,18 +26,11 @@ using namespace std::literals::string_literals;
|
|||
*
|
||||
*/
|
||||
|
||||
int glob_func_cnt, undef_func_cnt, glob_var_cnt, const_cnt;
|
||||
std::vector<SymDef*> glob_func, glob_vars, glob_get_methods;
|
||||
std::set<std::string> prohibited_var_names;
|
||||
|
||||
SymDef* define_builtin_func_impl(const std::string& name, SymValAsmFunc* func_val) {
|
||||
if (name.back() == '_') {
|
||||
prohibited_var_names.insert(name);
|
||||
}
|
||||
sym_idx_t name_idx = symbols.lookup(name, 1);
|
||||
if (symbols.is_keyword(name_idx)) {
|
||||
std::cerr << "fatal: global function `" << name << "` already defined as a keyword" << std::endl;
|
||||
G.prohibited_var_names.insert(name);
|
||||
}
|
||||
sym_idx_t name_idx = G.symbols.lookup(name, 1);
|
||||
SymDef* def = define_global_symbol(name_idx, true);
|
||||
if (!def) {
|
||||
std::cerr << "fatal: global function `" << name << "` already defined" << std::endl;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue