Skip to content

Commit

Permalink
refactor(stdlib): rewrite pow in Tact (#1821)
Browse files Browse the repository at this point in the history
  • Loading branch information
i582 authored Feb 13, 2025
1 parent 657dfdd commit dcb88ef
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 145 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1681,25 +1681,6 @@ return result;",
"name": "__tact_log",
"signature": "int __tact_log(int num, int base)",
},
{
"code": {
"code": "throw_unless(5, exp >= 0);
int result = 1;
repeat (exp) {
result *= base;
}
return result;",
"kind": "generic",
},
"comment": null,
"context": "stdlib",
"depends": Set {},
"flags": Set {
"inline",
},
"name": "__tact_pow",
"signature": "int __tact_pow(int base, int exp)",
},
{
"code": {
"code": "var (r, ok) = __tact_dict_get(d, kl, k);
Expand Down Expand Up @@ -7478,25 +7459,6 @@ return result;",
"name": "__tact_log",
"signature": "int __tact_log(int num, int base)",
},
{
"code": {
"code": "throw_unless(5, exp >= 0);
int result = 1;
repeat (exp) {
result *= base;
}
return result;",
"kind": "generic",
},
"comment": null,
"context": "stdlib",
"depends": Set {},
"flags": Set {
"inline",
},
"name": "__tact_pow",
"signature": "int __tact_pow(int base, int exp)",
},
{
"code": {
"code": "var (r, ok) = __tact_dict_get(d, kl, k);
Expand Down Expand Up @@ -13275,25 +13237,6 @@ return result;",
"name": "__tact_log",
"signature": "int __tact_log(int num, int base)",
},
{
"code": {
"code": "throw_unless(5, exp >= 0);
int result = 1;
repeat (exp) {
result *= base;
}
return result;",
"kind": "generic",
},
"comment": null,
"context": "stdlib",
"depends": Set {},
"flags": Set {
"inline",
},
"name": "__tact_pow",
"signature": "int __tact_pow(int base, int exp)",
},
{
"code": {
"code": "var (r, ok) = __tact_dict_get(d, kl, k);
Expand Down
16 changes: 0 additions & 16 deletions src/generator/writers/writeStdlib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1076,22 +1076,6 @@ export function writeStdlib(ctx: WriterContext): void {
});
});

ctx.fun(`__tact_pow`, () => {
ctx.signature(`int __tact_pow(int base, int exp)`);
ctx.flag("inline");
ctx.context("stdlib");
ctx.body(() => {
ctx.write(`
throw_unless(5, exp >= 0);
int result = 1;
repeat (exp) {
result *= base;
}
return result;
`);
});
});

// generate dict operations for all combinations of key/value types
for (const key of keyTypes) {
for (const val of valTypes) {
Expand Down
Loading

0 comments on commit dcb88ef

Please sign in to comment.