Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce tvm_setreg overloadable function #106

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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