mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
[FunC] Deprecate pragma allow-post-modification
All tests pass: it does not affect hashes (since modifying variables in a single expression was an error)
This commit is contained in:
parent
bb86dc0f96
commit
aaf3ca335d
5 changed files with 12 additions and 27 deletions
|
@ -1,5 +1,3 @@
|
|||
#pragma allow-post-modification;
|
||||
|
||||
forall X -> tuple unsafe_tuple(X x) asm "NOP";
|
||||
|
||||
(int, int) inc(int x, int y) {
|
||||
|
|
|
@ -347,6 +347,7 @@ int func_proceed(const std::vector<std::string> &sources, std::ostream &outs, st
|
|||
|
||||
funC::define_keywords();
|
||||
funC::define_builtins();
|
||||
pragma_allow_post_modification.always_on_and_deprecated("0.5.0");
|
||||
|
||||
int ok = 0, proc = 0;
|
||||
try {
|
||||
|
@ -365,7 +366,6 @@ int func_proceed(const std::vector<std::string> &sources, std::ostream &outs, st
|
|||
if (!proc) {
|
||||
throw src::Fatal{"no source files, no output"};
|
||||
}
|
||||
pragma_allow_post_modification.check_enable_in_libs();
|
||||
pragma_compute_asm_ltr.check_enable_in_libs();
|
||||
pragma_remove_unused_functions.check_enable_in_libs();
|
||||
return funC::generate_output(outs, errs);
|
||||
|
|
|
@ -686,7 +686,7 @@ typedef std::vector<FormalArg> FormalArgList;
|
|||
struct AsmOpList;
|
||||
|
||||
struct CodeBlob {
|
||||
enum { _AllowPostModification = 1, _ComputeAsmLtr = 2, _ForbidImpure = 4 };
|
||||
enum { _ComputeAsmLtr = 2, _ForbidImpure = 4 };
|
||||
int var_cnt, in_var_cnt, op_cnt;
|
||||
TypeExpr* ret_type;
|
||||
std::string name;
|
||||
|
|
|
@ -286,24 +286,17 @@ std::vector<var_idx_t> pre_compile_tensor(const std::vector<Expr *> args, CodeBl
|
|||
res_lists[i] = args[i]->pre_compile(code, lval_globs);
|
||||
for (size_t j = 0; j < res_lists[i].size(); ++j) {
|
||||
TmpVar& var = code.vars.at(res_lists[i][j]);
|
||||
if (code.flags & CodeBlob::_AllowPostModification) {
|
||||
if (!lval_globs && (var.cls & TmpVar::_Named)) {
|
||||
Op *op = &code.emplace_back(nullptr, Op::_Let, std::vector<var_idx_t>(), std::vector<var_idx_t>());
|
||||
op->set_disabled();
|
||||
var.on_modification.push_back([modified_vars, i, j, op, done = false](const SrcLocation &here) mutable {
|
||||
if (!done) {
|
||||
done = true;
|
||||
modified_vars->push_back({i, j, op});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
var.on_modification.push_back([](const SrcLocation &) {
|
||||
});
|
||||
}
|
||||
if (!lval_globs && (var.cls & TmpVar::_Named)) {
|
||||
Op *op = &code.emplace_back(nullptr, Op::_Let, std::vector<var_idx_t>(), std::vector<var_idx_t>());
|
||||
op->set_disabled();
|
||||
var.on_modification.push_back([modified_vars, i, j, op, done = false](const SrcLocation &here) mutable {
|
||||
if (!done) {
|
||||
done = true;
|
||||
modified_vars->push_back({i, j, op});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
var.on_modification.push_back([name = var.to_string()](const SrcLocation &here) {
|
||||
throw src::ParseError{here, PSTRING() << "Modifying local variable " << name
|
||||
<< " after using it in the same expression"};
|
||||
var.on_modification.push_back([](const SrcLocation &) {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -266,9 +266,6 @@ void parse_const_decl(Lexer& lex) {
|
|||
}
|
||||
lex.next();
|
||||
CodeBlob code;
|
||||
if (pragma_allow_post_modification.enabled()) {
|
||||
code.flags |= CodeBlob::_AllowPostModification;
|
||||
}
|
||||
if (pragma_compute_asm_ltr.enabled()) {
|
||||
code.flags |= CodeBlob::_ComputeAsmLtr;
|
||||
}
|
||||
|
@ -1219,9 +1216,6 @@ blk_fl::val parse_stmt(Lexer& lex, CodeBlob& code) {
|
|||
CodeBlob* parse_func_body(Lexer& lex, FormalArgList arg_list, TypeExpr* ret_type, bool marked_as_pure) {
|
||||
lex.expect('{');
|
||||
CodeBlob* blob = new CodeBlob{ret_type};
|
||||
if (pragma_allow_post_modification.enabled()) {
|
||||
blob->flags |= CodeBlob::_AllowPostModification;
|
||||
}
|
||||
if (pragma_compute_asm_ltr.enabled()) {
|
||||
blob->flags |= CodeBlob::_ComputeAsmLtr;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue