Skip to content

Commit

Permalink
Introduce tvm_setreg, tvm_setglobal overloadable functions
Browse files Browse the repository at this point in the history
  • Loading branch information
akiramenai committed Feb 20, 2020
1 parent a978b19 commit b4b1254
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
3 changes: 2 additions & 1 deletion stdlib/ton-sdk/tvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ Cell Deserialize_Cell() {
int s = __builtin_tvm_getglobal(3);
struct __attribute__((tvm_tuple)) { __tvm_cell c; __tvm_slice s; } st =
__builtin_tvm_ldref(__builtin_tvm_cast_to_slice(s));
__builtin_tvm_setglobal(3, __builtin_tvm_cast_from_slice(st.s));
tvm_setglobal(3, st.s);
return st.c;
}

void tvm_accept(void) {
__builtin_tvm_accept();
}

40 changes: 40 additions & 0 deletions stdlib/ton-sdk/tvm.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,44 @@ Cell Deserialize_Cell ();
__tvm_slice __tvm_ldu(__tvm_slice slice, int width, int *value);
__tvm_slice __tvm_ldi(__tvm_slice slice, int width, int *value);

__attribute__((overloadable, always_inline))
static void tvm_setreg(int n, int value) {
__builtin_tvm_setreg(n, value);
}

__attribute__((overloadable, always_inline))
static void tvm_setreg(int n, __tvm_builder value) {
__builtin_tvm_setreg(n, __builtin_tvm_cast_from_builder(value));
}

__attribute__((overloadable, always_inline))
static void tvm_setreg(int n, __tvm_cell value) {
__builtin_tvm_setreg(n, __builtin_tvm_cast_from_cell(value));
}

__attribute__((overloadable, always_inline))
static void tvm_setreg(int n, __tvm_slice value) {
__builtin_tvm_setreg(n, __builtin_tvm_cast_from_slice(value));
}

__attribute__((overloadable, always_inline))
static void tvm_setglobal(int n, int value) {
__builtin_tvm_setglobal(n, value);
}

__attribute__((overloadable, always_inline))
static void tvm_setglobal(int n, __tvm_builder value) {
__builtin_tvm_setglobal(n, __builtin_tvm_cast_from_builder(value));
}

__attribute__((overloadable, always_inline))
static void tvm_setglobal(int n, __tvm_cell value) {
__builtin_tvm_setglobal(n, __builtin_tvm_cast_from_cell(value));
}

__attribute__((overloadable, always_inline))
static void tvm_setglobal(int n, __tvm_slice value) {
__builtin_tvm_setglobal(n, __builtin_tvm_cast_from_slice(value));
}

#endif

0 comments on commit b4b1254

Please sign in to comment.