1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-03-09 15:40:10 +00:00

Make funcfiftlib compilation compatible with modern compilers (#618)

* wip: make funcfiftlib compilation compatible with modern compilers

* wip: add methods needed for another compiler

* fix: tdutils port config if emscripten

* feat: func source and realpath callback

* fix: invalid fift compilation exceptions

---------

Co-authored-by: krigga <krigga7@gmail.com>
This commit is contained in:
Dan Volkov 2023-03-09 18:37:15 +04:00 committed by GitHub
parent 82e231d0a7
commit 4590ed381b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 142 additions and 31 deletions

View file

@ -22,8 +22,6 @@
#include "openssl/digest.hpp"
#include "block/block.h"
#include "block-parse.h"
#include <fstream>
#include "td/utils/port/path.h"
namespace sym {
@ -1757,7 +1755,7 @@ bool parse_source_file(const char* filename, src::Lexem lex, bool is_main) {
}
}
auto path_res = td::realpath(td::CSlice(filename));
auto path_res = read_callback(ReadCallback::Kind::Realpath, filename);
if (path_res.is_error()) {
auto error = path_res.move_as_error();
lex.error(error.message().c_str());
@ -1784,17 +1782,19 @@ bool parse_source_file(const char* filename, src::Lexem lex, bool is_main) {
source_files[real_filename] = cur_source;
cur_source->is_main = is_main;
source_fdescr.push_back(cur_source);
std::ifstream ifs{filename};
if (ifs.fail()) {
auto msg = std::string{"cannot open source file `"} + filename + "`";
auto file_res = read_callback(ReadCallback::Kind::ReadFile, filename);
if (file_res.is_error()) {
auto msg = file_res.move_as_error().message().str();
if (lex.tp) {
lex.error(msg);
} else {
throw src::Fatal{msg};
}
}
auto file_str = file_res.move_as_ok();
std::stringstream ss{file_str};
inclusion_locations.push(lex.loc);
bool res = parse_source(&ifs, cur_source);
bool res = parse_source(&ss, cur_source);
inclusion_locations.pop();
return res;
}