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

[Tolk] Tolk v0.5.0 as FunC v0.5.0 could have been like

All changes from PR "FunC v0.5.0":
https://github.com/ton-blockchain/ton/pull/1026

Instead of developing FunC, we decided to fork it.
BTW, the first Tolk release will be v0.6,
a metaphor of FunC v0.5 that missed a chance to occur.
This commit is contained in:
tolk-vm 2024-10-31 10:54:05 +04:00
parent 82648ebd6a
commit ebbab54cda
No known key found for this signature in database
GPG key ID: 7905DD7FE0324B12
21 changed files with 1345 additions and 789 deletions

View file

@ -113,6 +113,39 @@ int TypeExpr::extract_components(std::vector<TypeExpr*>& comp_list) {
return res;
}
bool TypeExpr::equals_to(const TypeExpr *rhs) const {
const TypeExpr *l = this;
const TypeExpr *r = rhs;
while (l->constr == te_Indirect)
l = l->args[0];
while (r->constr == te_Indirect)
r = r->args[0];
bool eq = l->constr == r->constr && l->value == r->value &&
l->minw == r->minw && l->maxw == r->maxw &&
l->was_forall_var == r->was_forall_var &&
l->args.size() == r->args.size();
if (!eq)
return false;
for (int i = 0; i < static_cast<int>(l->args.size()); ++i) {
if (!l->args[i]->equals_to(r->args[i]))
return false;
}
return true;
}
bool TypeExpr::has_unknown_inside() const {
if (constr == te_Unknown)
return true;
for (const TypeExpr* inner : args) {
if (inner->has_unknown_inside())
return true;
}
return false;
}
TypeExpr* TypeExpr::new_map(TypeExpr* from, TypeExpr* to) {
return new TypeExpr{te_Map, std::vector<TypeExpr*>{from, to}};
}
@ -207,7 +240,7 @@ std::ostream& operator<<(std::ostream& os, TypeExpr* type_expr) {
return type_expr->print(os);
}
std::ostream& TypeExpr::print(std::ostream& os, int lex_level) {
std::ostream& TypeExpr::print(std::ostream& os, int lex_level) const {
switch (constr) {
case te_Unknown:
return os << "??" << value;