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

[FunC] Add an ability to deprecate pragmas

This commit is contained in:
Aleksandr Kirsanov 2024-05-10 15:38:28 +03:00
parent de570873d7
commit bb86dc0f96
No known key found for this signature in database
GPG key ID: B758BBAA01FFB3D3
2 changed files with 35 additions and 17 deletions

View file

@ -77,6 +77,37 @@ bool SymValCodeFunc::does_need_codegen() const {
// in the future, we may want to implement a true AST inlining for `inline` functions also
}
void GlobalPragma::enable(SrcLocation loc) {
if (deprecated_from_v_) {
loc.show_warning(PSTRING() << "#pragma " << name_ <<
" is deprecated since FunC v" << deprecated_from_v_ <<
". Please, remove this line from your code.");
return;
}
enabled_ = true;
locs_.push_back(std::move(loc));
}
void GlobalPragma::check_enable_in_libs() {
if (locs_.empty()) {
return;
}
for (const SrcLocation& loc : locs_) {
if (loc.fdescr->is_main) {
return;
}
}
locs_[0].show_warning(PSTRING() << "#pragma " << name_
<< " is enabled in included libraries, it may change the behavior of your code. "
<< "Add this #pragma to the main source file to suppress this warning.");
}
void GlobalPragma::always_on_and_deprecated(const char *deprecated_from_v) {
deprecated_from_v_ = deprecated_from_v;
enabled_ = true;
}
td::Result<std::string> fs_read_callback(ReadCallback::Kind kind, const char* query) {
switch (kind) {
case ReadCallback::Kind::ReadFile: {