diff options
| author | Rose Hogenson <rosehogenson@posteo.net> | 2024-02-04 16:46:20 -0800 |
|---|---|---|
| committer | Rose Hogenson <rosehogenson@posteo.net> | 2024-02-04 16:46:20 -0800 |
| commit | 17face3633686e374aa0859271ccf462a48e60aa (patch) | |
| tree | 6a5482717ef1b8194ccf347a6d8af06d664902cd /bytecode/value.c | |
| parent | d940187fd8720e0ab3c00e5a6a7ae8f181c7752d (diff) | |
| download | sml-17face3633686e374aa0859271ccf462a48e60aa.tar.zst | |
Rewrite the bytecode interpreter in Rust.
Diffstat (limited to 'bytecode/value.c')
| -rw-r--r-- | bytecode/value.c | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/bytecode/value.c b/bytecode/value.c deleted file mode 100644 index 1b18a96..0000000 --- a/bytecode/value.c +++ /dev/null @@ -1,42 +0,0 @@ -#include <stdbool.h> -#include <stdint.h> - -#include "panic.h" - -#include "value.h" - -bool is_int(value v) -{ - return v & 0x1; -} - -int64_t to_int(value v) -{ - if (!is_int(v)) { - panicf("value 0x%lx is not an int!\n", v); - } - return (int64_t) v >> 1; -} - -value from_int(int64_t i) -{ - return i << 1 | 0x1; -} - -bool is_pointer(value v) -{ - return v && !(v & 0x7); -} - -value *to_pointer(value v) -{ - if (!is_pointer(v)) { - panicf("value 0x%lx is not a pointer!\n", v); - } - return (value *) v; -} - -value from_pointer(value *p) -{ - return (value) p; -} |
