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

@ -30,6 +30,7 @@
#include "parser/srcread.h"
#include "parser/lexer.h"
#include "parser/symtable.h"
#include "td/utils/Status.h"
namespace funC {
@ -845,6 +846,35 @@ extern std::vector<SymDef*> glob_func, glob_vars;
*
*/
class ReadCallback {
public:
/// Noncopyable.
ReadCallback(ReadCallback const&) = delete;
ReadCallback& operator=(ReadCallback const&) = delete;
enum class Kind
{
ReadFile,
Realpath
};
static std::string kindString(Kind _kind)
{
switch (_kind)
{
case Kind::ReadFile:
return "source";
case Kind::Realpath:
return "realpath";
default:
throw ""; // todo ?
}
}
/// File reading or generic query callback.
using Callback = std::function<td::Result<std::string>(ReadCallback::Kind, const char*)>;
};
// defined in parse-func.cpp
bool parse_source(std::istream* is, const src::FileDescr* fdescr);
bool parse_source_file(const char* filename, src::Lexem lex = {}, bool is_main = false);
@ -1691,6 +1721,9 @@ void define_builtins();
extern int verbosity, indent, opt_level;
extern bool stack_layout_comments, op_rewrite_comments, program_envelope, asm_preamble, interactive;
extern std::string generated_from, boc_output_filename;
extern ReadCallback::Callback read_callback;
td::Result<std::string> fs_read_callback(ReadCallback::Kind kind, const char* query);
class GlobalPragma {
public: