Skip to content

Commit b4b1254

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

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

stdlib/ton-sdk/tvm.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,11 @@ 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+

stdlib/ton-sdk/tvm.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,44 @@ 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, always_inline))
42+
static void tvm_setreg(int n, int value) {
43+
__builtin_tvm_setreg(n, value);
44+
}
45+
46+
__attribute__((overloadable, always_inline))
47+
static void tvm_setreg(int n, __tvm_builder value) {
48+
__builtin_tvm_setreg(n, __builtin_tvm_cast_from_builder(value));
49+
}
50+
51+
__attribute__((overloadable, always_inline))
52+
static void tvm_setreg(int n, __tvm_cell value) {
53+
__builtin_tvm_setreg(n, __builtin_tvm_cast_from_cell(value));
54+
}
55+
56+
__attribute__((overloadable, always_inline))
57+
static void tvm_setreg(int n, __tvm_slice value) {
58+
__builtin_tvm_setreg(n, __builtin_tvm_cast_from_slice(value));
59+
}
60+
61+
__attribute__((overloadable, always_inline))
62+
static void tvm_setglobal(int n, int value) {
63+
__builtin_tvm_setglobal(n, value);
64+
}
65+
66+
__attribute__((overloadable, always_inline))
67+
static void tvm_setglobal(int n, __tvm_builder value) {
68+
__builtin_tvm_setglobal(n, __builtin_tvm_cast_from_builder(value));
69+
}
70+
71+
__attribute__((overloadable, always_inline))
72+
static void tvm_setglobal(int n, __tvm_cell value) {
73+
__builtin_tvm_setglobal(n, __builtin_tvm_cast_from_cell(value));
74+
}
75+
76+
__attribute__((overloadable, always_inline))
77+
static void tvm_setglobal(int n, __tvm_slice value) {
78+
__builtin_tvm_setglobal(n, __builtin_tvm_cast_from_slice(value));
79+
}
80+
4181
#endif

0 commit comments

Comments
 (0)