commit 8459ead04739e31e2169952504ecdd53cb172896
parent cfea70242e17a07c66a75f0a48768f1bf16c8b4c
Author: William Casarin <jb55@jb55.com>
Date: Sat, 17 Jul 2021 12:51:02 -0700
valtype fixes
Signed-off-by: William Casarin <jb55@jb55.com>
Diffstat:
2 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/src/wasm.c b/src/wasm.c
@@ -247,8 +247,8 @@ static int builtin_get_args_prep(struct wasm_interp *interp)
*/
static struct builtin BUILTINS[] = {
- { .name = "args_get", .fn = builtin_get_args },
- { .name = "args_sizes_get", .fn = builtin_get_args_sizes },
+ { .name = "args_get", .fn = builtin_get_args, .num_locals = 2 },
+ { .name = "args_sizes_get", .fn = builtin_get_args_sizes, .num_locals = 2 },
};
static const int NUM_BUILTINS = sizeof(BUILTINS) / sizeof(*BUILTINS);
@@ -257,13 +257,14 @@ static int parse_instr(struct expr_parser *parser, u8 tag, struct instr *op);
static INLINE int is_valtype(unsigned char byte)
{
- switch (byte) {
- case 0x7F: // i32
- case 0x7E: // i64
- case 0x7D: // f32
- case 0x7C: // f64
- case 0x70: // funcref
- case 0x6F: // externref
+ switch ((enum valtype)byte) {
+ case val_i32: // i32
+ case val_i64: // i64
+ case val_f32: // f32
+ case val_f64: // f64
+ case val_ref_func: // funcref
+ case val_ref_null: // null
+ case val_ref_extern: // externref
return 1;
}
diff --git a/src/wasm.h b/src/wasm.h
@@ -15,13 +15,13 @@ static const unsigned char WASM_MAGIC[] = {0,'a','s','m'};
#include "error.h"
enum valtype {
- val_i32,
- val_i64,
- val_f32,
- val_f64,
- val_ref_null,
- val_ref_func,
- val_ref_extern,
+ val_i32 = 0x7F,
+ val_i64 = 0x7E,
+ val_f32 = 0x7D,
+ val_f64 = 0x7C,
+ val_ref_null = 0xD0, // not sure if this is right...
+ val_ref_func = 0x70,
+ val_ref_extern = 0x6F,
};
enum const_instr {