Skip to content

Commit 41017ab

Browse files
committed
Introduce tvm_setreg, tvm_setglobal overloadable functions
1 parent a978b19 commit 41017ab

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

stdlib/ton-sdk/tvm.c

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,50 @@ Cell Deserialize_Cell() {
6565
int s = __builtin_tvm_getglobal(3);
6666
struct __attribute__((tvm_tuple)) { __tvm_cell c; __tvm_slice s; } st =
6767
__builtin_tvm_ldref(__builtin_tvm_cast_to_slice(s));
68-
__builtin_tvm_setglobal(3, __builtin_tvm_cast_from_slice(st.s));
68+
tvm_setglobal(3, st.s);
6969
return st.c;
7070
}
7171

7272
void tvm_accept(void) {
7373
__builtin_tvm_accept();
7474
}
75+
76+
__attribute__((overloadable))
77+
void tvm_setreg(int n, int value) {
78+
__builtin_tvm_setreg(n, value);
79+
}
80+
81+
__attribute__((overloadable))
82+
void tvm_setreg(int n, __tvm_builder value) {
83+
__builtin_tvm_setreg(n, __builtin_tvm_cast_from_builder(value));
84+
}
85+
86+
__attribute__((overloadable))
87+
void tvm_setreg(int n, __tvm_cell value) {
88+
__builtin_tvm_setreg(n, __builtin_tvm_cast_from_cell(value));
89+
}
90+
91+
__attribute__((overloadable))
92+
void tvm_setreg(int n, __tvm_slice value) {
93+
__builtin_tvm_setreg(n, __builtin_tvm_cast_from_slice(value));
94+
}
95+
96+
__attribute__((overloadable))
97+
void tvm_setglobal(int n, int value) {
98+
__builtin_tvm_setglobal(n, value);
99+
}
100+
101+
__attribute__((overloadable))
102+
void tvm_setglobal(int n, __tvm_builder value) {
103+
__builtin_tvm_setglobal(n, __builtin_tvm_cast_from_builder(value));
104+
}
105+
106+
__attribute__((overloadable))
107+
void tvm_setglobal(int n, __tvm_cell value) {
108+
__builtin_tvm_setglobal(n, __builtin_tvm_cast_from_cell(value));
109+
}
110+
111+
__attribute__((overloadable))
112+
void tvm_setglobal(int n, __tvm_slice value) {
113+
__builtin_tvm_setglobal(n, __builtin_tvm_cast_from_slice(value));
114+
}

stdlib/ton-sdk/tvm.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,14 @@ Cell Deserialize_Cell ();
3838
__tvm_slice __tvm_ldu(__tvm_slice slice, int width, int *value);
3939
__tvm_slice __tvm_ldi(__tvm_slice slice, int width, int *value);
4040

41+
__attribute__((overloadable)) void tvm_setreg(int n, int value);
42+
__attribute__((overloadable)) void tvm_setreg(int n, __tvm_builder value);
43+
__attribute__((overloadable)) void tvm_setreg(int n, __tvm_cell value);
44+
__attribute__((overloadable)) void tvm_setreg(int n, __tvm_slice value);
45+
46+
__attribute__((overloadable)) void tvm_setglobal(int n, int value);
47+
__attribute__((overloadable)) void tvm_setglobal(int n, __tvm_builder value);
48+
__attribute__((overloadable)) void tvm_setglobal(int n, __tvm_cell value);
49+
__attribute__((overloadable)) void tvm_setglobal(int n, __tvm_slice value);
50+
4151
#endif

0 commit comments

Comments
 (0)