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

[Tolk] Refactor: get rid of split_vars, construct valid LET ops

In FunC (and in Tolk before), tensor vars (actually occupying
several stack slots) were represented as a single var in terms
or IR vars (Ops):
> var a = (1, 2);
> LET (_i) = (_1, _2)

Now, every tensor of N stack slots is represented as N IR vars.
> LET (_i, _j) = (_1, _2)

This will give an ability to control access to parts of a tensor
when implementing `tensorVar.0` syntax.
This commit is contained in:
tolk-vm 2024-12-18 19:26:26 +03:00
parent 989629a832
commit 565bc59735
No known key found for this signature in database
GPG key ID: 7905DD7FE0324B12
17 changed files with 100 additions and 217 deletions

View file

@ -202,8 +202,8 @@ td::Result<std::vector<TypePtr>> deduce_substitutionTs_on_generic_func_call(cons
try {
GenericSubstitutionsDeduceForFunctionCall deducing(called_fun);
for (const LocalVarData& param : called_fun->parameters) {
if (param.declared_type->has_genericT_inside() && param.idx < static_cast<int>(arg_types.size())) {
deducing.consider_next_condition(param.declared_type, arg_types[param.idx]);
if (param.declared_type->has_genericT_inside() && param.param_idx < static_cast<int>(arg_types.size())) {
deducing.consider_next_condition(param.declared_type, arg_types[param.param_idx]);
}
}
int idx = deducing.get_first_not_deduced_idx();
@ -233,7 +233,7 @@ const FunctionData* instantiate_generic_function(SrcLocation loc, const Function
std::vector<LocalVarData> parameters;
parameters.reserve(fun_ref->get_num_params());
for (const LocalVarData& orig_p : fun_ref->parameters) {
parameters.emplace_back(orig_p.name, orig_p.loc, replace_genericT_with_deduced(orig_p.declared_type, fun_ref->genericTs, substitutionTs), orig_p.flags, orig_p.idx);
parameters.emplace_back(orig_p.name, orig_p.loc, replace_genericT_with_deduced(orig_p.declared_type, fun_ref->genericTs, substitutionTs), orig_p.flags, orig_p.param_idx);
}
TypePtr declared_return_type = replace_genericT_with_deduced(fun_ref->declared_return_type, fun_ref->genericTs, substitutionTs);
const GenericsInstantiation* instantiationTs = new GenericsInstantiation(loc, std::move(substitutionTs));