mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
[Tolk] Get rid of ~tilda with mutate
and self
methods
This is a very big change. If FunC has `.methods()` and `~methods()`, Tolk has only dot, one and only way to call a `.method()`. A method may mutate an object, or may not. It's a behavioral and semantic difference from FunC. - `cs.loadInt(32)` modifies a slice and returns an integer - `b.storeInt(x, 32)` modifies a builder - `b = b.storeInt()` also works, since it not only modifies, but returns - chained methods also work, they return `self` - everything works exactly as expected, similar to JS - no runtime overhead, exactly same Fift instructions - custom methods are created with ease - tilda `~` does not exist in Tolk at all
This commit is contained in:
parent
12ff28ac94
commit
d9dba320cc
85 changed files with 2710 additions and 1965 deletions
|
@ -1,3 +1,5 @@
|
|||
import "@stdlib/tvm-lowlevel"
|
||||
|
||||
fun pair_first<X, Y>(p: [X, Y]): X asm "FIRST";
|
||||
|
||||
fun one(dummy: tuple) {
|
||||
|
@ -35,13 +37,34 @@ fun test88(x: int) {
|
|||
@method_id(89)
|
||||
fun test89(last: int) {
|
||||
var t: tuple = createEmptyTuple();
|
||||
t~tuplePush(1);
|
||||
t~tuplePush(2);
|
||||
t~tuplePush(3);
|
||||
t~tuplePush(last);
|
||||
t.tuplePush(1);
|
||||
t.tuplePush(2);
|
||||
t.tuplePush(3);
|
||||
t.tuplePush(last);
|
||||
return (t.tupleAt(0), t.tupleAt(t.tupleSize() - 1), t.tupleFirst(), t.tupleLast());
|
||||
}
|
||||
|
||||
@pure fun get10() { return 10; }
|
||||
|
||||
@method_id(91)
|
||||
fun touchCodegen2() {
|
||||
var f = get10();
|
||||
f.stackMoveToTop();
|
||||
return f;
|
||||
}
|
||||
|
||||
@method_id(92)
|
||||
fun testDumpDontPolluteStack() {
|
||||
var f = get10();
|
||||
f.debugPrint();
|
||||
debugPrint(10);
|
||||
var s = "asdf";
|
||||
s.debugPrintString();
|
||||
debugDumpStack();
|
||||
debugPrintString("my");
|
||||
return (f, getRemainingBitsCount(s));
|
||||
}
|
||||
|
||||
@method_id(93)
|
||||
fun testStartBalanceCodegen1() {
|
||||
var t = getMyOriginalBalanceWithExtraCurrencies();
|
||||
|
@ -65,7 +88,27 @@ fun testStartBalanceCodegen2() {
|
|||
@testcase | 88 | 5 | 234
|
||||
@testcase | 88 | 50 | 0
|
||||
@testcase | 89 | 4 | 1 4 1 4
|
||||
@testcase | 91 | | 10
|
||||
@testcase | 92 | | 10 32
|
||||
|
||||
@fif_codegen
|
||||
"""
|
||||
touchCodegen2 PROC:<{
|
||||
//
|
||||
get10 CALLDICT // f
|
||||
}>
|
||||
"""
|
||||
|
||||
@fif_codegen
|
||||
"""
|
||||
testDumpDontPolluteStack PROC:<{
|
||||
...
|
||||
DUMPSTK
|
||||
x{6d79} PUSHSLICE // f s _9
|
||||
STRDUMP DROP
|
||||
SBITS // f _11
|
||||
}>
|
||||
"""
|
||||
|
||||
@fif_codegen
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue