summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/allocator.c34
-rw-r--r--src/allocator.h78
-rw-r--r--src/apply-names.c262
-rw-r--r--src/apply-names.h18
-rw-r--r--src/array.h36
-rw-r--r--src/ast-lexer.c180
-rw-r--r--src/ast-lexer.h42
-rw-r--r--src/ast-parser-lexer-shared.c98
-rw-r--r--src/ast-parser-lexer-shared.h288
-rw-r--r--src/ast-parser.h18
-rw-r--r--src/ast-parser.y754
-rw-r--r--src/ast-writer.c310
-rw-r--r--src/ast-writer.h18
-rw-r--r--src/ast.c722
-rw-r--r--src/ast.h906
-rw-r--r--src/binary-reader-ast.c808
-rw-r--r--src/binary-reader-ast.h24
-rw-r--r--src/binary-reader-interpreter.c1106
-rw-r--r--src/binary-reader-interpreter.h32
-rw-r--r--src/binary-reader-linker.c204
-rw-r--r--src/binary-reader-linker.h18
-rw-r--r--src/binary-reader-objdump.c426
-rw-r--r--src/binary-reader-objdump.h68
-rw-r--r--src/binary-reader-opcnt.c102
-rw-r--r--src/binary-reader-opcnt.h60
-rw-r--r--src/binary-reader.c806
-rw-r--r--src/binary-reader.h350
-rw-r--r--src/binary-writer-spec.c266
-rw-r--r--src/binary-writer-spec.h30
-rw-r--r--src/binary-writer.c632
-rw-r--r--src/binary-writer.h74
-rw-r--r--src/binary.c4
-rw-r--r--src/binary.h40
-rw-r--r--src/binding-hash.c96
-rw-r--r--src/binding-hash.h66
-rw-r--r--src/common.c100
-rw-r--r--src/common.h340
-rw-r--r--src/config.c6
-rw-r--r--src/config.h.in86
-rw-r--r--src/emscripten-exported.json425
-rw-r--r--src/emscripten-helpers.c56
-rw-r--r--src/generate-names.c114
-rw-r--r--src/generate-names.h16
-rw-r--r--src/interpreter.c1656
-rw-r--r--src/interpreter.h354
-rw-r--r--src/literal.c214
-rw-r--r--src/literal.h44
-rw-r--r--src/option-parser.c36
-rw-r--r--src/option-parser.h54
-rw-r--r--src/prebuilt/ast-lexer-gen.c9033
-rw-r--r--src/prebuilt/ast-parser-gen.c1020
-rw-r--r--src/prebuilt/ast-parser-gen.h190
-rw-r--r--src/prebuilt/ast-parser-gen.output4922
-rw-r--r--src/resolve-names.c278
-rw-r--r--src/resolve-names.h36
-rw-r--r--src/stack-allocator.c132
-rw-r--r--src/stack-allocator.h46
-rw-r--r--src/stream.c94
-rw-r--r--src/stream.h86
-rw-r--r--src/tools/wasm-interp.c1188
-rw-r--r--src/tools/wasm-link.c518
-rw-r--r--src/tools/wasm2wast.c110
-rw-r--r--src/tools/wasmdump.c84
-rw-r--r--src/tools/wasmopcodecnt.c186
-rw-r--r--src/tools/wast-desugar.c112
-rw-r--r--src/tools/wast2wasm.c140
-rw-r--r--src/type-vector.h24
-rw-r--r--src/validator.c732
-rw-r--r--src/validator.h22
-rw-r--r--src/vector-sort.h16
-rw-r--r--src/vector.c16
-rw-r--r--src/vector.h110
-rw-r--r--src/wabt.js (renamed from src/wasm.js)80
-rw-r--r--src/wasm-link.h104
-rw-r--r--src/writer.c96
-rw-r--r--src/writer.h72
76 files changed, 18814 insertions, 13110 deletions
diff --git a/src/allocator.c b/src/allocator.c
index d42ccf88..d29f8553 100644
--- a/src/allocator.c
+++ b/src/allocator.c
@@ -28,15 +28,15 @@ typedef struct MemInfo {
size_t size;
} MemInfo;
-static WasmBool s_has_jmpbuf;
+static WabtBool s_has_jmpbuf;
static jmp_buf s_jmpbuf;
#ifndef NDEBUG
-static WasmBool is_power_of_two(size_t x) {
+static WabtBool is_power_of_two(size_t x) {
return x && ((x & (x - 1)) == 0);
}
-static WasmBool is_aligned(void* p, size_t align) {
+static WabtBool is_aligned(void* p, size_t align) {
return ((intptr_t)p & (align - 1)) == 0;
}
#endif /* NDEBUG */
@@ -45,7 +45,7 @@ static void* align_up(void* p, size_t align) {
return (void*)(((intptr_t)p + align - 1) & ~(align - 1));
}
-static void* libc_alloc(WasmAllocator* allocator,
+static void* libc_alloc(WabtAllocator* allocator,
size_t size,
size_t align,
const char* file,
@@ -58,7 +58,7 @@ static void* libc_alloc(WasmAllocator* allocator,
if (!p) {
if (s_has_jmpbuf)
longjmp(s_jmpbuf, 1);
- WASM_FATAL("%s:%d: memory allocation failed\n", file, line);
+ WABT_FATAL("%s:%d: memory allocation failed\n", file, line);
}
void* aligned = align_up((void*)((size_t)p + sizeof(MemInfo)), align);
@@ -69,7 +69,7 @@ static void* libc_alloc(WasmAllocator* allocator,
return aligned;
}
-static void libc_free(WasmAllocator* allocator,
+static void libc_free(WabtAllocator* allocator,
void* p,
const char* file,
int line) {
@@ -81,9 +81,9 @@ static void libc_free(WasmAllocator* allocator,
}
/* nothing to destroy */
-static void libc_destroy(WasmAllocator* allocator) {}
+static void libc_destroy(WabtAllocator* allocator) {}
-static void* libc_realloc(WasmAllocator* allocator,
+static void* libc_realloc(WabtAllocator* allocator,
void* p,
size_t size,
size_t align,
@@ -101,26 +101,26 @@ static void* libc_realloc(WasmAllocator* allocator,
}
/* mark/reset_to_mark are not supported by the libc allocator */
-static WasmAllocatorMark libc_mark(WasmAllocator* allocator) {
+static WabtAllocatorMark libc_mark(WabtAllocator* allocator) {
return NULL;
}
-static void libc_reset_to_mark(WasmAllocator* allocator,
- WasmAllocatorMark mark) {}
+static void libc_reset_to_mark(WabtAllocator* allocator,
+ WabtAllocatorMark mark) {}
-static void libc_print_stats(WasmAllocator* allocator) {
+static void libc_print_stats(WabtAllocator* allocator) {
/* TODO(binji): nothing for now, implement later */
}
-static int libc_setjmp_handler(WasmAllocator* allocator) {
- s_has_jmpbuf = WASM_TRUE;
+static int libc_setjmp_handler(WabtAllocator* allocator) {
+ s_has_jmpbuf = WABT_TRUE;
return setjmp(s_jmpbuf);
}
-WasmAllocator g_wasm_libc_allocator = {
+WabtAllocator g_wabt_libc_allocator = {
libc_alloc, libc_realloc, libc_free, libc_destroy,
libc_mark, libc_reset_to_mark, libc_print_stats, libc_setjmp_handler};
-WasmAllocator* wasm_get_libc_allocator(void) {
- return &g_wasm_libc_allocator;
+WabtAllocator* wabt_get_libc_allocator(void) {
+ return &g_wabt_libc_allocator;
}
diff --git a/src/allocator.h b/src/allocator.h
index e074b4ac..433ce85f 100644
--- a/src/allocator.h
+++ b/src/allocator.h
@@ -14,76 +14,76 @@
* limitations under the License.
*/
-#ifndef WASM_ALLOCATOR_H_
-#define WASM_ALLOCATOR_H_
+#ifndef WABT_ALLOCATOR_H_
+#define WABT_ALLOCATOR_H_
#include <stdlib.h>
#include <string.h>
#include "common.h"
-#define WASM_DEFAULT_ALIGN sizeof(void*)
+#define WABT_DEFAULT_ALIGN sizeof(void*)
-typedef void* WasmAllocatorMark;
+typedef void* WabtAllocatorMark;
-typedef struct WasmAllocator {
- void* (*alloc)(struct WasmAllocator*,
+typedef struct WabtAllocator {
+ void* (*alloc)(struct WabtAllocator*,
size_t size,
size_t align,
const char* file,
int line);
- void* (*realloc)(struct WasmAllocator*,
+ void* (*realloc)(struct WabtAllocator*,
void* p,
size_t size,
size_t align,
const char* file,
int line);
- void (*free)(struct WasmAllocator*, void* p, const char* file, int line);
+ void (*free)(struct WabtAllocator*, void* p, const char* file, int line);
/* destroy the allocator */
- void (*destroy)(struct WasmAllocator*);
+ void (*destroy)(struct WabtAllocator*);
/* mark/reset_to_mark are only supported by the stack allocator */
- WasmAllocatorMark (*mark)(struct WasmAllocator*);
- void (*reset_to_mark)(struct WasmAllocator*, WasmAllocatorMark);
- void (*print_stats)(struct WasmAllocator*);
+ WabtAllocatorMark (*mark)(struct WabtAllocator*);
+ void (*reset_to_mark)(struct WabtAllocator*, WabtAllocatorMark);
+ void (*print_stats)(struct WabtAllocator*);
/* set the location to longjmp to if allocation fails. the return value is 0
* for normal execution, and 1 if an allocation failed. */
- int (*setjmp_handler)(struct WasmAllocator*);
-} WasmAllocator;
+ int (*setjmp_handler)(struct WabtAllocator*);
+} WabtAllocator;
-extern WasmAllocator g_wasm_libc_allocator;
+extern WabtAllocator g_wabt_libc_allocator;
-#define wasm_alloc(allocator, size, align) \
+#define wabt_alloc(allocator, size, align) \
(allocator)->alloc((allocator), (size), (align), __FILE__, __LINE__)
-#define wasm_alloc_zero(allocator, size, align) \
- wasm_alloc_zero_((allocator), (size), (align), __FILE__, __LINE__)
+#define wabt_alloc_zero(allocator, size, align) \
+ wabt_alloc_zero_((allocator), (size), (align), __FILE__, __LINE__)
-#define wasm_realloc(allocator, p, size, align) \
+#define wabt_realloc(allocator, p, size, align) \
(allocator)->realloc((allocator), (p), (size), (align), __FILE__, __LINE__)
-#define wasm_free(allocator, p) \
+#define wabt_free(allocator, p) \
(allocator)->free((allocator), (p), __FILE__, __LINE__)
-#define wasm_destroy_allocator(allocator) (allocator)->destroy(allocator)
-#define wasm_mark(allocator) (allocator)->mark(allocator)
+#define wabt_destroy_allocator(allocator) (allocator)->destroy(allocator)
+#define wabt_mark(allocator) (allocator)->mark(allocator)
-#define wasm_reset_to_mark(allocator, mark) \
+#define wabt_reset_to_mark(allocator, mark) \
(allocator)->reset_to_mark(allocator, mark)
-#define wasm_print_allocator_stats(allocator) \
+#define wabt_print_allocator_stats(allocator) \
(allocator)->print_stats(allocator)
-#define wasm_strndup(allocator, s, len) \
- wasm_strndup_(allocator, s, len, __FILE__, __LINE__)
+#define wabt_strndup(allocator, s, len) \
+ wabt_strndup_(allocator, s, len, __FILE__, __LINE__)
-#define wasm_dup_string_slice(allocator, str) \
- wasm_dup_string_slice_(allocator, str, __FILE__, __LINE__)
+#define wabt_dup_string_slice(allocator, str) \
+ wabt_dup_string_slice_(allocator, str, __FILE__, __LINE__)
-WASM_EXTERN_C_BEGIN
+WABT_EXTERN_C_BEGIN
-WasmAllocator* wasm_get_libc_allocator(void);
+WabtAllocator* wabt_get_libc_allocator(void);
-static WASM_INLINE void* wasm_alloc_zero_(WasmAllocator* allocator,
+static WABT_INLINE void* wabt_alloc_zero_(WabtAllocator* allocator,
size_t size,
size_t align,
const char* file,
@@ -93,7 +93,7 @@ static WASM_INLINE void* wasm_alloc_zero_(WasmAllocator* allocator,
return result;
}
-static WASM_INLINE char* wasm_strndup_(WasmAllocator* allocator,
+static WABT_INLINE char* wabt_strndup_(WabtAllocator* allocator,
const char* s,
size_t len,
const char* file,
@@ -111,17 +111,17 @@ static WASM_INLINE char* wasm_strndup_(WasmAllocator* allocator,
return new_s;
}
-static WASM_INLINE WasmStringSlice
-wasm_dup_string_slice_(WasmAllocator* allocator,
- WasmStringSlice str,
+static WABT_INLINE WabtStringSlice
+wabt_dup_string_slice_(WabtAllocator* allocator,
+ WabtStringSlice str,
const char* file,
int line) {
- WasmStringSlice result;
- result.start = wasm_strndup_(allocator, str.start, str.length, file, line);
+ WabtStringSlice result;
+ result.start = wabt_strndup_(allocator, str.start, str.length, file, line);
result.length = str.length;
return result;
}
-WASM_EXTERN_C_END
+WABT_EXTERN_C_END
-#endif /* WASM_ALLOCATOR_H_ */
+#endif /* WABT_ALLOCATOR_H_ */
diff --git a/src/apply-names.c b/src/apply-names.c
index 96e2c2b0..084a22fc 100644
--- a/src/apply-names.c
+++ b/src/apply-names.c
@@ -24,26 +24,26 @@
#define CHECK_RESULT(expr) \
do { \
- if (WASM_FAILED(expr)) \
- return WASM_ERROR; \
+ if (WABT_FAILED(expr)) \
+ return WABT_ERROR; \
} while (0)
-typedef WasmLabel* LabelPtr;
-WASM_DEFINE_VECTOR(label_ptr, LabelPtr);
+typedef WabtLabel* LabelPtr;
+WABT_DEFINE_VECTOR(label_ptr, LabelPtr);
typedef struct Context {
- WasmAllocator* allocator;
- WasmModule* module;
- WasmFunc* current_func;
- WasmExprVisitor visitor;
+ WabtAllocator* allocator;
+ WabtModule* module;
+ WabtFunc* current_func;
+ WabtExprVisitor visitor;
/* mapping from param index to its name, if any, for the current func */
- WasmStringSliceVector param_index_to_name;
- WasmStringSliceVector local_index_to_name;
+ WabtStringSliceVector param_index_to_name;
+ WabtStringSliceVector local_index_to_name;
LabelPtrVector labels;
} Context;
-static void push_label(Context* ctx, WasmLabel* label) {
- wasm_append_label_ptr_value(ctx->allocator, &ctx->labels, &label);
+static void push_label(Context* ctx, WabtLabel* label) {
+ wabt_append_label_ptr_value(ctx->allocator, &ctx->labels, &label);
}
static void pop_label(Context* ctx) {
@@ -51,12 +51,12 @@ static void pop_label(Context* ctx) {
ctx->labels.size--;
}
-static WasmLabel* find_label_by_var(Context* ctx, WasmVar* var) {
- if (var->type == WASM_VAR_TYPE_NAME) {
+static WabtLabel* find_label_by_var(Context* ctx, WabtVar* var) {
+ if (var->type == WABT_VAR_TYPE_NAME) {
int i;
for (i = ctx->labels.size - 1; i >= 0; --i) {
- WasmLabel* label = ctx->labels.data[i];
- if (wasm_string_slices_are_equal(label, &var->name))
+ WabtLabel* label = ctx->labels.data[i];
+ if (wabt_string_slices_are_equal(label, &var->name))
return label;
}
return NULL;
@@ -67,79 +67,79 @@ static WasmLabel* find_label_by_var(Context* ctx, WasmVar* var) {
}
}
-static void use_name_for_var(WasmAllocator* allocator,
- WasmStringSlice* name,
- WasmVar* var) {
- if (var->type == WASM_VAR_TYPE_NAME) {
- assert(wasm_string_slices_are_equal(name, &var->name));
+static void use_name_for_var(WabtAllocator* allocator,
+ WabtStringSlice* name,
+ WabtVar* var) {
+ if (var->type == WABT_VAR_TYPE_NAME) {
+ assert(wabt_string_slices_are_equal(name, &var->name));
}
if (name && name->start) {
- var->type = WASM_VAR_TYPE_NAME;
- var->name = wasm_dup_string_slice(allocator, *name);
+ var->type = WABT_VAR_TYPE_NAME;
+ var->name = wabt_dup_string_slice(allocator, *name);
}
}
-static WasmResult use_name_for_func_type_var(WasmAllocator* allocator,
- WasmModule* module,
- WasmVar* var) {
- WasmFuncType* func_type = wasm_get_func_type_by_var(module, var);
+static WabtResult use_name_for_func_type_var(WabtAllocator* allocator,
+ WabtModule* module,
+ WabtVar* var) {
+ WabtFuncType* func_type = wabt_get_func_type_by_var(module, var);
if (func_type == NULL)
- return WASM_ERROR;
+ return WABT_ERROR;
use_name_for_var(allocator, &func_type->name, var);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult use_name_for_func_var(WasmAllocator* allocator,
- WasmModule* module,
- WasmVar* var) {
- WasmFunc* func = wasm_get_func_by_var(module, var);
+static WabtResult use_name_for_func_var(WabtAllocator* allocator,
+ WabtModule* module,
+ WabtVar* var) {
+ WabtFunc* func = wabt_get_func_by_var(module, var);
if (func == NULL)
- return WASM_ERROR;
+ return WABT_ERROR;
use_name_for_var(allocator, &func->name, var);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult use_name_for_global_var(WasmAllocator* allocator,
- WasmModule* module,
- WasmVar* var) {
- WasmGlobal* global = wasm_get_global_by_var(module, var);
+static WabtResult use_name_for_global_var(WabtAllocator* allocator,
+ WabtModule* module,
+ WabtVar* var) {
+ WabtGlobal* global = wabt_get_global_by_var(module, var);
if (global == NULL)
- return WASM_ERROR;
+ return WABT_ERROR;
use_name_for_var(allocator, &global->name, var);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult use_name_for_table_var(WasmAllocator* allocator,
- WasmModule* module,
- WasmVar* var) {
- WasmTable* table = wasm_get_table_by_var(module, var);
+static WabtResult use_name_for_table_var(WabtAllocator* allocator,
+ WabtModule* module,
+ WabtVar* var) {
+ WabtTable* table = wabt_get_table_by_var(module, var);
if (table == NULL)
- return WASM_ERROR;
+ return WABT_ERROR;
use_name_for_var(allocator, &table->name, var);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult use_name_for_memory_var(WasmAllocator* allocator,
- WasmModule* module,
- WasmVar* var) {
- WasmMemory* memory = wasm_get_memory_by_var(module, var);
+static WabtResult use_name_for_memory_var(WabtAllocator* allocator,
+ WabtModule* module,
+ WabtVar* var) {
+ WabtMemory* memory = wabt_get_memory_by_var(module, var);
if (memory == NULL)
- return WASM_ERROR;
+ return WABT_ERROR;
use_name_for_var(allocator, &memory->name, var);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult use_name_for_param_and_local_var(Context* ctx,
- WasmFunc* func,
- WasmVar* var) {
- int local_index = wasm_get_local_index_by_var(func, var);
+static WabtResult use_name_for_param_and_local_var(Context* ctx,
+ WabtFunc* func,
+ WabtVar* var) {
+ int local_index = wabt_get_local_index_by_var(func, var);
if (local_index < 0 ||
- (size_t)local_index >= wasm_get_num_params_and_locals(func))
- return WASM_ERROR;
+ (size_t)local_index >= wabt_get_num_params_and_locals(func))
+ return WABT_ERROR;
- uint32_t num_params = wasm_get_num_params(func);
- WasmStringSlice* name;
+ uint32_t num_params = wabt_get_num_params(func);
+ WabtStringSlice* name;
if ((uint32_t)local_index < num_params) {
/* param */
assert((size_t)local_index < ctx->param_index_to_name.size);
@@ -151,167 +151,167 @@ static WasmResult use_name_for_param_and_local_var(Context* ctx,
name = &ctx->local_index_to_name.data[local_index];
}
- if (var->type == WASM_VAR_TYPE_NAME) {
- assert(wasm_string_slices_are_equal(name, &var->name));
- return WASM_OK;
+ if (var->type == WABT_VAR_TYPE_NAME) {
+ assert(wabt_string_slices_are_equal(name, &var->name));
+ return WABT_OK;
}
if (name->start) {
- var->type = WASM_VAR_TYPE_NAME;
- var->name = wasm_dup_string_slice(ctx->allocator, *name);
- return var->name.start != NULL ? WASM_OK : WASM_ERROR;
+ var->type = WABT_VAR_TYPE_NAME;
+ var->name = wabt_dup_string_slice(ctx->allocator, *name);
+ return var->name.start != NULL ? WABT_OK : WABT_ERROR;
}
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult begin_block_expr(WasmExpr* expr, void* user_data) {
+static WabtResult begin_block_expr(WabtExpr* expr, void* user_data) {
Context* ctx = user_data;
push_label(ctx, &expr->block.label);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult end_block_expr(WasmExpr* expr, void* user_data) {
+static WabtResult end_block_expr(WabtExpr* expr, void* user_data) {
Context* ctx = user_data;
pop_label(ctx);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult begin_loop_expr(WasmExpr* expr, void* user_data) {
+static WabtResult begin_loop_expr(WabtExpr* expr, void* user_data) {
Context* ctx = user_data;
push_label(ctx, &expr->loop.label);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult end_loop_expr(WasmExpr* expr, void* user_data) {
+static WabtResult end_loop_expr(WabtExpr* expr, void* user_data) {
Context* ctx = user_data;
pop_label(ctx);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_br_expr(WasmExpr* expr, void* user_data) {
+static WabtResult on_br_expr(WabtExpr* expr, void* user_data) {
Context* ctx = user_data;
- WasmLabel* label = find_label_by_var(ctx, &expr->br.var);
+ WabtLabel* label = find_label_by_var(ctx, &expr->br.var);
use_name_for_var(ctx->allocator, label, &expr->br.var);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_br_if_expr(WasmExpr* expr, void* user_data) {
+static WabtResult on_br_if_expr(WabtExpr* expr, void* user_data) {
Context* ctx = user_data;
- WasmLabel* label = find_label_by_var(ctx, &expr->br_if.var);
+ WabtLabel* label = find_label_by_var(ctx, &expr->br_if.var);
use_name_for_var(ctx->allocator, label, &expr->br_if.var);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_br_table_expr(WasmExpr* expr, void* user_data) {
+static WabtResult on_br_table_expr(WabtExpr* expr, void* user_data) {
Context* ctx = user_data;
size_t i;
- WasmVarVector* targets = &expr->br_table.targets;
+ WabtVarVector* targets = &expr->br_table.targets;
for (i = 0; i < targets->size; ++i) {
- WasmVar* target = &targets->data[i];
- WasmLabel* label = find_label_by_var(ctx, target);
+ WabtVar* target = &targets->data[i];
+ WabtLabel* label = find_label_by_var(ctx, target);
use_name_for_var(ctx->allocator, label, target);
}
- WasmLabel* label = find_label_by_var(ctx, &expr->br_table.default_target);
+ WabtLabel* label = find_label_by_var(ctx, &expr->br_table.default_target);
use_name_for_var(ctx->allocator, label, &expr->br_table.default_target);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_call_expr(WasmExpr* expr, void* user_data) {
+static WabtResult on_call_expr(WabtExpr* expr, void* user_data) {
Context* ctx = user_data;
CHECK_RESULT(
use_name_for_func_var(ctx->allocator, ctx->module, &expr->call.var));
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_call_indirect_expr(WasmExpr* expr, void* user_data) {
+static WabtResult on_call_indirect_expr(WabtExpr* expr, void* user_data) {
Context* ctx = user_data;
CHECK_RESULT(use_name_for_func_type_var(ctx->allocator, ctx->module,
&expr->call_indirect.var));
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_get_global_expr(WasmExpr* expr, void* user_data) {
+static WabtResult on_get_global_expr(WabtExpr* expr, void* user_data) {
Context* ctx = user_data;
CHECK_RESULT(use_name_for_global_var(ctx->allocator, ctx->module,
&expr->get_global.var));
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_get_local_expr(WasmExpr* expr, void* user_data) {
+static WabtResult on_get_local_expr(WabtExpr* expr, void* user_data) {
Context* ctx = user_data;
CHECK_RESULT(use_name_for_param_and_local_var(ctx, ctx->current_func,
&expr->get_local.var));
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult begin_if_expr(WasmExpr* expr, void* user_data) {
+static WabtResult begin_if_expr(WabtExpr* expr, void* user_data) {
Context* ctx = user_data;
push_label(ctx, &expr->if_.true_.label);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult end_if_expr(WasmExpr* expr, void* user_data) {
+static WabtResult end_if_expr(WabtExpr* expr, void* user_data) {
Context* ctx = user_data;
pop_label(ctx);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_set_global_expr(WasmExpr* expr, void* user_data) {
+static WabtResult on_set_global_expr(WabtExpr* expr, void* user_data) {
Context* ctx = user_data;
CHECK_RESULT(use_name_for_global_var(ctx->allocator, ctx->module,
&expr->set_global.var));
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_set_local_expr(WasmExpr* expr, void* user_data) {
+static WabtResult on_set_local_expr(WabtExpr* expr, void* user_data) {
Context* ctx = user_data;
CHECK_RESULT(use_name_for_param_and_local_var(ctx, ctx->current_func,
&expr->set_local.var));
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_tee_local_expr(WasmExpr* expr, void* user_data) {
+static WabtResult on_tee_local_expr(WabtExpr* expr, void* user_data) {
Context* ctx = user_data;
CHECK_RESULT(use_name_for_param_and_local_var(ctx, ctx->current_func,
&expr->tee_local.var));
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult visit_func(Context* ctx,
+static WabtResult visit_func(Context* ctx,
uint32_t func_index,
- WasmFunc* func) {
+ WabtFunc* func) {
ctx->current_func = func;
- if (wasm_decl_has_func_type(&func->decl)) {
+ if (wabt_decl_has_func_type(&func->decl)) {
CHECK_RESULT(use_name_for_func_type_var(ctx->allocator, ctx->module,
&func->decl.type_var));
}
- wasm_make_type_binding_reverse_mapping(
+ wabt_make_type_binding_reverse_mapping(
ctx->allocator, &func->decl.sig.param_types, &func->param_bindings,
&ctx->param_index_to_name);
- wasm_make_type_binding_reverse_mapping(ctx->allocator, &func->local_types,
+ wabt_make_type_binding_reverse_mapping(ctx->allocator, &func->local_types,
&func->local_bindings,
&ctx->local_index_to_name);
- CHECK_RESULT(wasm_visit_func(func, &ctx->visitor));
+ CHECK_RESULT(wabt_visit_func(func, &ctx->visitor));
ctx->current_func = NULL;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult visit_export(Context* ctx,
+static WabtResult visit_export(Context* ctx,
uint32_t export_index,
- WasmExport* export) {
- if (export->kind == WASM_EXTERNAL_KIND_FUNC) {
+ WabtExport* export) {
+ if (export->kind == WABT_EXTERNAL_KIND_FUNC) {
use_name_for_func_var(ctx->allocator, ctx->module, &export->var);
}
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult visit_elem_segment(Context* ctx,
+static WabtResult visit_elem_segment(Context* ctx,
uint32_t elem_segment_index,
- WasmElemSegment* segment) {
+ WabtElemSegment* segment) {
size_t i;
CHECK_RESULT(
use_name_for_table_var(ctx->allocator, ctx->module, &segment->table_var));
@@ -319,18 +319,18 @@ static WasmResult visit_elem_segment(Context* ctx,
CHECK_RESULT(use_name_for_func_var(ctx->allocator, ctx->module,
&segment->vars.data[i]));
}
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult visit_data_segment(Context* ctx,
+static WabtResult visit_data_segment(Context* ctx,
uint32_t data_segment_index,
- WasmDataSegment* segment) {
+ WabtDataSegment* segment) {
CHECK_RESULT(use_name_for_memory_var(ctx->allocator, ctx->module,
&segment->memory_var));
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult visit_module(Context* ctx, WasmModule* module) {
+static WabtResult visit_module(Context* ctx, WabtModule* module) {
size_t i;
for (i = 0; i < module->funcs.size; ++i)
CHECK_RESULT(visit_func(ctx, i, module->funcs.data[i]));
@@ -340,12 +340,12 @@ static WasmResult visit_module(Context* ctx, WasmModule* module) {
CHECK_RESULT(visit_elem_segment(ctx, i, module->elem_segments.data[i]));
for (i = 0; i < module->data_segments.size; ++i)
CHECK_RESULT(visit_data_segment(ctx, i, module->data_segments.data[i]));
- return WASM_OK;
+ return WABT_OK;
}
-WasmResult wasm_apply_names(WasmAllocator* allocator, WasmModule* module) {
+WabtResult wabt_apply_names(WabtAllocator* allocator, WabtModule* module) {
Context ctx;
- WASM_ZERO_MEMORY(ctx);
+ WABT_ZERO_MEMORY(ctx);
ctx.allocator = allocator;
ctx.module = module;
ctx.visitor.user_data = &ctx;
@@ -365,9 +365,9 @@ WasmResult wasm_apply_names(WasmAllocator* allocator, WasmModule* module) {
ctx.visitor.on_set_global_expr = on_set_global_expr;
ctx.visitor.on_set_local_expr = on_set_local_expr;
ctx.visitor.on_tee_local_expr = on_tee_local_expr;
- WasmResult result = visit_module(&ctx, module);
- wasm_destroy_string_slice_vector(allocator, &ctx.param_index_to_name);
- wasm_destroy_string_slice_vector(allocator, &ctx.local_index_to_name);
- wasm_destroy_label_ptr_vector(allocator, &ctx.labels);
+ WabtResult result = visit_module(&ctx, module);
+ wabt_destroy_string_slice_vector(allocator, &ctx.param_index_to_name);
+ wabt_destroy_string_slice_vector(allocator, &ctx.local_index_to_name);
+ wabt_destroy_label_ptr_vector(allocator, &ctx.labels);
return result;
}
diff --git a/src/apply-names.h b/src/apply-names.h
index b7499271..ec055153 100644
--- a/src/apply-names.h
+++ b/src/apply-names.h
@@ -14,15 +14,15 @@
* limitations under the License.
*/
-#ifndef WASM_APPLY_NAMES_H_
-#define WASM_APPLY_NAMES_H_
+#ifndef WABT_APPLY_NAMES_H_
+#define WABT_APPLY_NAMES_H_
#include "common.h"
-struct WasmAllocator;
-struct WasmModule;
+struct WabtAllocator;
+struct WabtModule;
-/* Use function, import, function type, parameter and local names in WasmVars
+/* Use function, import, function type, parameter and local names in WabtVars
* that reference them.
*
* e.g. transform this:
@@ -37,8 +37,8 @@ struct WasmModule;
* ...
* (call $foo ...)
*/
-WASM_EXTERN_C_BEGIN
-WasmResult wasm_apply_names(struct WasmAllocator*, struct WasmModule*);
-WASM_EXTERN_C_END
+WABT_EXTERN_C_BEGIN
+WabtResult wabt_apply_names(struct WabtAllocator*, struct WabtModule*);
+WABT_EXTERN_C_END
-#endif /* WASM_APPLY_NAMES_H_ */
+#endif /* WABT_APPLY_NAMES_H_ */
diff --git a/src/array.h b/src/array.h
index 84a728cb..0182d772 100644
--- a/src/array.h
+++ b/src/array.h
@@ -14,45 +14,45 @@
* limitations under the License.
*/
-#ifndef WASM_ARRAY_H_
-#define WASM_ARRAY_H_
+#ifndef WABT_ARRAY_H_
+#define WABT_ARRAY_H_
#include <stddef.h>
#include "allocator.h"
#include "common.h"
-#define WASM_DEFINE_ARRAY(name, type) \
+#define WABT_DEFINE_ARRAY(name, type) \
typedef struct type##Array { \
type* data; \
size_t size; \
} type##Array; \
\
- WASM_EXTERN_C_BEGIN \
- static WASM_INLINE void wasm_destroy_##name##_array( \
- struct WasmAllocator* allocator, type##Array* array) WASM_UNUSED; \
- static WASM_INLINE void wasm_new_##name##_array( \
- struct WasmAllocator* allocator, type##Array* array, size_t size) \
- WASM_UNUSED; \
- WASM_EXTERN_C_END \
+ WABT_EXTERN_C_BEGIN \
+ static WABT_INLINE void wabt_destroy_##name##_array( \
+ struct WabtAllocator* allocator, type##Array* array) WABT_UNUSED; \
+ static WABT_INLINE void wabt_new_##name##_array( \
+ struct WabtAllocator* allocator, type##Array* array, size_t size) \
+ WABT_UNUSED; \
+ WABT_EXTERN_C_END \
\
- void wasm_destroy_##name##_array(struct WasmAllocator* allocator, \
+ void wabt_destroy_##name##_array(struct WabtAllocator* allocator, \
type##Array* array) { \
- wasm_free(allocator, array->data); \
+ wabt_free(allocator, array->data); \
} \
- void wasm_new_##name##_array(struct WasmAllocator* allocator, \
+ void wabt_new_##name##_array(struct WabtAllocator* allocator, \
type##Array* array, size_t size) { \
array->size = size; \
array->data = \
- wasm_alloc_zero(allocator, size * sizeof(type), WASM_DEFAULT_ALIGN); \
+ wabt_alloc_zero(allocator, size * sizeof(type), WABT_DEFAULT_ALIGN); \
}
-#define WASM_DESTROY_ARRAY_AND_ELEMENTS(allocator, v, name) \
+#define WABT_DESTROY_ARRAY_AND_ELEMENTS(allocator, v, name) \
{ \
size_t i; \
for (i = 0; i < (v).size; ++i) \
- wasm_destroy_##name(allocator, &((v).data[i])); \
- wasm_destroy_##name##_array(allocator, &(v)); \
+ wabt_destroy_##name(allocator, &((v).data[i])); \
+ wabt_destroy_##name##_array(allocator, &(v)); \
}
-#endif /* WASM_ARRAY_H_ */
+#endif /* WABT_ARRAY_H_ */
diff --git a/src/ast-lexer.c b/src/ast-lexer.c
index ae4f5f38..c7cf645b 100644
--- a/src/ast-lexer.c
+++ b/src/ast-lexer.c
@@ -43,11 +43,11 @@
#define RETURN(name) \
YY_USER_ACTION; \
- return WASM_TOKEN_TYPE_##name
+ return WABT_TOKEN_TYPE_##name
#define ERROR(...) \
YY_USER_ACTION; \
- wasm_ast_parser_error(loc, lexer, parser, __VA_ARGS__)
+ wabt_ast_parser_error(loc, lexer, parser, __VA_ARGS__)
#define BEGIN(c) \
do { \
@@ -55,7 +55,7 @@
} while (0)
#define FILL(n) \
do { \
- if (WASM_FAILED(fill(loc, lexer, parser, n))) { \
+ if (WABT_FAILED(fill(loc, lexer, parser, n))) { \
RETURN(EOF); \
continue; \
} \
@@ -83,21 +83,21 @@
lval->text.start = yytext + offset; \
lval->text.length = yyleng - offset
-#define TYPE(type_) lval->type = WASM_TYPE_##type_
+#define TYPE(type_) lval->type = WABT_TYPE_##type_
-#define OPCODE(name) lval->opcode = WASM_OPCODE_##name
+#define OPCODE(name) lval->opcode = WABT_OPCODE_##name
#define LITERAL(type_) \
- lval->literal.type = WASM_LITERAL_TYPE_##type_; \
+ lval->literal.type = WABT_LITERAL_TYPE_##type_; \
lval->literal.text.start = yytext; \
lval->literal.text.length = yyleng
-static WasmResult fill(WasmLocation* loc,
- WasmAstLexer* lexer,
- WasmAstParser* parser,
+static WabtResult fill(WabtLocation* loc,
+ WabtAstLexer* lexer,
+ WabtAstParser* parser,
size_t need) {
if (lexer->eof)
- return WASM_ERROR;
+ return WABT_ERROR;
size_t free = lexer->token - lexer->buffer;
assert((size_t)(lexer->cursor - lexer->buffer) >= free);
/* our buffer is too small, need to realloc */
@@ -114,12 +114,12 @@ static WasmResult fill(WasmLocation* loc,
/* TODO(binji): could just alloc instead, because we know we'll need to
* memmove below */
- char* new_buffer = wasm_realloc(lexer->allocator, lexer->buffer,
- new_buffer_size, WASM_DEFAULT_ALIGN);
+ char* new_buffer = wabt_realloc(lexer->allocator, lexer->buffer,
+ new_buffer_size, WABT_DEFAULT_ALIGN);
if (new_buffer == NULL) {
- wasm_ast_parser_error(loc, lexer, parser,
+ wabt_ast_parser_error(loc, lexer, parser,
"unable to reallocate lexer buffer.");
- return WASM_ERROR;
+ return WABT_ERROR;
}
memmove(new_buffer, lexer->token, lexer->limit - lexer->token);
lexer->buffer = new_buffer;
@@ -140,11 +140,11 @@ static WasmResult fill(WasmLocation* loc,
lexer->buffer_file_offset += free;
}
/* read the new data into the buffer */
- if (lexer->source.type == WASM_LEXER_SOURCE_TYPE_FILE) {
+ if (lexer->source.type == WABT_LEXER_SOURCE_TYPE_FILE) {
lexer->limit += fread(lexer->limit, 1, free, lexer->source.file);
} else {
/* TODO(binji): could lex directly from buffer */
- assert(lexer->source.type == WASM_LEXER_SOURCE_TYPE_BUFFER);
+ assert(lexer->source.type == WABT_LEXER_SOURCE_TYPE_BUFFER);
size_t read_size = free;
size_t offset = lexer->source.buffer.read_offset;
size_t bytes_left = lexer->source.buffer.size - offset;
@@ -159,17 +159,17 @@ static WasmResult fill(WasmLocation* loc,
* characters", that are not a lexeme nor a lexeme suffix. see
* http://re2c.org/examples/example_03.html */
if (lexer->limit < lexer->buffer + lexer->buffer_size - YYMAXFILL) {
- lexer->eof = WASM_TRUE;
+ lexer->eof = WABT_TRUE;
memset(lexer->limit, 0, YYMAXFILL);
lexer->limit += YYMAXFILL;
}
- return WASM_OK;
+ return WABT_OK;
}
-int wasm_ast_lexer_lex(WASM_AST_PARSER_STYPE* lval,
- WASM_AST_PARSER_LTYPE* loc,
- WasmAstLexer* lexer,
- WasmAstParser* parser) {
+int wabt_ast_lexer_lex(WABT_AST_PARSER_STYPE* lval,
+ WABT_AST_PARSER_LTYPE* loc,
+ WabtAstLexer* lexer,
+ WabtAstParser* parser) {
enum {
YYCOND_INIT,
YYCOND_BAD_TEXT,
@@ -468,11 +468,11 @@ int wasm_ast_lexer_lex(WASM_AST_PARSER_STYPE* lval,
}
}
-static WasmAstLexer* wasm_new_lexer(WasmAllocator* allocator,
- WasmAstLexerSourceType type,
+static WabtAstLexer* wabt_new_lexer(WabtAllocator* allocator,
+ WabtAstLexerSourceType type,
const char* filename) {
- WasmAstLexer* lexer =
- wasm_alloc_zero(allocator, sizeof(WasmAstLexer), WASM_DEFAULT_ALIGN);
+ WabtAstLexer* lexer =
+ wabt_alloc_zero(allocator, sizeof(WabtAstLexer), WABT_DEFAULT_ALIGN);
lexer->allocator = allocator;
lexer->line = 1;
lexer->filename = filename;
@@ -480,62 +480,62 @@ static WasmAstLexer* wasm_new_lexer(WasmAllocator* allocator,
return lexer;
}
-WasmAstLexer* wasm_new_ast_file_lexer(WasmAllocator* allocator,
+WabtAstLexer* wabt_new_ast_file_lexer(WabtAllocator* allocator,
const char* filename) {
- WasmAstLexer* lexer =
- wasm_new_lexer(allocator, WASM_LEXER_SOURCE_TYPE_FILE, filename);
+ WabtAstLexer* lexer =
+ wabt_new_lexer(allocator, WABT_LEXER_SOURCE_TYPE_FILE, filename);
lexer->source.file = fopen(filename, "rb");
if (!lexer->source.file) {
- wasm_destroy_ast_lexer(lexer);
+ wabt_destroy_ast_lexer(lexer);
return NULL;
}
return lexer;
}
-WasmAstLexer* wasm_new_ast_buffer_lexer(WasmAllocator* allocator,
+WabtAstLexer* wabt_new_ast_buffer_lexer(WabtAllocator* allocator,
const char* filename,
const void* data,
size_t size) {
- WasmAstLexer* lexer =
- wasm_new_lexer(allocator, WASM_LEXER_SOURCE_TYPE_BUFFER, filename);
+ WabtAstLexer* lexer =
+ wabt_new_lexer(allocator, WABT_LEXER_SOURCE_TYPE_BUFFER, filename);
lexer->source.buffer.data = data;
lexer->source.buffer.size = size;
lexer->source.buffer.read_offset = 0;
return lexer;
}
-void wasm_destroy_ast_lexer(WasmAstLexer* lexer) {
- if (lexer->source.type == WASM_LEXER_SOURCE_TYPE_FILE && lexer->source.file)
+void wabt_destroy_ast_lexer(WabtAstLexer* lexer) {
+ if (lexer->source.type == WABT_LEXER_SOURCE_TYPE_FILE && lexer->source.file)
fclose(lexer->source.file);
- wasm_free(lexer->allocator, lexer->buffer);
- wasm_free(lexer->allocator, lexer);
+ wabt_free(lexer->allocator, lexer->buffer);
+ wabt_free(lexer->allocator, lexer);
}
-WasmAllocator* wasm_ast_lexer_get_allocator(WasmAstLexer* lexer) {
+WabtAllocator* wabt_ast_lexer_get_allocator(WabtAstLexer* lexer) {
return lexer->allocator;
}
-typedef enum WasmLineOffsetPosition {
- WASM_LINE_OFFSET_POSITION_START,
- WASM_LINE_OFFSET_POSITION_END,
-} WasmLineOffsetPosition;
+typedef enum WabtLineOffsetPosition {
+ WABT_LINE_OFFSET_POSITION_START,
+ WABT_LINE_OFFSET_POSITION_END,
+} WabtLineOffsetPosition;
-static WasmResult scan_forward_for_line_offset_in_buffer(
+static WabtResult scan_forward_for_line_offset_in_buffer(
const char* buffer_start,
const char* buffer_end,
int buffer_line,
size_t buffer_file_offset,
- WasmLineOffsetPosition find_position,
+ WabtLineOffsetPosition find_position,
int find_line,
int* out_line,
size_t* out_line_offset) {
int line = buffer_line;
int line_offset = 0;
const char* p;
- WasmBool is_previous_carriage = 0;
+ WabtBool is_previous_carriage = 0;
for (p = buffer_start; p < buffer_end; ++p) {
if (*p == '\n') {
- if (find_position == WASM_LINE_OFFSET_POSITION_START) {
+ if (find_position == WABT_LINE_OFFSET_POSITION_START) {
if (++line == find_line) {
line_offset = buffer_file_offset + (p - buffer_start) + 1;
break;
@@ -550,11 +550,11 @@ static WasmResult scan_forward_for_line_offset_in_buffer(
is_previous_carriage = *p == '\r';
}
- WasmResult result = WASM_OK;
+ WabtResult result = WABT_OK;
if (p == buffer_end) {
/* end of buffer */
- if (find_position == WASM_LINE_OFFSET_POSITION_START) {
- result = WASM_ERROR;
+ if (find_position == WABT_LINE_OFFSET_POSITION_START) {
+ result = WABT_ERROR;
} else {
line_offset = buffer_file_offset + (buffer_end - buffer_start);
}
@@ -565,33 +565,33 @@ static WasmResult scan_forward_for_line_offset_in_buffer(
return result;
}
-static WasmResult scan_forward_for_line_offset_in_file(
- WasmAstLexer* lexer,
+static WabtResult scan_forward_for_line_offset_in_file(
+ WabtAstLexer* lexer,
int line,
size_t line_start_offset,
- WasmLineOffsetPosition find_position,
+ WabtLineOffsetPosition find_position,
int find_line,
size_t* out_line_offset) {
FILE* lexer_file = lexer->source.file;
- WasmResult result = WASM_ERROR;
+ WabtResult result = WABT_ERROR;
long old_offset = ftell(lexer_file);
if (old_offset == -1)
- return WASM_ERROR;
+ return WABT_ERROR;
size_t buffer_file_offset = line_start_offset;
if (fseek(lexer_file, buffer_file_offset, SEEK_SET) == -1)
goto cleanup;
while (1) {
char buffer[8 * 1024];
- const size_t buffer_size = WASM_ARRAY_SIZE(buffer);
+ const size_t buffer_size = WABT_ARRAY_SIZE(buffer);
size_t read_bytes = fread(buffer, 1, buffer_size, lexer_file);
if (read_bytes == 0) {
/* end of buffer */
- if (find_position == WASM_LINE_OFFSET_POSITION_START) {
- result = WASM_ERROR;
+ if (find_position == WABT_LINE_OFFSET_POSITION_START) {
+ result = WABT_ERROR;
} else {
*out_line_offset = buffer_file_offset + read_bytes;
- result = WASM_OK;
+ result = WABT_OK;
}
goto cleanup;
}
@@ -600,7 +600,7 @@ static WasmResult scan_forward_for_line_offset_in_file(
result = scan_forward_for_line_offset_in_buffer(
buffer, buffer_end, line, buffer_file_offset, find_position, find_line,
&line, out_line_offset);
- if (result == WASM_OK)
+ if (result == WABT_OK)
goto cleanup;
buffer_file_offset += read_bytes;
@@ -609,19 +609,19 @@ static WasmResult scan_forward_for_line_offset_in_file(
cleanup:
/* if this fails, we're screwed */
if (fseek(lexer_file, old_offset, SEEK_SET) == -1)
- return WASM_ERROR;
+ return WABT_ERROR;
return result;
}
-static WasmResult scan_forward_for_line_offset(
- WasmAstLexer* lexer,
+static WabtResult scan_forward_for_line_offset(
+ WabtAstLexer* lexer,
int line,
size_t line_start_offset,
- WasmLineOffsetPosition find_position,
+ WabtLineOffsetPosition find_position,
int find_line,
size_t* out_line_offset) {
assert(line <= find_line);
- if (lexer->source.type == WASM_LEXER_SOURCE_TYPE_BUFFER) {
+ if (lexer->source.type == WABT_LEXER_SOURCE_TYPE_BUFFER) {
const char* source_buffer = lexer->source.buffer.data;
const char* buffer_start = source_buffer + line_start_offset;
const char* buffer_end = source_buffer + lexer->source.buffer.size;
@@ -629,14 +629,14 @@ static WasmResult scan_forward_for_line_offset(
buffer_start, buffer_end, line, line_start_offset, find_position,
find_line, &line, out_line_offset);
} else {
- assert(lexer->source.type == WASM_LEXER_SOURCE_TYPE_FILE);
+ assert(lexer->source.type == WABT_LEXER_SOURCE_TYPE_FILE);
return scan_forward_for_line_offset_in_file(lexer, line, line_start_offset,
find_position, find_line,
out_line_offset);
}
}
-static WasmResult get_line_start_offset(WasmAstLexer* lexer,
+static WabtResult get_line_start_offset(WabtAstLexer* lexer,
int line,
size_t* out_offset) {
int first_line = 1;
@@ -646,38 +646,38 @@ static WasmResult get_line_start_offset(WasmAstLexer* lexer,
if (line == current_line) {
*out_offset = current_offset;
- return WASM_OK;
+ return WABT_OK;
} else if (line == first_line) {
*out_offset = first_offset;
- return WASM_OK;
+ return WABT_OK;
} else if (line > current_line) {
return scan_forward_for_line_offset(lexer, current_line, current_offset,
- WASM_LINE_OFFSET_POSITION_START, line,
+ WABT_LINE_OFFSET_POSITION_START, line,
out_offset);
} else {
/* TODO(binji): optimize by storing more known line/offset pairs */
return scan_forward_for_line_offset(lexer, first_line, first_offset,
- WASM_LINE_OFFSET_POSITION_START, line,
+ WABT_LINE_OFFSET_POSITION_START, line,
out_offset);
}
}
-static WasmResult get_offsets_from_line(WasmAstLexer* lexer,
+static WabtResult get_offsets_from_line(WabtAstLexer* lexer,
int line,
size_t* out_line_start,
size_t* out_line_end) {
size_t line_start;
- if (WASM_FAILED(get_line_start_offset(lexer, line, &line_start)))
- return WASM_ERROR;
+ if (WABT_FAILED(get_line_start_offset(lexer, line, &line_start)))
+ return WABT_ERROR;
size_t line_end;
- if (WASM_FAILED(scan_forward_for_line_offset(lexer, line, line_start,
- WASM_LINE_OFFSET_POSITION_END,
+ if (WABT_FAILED(scan_forward_for_line_offset(lexer, line, line_start,
+ WABT_LINE_OFFSET_POSITION_END,
line, &line_end)))
- return WASM_ERROR;
+ return WABT_ERROR;
*out_line_start = line_start;
*out_line_end = line_end;
- return WASM_OK;
+ return WABT_OK;
}
static void clamp_source_line_offsets_to_location(size_t line_start,
@@ -709,17 +709,17 @@ static void clamp_source_line_offsets_to_location(size_t line_start,
*out_new_line_end = line_end;
}
-WasmResult wasm_ast_lexer_get_source_line(WasmAstLexer* lexer,
- const WasmLocation* loc,
+WabtResult wabt_ast_lexer_get_source_line(WabtAstLexer* lexer,
+ const WabtLocation* loc,
size_t line_max_length,
char* line,
size_t* out_line_length,
int* out_column_offset) {
- WasmResult result;
+ WabtResult result;
size_t line_start; /* inclusive */
size_t line_end; /* exclusive */
result = get_offsets_from_line(lexer, loc->line, &line_start, &line_end);
- if (WASM_FAILED(result))
+ if (WABT_FAILED(result))
return result;
size_t new_line_start;
@@ -727,8 +727,8 @@ WasmResult wasm_ast_lexer_get_source_line(WasmAstLexer* lexer,
clamp_source_line_offsets_to_location(line_start, line_end, loc->first_column,
loc->last_column, line_max_length,
&new_line_start, &new_line_end);
- WasmBool has_start_ellipsis = line_start != new_line_start;
- WasmBool has_end_ellipsis = line_end != new_line_end;
+ WabtBool has_start_ellipsis = line_start != new_line_start;
+ WabtBool has_end_ellipsis = line_end != new_line_end;
char* write_start = line;
size_t line_length = new_line_end - new_line_start;
@@ -745,26 +745,26 @@ WasmResult wasm_ast_lexer_get_source_line(WasmAstLexer* lexer,
read_length -= 3;
}
- if (lexer->source.type == WASM_LEXER_SOURCE_TYPE_BUFFER) {
+ if (lexer->source.type == WABT_LEXER_SOURCE_TYPE_BUFFER) {
char* buffer_read_start = (char*)lexer->source.buffer.data + read_start;
memcpy(write_start, buffer_read_start, read_length);
} else {
- assert(lexer->source.type == WASM_LEXER_SOURCE_TYPE_FILE);
+ assert(lexer->source.type == WABT_LEXER_SOURCE_TYPE_FILE);
FILE* lexer_file = lexer->source.file;
long old_offset = ftell(lexer_file);
if (old_offset == -1)
- return WASM_ERROR;
+ return WABT_ERROR;
if (fseek(lexer_file, read_start, SEEK_SET) == -1)
- return WASM_ERROR;
+ return WABT_ERROR;
if (fread(write_start, 1, read_length, lexer_file) < read_length)
- return WASM_ERROR;
+ return WABT_ERROR;
if (fseek(lexer_file, old_offset, SEEK_SET) == -1)
- return WASM_ERROR;
+ return WABT_ERROR;
}
line[line_length] = '\0';
*out_line_length = line_length;
*out_column_offset = new_line_start - line_start;
- return WASM_OK;
+ return WABT_OK;
}
diff --git a/src/ast-lexer.h b/src/ast-lexer.h
index d69f73fb..e06672f5 100644
--- a/src/ast-lexer.h
+++ b/src/ast-lexer.h
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#ifndef WASM_AST_LEXER_H_
-#define WASM_AST_LEXER_H_
+#ifndef WABT_AST_LEXER_H_
+#define WABT_AST_LEXER_H_
#include <stddef.h>
#include <stdio.h>
@@ -23,15 +23,15 @@
#include "common.h"
#include "vector.h"
-struct WasmAllocator;
+struct WabtAllocator;
-typedef enum WasmAstLexerSourceType {
- WASM_LEXER_SOURCE_TYPE_FILE,
- WASM_LEXER_SOURCE_TYPE_BUFFER,
-} WasmAstLexerSourceType;
+typedef enum WabtAstLexerSourceType {
+ WABT_LEXER_SOURCE_TYPE_FILE,
+ WABT_LEXER_SOURCE_TYPE_BUFFER,
+} WabtAstLexerSourceType;
-typedef struct WasmAstLexerSource {
- WasmAstLexerSourceType type;
+typedef struct WabtAstLexerSource {
+ WabtAstLexerSourceType type;
union {
FILE* file;
struct {
@@ -40,11 +40,11 @@ typedef struct WasmAstLexerSource {
size_t read_offset;
} buffer;
};
-} WasmAstLexerSource;
+} WabtAstLexerSource;
-typedef struct WasmAstLexer {
- struct WasmAllocator* allocator;
- WasmAstLexerSource source;
+typedef struct WabtAstLexer {
+ struct WabtAllocator* allocator;
+ WabtAstLexerSource source;
const char* filename;
int line;
int comment_nesting;
@@ -52,24 +52,24 @@ typedef struct WasmAstLexer {
size_t line_file_offset; /* file offset of the start of the current line */
/* lexing data needed by re2c */
- WasmBool eof;
+ WabtBool eof;
char* buffer;
size_t buffer_size;
char* marker;
char* token;
char* cursor;
char* limit;
-} WasmAstLexer;
+} WabtAstLexer;
-WASM_EXTERN_C_BEGIN
+WABT_EXTERN_C_BEGIN
-WasmAstLexer* wasm_new_ast_file_lexer(struct WasmAllocator*,
+WabtAstLexer* wabt_new_ast_file_lexer(struct WabtAllocator*,
const char* filename);
-WasmAstLexer* wasm_new_ast_buffer_lexer(struct WasmAllocator*,
+WabtAstLexer* wabt_new_ast_buffer_lexer(struct WabtAllocator*,
const char* filename,
const void* data,
size_t size);
-void wasm_destroy_ast_lexer(WasmAstLexer*);
-WASM_EXTERN_C_END
+void wabt_destroy_ast_lexer(WabtAstLexer*);
+WABT_EXTERN_C_END
-#endif /* WASM_AST_LEXER_H_ */
+#endif /* WABT_AST_LEXER_H_ */
diff --git a/src/ast-parser-lexer-shared.c b/src/ast-parser-lexer-shared.c
index cb15770b..327ec69f 100644
--- a/src/ast-parser-lexer-shared.c
+++ b/src/ast-parser-lexer-shared.c
@@ -20,31 +20,31 @@
#include <stdio.h>
#include <string.h>
-void wasm_ast_parser_error(WasmLocation* loc,
- WasmAstLexer* lexer,
- WasmAstParser* parser,
+void wabt_ast_parser_error(WabtLocation* loc,
+ WabtAstLexer* lexer,
+ WabtAstParser* parser,
const char* format,
...) {
parser->errors++;
va_list args;
va_start(args, format);
- wasm_ast_format_error(parser->error_handler, loc, lexer, format, args);
+ wabt_ast_format_error(parser->error_handler, loc, lexer, format, args);
va_end(args);
}
-void wasm_ast_format_error(WasmSourceErrorHandler* error_handler,
- const struct WasmLocation* loc,
- WasmAstLexer* lexer,
+void wabt_ast_format_error(WabtSourceErrorHandler* error_handler,
+ const struct WabtLocation* loc,
+ WabtAstLexer* lexer,
const char* format,
va_list args) {
va_list args_copy;
va_copy(args_copy, args);
- char fixed_buf[WASM_DEFAULT_SNPRINTF_ALLOCA_BUFSIZE];
+ char fixed_buf[WABT_DEFAULT_SNPRINTF_ALLOCA_BUFSIZE];
char* buffer = fixed_buf;
- size_t len = wasm_vsnprintf(fixed_buf, sizeof(fixed_buf), format, args);
+ size_t len = wabt_vsnprintf(fixed_buf, sizeof(fixed_buf), format, args);
if (len + 1 > sizeof(fixed_buf)) {
buffer = alloca(len + 1);
- len = wasm_vsnprintf(buffer, len + 1, format, args_copy);
+ len = wabt_vsnprintf(buffer, len + 1, format, args_copy);
}
char* source_line = NULL;
@@ -53,13 +53,13 @@ void wasm_ast_format_error(WasmSourceErrorHandler* error_handler,
size_t source_line_max_length = error_handler->source_line_max_length;
if (loc && lexer) {
source_line = alloca(source_line_max_length + 1);
- WasmResult result = wasm_ast_lexer_get_source_line(
+ WabtResult result = wabt_ast_lexer_get_source_line(
lexer, loc, source_line_max_length, source_line, &source_line_length,
&source_line_column_offset);
- if (WASM_FAILED(result)) {
+ if (WABT_FAILED(result)) {
/* if this fails, it means that we've probably screwed up the lexer. blow
* up. */
- WASM_FATAL("error getting the source line.\n");
+ WABT_FATAL("error getting the source line.\n");
}
}
@@ -71,69 +71,69 @@ void wasm_ast_format_error(WasmSourceErrorHandler* error_handler,
va_end(args_copy);
}
-void wasm_destroy_optional_export(WasmAllocator* allocator,
- WasmOptionalExport* export_) {
+void wabt_destroy_optional_export(WabtAllocator* allocator,
+ WabtOptionalExport* export_) {
if (export_->has_export)
- wasm_destroy_export(allocator, &export_->export_);
+ wabt_destroy_export(allocator, &export_->export_);
}
-void wasm_destroy_exported_func(WasmAllocator* allocator,
- WasmExportedFunc* exported_func) {
- wasm_destroy_optional_export(allocator, &exported_func->export_);
- wasm_destroy_func(allocator, exported_func->func);
- wasm_free(allocator, exported_func->func);
+void wabt_destroy_exported_func(WabtAllocator* allocator,
+ WabtExportedFunc* exported_func) {
+ wabt_destroy_optional_export(allocator, &exported_func->export_);
+ wabt_destroy_func(allocator, exported_func->func);
+ wabt_free(allocator, exported_func->func);
}
-void wasm_destroy_text_list(WasmAllocator* allocator, WasmTextList* text_list) {
- WasmTextListNode* node = text_list->first;
+void wabt_destroy_text_list(WabtAllocator* allocator, WabtTextList* text_list) {
+ WabtTextListNode* node = text_list->first;
while (node) {
- WasmTextListNode* next = node->next;
- wasm_destroy_string_slice(allocator, &node->text);
- wasm_free(allocator, node);
+ WabtTextListNode* next = node->next;
+ wabt_destroy_string_slice(allocator, &node->text);
+ wabt_free(allocator, node);
node = next;
}
}
-void wasm_destroy_func_fields(struct WasmAllocator* allocator,
- WasmFuncField* func_field) {
+void wabt_destroy_func_fields(struct WabtAllocator* allocator,
+ WabtFuncField* func_field) {
/* destroy the entire linked-list */
while (func_field) {
- WasmFuncField* next_func_field = func_field->next;
+ WabtFuncField* next_func_field = func_field->next;
switch (func_field->type) {
- case WASM_FUNC_FIELD_TYPE_EXPRS:
- wasm_destroy_expr_list(allocator, func_field->first_expr);
+ case WABT_FUNC_FIELD_TYPE_EXPRS:
+ wabt_destroy_expr_list(allocator, func_field->first_expr);
break;
- case WASM_FUNC_FIELD_TYPE_PARAM_TYPES:
- case WASM_FUNC_FIELD_TYPE_LOCAL_TYPES:
- case WASM_FUNC_FIELD_TYPE_RESULT_TYPES:
- wasm_destroy_type_vector(allocator, &func_field->types);
+ case WABT_FUNC_FIELD_TYPE_PARAM_TYPES:
+ case WABT_FUNC_FIELD_TYPE_LOCAL_TYPES:
+ case WABT_FUNC_FIELD_TYPE_RESULT_TYPES:
+ wabt_destroy_type_vector(allocator, &func_field->types);
break;
- case WASM_FUNC_FIELD_TYPE_BOUND_PARAM:
- case WASM_FUNC_FIELD_TYPE_BOUND_LOCAL:
- wasm_destroy_string_slice(allocator, &func_field->bound_type.name);
+ case WABT_FUNC_FIELD_TYPE_BOUND_PARAM:
+ case WABT_FUNC_FIELD_TYPE_BOUND_LOCAL:
+ wabt_destroy_string_slice(allocator, &func_field->bound_type.name);
break;
}
- wasm_free(allocator, func_field);
+ wabt_free(allocator, func_field);
func_field = next_func_field;
}
}
-void wasm_destroy_exported_memory(WasmAllocator* allocator,
- WasmExportedMemory* memory) {
- wasm_destroy_memory(allocator, &memory->memory);
- wasm_destroy_optional_export(allocator, &memory->export_);
+void wabt_destroy_exported_memory(WabtAllocator* allocator,
+ WabtExportedMemory* memory) {
+ wabt_destroy_memory(allocator, &memory->memory);
+ wabt_destroy_optional_export(allocator, &memory->export_);
if (memory->has_data_segment)
- wasm_destroy_data_segment(allocator, &memory->data_segment);
+ wabt_destroy_data_segment(allocator, &memory->data_segment);
}
-void wasm_destroy_exported_table(WasmAllocator* allocator,
- WasmExportedTable* table) {
- wasm_destroy_table(allocator, &table->table);
- wasm_destroy_optional_export(allocator, &table->export_);
+void wabt_destroy_exported_table(WabtAllocator* allocator,
+ WabtExportedTable* table) {
+ wabt_destroy_table(allocator, &table->table);
+ wabt_destroy_optional_export(allocator, &table->export_);
if (table->has_elem_segment)
- wasm_destroy_elem_segment(allocator, &table->elem_segment);
+ wabt_destroy_elem_segment(allocator, &table->elem_segment);
}
diff --git a/src/ast-parser-lexer-shared.h b/src/ast-parser-lexer-shared.h
index 2a164acd..e8982636 100644
--- a/src/ast-parser-lexer-shared.h
+++ b/src/ast-parser-lexer-shared.h
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#ifndef WASM_AST_PARSER_LEXER_SHARED_H_
-#define WASM_AST_PARSER_LEXER_SHARED_H_
+#ifndef WABT_AST_PARSER_LEXER_SHARED_H_
+#define WABT_AST_PARSER_LEXER_SHARED_H_
#include <stdarg.h>
@@ -23,167 +23,167 @@
#include "ast-lexer.h"
#include "common.h"
-#define WASM_AST_PARSER_STYPE WasmToken
-#define WASM_AST_PARSER_LTYPE WasmLocation
-#define YYSTYPE WASM_AST_PARSER_STYPE
-#define YYLTYPE WASM_AST_PARSER_LTYPE
+#define WABT_AST_PARSER_STYPE WabtToken
+#define WABT_AST_PARSER_LTYPE WabtLocation
+#define YYSTYPE WABT_AST_PARSER_STYPE
+#define YYLTYPE WABT_AST_PARSER_LTYPE
-#define WASM_INVALID_LINE_OFFSET ((size_t)~0)
+#define WABT_INVALID_LINE_OFFSET ((size_t)~0)
-struct WasmAllocator;
+struct WabtAllocator;
-typedef struct WasmExprList {
- WasmExpr* first;
- WasmExpr* last;
+typedef struct WabtExprList {
+ WabtExpr* first;
+ WabtExpr* last;
size_t size;
-} WasmExprList;
-
-typedef struct WasmTextListNode {
- WasmStringSlice text;
- struct WasmTextListNode* next;
-} WasmTextListNode;
-
-typedef struct WasmTextList {
- WasmTextListNode* first;
- WasmTextListNode* last;
-} WasmTextList;
-
-typedef struct WasmOptionalExport {
- WasmExport export_;
- WasmBool has_export;
-} WasmOptionalExport;
-
-typedef struct WasmExportedFunc {
- WasmFunc* func;
- WasmOptionalExport export_;
-} WasmExportedFunc;
-
-typedef struct WasmExportedGlobal {
- WasmGlobal global;
- WasmOptionalExport export_;
-} WasmExportedGlobal;
-
-typedef struct WasmExportedTable {
- WasmTable table;
- WasmElemSegment elem_segment;
- WasmOptionalExport export_;
- WasmBool has_elem_segment;
-} WasmExportedTable;
-
-typedef struct WasmExportedMemory {
- WasmMemory memory;
- WasmDataSegment data_segment;
- WasmOptionalExport export_;
- WasmBool has_data_segment;
-} WasmExportedMemory;
-
-typedef enum WasmFuncFieldType {
- WASM_FUNC_FIELD_TYPE_EXPRS,
- WASM_FUNC_FIELD_TYPE_PARAM_TYPES,
- WASM_FUNC_FIELD_TYPE_BOUND_PARAM,
- WASM_FUNC_FIELD_TYPE_RESULT_TYPES,
- WASM_FUNC_FIELD_TYPE_LOCAL_TYPES,
- WASM_FUNC_FIELD_TYPE_BOUND_LOCAL,
-} WasmFuncFieldType;
-
-typedef struct WasmBoundType {
- WasmLocation loc;
- WasmStringSlice name;
- WasmType type;
-} WasmBoundType;
-
-typedef struct WasmFuncField {
- WasmFuncFieldType type;
+} WabtExprList;
+
+typedef struct WabtTextListNode {
+ WabtStringSlice text;
+ struct WabtTextListNode* next;
+} WabtTextListNode;
+
+typedef struct WabtTextList {
+ WabtTextListNode* first;
+ WabtTextListNode* last;
+} WabtTextList;
+
+typedef struct WabtOptionalExport {
+ WabtExport export_;
+ WabtBool has_export;
+} WabtOptionalExport;
+
+typedef struct WabtExportedFunc {
+ WabtFunc* func;
+ WabtOptionalExport export_;
+} WabtExportedFunc;
+
+typedef struct WabtExportedGlobal {
+ WabtGlobal global;
+ WabtOptionalExport export_;
+} WabtExportedGlobal;
+
+typedef struct WabtExportedTable {
+ WabtTable table;
+ WabtElemSegment elem_segment;
+ WabtOptionalExport export_;
+ WabtBool has_elem_segment;
+} WabtExportedTable;
+
+typedef struct WabtExportedMemory {
+ WabtMemory memory;
+ WabtDataSegment data_segment;
+ WabtOptionalExport export_;
+ WabtBool has_data_segment;
+} WabtExportedMemory;
+
+typedef enum WabtFuncFieldType {
+ WABT_FUNC_FIELD_TYPE_EXPRS,
+ WABT_FUNC_FIELD_TYPE_PARAM_TYPES,
+ WABT_FUNC_FIELD_TYPE_BOUND_PARAM,
+ WABT_FUNC_FIELD_TYPE_RESULT_TYPES,
+ WABT_FUNC_FIELD_TYPE_LOCAL_TYPES,
+ WABT_FUNC_FIELD_TYPE_BOUND_LOCAL,
+} WabtFuncFieldType;
+
+typedef struct WabtBoundType {
+ WabtLocation loc;
+ WabtStringSlice name;
+ WabtType type;
+} WabtBoundType;
+
+typedef struct WabtFuncField {
+ WabtFuncFieldType type;
union {
- WasmExpr* first_expr; /* WASM_FUNC_FIELD_TYPE_EXPRS */
- WasmTypeVector types; /* WASM_FUNC_FIELD_TYPE_*_TYPES */
- WasmBoundType bound_type; /* WASM_FUNC_FIELD_TYPE_BOUND_{LOCAL, PARAM} */
+ WabtExpr* first_expr; /* WABT_FUNC_FIELD_TYPE_EXPRS */
+ WabtTypeVector types; /* WABT_FUNC_FIELD_TYPE_*_TYPES */
+ WabtBoundType bound_type; /* WABT_FUNC_FIELD_TYPE_BOUND_{LOCAL, PARAM} */
};
- struct WasmFuncField* next;
-} WasmFuncField;
+ struct WabtFuncField* next;
+} WabtFuncField;
-typedef union WasmToken {
+typedef union WabtToken {
/* terminals */
- WasmStringSlice text;
- WasmType type;
- WasmOpcode opcode;
- WasmLiteral literal;
+ WabtStringSlice text;
+ WabtType type;
+ WabtOpcode opcode;
+ WabtLiteral literal;
/* non-terminals */
- /* some of these use pointers to keep the size of WasmToken down; copying the
+ /* some of these use pointers to keep the size of WabtToken down; copying the
tokens is a hotspot when parsing large files. */
- WasmAction action;
- WasmBlock block;
- WasmCommand* command;
- WasmCommandVector commands;
- WasmConst const_;
- WasmConstVector consts;
- WasmDataSegment data_segment;
- WasmElemSegment elem_segment;
- WasmExport export_;
- WasmExportedFunc exported_func;
- WasmExportedGlobal exported_global;
- WasmExportedMemory exported_memory;
- WasmExportedTable exported_table;
- WasmExpr* expr;
- WasmExprList expr_list;
- WasmFuncField* func_fields;
- WasmFunc* func;
- WasmFuncSignature func_sig;
- WasmFuncType func_type;
- WasmGlobal global;
- WasmImport* import;
- WasmLimits limits;
- WasmOptionalExport optional_export;
- WasmMemory memory;
- WasmModule* module;
- WasmRawModule raw_module;
- WasmScript script;
- WasmTable table;
- WasmTextList text_list;
- WasmTypeVector types;
+ WabtAction action;
+ WabtBlock block;
+ WabtCommand* command;
+ WabtCommandVector commands;
+ WabtConst const_;
+ WabtConstVector consts;
+ WabtDataSegment data_segment;
+ WabtElemSegment elem_segment;
+ WabtExport export_;
+ WabtExportedFunc exported_func;
+ WabtExportedGlobal exported_global;
+ WabtExportedMemory exported_memory;
+ WabtExportedTable exported_table;
+ WabtExpr* expr;
+ WabtExprList expr_list;
+ WabtFuncField* func_fields;
+ WabtFunc* func;
+ WabtFuncSignature func_sig;
+ WabtFuncType func_type;
+ WabtGlobal global;
+ WabtImport* import;
+ WabtLimits limits;
+ WabtOptionalExport optional_export;
+ WabtMemory memory;
+ WabtModule* module;
+ WabtRawModule raw_module;
+ WabtScript script;
+ WabtTable table;
+ WabtTextList text_list;
+ WabtTypeVector types;
uint32_t u32;
uint64_t u64;
- WasmVar var;
- WasmVarVector vars;
-} WasmToken;
-
-typedef struct WasmAstParser {
- struct WasmAllocator* allocator;
- WasmScript script;
- WasmSourceErrorHandler* error_handler;
+ WabtVar var;
+ WabtVarVector vars;
+} WabtToken;
+
+typedef struct WabtAstParser {
+ struct WabtAllocator* allocator;
+ WabtScript script;
+ WabtSourceErrorHandler* error_handler;
int errors;
-} WasmAstParser;
-
-WASM_EXTERN_C_BEGIN
-struct WasmAllocator* wasm_ast_lexer_get_allocator(WasmAstLexer* lexer);
-int wasm_ast_lexer_lex(union WasmToken*,
- struct WasmLocation*,
- WasmAstLexer*,
- struct WasmAstParser*);
-WasmResult wasm_ast_lexer_get_source_line(WasmAstLexer*,
- const struct WasmLocation*,
+} WabtAstParser;
+
+WABT_EXTERN_C_BEGIN
+struct WabtAllocator* wabt_ast_lexer_get_allocator(WabtAstLexer* lexer);
+int wabt_ast_lexer_lex(union WabtToken*,
+ struct WabtLocation*,
+ WabtAstLexer*,
+ struct WabtAstParser*);
+WabtResult wabt_ast_lexer_get_source_line(WabtAstLexer*,
+ const struct WabtLocation*,
size_t line_max_length,
char* line,
size_t* out_line_length,
int* out_column_offset);
-void WASM_PRINTF_FORMAT(4, 5) wasm_ast_parser_error(struct WasmLocation*,
- WasmAstLexer*,
- struct WasmAstParser*,
+void WABT_PRINTF_FORMAT(4, 5) wabt_ast_parser_error(struct WabtLocation*,
+ WabtAstLexer*,
+ struct WabtAstParser*,
const char*,
...);
-void wasm_ast_format_error(WasmSourceErrorHandler*,
- const struct WasmLocation*,
- WasmAstLexer*,
+void wabt_ast_format_error(WabtSourceErrorHandler*,
+ const struct WabtLocation*,
+ WabtAstLexer*,
const char* format,
va_list);
-void wasm_destroy_optional_export(WasmAllocator*, WasmOptionalExport*);
-void wasm_destroy_exported_func(WasmAllocator*, WasmExportedFunc*);
-void wasm_destroy_exported_global(WasmAllocator*, WasmExportedFunc*);
-void wasm_destroy_exported_memory(WasmAllocator*, WasmExportedMemory*);
-void wasm_destroy_exported_table(WasmAllocator*, WasmExportedTable*);
-void wasm_destroy_func_fields(WasmAllocator*, WasmFuncField*);
-void wasm_destroy_text_list(WasmAllocator*, WasmTextList*);
-WASM_EXTERN_C_END
-
-#endif /* WASM_AST_PARSER_LEXER_SHARED_H_ */
+void wabt_destroy_optional_export(WabtAllocator*, WabtOptionalExport*);
+void wabt_destroy_exported_func(WabtAllocator*, WabtExportedFunc*);
+void wabt_destroy_exported_global(WabtAllocator*, WabtExportedFunc*);
+void wabt_destroy_exported_memory(WabtAllocator*, WabtExportedMemory*);
+void wabt_destroy_exported_table(WabtAllocator*, WabtExportedTable*);
+void wabt_destroy_func_fields(WabtAllocator*, WabtFuncField*);
+void wabt_destroy_text_list(WabtAllocator*, WabtTextList*);
+WABT_EXTERN_C_END
+
+#endif /* WABT_AST_PARSER_LEXER_SHARED_H_ */
diff --git a/src/ast-parser.h b/src/ast-parser.h
index d19ddcca..b5d58ffc 100644
--- a/src/ast-parser.h
+++ b/src/ast-parser.h
@@ -14,18 +14,18 @@
* limitations under the License.
*/
-#ifndef WASM_AST_PARSER_H_
-#define WASM_AST_PARSER_H_
+#ifndef WABT_AST_PARSER_H_
+#define WABT_AST_PARSER_H_
#include "ast-lexer.h"
#include "common.h"
-struct WasmScript;
+struct WabtScript;
-WASM_EXTERN_C_BEGIN
-WasmResult wasm_parse_ast(WasmAstLexer* lexer,
- struct WasmScript* out_script,
- WasmSourceErrorHandler*);
-WASM_EXTERN_C_END
+WABT_EXTERN_C_BEGIN
+WabtResult wabt_parse_ast(WabtAstLexer* lexer,
+ struct WabtScript* out_script,
+ WabtSourceErrorHandler*);
+WABT_EXTERN_C_END
-#endif /* WASM_AST_PARSER_H_ */
+#endif /* WABT_AST_PARSER_H_ */
diff --git a/src/ast-parser.y b/src/ast-parser.y
index 07a5bb20..cff755ce 100644
--- a/src/ast-parser.y
+++ b/src/ast-parser.y
@@ -41,7 +41,7 @@
#define YYMAXDEPTH 10000000
#define DUPTEXT(dst, src) \
- (dst).start = wasm_strndup(parser->allocator, (src).start, (src).length); \
+ (dst).start = wabt_strndup(parser->allocator, (src).start, (src).length); \
(dst).length = (src).length
#define YYLLOC_DEFAULT(Current, Rhs, N) \
@@ -61,23 +61,23 @@
#define APPEND_FIELD_TO_LIST(module, field, KIND, kind, loc_, item) \
do { \
- field = wasm_append_module_field(parser->allocator, module); \
+ field = wabt_append_module_field(parser->allocator, module); \
field->loc = loc_; \
- field->type = WASM_MODULE_FIELD_TYPE_##KIND; \
+ field->type = WABT_MODULE_FIELD_TYPE_##KIND; \
field->kind = item; \
} while (0)
#define APPEND_ITEM_TO_VECTOR(module, Kind, kind, kinds, item_ptr) \
do { \
- Wasm##Kind* dummy = item_ptr; \
- wasm_append_##kind##_ptr_value(parser->allocator, &(module)->kinds, \
+ Wabt##Kind* dummy = item_ptr; \
+ wabt_append_##kind##_ptr_value(parser->allocator, &(module)->kinds, \
&dummy); \
} while (0)
#define INSERT_BINDING(module, kind, kinds, loc_, name) \
do \
if ((name).start) { \
- WasmBinding* binding = wasm_insert_binding( \
+ WabtBinding* binding = wabt_insert_binding( \
parser->allocator, &(module)->kind##_bindings, &(name)); \
binding->loc = loc_; \
binding->index = (module)->kinds.size - 1; \
@@ -87,10 +87,10 @@
#define APPEND_INLINE_EXPORT(module, KIND, loc_, value, index_) \
do \
if ((value).export_.has_export) { \
- WasmModuleField* export_field; \
+ WabtModuleField* export_field; \
APPEND_FIELD_TO_LIST(module, export_field, EXPORT, export_, loc_, \
(value).export_.export_); \
- export_field->export_.kind = WASM_EXTERNAL_KIND_##KIND; \
+ export_field->export_.kind = WABT_EXTERNAL_KIND_##KIND; \
export_field->export_.var.loc = loc_; \
export_field->export_.var.index = index_; \
APPEND_ITEM_TO_VECTOR(module, Export, export, exports, \
@@ -103,7 +103,7 @@
#define CHECK_IMPORT_ORDERING(module, kind, kinds, loc_) \
do { \
if ((module)->kinds.size != (module)->num_##kind##_imports) { \
- wasm_ast_parser_error( \
+ wabt_ast_parser_error( \
&loc_, lexer, parser, \
"imports must occur before all non-import definitions"); \
} \
@@ -111,87 +111,87 @@
#define CHECK_END_LABEL(loc, begin_label, end_label) \
do { \
- if (!wasm_string_slice_is_empty(&(end_label))) { \
- if (wasm_string_slice_is_empty(&(begin_label))) { \
- wasm_ast_parser_error(&loc, lexer, parser, \
+ if (!wabt_string_slice_is_empty(&(end_label))) { \
+ if (wabt_string_slice_is_empty(&(begin_label))) { \
+ wabt_ast_parser_error(&loc, lexer, parser, \
"unexpected label \"" PRIstringslice "\"", \
- WASM_PRINTF_STRING_SLICE_ARG(end_label)); \
- } else if (!wasm_string_slices_are_equal(&(begin_label), \
+ WABT_PRINTF_STRING_SLICE_ARG(end_label)); \
+ } else if (!wabt_string_slices_are_equal(&(begin_label), \
&(end_label))) { \
- wasm_ast_parser_error(&loc, lexer, parser, \
+ wabt_ast_parser_error(&loc, lexer, parser, \
"mismatching label \"" PRIstringslice \
"\" != \"" PRIstringslice "\"", \
- WASM_PRINTF_STRING_SLICE_ARG(begin_label), \
- WASM_PRINTF_STRING_SLICE_ARG(end_label)); \
+ WABT_PRINTF_STRING_SLICE_ARG(begin_label), \
+ WABT_PRINTF_STRING_SLICE_ARG(end_label)); \
} \
- wasm_destroy_string_slice(parser->allocator, &(end_label)); \
+ wabt_destroy_string_slice(parser->allocator, &(end_label)); \
} \
} while (0)
-#define YYMALLOC(size) wasm_alloc(parser->allocator, size, WASM_DEFAULT_ALIGN)
-#define YYFREE(p) wasm_free(parser->allocator, p)
+#define YYMALLOC(size) wabt_alloc(parser->allocator, size, WABT_DEFAULT_ALIGN)
+#define YYFREE(p) wabt_free(parser->allocator, p)
#define USE_NATURAL_ALIGNMENT (~0)
-static WasmExprList join_exprs1(WasmLocation* loc, WasmExpr* expr1);
-static WasmExprList join_exprs2(WasmLocation* loc, WasmExprList* expr1,
- WasmExpr* expr2);
+static WabtExprList join_exprs1(WabtLocation* loc, WabtExpr* expr1);
+static WabtExprList join_exprs2(WabtLocation* loc, WabtExprList* expr1,
+ WabtExpr* expr2);
-static WasmFuncField* new_func_field(WasmAllocator* allocator) {
- return wasm_alloc_zero(allocator, sizeof(WasmFuncField), WASM_DEFAULT_ALIGN);
+static WabtFuncField* new_func_field(WabtAllocator* allocator) {
+ return wabt_alloc_zero(allocator, sizeof(WabtFuncField), WABT_DEFAULT_ALIGN);
}
-static WasmFunc* new_func(WasmAllocator* allocator) {
- return wasm_alloc_zero(allocator, sizeof(WasmFunc), WASM_DEFAULT_ALIGN);
+static WabtFunc* new_func(WabtAllocator* allocator) {
+ return wabt_alloc_zero(allocator, sizeof(WabtFunc), WABT_DEFAULT_ALIGN);
}
-static WasmCommand* new_command(WasmAllocator* allocator) {
- return wasm_alloc_zero(allocator, sizeof(WasmCommand), WASM_DEFAULT_ALIGN);
+static WabtCommand* new_command(WabtAllocator* allocator) {
+ return wabt_alloc_zero(allocator, sizeof(WabtCommand), WABT_DEFAULT_ALIGN);
}
-static WasmModule* new_module(WasmAllocator* allocator) {
- return wasm_alloc_zero(allocator, sizeof(WasmModule), WASM_DEFAULT_ALIGN);
+static WabtModule* new_module(WabtAllocator* allocator) {
+ return wabt_alloc_zero(allocator, sizeof(WabtModule), WABT_DEFAULT_ALIGN);
}
-static WasmImport* new_import(WasmAllocator* allocator) {
- return wasm_alloc_zero(allocator, sizeof(WasmImport), WASM_DEFAULT_ALIGN);
+static WabtImport* new_import(WabtAllocator* allocator) {
+ return wabt_alloc_zero(allocator, sizeof(WabtImport), WABT_DEFAULT_ALIGN);
}
-static WasmTextListNode* new_text_list_node(WasmAllocator* allocator) {
- return wasm_alloc_zero(allocator, sizeof(WasmTextListNode),
- WASM_DEFAULT_ALIGN);
+static WabtTextListNode* new_text_list_node(WabtAllocator* allocator) {
+ return wabt_alloc_zero(allocator, sizeof(WabtTextListNode),
+ WABT_DEFAULT_ALIGN);
}
-static WasmResult parse_const(WasmType type, WasmLiteralType literal_type,
- const char* s, const char* end, WasmConst* out);
-static void dup_text_list(WasmAllocator*, WasmTextList* text_list,
+static WabtResult parse_const(WabtType type, WabtLiteralType literal_type,
+ const char* s, const char* end, WabtConst* out);
+static void dup_text_list(WabtAllocator*, WabtTextList* text_list,
void** out_data, size_t* out_size);
-static WasmBool is_empty_signature(WasmFuncSignature* sig);
+static WabtBool is_empty_signature(WabtFuncSignature* sig);
-static void append_implicit_func_declaration(WasmAllocator*, WasmLocation*,
- WasmModule*, WasmFuncDeclaration*);
+static void append_implicit_func_declaration(WabtAllocator*, WabtLocation*,
+ WabtModule*, WabtFuncDeclaration*);
typedef struct BinaryErrorCallbackData {
- WasmLocation* loc;
- WasmAstLexer* lexer;
- WasmAstParser* parser;
+ WabtLocation* loc;
+ WabtAstLexer* lexer;
+ WabtAstParser* parser;
} BinaryErrorCallbackData;
static void on_read_binary_error(uint32_t offset, const char* error,
void* user_data);
-#define wasm_ast_parser_lex wasm_ast_lexer_lex
+#define wabt_ast_parser_lex wabt_ast_lexer_lex
%}
-%define api.prefix {wasm_ast_parser_}
+%define api.prefix {wabt_ast_parser_}
%define api.pure true
-%define api.value.type {WasmToken}
-%define api.token.prefix {WASM_TOKEN_TYPE_}
+%define api.value.type {WabtToken}
+%define api.token.prefix {WABT_TOKEN_TYPE_}
%define parse.error verbose
-%lex-param {WasmAstLexer* lexer} {WasmAstParser* parser}
-%parse-param {WasmAstLexer* lexer} {WasmAstParser* parser}
+%lex-param {WabtAstLexer* lexer} {WabtAstParser* parser}
+%parse-param {WabtAstLexer* lexer} {WabtAstParser* parser}
%locations
%token LPAR "("
@@ -257,32 +257,32 @@ static void on_read_binary_error(uint32_t offset, const char* error,
/* These non-terminals use the types below that have destructors, but the
* memory is shared with the lexer, so should not be destroyed. */
%destructor {} ALIGN_EQ_NAT OFFSET_EQ_NAT TEXT VAR NAT INT FLOAT
-%destructor { wasm_destroy_block(parser->allocator, &$$); } <block>
-%destructor { wasm_destroy_command(parser->allocator, $$); wasm_free(parser->allocator, $$); } <command>
-%destructor { wasm_destroy_command_vector_and_elements(parser->allocator, &$$); } <commands>
-%destructor { wasm_destroy_const_vector(parser->allocator, &$$); } <consts>
-%destructor { wasm_destroy_elem_segment(parser->allocator, &$$); } <elem_segment>
-%destructor { wasm_destroy_export(parser->allocator, &$$); } <export_>
-%destructor { wasm_destroy_exported_func(parser->allocator, &$$); } <exported_func>
-%destructor { wasm_destroy_exported_memory(parser->allocator, &$$); } <exported_memory>
-%destructor { wasm_destroy_exported_table(parser->allocator, &$$); } <exported_table>
-%destructor { wasm_destroy_expr(parser->allocator, $$); } <expr>
-%destructor { wasm_destroy_expr_list(parser->allocator, $$.first); } <expr_list>
-%destructor { wasm_destroy_func_fields(parser->allocator, $$); } <func_fields>
-%destructor { wasm_destroy_func(parser->allocator, $$); wasm_free(parser->allocator, $$); } <func>
-%destructor { wasm_destroy_func_signature(parser->allocator, &$$); } <func_sig>
-%destructor { wasm_destroy_func_type(parser->allocator, &$$); } <func_type>
-%destructor { wasm_destroy_import(parser->allocator, $$); wasm_free(parser->allocator, $$); } <import>
-%destructor { wasm_destroy_data_segment(parser->allocator, &$$); } <data_segment>
-%destructor { wasm_destroy_module(parser->allocator, $$); wasm_free(parser->allocator, $$); } <module>
-%destructor { wasm_destroy_raw_module(parser->allocator, &$$); } <raw_module>
-%destructor { wasm_destroy_string_slice(parser->allocator, &$$.text); } <literal>
-%destructor { wasm_destroy_script(&$$); } <script>
-%destructor { wasm_destroy_string_slice(parser->allocator, &$$); } <text>
-%destructor { wasm_destroy_text_list(parser->allocator, &$$); } <text_list>
-%destructor { wasm_destroy_type_vector(parser->allocator, &$$); } <types>
-%destructor { wasm_destroy_var_vector_and_elements(parser->allocator, &$$); } <vars>
-%destructor { wasm_destroy_var(parser->allocator, &$$); } <var>
+%destructor { wabt_destroy_block(parser->allocator, &$$); } <block>
+%destructor { wabt_destroy_command(parser->allocator, $$); wabt_free(parser->allocator, $$); } <command>
+%destructor { wabt_destroy_command_vector_and_elements(parser->allocator, &$$); } <commands>
+%destructor { wabt_destroy_const_vector(parser->allocator, &$$); } <consts>
+%destructor { wabt_destroy_elem_segment(parser->allocator, &$$); } <elem_segment>
+%destructor { wabt_destroy_export(parser->allocator, &$$); } <export_>
+%destructor { wabt_destroy_exported_func(parser->allocator, &$$); } <exported_func>
+%destructor { wabt_destroy_exported_memory(parser->allocator, &$$); } <exported_memory>
+%destructor { wabt_destroy_exported_table(parser->allocator, &$$); } <exported_table>
+%destructor { wabt_destroy_expr(parser->allocator, $$); } <expr>
+%destructor { wabt_destroy_expr_list(parser->allocator, $$.first); } <expr_list>
+%destructor { wabt_destroy_func_fields(parser->allocator, $$); } <func_fields>
+%destructor { wabt_destroy_func(parser->allocator, $$); wabt_free(parser->allocator, $$); } <func>
+%destructor { wabt_destroy_func_signature(parser->allocator, &$$); } <func_sig>
+%destructor { wabt_destroy_func_type(parser->allocator, &$$); } <func_type>
+%destructor { wabt_destroy_import(parser->allocator, $$); wabt_free(parser->allocator, $$); } <import>
+%destructor { wabt_destroy_data_segment(parser->allocator, &$$); } <data_segment>
+%destructor { wabt_destroy_module(parser->allocator, $$); wabt_free(parser->allocator, $$); } <module>
+%destructor { wabt_destroy_raw_module(parser->allocator, &$$); } <raw_module>
+%destructor { wabt_destroy_string_slice(parser->allocator, &$$.text); } <literal>
+%destructor { wabt_destroy_script(&$$); } <script>
+%destructor { wabt_destroy_string_slice(parser->allocator, &$$); } <text>
+%destructor { wabt_destroy_text_list(parser->allocator, &$$); } <text_list>
+%destructor { wabt_destroy_type_vector(parser->allocator, &$$); } <types>
+%destructor { wabt_destroy_var_vector_and_elements(parser->allocator, &$$); } <vars>
+%destructor { wabt_destroy_var(parser->allocator, &$$); } <var>
%nonassoc LOW
@@ -296,14 +296,14 @@ static void on_read_binary_error(uint32_t offset, const char* error,
non_empty_text_list :
TEXT {
- WasmTextListNode* node = new_text_list_node(parser->allocator);
+ WabtTextListNode* node = new_text_list_node(parser->allocator);
DUPTEXT(node->text, $1);
node->next = NULL;
$$.first = $$.last = node;
}
| non_empty_text_list TEXT {
$$ = $1;
- WasmTextListNode* node = new_text_list_node(parser->allocator);
+ WabtTextListNode* node = new_text_list_node(parser->allocator);
DUPTEXT(node->text, $2);
node->next = NULL;
$$.last->next = node;
@@ -317,10 +317,10 @@ text_list :
quoted_text :
TEXT {
- WasmTextListNode node;
+ WabtTextListNode node;
node.text = $1;
node.next = NULL;
- WasmTextList text_list;
+ WabtTextList text_list;
text_list.first = &node;
text_list.last = &node;
void* data;
@@ -334,10 +334,10 @@ quoted_text :
/* Types */
value_type_list :
- /* empty */ { WASM_ZERO_MEMORY($$); }
+ /* empty */ { WABT_ZERO_MEMORY($$); }
| value_type_list VALUE_TYPE {
$$ = $1;
- wasm_append_type_value(parser->allocator, &$$, &$2);
+ wabt_append_type_value(parser->allocator, &$$, &$2);
}
;
elem_type :
@@ -345,32 +345,32 @@ elem_type :
;
global_type :
VALUE_TYPE {
- WASM_ZERO_MEMORY($$);
+ WABT_ZERO_MEMORY($$);
$$.type = $1;
- $$.mutable_ = WASM_FALSE;
+ $$.mutable_ = WABT_FALSE;
}
| LPAR MUT VALUE_TYPE RPAR {
- WASM_ZERO_MEMORY($$);
+ WABT_ZERO_MEMORY($$);
$$.type = $3;
- $$.mutable_ = WASM_TRUE;
+ $$.mutable_ = WABT_TRUE;
}
;
func_type :
LPAR FUNC func_sig RPAR { $$ = $3; }
;
func_sig :
- /* empty */ { WASM_ZERO_MEMORY($$); }
+ /* empty */ { WABT_ZERO_MEMORY($$); }
| LPAR PARAM value_type_list RPAR {
- WASM_ZERO_MEMORY($$);
+ WABT_ZERO_MEMORY($$);
$$.param_types = $3;
}
| LPAR PARAM value_type_list RPAR LPAR RESULT value_type_list RPAR {
- WASM_ZERO_MEMORY($$);
+ WABT_ZERO_MEMORY($$);
$$.param_types = $3;
$$.result_types = $7;
}
| LPAR RESULT value_type_list RPAR {
- WASM_ZERO_MEMORY($$);
+ WABT_ZERO_MEMORY($$);
$$.result_types = $3;
}
;
@@ -383,12 +383,12 @@ memory_sig :
;
limits :
nat {
- $$.has_max = WASM_FALSE;
+ $$.has_max = WABT_FALSE;
$$.initial = $1;
$$.max = 0;
}
| nat nat {
- $$.has_max = WASM_TRUE;
+ $$.has_max = WABT_TRUE;
$$.initial = $1;
$$.max = $2;
}
@@ -401,11 +401,11 @@ type_use :
nat :
NAT {
- if (WASM_FAILED(wasm_parse_uint64($1.text.start,
+ if (WABT_FAILED(wabt_parse_uint64($1.text.start,
$1.text.start + $1.text.length, &$$))) {
- wasm_ast_parser_error(&@1, lexer, parser,
+ wabt_ast_parser_error(&@1, lexer, parser,
"invalid int " PRIstringslice "\"",
- WASM_PRINTF_STRING_SLICE_ARG($1.text));
+ WABT_PRINTF_STRING_SLICE_ARG($1.text));
}
}
;
@@ -428,24 +428,24 @@ literal :
var :
nat {
$$.loc = @1;
- $$.type = WASM_VAR_TYPE_INDEX;
+ $$.type = WABT_VAR_TYPE_INDEX;
$$.index = $1;
}
| VAR {
$$.loc = @1;
- $$.type = WASM_VAR_TYPE_NAME;
+ $$.type = WABT_VAR_TYPE_NAME;
DUPTEXT($$.name, $1);
}
;
var_list :
- /* empty */ { WASM_ZERO_MEMORY($$); }
+ /* empty */ { WABT_ZERO_MEMORY($$); }
| var_list var {
$$ = $1;
- wasm_append_var_value(parser->allocator, &$$, &$2);
+ wabt_append_var_value(parser->allocator, &$$, &$2);
}
;
bind_var_opt :
- /* empty */ { WASM_ZERO_MEMORY($$); }
+ /* empty */ { WABT_ZERO_MEMORY($$); }
| bind_var
;
bind_var :
@@ -453,29 +453,29 @@ bind_var :
;
labeling_opt :
- /* empty */ %prec LOW { WASM_ZERO_MEMORY($$); }
+ /* empty */ %prec LOW { WABT_ZERO_MEMORY($$); }
| bind_var
;
offset_opt :
/* empty */ { $$ = 0; }
| OFFSET_EQ_NAT {
- if (WASM_FAILED(wasm_parse_int64($1.start, $1.start + $1.length, &$$,
- WASM_PARSE_SIGNED_AND_UNSIGNED))) {
- wasm_ast_parser_error(&@1, lexer, parser,
+ if (WABT_FAILED(wabt_parse_int64($1.start, $1.start + $1.length, &$$,
+ WABT_PARSE_SIGNED_AND_UNSIGNED))) {
+ wabt_ast_parser_error(&@1, lexer, parser,
"invalid offset \"" PRIstringslice "\"",
- WASM_PRINTF_STRING_SLICE_ARG($1));
+ WABT_PRINTF_STRING_SLICE_ARG($1));
}
}
;
align_opt :
/* empty */ { $$ = USE_NATURAL_ALIGNMENT; }
| ALIGN_EQ_NAT {
- if (WASM_FAILED(wasm_parse_int32($1.start, $1.start + $1.length, &$$,
- WASM_PARSE_UNSIGNED_ONLY))) {
- wasm_ast_parser_error(&@1, lexer, parser,
+ if (WABT_FAILED(wabt_parse_int32($1.start, $1.start + $1.length, &$$,
+ WABT_PARSE_UNSIGNED_ONLY))) {
+ wabt_ast_parser_error(&@1, lexer, parser,
"invalid alignment \"" PRIstringslice "\"",
- WASM_PRINTF_STRING_SLICE_ARG($1));
+ WABT_PRINTF_STRING_SLICE_ARG($1));
}
}
;
@@ -487,129 +487,129 @@ instr :
;
plain_instr :
UNREACHABLE {
- $$ = wasm_new_unreachable_expr(parser->allocator);
+ $$ = wabt_new_unreachable_expr(parser->allocator);
}
| NOP {
- $$ = wasm_new_nop_expr(parser->allocator);
+ $$ = wabt_new_nop_expr(parser->allocator);
}
| DROP {
- $$ = wasm_new_drop_expr(parser->allocator);
+ $$ = wabt_new_drop_expr(parser->allocator);
}
| SELECT {
- $$ = wasm_new_select_expr(parser->allocator);
+ $$ = wabt_new_select_expr(parser->allocator);
}
| BR var {
- $$ = wasm_new_br_expr(parser->allocator);
+ $$ = wabt_new_br_expr(parser->allocator);
$$->br.var = $2;
}
| BR_IF var {
- $$ = wasm_new_br_if_expr(parser->allocator);
+ $$ = wabt_new_br_if_expr(parser->allocator);
$$->br_if.var = $2;
}
| BR_TABLE var_list var {
- $$ = wasm_new_br_table_expr(parser->allocator);
+ $$ = wabt_new_br_table_expr(parser->allocator);
$$->br_table.targets = $2;
$$->br_table.default_target = $3;
}
| RETURN {
- $$ = wasm_new_return_expr(parser->allocator);
+ $$ = wabt_new_return_expr(parser->allocator);
}
| CALL var {
- $$ = wasm_new_call_expr(parser->allocator);
+ $$ = wabt_new_call_expr(parser->allocator);
$$->call.var = $2;
}
| CALL_INDIRECT var {
- $$ = wasm_new_call_indirect_expr(parser->allocator);
+ $$ = wabt_new_call_indirect_expr(parser->allocator);
$$->call_indirect.var = $2;
}
| GET_LOCAL var {
- $$ = wasm_new_get_local_expr(parser->allocator);
+ $$ = wabt_new_get_local_expr(parser->allocator);
$$->get_local.var = $2;
}
| SET_LOCAL var {
- $$ = wasm_new_set_local_expr(parser->allocator);
+ $$ = wabt_new_set_local_expr(parser->allocator);
$$->set_local.var = $2;
}
| TEE_LOCAL var {
- $$ = wasm_new_tee_local_expr(parser->allocator);
+ $$ = wabt_new_tee_local_expr(parser->allocator);
$$->tee_local.var = $2;
}
| GET_GLOBAL var {
- $$ = wasm_new_get_global_expr(parser->allocator);
+ $$ = wabt_new_get_global_expr(parser->allocator);
$$->get_global.var = $2;
}
| SET_GLOBAL var {
- $$ = wasm_new_set_global_expr(parser->allocator);
+ $$ = wabt_new_set_global_expr(parser->allocator);
$$->set_global.var = $2;
}
| LOAD offset_opt align_opt {
- $$ = wasm_new_load_expr(parser->allocator);
+ $$ = wabt_new_load_expr(parser->allocator);
$$->load.opcode = $1;
$$->load.offset = $2;
$$->load.align = $3;
}
| STORE offset_opt align_opt {
- $$ = wasm_new_store_expr(parser->allocator);
+ $$ = wabt_new_store_expr(parser->allocator);
$$->store.opcode = $1;
$$->store.offset = $2;
$$->store.align = $3;
}
| CONST literal {
- $$ = wasm_new_const_expr(parser->allocator);
+ $$ = wabt_new_const_expr(parser->allocator);
$$->const_.loc = @1;
- if (WASM_FAILED(parse_const($1, $2.type, $2.text.start,
+ if (WABT_FAILED(parse_const($1, $2.type, $2.text.start,
$2.text.start + $2.text.length,
&$$->const_))) {
- wasm_ast_parser_error(&@2, lexer, parser,
+ wabt_ast_parser_error(&@2, lexer, parser,
"invalid literal \"" PRIstringslice "\"",
- WASM_PRINTF_STRING_SLICE_ARG($2.text));
+ WABT_PRINTF_STRING_SLICE_ARG($2.text));
}
- wasm_free(parser->allocator, (char*)$2.text.start);
+ wabt_free(parser->allocator, (char*)$2.text.start);
}
| UNARY {
- $$ = wasm_new_unary_expr(parser->allocator);
+ $$ = wabt_new_unary_expr(parser->allocator);
$$->unary.opcode = $1;
}
| BINARY {
- $$ = wasm_new_binary_expr(parser->allocator);
+ $$ = wabt_new_binary_expr(parser->allocator);
$$->binary.opcode = $1;
}
| COMPARE {
- $$ = wasm_new_compare_expr(parser->allocator);
+ $$ = wabt_new_compare_expr(parser->allocator);
$$->compare.opcode = $1;
}
| CONVERT {
- $$ = wasm_new_convert_expr(parser->allocator);
+ $$ = wabt_new_convert_expr(parser->allocator);
$$->convert.opcode = $1;
}
| CURRENT_MEMORY {
- $$ = wasm_new_current_memory_expr(parser->allocator);
+ $$ = wabt_new_current_memory_expr(parser->allocator);
}
| GROW_MEMORY {
- $$ = wasm_new_grow_memory_expr(parser->allocator);
+ $$ = wabt_new_grow_memory_expr(parser->allocator);
}
;
block_instr :
BLOCK labeling_opt block END labeling_opt {
- $$ = wasm_new_block_expr(parser->allocator);
+ $$ = wabt_new_block_expr(parser->allocator);
$$->block = $3;
$$->block.label = $2;
CHECK_END_LABEL(@5, $$->block.label, $5);
}
| LOOP labeling_opt block END labeling_opt {
- $$ = wasm_new_loop_expr(parser->allocator);
+ $$ = wabt_new_loop_expr(parser->allocator);
$$->loop = $3;
$$->loop.label = $2;
CHECK_END_LABEL(@5, $$->block.label, $5);
}
| IF labeling_opt block END labeling_opt {
- $$ = wasm_new_if_expr(parser->allocator);
+ $$ = wabt_new_if_expr(parser->allocator);
$$->if_.true_ = $3;
$$->if_.true_.label = $2;
CHECK_END_LABEL(@5, $$->block.label, $5);
}
| IF labeling_opt block ELSE labeling_opt instr_list END labeling_opt {
- $$ = wasm_new_if_expr(parser->allocator);
+ $$ = wabt_new_if_expr(parser->allocator);
$$->if_.true_ = $3;
$$->if_.true_.label = $2;
$$->if_.false_ = $6.first;
@@ -619,7 +619,7 @@ block_instr :
;
block :
value_type_list instr_list {
- WASM_ZERO_MEMORY($$);
+ WABT_ZERO_MEMORY($$);
$$.sig = $1;
$$.first = $2.first;
}
@@ -634,63 +634,63 @@ expr1 :
$$ = join_exprs2(&@1, &$2, $1);
}
| BLOCK labeling_opt block {
- WasmExpr* expr = wasm_new_block_expr(parser->allocator);
+ WabtExpr* expr = wabt_new_block_expr(parser->allocator);
expr->block = $3;
expr->block.label = $2;
$$ = join_exprs1(&@1, expr);
}
| LOOP labeling_opt block {
- WasmExpr* expr = wasm_new_loop_expr(parser->allocator);
+ WabtExpr* expr = wabt_new_loop_expr(parser->allocator);
expr->loop = $3;
expr->loop.label = $2;
$$ = join_exprs1(&@1, expr);
}
| IF labeling_opt value_type_list if_ {
$$ = $4;
- WasmExpr* if_ = $4.last;
- assert(if_->type == WASM_EXPR_TYPE_IF);
+ WabtExpr* if_ = $4.last;
+ assert(if_->type == WABT_EXPR_TYPE_IF);
if_->if_.true_.label = $2;
if_->if_.true_.sig = $3;
}
;
if_ :
LPAR THEN instr_list RPAR LPAR ELSE instr_list RPAR {
- WasmExpr* expr = wasm_new_if_expr(parser->allocator);
+ WabtExpr* expr = wabt_new_if_expr(parser->allocator);
expr->if_.true_.first = $3.first;
expr->if_.false_ = $7.first;
$$ = join_exprs1(&@1, expr);
}
| LPAR THEN instr_list RPAR {
- WasmExpr* expr = wasm_new_if_expr(parser->allocator);
+ WabtExpr* expr = wabt_new_if_expr(parser->allocator);
expr->if_.true_.first = $3.first;
$$ = join_exprs1(&@1, expr);
}
| expr LPAR THEN instr_list RPAR LPAR ELSE instr_list RPAR {
- WasmExpr* expr = wasm_new_if_expr(parser->allocator);
+ WabtExpr* expr = wabt_new_if_expr(parser->allocator);
expr->if_.true_.first = $4.first;
expr->if_.false_ = $8.first;
$$ = join_exprs2(&@1, &$1, expr);
}
| expr LPAR THEN instr_list RPAR {
- WasmExpr* expr = wasm_new_if_expr(parser->allocator);
+ WabtExpr* expr = wabt_new_if_expr(parser->allocator);
expr->if_.true_.first = $4.first;
$$ = join_exprs2(&@1, &$1, expr);
}
| expr expr expr {
- WasmExpr* expr = wasm_new_if_expr(parser->allocator);
+ WabtExpr* expr = wabt_new_if_expr(parser->allocator);
expr->if_.true_.first = $2.first;
expr->if_.false_ = $3.first;
$$ = join_exprs2(&@1, &$1, expr);
}
| expr expr {
- WasmExpr* expr = wasm_new_if_expr(parser->allocator);
+ WabtExpr* expr = wabt_new_if_expr(parser->allocator);
expr->if_.true_.first = $2.first;
$$ = join_exprs2(&@1, &$1, expr);
}
;
instr_list :
- /* empty */ { WASM_ZERO_MEMORY($$); }
+ /* empty */ { WABT_ZERO_MEMORY($$); }
| instr instr_list {
$$.first = $1.first;
$1.last->next = $2.first;
@@ -699,7 +699,7 @@ instr_list :
}
;
expr_list :
- /* empty */ { WASM_ZERO_MEMORY($$); }
+ /* empty */ { WABT_ZERO_MEMORY($$); }
| expr expr_list {
$$.first = $1.first;
$1.last->next = $2.first;
@@ -716,19 +716,19 @@ func_fields :
func_body
| LPAR RESULT value_type_list RPAR func_body {
$$ = new_func_field(parser->allocator);
- $$->type = WASM_FUNC_FIELD_TYPE_RESULT_TYPES;
+ $$->type = WABT_FUNC_FIELD_TYPE_RESULT_TYPES;
$$->types = $3;
$$->next = $5;
}
| LPAR PARAM value_type_list RPAR func_fields {
$$ = new_func_field(parser->allocator);
- $$->type = WASM_FUNC_FIELD_TYPE_PARAM_TYPES;
+ $$->type = WABT_FUNC_FIELD_TYPE_PARAM_TYPES;
$$->types = $3;
$$->next = $5;
}
| LPAR PARAM bind_var VALUE_TYPE RPAR func_fields {
$$ = new_func_field(parser->allocator);
- $$->type = WASM_FUNC_FIELD_TYPE_BOUND_PARAM;
+ $$->type = WABT_FUNC_FIELD_TYPE_BOUND_PARAM;
$$->bound_type.loc = @2;
$$->bound_type.name = $3;
$$->bound_type.type = $4;
@@ -738,19 +738,19 @@ func_fields :
func_body :
instr_list {
$$ = new_func_field(parser->allocator);
- $$->type = WASM_FUNC_FIELD_TYPE_EXPRS;
+ $$->type = WABT_FUNC_FIELD_TYPE_EXPRS;
$$->first_expr = $1.first;
$$->next = NULL;
}
| LPAR LOCAL value_type_list RPAR func_body {
$$ = new_func_field(parser->allocator);
- $$->type = WASM_FUNC_FIELD_TYPE_LOCAL_TYPES;
+ $$->type = WABT_FUNC_FIELD_TYPE_LOCAL_TYPES;
$$->types = $3;
$$->next = $5;
}
| LPAR LOCAL bind_var VALUE_TYPE RPAR func_body {
$$ = new_func_field(parser->allocator);
- $$->type = WASM_FUNC_FIELD_TYPE_BOUND_LOCAL;
+ $$->type = WABT_FUNC_FIELD_TYPE_BOUND_LOCAL;
$$->bound_type.loc = @2;
$$->bound_type.name = $3;
$$->bound_type.type = $4;
@@ -760,31 +760,31 @@ func_body :
func_info :
func_fields {
$$ = new_func(parser->allocator);
- WasmFuncField* field = $1;
+ WabtFuncField* field = $1;
while (field) {
- WasmFuncField* next = field->next;
+ WabtFuncField* next = field->next;
switch (field->type) {
- case WASM_FUNC_FIELD_TYPE_EXPRS:
+ case WABT_FUNC_FIELD_TYPE_EXPRS:
$$->first_expr = field->first_expr;
break;
- case WASM_FUNC_FIELD_TYPE_PARAM_TYPES:
- case WASM_FUNC_FIELD_TYPE_LOCAL_TYPES: {
- WasmTypeVector* types =
- field->type == WASM_FUNC_FIELD_TYPE_PARAM_TYPES
+ case WABT_FUNC_FIELD_TYPE_PARAM_TYPES:
+ case WABT_FUNC_FIELD_TYPE_LOCAL_TYPES: {
+ WabtTypeVector* types =
+ field->type == WABT_FUNC_FIELD_TYPE_PARAM_TYPES
? &$$->decl.sig.param_types
: &$$->local_types;
- wasm_extend_types(parser->allocator, types, &field->types);
- wasm_destroy_type_vector(parser->allocator, &field->types);
+ wabt_extend_types(parser->allocator, types, &field->types);
+ wabt_destroy_type_vector(parser->allocator, &field->types);
break;
}
- case WASM_FUNC_FIELD_TYPE_BOUND_PARAM:
- case WASM_FUNC_FIELD_TYPE_BOUND_LOCAL: {
- WasmTypeVector* types;
- WasmBindingHash* bindings;
- if (field->type == WASM_FUNC_FIELD_TYPE_BOUND_PARAM) {
+ case WABT_FUNC_FIELD_TYPE_BOUND_PARAM:
+ case WABT_FUNC_FIELD_TYPE_BOUND_LOCAL: {
+ WabtTypeVector* types;
+ WabtBindingHash* bindings;
+ if (field->type == WABT_FUNC_FIELD_TYPE_BOUND_PARAM) {
types = &$$->decl.sig.param_types;
bindings = &$$->param_bindings;
} else {
@@ -792,52 +792,52 @@ func_info :
bindings = &$$->local_bindings;
}
- wasm_append_type_value(parser->allocator, types,
+ wabt_append_type_value(parser->allocator, types,
&field->bound_type.type);
- WasmBinding* binding = wasm_insert_binding(
+ WabtBinding* binding = wabt_insert_binding(
parser->allocator, bindings, &field->bound_type.name);
binding->loc = field->bound_type.loc;
binding->index = types->size - 1;
break;
}
- case WASM_FUNC_FIELD_TYPE_RESULT_TYPES:
+ case WABT_FUNC_FIELD_TYPE_RESULT_TYPES:
$$->decl.sig.result_types = field->types;
break;
}
/* we steal memory from the func field, but not the linked list nodes */
- wasm_free(parser->allocator, field);
+ wabt_free(parser->allocator, field);
field = next;
}
}
;
func :
LPAR FUNC bind_var_opt inline_export type_use func_info RPAR {
- WASM_ZERO_MEMORY($$);
+ WABT_ZERO_MEMORY($$);
$$.func = $6;
- $$.func->decl.flags |= WASM_FUNC_DECLARATION_FLAG_HAS_FUNC_TYPE;
+ $$.func->decl.flags |= WABT_FUNC_DECLARATION_FLAG_HAS_FUNC_TYPE;
$$.func->decl.type_var = $5;
$$.func->name = $3;
$$.export_ = $4;
}
/* Duplicate above for empty inline_export_opt to avoid LR(1) conflict. */
| LPAR FUNC bind_var_opt type_use func_info RPAR {
- WASM_ZERO_MEMORY($$);
+ WABT_ZERO_MEMORY($$);
$$.func = $5;
- $$.func->decl.flags |= WASM_FUNC_DECLARATION_FLAG_HAS_FUNC_TYPE;
+ $$.func->decl.flags |= WABT_FUNC_DECLARATION_FLAG_HAS_FUNC_TYPE;
$$.func->decl.type_var = $4;
$$.func->name = $3;
}
| LPAR FUNC bind_var_opt inline_export func_info RPAR {
- WASM_ZERO_MEMORY($$);
+ WABT_ZERO_MEMORY($$);
$$.func = $5;
$$.func->name = $3;
$$.export_ = $4;
}
/* Duplicate above for empty inline_export_opt to avoid LR(1) conflict. */
| LPAR FUNC bind_var_opt func_info RPAR {
- WASM_ZERO_MEMORY($$);
+ WABT_ZERO_MEMORY($$);
$$.func = $4;
$$.func->name = $3;
}
@@ -854,15 +854,15 @@ offset :
elem :
LPAR ELEM var offset var_list RPAR {
- WASM_ZERO_MEMORY($$);
+ WABT_ZERO_MEMORY($$);
$$.table_var = $3;
$$.offset = $4.first;
$$.vars = $5;
}
| LPAR ELEM offset var_list RPAR {
- WASM_ZERO_MEMORY($$);
+ WABT_ZERO_MEMORY($$);
$$.table_var.loc = @2;
- $$.table_var.type = WASM_VAR_TYPE_INDEX;
+ $$.table_var.type = WABT_VAR_TYPE_INDEX;
$$.table_var.index = 0;
$$.offset = $3.first;
$$.vars = $4;
@@ -873,22 +873,22 @@ table :
LPAR TABLE bind_var_opt inline_export_opt table_sig RPAR {
$$.table = $5;
$$.table.name = $3;
- $$.has_elem_segment = WASM_FALSE;
+ $$.has_elem_segment = WABT_FALSE;
$$.export_ = $4;
}
| LPAR TABLE bind_var_opt inline_export_opt elem_type
LPAR ELEM var_list RPAR RPAR {
- WasmExpr* expr = wasm_new_const_expr(parser->allocator);
+ WabtExpr* expr = wabt_new_const_expr(parser->allocator);
expr->loc = @2;
- expr->const_.type = WASM_TYPE_I32;
+ expr->const_.type = WABT_TYPE_I32;
expr->const_.u32 = 0;
- WASM_ZERO_MEMORY($$);
+ WABT_ZERO_MEMORY($$);
$$.table.name = $3;
$$.table.elem_limits.initial = $8.size;
$$.table.elem_limits.max = $8.size;
- $$.table.elem_limits.has_max = WASM_TRUE;
- $$.has_elem_segment = WASM_TRUE;
+ $$.table.elem_limits.has_max = WABT_TRUE;
+ $$.has_elem_segment = WABT_TRUE;
$$.elem_segment.offset = expr;
$$.elem_segment.vars = $8;
$$.export_ = $4;
@@ -897,88 +897,88 @@ table :
data :
LPAR DATA var offset text_list RPAR {
- WASM_ZERO_MEMORY($$);
+ WABT_ZERO_MEMORY($$);
$$.memory_var = $3;
$$.offset = $4.first;
dup_text_list(parser->allocator, &$5, &$$.data, &$$.size);
- wasm_destroy_text_list(parser->allocator, &$5);
+ wabt_destroy_text_list(parser->allocator, &$5);
}
| LPAR DATA offset text_list RPAR {
- WASM_ZERO_MEMORY($$);
+ WABT_ZERO_MEMORY($$);
$$.memory_var.loc = @2;
- $$.memory_var.type = WASM_VAR_TYPE_INDEX;
+ $$.memory_var.type = WABT_VAR_TYPE_INDEX;
$$.memory_var.index = 0;
$$.offset = $3.first;
dup_text_list(parser->allocator, &$4, &$$.data, &$$.size);
- wasm_destroy_text_list(parser->allocator, &$4);
+ wabt_destroy_text_list(parser->allocator, &$4);
}
;
memory :
LPAR MEMORY bind_var_opt inline_export_opt memory_sig RPAR {
- WASM_ZERO_MEMORY($$);
+ WABT_ZERO_MEMORY($$);
$$.memory = $5;
$$.memory.name = $3;
- $$.has_data_segment = WASM_FALSE;
+ $$.has_data_segment = WABT_FALSE;
$$.export_ = $4;
}
| LPAR MEMORY bind_var_opt inline_export LPAR DATA text_list RPAR RPAR {
- WasmExpr* expr = wasm_new_const_expr(parser->allocator);
+ WabtExpr* expr = wabt_new_const_expr(parser->allocator);
expr->loc = @2;
- expr->const_.type = WASM_TYPE_I32;
+ expr->const_.type = WABT_TYPE_I32;
expr->const_.u32 = 0;
- WASM_ZERO_MEMORY($$);
- $$.has_data_segment = WASM_TRUE;
+ WABT_ZERO_MEMORY($$);
+ $$.has_data_segment = WABT_TRUE;
$$.data_segment.offset = expr;
dup_text_list(parser->allocator, &$7, &$$.data_segment.data,
&$$.data_segment.size);
- wasm_destroy_text_list(parser->allocator, &$7);
- uint32_t byte_size = WASM_ALIGN_UP_TO_PAGE($$.data_segment.size);
- uint32_t page_size = WASM_BYTES_TO_PAGES(byte_size);
+ wabt_destroy_text_list(parser->allocator, &$7);
+ uint32_t byte_size = WABT_ALIGN_UP_TO_PAGE($$.data_segment.size);
+ uint32_t page_size = WABT_BYTES_TO_PAGES(byte_size);
$$.memory.name = $3;
$$.memory.page_limits.initial = page_size;
$$.memory.page_limits.max = page_size;
- $$.memory.page_limits.has_max = WASM_TRUE;
+ $$.memory.page_limits.has_max = WABT_TRUE;
$$.export_ = $4;
}
/* Duplicate above for empty inline_export_opt to avoid LR(1) conflict. */
| LPAR MEMORY bind_var_opt LPAR DATA text_list RPAR RPAR {
- WasmExpr* expr = wasm_new_const_expr(parser->allocator);
+ WabtExpr* expr = wabt_new_const_expr(parser->allocator);
expr->loc = @2;
- expr->const_.type = WASM_TYPE_I32;
+ expr->const_.type = WABT_TYPE_I32;
expr->const_.u32 = 0;
- WASM_ZERO_MEMORY($$);
- $$.has_data_segment = WASM_TRUE;
+ WABT_ZERO_MEMORY($$);
+ $$.has_data_segment = WABT_TRUE;
$$.data_segment.offset = expr;
dup_text_list(parser->allocator, &$6, &$$.data_segment.data,
&$$.data_segment.size);
- wasm_destroy_text_list(parser->allocator, &$6);
- uint32_t byte_size = WASM_ALIGN_UP_TO_PAGE($$.data_segment.size);
- uint32_t page_size = WASM_BYTES_TO_PAGES(byte_size);
+ wabt_destroy_text_list(parser->allocator, &$6);
+ uint32_t byte_size = WABT_ALIGN_UP_TO_PAGE($$.data_segment.size);
+ uint32_t page_size = WABT_BYTES_TO_PAGES(byte_size);
$$.memory.name = $3;
$$.memory.page_limits.initial = page_size;
$$.memory.page_limits.max = page_size;
- $$.memory.page_limits.has_max = WASM_TRUE;
- $$.export_.has_export = WASM_FALSE;
+ $$.memory.page_limits.has_max = WABT_TRUE;
+ $$.export_.has_export = WABT_FALSE;
}
;
global :
LPAR GLOBAL bind_var_opt inline_export global_type const_expr RPAR {
- WASM_ZERO_MEMORY($$);
+ WABT_ZERO_MEMORY($$);
$$.global = $5;
$$.global.name = $3;
$$.global.init_expr = $6.first;
$$.export_ = $4;
}
| LPAR GLOBAL bind_var_opt global_type const_expr RPAR {
- WASM_ZERO_MEMORY($$);
+ WABT_ZERO_MEMORY($$);
$$.global = $4;
$$.global.name = $3;
$$.global.init_expr = $5.first;
- $$.export_.has_export = WASM_FALSE;
+ $$.export_.has_export = WABT_FALSE;
}
;
@@ -988,32 +988,32 @@ global :
import_kind :
LPAR FUNC bind_var_opt type_use RPAR {
$$ = new_import(parser->allocator);
- $$->kind = WASM_EXTERNAL_KIND_FUNC;
+ $$->kind = WABT_EXTERNAL_KIND_FUNC;
$$->func.name = $3;
- $$->func.decl.flags = WASM_FUNC_DECLARATION_FLAG_HAS_FUNC_TYPE;
+ $$->func.decl.flags = WABT_FUNC_DECLARATION_FLAG_HAS_FUNC_TYPE;
$$->func.decl.type_var = $4;
}
| LPAR FUNC bind_var_opt func_sig RPAR {
$$ = new_import(parser->allocator);
- $$->kind = WASM_EXTERNAL_KIND_FUNC;
+ $$->kind = WABT_EXTERNAL_KIND_FUNC;
$$->func.name = $3;
$$->func.decl.sig = $4;
}
| LPAR TABLE bind_var_opt table_sig RPAR {
$$ = new_import(parser->allocator);
- $$->kind = WASM_EXTERNAL_KIND_TABLE;
+ $$->kind = WABT_EXTERNAL_KIND_TABLE;
$$->table = $4;
$$->table.name = $3;
}
| LPAR MEMORY bind_var_opt memory_sig RPAR {
$$ = new_import(parser->allocator);
- $$->kind = WASM_EXTERNAL_KIND_MEMORY;
+ $$->kind = WABT_EXTERNAL_KIND_MEMORY;
$$->memory = $4;
$$->memory.name = $3;
}
| LPAR GLOBAL bind_var_opt global_type RPAR {
$$ = new_import(parser->allocator);
- $$->kind = WASM_EXTERNAL_KIND_GLOBAL;
+ $$->kind = WABT_EXTERNAL_KIND_GLOBAL;
$$->global = $4;
$$->global.name = $3;
}
@@ -1026,32 +1026,32 @@ import :
}
| LPAR FUNC bind_var_opt inline_import type_use RPAR {
$$ = $4;
- $$->kind = WASM_EXTERNAL_KIND_FUNC;
+ $$->kind = WABT_EXTERNAL_KIND_FUNC;
$$->func.name = $3;
- $$->func.decl.flags = WASM_FUNC_DECLARATION_FLAG_HAS_FUNC_TYPE;
+ $$->func.decl.flags = WABT_FUNC_DECLARATION_FLAG_HAS_FUNC_TYPE;
$$->func.decl.type_var = $5;
}
| LPAR FUNC bind_var_opt inline_import func_sig RPAR {
$$ = $4;
- $$->kind = WASM_EXTERNAL_KIND_FUNC;
+ $$->kind = WABT_EXTERNAL_KIND_FUNC;
$$->func.name = $3;
$$->func.decl.sig = $5;
}
| LPAR TABLE bind_var_opt inline_import table_sig RPAR {
$$ = $4;
- $$->kind = WASM_EXTERNAL_KIND_TABLE;
+ $$->kind = WABT_EXTERNAL_KIND_TABLE;
$$->table = $5;
$$->table.name = $3;
}
| LPAR MEMORY bind_var_opt inline_import memory_sig RPAR {
$$ = $4;
- $$->kind = WASM_EXTERNAL_KIND_MEMORY;
+ $$->kind = WABT_EXTERNAL_KIND_MEMORY;
$$->memory = $5;
$$->memory.name = $3;
}
| LPAR GLOBAL bind_var_opt inline_import global_type RPAR {
$$ = $4;
- $$->kind = WASM_EXTERNAL_KIND_GLOBAL;
+ $$->kind = WABT_EXTERNAL_KIND_GLOBAL;
$$->global = $5;
$$->global.name = $3;
}
@@ -1067,23 +1067,23 @@ inline_import :
export_kind :
LPAR FUNC var RPAR {
- WASM_ZERO_MEMORY($$);
- $$.kind = WASM_EXTERNAL_KIND_FUNC;
+ WABT_ZERO_MEMORY($$);
+ $$.kind = WABT_EXTERNAL_KIND_FUNC;
$$.var = $3;
}
| LPAR TABLE var RPAR {
- WASM_ZERO_MEMORY($$);
- $$.kind = WASM_EXTERNAL_KIND_TABLE;
+ WABT_ZERO_MEMORY($$);
+ $$.kind = WABT_EXTERNAL_KIND_TABLE;
$$.var = $3;
}
| LPAR MEMORY var RPAR {
- WASM_ZERO_MEMORY($$);
- $$.kind = WASM_EXTERNAL_KIND_MEMORY;
+ WABT_ZERO_MEMORY($$);
+ $$.kind = WABT_EXTERNAL_KIND_MEMORY;
$$.var = $3;
}
| LPAR GLOBAL var RPAR {
- WASM_ZERO_MEMORY($$);
- $$.kind = WASM_EXTERNAL_KIND_GLOBAL;
+ WABT_ZERO_MEMORY($$);
+ $$.kind = WABT_EXTERNAL_KIND_GLOBAL;
$$.var = $3;
}
;
@@ -1096,15 +1096,15 @@ export :
inline_export_opt :
/* empty */ {
- WASM_ZERO_MEMORY($$);
- $$.has_export = WASM_FALSE;
+ WABT_ZERO_MEMORY($$);
+ $$.has_export = WABT_FALSE;
}
| inline_export
;
inline_export :
LPAR EXPORT quoted_text RPAR {
- WASM_ZERO_MEMORY($$);
- $$.has_export = WASM_TRUE;
+ WABT_ZERO_MEMORY($$);
+ $$.has_export = WABT_TRUE;
$$.export_.name = $3;
}
;
@@ -1114,7 +1114,7 @@ inline_export :
type_def :
LPAR TYPE func_type RPAR {
- WASM_ZERO_MEMORY($$);
+ WABT_ZERO_MEMORY($$);
$$.sig = $3;
}
| LPAR TYPE bind_var func_type RPAR {
@@ -1133,7 +1133,7 @@ module_fields :
}
| module_fields type_def {
$$ = $1;
- WasmModuleField* field;
+ WabtModuleField* field;
APPEND_FIELD_TO_LIST($$, field, FUNC_TYPE, func_type, @2, $2);
APPEND_ITEM_TO_VECTOR($$, FuncType, func_type, func_types,
&field->func_type);
@@ -1141,7 +1141,7 @@ module_fields :
}
| module_fields global {
$$ = $1;
- WasmModuleField* field;
+ WabtModuleField* field;
APPEND_FIELD_TO_LIST($$, field, GLOBAL, global, @2, $2.global);
APPEND_ITEM_TO_VECTOR($$, Global, global, globals, &field->global);
INSERT_BINDING($$, global, globals, @2, $2.global.name);
@@ -1149,14 +1149,14 @@ module_fields :
}
| module_fields table {
$$ = $1;
- WasmModuleField* field;
+ WabtModuleField* field;
APPEND_FIELD_TO_LIST($$, field, TABLE, table, @2, $2.table);
APPEND_ITEM_TO_VECTOR($$, Table, table, tables, &field->table);
INSERT_BINDING($$, table, tables, @2, $2.table.name);
APPEND_INLINE_EXPORT($$, TABLE, @2, $2, $$->tables.size - 1);
if ($2.has_elem_segment) {
- WasmModuleField* elem_segment_field;
+ WabtModuleField* elem_segment_field;
APPEND_FIELD_TO_LIST($$, elem_segment_field, ELEM_SEGMENT, elem_segment,
@2, $2.elem_segment);
APPEND_ITEM_TO_VECTOR($$, ElemSegment, elem_segment, elem_segments,
@@ -1166,14 +1166,14 @@ module_fields :
}
| module_fields memory {
$$ = $1;
- WasmModuleField* field;
+ WabtModuleField* field;
APPEND_FIELD_TO_LIST($$, field, MEMORY, memory, @2, $2.memory);
APPEND_ITEM_TO_VECTOR($$, Memory, memory, memories, &field->memory);
INSERT_BINDING($$, memory, memories, @2, $2.memory.name);
APPEND_INLINE_EXPORT($$, MEMORY, @2, $2, $$->memories.size - 1);
if ($2.has_data_segment) {
- WasmModuleField* data_segment_field;
+ WabtModuleField* data_segment_field;
APPEND_FIELD_TO_LIST($$, data_segment_field, DATA_SEGMENT, data_segment,
@2, $2.data_segment);
APPEND_ITEM_TO_VECTOR($$, DataSegment, data_segment, data_segments,
@@ -1182,78 +1182,78 @@ module_fields :
}
| module_fields func {
$$ = $1;
- WasmModuleField* field;
+ WabtModuleField* field;
APPEND_FIELD_TO_LIST($$, field, FUNC, func, @2, *$2.func);
append_implicit_func_declaration(parser->allocator, &@2, $$,
&field->func.decl);
APPEND_ITEM_TO_VECTOR($$, Func, func, funcs, &field->func);
INSERT_BINDING($$, func, funcs, @2, $2.func->name);
APPEND_INLINE_EXPORT($$, FUNC, @2, $2, $$->funcs.size - 1);
- wasm_free(parser->allocator, $2.func);
+ wabt_free(parser->allocator, $2.func);
}
| module_fields elem {
$$ = $1;
- WasmModuleField* field;
+ WabtModuleField* field;
APPEND_FIELD_TO_LIST($$, field, ELEM_SEGMENT, elem_segment, @2, $2);
APPEND_ITEM_TO_VECTOR($$, ElemSegment, elem_segment, elem_segments,
&field->elem_segment);
}
| module_fields data {
$$ = $1;
- WasmModuleField* field;
+ WabtModuleField* field;
APPEND_FIELD_TO_LIST($$, field, DATA_SEGMENT, data_segment, @2, $2);
APPEND_ITEM_TO_VECTOR($$, DataSegment, data_segment, data_segments,
&field->data_segment);
}
| module_fields start {
$$ = $1;
- WasmModuleField* field;
+ WabtModuleField* field;
APPEND_FIELD_TO_LIST($$, field, START, start, @2, $2);
$$->start = &field->start;
}
| module_fields import {
$$ = $1;
- WasmModuleField* field;
+ WabtModuleField* field;
APPEND_FIELD_TO_LIST($$, field, IMPORT, import, @2, *$2);
CHECK_IMPORT_ORDERING($$, func, funcs, @2);
CHECK_IMPORT_ORDERING($$, table, tables, @2);
CHECK_IMPORT_ORDERING($$, memory, memories, @2);
CHECK_IMPORT_ORDERING($$, global, globals, @2);
switch ($2->kind) {
- case WASM_EXTERNAL_KIND_FUNC:
+ case WABT_EXTERNAL_KIND_FUNC:
append_implicit_func_declaration(parser->allocator, &@2, $$,
&field->import.func.decl);
APPEND_ITEM_TO_VECTOR($$, Func, func, funcs, &field->import.func);
INSERT_BINDING($$, func, funcs, @2, field->import.func.name);
$$->num_func_imports++;
break;
- case WASM_EXTERNAL_KIND_TABLE:
+ case WABT_EXTERNAL_KIND_TABLE:
APPEND_ITEM_TO_VECTOR($$, Table, table, tables, &field->import.table);
INSERT_BINDING($$, table, tables, @2, field->import.table.name);
$$->num_table_imports++;
break;
- case WASM_EXTERNAL_KIND_MEMORY:
+ case WABT_EXTERNAL_KIND_MEMORY:
APPEND_ITEM_TO_VECTOR($$, Memory, memory, memories,
&field->import.memory);
INSERT_BINDING($$, memory, memories, @2, field->import.memory.name);
$$->num_memory_imports++;
break;
- case WASM_EXTERNAL_KIND_GLOBAL:
+ case WABT_EXTERNAL_KIND_GLOBAL:
APPEND_ITEM_TO_VECTOR($$, Global, global, globals,
&field->import.global);
INSERT_BINDING($$, global, globals, @2, field->import.global.name);
$$->num_global_imports++;
break;
- case WASM_NUM_EXTERNAL_KINDS:
+ case WABT_NUM_EXTERNAL_KINDS:
assert(0);
break;
}
- wasm_free(parser->allocator, $2);
+ wabt_free(parser->allocator, $2);
APPEND_ITEM_TO_VECTOR($$, Import, import, imports, &field->import);
}
| module_fields export {
$$ = $1;
- WasmModuleField* field = wasm_append_module_field(parser->allocator, $$);
+ WabtModuleField* field = wabt_append_module_field(parser->allocator, $$);
APPEND_FIELD_TO_LIST($$, field, EXPORT, export_, @2, $2);
APPEND_ITEM_TO_VECTOR($$, Export, export, exports, &field->export_);
INSERT_BINDING($$, export, exports, @2, $2.name);
@@ -1262,7 +1262,7 @@ module_fields :
raw_module :
LPAR MODULE bind_var_opt module_fields RPAR {
- $$.type = WASM_RAW_MODULE_TYPE_TEXT;
+ $$.type = WABT_RAW_MODULE_TYPE_TEXT;
$$.text = $4;
$$.text->name = $3;
$$.text->loc = @2;
@@ -1271,45 +1271,45 @@ raw_module :
* explicitly */
size_t i;
for (i = 0; i < $4->funcs.size; ++i) {
- WasmFunc* func = $4->funcs.data[i];
- if (wasm_decl_has_func_type(&func->decl) &&
+ WabtFunc* func = $4->funcs.data[i];
+ if (wabt_decl_has_func_type(&func->decl) &&
is_empty_signature(&func->decl.sig)) {
- WasmFuncType* func_type =
- wasm_get_func_type_by_var($4, &func->decl.type_var);
+ WabtFuncType* func_type =
+ wabt_get_func_type_by_var($4, &func->decl.type_var);
if (func_type) {
func->decl.sig = func_type->sig;
- func->decl.flags |= WASM_FUNC_DECLARATION_FLAG_SHARED_SIGNATURE;
+ func->decl.flags |= WABT_FUNC_DECLARATION_FLAG_SHARED_SIGNATURE;
}
}
}
}
| LPAR MODULE bind_var_opt non_empty_text_list RPAR {
- $$.type = WASM_RAW_MODULE_TYPE_BINARY;
+ $$.type = WABT_RAW_MODULE_TYPE_BINARY;
$$.binary.name = $3;
$$.binary.loc = @2;
dup_text_list(parser->allocator, &$4, &$$.binary.data, &$$.binary.size);
- wasm_destroy_text_list(parser->allocator, &$4);
+ wabt_destroy_text_list(parser->allocator, &$4);
}
;
module :
raw_module {
- if ($1.type == WASM_RAW_MODULE_TYPE_TEXT) {
+ if ($1.type == WABT_RAW_MODULE_TYPE_TEXT) {
$$ = $1.text;
} else {
- assert($1.type == WASM_RAW_MODULE_TYPE_BINARY);
+ assert($1.type == WABT_RAW_MODULE_TYPE_BINARY);
$$ = new_module(parser->allocator);
- WasmReadBinaryOptions options = WASM_READ_BINARY_OPTIONS_DEFAULT;
+ WabtReadBinaryOptions options = WABT_READ_BINARY_OPTIONS_DEFAULT;
BinaryErrorCallbackData user_data;
user_data.loc = &$1.binary.loc;
user_data.lexer = lexer;
user_data.parser = parser;
- WasmBinaryErrorHandler error_handler;
+ WabtBinaryErrorHandler error_handler;
error_handler.on_error = on_read_binary_error;
error_handler.user_data = &user_data;
- wasm_read_binary_ast(parser->allocator, $1.binary.data, $1.binary.size,
+ wabt_read_binary_ast(parser->allocator, $1.binary.data, $1.binary.size,
&options, &error_handler, $$);
- wasm_free(parser->allocator, $1.binary.data);
+ wabt_free(parser->allocator, $1.binary.data);
$$->name = $1.binary.name;
$$->loc = $1.binary.loc;
}
@@ -1320,31 +1320,31 @@ module :
script_var_opt :
/* empty */ {
- WASM_ZERO_MEMORY($$);
- $$.type = WASM_VAR_TYPE_INDEX;
+ WABT_ZERO_MEMORY($$);
+ $$.type = WABT_VAR_TYPE_INDEX;
$$.index = INVALID_VAR_INDEX;
}
| VAR {
- WASM_ZERO_MEMORY($$);
- $$.type = WASM_VAR_TYPE_NAME;
+ WABT_ZERO_MEMORY($$);
+ $$.type = WABT_VAR_TYPE_NAME;
DUPTEXT($$.name, $1);
}
;
action :
LPAR INVOKE script_var_opt quoted_text const_list RPAR {
- WASM_ZERO_MEMORY($$);
+ WABT_ZERO_MEMORY($$);
$$.loc = @2;
$$.module_var = $3;
- $$.type = WASM_ACTION_TYPE_INVOKE;
+ $$.type = WABT_ACTION_TYPE_INVOKE;
$$.invoke.name = $4;
$$.invoke.args = $5;
}
| LPAR GET script_var_opt quoted_text RPAR {
- WASM_ZERO_MEMORY($$);
+ WABT_ZERO_MEMORY($$);
$$.loc = @2;
$$.module_var = $3;
- $$.type = WASM_ACTION_TYPE_GET;
+ $$.type = WABT_ACTION_TYPE_GET;
$$.invoke.name = $4;
}
;
@@ -1352,48 +1352,48 @@ action :
assertion :
LPAR ASSERT_MALFORMED raw_module quoted_text RPAR {
$$ = new_command(parser->allocator);
- $$->type = WASM_COMMAND_TYPE_ASSERT_MALFORMED;
+ $$->type = WABT_COMMAND_TYPE_ASSERT_MALFORMED;
$$->assert_malformed.module = $3;
$$->assert_malformed.text = $4;
}
| LPAR ASSERT_INVALID raw_module quoted_text RPAR {
$$ = new_command(parser->allocator);
- $$->type = WASM_COMMAND_TYPE_ASSERT_INVALID;
+ $$->type = WABT_COMMAND_TYPE_ASSERT_INVALID;
$$->assert_invalid.module = $3;
$$->assert_invalid.text = $4;
}
| LPAR ASSERT_UNLINKABLE raw_module quoted_text RPAR {
$$ = new_command(parser->allocator);
- $$->type = WASM_COMMAND_TYPE_ASSERT_UNLINKABLE;
+ $$->type = WABT_COMMAND_TYPE_ASSERT_UNLINKABLE;
$$->assert_unlinkable.module = $3;
$$->assert_unlinkable.text = $4;
}
| LPAR ASSERT_TRAP raw_module quoted_text RPAR {
$$ = new_command(parser->allocator);
- $$->type = WASM_COMMAND_TYPE_ASSERT_UNINSTANTIABLE;
+ $$->type = WABT_COMMAND_TYPE_ASSERT_UNINSTANTIABLE;
$$->assert_uninstantiable.module = $3;
$$->assert_uninstantiable.text = $4;
}
| LPAR ASSERT_RETURN action const_list RPAR {
$$ = new_command(parser->allocator);
- $$->type = WASM_COMMAND_TYPE_ASSERT_RETURN;
+ $$->type = WABT_COMMAND_TYPE_ASSERT_RETURN;
$$->assert_return.action = $3;
$$->assert_return.expected = $4;
}
| LPAR ASSERT_RETURN_NAN action RPAR {
$$ = new_command(parser->allocator);
- $$->type = WASM_COMMAND_TYPE_ASSERT_RETURN_NAN;
+ $$->type = WABT_COMMAND_TYPE_ASSERT_RETURN_NAN;
$$->assert_return_nan.action = $3;
}
| LPAR ASSERT_TRAP action quoted_text RPAR {
$$ = new_command(parser->allocator);
- $$->type = WASM_COMMAND_TYPE_ASSERT_TRAP;
+ $$->type = WABT_COMMAND_TYPE_ASSERT_TRAP;
$$->assert_trap.action = $3;
$$->assert_trap.text = $4;
}
| LPAR ASSERT_EXHAUSTION action quoted_text RPAR {
$$ = new_command(parser->allocator);
- $$->type = WASM_COMMAND_TYPE_ASSERT_EXHAUSTION;
+ $$->type = WABT_COMMAND_TYPE_ASSERT_EXHAUSTION;
$$->assert_trap.action = $3;
$$->assert_trap.text = $4;
}
@@ -1402,103 +1402,103 @@ assertion :
cmd :
action {
$$ = new_command(parser->allocator);
- $$->type = WASM_COMMAND_TYPE_ACTION;
+ $$->type = WABT_COMMAND_TYPE_ACTION;
$$->action = $1;
}
| assertion
| module {
$$ = new_command(parser->allocator);
- $$->type = WASM_COMMAND_TYPE_MODULE;
+ $$->type = WABT_COMMAND_TYPE_MODULE;
$$->module = *$1;
- wasm_free(parser->allocator, $1);
+ wabt_free(parser->allocator, $1);
}
| LPAR REGISTER quoted_text script_var_opt RPAR {
$$ = new_command(parser->allocator);
- $$->type = WASM_COMMAND_TYPE_REGISTER;
+ $$->type = WABT_COMMAND_TYPE_REGISTER;
$$->register_.module_name = $3;
$$->register_.var = $4;
$$->register_.var.loc = @4;
}
;
cmd_list :
- /* empty */ { WASM_ZERO_MEMORY($$); }
+ /* empty */ { WABT_ZERO_MEMORY($$); }
| cmd_list cmd {
$$ = $1;
- wasm_append_command_value(parser->allocator, &$$, $2);
- wasm_free(parser->allocator, $2);
+ wabt_append_command_value(parser->allocator, &$$, $2);
+ wabt_free(parser->allocator, $2);
}
;
const :
LPAR CONST literal RPAR {
$$.loc = @2;
- if (WASM_FAILED(parse_const($2, $3.type, $3.text.start,
+ if (WABT_FAILED(parse_const($2, $3.type, $3.text.start,
$3.text.start + $3.text.length, &$$))) {
- wasm_ast_parser_error(&@3, lexer, parser,
+ wabt_ast_parser_error(&@3, lexer, parser,
"invalid literal \"" PRIstringslice "\"",
- WASM_PRINTF_STRING_SLICE_ARG($3.text));
+ WABT_PRINTF_STRING_SLICE_ARG($3.text));
}
- wasm_free(parser->allocator, (char*)$3.text.start);
+ wabt_free(parser->allocator, (char*)$3.text.start);
}
;
const_list :
- /* empty */ { WASM_ZERO_MEMORY($$); }
+ /* empty */ { WABT_ZERO_MEMORY($$); }
| const_list const {
$$ = $1;
- wasm_append_const_value(parser->allocator, &$$, &$2);
+ wabt_append_const_value(parser->allocator, &$$, &$2);
}
;
script :
cmd_list {
- WASM_ZERO_MEMORY($$);
+ WABT_ZERO_MEMORY($$);
$$.allocator = parser->allocator;
$$.commands = $1;
int last_module_index = -1;
size_t i;
for (i = 0; i < $$.commands.size; ++i) {
- WasmCommand* command = &$$.commands.data[i];
- WasmVar* module_var = NULL;
+ WabtCommand* command = &$$.commands.data[i];
+ WabtVar* module_var = NULL;
switch (command->type) {
- case WASM_COMMAND_TYPE_MODULE: {
+ case WABT_COMMAND_TYPE_MODULE: {
last_module_index = i;
/* Wire up module name bindings. */
- WasmModule* module = &command->module;
+ WabtModule* module = &command->module;
if (module->name.length == 0)
continue;
- WasmStringSlice module_name =
- wasm_dup_string_slice(parser->allocator, module->name);
- WasmBinding* binding = wasm_insert_binding(
+ WabtStringSlice module_name =
+ wabt_dup_string_slice(parser->allocator, module->name);
+ WabtBinding* binding = wabt_insert_binding(
parser->allocator, &$$.module_bindings, &module_name);
binding->loc = module->loc;
binding->index = i;
break;
}
- case WASM_COMMAND_TYPE_ASSERT_RETURN:
+ case WABT_COMMAND_TYPE_ASSERT_RETURN:
module_var = &command->assert_return.action.module_var;
goto has_module_var;
- case WASM_COMMAND_TYPE_ASSERT_RETURN_NAN:
+ case WABT_COMMAND_TYPE_ASSERT_RETURN_NAN:
module_var = &command->assert_return_nan.action.module_var;
goto has_module_var;
- case WASM_COMMAND_TYPE_ASSERT_TRAP:
- case WASM_COMMAND_TYPE_ASSERT_EXHAUSTION:
+ case WABT_COMMAND_TYPE_ASSERT_TRAP:
+ case WABT_COMMAND_TYPE_ASSERT_EXHAUSTION:
module_var = &command->assert_trap.action.module_var;
goto has_module_var;
- case WASM_COMMAND_TYPE_ACTION:
+ case WABT_COMMAND_TYPE_ACTION:
module_var = &command->action.module_var;
goto has_module_var;
- case WASM_COMMAND_TYPE_REGISTER:
+ case WABT_COMMAND_TYPE_REGISTER:
module_var = &command->register_.var;
goto has_module_var;
has_module_var: {
/* Resolve actions with an invalid index to use the preceding
* module. */
- if (module_var->type == WASM_VAR_TYPE_INDEX &&
+ if (module_var->type == WABT_VAR_TYPE_INDEX &&
module_var->index == INVALID_VAR_INDEX) {
module_var->index = last_module_index;
}
@@ -1521,7 +1521,7 @@ script_start :
%%
-static void append_expr_list(WasmExprList* expr_list, WasmExprList* expr) {
+static void append_expr_list(WabtExprList* expr_list, WabtExprList* expr) {
if (!expr->first)
return;
if (expr_list->last)
@@ -1532,7 +1532,7 @@ static void append_expr_list(WasmExprList* expr_list, WasmExprList* expr) {
expr_list->size += expr->size;
}
-static void append_expr(WasmExprList* expr_list, WasmExpr* expr) {
+static void append_expr(WabtExprList* expr_list, WabtExpr* expr) {
if (expr_list->last)
expr_list->last->next = expr;
else
@@ -1541,49 +1541,49 @@ static void append_expr(WasmExprList* expr_list, WasmExpr* expr) {
expr_list->size++;
}
-static WasmExprList join_exprs1(WasmLocation* loc, WasmExpr* expr1) {
- WasmExprList result;
- WASM_ZERO_MEMORY(result);
+static WabtExprList join_exprs1(WabtLocation* loc, WabtExpr* expr1) {
+ WabtExprList result;
+ WABT_ZERO_MEMORY(result);
append_expr(&result, expr1);
expr1->loc = *loc;
return result;
}
-static WasmExprList join_exprs2(WasmLocation* loc, WasmExprList* expr1,
- WasmExpr* expr2) {
- WasmExprList result;
- WASM_ZERO_MEMORY(result);
+static WabtExprList join_exprs2(WabtLocation* loc, WabtExprList* expr1,
+ WabtExpr* expr2) {
+ WabtExprList result;
+ WABT_ZERO_MEMORY(result);
append_expr_list(&result, expr1);
append_expr(&result, expr2);
expr2->loc = *loc;
return result;
}
-static WasmResult parse_const(WasmType type,
- WasmLiteralType literal_type,
+static WabtResult parse_const(WabtType type,
+ WabtLiteralType literal_type,
const char* s,
const char* end,
- WasmConst* out) {
+ WabtConst* out) {
out->type = type;
switch (type) {
- case WASM_TYPE_I32:
- return wasm_parse_int32(s, end, &out->u32,
- WASM_PARSE_SIGNED_AND_UNSIGNED);
- case WASM_TYPE_I64:
- return wasm_parse_int64(s, end, &out->u64,
- WASM_PARSE_SIGNED_AND_UNSIGNED);
- case WASM_TYPE_F32:
- return wasm_parse_float(literal_type, s, end, &out->f32_bits);
- case WASM_TYPE_F64:
- return wasm_parse_double(literal_type, s, end, &out->f64_bits);
+ case WABT_TYPE_I32:
+ return wabt_parse_int32(s, end, &out->u32,
+ WABT_PARSE_SIGNED_AND_UNSIGNED);
+ case WABT_TYPE_I64:
+ return wabt_parse_int64(s, end, &out->u64,
+ WABT_PARSE_SIGNED_AND_UNSIGNED);
+ case WABT_TYPE_F32:
+ return wabt_parse_float(literal_type, s, end, &out->f32_bits);
+ case WABT_TYPE_F64:
+ return wabt_parse_double(literal_type, s, end, &out->f64_bits);
default:
assert(0);
break;
}
- return WASM_ERROR;
+ return WABT_ERROR;
}
-static size_t copy_string_contents(WasmStringSlice* text, char* dest) {
+static size_t copy_string_contents(WabtStringSlice* text, char* dest) {
const char* src = text->start + 1;
const char* end = text->start + text->length - 1;
@@ -1613,8 +1613,8 @@ static size_t copy_string_contents(WasmStringSlice* text, char* dest) {
* sequence */
uint32_t hi;
uint32_t lo;
- if (WASM_SUCCEEDED(wasm_parse_hexdigit(src[0], &hi)) &&
- WASM_SUCCEEDED(wasm_parse_hexdigit(src[1], &lo))) {
+ if (WABT_SUCCEEDED(wabt_parse_hexdigit(src[0], &hi)) &&
+ WABT_SUCCEEDED(wabt_parse_hexdigit(src[1], &lo))) {
*dest++ = (hi << 4) | lo;
} else {
assert(0);
@@ -1632,13 +1632,13 @@ static size_t copy_string_contents(WasmStringSlice* text, char* dest) {
return dest - dest_start;
}
-static void dup_text_list(WasmAllocator* allocator,
- WasmTextList* text_list,
+static void dup_text_list(WabtAllocator* allocator,
+ WabtTextList* text_list,
void** out_data,
size_t* out_size) {
/* walk the linked list to see how much total space is needed */
size_t total_size = 0;
- WasmTextListNode* node;
+ WabtTextListNode* node;
for (node = text_list->first; node; node = node->next) {
/* Always allocate enough space for the entire string including the escape
* characters. It will only get shorter, and this way we only have to
@@ -1648,7 +1648,7 @@ static void dup_text_list(WasmAllocator* allocator,
size_t size = (end > src) ? (end - src) : 0;
total_size += size;
}
- char* result = wasm_alloc(allocator, total_size, 1);
+ char* result = wabt_alloc(allocator, total_size, 1);
char* dest = result;
for (node = text_list->first; node; node = node->next) {
size_t actual_size = copy_string_contents(&node->text, dest);
@@ -1658,56 +1658,56 @@ static void dup_text_list(WasmAllocator* allocator,
*out_size = dest - result;
}
-static WasmBool is_empty_signature(WasmFuncSignature* sig) {
+static WabtBool is_empty_signature(WabtFuncSignature* sig) {
return sig->result_types.size == 0 && sig->param_types.size == 0;
}
-static void append_implicit_func_declaration(WasmAllocator* allocator,
- WasmLocation* loc,
- WasmModule* module,
- WasmFuncDeclaration* decl) {
- if (wasm_decl_has_func_type(decl))
+static void append_implicit_func_declaration(WabtAllocator* allocator,
+ WabtLocation* loc,
+ WabtModule* module,
+ WabtFuncDeclaration* decl) {
+ if (wabt_decl_has_func_type(decl))
return;
- int sig_index = wasm_get_func_type_index_by_decl(module, decl);
+ int sig_index = wabt_get_func_type_index_by_decl(module, decl);
if (sig_index == -1) {
- wasm_append_implicit_func_type(allocator, loc, module, &decl->sig);
+ wabt_append_implicit_func_type(allocator, loc, module, &decl->sig);
} else {
/* signature already exists, share that one and destroy this one */
- wasm_destroy_func_signature(allocator, &decl->sig);
- WasmFuncSignature* sig = &module->func_types.data[sig_index]->sig;
+ wabt_destroy_func_signature(allocator, &decl->sig);
+ WabtFuncSignature* sig = &module->func_types.data[sig_index]->sig;
decl->sig = *sig;
}
- decl->flags |= WASM_FUNC_DECLARATION_FLAG_SHARED_SIGNATURE;
+ decl->flags |= WABT_FUNC_DECLARATION_FLAG_SHARED_SIGNATURE;
}
-WasmResult wasm_parse_ast(WasmAstLexer* lexer,
- struct WasmScript* out_script,
- WasmSourceErrorHandler* error_handler) {
- WasmAstParser parser;
- WASM_ZERO_MEMORY(parser);
- WasmAllocator* allocator = wasm_ast_lexer_get_allocator(lexer);
+WabtResult wabt_parse_ast(WabtAstLexer* lexer,
+ struct WabtScript* out_script,
+ WabtSourceErrorHandler* error_handler) {
+ WabtAstParser parser;
+ WABT_ZERO_MEMORY(parser);
+ WabtAllocator* allocator = wabt_ast_lexer_get_allocator(lexer);
parser.allocator = allocator;
parser.script.allocator = allocator;
parser.error_handler = error_handler;
- int result = wasm_ast_parser_parse(lexer, &parser);
+ int result = wabt_ast_parser_parse(lexer, &parser);
*out_script = parser.script;
- return result == 0 && parser.errors == 0 ? WASM_OK : WASM_ERROR;
+ return result == 0 && parser.errors == 0 ? WABT_OK : WABT_ERROR;
}
static void on_read_binary_error(uint32_t offset, const char* error,
void* user_data) {
BinaryErrorCallbackData* data = user_data;
- if (offset == WASM_UNKNOWN_OFFSET) {
- wasm_ast_parser_error(data->loc, data->lexer, data->parser,
+ if (offset == WABT_UNKNOWN_OFFSET) {
+ wabt_ast_parser_error(data->loc, data->lexer, data->parser,
"error in binary module: %s", error);
} else {
- wasm_ast_parser_error(data->loc, data->lexer, data->parser,
+ wabt_ast_parser_error(data->loc, data->lexer, data->parser,
"error in binary module: @0x%08x: %s", offset, error);
}
}
/* see comment above definition of YYMAXDEPTH at the top of this file */
-WASM_STATIC_ASSERT(YYSTACK_ALLOC_MAXIMUM >= UINT32_MAX);
-WASM_STATIC_ASSERT(YYSTACK_BYTES((uint64_t)YYMAXDEPTH) <= UINT32_MAX);
+WABT_STATIC_ASSERT(YYSTACK_ALLOC_MAXIMUM >= UINT32_MAX);
+WABT_STATIC_ASSERT(YYSTACK_BYTES((uint64_t)YYMAXDEPTH) <= UINT32_MAX);
diff --git a/src/ast-writer.c b/src/ast-writer.c
index 220eb532..c50ce640 100644
--- a/src/ast-writer.c
+++ b/src/ast-writer.c
@@ -55,13 +55,13 @@ typedef enum NextChar {
} NextChar;
typedef struct Context {
- WasmAllocator* allocator;
- WasmStream stream;
- WasmResult result;
+ WabtAllocator* allocator;
+ WabtStream stream;
+ WabtResult result;
int indent;
NextChar next_char;
int depth;
- WasmStringSliceVector index_to_name;
+ WabtStringSliceVector index_to_name;
int func_index;
int global_index;
@@ -87,22 +87,22 @@ static void write_indent(Context* ctx) {
static size_t s_indent_len = sizeof(s_indent) - 1;
size_t indent = ctx->indent;
while (indent > s_indent_len) {
- wasm_write_data(&ctx->stream, s_indent, s_indent_len, NULL);
+ wabt_write_data(&ctx->stream, s_indent, s_indent_len, NULL);
indent -= s_indent_len;
}
if (indent > 0) {
- wasm_write_data(&ctx->stream, s_indent, indent, NULL);
+ wabt_write_data(&ctx->stream, s_indent, indent, NULL);
}
}
static void write_next_char(Context* ctx) {
switch (ctx->next_char) {
case NEXT_CHAR_SPACE:
- wasm_write_data(&ctx->stream, " ", 1, NULL);
+ wabt_write_data(&ctx->stream, " ", 1, NULL);
break;
case NEXT_CHAR_NEWLINE:
case NEXT_CHAR_FORCE_NEWLINE:
- wasm_write_data(&ctx->stream, "\n", 1, NULL);
+ wabt_write_data(&ctx->stream, "\n", 1, NULL);
write_indent(ctx);
break;
@@ -117,19 +117,19 @@ static void write_data_with_next_char(Context* ctx,
const void* src,
size_t size) {
write_next_char(ctx);
- wasm_write_data(&ctx->stream, src, size, NULL);
+ wabt_write_data(&ctx->stream, src, size, NULL);
}
-static void WASM_PRINTF_FORMAT(2, 3)
+static void WABT_PRINTF_FORMAT(2, 3)
writef(Context* ctx, const char* format, ...) {
- WASM_SNPRINTF_ALLOCA(buffer, length, format);
+ WABT_SNPRINTF_ALLOCA(buffer, length, format);
/* default to following space */
write_data_with_next_char(ctx, buffer, length);
ctx->next_char = NEXT_CHAR_SPACE;
}
static void write_putc(Context* ctx, char c) {
- wasm_write_data(&ctx->stream, &c, 1, NULL);
+ wabt_write_data(&ctx->stream, &c, 1, NULL);
}
static void write_puts(Context* ctx, const char* s, NextChar next_char) {
@@ -146,7 +146,7 @@ static void write_puts_newline(Context* ctx, const char* s) {
write_puts(ctx, s, NEXT_CHAR_NEWLINE);
}
-static void write_newline(Context* ctx, WasmBool force) {
+static void write_newline(Context* ctx, WabtBool force) {
if (ctx->next_char == NEXT_CHAR_FORCE_NEWLINE)
write_next_char(ctx);
ctx->next_char = force ? NEXT_CHAR_FORCE_NEWLINE : NEXT_CHAR_NEWLINE;
@@ -182,22 +182,22 @@ static void write_close_space(Context* ctx) {
}
static void write_string_slice(Context* ctx,
- const WasmStringSlice* str,
+ const WabtStringSlice* str,
NextChar next_char) {
- writef(ctx, PRIstringslice, WASM_PRINTF_STRING_SLICE_ARG(*str));
+ writef(ctx, PRIstringslice, WABT_PRINTF_STRING_SLICE_ARG(*str));
ctx->next_char = next_char;
}
-static WasmBool write_string_slice_opt(Context* ctx,
- const WasmStringSlice* str,
+static WabtBool write_string_slice_opt(Context* ctx,
+ const WabtStringSlice* str,
NextChar next_char) {
if (str->start)
write_string_slice(ctx, str, next_char);
- return str->start ? WASM_TRUE : WASM_FALSE;
+ return str->start ? WABT_TRUE : WABT_FALSE;
}
static void write_string_slice_or_index(Context* ctx,
- const WasmStringSlice* str,
+ const WabtStringSlice* str,
uint32_t index,
NextChar next_char) {
if (str->start)
@@ -227,14 +227,14 @@ static void write_quoted_data(Context* ctx, const void* data, size_t length) {
}
static void write_quoted_string_slice(Context* ctx,
- const WasmStringSlice* str,
+ const WabtStringSlice* str,
NextChar next_char) {
write_quoted_data(ctx, str->start, str->length);
ctx->next_char = next_char;
}
-static void write_var(Context* ctx, const WasmVar* var, NextChar next_char) {
- if (var->type == WASM_VAR_TYPE_INDEX) {
+static void write_var(Context* ctx, const WabtVar* var, NextChar next_char) {
+ if (var->type == WABT_VAR_TYPE_INDEX) {
writef(ctx, "%" PRId64, var->index);
ctx->next_char = next_char;
} else {
@@ -242,8 +242,8 @@ static void write_var(Context* ctx, const WasmVar* var, NextChar next_char) {
}
}
-static void write_br_var(Context* ctx, const WasmVar* var, NextChar next_char) {
- if (var->type == WASM_VAR_TYPE_INDEX) {
+static void write_br_var(Context* ctx, const WabtVar* var, NextChar next_char) {
+ if (var->type == WABT_VAR_TYPE_INDEX) {
writef(ctx, "%" PRId64 " (;@%" PRId64 ";)", var->index,
ctx->depth - var->index - 1);
ctx->next_char = next_char;
@@ -252,14 +252,14 @@ static void write_br_var(Context* ctx, const WasmVar* var, NextChar next_char) {
}
}
-static void write_type(Context* ctx, WasmType type, NextChar next_char) {
- const char* type_name = wasm_get_type_name(type);
+static void write_type(Context* ctx, WabtType type, NextChar next_char) {
+ const char* type_name = wabt_get_type_name(type);
assert(type_name != NULL);
write_puts(ctx, type_name, next_char);
}
static void write_types(Context* ctx,
- const WasmTypeVector* types,
+ const WabtTypeVector* types,
const char* name) {
if (types->size) {
size_t i;
@@ -273,20 +273,20 @@ static void write_types(Context* ctx,
}
static void write_func_sig_space(Context* ctx,
- const WasmFuncSignature* func_sig) {
+ const WabtFuncSignature* func_sig) {
write_types(ctx, &func_sig->param_types, "param");
write_types(ctx, &func_sig->result_types, "result");
}
-static void write_expr_list(Context* ctx, const WasmExpr* first);
+static void write_expr_list(Context* ctx, const WabtExpr* first);
-static void write_expr(Context* ctx, const WasmExpr* expr);
+static void write_expr(Context* ctx, const WabtExpr* expr);
static void write_begin_block(Context* ctx,
- const WasmBlock* block,
+ const WabtBlock* block,
const char* text) {
write_puts_space(ctx, text);
- WasmBool has_label =
+ WabtBool has_label =
write_string_slice_opt(ctx, &block->label, NEXT_CHAR_SPACE);
write_types(ctx, &block->sig, NULL);
if (!has_label)
@@ -299,35 +299,35 @@ static void write_begin_block(Context* ctx,
static void write_end_block(Context* ctx) {
dedent(ctx);
ctx->depth--;
- write_puts_newline(ctx, wasm_get_opcode_name(WASM_OPCODE_END));
+ write_puts_newline(ctx, wabt_get_opcode_name(WABT_OPCODE_END));
}
static void write_block(Context* ctx,
- const WasmBlock* block,
+ const WabtBlock* block,
const char* start_text) {
write_begin_block(ctx, block, start_text);
write_expr_list(ctx, block->first);
write_end_block(ctx);
}
-static void write_const(Context* ctx, const WasmConst* const_) {
+static void write_const(Context* ctx, const WabtConst* const_) {
switch (const_->type) {
- case WASM_TYPE_I32:
- write_puts_space(ctx, wasm_get_opcode_name(WASM_OPCODE_I32_CONST));
+ case WABT_TYPE_I32:
+ write_puts_space(ctx, wabt_get_opcode_name(WABT_OPCODE_I32_CONST));
writef(ctx, "%d", (int32_t)const_->u32);
write_newline(ctx, NO_FORCE_NEWLINE);
break;
- case WASM_TYPE_I64:
- write_puts_space(ctx, wasm_get_opcode_name(WASM_OPCODE_I64_CONST));
+ case WABT_TYPE_I64:
+ write_puts_space(ctx, wabt_get_opcode_name(WABT_OPCODE_I64_CONST));
writef(ctx, "%" PRId64, (int64_t)const_->u64);
write_newline(ctx, NO_FORCE_NEWLINE);
break;
- case WASM_TYPE_F32: {
- write_puts_space(ctx, wasm_get_opcode_name(WASM_OPCODE_F32_CONST));
+ case WABT_TYPE_F32: {
+ write_puts_space(ctx, wabt_get_opcode_name(WABT_OPCODE_F32_CONST));
char buffer[128];
- wasm_write_float_hex(buffer, 128, const_->f32_bits);
+ wabt_write_float_hex(buffer, 128, const_->f32_bits);
write_puts_space(ctx, buffer);
float f32;
memcpy(&f32, &const_->f32_bits, sizeof(f32));
@@ -336,10 +336,10 @@ static void write_const(Context* ctx, const WasmConst* const_) {
break;
}
- case WASM_TYPE_F64: {
- write_puts_space(ctx, wasm_get_opcode_name(WASM_OPCODE_F64_CONST));
+ case WABT_TYPE_F64: {
+ write_puts_space(ctx, wabt_get_opcode_name(WABT_OPCODE_F64_CONST));
char buffer[128];
- wasm_write_double_hex(buffer, 128, const_->f64_bits);
+ wabt_write_double_hex(buffer, 128, const_->f64_bits);
write_puts_space(ctx, buffer);
double f64;
memcpy(&f64, &const_->f64_bits, sizeof(f64));
@@ -354,28 +354,28 @@ static void write_const(Context* ctx, const WasmConst* const_) {
}
}
-static void write_expr(Context* ctx, const WasmExpr* expr) {
+static void write_expr(Context* ctx, const WabtExpr* expr) {
switch (expr->type) {
- case WASM_EXPR_TYPE_BINARY:
- write_puts_newline(ctx, wasm_get_opcode_name(expr->binary.opcode));
+ case WABT_EXPR_TYPE_BINARY:
+ write_puts_newline(ctx, wabt_get_opcode_name(expr->binary.opcode));
break;
- case WASM_EXPR_TYPE_BLOCK:
- write_block(ctx, &expr->block, wasm_get_opcode_name(WASM_OPCODE_BLOCK));
+ case WABT_EXPR_TYPE_BLOCK:
+ write_block(ctx, &expr->block, wabt_get_opcode_name(WABT_OPCODE_BLOCK));
break;
- case WASM_EXPR_TYPE_BR:
- write_puts_space(ctx, wasm_get_opcode_name(WASM_OPCODE_BR));
+ case WABT_EXPR_TYPE_BR:
+ write_puts_space(ctx, wabt_get_opcode_name(WABT_OPCODE_BR));
write_br_var(ctx, &expr->br.var, NEXT_CHAR_NEWLINE);
break;
- case WASM_EXPR_TYPE_BR_IF:
- write_puts_space(ctx, wasm_get_opcode_name(WASM_OPCODE_BR_IF));
+ case WABT_EXPR_TYPE_BR_IF:
+ write_puts_space(ctx, wabt_get_opcode_name(WABT_OPCODE_BR_IF));
write_br_var(ctx, &expr->br_if.var, NEXT_CHAR_NEWLINE);
break;
- case WASM_EXPR_TYPE_BR_TABLE: {
- write_puts_space(ctx, wasm_get_opcode_name(WASM_OPCODE_BR_TABLE));
+ case WABT_EXPR_TYPE_BR_TABLE: {
+ write_puts_space(ctx, wabt_get_opcode_name(WABT_OPCODE_BR_TABLE));
size_t i;
for (i = 0; i < expr->br_table.targets.size; ++i)
write_br_var(ctx, &expr->br_table.targets.data[i], NEXT_CHAR_SPACE);
@@ -383,53 +383,53 @@ static void write_expr(Context* ctx, const WasmExpr* expr) {
break;
}
- case WASM_EXPR_TYPE_CALL:
- write_puts_space(ctx, wasm_get_opcode_name(WASM_OPCODE_CALL));
+ case WABT_EXPR_TYPE_CALL:
+ write_puts_space(ctx, wabt_get_opcode_name(WABT_OPCODE_CALL));
write_var(ctx, &expr->call.var, NEXT_CHAR_NEWLINE);
break;
- case WASM_EXPR_TYPE_CALL_INDIRECT:
- write_puts_space(ctx, wasm_get_opcode_name(WASM_OPCODE_CALL_INDIRECT));
+ case WABT_EXPR_TYPE_CALL_INDIRECT:
+ write_puts_space(ctx, wabt_get_opcode_name(WABT_OPCODE_CALL_INDIRECT));
write_var(ctx, &expr->call_indirect.var, NEXT_CHAR_NEWLINE);
break;
- case WASM_EXPR_TYPE_COMPARE:
- write_puts_newline(ctx, wasm_get_opcode_name(expr->compare.opcode));
+ case WABT_EXPR_TYPE_COMPARE:
+ write_puts_newline(ctx, wabt_get_opcode_name(expr->compare.opcode));
break;
- case WASM_EXPR_TYPE_CONST:
+ case WABT_EXPR_TYPE_CONST:
write_const(ctx, &expr->const_);
break;
- case WASM_EXPR_TYPE_CONVERT:
- write_puts_newline(ctx, wasm_get_opcode_name(expr->convert.opcode));
+ case WABT_EXPR_TYPE_CONVERT:
+ write_puts_newline(ctx, wabt_get_opcode_name(expr->convert.opcode));
break;
- case WASM_EXPR_TYPE_DROP:
- write_puts_newline(ctx, wasm_get_opcode_name(WASM_OPCODE_DROP));
+ case WABT_EXPR_TYPE_DROP:
+ write_puts_newline(ctx, wabt_get_opcode_name(WABT_OPCODE_DROP));
break;
- case WASM_EXPR_TYPE_GET_GLOBAL:
- write_puts_space(ctx, wasm_get_opcode_name(WASM_OPCODE_GET_GLOBAL));
+ case WABT_EXPR_TYPE_GET_GLOBAL:
+ write_puts_space(ctx, wabt_get_opcode_name(WABT_OPCODE_GET_GLOBAL));
write_var(ctx, &expr->get_global.var, NEXT_CHAR_NEWLINE);
break;
- case WASM_EXPR_TYPE_GET_LOCAL:
- write_puts_space(ctx, wasm_get_opcode_name(WASM_OPCODE_GET_LOCAL));
+ case WABT_EXPR_TYPE_GET_LOCAL:
+ write_puts_space(ctx, wabt_get_opcode_name(WABT_OPCODE_GET_LOCAL));
write_var(ctx, &expr->get_local.var, NEXT_CHAR_NEWLINE);
break;
- case WASM_EXPR_TYPE_GROW_MEMORY:
- write_puts_newline(ctx, wasm_get_opcode_name(WASM_OPCODE_GROW_MEMORY));
+ case WABT_EXPR_TYPE_GROW_MEMORY:
+ write_puts_newline(ctx, wabt_get_opcode_name(WABT_OPCODE_GROW_MEMORY));
break;
- case WASM_EXPR_TYPE_IF:
+ case WABT_EXPR_TYPE_IF:
write_begin_block(ctx, &expr->if_.true_,
- wasm_get_opcode_name(WASM_OPCODE_IF));
+ wabt_get_opcode_name(WABT_OPCODE_IF));
write_expr_list(ctx, expr->if_.true_.first);
if (expr->if_.false_) {
dedent(ctx);
- write_puts_space(ctx, wasm_get_opcode_name(WASM_OPCODE_ELSE));
+ write_puts_space(ctx, wabt_get_opcode_name(WABT_OPCODE_ELSE));
indent(ctx);
write_newline(ctx, FORCE_NEWLINE);
write_expr_list(ctx, expr->if_.false_);
@@ -437,65 +437,65 @@ static void write_expr(Context* ctx, const WasmExpr* expr) {
write_end_block(ctx);
break;
- case WASM_EXPR_TYPE_LOAD:
- write_puts_space(ctx, wasm_get_opcode_name(expr->load.opcode));
+ case WABT_EXPR_TYPE_LOAD:
+ write_puts_space(ctx, wabt_get_opcode_name(expr->load.opcode));
if (expr->load.offset)
writef(ctx, "offset=%" PRIu64, expr->load.offset);
- if (!wasm_is_naturally_aligned(expr->load.opcode, expr->load.align))
+ if (!wabt_is_naturally_aligned(expr->load.opcode, expr->load.align))
writef(ctx, "align=%u", expr->load.align);
write_newline(ctx, NO_FORCE_NEWLINE);
break;
- case WASM_EXPR_TYPE_LOOP:
- write_block(ctx, &expr->loop, wasm_get_opcode_name(WASM_OPCODE_LOOP));
+ case WABT_EXPR_TYPE_LOOP:
+ write_block(ctx, &expr->loop, wabt_get_opcode_name(WABT_OPCODE_LOOP));
break;
- case WASM_EXPR_TYPE_CURRENT_MEMORY:
- write_puts_newline(ctx, wasm_get_opcode_name(WASM_OPCODE_CURRENT_MEMORY));
+ case WABT_EXPR_TYPE_CURRENT_MEMORY:
+ write_puts_newline(ctx, wabt_get_opcode_name(WABT_OPCODE_CURRENT_MEMORY));
break;
- case WASM_EXPR_TYPE_NOP:
- write_puts_newline(ctx, wasm_get_opcode_name(WASM_OPCODE_NOP));
+ case WABT_EXPR_TYPE_NOP:
+ write_puts_newline(ctx, wabt_get_opcode_name(WABT_OPCODE_NOP));
break;
- case WASM_EXPR_TYPE_RETURN:
- write_puts_newline(ctx, wasm_get_opcode_name(WASM_OPCODE_RETURN));
+ case WABT_EXPR_TYPE_RETURN:
+ write_puts_newline(ctx, wabt_get_opcode_name(WABT_OPCODE_RETURN));
break;
- case WASM_EXPR_TYPE_SELECT:
- write_puts_newline(ctx, wasm_get_opcode_name(WASM_OPCODE_SELECT));
+ case WABT_EXPR_TYPE_SELECT:
+ write_puts_newline(ctx, wabt_get_opcode_name(WABT_OPCODE_SELECT));
break;
- case WASM_EXPR_TYPE_SET_GLOBAL:
- write_puts_space(ctx, wasm_get_opcode_name(WASM_OPCODE_SET_GLOBAL));
+ case WABT_EXPR_TYPE_SET_GLOBAL:
+ write_puts_space(ctx, wabt_get_opcode_name(WABT_OPCODE_SET_GLOBAL));
write_var(ctx, &expr->set_global.var, NEXT_CHAR_NEWLINE);
break;
- case WASM_EXPR_TYPE_SET_LOCAL:
- write_puts_space(ctx, wasm_get_opcode_name(WASM_OPCODE_SET_LOCAL));
+ case WABT_EXPR_TYPE_SET_LOCAL:
+ write_puts_space(ctx, wabt_get_opcode_name(WABT_OPCODE_SET_LOCAL));
write_var(ctx, &expr->set_local.var, NEXT_CHAR_NEWLINE);
break;
- case WASM_EXPR_TYPE_STORE:
- write_puts_space(ctx, wasm_get_opcode_name(expr->store.opcode));
+ case WABT_EXPR_TYPE_STORE:
+ write_puts_space(ctx, wabt_get_opcode_name(expr->store.opcode));
if (expr->store.offset)
writef(ctx, "offset=%" PRIu64, expr->store.offset);
- if (!wasm_is_naturally_aligned(expr->store.opcode, expr->store.align))
+ if (!wabt_is_naturally_aligned(expr->store.opcode, expr->store.align))
writef(ctx, "align=%u", expr->store.align);
write_newline(ctx, NO_FORCE_NEWLINE);
break;
- case WASM_EXPR_TYPE_TEE_LOCAL:
- write_puts_space(ctx, wasm_get_opcode_name(WASM_OPCODE_TEE_LOCAL));
+ case WABT_EXPR_TYPE_TEE_LOCAL:
+ write_puts_space(ctx, wabt_get_opcode_name(WABT_OPCODE_TEE_LOCAL));
write_var(ctx, &expr->tee_local.var, NEXT_CHAR_NEWLINE);
break;
- case WASM_EXPR_TYPE_UNARY:
- write_puts_newline(ctx, wasm_get_opcode_name(expr->unary.opcode));
+ case WABT_EXPR_TYPE_UNARY:
+ write_puts_newline(ctx, wabt_get_opcode_name(expr->unary.opcode));
break;
- case WASM_EXPR_TYPE_UNREACHABLE:
- write_puts_newline(ctx, wasm_get_opcode_name(WASM_OPCODE_UNREACHABLE));
+ case WABT_EXPR_TYPE_UNREACHABLE:
+ write_puts_newline(ctx, wabt_get_opcode_name(WABT_OPCODE_UNREACHABLE));
break;
default:
@@ -505,13 +505,13 @@ static void write_expr(Context* ctx, const WasmExpr* expr) {
}
}
-static void write_expr_list(Context* ctx, const WasmExpr* first) {
- const WasmExpr* expr;
+static void write_expr_list(Context* ctx, const WabtExpr* first) {
+ const WabtExpr* expr;
for (expr = first; expr; expr = expr->next)
write_expr(ctx, expr);
}
-static void write_init_expr(Context* ctx, const WasmExpr* expr) {
+static void write_init_expr(Context* ctx, const WabtExpr* expr) {
if (expr) {
write_puts(ctx, "(", NEXT_CHAR_NONE);
write_expr(ctx, expr);
@@ -523,10 +523,10 @@ static void write_init_expr(Context* ctx, const WasmExpr* expr) {
static void write_type_bindings(Context* ctx,
const char* prefix,
- const WasmFunc* func,
- const WasmTypeVector* types,
- const WasmBindingHash* bindings) {
- wasm_make_type_binding_reverse_mapping(ctx->allocator, types, bindings,
+ const WabtFunc* func,
+ const WabtTypeVector* types,
+ const WabtBindingHash* bindings) {
+ wabt_make_type_binding_reverse_mapping(ctx->allocator, types, bindings,
&ctx->index_to_name);
/* named params/locals must be specified by themselves, but nameless
@@ -534,22 +534,22 @@ static void write_type_bindings(Context* ctx,
* (param $foo i32)
* (param i32 i64 f32)
*/
- WasmBool is_open = WASM_FALSE;
+ WabtBool is_open = WABT_FALSE;
size_t i;
for (i = 0; i < types->size; ++i) {
if (!is_open) {
write_open_space(ctx, prefix);
- is_open = WASM_TRUE;
+ is_open = WABT_TRUE;
}
- const WasmStringSlice* name = &ctx->index_to_name.data[i];
- WasmBool has_name = name->start != NULL;
+ const WabtStringSlice* name = &ctx->index_to_name.data[i];
+ WabtBool has_name = name->start != NULL;
if (has_name)
write_string_slice(ctx, name, NEXT_CHAR_SPACE);
write_type(ctx, types->data[i], NEXT_CHAR_SPACE);
if (has_name) {
write_close_space(ctx);
- is_open = WASM_FALSE;
+ is_open = WABT_FALSE;
}
}
if (is_open)
@@ -557,12 +557,12 @@ static void write_type_bindings(Context* ctx,
}
static void write_func(Context* ctx,
- const WasmModule* module,
- const WasmFunc* func) {
+ const WabtModule* module,
+ const WabtFunc* func) {
write_open_space(ctx, "func");
write_string_slice_or_index(ctx, &func->name, ctx->func_index++,
NEXT_CHAR_SPACE);
- if (wasm_decl_has_func_type(&func->decl)) {
+ if (wabt_decl_has_func_type(&func->decl)) {
write_open_space(ctx, "type");
write_var(ctx, &func->decl.type_var, NEXT_CHAR_NONE);
write_close_space(ctx);
@@ -581,7 +581,7 @@ static void write_func(Context* ctx,
write_close_newline(ctx);
}
-static void write_begin_global(Context* ctx, const WasmGlobal* global) {
+static void write_begin_global(Context* ctx, const WabtGlobal* global) {
write_open_space(ctx, "global");
write_string_slice_or_index(ctx, &global->name, ctx->global_index++,
NEXT_CHAR_SPACE);
@@ -594,19 +594,19 @@ static void write_begin_global(Context* ctx, const WasmGlobal* global) {
}
}
-static void write_global(Context* ctx, const WasmGlobal* global) {
+static void write_global(Context* ctx, const WabtGlobal* global) {
write_begin_global(ctx, global);
write_init_expr(ctx, global->init_expr);
write_close_newline(ctx);
}
-static void write_limits(Context* ctx, const WasmLimits* limits) {
+static void write_limits(Context* ctx, const WabtLimits* limits) {
writef(ctx, "%" PRIu64, limits->initial);
if (limits->has_max)
writef(ctx, "%" PRIu64, limits->max);
}
-static void write_table(Context* ctx, const WasmTable* table) {
+static void write_table(Context* ctx, const WabtTable* table) {
write_open_space(ctx, "table");
write_string_slice_or_index(ctx, &table->name, ctx->table_index++,
NEXT_CHAR_SPACE);
@@ -615,7 +615,7 @@ static void write_table(Context* ctx, const WasmTable* table) {
write_close_newline(ctx);
}
-static void write_elem_segment(Context* ctx, const WasmElemSegment* segment) {
+static void write_elem_segment(Context* ctx, const WabtElemSegment* segment) {
write_open_space(ctx, "elem");
write_init_expr(ctx, segment->offset);
size_t i;
@@ -624,7 +624,7 @@ static void write_elem_segment(Context* ctx, const WasmElemSegment* segment) {
write_close_newline(ctx);
}
-static void write_memory(Context* ctx, const WasmMemory* memory) {
+static void write_memory(Context* ctx, const WabtMemory* memory) {
write_open_space(ctx, "memory");
write_string_slice_or_index(ctx, &memory->name, ctx->memory_index++,
NEXT_CHAR_SPACE);
@@ -632,23 +632,23 @@ static void write_memory(Context* ctx, const WasmMemory* memory) {
write_close_newline(ctx);
}
-static void write_data_segment(Context* ctx, const WasmDataSegment* segment) {
+static void write_data_segment(Context* ctx, const WabtDataSegment* segment) {
write_open_space(ctx, "data");
write_init_expr(ctx, segment->offset);
write_quoted_data(ctx, segment->data, segment->size);
write_close_newline(ctx);
}
-static void write_import(Context* ctx, const WasmImport* import) {
+static void write_import(Context* ctx, const WabtImport* import) {
write_open_space(ctx, "import");
write_quoted_string_slice(ctx, &import->module_name, NEXT_CHAR_SPACE);
write_quoted_string_slice(ctx, &import->field_name, NEXT_CHAR_SPACE);
switch (import->kind) {
- case WASM_EXTERNAL_KIND_FUNC:
+ case WABT_EXTERNAL_KIND_FUNC:
write_open_space(ctx, "func");
write_string_slice_or_index(ctx, &import->func.name, ctx->func_index++,
NEXT_CHAR_SPACE);
- if (wasm_decl_has_func_type(&import->func.decl)) {
+ if (wabt_decl_has_func_type(&import->func.decl)) {
write_open_space(ctx, "type");
write_var(ctx, &import->func.decl.type_var, NEXT_CHAR_NONE);
write_close_space(ctx);
@@ -658,39 +658,39 @@ static void write_import(Context* ctx, const WasmImport* import) {
write_close_space(ctx);
break;
- case WASM_EXTERNAL_KIND_TABLE:
+ case WABT_EXTERNAL_KIND_TABLE:
write_table(ctx, &import->table);
break;
- case WASM_EXTERNAL_KIND_MEMORY:
+ case WABT_EXTERNAL_KIND_MEMORY:
write_memory(ctx, &import->memory);
break;
- case WASM_EXTERNAL_KIND_GLOBAL:
+ case WABT_EXTERNAL_KIND_GLOBAL:
write_begin_global(ctx, &import->global);
write_close_space(ctx);
break;
- case WASM_NUM_EXTERNAL_KINDS:
+ case WABT_NUM_EXTERNAL_KINDS:
assert(0);
break;
}
write_close_newline(ctx);
}
-static void write_export(Context* ctx, const WasmExport* export) {
+static void write_export(Context* ctx, const WabtExport* export) {
static const char* s_kind_names[] = {"func", "table", "memory", "global"};
- WASM_STATIC_ASSERT(WASM_ARRAY_SIZE(s_kind_names) == WASM_NUM_EXTERNAL_KINDS);
+ WABT_STATIC_ASSERT(WABT_ARRAY_SIZE(s_kind_names) == WABT_NUM_EXTERNAL_KINDS);
write_open_space(ctx, "export");
write_quoted_string_slice(ctx, &export->name, NEXT_CHAR_SPACE);
- assert(export->kind < WASM_ARRAY_SIZE(s_kind_names));
+ assert(export->kind < WABT_ARRAY_SIZE(s_kind_names));
write_open_space(ctx, s_kind_names[export->kind]);
write_var(ctx, &export->var, NEXT_CHAR_SPACE);
write_close_space(ctx);
write_close_newline(ctx);
}
-static void write_func_type(Context* ctx, const WasmFuncType* func_type) {
+static void write_func_type(Context* ctx, const WabtFuncType* func_type) {
write_open_space(ctx, "type");
write_string_slice_or_index(ctx, &func_type->name, ctx->func_type_index++,
NEXT_CHAR_SPACE);
@@ -700,45 +700,45 @@ static void write_func_type(Context* ctx, const WasmFuncType* func_type) {
write_close_newline(ctx);
}
-static void write_start_function(Context* ctx, const WasmVar* start) {
+static void write_start_function(Context* ctx, const WabtVar* start) {
write_open_space(ctx, "start");
write_var(ctx, start, NEXT_CHAR_NONE);
write_close_newline(ctx);
}
-static void write_module(Context* ctx, const WasmModule* module) {
+static void write_module(Context* ctx, const WabtModule* module) {
write_open_newline(ctx, "module");
- const WasmModuleField* field;
+ const WabtModuleField* field;
for (field = module->first_field; field != NULL; field = field->next) {
switch (field->type) {
- case WASM_MODULE_FIELD_TYPE_FUNC:
+ case WABT_MODULE_FIELD_TYPE_FUNC:
write_func(ctx, module, &field->func);
break;
- case WASM_MODULE_FIELD_TYPE_GLOBAL:
+ case WABT_MODULE_FIELD_TYPE_GLOBAL:
write_global(ctx, &field->global);
break;
- case WASM_MODULE_FIELD_TYPE_IMPORT:
+ case WABT_MODULE_FIELD_TYPE_IMPORT:
write_import(ctx, &field->import);
break;
- case WASM_MODULE_FIELD_TYPE_EXPORT:
+ case WABT_MODULE_FIELD_TYPE_EXPORT:
write_export(ctx, &field->export_);
break;
- case WASM_MODULE_FIELD_TYPE_TABLE:
+ case WABT_MODULE_FIELD_TYPE_TABLE:
write_table(ctx, &field->table);
break;
- case WASM_MODULE_FIELD_TYPE_ELEM_SEGMENT:
+ case WABT_MODULE_FIELD_TYPE_ELEM_SEGMENT:
write_elem_segment(ctx, &field->elem_segment);
break;
- case WASM_MODULE_FIELD_TYPE_MEMORY:
+ case WABT_MODULE_FIELD_TYPE_MEMORY:
write_memory(ctx, &field->memory);
break;
- case WASM_MODULE_FIELD_TYPE_DATA_SEGMENT:
+ case WABT_MODULE_FIELD_TYPE_DATA_SEGMENT:
write_data_segment(ctx, &field->data_segment);
break;
- case WASM_MODULE_FIELD_TYPE_FUNC_TYPE:
+ case WABT_MODULE_FIELD_TYPE_FUNC_TYPE:
write_func_type(ctx, &field->func_type);
break;
- case WASM_MODULE_FIELD_TYPE_START:
+ case WABT_MODULE_FIELD_TYPE_START:
write_start_function(ctx, &field->start);
break;
}
@@ -748,17 +748,17 @@ static void write_module(Context* ctx, const WasmModule* module) {
write_next_char(ctx);
}
-WasmResult wasm_write_ast(WasmAllocator* allocator,
- WasmWriter* writer,
- const WasmModule* module) {
+WabtResult wabt_write_ast(WabtAllocator* allocator,
+ WabtWriter* writer,
+ const WabtModule* module) {
Context ctx;
- WASM_ZERO_MEMORY(ctx);
+ WABT_ZERO_MEMORY(ctx);
ctx.allocator = allocator;
- ctx.result = WASM_OK;
- wasm_init_stream(&ctx.stream, writer, NULL);
+ ctx.result = WABT_OK;
+ wabt_init_stream(&ctx.stream, writer, NULL);
write_module(&ctx, module);
/* the memory for the actual string slice is shared with the module, so we
* only need to free the vector */
- wasm_destroy_string_slice_vector(allocator, &ctx.index_to_name);
+ wabt_destroy_string_slice_vector(allocator, &ctx.index_to_name);
return ctx.result;
}
diff --git a/src/ast-writer.h b/src/ast-writer.h
index 4545af05..09ee9f3b 100644
--- a/src/ast-writer.h
+++ b/src/ast-writer.h
@@ -14,17 +14,17 @@
* limitations under the License.
*/
-#ifndef WASM_AST_WRITER_H_
-#define WASM_AST_WRITER_H_
+#ifndef WABT_AST_WRITER_H_
+#define WABT_AST_WRITER_H_
#include "common.h"
-struct WasmAllocator;
-struct WasmModule;
-struct WasmWriter;
+struct WabtAllocator;
+struct WabtModule;
+struct WabtWriter;
-WASM_EXTERN_C WasmResult wasm_write_ast(struct WasmAllocator*,
- struct WasmWriter*,
- const struct WasmModule*);
+WABT_EXTERN_C WabtResult wabt_write_ast(struct WabtAllocator*,
+ struct WabtWriter*,
+ const struct WabtModule*);
-#endif /* WASM_AST_WRITER_H_ */
+#endif /* WABT_AST_WRITER_H_ */
diff --git a/src/ast.c b/src/ast.c
index 301468b8..3c3d4c7a 100644
--- a/src/ast.c
+++ b/src/ast.c
@@ -21,51 +21,51 @@
#include "allocator.h"
-int wasm_get_index_from_var(const WasmBindingHash* hash, const WasmVar* var) {
- if (var->type == WASM_VAR_TYPE_NAME)
- return wasm_find_binding_index_by_name(hash, &var->name);
+int wabt_get_index_from_var(const WabtBindingHash* hash, const WabtVar* var) {
+ if (var->type == WABT_VAR_TYPE_NAME)
+ return wabt_find_binding_index_by_name(hash, &var->name);
return (int)var->index;
}
-WasmExportPtr wasm_get_export_by_name(const WasmModule* module,
- const WasmStringSlice* name) {
- int index = wasm_find_binding_index_by_name(&module->export_bindings, name);
+WabtExportPtr wabt_get_export_by_name(const WabtModule* module,
+ const WabtStringSlice* name) {
+ int index = wabt_find_binding_index_by_name(&module->export_bindings, name);
if (index == -1)
return NULL;
return module->exports.data[index];
}
-int wasm_get_func_index_by_var(const WasmModule* module, const WasmVar* var) {
- return wasm_get_index_from_var(&module->func_bindings, var);
+int wabt_get_func_index_by_var(const WabtModule* module, const WabtVar* var) {
+ return wabt_get_index_from_var(&module->func_bindings, var);
}
-int wasm_get_global_index_by_var(const WasmModule* module, const WasmVar* var) {
- return wasm_get_index_from_var(&module->global_bindings, var);
+int wabt_get_global_index_by_var(const WabtModule* module, const WabtVar* var) {
+ return wabt_get_index_from_var(&module->global_bindings, var);
}
-int wasm_get_table_index_by_var(const WasmModule* module, const WasmVar* var) {
- return wasm_get_index_from_var(&module->table_bindings, var);
+int wabt_get_table_index_by_var(const WabtModule* module, const WabtVar* var) {
+ return wabt_get_index_from_var(&module->table_bindings, var);
}
-int wasm_get_memory_index_by_var(const WasmModule* module, const WasmVar* var) {
- return wasm_get_index_from_var(&module->memory_bindings, var);
+int wabt_get_memory_index_by_var(const WabtModule* module, const WabtVar* var) {
+ return wabt_get_index_from_var(&module->memory_bindings, var);
}
-int wasm_get_func_type_index_by_var(const WasmModule* module,
- const WasmVar* var) {
- return wasm_get_index_from_var(&module->func_type_bindings, var);
+int wabt_get_func_type_index_by_var(const WabtModule* module,
+ const WabtVar* var) {
+ return wabt_get_index_from_var(&module->func_type_bindings, var);
}
-int wasm_get_local_index_by_var(const WasmFunc* func, const WasmVar* var) {
- if (var->type == WASM_VAR_TYPE_INDEX)
+int wabt_get_local_index_by_var(const WabtFunc* func, const WabtVar* var) {
+ if (var->type == WABT_VAR_TYPE_INDEX)
return (int)var->index;
int result =
- wasm_find_binding_index_by_name(&func->param_bindings, &var->name);
+ wabt_find_binding_index_by_name(&func->param_bindings, &var->name);
if (result != -1)
return result;
- result = wasm_find_binding_index_by_name(&func->local_bindings, &var->name);
+ result = wabt_find_binding_index_by_name(&func->local_bindings, &var->name);
if (result == -1)
return result;
@@ -73,102 +73,102 @@ int wasm_get_local_index_by_var(const WasmFunc* func, const WasmVar* var) {
return func->decl.sig.param_types.size + result;
}
-int wasm_get_module_index_by_var(const WasmScript* script, const WasmVar* var) {
- return wasm_get_index_from_var(&script->module_bindings, var);
+int wabt_get_module_index_by_var(const WabtScript* script, const WabtVar* var) {
+ return wabt_get_index_from_var(&script->module_bindings, var);
}
-WasmFuncPtr wasm_get_func_by_var(const WasmModule* module, const WasmVar* var) {
- int index = wasm_get_index_from_var(&module->func_bindings, var);
+WabtFuncPtr wabt_get_func_by_var(const WabtModule* module, const WabtVar* var) {
+ int index = wabt_get_index_from_var(&module->func_bindings, var);
if (index < 0 || (size_t)index >= module->funcs.size)
return NULL;
return module->funcs.data[index];
}
-WasmGlobalPtr wasm_get_global_by_var(const WasmModule* module,
- const WasmVar* var) {
- int index = wasm_get_index_from_var(&module->global_bindings, var);
+WabtGlobalPtr wabt_get_global_by_var(const WabtModule* module,
+ const WabtVar* var) {
+ int index = wabt_get_index_from_var(&module->global_bindings, var);
if (index < 0 || (size_t)index >= module->globals.size)
return NULL;
return module->globals.data[index];
}
-WasmTablePtr wasm_get_table_by_var(const WasmModule* module,
- const WasmVar* var) {
- int index = wasm_get_index_from_var(&module->table_bindings, var);
+WabtTablePtr wabt_get_table_by_var(const WabtModule* module,
+ const WabtVar* var) {
+ int index = wabt_get_index_from_var(&module->table_bindings, var);
if (index < 0 || (size_t)index >= module->tables.size)
return NULL;
return module->tables.data[index];
}
-WasmMemoryPtr wasm_get_memory_by_var(const WasmModule* module,
- const WasmVar* var) {
- int index = wasm_get_index_from_var(&module->memory_bindings, var);
+WabtMemoryPtr wabt_get_memory_by_var(const WabtModule* module,
+ const WabtVar* var) {
+ int index = wabt_get_index_from_var(&module->memory_bindings, var);
if (index < 0 || (size_t)index >= module->memories.size)
return NULL;
return module->memories.data[index];
}
-WasmFuncTypePtr wasm_get_func_type_by_var(const WasmModule* module,
- const WasmVar* var) {
- int index = wasm_get_index_from_var(&module->func_type_bindings, var);
+WabtFuncTypePtr wabt_get_func_type_by_var(const WabtModule* module,
+ const WabtVar* var) {
+ int index = wabt_get_index_from_var(&module->func_type_bindings, var);
if (index < 0 || (size_t)index >= module->func_types.size)
return NULL;
return module->func_types.data[index];
}
-int wasm_get_func_type_index_by_sig(const WasmModule* module,
- const WasmFuncSignature* sig) {
+int wabt_get_func_type_index_by_sig(const WabtModule* module,
+ const WabtFuncSignature* sig) {
size_t i;
for (i = 0; i < module->func_types.size; ++i)
- if (wasm_signatures_are_equal(&module->func_types.data[i]->sig, sig))
+ if (wabt_signatures_are_equal(&module->func_types.data[i]->sig, sig))
return i;
return -1;
}
-int wasm_get_func_type_index_by_decl(const WasmModule* module,
- const WasmFuncDeclaration* decl) {
- if (wasm_decl_has_func_type(decl)) {
- return wasm_get_func_type_index_by_var(module, &decl->type_var);
+int wabt_get_func_type_index_by_decl(const WabtModule* module,
+ const WabtFuncDeclaration* decl) {
+ if (wabt_decl_has_func_type(decl)) {
+ return wabt_get_func_type_index_by_var(module, &decl->type_var);
} else {
- return wasm_get_func_type_index_by_sig(module, &decl->sig);
+ return wabt_get_func_type_index_by_sig(module, &decl->sig);
}
}
-WasmModule* wasm_get_first_module(const WasmScript* script) {
+WabtModule* wabt_get_first_module(const WabtScript* script) {
size_t i;
for (i = 0; i < script->commands.size; ++i) {
- WasmCommand* command = &script->commands.data[i];
- if (command->type == WASM_COMMAND_TYPE_MODULE)
+ WabtCommand* command = &script->commands.data[i];
+ if (command->type == WABT_COMMAND_TYPE_MODULE)
return &command->module;
}
return NULL;
}
-WasmModule* wasm_get_module_by_var(const WasmScript* script,
- const WasmVar* var) {
- int index = wasm_get_index_from_var(&script->module_bindings, var);
+WabtModule* wabt_get_module_by_var(const WabtScript* script,
+ const WabtVar* var) {
+ int index = wabt_get_index_from_var(&script->module_bindings, var);
if (index < 0 || (size_t)index >= script->commands.size)
return NULL;
- WasmCommand* command = &script->commands.data[index];
- assert(command->type == WASM_COMMAND_TYPE_MODULE);
+ WabtCommand* command = &script->commands.data[index];
+ assert(command->type == WABT_COMMAND_TYPE_MODULE);
return &command->module;
}
-void wasm_make_type_binding_reverse_mapping(
- struct WasmAllocator* allocator,
- const WasmTypeVector* types,
- const WasmBindingHash* bindings,
- WasmStringSliceVector* out_reverse_mapping) {
+void wabt_make_type_binding_reverse_mapping(
+ struct WabtAllocator* allocator,
+ const WabtTypeVector* types,
+ const WabtBindingHash* bindings,
+ WabtStringSliceVector* out_reverse_mapping) {
uint32_t num_names = types->size;
- wasm_reserve_string_slices(allocator, out_reverse_mapping, num_names);
+ wabt_reserve_string_slices(allocator, out_reverse_mapping, num_names);
out_reverse_mapping->size = num_names;
- memset(out_reverse_mapping->data, 0, num_names * sizeof(WasmStringSlice));
+ memset(out_reverse_mapping->data, 0, num_names * sizeof(WabtStringSlice));
/* map index to name */
size_t i;
for (i = 0; i < bindings->entries.capacity; ++i) {
- const WasmBindingHashEntry* entry = &bindings->entries.data[i];
- if (wasm_hash_entry_is_free(entry))
+ const WabtBindingHashEntry* entry = &bindings->entries.data[i];
+ if (wabt_hash_entry_is_free(entry))
continue;
uint32_t index = entry->binding.index;
@@ -177,34 +177,34 @@ void wasm_make_type_binding_reverse_mapping(
}
}
-void wasm_find_duplicate_bindings(const WasmBindingHash* bindings,
- WasmDuplicateBindingCallback callback,
+void wabt_find_duplicate_bindings(const WabtBindingHash* bindings,
+ WabtDuplicateBindingCallback callback,
void* user_data) {
size_t i;
for (i = 0; i < bindings->entries.capacity; ++i) {
- WasmBindingHashEntry* entry = &bindings->entries.data[i];
- if (wasm_hash_entry_is_free(entry))
+ WabtBindingHashEntry* entry = &bindings->entries.data[i];
+ if (wabt_hash_entry_is_free(entry))
continue;
/* only follow the chain if this is the first entry in the chain */
if (entry->prev != NULL)
continue;
- WasmBindingHashEntry* a = entry;
+ WabtBindingHashEntry* a = entry;
for (; a; a = a->next) {
- WasmBindingHashEntry* b = a->next;
+ WabtBindingHashEntry* b = a->next;
for (; b; b = b->next) {
- if (wasm_string_slices_are_equal(&a->binding.name, &b->binding.name))
+ if (wabt_string_slices_are_equal(&a->binding.name, &b->binding.name))
callback(a, b, user_data);
}
}
}
}
-WasmModuleField* wasm_append_module_field(struct WasmAllocator* allocator,
- WasmModule* module) {
- WasmModuleField* result =
- wasm_alloc_zero(allocator, sizeof(WasmModuleField), WASM_DEFAULT_ALIGN);
+WabtModuleField* wabt_append_module_field(struct WabtAllocator* allocator,
+ WabtModule* module) {
+ WabtModuleField* result =
+ wabt_alloc_zero(allocator, sizeof(WabtModuleField), WABT_DEFAULT_ALIGN);
if (!module->first_field)
module->first_field = result;
else if (module->last_field)
@@ -213,51 +213,51 @@ WasmModuleField* wasm_append_module_field(struct WasmAllocator* allocator,
return result;
}
-WasmFuncType* wasm_append_implicit_func_type(struct WasmAllocator* allocator,
- WasmLocation* loc,
- WasmModule* module,
- WasmFuncSignature* sig) {
- WasmModuleField* field = wasm_append_module_field(allocator, module);
+WabtFuncType* wabt_append_implicit_func_type(struct WabtAllocator* allocator,
+ WabtLocation* loc,
+ WabtModule* module,
+ WabtFuncSignature* sig) {
+ WabtModuleField* field = wabt_append_module_field(allocator, module);
field->loc = *loc;
- field->type = WASM_MODULE_FIELD_TYPE_FUNC_TYPE;
+ field->type = WABT_MODULE_FIELD_TYPE_FUNC_TYPE;
field->func_type.sig = *sig;
- WasmFuncType* func_type_ptr = &field->func_type;
- wasm_append_func_type_ptr_value(allocator, &module->func_types,
+ WabtFuncType* func_type_ptr = &field->func_type;
+ wabt_append_func_type_ptr_value(allocator, &module->func_types,
&func_type_ptr);
return func_type_ptr;
}
#define ALLOC_EXPR_TYPE_ZERO(allocator, member) \
- wasm_alloc_zero(allocator, \
- offsetof(WasmExpr, member) + sizeof(((WasmExpr*)0)->member), \
- WASM_DEFAULT_ALIGN)
+ wabt_alloc_zero(allocator, \
+ offsetof(WabtExpr, member) + sizeof(((WabtExpr*)0)->member), \
+ WABT_DEFAULT_ALIGN)
#define FOREACH_EXPR_TYPE(V) \
- V(WASM_EXPR_TYPE_BINARY, binary, binary) \
- V(WASM_EXPR_TYPE_BLOCK, block, block) \
- V(WASM_EXPR_TYPE_BR, br, br) \
- V(WASM_EXPR_TYPE_BR_IF, br_if, br_if) \
- V(WASM_EXPR_TYPE_BR_TABLE, br_table, br_table) \
- V(WASM_EXPR_TYPE_CALL, call, call) \
- V(WASM_EXPR_TYPE_CALL_INDIRECT, call_indirect, call_indirect) \
- V(WASM_EXPR_TYPE_COMPARE, compare, compare) \
- V(WASM_EXPR_TYPE_CONST, const, const_) \
- V(WASM_EXPR_TYPE_CONVERT, convert, convert) \
- V(WASM_EXPR_TYPE_GET_GLOBAL, get_global, get_global) \
- V(WASM_EXPR_TYPE_GET_LOCAL, get_local, get_local) \
- V(WASM_EXPR_TYPE_IF, if, if_) \
- V(WASM_EXPR_TYPE_LOAD, load, load) \
- V(WASM_EXPR_TYPE_LOOP, loop, loop) \
- V(WASM_EXPR_TYPE_SET_GLOBAL, set_global, set_global) \
- V(WASM_EXPR_TYPE_SET_LOCAL, set_local, set_local) \
- V(WASM_EXPR_TYPE_STORE, store, store) \
- V(WASM_EXPR_TYPE_TEE_LOCAL, tee_local, tee_local) \
- V(WASM_EXPR_TYPE_UNARY, unary, unary)
+ V(WABT_EXPR_TYPE_BINARY, binary, binary) \
+ V(WABT_EXPR_TYPE_BLOCK, block, block) \
+ V(WABT_EXPR_TYPE_BR, br, br) \
+ V(WABT_EXPR_TYPE_BR_IF, br_if, br_if) \
+ V(WABT_EXPR_TYPE_BR_TABLE, br_table, br_table) \
+ V(WABT_EXPR_TYPE_CALL, call, call) \
+ V(WABT_EXPR_TYPE_CALL_INDIRECT, call_indirect, call_indirect) \
+ V(WABT_EXPR_TYPE_COMPARE, compare, compare) \
+ V(WABT_EXPR_TYPE_CONST, const, const_) \
+ V(WABT_EXPR_TYPE_CONVERT, convert, convert) \
+ V(WABT_EXPR_TYPE_GET_GLOBAL, get_global, get_global) \
+ V(WABT_EXPR_TYPE_GET_LOCAL, get_local, get_local) \
+ V(WABT_EXPR_TYPE_IF, if, if_) \
+ V(WABT_EXPR_TYPE_LOAD, load, load) \
+ V(WABT_EXPR_TYPE_LOOP, loop, loop) \
+ V(WABT_EXPR_TYPE_SET_GLOBAL, set_global, set_global) \
+ V(WABT_EXPR_TYPE_SET_LOCAL, set_local, set_local) \
+ V(WABT_EXPR_TYPE_STORE, store, store) \
+ V(WABT_EXPR_TYPE_TEE_LOCAL, tee_local, tee_local) \
+ V(WABT_EXPR_TYPE_UNARY, unary, unary)
#define DEFINE_NEW_EXPR(type_, name, member) \
- WasmExpr* wasm_new_##name##_expr(WasmAllocator* allocator) { \
- WasmExpr* result = ALLOC_EXPR_TYPE_ZERO(allocator, member); \
+ WabtExpr* wabt_new_##name##_expr(WabtAllocator* allocator) { \
+ WabtExpr* result = ALLOC_EXPR_TYPE_ZERO(allocator, member); \
result->type = type_; \
return result; \
}
@@ -265,497 +265,497 @@ FOREACH_EXPR_TYPE(DEFINE_NEW_EXPR)
#undef DEFINE_NEW_EXPR
#define FOREACH_EMPTY_EXPR_TYPE(V) \
- V(WASM_EXPR_TYPE_CURRENT_MEMORY, current_memory) \
- V(WASM_EXPR_TYPE_DROP, drop) \
- V(WASM_EXPR_TYPE_GROW_MEMORY, grow_memory) \
- V(WASM_EXPR_TYPE_NOP, nop) \
- V(WASM_EXPR_TYPE_RETURN, return ) \
- V(WASM_EXPR_TYPE_SELECT, select) \
- V(WASM_EXPR_TYPE_UNREACHABLE, unreachable)
+ V(WABT_EXPR_TYPE_CURRENT_MEMORY, current_memory) \
+ V(WABT_EXPR_TYPE_DROP, drop) \
+ V(WABT_EXPR_TYPE_GROW_MEMORY, grow_memory) \
+ V(WABT_EXPR_TYPE_NOP, nop) \
+ V(WABT_EXPR_TYPE_RETURN, return ) \
+ V(WABT_EXPR_TYPE_SELECT, select) \
+ V(WABT_EXPR_TYPE_UNREACHABLE, unreachable)
#define DEFINE_NEW_EMPTY_EXPR(type_, name) \
- WasmExpr* wasm_new_##name##_expr(WasmAllocator* allocator) { \
- WasmExpr* result = ALLOC_EXPR_TYPE_ZERO(allocator, next); \
+ WabtExpr* wabt_new_##name##_expr(WabtAllocator* allocator) { \
+ WabtExpr* result = ALLOC_EXPR_TYPE_ZERO(allocator, next); \
result->type = type_; \
return result; \
}
FOREACH_EMPTY_EXPR_TYPE(DEFINE_NEW_EMPTY_EXPR)
#undef DEFINE_NEW_EMPTY_EXPR
-WasmExpr* wasm_new_empty_expr(struct WasmAllocator* allocator,
- WasmExprType type) {
- WasmExpr* result = ALLOC_EXPR_TYPE_ZERO(allocator, next);
+WabtExpr* wabt_new_empty_expr(struct WabtAllocator* allocator,
+ WabtExprType type) {
+ WabtExpr* result = ALLOC_EXPR_TYPE_ZERO(allocator, next);
result->type = type;
return result;
}
-void wasm_destroy_var(WasmAllocator* allocator, WasmVar* var) {
- if (var->type == WASM_VAR_TYPE_NAME)
- wasm_destroy_string_slice(allocator, &var->name);
+void wabt_destroy_var(WabtAllocator* allocator, WabtVar* var) {
+ if (var->type == WABT_VAR_TYPE_NAME)
+ wabt_destroy_string_slice(allocator, &var->name);
}
-void wasm_destroy_var_vector_and_elements(WasmAllocator* allocator,
- WasmVarVector* vars) {
- WASM_DESTROY_VECTOR_AND_ELEMENTS(allocator, *vars, var);
+void wabt_destroy_var_vector_and_elements(WabtAllocator* allocator,
+ WabtVarVector* vars) {
+ WABT_DESTROY_VECTOR_AND_ELEMENTS(allocator, *vars, var);
}
-void wasm_destroy_func_signature(WasmAllocator* allocator,
- WasmFuncSignature* sig) {
- wasm_destroy_type_vector(allocator, &sig->param_types);
- wasm_destroy_type_vector(allocator, &sig->result_types);
+void wabt_destroy_func_signature(WabtAllocator* allocator,
+ WabtFuncSignature* sig) {
+ wabt_destroy_type_vector(allocator, &sig->param_types);
+ wabt_destroy_type_vector(allocator, &sig->result_types);
}
-void wasm_destroy_expr_list(WasmAllocator* allocator, WasmExpr* first) {
- WasmExpr* expr = first;
+void wabt_destroy_expr_list(WabtAllocator* allocator, WabtExpr* first) {
+ WabtExpr* expr = first;
while (expr) {
- WasmExpr* next = expr->next;
- wasm_destroy_expr(allocator, expr);
+ WabtExpr* next = expr->next;
+ wabt_destroy_expr(allocator, expr);
expr = next;
}
}
-void wasm_destroy_block(WasmAllocator* allocator, WasmBlock* block) {
- wasm_destroy_string_slice(allocator, &block->label);
- wasm_destroy_type_vector(allocator, &block->sig);
- wasm_destroy_expr_list(allocator, block->first);
+void wabt_destroy_block(WabtAllocator* allocator, WabtBlock* block) {
+ wabt_destroy_string_slice(allocator, &block->label);
+ wabt_destroy_type_vector(allocator, &block->sig);
+ wabt_destroy_expr_list(allocator, block->first);
}
-void wasm_destroy_expr(WasmAllocator* allocator, WasmExpr* expr) {
+void wabt_destroy_expr(WabtAllocator* allocator, WabtExpr* expr) {
switch (expr->type) {
- case WASM_EXPR_TYPE_BLOCK:
- wasm_destroy_block(allocator, &expr->block);
+ case WABT_EXPR_TYPE_BLOCK:
+ wabt_destroy_block(allocator, &expr->block);
break;
- case WASM_EXPR_TYPE_BR:
- wasm_destroy_var(allocator, &expr->br.var);
+ case WABT_EXPR_TYPE_BR:
+ wabt_destroy_var(allocator, &expr->br.var);
break;
- case WASM_EXPR_TYPE_BR_IF:
- wasm_destroy_var(allocator, &expr->br_if.var);
+ case WABT_EXPR_TYPE_BR_IF:
+ wabt_destroy_var(allocator, &expr->br_if.var);
break;
- case WASM_EXPR_TYPE_BR_TABLE:
- WASM_DESTROY_VECTOR_AND_ELEMENTS(allocator, expr->br_table.targets, var);
- wasm_destroy_var(allocator, &expr->br_table.default_target);
+ case WABT_EXPR_TYPE_BR_TABLE:
+ WABT_DESTROY_VECTOR_AND_ELEMENTS(allocator, expr->br_table.targets, var);
+ wabt_destroy_var(allocator, &expr->br_table.default_target);
break;
- case WASM_EXPR_TYPE_CALL:
- wasm_destroy_var(allocator, &expr->call.var);
+ case WABT_EXPR_TYPE_CALL:
+ wabt_destroy_var(allocator, &expr->call.var);
break;
- case WASM_EXPR_TYPE_CALL_INDIRECT:
- wasm_destroy_var(allocator, &expr->call_indirect.var);
+ case WABT_EXPR_TYPE_CALL_INDIRECT:
+ wabt_destroy_var(allocator, &expr->call_indirect.var);
break;
- case WASM_EXPR_TYPE_GET_GLOBAL:
- wasm_destroy_var(allocator, &expr->get_global.var);
+ case WABT_EXPR_TYPE_GET_GLOBAL:
+ wabt_destroy_var(allocator, &expr->get_global.var);
break;
- case WASM_EXPR_TYPE_GET_LOCAL:
- wasm_destroy_var(allocator, &expr->get_local.var);
+ case WABT_EXPR_TYPE_GET_LOCAL:
+ wabt_destroy_var(allocator, &expr->get_local.var);
break;
- case WASM_EXPR_TYPE_IF:
- wasm_destroy_block(allocator, &expr->if_.true_);
- wasm_destroy_expr_list(allocator, expr->if_.false_);
+ case WABT_EXPR_TYPE_IF:
+ wabt_destroy_block(allocator, &expr->if_.true_);
+ wabt_destroy_expr_list(allocator, expr->if_.false_);
break;
- case WASM_EXPR_TYPE_LOOP:
- wasm_destroy_block(allocator, &expr->loop);
+ case WABT_EXPR_TYPE_LOOP:
+ wabt_destroy_block(allocator, &expr->loop);
break;
- case WASM_EXPR_TYPE_SET_GLOBAL:
- wasm_destroy_var(allocator, &expr->set_global.var);
+ case WABT_EXPR_TYPE_SET_GLOBAL:
+ wabt_destroy_var(allocator, &expr->set_global.var);
break;
- case WASM_EXPR_TYPE_SET_LOCAL:
- wasm_destroy_var(allocator, &expr->set_local.var);
+ case WABT_EXPR_TYPE_SET_LOCAL:
+ wabt_destroy_var(allocator, &expr->set_local.var);
break;
- case WASM_EXPR_TYPE_TEE_LOCAL:
- wasm_destroy_var(allocator, &expr->tee_local.var);
+ case WABT_EXPR_TYPE_TEE_LOCAL:
+ wabt_destroy_var(allocator, &expr->tee_local.var);
break;
- case WASM_EXPR_TYPE_BINARY:
- case WASM_EXPR_TYPE_COMPARE:
- case WASM_EXPR_TYPE_CONST:
- case WASM_EXPR_TYPE_CONVERT:
- case WASM_EXPR_TYPE_DROP:
- case WASM_EXPR_TYPE_CURRENT_MEMORY:
- case WASM_EXPR_TYPE_GROW_MEMORY:
- case WASM_EXPR_TYPE_LOAD:
- case WASM_EXPR_TYPE_NOP:
- case WASM_EXPR_TYPE_RETURN:
- case WASM_EXPR_TYPE_SELECT:
- case WASM_EXPR_TYPE_STORE:
- case WASM_EXPR_TYPE_UNARY:
- case WASM_EXPR_TYPE_UNREACHABLE:
+ case WABT_EXPR_TYPE_BINARY:
+ case WABT_EXPR_TYPE_COMPARE:
+ case WABT_EXPR_TYPE_CONST:
+ case WABT_EXPR_TYPE_CONVERT:
+ case WABT_EXPR_TYPE_DROP:
+ case WABT_EXPR_TYPE_CURRENT_MEMORY:
+ case WABT_EXPR_TYPE_GROW_MEMORY:
+ case WABT_EXPR_TYPE_LOAD:
+ case WABT_EXPR_TYPE_NOP:
+ case WABT_EXPR_TYPE_RETURN:
+ case WABT_EXPR_TYPE_SELECT:
+ case WABT_EXPR_TYPE_STORE:
+ case WABT_EXPR_TYPE_UNARY:
+ case WABT_EXPR_TYPE_UNREACHABLE:
break;
}
- wasm_free(allocator, expr);
+ wabt_free(allocator, expr);
}
-void wasm_destroy_func_declaration(WasmAllocator* allocator,
- WasmFuncDeclaration* decl) {
- wasm_destroy_var(allocator, &decl->type_var);
- if (!(decl->flags & WASM_FUNC_DECLARATION_FLAG_SHARED_SIGNATURE))
- wasm_destroy_func_signature(allocator, &decl->sig);
+void wabt_destroy_func_declaration(WabtAllocator* allocator,
+ WabtFuncDeclaration* decl) {
+ wabt_destroy_var(allocator, &decl->type_var);
+ if (!(decl->flags & WABT_FUNC_DECLARATION_FLAG_SHARED_SIGNATURE))
+ wabt_destroy_func_signature(allocator, &decl->sig);
}
-void wasm_destroy_func(WasmAllocator* allocator, WasmFunc* func) {
- wasm_destroy_string_slice(allocator, &func->name);
- wasm_destroy_func_declaration(allocator, &func->decl);
- wasm_destroy_type_vector(allocator, &func->local_types);
- wasm_destroy_binding_hash(allocator, &func->param_bindings);
- wasm_destroy_binding_hash(allocator, &func->local_bindings);
- wasm_destroy_expr_list(allocator, func->first_expr);
+void wabt_destroy_func(WabtAllocator* allocator, WabtFunc* func) {
+ wabt_destroy_string_slice(allocator, &func->name);
+ wabt_destroy_func_declaration(allocator, &func->decl);
+ wabt_destroy_type_vector(allocator, &func->local_types);
+ wabt_destroy_binding_hash(allocator, &func->param_bindings);
+ wabt_destroy_binding_hash(allocator, &func->local_bindings);
+ wabt_destroy_expr_list(allocator, func->first_expr);
}
-void wasm_destroy_global(WasmAllocator* allocator, WasmGlobal* global) {
- wasm_destroy_string_slice(allocator, &global->name);
- wasm_destroy_expr_list(allocator, global->init_expr);
+void wabt_destroy_global(WabtAllocator* allocator, WabtGlobal* global) {
+ wabt_destroy_string_slice(allocator, &global->name);
+ wabt_destroy_expr_list(allocator, global->init_expr);
}
-void wasm_destroy_import(WasmAllocator* allocator, WasmImport* import) {
- wasm_destroy_string_slice(allocator, &import->module_name);
- wasm_destroy_string_slice(allocator, &import->field_name);
+void wabt_destroy_import(WabtAllocator* allocator, WabtImport* import) {
+ wabt_destroy_string_slice(allocator, &import->module_name);
+ wabt_destroy_string_slice(allocator, &import->field_name);
switch (import->kind) {
- case WASM_EXTERNAL_KIND_FUNC:
- wasm_destroy_func(allocator, &import->func);
+ case WABT_EXTERNAL_KIND_FUNC:
+ wabt_destroy_func(allocator, &import->func);
break;
- case WASM_EXTERNAL_KIND_TABLE:
- wasm_destroy_table(allocator, &import->table);
+ case WABT_EXTERNAL_KIND_TABLE:
+ wabt_destroy_table(allocator, &import->table);
break;
- case WASM_EXTERNAL_KIND_MEMORY:
- wasm_destroy_memory(allocator, &import->memory);
+ case WABT_EXTERNAL_KIND_MEMORY:
+ wabt_destroy_memory(allocator, &import->memory);
break;
- case WASM_EXTERNAL_KIND_GLOBAL:
- wasm_destroy_global(allocator, &import->global);
+ case WABT_EXTERNAL_KIND_GLOBAL:
+ wabt_destroy_global(allocator, &import->global);
break;
- case WASM_NUM_EXTERNAL_KINDS:
+ case WABT_NUM_EXTERNAL_KINDS:
assert(0);
break;
}
}
-void wasm_destroy_export(WasmAllocator* allocator, WasmExport* export) {
- wasm_destroy_string_slice(allocator, &export->name);
- wasm_destroy_var(allocator, &export->var);
+void wabt_destroy_export(WabtAllocator* allocator, WabtExport* export) {
+ wabt_destroy_string_slice(allocator, &export->name);
+ wabt_destroy_var(allocator, &export->var);
}
-void wasm_destroy_func_type(WasmAllocator* allocator, WasmFuncType* func_type) {
- wasm_destroy_string_slice(allocator, &func_type->name);
- wasm_destroy_func_signature(allocator, &func_type->sig);
+void wabt_destroy_func_type(WabtAllocator* allocator, WabtFuncType* func_type) {
+ wabt_destroy_string_slice(allocator, &func_type->name);
+ wabt_destroy_func_signature(allocator, &func_type->sig);
}
-void wasm_destroy_data_segment(WasmAllocator* allocator,
- WasmDataSegment* data) {
- wasm_destroy_var(allocator, &data->memory_var);
- wasm_destroy_expr_list(allocator, data->offset);
- wasm_free(allocator, data->data);
+void wabt_destroy_data_segment(WabtAllocator* allocator,
+ WabtDataSegment* data) {
+ wabt_destroy_var(allocator, &data->memory_var);
+ wabt_destroy_expr_list(allocator, data->offset);
+ wabt_free(allocator, data->data);
}
-void wasm_destroy_memory(struct WasmAllocator* allocator, WasmMemory* memory) {
- wasm_destroy_string_slice(allocator, &memory->name);
+void wabt_destroy_memory(struct WabtAllocator* allocator, WabtMemory* memory) {
+ wabt_destroy_string_slice(allocator, &memory->name);
}
-void wasm_destroy_table(struct WasmAllocator* allocator, WasmTable* table) {
- wasm_destroy_string_slice(allocator, &table->name);
+void wabt_destroy_table(struct WabtAllocator* allocator, WabtTable* table) {
+ wabt_destroy_string_slice(allocator, &table->name);
}
-static void destroy_module_field(WasmAllocator* allocator,
- WasmModuleField* field) {
+static void destroy_module_field(WabtAllocator* allocator,
+ WabtModuleField* field) {
switch (field->type) {
- case WASM_MODULE_FIELD_TYPE_FUNC:
- wasm_destroy_func(allocator, &field->func);
+ case WABT_MODULE_FIELD_TYPE_FUNC:
+ wabt_destroy_func(allocator, &field->func);
break;
- case WASM_MODULE_FIELD_TYPE_GLOBAL:
- wasm_destroy_global(allocator, &field->global);
+ case WABT_MODULE_FIELD_TYPE_GLOBAL:
+ wabt_destroy_global(allocator, &field->global);
break;
- case WASM_MODULE_FIELD_TYPE_IMPORT:
- wasm_destroy_import(allocator, &field->import);
+ case WABT_MODULE_FIELD_TYPE_IMPORT:
+ wabt_destroy_import(allocator, &field->import);
break;
- case WASM_MODULE_FIELD_TYPE_EXPORT:
- wasm_destroy_export(allocator, &field->export_);
+ case WABT_MODULE_FIELD_TYPE_EXPORT:
+ wabt_destroy_export(allocator, &field->export_);
break;
- case WASM_MODULE_FIELD_TYPE_FUNC_TYPE:
- wasm_destroy_func_type(allocator, &field->func_type);
+ case WABT_MODULE_FIELD_TYPE_FUNC_TYPE:
+ wabt_destroy_func_type(allocator, &field->func_type);
break;
- case WASM_MODULE_FIELD_TYPE_TABLE:
- wasm_destroy_table(allocator, &field->table);
+ case WABT_MODULE_FIELD_TYPE_TABLE:
+ wabt_destroy_table(allocator, &field->table);
break;
- case WASM_MODULE_FIELD_TYPE_ELEM_SEGMENT:
- wasm_destroy_elem_segment(allocator, &field->elem_segment);
+ case WABT_MODULE_FIELD_TYPE_ELEM_SEGMENT:
+ wabt_destroy_elem_segment(allocator, &field->elem_segment);
break;
- case WASM_MODULE_FIELD_TYPE_MEMORY:
- wasm_destroy_memory(allocator, &field->memory);
+ case WABT_MODULE_FIELD_TYPE_MEMORY:
+ wabt_destroy_memory(allocator, &field->memory);
break;
- case WASM_MODULE_FIELD_TYPE_DATA_SEGMENT:
- wasm_destroy_data_segment(allocator, &field->data_segment);
+ case WABT_MODULE_FIELD_TYPE_DATA_SEGMENT:
+ wabt_destroy_data_segment(allocator, &field->data_segment);
break;
- case WASM_MODULE_FIELD_TYPE_START:
- wasm_destroy_var(allocator, &field->start);
+ case WABT_MODULE_FIELD_TYPE_START:
+ wabt_destroy_var(allocator, &field->start);
break;
}
}
-void wasm_destroy_module(WasmAllocator* allocator, WasmModule* module) {
- wasm_destroy_string_slice(allocator, &module->name);
+void wabt_destroy_module(WabtAllocator* allocator, WabtModule* module) {
+ wabt_destroy_string_slice(allocator, &module->name);
- WasmModuleField* field = module->first_field;
+ WabtModuleField* field = module->first_field;
while (field != NULL) {
- WasmModuleField* next_field = field->next;
+ WabtModuleField* next_field = field->next;
destroy_module_field(allocator, field);
- wasm_free(allocator, field);
+ wabt_free(allocator, field);
field = next_field;
}
/* everything that follows shares data with the module fields above, so we
only need to destroy the containing vectors */
- wasm_destroy_func_ptr_vector(allocator, &module->funcs);
- wasm_destroy_global_ptr_vector(allocator, &module->globals);
- wasm_destroy_import_ptr_vector(allocator, &module->imports);
- wasm_destroy_export_ptr_vector(allocator, &module->exports);
- wasm_destroy_func_type_ptr_vector(allocator, &module->func_types);
- wasm_destroy_table_ptr_vector(allocator, &module->tables);
- wasm_destroy_elem_segment_ptr_vector(allocator, &module->elem_segments);
- wasm_destroy_memory_ptr_vector(allocator, &module->memories);
- wasm_destroy_data_segment_ptr_vector(allocator, &module->data_segments);
- wasm_destroy_binding_hash_entry_vector(allocator,
+ wabt_destroy_func_ptr_vector(allocator, &module->funcs);
+ wabt_destroy_global_ptr_vector(allocator, &module->globals);
+ wabt_destroy_import_ptr_vector(allocator, &module->imports);
+ wabt_destroy_export_ptr_vector(allocator, &module->exports);
+ wabt_destroy_func_type_ptr_vector(allocator, &module->func_types);
+ wabt_destroy_table_ptr_vector(allocator, &module->tables);
+ wabt_destroy_elem_segment_ptr_vector(allocator, &module->elem_segments);
+ wabt_destroy_memory_ptr_vector(allocator, &module->memories);
+ wabt_destroy_data_segment_ptr_vector(allocator, &module->data_segments);
+ wabt_destroy_binding_hash_entry_vector(allocator,
&module->func_bindings.entries);
- wasm_destroy_binding_hash_entry_vector(allocator,
+ wabt_destroy_binding_hash_entry_vector(allocator,
&module->global_bindings.entries);
- wasm_destroy_binding_hash_entry_vector(allocator,
+ wabt_destroy_binding_hash_entry_vector(allocator,
&module->export_bindings.entries);
- wasm_destroy_binding_hash_entry_vector(allocator,
+ wabt_destroy_binding_hash_entry_vector(allocator,
&module->func_type_bindings.entries);
- wasm_destroy_binding_hash_entry_vector(allocator,
+ wabt_destroy_binding_hash_entry_vector(allocator,
&module->table_bindings.entries);
- wasm_destroy_binding_hash_entry_vector(allocator,
+ wabt_destroy_binding_hash_entry_vector(allocator,
&module->memory_bindings.entries);
}
-void wasm_destroy_raw_module(WasmAllocator* allocator, WasmRawModule* raw) {
- if (raw->type == WASM_RAW_MODULE_TYPE_TEXT) {
- wasm_destroy_module(allocator, raw->text);
- wasm_free(allocator, raw->text);
+void wabt_destroy_raw_module(WabtAllocator* allocator, WabtRawModule* raw) {
+ if (raw->type == WABT_RAW_MODULE_TYPE_TEXT) {
+ wabt_destroy_module(allocator, raw->text);
+ wabt_free(allocator, raw->text);
} else {
- wasm_destroy_string_slice(allocator, &raw->binary.name);
- wasm_free(allocator, raw->binary.data);
+ wabt_destroy_string_slice(allocator, &raw->binary.name);
+ wabt_free(allocator, raw->binary.data);
}
}
-void wasm_destroy_action(WasmAllocator* allocator, WasmAction* action) {
- wasm_destroy_var(allocator, &action->module_var);
+void wabt_destroy_action(WabtAllocator* allocator, WabtAction* action) {
+ wabt_destroy_var(allocator, &action->module_var);
switch (action->type) {
- case WASM_ACTION_TYPE_INVOKE:
- wasm_destroy_string_slice(allocator, &action->invoke.name);
- wasm_destroy_const_vector(allocator, &action->invoke.args);
+ case WABT_ACTION_TYPE_INVOKE:
+ wabt_destroy_string_slice(allocator, &action->invoke.name);
+ wabt_destroy_const_vector(allocator, &action->invoke.args);
break;
- case WASM_ACTION_TYPE_GET:
- wasm_destroy_string_slice(allocator, &action->get.name);
+ case WABT_ACTION_TYPE_GET:
+ wabt_destroy_string_slice(allocator, &action->get.name);
break;
}
}
-void wasm_destroy_command(WasmAllocator* allocator, WasmCommand* command) {
+void wabt_destroy_command(WabtAllocator* allocator, WabtCommand* command) {
switch (command->type) {
- case WASM_COMMAND_TYPE_MODULE:
- wasm_destroy_module(allocator, &command->module);
+ case WABT_COMMAND_TYPE_MODULE:
+ wabt_destroy_module(allocator, &command->module);
break;
- case WASM_COMMAND_TYPE_ACTION:
- wasm_destroy_action(allocator, &command->action);
+ case WABT_COMMAND_TYPE_ACTION:
+ wabt_destroy_action(allocator, &command->action);
break;
- case WASM_COMMAND_TYPE_REGISTER:
- wasm_destroy_string_slice(allocator, &command->register_.module_name);
- wasm_destroy_var(allocator, &command->register_.var);
+ case WABT_COMMAND_TYPE_REGISTER:
+ wabt_destroy_string_slice(allocator, &command->register_.module_name);
+ wabt_destroy_var(allocator, &command->register_.var);
break;
- case WASM_COMMAND_TYPE_ASSERT_MALFORMED:
- wasm_destroy_raw_module(allocator, &command->assert_malformed.module);
- wasm_destroy_string_slice(allocator, &command->assert_malformed.text);
+ case WABT_COMMAND_TYPE_ASSERT_MALFORMED:
+ wabt_destroy_raw_module(allocator, &command->assert_malformed.module);
+ wabt_destroy_string_slice(allocator, &command->assert_malformed.text);
break;
- case WASM_COMMAND_TYPE_ASSERT_INVALID:
- case WASM_COMMAND_TYPE_ASSERT_INVALID_NON_BINARY:
- wasm_destroy_raw_module(allocator, &command->assert_invalid.module);
- wasm_destroy_string_slice(allocator, &command->assert_invalid.text);
+ case WABT_COMMAND_TYPE_ASSERT_INVALID:
+ case WABT_COMMAND_TYPE_ASSERT_INVALID_NON_BINARY:
+ wabt_destroy_raw_module(allocator, &command->assert_invalid.module);
+ wabt_destroy_string_slice(allocator, &command->assert_invalid.text);
break;
- case WASM_COMMAND_TYPE_ASSERT_UNLINKABLE:
- wasm_destroy_raw_module(allocator, &command->assert_unlinkable.module);
- wasm_destroy_string_slice(allocator, &command->assert_unlinkable.text);
+ case WABT_COMMAND_TYPE_ASSERT_UNLINKABLE:
+ wabt_destroy_raw_module(allocator, &command->assert_unlinkable.module);
+ wabt_destroy_string_slice(allocator, &command->assert_unlinkable.text);
break;
- case WASM_COMMAND_TYPE_ASSERT_UNINSTANTIABLE:
- wasm_destroy_raw_module(allocator,
+ case WABT_COMMAND_TYPE_ASSERT_UNINSTANTIABLE:
+ wabt_destroy_raw_module(allocator,
&command->assert_uninstantiable.module);
- wasm_destroy_string_slice(allocator,
+ wabt_destroy_string_slice(allocator,
&command->assert_uninstantiable.text);
break;
- case WASM_COMMAND_TYPE_ASSERT_RETURN:
- wasm_destroy_action(allocator, &command->assert_return.action);
- wasm_destroy_const_vector(allocator, &command->assert_return.expected);
+ case WABT_COMMAND_TYPE_ASSERT_RETURN:
+ wabt_destroy_action(allocator, &command->assert_return.action);
+ wabt_destroy_const_vector(allocator, &command->assert_return.expected);
break;
- case WASM_COMMAND_TYPE_ASSERT_RETURN_NAN:
- wasm_destroy_action(allocator, &command->assert_return_nan.action);
+ case WABT_COMMAND_TYPE_ASSERT_RETURN_NAN:
+ wabt_destroy_action(allocator, &command->assert_return_nan.action);
break;
- case WASM_COMMAND_TYPE_ASSERT_TRAP:
- case WASM_COMMAND_TYPE_ASSERT_EXHAUSTION:
- wasm_destroy_action(allocator, &command->assert_trap.action);
- wasm_destroy_string_slice(allocator, &command->assert_trap.text);
+ case WABT_COMMAND_TYPE_ASSERT_TRAP:
+ case WABT_COMMAND_TYPE_ASSERT_EXHAUSTION:
+ wabt_destroy_action(allocator, &command->assert_trap.action);
+ wabt_destroy_string_slice(allocator, &command->assert_trap.text);
break;
- case WASM_NUM_COMMAND_TYPES:
+ case WABT_NUM_COMMAND_TYPES:
assert(0);
break;
}
}
-void wasm_destroy_command_vector_and_elements(WasmAllocator* allocator,
- WasmCommandVector* commands) {
- WASM_DESTROY_VECTOR_AND_ELEMENTS(allocator, *commands, command);
+void wabt_destroy_command_vector_and_elements(WabtAllocator* allocator,
+ WabtCommandVector* commands) {
+ WABT_DESTROY_VECTOR_AND_ELEMENTS(allocator, *commands, command);
}
-void wasm_destroy_elem_segment(WasmAllocator* allocator,
- WasmElemSegment* elem) {
- wasm_destroy_var(allocator, &elem->table_var);
- wasm_destroy_expr_list(allocator, elem->offset);
- WASM_DESTROY_VECTOR_AND_ELEMENTS(allocator, elem->vars, var);
+void wabt_destroy_elem_segment(WabtAllocator* allocator,
+ WabtElemSegment* elem) {
+ wabt_destroy_var(allocator, &elem->table_var);
+ wabt_destroy_expr_list(allocator, elem->offset);
+ WABT_DESTROY_VECTOR_AND_ELEMENTS(allocator, elem->vars, var);
}
-void wasm_destroy_script(WasmScript* script) {
- WASM_DESTROY_VECTOR_AND_ELEMENTS(script->allocator, script->commands,
+void wabt_destroy_script(WabtScript* script) {
+ WABT_DESTROY_VECTOR_AND_ELEMENTS(script->allocator, script->commands,
command);
- wasm_destroy_binding_hash(script->allocator, &script->module_bindings);
+ wabt_destroy_binding_hash(script->allocator, &script->module_bindings);
}
#define CHECK_RESULT(expr) \
do { \
- if (WASM_FAILED((expr))) \
- return WASM_ERROR; \
+ if (WABT_FAILED((expr))) \
+ return WABT_ERROR; \
} while (0)
#define CALLBACK(member) \
CHECK_RESULT((visitor)->member \
? (visitor)->member(expr, (visitor)->user_data) \
- : WASM_OK)
+ : WABT_OK)
-static WasmResult visit_expr(WasmExpr* expr, WasmExprVisitor* visitor);
+static WabtResult visit_expr(WabtExpr* expr, WabtExprVisitor* visitor);
-WasmResult wasm_visit_expr_list(WasmExpr* first, WasmExprVisitor* visitor) {
- WasmExpr* expr;
+WabtResult wabt_visit_expr_list(WabtExpr* first, WabtExprVisitor* visitor) {
+ WabtExpr* expr;
for (expr = first; expr; expr = expr->next)
CHECK_RESULT(visit_expr(expr, visitor));
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult visit_expr(WasmExpr* expr, WasmExprVisitor* visitor) {
+static WabtResult visit_expr(WabtExpr* expr, WabtExprVisitor* visitor) {
switch (expr->type) {
- case WASM_EXPR_TYPE_BINARY:
+ case WABT_EXPR_TYPE_BINARY:
CALLBACK(on_binary_expr);
break;
- case WASM_EXPR_TYPE_BLOCK:
+ case WABT_EXPR_TYPE_BLOCK:
CALLBACK(begin_block_expr);
- CHECK_RESULT(wasm_visit_expr_list(expr->block.first, visitor));
+ CHECK_RESULT(wabt_visit_expr_list(expr->block.first, visitor));
CALLBACK(end_block_expr);
break;
- case WASM_EXPR_TYPE_BR:
+ case WABT_EXPR_TYPE_BR:
CALLBACK(on_br_expr);
break;
- case WASM_EXPR_TYPE_BR_IF:
+ case WABT_EXPR_TYPE_BR_IF:
CALLBACK(on_br_if_expr);
break;
- case WASM_EXPR_TYPE_BR_TABLE:
+ case WABT_EXPR_TYPE_BR_TABLE:
CALLBACK(on_br_table_expr);
break;
- case WASM_EXPR_TYPE_CALL:
+ case WABT_EXPR_TYPE_CALL:
CALLBACK(on_call_expr);
break;
- case WASM_EXPR_TYPE_CALL_INDIRECT:
+ case WABT_EXPR_TYPE_CALL_INDIRECT:
CALLBACK(on_call_indirect_expr);
break;
- case WASM_EXPR_TYPE_COMPARE:
+ case WABT_EXPR_TYPE_COMPARE:
CALLBACK(on_compare_expr);
break;
- case WASM_EXPR_TYPE_CONST:
+ case WABT_EXPR_TYPE_CONST:
CALLBACK(on_const_expr);
break;
- case WASM_EXPR_TYPE_CONVERT:
+ case WABT_EXPR_TYPE_CONVERT:
CALLBACK(on_convert_expr);
break;
- case WASM_EXPR_TYPE_CURRENT_MEMORY:
+ case WABT_EXPR_TYPE_CURRENT_MEMORY:
CALLBACK(on_current_memory_expr);
break;
- case WASM_EXPR_TYPE_DROP:
+ case WABT_EXPR_TYPE_DROP:
CALLBACK(on_drop_expr);
break;
- case WASM_EXPR_TYPE_GET_GLOBAL:
+ case WABT_EXPR_TYPE_GET_GLOBAL:
CALLBACK(on_get_global_expr);
break;
- case WASM_EXPR_TYPE_GET_LOCAL:
+ case WABT_EXPR_TYPE_GET_LOCAL:
CALLBACK(on_get_local_expr);
break;
- case WASM_EXPR_TYPE_GROW_MEMORY:
+ case WABT_EXPR_TYPE_GROW_MEMORY:
CALLBACK(on_grow_memory_expr);
break;
- case WASM_EXPR_TYPE_IF:
+ case WABT_EXPR_TYPE_IF:
CALLBACK(begin_if_expr);
- CHECK_RESULT(wasm_visit_expr_list(expr->if_.true_.first, visitor));
+ CHECK_RESULT(wabt_visit_expr_list(expr->if_.true_.first, visitor));
CALLBACK(after_if_true_expr);
- CHECK_RESULT(wasm_visit_expr_list(expr->if_.false_, visitor));
+ CHECK_RESULT(wabt_visit_expr_list(expr->if_.false_, visitor));
CALLBACK(end_if_expr);
break;
- case WASM_EXPR_TYPE_LOAD:
+ case WABT_EXPR_TYPE_LOAD:
CALLBACK(on_load_expr);
break;
- case WASM_EXPR_TYPE_LOOP:
+ case WABT_EXPR_TYPE_LOOP:
CALLBACK(begin_loop_expr);
- CHECK_RESULT(wasm_visit_expr_list(expr->loop.first, visitor));
+ CHECK_RESULT(wabt_visit_expr_list(expr->loop.first, visitor));
CALLBACK(end_loop_expr);
break;
- case WASM_EXPR_TYPE_NOP:
+ case WABT_EXPR_TYPE_NOP:
CALLBACK(on_nop_expr);
break;
- case WASM_EXPR_TYPE_RETURN:
+ case WABT_EXPR_TYPE_RETURN:
CALLBACK(on_return_expr);
break;
- case WASM_EXPR_TYPE_SELECT:
+ case WABT_EXPR_TYPE_SELECT:
CALLBACK(on_select_expr);
break;
- case WASM_EXPR_TYPE_SET_GLOBAL:
+ case WABT_EXPR_TYPE_SET_GLOBAL:
CALLBACK(on_set_global_expr);
break;
- case WASM_EXPR_TYPE_SET_LOCAL:
+ case WABT_EXPR_TYPE_SET_LOCAL:
CALLBACK(on_set_local_expr);
break;
- case WASM_EXPR_TYPE_STORE:
+ case WABT_EXPR_TYPE_STORE:
CALLBACK(on_store_expr);
break;
- case WASM_EXPR_TYPE_TEE_LOCAL:
+ case WABT_EXPR_TYPE_TEE_LOCAL:
CALLBACK(on_tee_local_expr);
break;
- case WASM_EXPR_TYPE_UNARY:
+ case WABT_EXPR_TYPE_UNARY:
CALLBACK(on_unary_expr);
break;
- case WASM_EXPR_TYPE_UNREACHABLE:
+ case WABT_EXPR_TYPE_UNREACHABLE:
CALLBACK(on_unreachable_expr);
break;
}
- return WASM_OK;
+ return WABT_OK;
}
/* TODO(binji): make the visitor non-recursive */
-WasmResult wasm_visit_func(WasmFunc* func, WasmExprVisitor* visitor) {
- return wasm_visit_expr_list(func->first_expr, visitor);
+WabtResult wabt_visit_func(WabtFunc* func, WabtExprVisitor* visitor) {
+ return wabt_visit_expr_list(func->first_expr, visitor);
}
diff --git a/src/ast.h b/src/ast.h
index 27844d66..c84f31c7 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#ifndef WASM_AST_H_
-#define WASM_AST_H_
+#ifndef WABT_AST_H_
+#define WABT_AST_H_
#include <assert.h>
#include <stddef.h>
@@ -26,230 +26,230 @@
#include "type-vector.h"
#include "vector.h"
-typedef enum WasmVarType {
- WASM_VAR_TYPE_INDEX,
- WASM_VAR_TYPE_NAME,
-} WasmVarType;
+typedef enum WabtVarType {
+ WABT_VAR_TYPE_INDEX,
+ WABT_VAR_TYPE_NAME,
+} WabtVarType;
-typedef struct WasmVar {
- WasmLocation loc;
- WasmVarType type;
+typedef struct WabtVar {
+ WabtLocation loc;
+ WabtVarType type;
union {
int64_t index;
- WasmStringSlice name;
+ WabtStringSlice name;
};
-} WasmVar;
-WASM_DEFINE_VECTOR(var, WasmVar);
+} WabtVar;
+WABT_DEFINE_VECTOR(var, WabtVar);
-typedef WasmStringSlice WasmLabel;
-WASM_DEFINE_VECTOR(string_slice, WasmStringSlice);
+typedef WabtStringSlice WabtLabel;
+WABT_DEFINE_VECTOR(string_slice, WabtStringSlice);
-typedef struct WasmConst {
- WasmLocation loc;
- WasmType type;
+typedef struct WabtConst {
+ WabtLocation loc;
+ WabtType type;
union {
uint32_t u32;
uint64_t u64;
uint32_t f32_bits;
uint64_t f64_bits;
};
-} WasmConst;
-WASM_DEFINE_VECTOR(const, WasmConst);
-
-typedef enum WasmExprType {
- WASM_EXPR_TYPE_BINARY,
- WASM_EXPR_TYPE_BLOCK,
- WASM_EXPR_TYPE_BR,
- WASM_EXPR_TYPE_BR_IF,
- WASM_EXPR_TYPE_BR_TABLE,
- WASM_EXPR_TYPE_CALL,
- WASM_EXPR_TYPE_CALL_INDIRECT,
- WASM_EXPR_TYPE_COMPARE,
- WASM_EXPR_TYPE_CONST,
- WASM_EXPR_TYPE_CONVERT,
- WASM_EXPR_TYPE_CURRENT_MEMORY,
- WASM_EXPR_TYPE_DROP,
- WASM_EXPR_TYPE_GET_GLOBAL,
- WASM_EXPR_TYPE_GET_LOCAL,
- WASM_EXPR_TYPE_GROW_MEMORY,
- WASM_EXPR_TYPE_IF,
- WASM_EXPR_TYPE_LOAD,
- WASM_EXPR_TYPE_LOOP,
- WASM_EXPR_TYPE_NOP,
- WASM_EXPR_TYPE_RETURN,
- WASM_EXPR_TYPE_SELECT,
- WASM_EXPR_TYPE_SET_GLOBAL,
- WASM_EXPR_TYPE_SET_LOCAL,
- WASM_EXPR_TYPE_STORE,
- WASM_EXPR_TYPE_TEE_LOCAL,
- WASM_EXPR_TYPE_UNARY,
- WASM_EXPR_TYPE_UNREACHABLE,
-} WasmExprType;
-
-typedef WasmTypeVector WasmBlockSignature;
-
-typedef struct WasmBlock {
- WasmLabel label;
- WasmBlockSignature sig;
- struct WasmExpr* first;
-} WasmBlock;
-
-typedef struct WasmExpr WasmExpr;
-struct WasmExpr {
- WasmLocation loc;
- WasmExprType type;
- WasmExpr* next;
+} WabtConst;
+WABT_DEFINE_VECTOR(const, WabtConst);
+
+typedef enum WabtExprType {
+ WABT_EXPR_TYPE_BINARY,
+ WABT_EXPR_TYPE_BLOCK,
+ WABT_EXPR_TYPE_BR,
+ WABT_EXPR_TYPE_BR_IF,
+ WABT_EXPR_TYPE_BR_TABLE,
+ WABT_EXPR_TYPE_CALL,
+ WABT_EXPR_TYPE_CALL_INDIRECT,
+ WABT_EXPR_TYPE_COMPARE,
+ WABT_EXPR_TYPE_CONST,
+ WABT_EXPR_TYPE_CONVERT,
+ WABT_EXPR_TYPE_CURRENT_MEMORY,
+ WABT_EXPR_TYPE_DROP,
+ WABT_EXPR_TYPE_GET_GLOBAL,
+ WABT_EXPR_TYPE_GET_LOCAL,
+ WABT_EXPR_TYPE_GROW_MEMORY,
+ WABT_EXPR_TYPE_IF,
+ WABT_EXPR_TYPE_LOAD,
+ WABT_EXPR_TYPE_LOOP,
+ WABT_EXPR_TYPE_NOP,
+ WABT_EXPR_TYPE_RETURN,
+ WABT_EXPR_TYPE_SELECT,
+ WABT_EXPR_TYPE_SET_GLOBAL,
+ WABT_EXPR_TYPE_SET_LOCAL,
+ WABT_EXPR_TYPE_STORE,
+ WABT_EXPR_TYPE_TEE_LOCAL,
+ WABT_EXPR_TYPE_UNARY,
+ WABT_EXPR_TYPE_UNREACHABLE,
+} WabtExprType;
+
+typedef WabtTypeVector WabtBlockSignature;
+
+typedef struct WabtBlock {
+ WabtLabel label;
+ WabtBlockSignature sig;
+ struct WabtExpr* first;
+} WabtBlock;
+
+typedef struct WabtExpr WabtExpr;
+struct WabtExpr {
+ WabtLocation loc;
+ WabtExprType type;
+ WabtExpr* next;
union {
- struct { WasmOpcode opcode; } binary, compare, convert, unary;
- WasmBlock block, loop;
- struct { WasmVar var; } br, br_if;
- struct { WasmVarVector targets; WasmVar default_target; } br_table;
- struct { WasmVar var; } call, call_indirect;
- WasmConst const_;
- struct { WasmVar var; } get_global, set_global;
- struct { WasmVar var; } get_local, set_local, tee_local;
- struct { WasmBlock true_; struct WasmExpr* false_; } if_;
- struct { WasmOpcode opcode; uint32_t align; uint64_t offset; } load, store;
+ struct { WabtOpcode opcode; } binary, compare, convert, unary;
+ WabtBlock block, loop;
+ struct { WabtVar var; } br, br_if;
+ struct { WabtVarVector targets; WabtVar default_target; } br_table;
+ struct { WabtVar var; } call, call_indirect;
+ WabtConst const_;
+ struct { WabtVar var; } get_global, set_global;
+ struct { WabtVar var; } get_local, set_local, tee_local;
+ struct { WabtBlock true_; struct WabtExpr* false_; } if_;
+ struct { WabtOpcode opcode; uint32_t align; uint64_t offset; } load, store;
};
};
-typedef struct WasmFuncSignature {
- WasmTypeVector param_types;
- WasmTypeVector result_types;
-} WasmFuncSignature;
+typedef struct WabtFuncSignature {
+ WabtTypeVector param_types;
+ WabtTypeVector result_types;
+} WabtFuncSignature;
-typedef struct WasmFuncType {
- WasmStringSlice name;
- WasmFuncSignature sig;
-} WasmFuncType;
-typedef WasmFuncType* WasmFuncTypePtr;
-WASM_DEFINE_VECTOR(func_type_ptr, WasmFuncTypePtr);
+typedef struct WabtFuncType {
+ WabtStringSlice name;
+ WabtFuncSignature sig;
+} WabtFuncType;
+typedef WabtFuncType* WabtFuncTypePtr;
+WABT_DEFINE_VECTOR(func_type_ptr, WabtFuncTypePtr);
enum {
- WASM_FUNC_DECLARATION_FLAG_HAS_FUNC_TYPE = 1,
+ WABT_FUNC_DECLARATION_FLAG_HAS_FUNC_TYPE = 1,
/* set if the signature is owned by module */
- WASM_FUNC_DECLARATION_FLAG_SHARED_SIGNATURE = 2,
+ WABT_FUNC_DECLARATION_FLAG_SHARED_SIGNATURE = 2,
};
-typedef uint32_t WasmFuncDeclarationFlags;
-
-typedef struct WasmFuncDeclaration {
- WasmFuncDeclarationFlags flags;
- WasmVar type_var;
- WasmFuncSignature sig;
-} WasmFuncDeclaration;
-
-typedef struct WasmFunc {
- WasmStringSlice name;
- WasmFuncDeclaration decl;
- WasmTypeVector local_types;
- WasmBindingHash param_bindings;
- WasmBindingHash local_bindings;
- WasmExpr* first_expr;
-} WasmFunc;
-typedef WasmFunc* WasmFuncPtr;
-WASM_DEFINE_VECTOR(func_ptr, WasmFuncPtr);
-
-typedef struct WasmGlobal {
- WasmStringSlice name;
- WasmType type;
- WasmBool mutable_;
- WasmExpr* init_expr;
-} WasmGlobal;
-typedef WasmGlobal* WasmGlobalPtr;
-WASM_DEFINE_VECTOR(global_ptr, WasmGlobalPtr);
-
-typedef struct WasmTable {
- WasmStringSlice name;
- WasmLimits elem_limits;
-} WasmTable;
-typedef WasmTable* WasmTablePtr;
-WASM_DEFINE_VECTOR(table_ptr, WasmTablePtr);
-
-typedef struct WasmElemSegment {
- WasmVar table_var;
- WasmExpr* offset;
- WasmVarVector vars;
-} WasmElemSegment;
-typedef WasmElemSegment* WasmElemSegmentPtr;
-WASM_DEFINE_VECTOR(elem_segment_ptr, WasmElemSegmentPtr);
-
-typedef struct WasmMemory {
- WasmStringSlice name;
- WasmLimits page_limits;
-} WasmMemory;
-typedef WasmMemory* WasmMemoryPtr;
-WASM_DEFINE_VECTOR(memory_ptr, WasmMemoryPtr);
-
-typedef struct WasmDataSegment {
- WasmVar memory_var;
- WasmExpr* offset;
+typedef uint32_t WabtFuncDeclarationFlags;
+
+typedef struct WabtFuncDeclaration {
+ WabtFuncDeclarationFlags flags;
+ WabtVar type_var;
+ WabtFuncSignature sig;
+} WabtFuncDeclaration;
+
+typedef struct WabtFunc {
+ WabtStringSlice name;
+ WabtFuncDeclaration decl;
+ WabtTypeVector local_types;
+ WabtBindingHash param_bindings;
+ WabtBindingHash local_bindings;
+ WabtExpr* first_expr;
+} WabtFunc;
+typedef WabtFunc* WabtFuncPtr;
+WABT_DEFINE_VECTOR(func_ptr, WabtFuncPtr);
+
+typedef struct WabtGlobal {
+ WabtStringSlice name;
+ WabtType type;
+ WabtBool mutable_;
+ WabtExpr* init_expr;
+} WabtGlobal;
+typedef WabtGlobal* WabtGlobalPtr;
+WABT_DEFINE_VECTOR(global_ptr, WabtGlobalPtr);
+
+typedef struct WabtTable {
+ WabtStringSlice name;
+ WabtLimits elem_limits;
+} WabtTable;
+typedef WabtTable* WabtTablePtr;
+WABT_DEFINE_VECTOR(table_ptr, WabtTablePtr);
+
+typedef struct WabtElemSegment {
+ WabtVar table_var;
+ WabtExpr* offset;
+ WabtVarVector vars;
+} WabtElemSegment;
+typedef WabtElemSegment* WabtElemSegmentPtr;
+WABT_DEFINE_VECTOR(elem_segment_ptr, WabtElemSegmentPtr);
+
+typedef struct WabtMemory {
+ WabtStringSlice name;
+ WabtLimits page_limits;
+} WabtMemory;
+typedef WabtMemory* WabtMemoryPtr;
+WABT_DEFINE_VECTOR(memory_ptr, WabtMemoryPtr);
+
+typedef struct WabtDataSegment {
+ WabtVar memory_var;
+ WabtExpr* offset;
void* data;
size_t size;
-} WasmDataSegment;
-typedef WasmDataSegment* WasmDataSegmentPtr;
-WASM_DEFINE_VECTOR(data_segment_ptr, WasmDataSegmentPtr);
-
-typedef struct WasmImport {
- WasmStringSlice module_name;
- WasmStringSlice field_name;
- WasmExternalKind kind;
+} WabtDataSegment;
+typedef WabtDataSegment* WabtDataSegmentPtr;
+WABT_DEFINE_VECTOR(data_segment_ptr, WabtDataSegmentPtr);
+
+typedef struct WabtImport {
+ WabtStringSlice module_name;
+ WabtStringSlice field_name;
+ WabtExternalKind kind;
union {
- /* an imported func is has the type WasmFunc so it can be more easily
+ /* an imported func is has the type WabtFunc so it can be more easily
* included in the Module's vector of funcs; but only the
- * WasmFuncDeclaration will have any useful information */
- WasmFunc func;
- WasmTable table;
- WasmMemory memory;
- WasmGlobal global;
+ * WabtFuncDeclaration will have any useful information */
+ WabtFunc func;
+ WabtTable table;
+ WabtMemory memory;
+ WabtGlobal global;
};
-} WasmImport;
-typedef WasmImport* WasmImportPtr;
-WASM_DEFINE_VECTOR(import_ptr, WasmImportPtr);
-
-typedef struct WasmExport {
- WasmStringSlice name;
- WasmExternalKind kind;
- WasmVar var;
-} WasmExport;
-typedef WasmExport* WasmExportPtr;
-WASM_DEFINE_VECTOR(export_ptr, WasmExportPtr);
-
-typedef enum WasmModuleFieldType {
- WASM_MODULE_FIELD_TYPE_FUNC,
- WASM_MODULE_FIELD_TYPE_GLOBAL,
- WASM_MODULE_FIELD_TYPE_IMPORT,
- WASM_MODULE_FIELD_TYPE_EXPORT,
- WASM_MODULE_FIELD_TYPE_FUNC_TYPE,
- WASM_MODULE_FIELD_TYPE_TABLE,
- WASM_MODULE_FIELD_TYPE_ELEM_SEGMENT,
- WASM_MODULE_FIELD_TYPE_MEMORY,
- WASM_MODULE_FIELD_TYPE_DATA_SEGMENT,
- WASM_MODULE_FIELD_TYPE_START,
-} WasmModuleFieldType;
-
-typedef struct WasmModuleField {
- WasmLocation loc;
- WasmModuleFieldType type;
- struct WasmModuleField* next;
+} WabtImport;
+typedef WabtImport* WabtImportPtr;
+WABT_DEFINE_VECTOR(import_ptr, WabtImportPtr);
+
+typedef struct WabtExport {
+ WabtStringSlice name;
+ WabtExternalKind kind;
+ WabtVar var;
+} WabtExport;
+typedef WabtExport* WabtExportPtr;
+WABT_DEFINE_VECTOR(export_ptr, WabtExportPtr);
+
+typedef enum WabtModuleFieldType {
+ WABT_MODULE_FIELD_TYPE_FUNC,
+ WABT_MODULE_FIELD_TYPE_GLOBAL,
+ WABT_MODULE_FIELD_TYPE_IMPORT,
+ WABT_MODULE_FIELD_TYPE_EXPORT,
+ WABT_MODULE_FIELD_TYPE_FUNC_TYPE,
+ WABT_MODULE_FIELD_TYPE_TABLE,
+ WABT_MODULE_FIELD_TYPE_ELEM_SEGMENT,
+ WABT_MODULE_FIELD_TYPE_MEMORY,
+ WABT_MODULE_FIELD_TYPE_DATA_SEGMENT,
+ WABT_MODULE_FIELD_TYPE_START,
+} WabtModuleFieldType;
+
+typedef struct WabtModuleField {
+ WabtLocation loc;
+ WabtModuleFieldType type;
+ struct WabtModuleField* next;
union {
- WasmFunc func;
- WasmGlobal global;
- WasmImport import;
- WasmExport export_;
- WasmFuncType func_type;
- WasmTable table;
- WasmElemSegment elem_segment;
- WasmMemory memory;
- WasmDataSegment data_segment;
- WasmVar start;
+ WabtFunc func;
+ WabtGlobal global;
+ WabtImport import;
+ WabtExport export_;
+ WabtFuncType func_type;
+ WabtTable table;
+ WabtElemSegment elem_segment;
+ WabtMemory memory;
+ WabtDataSegment data_segment;
+ WabtVar start;
};
-} WasmModuleField;
+} WabtModuleField;
-typedef struct WasmModule {
- WasmLocation loc;
- WasmStringSlice name;
- WasmModuleField* first_field;
- WasmModuleField* last_field;
+typedef struct WabtModule {
+ WabtLocation loc;
+ WabtStringSlice name;
+ WabtModuleField* first_field;
+ WabtModuleField* last_field;
uint32_t num_func_imports;
uint32_t num_table_imports;
@@ -257,343 +257,343 @@ typedef struct WasmModule {
uint32_t num_global_imports;
/* cached for convenience; the pointers are shared with values that are
- * stored in either WasmModuleField or WasmImport. */
- WasmFuncPtrVector funcs;
- WasmGlobalPtrVector globals;
- WasmImportPtrVector imports;
- WasmExportPtrVector exports;
- WasmFuncTypePtrVector func_types;
- WasmTablePtrVector tables;
- WasmElemSegmentPtrVector elem_segments;
- WasmMemoryPtrVector memories;
- WasmDataSegmentPtrVector data_segments;
- WasmVar* start;
-
- WasmBindingHash func_bindings;
- WasmBindingHash global_bindings;
- WasmBindingHash export_bindings;
- WasmBindingHash func_type_bindings;
- WasmBindingHash table_bindings;
- WasmBindingHash memory_bindings;
-} WasmModule;
-
-typedef enum WasmRawModuleType {
- WASM_RAW_MODULE_TYPE_TEXT,
- WASM_RAW_MODULE_TYPE_BINARY,
-} WasmRawModuleType;
+ * stored in either WabtModuleField or WabtImport. */
+ WabtFuncPtrVector funcs;
+ WabtGlobalPtrVector globals;
+ WabtImportPtrVector imports;
+ WabtExportPtrVector exports;
+ WabtFuncTypePtrVector func_types;
+ WabtTablePtrVector tables;
+ WabtElemSegmentPtrVector elem_segments;
+ WabtMemoryPtrVector memories;
+ WabtDataSegmentPtrVector data_segments;
+ WabtVar* start;
+
+ WabtBindingHash func_bindings;
+ WabtBindingHash global_bindings;
+ WabtBindingHash export_bindings;
+ WabtBindingHash func_type_bindings;
+ WabtBindingHash table_bindings;
+ WabtBindingHash memory_bindings;
+} WabtModule;
+
+typedef enum WabtRawModuleType {
+ WABT_RAW_MODULE_TYPE_TEXT,
+ WABT_RAW_MODULE_TYPE_BINARY,
+} WabtRawModuleType;
/* "raw" means that the binary module has not yet been decoded. This is only
* necessary when embedded in assert_invalid. In that case we want to defer
- * decoding errors until wasm_check_assert_invalid is called. This isn't needed
+ * decoding errors until wabt_check_assert_invalid is called. This isn't needed
* when parsing text, as assert_invalid always assumes that text parsing
* succeeds. */
-typedef struct WasmRawModule {
- WasmRawModuleType type;
+typedef struct WabtRawModule {
+ WabtRawModuleType type;
union {
- WasmModule* text;
+ WabtModule* text;
struct {
- WasmLocation loc;
- WasmStringSlice name;
+ WabtLocation loc;
+ WabtStringSlice name;
void* data;
size_t size;
} binary;
};
-} WasmRawModule;
-
-typedef enum WasmActionType {
- WASM_ACTION_TYPE_INVOKE,
- WASM_ACTION_TYPE_GET,
-} WasmActionType;
-
-typedef struct WasmActionInvoke {
- WasmStringSlice name;
- WasmConstVector args;
-} WasmActionInvoke;
-
-typedef struct WasmActionGet {
- WasmStringSlice name;
-} WasmActionGet;
-
-typedef struct WasmAction {
- WasmLocation loc;
- WasmActionType type;
- WasmVar module_var;
+} WabtRawModule;
+
+typedef enum WabtActionType {
+ WABT_ACTION_TYPE_INVOKE,
+ WABT_ACTION_TYPE_GET,
+} WabtActionType;
+
+typedef struct WabtActionInvoke {
+ WabtStringSlice name;
+ WabtConstVector args;
+} WabtActionInvoke;
+
+typedef struct WabtActionGet {
+ WabtStringSlice name;
+} WabtActionGet;
+
+typedef struct WabtAction {
+ WabtLocation loc;
+ WabtActionType type;
+ WabtVar module_var;
union {
- WasmActionInvoke invoke;
- WasmActionGet get;
+ WabtActionInvoke invoke;
+ WabtActionGet get;
};
-} WasmAction;
-
-typedef enum WasmCommandType {
- WASM_COMMAND_TYPE_MODULE,
- WASM_COMMAND_TYPE_ACTION,
- WASM_COMMAND_TYPE_REGISTER,
- WASM_COMMAND_TYPE_ASSERT_MALFORMED,
- WASM_COMMAND_TYPE_ASSERT_INVALID,
+} WabtAction;
+
+typedef enum WabtCommandType {
+ WABT_COMMAND_TYPE_MODULE,
+ WABT_COMMAND_TYPE_ACTION,
+ WABT_COMMAND_TYPE_REGISTER,
+ WABT_COMMAND_TYPE_ASSERT_MALFORMED,
+ WABT_COMMAND_TYPE_ASSERT_INVALID,
/* This is a module that is invalid, but cannot be written as a binary module
* (e.g. it has unresolvable names.) */
- WASM_COMMAND_TYPE_ASSERT_INVALID_NON_BINARY,
- WASM_COMMAND_TYPE_ASSERT_UNLINKABLE,
- WASM_COMMAND_TYPE_ASSERT_UNINSTANTIABLE,
- WASM_COMMAND_TYPE_ASSERT_RETURN,
- WASM_COMMAND_TYPE_ASSERT_RETURN_NAN,
- WASM_COMMAND_TYPE_ASSERT_TRAP,
- WASM_COMMAND_TYPE_ASSERT_EXHAUSTION,
- WASM_NUM_COMMAND_TYPES,
-} WasmCommandType;
-
-typedef struct WasmCommand {
- WasmCommandType type;
+ WABT_COMMAND_TYPE_ASSERT_INVALID_NON_BINARY,
+ WABT_COMMAND_TYPE_ASSERT_UNLINKABLE,
+ WABT_COMMAND_TYPE_ASSERT_UNINSTANTIABLE,
+ WABT_COMMAND_TYPE_ASSERT_RETURN,
+ WABT_COMMAND_TYPE_ASSERT_RETURN_NAN,
+ WABT_COMMAND_TYPE_ASSERT_TRAP,
+ WABT_COMMAND_TYPE_ASSERT_EXHAUSTION,
+ WABT_NUM_COMMAND_TYPES,
+} WabtCommandType;
+
+typedef struct WabtCommand {
+ WabtCommandType type;
union {
- WasmModule module;
- WasmAction action;
- struct { WasmStringSlice module_name; WasmVar var; } register_;
- struct { WasmAction action; WasmConstVector expected; } assert_return;
- struct { WasmAction action; } assert_return_nan;
- struct { WasmAction action; WasmStringSlice text; } assert_trap;
+ WabtModule module;
+ WabtAction action;
+ struct { WabtStringSlice module_name; WabtVar var; } register_;
+ struct { WabtAction action; WabtConstVector expected; } assert_return;
+ struct { WabtAction action; } assert_return_nan;
+ struct { WabtAction action; WabtStringSlice text; } assert_trap;
struct {
- WasmRawModule module;
- WasmStringSlice text;
+ WabtRawModule module;
+ WabtStringSlice text;
} assert_malformed, assert_invalid, assert_unlinkable,
assert_uninstantiable;
};
-} WasmCommand;
-WASM_DEFINE_VECTOR(command, WasmCommand);
+} WabtCommand;
+WABT_DEFINE_VECTOR(command, WabtCommand);
-typedef struct WasmScript {
- struct WasmAllocator* allocator;
- WasmCommandVector commands;
- WasmBindingHash module_bindings;
-} WasmScript;
+typedef struct WabtScript {
+ struct WabtAllocator* allocator;
+ WabtCommandVector commands;
+ WabtBindingHash module_bindings;
+} WabtScript;
-typedef struct WasmExprVisitor {
+typedef struct WabtExprVisitor {
void* user_data;
- WasmResult (*on_binary_expr)(WasmExpr*, void* user_data);
- WasmResult (*begin_block_expr)(WasmExpr*, void* user_data);
- WasmResult (*end_block_expr)(WasmExpr*, void* user_data);
- WasmResult (*on_br_expr)(WasmExpr*, void* user_data);
- WasmResult (*on_br_if_expr)(WasmExpr*, void* user_data);
- WasmResult (*on_br_table_expr)(WasmExpr*, void* user_data);
- WasmResult (*on_call_expr)(WasmExpr*, void* user_data);
- WasmResult (*on_call_indirect_expr)(WasmExpr*, void* user_data);
- WasmResult (*on_compare_expr)(WasmExpr*, void* user_data);
- WasmResult (*on_const_expr)(WasmExpr*, void* user_data);
- WasmResult (*on_convert_expr)(WasmExpr*, void* user_data);
- WasmResult (*on_current_memory_expr)(WasmExpr*, void* user_data);
- WasmResult (*on_drop_expr)(WasmExpr*, void* user_data);
- WasmResult (*on_get_global_expr)(WasmExpr*, void* user_data);
- WasmResult (*on_get_local_expr)(WasmExpr*, void* user_data);
- WasmResult (*on_grow_memory_expr)(WasmExpr*, void* user_data);
- WasmResult (*begin_if_expr)(WasmExpr*, void* user_data);
- WasmResult (*after_if_true_expr)(WasmExpr*, void* user_data);
- WasmResult (*end_if_expr)(WasmExpr*, void* user_data);
- WasmResult (*on_load_expr)(WasmExpr*, void* user_data);
- WasmResult (*begin_loop_expr)(WasmExpr*, void* user_data);
- WasmResult (*end_loop_expr)(WasmExpr*, void* user_data);
- WasmResult (*on_nop_expr)(WasmExpr*, void* user_data);
- WasmResult (*on_return_expr)(WasmExpr*, void* user_data);
- WasmResult (*on_select_expr)(WasmExpr*, void* user_data);
- WasmResult (*on_set_global_expr)(WasmExpr*, void* user_data);
- WasmResult (*on_set_local_expr)(WasmExpr*, void* user_data);
- WasmResult (*on_store_expr)(WasmExpr*, void* user_data);
- WasmResult (*on_tee_local_expr)(WasmExpr*, void* user_data);
- WasmResult (*on_unary_expr)(WasmExpr*, void* user_data);
- WasmResult (*on_unreachable_expr)(WasmExpr*, void* user_data);
-} WasmExprVisitor;
-
-WASM_EXTERN_C_BEGIN
-WasmModuleField* wasm_append_module_field(struct WasmAllocator*, WasmModule*);
+ WabtResult (*on_binary_expr)(WabtExpr*, void* user_data);
+ WabtResult (*begin_block_expr)(WabtExpr*, void* user_data);
+ WabtResult (*end_block_expr)(WabtExpr*, void* user_data);
+ WabtResult (*on_br_expr)(WabtExpr*, void* user_data);
+ WabtResult (*on_br_if_expr)(WabtExpr*, void* user_data);
+ WabtResult (*on_br_table_expr)(WabtExpr*, void* user_data);
+ WabtResult (*on_call_expr)(WabtExpr*, void* user_data);
+ WabtResult (*on_call_indirect_expr)(WabtExpr*, void* user_data);
+ WabtResult (*on_compare_expr)(WabtExpr*, void* user_data);
+ WabtResult (*on_const_expr)(WabtExpr*, void* user_data);
+ WabtResult (*on_convert_expr)(WabtExpr*, void* user_data);
+ WabtResult (*on_current_memory_expr)(WabtExpr*, void* user_data);
+ WabtResult (*on_drop_expr)(WabtExpr*, void* user_data);
+ WabtResult (*on_get_global_expr)(WabtExpr*, void* user_data);
+ WabtResult (*on_get_local_expr)(WabtExpr*, void* user_data);
+ WabtResult (*on_grow_memory_expr)(WabtExpr*, void* user_data);
+ WabtResult (*begin_if_expr)(WabtExpr*, void* user_data);
+ WabtResult (*after_if_true_expr)(WabtExpr*, void* user_data);
+ WabtResult (*end_if_expr)(WabtExpr*, void* user_data);
+ WabtResult (*on_load_expr)(WabtExpr*, void* user_data);
+ WabtResult (*begin_loop_expr)(WabtExpr*, void* user_data);
+ WabtResult (*end_loop_expr)(WabtExpr*, void* user_data);
+ WabtResult (*on_nop_expr)(WabtExpr*, void* user_data);
+ WabtResult (*on_return_expr)(WabtExpr*, void* user_data);
+ WabtResult (*on_select_expr)(WabtExpr*, void* user_data);
+ WabtResult (*on_set_global_expr)(WabtExpr*, void* user_data);
+ WabtResult (*on_set_local_expr)(WabtExpr*, void* user_data);
+ WabtResult (*on_store_expr)(WabtExpr*, void* user_data);
+ WabtResult (*on_tee_local_expr)(WabtExpr*, void* user_data);
+ WabtResult (*on_unary_expr)(WabtExpr*, void* user_data);
+ WabtResult (*on_unreachable_expr)(WabtExpr*, void* user_data);
+} WabtExprVisitor;
+
+WABT_EXTERN_C_BEGIN
+WabtModuleField* wabt_append_module_field(struct WabtAllocator*, WabtModule*);
/* ownership of the function signature is passed to the module */
-WasmFuncType* wasm_append_implicit_func_type(struct WasmAllocator*,
- WasmLocation*,
- WasmModule*,
- WasmFuncSignature*);
-
-/* WasmExpr creation functions */
-WasmExpr* wasm_new_binary_expr(struct WasmAllocator*);
-WasmExpr* wasm_new_block_expr(struct WasmAllocator*);
-WasmExpr* wasm_new_br_expr(struct WasmAllocator*);
-WasmExpr* wasm_new_br_if_expr(struct WasmAllocator*);
-WasmExpr* wasm_new_br_table_expr(struct WasmAllocator*);
-WasmExpr* wasm_new_call_expr(struct WasmAllocator*);
-WasmExpr* wasm_new_call_indirect_expr(struct WasmAllocator*);
-WasmExpr* wasm_new_compare_expr(struct WasmAllocator*);
-WasmExpr* wasm_new_const_expr(struct WasmAllocator*);
-WasmExpr* wasm_new_convert_expr(struct WasmAllocator*);
-WasmExpr* wasm_new_current_memory_expr(struct WasmAllocator*);
-WasmExpr* wasm_new_drop_expr(struct WasmAllocator*);
-WasmExpr* wasm_new_get_global_expr(struct WasmAllocator*);
-WasmExpr* wasm_new_get_local_expr(struct WasmAllocator*);
-WasmExpr* wasm_new_grow_memory_expr(struct WasmAllocator*);
-WasmExpr* wasm_new_if_expr(struct WasmAllocator*);
-WasmExpr* wasm_new_load_expr(struct WasmAllocator*);
-WasmExpr* wasm_new_loop_expr(struct WasmAllocator*);
-WasmExpr* wasm_new_nop_expr(struct WasmAllocator*);
-WasmExpr* wasm_new_return_expr(struct WasmAllocator*);
-WasmExpr* wasm_new_select_expr(struct WasmAllocator*);
-WasmExpr* wasm_new_set_global_expr(struct WasmAllocator*);
-WasmExpr* wasm_new_set_local_expr(struct WasmAllocator*);
-WasmExpr* wasm_new_store_expr(struct WasmAllocator*);
-WasmExpr* wasm_new_tee_local_expr(struct WasmAllocator*);
-WasmExpr* wasm_new_unary_expr(struct WasmAllocator*);
-WasmExpr* wasm_new_unreachable_expr(struct WasmAllocator*);
+WabtFuncType* wabt_append_implicit_func_type(struct WabtAllocator*,
+ WabtLocation*,
+ WabtModule*,
+ WabtFuncSignature*);
+
+/* WabtExpr creation functions */
+WabtExpr* wabt_new_binary_expr(struct WabtAllocator*);
+WabtExpr* wabt_new_block_expr(struct WabtAllocator*);
+WabtExpr* wabt_new_br_expr(struct WabtAllocator*);
+WabtExpr* wabt_new_br_if_expr(struct WabtAllocator*);
+WabtExpr* wabt_new_br_table_expr(struct WabtAllocator*);
+WabtExpr* wabt_new_call_expr(struct WabtAllocator*);
+WabtExpr* wabt_new_call_indirect_expr(struct WabtAllocator*);
+WabtExpr* wabt_new_compare_expr(struct WabtAllocator*);
+WabtExpr* wabt_new_const_expr(struct WabtAllocator*);
+WabtExpr* wabt_new_convert_expr(struct WabtAllocator*);
+WabtExpr* wabt_new_current_memory_expr(struct WabtAllocator*);
+WabtExpr* wabt_new_drop_expr(struct WabtAllocator*);
+WabtExpr* wabt_new_get_global_expr(struct WabtAllocator*);
+WabtExpr* wabt_new_get_local_expr(struct WabtAllocator*);
+WabtExpr* wabt_new_grow_memory_expr(struct WabtAllocator*);
+WabtExpr* wabt_new_if_expr(struct WabtAllocator*);
+WabtExpr* wabt_new_load_expr(struct WabtAllocator*);
+WabtExpr* wabt_new_loop_expr(struct WabtAllocator*);
+WabtExpr* wabt_new_nop_expr(struct WabtAllocator*);
+WabtExpr* wabt_new_return_expr(struct WabtAllocator*);
+WabtExpr* wabt_new_select_expr(struct WabtAllocator*);
+WabtExpr* wabt_new_set_global_expr(struct WabtAllocator*);
+WabtExpr* wabt_new_set_local_expr(struct WabtAllocator*);
+WabtExpr* wabt_new_store_expr(struct WabtAllocator*);
+WabtExpr* wabt_new_tee_local_expr(struct WabtAllocator*);
+WabtExpr* wabt_new_unary_expr(struct WabtAllocator*);
+WabtExpr* wabt_new_unreachable_expr(struct WabtAllocator*);
/* destruction functions. not needed unless you're creating your own AST
elements */
-void wasm_destroy_script(struct WasmScript*);
-void wasm_destroy_action(struct WasmAllocator*, struct WasmAction*);
-void wasm_destroy_block(struct WasmAllocator*, struct WasmBlock*);
-void wasm_destroy_command_vector_and_elements(struct WasmAllocator*,
- WasmCommandVector*);
-void wasm_destroy_command(struct WasmAllocator*, WasmCommand*);
-void wasm_destroy_data_segment(struct WasmAllocator*, WasmDataSegment*);
-void wasm_destroy_elem_segment(struct WasmAllocator*, WasmElemSegment*);
-void wasm_destroy_export(struct WasmAllocator*, WasmExport*);
-void wasm_destroy_expr(struct WasmAllocator*, WasmExpr*);
-void wasm_destroy_expr_list(struct WasmAllocator*, WasmExpr*);
-void wasm_destroy_func_declaration(struct WasmAllocator*, WasmFuncDeclaration*);
-void wasm_destroy_func_signature(struct WasmAllocator*, WasmFuncSignature*);
-void wasm_destroy_func_type(struct WasmAllocator*, WasmFuncType*);
-void wasm_destroy_func(struct WasmAllocator*, WasmFunc*);
-void wasm_destroy_import(struct WasmAllocator*, WasmImport*);
-void wasm_destroy_memory(struct WasmAllocator*, WasmMemory*);
-void wasm_destroy_module(struct WasmAllocator*, WasmModule*);
-void wasm_destroy_raw_module(struct WasmAllocator*, WasmRawModule*);
-void wasm_destroy_table(struct WasmAllocator*, WasmTable*);
-void wasm_destroy_var_vector_and_elements(struct WasmAllocator*,
- WasmVarVector*);
-void wasm_destroy_var(struct WasmAllocator*, WasmVar*);
+void wabt_destroy_script(struct WabtScript*);
+void wabt_destroy_action(struct WabtAllocator*, struct WabtAction*);
+void wabt_destroy_block(struct WabtAllocator*, struct WabtBlock*);
+void wabt_destroy_command_vector_and_elements(struct WabtAllocator*,
+ WabtCommandVector*);
+void wabt_destroy_command(struct WabtAllocator*, WabtCommand*);
+void wabt_destroy_data_segment(struct WabtAllocator*, WabtDataSegment*);
+void wabt_destroy_elem_segment(struct WabtAllocator*, WabtElemSegment*);
+void wabt_destroy_export(struct WabtAllocator*, WabtExport*);
+void wabt_destroy_expr(struct WabtAllocator*, WabtExpr*);
+void wabt_destroy_expr_list(struct WabtAllocator*, WabtExpr*);
+void wabt_destroy_func_declaration(struct WabtAllocator*, WabtFuncDeclaration*);
+void wabt_destroy_func_signature(struct WabtAllocator*, WabtFuncSignature*);
+void wabt_destroy_func_type(struct WabtAllocator*, WabtFuncType*);
+void wabt_destroy_func(struct WabtAllocator*, WabtFunc*);
+void wabt_destroy_import(struct WabtAllocator*, WabtImport*);
+void wabt_destroy_memory(struct WabtAllocator*, WabtMemory*);
+void wabt_destroy_module(struct WabtAllocator*, WabtModule*);
+void wabt_destroy_raw_module(struct WabtAllocator*, WabtRawModule*);
+void wabt_destroy_table(struct WabtAllocator*, WabtTable*);
+void wabt_destroy_var_vector_and_elements(struct WabtAllocator*,
+ WabtVarVector*);
+void wabt_destroy_var(struct WabtAllocator*, WabtVar*);
/* traversal functions */
-WasmResult wasm_visit_func(WasmFunc* func, WasmExprVisitor*);
-WasmResult wasm_visit_expr_list(WasmExpr* expr, WasmExprVisitor*);
+WabtResult wabt_visit_func(WabtFunc* func, WabtExprVisitor*);
+WabtResult wabt_visit_expr_list(WabtExpr* expr, WabtExprVisitor*);
/* convenience functions for looking through the AST */
-int wasm_get_index_from_var(const WasmBindingHash* bindings,
- const WasmVar* var);
-int wasm_get_func_index_by_var(const WasmModule* module, const WasmVar* var);
-int wasm_get_global_index_by_var(const WasmModule* func, const WasmVar* var);
-int wasm_get_func_type_index_by_var(const WasmModule* module,
- const WasmVar* var);
-int wasm_get_func_type_index_by_sig(const WasmModule* module,
- const WasmFuncSignature* sig);
-int wasm_get_func_type_index_by_decl(const WasmModule* module,
- const WasmFuncDeclaration* decl);
-int wasm_get_table_index_by_var(const WasmModule* module, const WasmVar* var);
-int wasm_get_memory_index_by_var(const WasmModule* module, const WasmVar* var);
-int wasm_get_import_index_by_var(const WasmModule* module, const WasmVar* var);
-int wasm_get_local_index_by_var(const WasmFunc* func, const WasmVar* var);
-int wasm_get_module_index_by_var(const WasmScript* script, const WasmVar* var);
-
-WasmFuncPtr wasm_get_func_by_var(const WasmModule* module, const WasmVar* var);
-WasmGlobalPtr wasm_get_global_by_var(const WasmModule* func,
- const WasmVar* var);
-WasmFuncTypePtr wasm_get_func_type_by_var(const WasmModule* module,
- const WasmVar* var);
-WasmTablePtr wasm_get_table_by_var(const WasmModule* module,
- const WasmVar* var);
-WasmMemoryPtr wasm_get_memory_by_var(const WasmModule* module,
- const WasmVar* var);
-WasmImportPtr wasm_get_import_by_var(const WasmModule* module,
- const WasmVar* var);
-WasmExportPtr wasm_get_export_by_name(const WasmModule* module,
- const WasmStringSlice* name);
-WasmModule* wasm_get_first_module(const WasmScript* script);
-WasmModule* wasm_get_module_by_var(const WasmScript* script,
- const WasmVar* var);
-
-void wasm_make_type_binding_reverse_mapping(
- struct WasmAllocator*,
- const WasmTypeVector*,
- const WasmBindingHash*,
- WasmStringSliceVector* out_reverse_mapping);
-
-typedef void (*WasmDuplicateBindingCallback)(WasmBindingHashEntry* a,
- WasmBindingHashEntry* b,
+int wabt_get_index_from_var(const WabtBindingHash* bindings,
+ const WabtVar* var);
+int wabt_get_func_index_by_var(const WabtModule* module, const WabtVar* var);
+int wabt_get_global_index_by_var(const WabtModule* func, const WabtVar* var);
+int wabt_get_func_type_index_by_var(const WabtModule* module,
+ const WabtVar* var);
+int wabt_get_func_type_index_by_sig(const WabtModule* module,
+ const WabtFuncSignature* sig);
+int wabt_get_func_type_index_by_decl(const WabtModule* module,
+ const WabtFuncDeclaration* decl);
+int wabt_get_table_index_by_var(const WabtModule* module, const WabtVar* var);
+int wabt_get_memory_index_by_var(const WabtModule* module, const WabtVar* var);
+int wabt_get_import_index_by_var(const WabtModule* module, const WabtVar* var);
+int wabt_get_local_index_by_var(const WabtFunc* func, const WabtVar* var);
+int wabt_get_module_index_by_var(const WabtScript* script, const WabtVar* var);
+
+WabtFuncPtr wabt_get_func_by_var(const WabtModule* module, const WabtVar* var);
+WabtGlobalPtr wabt_get_global_by_var(const WabtModule* func,
+ const WabtVar* var);
+WabtFuncTypePtr wabt_get_func_type_by_var(const WabtModule* module,
+ const WabtVar* var);
+WabtTablePtr wabt_get_table_by_var(const WabtModule* module,
+ const WabtVar* var);
+WabtMemoryPtr wabt_get_memory_by_var(const WabtModule* module,
+ const WabtVar* var);
+WabtImportPtr wabt_get_import_by_var(const WabtModule* module,
+ const WabtVar* var);
+WabtExportPtr wabt_get_export_by_name(const WabtModule* module,
+ const WabtStringSlice* name);
+WabtModule* wabt_get_first_module(const WabtScript* script);
+WabtModule* wabt_get_module_by_var(const WabtScript* script,
+ const WabtVar* var);
+
+void wabt_make_type_binding_reverse_mapping(
+ struct WabtAllocator*,
+ const WabtTypeVector*,
+ const WabtBindingHash*,
+ WabtStringSliceVector* out_reverse_mapping);
+
+typedef void (*WabtDuplicateBindingCallback)(WabtBindingHashEntry* a,
+ WabtBindingHashEntry* b,
void* user_data);
-void wasm_find_duplicate_bindings(const WasmBindingHash*,
- WasmDuplicateBindingCallback callback,
+void wabt_find_duplicate_bindings(const WabtBindingHash*,
+ WabtDuplicateBindingCallback callback,
void* user_data);
-static WASM_INLINE WasmBool
-wasm_decl_has_func_type(const WasmFuncDeclaration* decl) {
- return (WasmBool)((decl->flags & WASM_FUNC_DECLARATION_FLAG_HAS_FUNC_TYPE) !=
+static WABT_INLINE WabtBool
+wabt_decl_has_func_type(const WabtFuncDeclaration* decl) {
+ return (WabtBool)((decl->flags & WABT_FUNC_DECLARATION_FLAG_HAS_FUNC_TYPE) !=
0);
}
-static WASM_INLINE WasmBool
-wasm_signatures_are_equal(const WasmFuncSignature* sig1,
- const WasmFuncSignature* sig2) {
- return (WasmBool)(
- wasm_type_vectors_are_equal(&sig1->param_types, &sig2->param_types) &&
- wasm_type_vectors_are_equal(&sig1->result_types, &sig2->result_types));
+static WABT_INLINE WabtBool
+wabt_signatures_are_equal(const WabtFuncSignature* sig1,
+ const WabtFuncSignature* sig2) {
+ return (WabtBool)(
+ wabt_type_vectors_are_equal(&sig1->param_types, &sig2->param_types) &&
+ wabt_type_vectors_are_equal(&sig1->result_types, &sig2->result_types));
}
-static WASM_INLINE size_t wasm_get_num_params(const WasmFunc* func) {
+static WABT_INLINE size_t wabt_get_num_params(const WabtFunc* func) {
return func->decl.sig.param_types.size;
}
-static WASM_INLINE size_t wasm_get_num_results(const WasmFunc* func) {
+static WABT_INLINE size_t wabt_get_num_results(const WabtFunc* func) {
return func->decl.sig.result_types.size;
}
-static WASM_INLINE size_t wasm_get_num_locals(const WasmFunc* func) {
+static WABT_INLINE size_t wabt_get_num_locals(const WabtFunc* func) {
return func->local_types.size;
}
-static WASM_INLINE size_t wasm_get_num_params_and_locals(const WasmFunc* func) {
- return wasm_get_num_params(func) + wasm_get_num_locals(func);
+static WABT_INLINE size_t wabt_get_num_params_and_locals(const WabtFunc* func) {
+ return wabt_get_num_params(func) + wabt_get_num_locals(func);
}
-static WASM_INLINE WasmType wasm_get_param_type(const WasmFunc* func,
+static WABT_INLINE WabtType wabt_get_param_type(const WabtFunc* func,
int index) {
assert((size_t)index < func->decl.sig.param_types.size);
return func->decl.sig.param_types.data[index];
}
-static WASM_INLINE WasmType wasm_get_local_type(const WasmFunc* func,
+static WABT_INLINE WabtType wabt_get_local_type(const WabtFunc* func,
int index) {
- assert((size_t)index < wasm_get_num_locals(func));
+ assert((size_t)index < wabt_get_num_locals(func));
return func->local_types.data[index];
}
-static WASM_INLINE WasmType wasm_get_result_type(const WasmFunc* func,
+static WABT_INLINE WabtType wabt_get_result_type(const WabtFunc* func,
int index) {
assert((size_t)index < func->decl.sig.result_types.size);
return func->decl.sig.result_types.data[index];
}
-static WASM_INLINE WasmType
-wasm_get_func_type_param_type(const WasmFuncType* func_type, int index) {
+static WABT_INLINE WabtType
+wabt_get_func_type_param_type(const WabtFuncType* func_type, int index) {
return func_type->sig.param_types.data[index];
}
-static WASM_INLINE size_t
-wasm_get_func_type_num_params(const WasmFuncType* func_type) {
+static WABT_INLINE size_t
+wabt_get_func_type_num_params(const WabtFuncType* func_type) {
return func_type->sig.param_types.size;
}
-static WASM_INLINE WasmType
-wasm_get_func_type_result_type(const WasmFuncType* func_type, int index) {
+static WABT_INLINE WabtType
+wabt_get_func_type_result_type(const WabtFuncType* func_type, int index) {
return func_type->sig.result_types.data[index];
}
-static WASM_INLINE size_t
-wasm_get_func_type_num_results(const WasmFuncType* func_type) {
+static WABT_INLINE size_t
+wabt_get_func_type_num_results(const WabtFuncType* func_type) {
return func_type->sig.result_types.size;
}
-static WASM_INLINE const WasmLocation* wasm_get_raw_module_location(
- const WasmRawModule* raw) {
+static WABT_INLINE const WabtLocation* wabt_get_raw_module_location(
+ const WabtRawModule* raw) {
switch (raw->type) {
- case WASM_RAW_MODULE_TYPE_BINARY: return &raw->binary.loc;
- case WASM_RAW_MODULE_TYPE_TEXT: return &raw->text->loc;
+ case WABT_RAW_MODULE_TYPE_BINARY: return &raw->binary.loc;
+ case WABT_RAW_MODULE_TYPE_TEXT: return &raw->text->loc;
default:
assert(0);
return NULL;
}
}
-WASM_EXTERN_C_END
+WABT_EXTERN_C_END
-#endif /* WASM_AST_H_ */
+#endif /* WABT_AST_H_ */
diff --git a/src/binary-reader-ast.c b/src/binary-reader-ast.c
index 3295d1be..9ab3c7bc 100644
--- a/src/binary-reader-ast.c
+++ b/src/binary-reader-ast.c
@@ -29,8 +29,8 @@
#define CHECK_RESULT(expr) \
do { \
- if (WASM_FAILED(expr)) \
- return WASM_ERROR; \
+ if (WABT_FAILED(expr)) \
+ return WABT_ERROR; \
} while (0)
typedef enum LabelType {
@@ -43,82 +43,82 @@ typedef enum LabelType {
typedef struct LabelNode {
LabelType label_type;
- WasmExpr** first;
- WasmExpr* last;
+ WabtExpr** first;
+ WabtExpr* last;
} LabelNode;
-WASM_DEFINE_VECTOR(label_node, LabelNode);
+WABT_DEFINE_VECTOR(label_node, LabelNode);
typedef struct Context {
- WasmAllocator* allocator;
- WasmBinaryErrorHandler* error_handler;
- WasmModule* module;
+ WabtAllocator* allocator;
+ WabtBinaryErrorHandler* error_handler;
+ WabtModule* module;
- WasmFunc* current_func;
+ WabtFunc* current_func;
LabelNodeVector label_stack;
uint32_t max_depth;
- WasmExpr** current_init_expr;
+ WabtExpr** current_init_expr;
} Context;
static void handle_error(Context* ctx, uint32_t offset, const char* message);
-static void WASM_PRINTF_FORMAT(2, 3)
+static void WABT_PRINTF_FORMAT(2, 3)
print_error(Context* ctx, const char* format, ...) {
- WASM_SNPRINTF_ALLOCA(buffer, length, format);
- handle_error(ctx, WASM_UNKNOWN_OFFSET, buffer);
+ WABT_SNPRINTF_ALLOCA(buffer, length, format);
+ handle_error(ctx, WABT_UNKNOWN_OFFSET, buffer);
}
-static void push_label(Context* ctx, LabelType label_type, WasmExpr** first) {
+static void push_label(Context* ctx, LabelType label_type, WabtExpr** first) {
LabelNode label;
label.label_type = label_type;
label.first = first;
label.last = NULL;
ctx->max_depth++;
- wasm_append_label_node_value(ctx->allocator, &ctx->label_stack, &label);
+ wabt_append_label_node_value(ctx->allocator, &ctx->label_stack, &label);
}
-static WasmResult pop_label(Context* ctx) {
+static WabtResult pop_label(Context* ctx) {
if (ctx->label_stack.size == 0) {
print_error(ctx, "popping empty label stack");
- return WASM_ERROR;
+ return WABT_ERROR;
}
ctx->max_depth--;
ctx->label_stack.size--;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult get_label_at(Context* ctx,
+static WabtResult get_label_at(Context* ctx,
LabelNode** label,
uint32_t depth) {
if (depth >= ctx->label_stack.size) {
print_error(ctx, "accessing stack depth: %u >= max: %" PRIzd, depth,
ctx->label_stack.size);
- return WASM_ERROR;
+ return WABT_ERROR;
}
*label = &ctx->label_stack.data[ctx->label_stack.size - depth - 1];
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult top_label(Context* ctx, LabelNode** label) {
+static WabtResult top_label(Context* ctx, LabelNode** label) {
return get_label_at(ctx, label, 0);
}
static void dup_name(Context* ctx,
- WasmStringSlice* name,
- WasmStringSlice* out_name) {
+ WabtStringSlice* name,
+ WabtStringSlice* out_name) {
if (name->length > 0) {
- *out_name = wasm_dup_string_slice(ctx->allocator, *name);
+ *out_name = wabt_dup_string_slice(ctx->allocator, *name);
} else {
- WASM_ZERO_MEMORY(*out_name);
+ WABT_ZERO_MEMORY(*out_name);
}
}
-static WasmResult append_expr(Context* ctx, WasmExpr* expr) {
+static WabtResult append_expr(Context* ctx, WabtExpr* expr) {
LabelNode* label;
- if (WASM_FAILED(top_label(ctx, &label))) {
- wasm_free(ctx->allocator, expr);
- return WASM_ERROR;
+ if (WABT_FAILED(top_label(ctx, &label))) {
+ wabt_free(ctx->allocator, expr);
+ return WABT_ERROR;
}
if (*label->first) {
label->last->next = expr;
@@ -126,7 +126,7 @@ static WasmResult append_expr(Context* ctx, WasmExpr* expr) {
} else {
*label->first = label->last = expr;
}
- return WASM_OK;
+ return WABT_OK;
}
static void handle_error(Context* ctx, uint32_t offset, const char* message) {
@@ -136,903 +136,903 @@ static void handle_error(Context* ctx, uint32_t offset, const char* message) {
}
}
-static void on_error(WasmBinaryReaderContext* reader_context,
+static void on_error(WabtBinaryReaderContext* reader_context,
const char* message) {
Context* ctx = reader_context->user_data;
handle_error(ctx, reader_context->offset, message);
}
-static WasmResult on_signature_count(uint32_t count, void* user_data) {
+static WabtResult on_signature_count(uint32_t count, void* user_data) {
Context* ctx = user_data;
- wasm_reserve_func_type_ptrs(ctx->allocator, &ctx->module->func_types, count);
- return WASM_OK;
+ wabt_reserve_func_type_ptrs(ctx->allocator, &ctx->module->func_types, count);
+ return WABT_OK;
}
-static WasmResult on_signature(uint32_t index,
+static WabtResult on_signature(uint32_t index,
uint32_t param_count,
- WasmType* param_types,
+ WabtType* param_types,
uint32_t result_count,
- WasmType* result_types,
+ WabtType* result_types,
void* user_data) {
Context* ctx = user_data;
- WasmModuleField* field =
- wasm_append_module_field(ctx->allocator, ctx->module);
- field->type = WASM_MODULE_FIELD_TYPE_FUNC_TYPE;
+ WabtModuleField* field =
+ wabt_append_module_field(ctx->allocator, ctx->module);
+ field->type = WABT_MODULE_FIELD_TYPE_FUNC_TYPE;
- WasmFuncType* func_type = &field->func_type;
- WASM_ZERO_MEMORY(*func_type);
+ WabtFuncType* func_type = &field->func_type;
+ WABT_ZERO_MEMORY(*func_type);
- wasm_reserve_types(ctx->allocator, &func_type->sig.param_types, param_count);
+ wabt_reserve_types(ctx->allocator, &func_type->sig.param_types, param_count);
func_type->sig.param_types.size = param_count;
memcpy(func_type->sig.param_types.data, param_types,
- param_count * sizeof(WasmType));
+ param_count * sizeof(WabtType));
- wasm_reserve_types(ctx->allocator, &func_type->sig.result_types,
+ wabt_reserve_types(ctx->allocator, &func_type->sig.result_types,
result_count);
func_type->sig.result_types.size = result_count;
memcpy(func_type->sig.result_types.data, result_types,
- result_count * sizeof(WasmType));
+ result_count * sizeof(WabtType));
assert(index < ctx->module->func_types.capacity);
- WasmFuncTypePtr* func_type_ptr =
- wasm_append_func_type_ptr(ctx->allocator, &ctx->module->func_types);
+ WabtFuncTypePtr* func_type_ptr =
+ wabt_append_func_type_ptr(ctx->allocator, &ctx->module->func_types);
*func_type_ptr = func_type;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_import_count(uint32_t count, void* user_data) {
+static WabtResult on_import_count(uint32_t count, void* user_data) {
Context* ctx = user_data;
- wasm_reserve_import_ptrs(ctx->allocator, &ctx->module->imports, count);
- return WASM_OK;
+ wabt_reserve_import_ptrs(ctx->allocator, &ctx->module->imports, count);
+ return WABT_OK;
}
-static WasmResult on_import(uint32_t index,
- WasmStringSlice module_name,
- WasmStringSlice field_name,
+static WabtResult on_import(uint32_t index,
+ WabtStringSlice module_name,
+ WabtStringSlice field_name,
void* user_data) {
Context* ctx = user_data;
assert(index < ctx->module->imports.capacity);
- WasmModuleField* field =
- wasm_append_module_field(ctx->allocator, ctx->module);
- field->type = WASM_MODULE_FIELD_TYPE_IMPORT;
+ WabtModuleField* field =
+ wabt_append_module_field(ctx->allocator, ctx->module);
+ field->type = WABT_MODULE_FIELD_TYPE_IMPORT;
- WasmImport* import = &field->import;
- WASM_ZERO_MEMORY(*import);
- import->module_name = wasm_dup_string_slice(ctx->allocator, module_name);
- import->field_name = wasm_dup_string_slice(ctx->allocator, field_name);
+ WabtImport* import = &field->import;
+ WABT_ZERO_MEMORY(*import);
+ import->module_name = wabt_dup_string_slice(ctx->allocator, module_name);
+ import->field_name = wabt_dup_string_slice(ctx->allocator, field_name);
- WasmImportPtr* import_ptr =
- wasm_append_import_ptr(ctx->allocator, &ctx->module->imports);
+ WabtImportPtr* import_ptr =
+ wabt_append_import_ptr(ctx->allocator, &ctx->module->imports);
*import_ptr = import;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_import_func(uint32_t import_index,
+static WabtResult on_import_func(uint32_t import_index,
uint32_t func_index,
uint32_t sig_index,
void* user_data) {
Context* ctx = user_data;
assert(import_index == ctx->module->imports.size - 1);
assert(sig_index < ctx->module->func_types.size);
- WasmImport* import = ctx->module->imports.data[import_index];
+ WabtImport* import = ctx->module->imports.data[import_index];
- import->kind = WASM_EXTERNAL_KIND_FUNC;
- import->func.decl.flags = WASM_FUNC_DECLARATION_FLAG_HAS_FUNC_TYPE |
- WASM_FUNC_DECLARATION_FLAG_SHARED_SIGNATURE;
- import->func.decl.type_var.type = WASM_VAR_TYPE_INDEX;
+ import->kind = WABT_EXTERNAL_KIND_FUNC;
+ import->func.decl.flags = WABT_FUNC_DECLARATION_FLAG_HAS_FUNC_TYPE |
+ WABT_FUNC_DECLARATION_FLAG_SHARED_SIGNATURE;
+ import->func.decl.type_var.type = WABT_VAR_TYPE_INDEX;
import->func.decl.type_var.index = sig_index;
import->func.decl.sig = ctx->module->func_types.data[sig_index]->sig;
- WasmFuncPtr func_ptr = &import->func;
- wasm_append_func_ptr_value(ctx->allocator, &ctx->module->funcs, &func_ptr);
+ WabtFuncPtr func_ptr = &import->func;
+ wabt_append_func_ptr_value(ctx->allocator, &ctx->module->funcs, &func_ptr);
ctx->module->num_func_imports++;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_import_table(uint32_t import_index,
+static WabtResult on_import_table(uint32_t import_index,
uint32_t table_index,
- WasmType elem_type,
- const WasmLimits* elem_limits,
+ WabtType elem_type,
+ const WabtLimits* elem_limits,
void* user_data) {
Context* ctx = user_data;
assert(import_index == ctx->module->imports.size - 1);
- WasmImport* import = ctx->module->imports.data[import_index];
- import->kind = WASM_EXTERNAL_KIND_TABLE;
+ WabtImport* import = ctx->module->imports.data[import_index];
+ import->kind = WABT_EXTERNAL_KIND_TABLE;
import->table.elem_limits = *elem_limits;
- WasmTablePtr table_ptr = &import->table;
- wasm_append_table_ptr_value(ctx->allocator, &ctx->module->tables, &table_ptr);
+ WabtTablePtr table_ptr = &import->table;
+ wabt_append_table_ptr_value(ctx->allocator, &ctx->module->tables, &table_ptr);
ctx->module->num_table_imports++;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_import_memory(uint32_t import_index,
+static WabtResult on_import_memory(uint32_t import_index,
uint32_t memory_index,
- const WasmLimits* page_limits,
+ const WabtLimits* page_limits,
void* user_data) {
Context* ctx = user_data;
assert(import_index == ctx->module->imports.size - 1);
- WasmImport* import = ctx->module->imports.data[import_index];
- import->kind = WASM_EXTERNAL_KIND_MEMORY;
+ WabtImport* import = ctx->module->imports.data[import_index];
+ import->kind = WABT_EXTERNAL_KIND_MEMORY;
import->memory.page_limits = *page_limits;
- WasmMemoryPtr memory_ptr = &import->memory;
- wasm_append_memory_ptr_value(ctx->allocator, &ctx->module->memories,
+ WabtMemoryPtr memory_ptr = &import->memory;
+ wabt_append_memory_ptr_value(ctx->allocator, &ctx->module->memories,
&memory_ptr);
ctx->module->num_memory_imports++;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_import_global(uint32_t import_index,
+static WabtResult on_import_global(uint32_t import_index,
uint32_t global_index,
- WasmType type,
- WasmBool mutable_,
+ WabtType type,
+ WabtBool mutable_,
void* user_data) {
Context* ctx = user_data;
assert(import_index == ctx->module->imports.size - 1);
- WasmImport* import = ctx->module->imports.data[import_index];
- import->kind = WASM_EXTERNAL_KIND_GLOBAL;
+ WabtImport* import = ctx->module->imports.data[import_index];
+ import->kind = WABT_EXTERNAL_KIND_GLOBAL;
import->global.type = type;
import->global.mutable_ = mutable_;
- WasmGlobalPtr global_ptr = &import->global;
- wasm_append_global_ptr_value(ctx->allocator, &ctx->module->globals,
+ WabtGlobalPtr global_ptr = &import->global;
+ wabt_append_global_ptr_value(ctx->allocator, &ctx->module->globals,
&global_ptr);
ctx->module->num_global_imports++;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_function_signatures_count(uint32_t count,
+static WabtResult on_function_signatures_count(uint32_t count,
void* user_data) {
Context* ctx = user_data;
- wasm_reserve_func_ptrs(ctx->allocator, &ctx->module->funcs, count);
- return WASM_OK;
+ wabt_reserve_func_ptrs(ctx->allocator, &ctx->module->funcs, count);
+ return WABT_OK;
}
-static WasmResult on_function_signature(uint32_t index,
+static WabtResult on_function_signature(uint32_t index,
uint32_t sig_index,
void* user_data) {
Context* ctx = user_data;
assert(index < ctx->module->funcs.capacity);
assert(sig_index < ctx->module->func_types.size);
- WasmModuleField* field =
- wasm_append_module_field(ctx->allocator, ctx->module);
- field->type = WASM_MODULE_FIELD_TYPE_FUNC;
+ WabtModuleField* field =
+ wabt_append_module_field(ctx->allocator, ctx->module);
+ field->type = WABT_MODULE_FIELD_TYPE_FUNC;
- WasmFunc* func = &field->func;
- WASM_ZERO_MEMORY(*func);
- func->decl.flags = WASM_FUNC_DECLARATION_FLAG_HAS_FUNC_TYPE |
- WASM_FUNC_DECLARATION_FLAG_SHARED_SIGNATURE;
- func->decl.type_var.type = WASM_VAR_TYPE_INDEX;
+ WabtFunc* func = &field->func;
+ WABT_ZERO_MEMORY(*func);
+ func->decl.flags = WABT_FUNC_DECLARATION_FLAG_HAS_FUNC_TYPE |
+ WABT_FUNC_DECLARATION_FLAG_SHARED_SIGNATURE;
+ func->decl.type_var.type = WABT_VAR_TYPE_INDEX;
func->decl.type_var.index = sig_index;
func->decl.sig = ctx->module->func_types.data[sig_index]->sig;
- WasmFuncPtr* func_ptr =
- wasm_append_func_ptr(ctx->allocator, &ctx->module->funcs);
+ WabtFuncPtr* func_ptr =
+ wabt_append_func_ptr(ctx->allocator, &ctx->module->funcs);
*func_ptr = func;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_table_count(uint32_t count, void* user_data) {
+static WabtResult on_table_count(uint32_t count, void* user_data) {
Context* ctx = user_data;
- wasm_reserve_table_ptrs(ctx->allocator, &ctx->module->tables, count);
- return WASM_OK;
+ wabt_reserve_table_ptrs(ctx->allocator, &ctx->module->tables, count);
+ return WABT_OK;
}
-static WasmResult on_table(uint32_t index,
- WasmType elem_type,
- const WasmLimits* elem_limits,
+static WabtResult on_table(uint32_t index,
+ WabtType elem_type,
+ const WabtLimits* elem_limits,
void* user_data) {
Context* ctx = user_data;
assert(index < ctx->module->tables.capacity);
- WasmModuleField* field =
- wasm_append_module_field(ctx->allocator, ctx->module);
- field->type = WASM_MODULE_FIELD_TYPE_TABLE;
+ WabtModuleField* field =
+ wabt_append_module_field(ctx->allocator, ctx->module);
+ field->type = WABT_MODULE_FIELD_TYPE_TABLE;
- WasmTable* table = &field->table;
- WASM_ZERO_MEMORY(*table);
+ WabtTable* table = &field->table;
+ WABT_ZERO_MEMORY(*table);
table->elem_limits = *elem_limits;
- WasmTablePtr* table_ptr =
- wasm_append_table_ptr(ctx->allocator, &ctx->module->tables);
+ WabtTablePtr* table_ptr =
+ wabt_append_table_ptr(ctx->allocator, &ctx->module->tables);
*table_ptr = table;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_memory_count(uint32_t count, void* user_data) {
+static WabtResult on_memory_count(uint32_t count, void* user_data) {
Context* ctx = user_data;
- wasm_reserve_memory_ptrs(ctx->allocator, &ctx->module->memories, count);
- return WASM_OK;
+ wabt_reserve_memory_ptrs(ctx->allocator, &ctx->module->memories, count);
+ return WABT_OK;
}
-static WasmResult on_memory(uint32_t index,
- const WasmLimits* page_limits,
+static WabtResult on_memory(uint32_t index,
+ const WabtLimits* page_limits,
void* user_data) {
Context* ctx = user_data;
assert(index < ctx->module->memories.capacity);
- WasmModuleField* field =
- wasm_append_module_field(ctx->allocator, ctx->module);
- field->type = WASM_MODULE_FIELD_TYPE_MEMORY;
+ WabtModuleField* field =
+ wabt_append_module_field(ctx->allocator, ctx->module);
+ field->type = WABT_MODULE_FIELD_TYPE_MEMORY;
- WasmMemory* memory = &field->memory;
- WASM_ZERO_MEMORY(*memory);
+ WabtMemory* memory = &field->memory;
+ WABT_ZERO_MEMORY(*memory);
memory->page_limits = *page_limits;
- WasmMemoryPtr* memory_ptr =
- wasm_append_memory_ptr(ctx->allocator, &ctx->module->memories);
+ WabtMemoryPtr* memory_ptr =
+ wabt_append_memory_ptr(ctx->allocator, &ctx->module->memories);
*memory_ptr = memory;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_global_count(uint32_t count, void* user_data) {
+static WabtResult on_global_count(uint32_t count, void* user_data) {
Context* ctx = user_data;
- wasm_reserve_global_ptrs(ctx->allocator, &ctx->module->globals, count);
- return WASM_OK;
+ wabt_reserve_global_ptrs(ctx->allocator, &ctx->module->globals, count);
+ return WABT_OK;
}
-static WasmResult begin_global(uint32_t index,
- WasmType type,
- WasmBool mutable_,
+static WabtResult begin_global(uint32_t index,
+ WabtType type,
+ WabtBool mutable_,
void* user_data) {
Context* ctx = user_data;
assert(index - ctx->module->num_global_imports <
ctx->module->globals.capacity);
- WasmModuleField* field =
- wasm_append_module_field(ctx->allocator, ctx->module);
- field->type = WASM_MODULE_FIELD_TYPE_GLOBAL;
+ WabtModuleField* field =
+ wabt_append_module_field(ctx->allocator, ctx->module);
+ field->type = WABT_MODULE_FIELD_TYPE_GLOBAL;
- WasmGlobal* global = &field->global;
- WASM_ZERO_MEMORY(*global);
+ WabtGlobal* global = &field->global;
+ WABT_ZERO_MEMORY(*global);
global->type = type;
global->mutable_ = mutable_;
- WasmGlobalPtr* global_ptr =
- wasm_append_global_ptr(ctx->allocator, &ctx->module->globals);
+ WabtGlobalPtr* global_ptr =
+ wabt_append_global_ptr(ctx->allocator, &ctx->module->globals);
*global_ptr = global;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult begin_global_init_expr(uint32_t index, void* user_data) {
+static WabtResult begin_global_init_expr(uint32_t index, void* user_data) {
Context* ctx = user_data;
assert(index == ctx->module->globals.size - 1);
- WasmGlobal* global = ctx->module->globals.data[index];
+ WabtGlobal* global = ctx->module->globals.data[index];
ctx->current_init_expr = &global->init_expr;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult end_global_init_expr(uint32_t index, void* user_data) {
+static WabtResult end_global_init_expr(uint32_t index, void* user_data) {
Context* ctx = user_data;
ctx->current_init_expr = NULL;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_export_count(uint32_t count, void* user_data) {
+static WabtResult on_export_count(uint32_t count, void* user_data) {
Context* ctx = user_data;
- wasm_reserve_export_ptrs(ctx->allocator, &ctx->module->exports, count);
- return WASM_OK;
+ wabt_reserve_export_ptrs(ctx->allocator, &ctx->module->exports, count);
+ return WABT_OK;
}
-static WasmResult on_export(uint32_t index,
- WasmExternalKind kind,
+static WabtResult on_export(uint32_t index,
+ WabtExternalKind kind,
uint32_t item_index,
- WasmStringSlice name,
+ WabtStringSlice name,
void* user_data) {
Context* ctx = user_data;
- WasmModuleField* field =
- wasm_append_module_field(ctx->allocator, ctx->module);
- field->type = WASM_MODULE_FIELD_TYPE_EXPORT;
+ WabtModuleField* field =
+ wabt_append_module_field(ctx->allocator, ctx->module);
+ field->type = WABT_MODULE_FIELD_TYPE_EXPORT;
- WasmExport* export = &field->export_;
- WASM_ZERO_MEMORY(*export);
- export->name = wasm_dup_string_slice(ctx->allocator, name);
+ WabtExport* export = &field->export_;
+ WABT_ZERO_MEMORY(*export);
+ export->name = wabt_dup_string_slice(ctx->allocator, name);
switch (kind) {
- case WASM_EXTERNAL_KIND_FUNC:
+ case WABT_EXTERNAL_KIND_FUNC:
assert(item_index < ctx->module->funcs.size);
break;
- case WASM_EXTERNAL_KIND_TABLE:
+ case WABT_EXTERNAL_KIND_TABLE:
assert(item_index < ctx->module->tables.size);
break;
- case WASM_EXTERNAL_KIND_MEMORY:
+ case WABT_EXTERNAL_KIND_MEMORY:
assert(item_index < ctx->module->memories.size);
break;
- case WASM_EXTERNAL_KIND_GLOBAL:
+ case WABT_EXTERNAL_KIND_GLOBAL:
assert(item_index < ctx->module->globals.size);
break;
- case WASM_NUM_EXTERNAL_KINDS:
+ case WABT_NUM_EXTERNAL_KINDS:
assert(0);
break;
}
- export->var.type = WASM_VAR_TYPE_INDEX;
+ export->var.type = WABT_VAR_TYPE_INDEX;
export->var.index = item_index;
export->kind = kind;
assert(index < ctx->module->exports.capacity);
- WasmExportPtr* export_ptr =
- wasm_append_export_ptr(ctx->allocator, &ctx->module->exports);
+ WabtExportPtr* export_ptr =
+ wabt_append_export_ptr(ctx->allocator, &ctx->module->exports);
*export_ptr = export;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_start_function(uint32_t func_index, void* user_data) {
+static WabtResult on_start_function(uint32_t func_index, void* user_data) {
Context* ctx = user_data;
- WasmModuleField* field =
- wasm_append_module_field(ctx->allocator, ctx->module);
- field->type = WASM_MODULE_FIELD_TYPE_START;
+ WabtModuleField* field =
+ wabt_append_module_field(ctx->allocator, ctx->module);
+ field->type = WABT_MODULE_FIELD_TYPE_START;
- field->start.type = WASM_VAR_TYPE_INDEX;
+ field->start.type = WABT_VAR_TYPE_INDEX;
assert(func_index < ctx->module->funcs.size);
field->start.index = func_index;
ctx->module->start = &field->start;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_function_bodies_count(uint32_t count, void* user_data) {
+static WabtResult on_function_bodies_count(uint32_t count, void* user_data) {
Context* ctx = user_data;
assert(ctx->module->num_func_imports + count == ctx->module->funcs.size);
(void)ctx;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult begin_function_body(WasmBinaryReaderContext* context,
+static WabtResult begin_function_body(WabtBinaryReaderContext* context,
uint32_t index) {
Context* ctx = context->user_data;
assert(index < ctx->module->funcs.size);
ctx->current_func = ctx->module->funcs.data[index];
push_label(ctx, LABEL_TYPE_FUNC, &ctx->current_func->first_expr);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_local_decl(uint32_t decl_index,
+static WabtResult on_local_decl(uint32_t decl_index,
uint32_t count,
- WasmType type,
+ WabtType type,
void* user_data) {
Context* ctx = user_data;
size_t old_local_count = ctx->current_func->local_types.size;
size_t new_local_count = old_local_count + count;
- wasm_reserve_types(ctx->allocator, &ctx->current_func->local_types,
+ wabt_reserve_types(ctx->allocator, &ctx->current_func->local_types,
new_local_count);
- WasmTypeVector* types = &ctx->current_func->local_types;
+ WabtTypeVector* types = &ctx->current_func->local_types;
size_t i;
for (i = 0; i < count; ++i)
types->data[old_local_count + i] = type;
types->size = new_local_count;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_binary_expr(WasmOpcode opcode, void* user_data) {
+static WabtResult on_binary_expr(WabtOpcode opcode, void* user_data) {
Context* ctx = user_data;
- WasmExpr* expr = wasm_new_binary_expr(ctx->allocator);
+ WabtExpr* expr = wabt_new_binary_expr(ctx->allocator);
expr->binary.opcode = opcode;
return append_expr(ctx, expr);
}
-static WasmResult on_block_expr(uint32_t num_types,
- WasmType* sig_types,
+static WabtResult on_block_expr(uint32_t num_types,
+ WabtType* sig_types,
void* user_data) {
Context* ctx = user_data;
- WasmExpr* expr = wasm_new_block_expr(ctx->allocator);
- WasmTypeVector src;
- WASM_ZERO_MEMORY(src);
+ WabtExpr* expr = wabt_new_block_expr(ctx->allocator);
+ WabtTypeVector src;
+ WABT_ZERO_MEMORY(src);
src.size = num_types;
src.data = sig_types;
- wasm_extend_types(ctx->allocator, &expr->block.sig, &src);
+ wabt_extend_types(ctx->allocator, &expr->block.sig, &src);
append_expr(ctx, expr);
push_label(ctx, LABEL_TYPE_BLOCK, &expr->block.first);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_br_expr(uint32_t depth, void* user_data) {
+static WabtResult on_br_expr(uint32_t depth, void* user_data) {
Context* ctx = user_data;
- WasmExpr* expr = wasm_new_br_expr(ctx->allocator);
- expr->br.var.type = WASM_VAR_TYPE_INDEX;
+ WabtExpr* expr = wabt_new_br_expr(ctx->allocator);
+ expr->br.var.type = WABT_VAR_TYPE_INDEX;
expr->br.var.index = depth;
return append_expr(ctx, expr);
}
-static WasmResult on_br_if_expr(uint32_t depth, void* user_data) {
+static WabtResult on_br_if_expr(uint32_t depth, void* user_data) {
Context* ctx = user_data;
- WasmExpr* expr = wasm_new_br_if_expr(ctx->allocator);
- expr->br_if.var.type = WASM_VAR_TYPE_INDEX;
+ WabtExpr* expr = wabt_new_br_if_expr(ctx->allocator);
+ expr->br_if.var.type = WABT_VAR_TYPE_INDEX;
expr->br_if.var.index = depth;
return append_expr(ctx, expr);
}
-static WasmResult on_br_table_expr(WasmBinaryReaderContext* context,
+static WabtResult on_br_table_expr(WabtBinaryReaderContext* context,
uint32_t num_targets,
uint32_t* target_depths,
uint32_t default_target_depth) {
Context* ctx = context->user_data;
- WasmExpr* expr = wasm_new_br_table_expr(ctx->allocator);
- wasm_reserve_vars(ctx->allocator, &expr->br_table.targets, num_targets);
+ WabtExpr* expr = wabt_new_br_table_expr(ctx->allocator);
+ wabt_reserve_vars(ctx->allocator, &expr->br_table.targets, num_targets);
expr->br_table.targets.size = num_targets;
uint32_t i;
for (i = 0; i < num_targets; ++i) {
- WasmVar* var = &expr->br_table.targets.data[i];
- var->type = WASM_VAR_TYPE_INDEX;
+ WabtVar* var = &expr->br_table.targets.data[i];
+ var->type = WABT_VAR_TYPE_INDEX;
var->index = target_depths[i];
}
- expr->br_table.default_target.type = WASM_VAR_TYPE_INDEX;
+ expr->br_table.default_target.type = WABT_VAR_TYPE_INDEX;
expr->br_table.default_target.index = default_target_depth;
return append_expr(ctx, expr);
}
-static WasmResult on_call_expr(uint32_t func_index, void* user_data) {
+static WabtResult on_call_expr(uint32_t func_index, void* user_data) {
Context* ctx = user_data;
assert(func_index < ctx->module->funcs.size);
- WasmExpr* expr = wasm_new_call_expr(ctx->allocator);
- expr->call.var.type = WASM_VAR_TYPE_INDEX;
+ WabtExpr* expr = wabt_new_call_expr(ctx->allocator);
+ expr->call.var.type = WABT_VAR_TYPE_INDEX;
expr->call.var.index = func_index;
return append_expr(ctx, expr);
}
-static WasmResult on_call_indirect_expr(uint32_t sig_index, void* user_data) {
+static WabtResult on_call_indirect_expr(uint32_t sig_index, void* user_data) {
Context* ctx = user_data;
assert(sig_index < ctx->module->func_types.size);
- WasmExpr* expr = wasm_new_call_indirect_expr(ctx->allocator);
- expr->call_indirect.var.type = WASM_VAR_TYPE_INDEX;
+ WabtExpr* expr = wabt_new_call_indirect_expr(ctx->allocator);
+ expr->call_indirect.var.type = WABT_VAR_TYPE_INDEX;
expr->call_indirect.var.index = sig_index;
return append_expr(ctx, expr);
}
-static WasmResult on_compare_expr(WasmOpcode opcode, void* user_data) {
+static WabtResult on_compare_expr(WabtOpcode opcode, void* user_data) {
Context* ctx = user_data;
- WasmExpr* expr = wasm_new_compare_expr(ctx->allocator);
+ WabtExpr* expr = wabt_new_compare_expr(ctx->allocator);
expr->compare.opcode = opcode;
return append_expr(ctx, expr);
}
-static WasmResult on_convert_expr(WasmOpcode opcode, void* user_data) {
+static WabtResult on_convert_expr(WabtOpcode opcode, void* user_data) {
Context* ctx = user_data;
- WasmExpr* expr = wasm_new_convert_expr(ctx->allocator);
+ WabtExpr* expr = wabt_new_convert_expr(ctx->allocator);
expr->convert.opcode = opcode;
return append_expr(ctx, expr);
}
-static WasmResult on_current_memory_expr(void* user_data) {
+static WabtResult on_current_memory_expr(void* user_data) {
Context* ctx = user_data;
- WasmExpr* expr = wasm_new_current_memory_expr(ctx->allocator);
+ WabtExpr* expr = wabt_new_current_memory_expr(ctx->allocator);
return append_expr(ctx, expr);
}
-static WasmResult on_drop_expr(void* user_data) {
+static WabtResult on_drop_expr(void* user_data) {
Context* ctx = user_data;
- WasmExpr* expr = wasm_new_drop_expr(ctx->allocator);
+ WabtExpr* expr = wabt_new_drop_expr(ctx->allocator);
return append_expr(ctx, expr);
}
-static WasmResult on_else_expr(void* user_data) {
+static WabtResult on_else_expr(void* user_data) {
Context* ctx = user_data;
LabelNode* label;
CHECK_RESULT(top_label(ctx, &label));
if (label->label_type != LABEL_TYPE_IF) {
print_error(ctx, "else expression without matching if");
- return WASM_ERROR;
+ return WABT_ERROR;
}
LabelNode* parent_label;
CHECK_RESULT(get_label_at(ctx, &parent_label, 1));
- assert(parent_label->last->type == WASM_EXPR_TYPE_IF);
+ assert(parent_label->last->type == WABT_EXPR_TYPE_IF);
label->label_type = LABEL_TYPE_ELSE;
label->first = &parent_label->last->if_.false_;
label->last = NULL;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_end_expr(void* user_data) {
+static WabtResult on_end_expr(void* user_data) {
Context* ctx = user_data;
return pop_label(ctx);
}
-static WasmResult on_f32_const_expr(uint32_t value_bits, void* user_data) {
+static WabtResult on_f32_const_expr(uint32_t value_bits, void* user_data) {
Context* ctx = user_data;
- WasmExpr* expr = wasm_new_const_expr(ctx->allocator);
- expr->const_.type = WASM_TYPE_F32;
+ WabtExpr* expr = wabt_new_const_expr(ctx->allocator);
+ expr->const_.type = WABT_TYPE_F32;
expr->const_.f32_bits = value_bits;
return append_expr(ctx, expr);
}
-static WasmResult on_f64_const_expr(uint64_t value_bits, void* user_data) {
+static WabtResult on_f64_const_expr(uint64_t value_bits, void* user_data) {
Context* ctx = user_data;
- WasmExpr* expr = wasm_new_const_expr(ctx->allocator);
- expr->const_.type = WASM_TYPE_F64;
+ WabtExpr* expr = wabt_new_const_expr(ctx->allocator);
+ expr->const_.type = WABT_TYPE_F64;
expr->const_.f64_bits = value_bits;
return append_expr(ctx, expr);
}
-static WasmResult on_get_global_expr(uint32_t global_index, void* user_data) {
+static WabtResult on_get_global_expr(uint32_t global_index, void* user_data) {
Context* ctx = user_data;
- WasmExpr* expr = wasm_new_get_global_expr(ctx->allocator);
- expr->get_global.var.type = WASM_VAR_TYPE_INDEX;
+ WabtExpr* expr = wabt_new_get_global_expr(ctx->allocator);
+ expr->get_global.var.type = WABT_VAR_TYPE_INDEX;
expr->get_global.var.index = global_index;
return append_expr(ctx, expr);
}
-static WasmResult on_get_local_expr(uint32_t local_index, void* user_data) {
+static WabtResult on_get_local_expr(uint32_t local_index, void* user_data) {
Context* ctx = user_data;
- WasmExpr* expr = wasm_new_get_local_expr(ctx->allocator);
- expr->get_local.var.type = WASM_VAR_TYPE_INDEX;
+ WabtExpr* expr = wabt_new_get_local_expr(ctx->allocator);
+ expr->get_local.var.type = WABT_VAR_TYPE_INDEX;
expr->get_local.var.index = local_index;
return append_expr(ctx, expr);
}
-static WasmResult on_grow_memory_expr(void* user_data) {
+static WabtResult on_grow_memory_expr(void* user_data) {
Context* ctx = user_data;
- WasmExpr* expr = wasm_new_grow_memory_expr(ctx->allocator);
+ WabtExpr* expr = wabt_new_grow_memory_expr(ctx->allocator);
return append_expr(ctx, expr);
}
-static WasmResult on_i32_const_expr(uint32_t value, void* user_data) {
+static WabtResult on_i32_const_expr(uint32_t value, void* user_data) {
Context* ctx = user_data;
- WasmExpr* expr = wasm_new_const_expr(ctx->allocator);
- expr->const_.type = WASM_TYPE_I32;
+ WabtExpr* expr = wabt_new_const_expr(ctx->allocator);
+ expr->const_.type = WABT_TYPE_I32;
expr->const_.u32 = value;
return append_expr(ctx, expr);
}
-static WasmResult on_i64_const_expr(uint64_t value, void* user_data) {
+static WabtResult on_i64_const_expr(uint64_t value, void* user_data) {
Context* ctx = user_data;
- WasmExpr* expr = wasm_new_const_expr(ctx->allocator);
- expr->const_.type = WASM_TYPE_I64;
+ WabtExpr* expr = wabt_new_const_expr(ctx->allocator);
+ expr->const_.type = WABT_TYPE_I64;
expr->const_.u64 = value;
return append_expr(ctx, expr);
}
-static WasmResult on_if_expr(uint32_t num_types,
- WasmType* sig_types,
+static WabtResult on_if_expr(uint32_t num_types,
+ WabtType* sig_types,
void* user_data) {
Context* ctx = user_data;
- WasmExpr* expr = wasm_new_if_expr(ctx->allocator);
- WasmTypeVector src;
- WASM_ZERO_MEMORY(src);
+ WabtExpr* expr = wabt_new_if_expr(ctx->allocator);
+ WabtTypeVector src;
+ WABT_ZERO_MEMORY(src);
src.size = num_types;
src.data = sig_types;
- wasm_extend_types(ctx->allocator, &expr->if_.true_.sig, &src);
+ wabt_extend_types(ctx->allocator, &expr->if_.true_.sig, &src);
append_expr(ctx, expr);
push_label(ctx, LABEL_TYPE_IF, &expr->if_.true_.first);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_load_expr(WasmOpcode opcode,
+static WabtResult on_load_expr(WabtOpcode opcode,
uint32_t alignment_log2,
uint32_t offset,
void* user_data) {
Context* ctx = user_data;
- WasmExpr* expr = wasm_new_load_expr(ctx->allocator);
+ WabtExpr* expr = wabt_new_load_expr(ctx->allocator);
expr->load.opcode = opcode;
expr->load.align = 1 << alignment_log2;
expr->load.offset = offset;
return append_expr(ctx, expr);
}
-static WasmResult on_loop_expr(uint32_t num_types,
- WasmType* sig_types,
+static WabtResult on_loop_expr(uint32_t num_types,
+ WabtType* sig_types,
void* user_data) {
Context* ctx = user_data;
- WasmExpr* expr = wasm_new_loop_expr(ctx->allocator);
- WasmTypeVector src;
- WASM_ZERO_MEMORY(src);
+ WabtExpr* expr = wabt_new_loop_expr(ctx->allocator);
+ WabtTypeVector src;
+ WABT_ZERO_MEMORY(src);
src.size = num_types;
src.data = sig_types;
- wasm_extend_types(ctx->allocator, &expr->loop.sig, &src);
+ wabt_extend_types(ctx->allocator, &expr->loop.sig, &src);
append_expr(ctx, expr);
push_label(ctx, LABEL_TYPE_LOOP, &expr->loop.first);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_nop_expr(void* user_data) {
+static WabtResult on_nop_expr(void* user_data) {
Context* ctx = user_data;
- WasmExpr* expr = wasm_new_nop_expr(ctx->allocator);
+ WabtExpr* expr = wabt_new_nop_expr(ctx->allocator);
return append_expr(ctx, expr);
}
-static WasmResult on_return_expr(void* user_data) {
+static WabtResult on_return_expr(void* user_data) {
Context* ctx = user_data;
- WasmExpr* expr = wasm_new_return_expr(ctx->allocator);
+ WabtExpr* expr = wabt_new_return_expr(ctx->allocator);
return append_expr(ctx, expr);
}
-static WasmResult on_select_expr(void* user_data) {
+static WabtResult on_select_expr(void* user_data) {
Context* ctx = user_data;
- WasmExpr* expr = wasm_new_select_expr(ctx->allocator);
+ WabtExpr* expr = wabt_new_select_expr(ctx->allocator);
return append_expr(ctx, expr);
}
-static WasmResult on_set_global_expr(uint32_t global_index, void* user_data) {
+static WabtResult on_set_global_expr(uint32_t global_index, void* user_data) {
Context* ctx = user_data;
- WasmExpr* expr = wasm_new_set_global_expr(ctx->allocator);
- expr->set_global.var.type = WASM_VAR_TYPE_INDEX;
+ WabtExpr* expr = wabt_new_set_global_expr(ctx->allocator);
+ expr->set_global.var.type = WABT_VAR_TYPE_INDEX;
expr->set_global.var.index = global_index;
return append_expr(ctx, expr);
}
-static WasmResult on_set_local_expr(uint32_t local_index, void* user_data) {
+static WabtResult on_set_local_expr(uint32_t local_index, void* user_data) {
Context* ctx = user_data;
- WasmExpr* expr = wasm_new_set_local_expr(ctx->allocator);
- expr->set_local.var.type = WASM_VAR_TYPE_INDEX;
+ WabtExpr* expr = wabt_new_set_local_expr(ctx->allocator);
+ expr->set_local.var.type = WABT_VAR_TYPE_INDEX;
expr->set_local.var.index = local_index;
return append_expr(ctx, expr);
}
-static WasmResult on_store_expr(WasmOpcode opcode,
+static WabtResult on_store_expr(WabtOpcode opcode,
uint32_t alignment_log2,
uint32_t offset,
void* user_data) {
Context* ctx = user_data;
- WasmExpr* expr = wasm_new_store_expr(ctx->allocator);
+ WabtExpr* expr = wabt_new_store_expr(ctx->allocator);
expr->store.opcode = opcode;
expr->store.align = 1 << alignment_log2;
expr->store.offset = offset;
return append_expr(ctx, expr);
}
-static WasmResult on_tee_local_expr(uint32_t local_index, void* user_data) {
+static WabtResult on_tee_local_expr(uint32_t local_index, void* user_data) {
Context* ctx = user_data;
- WasmExpr* expr = wasm_new_tee_local_expr(ctx->allocator);
- expr->tee_local.var.type = WASM_VAR_TYPE_INDEX;
+ WabtExpr* expr = wabt_new_tee_local_expr(ctx->allocator);
+ expr->tee_local.var.type = WABT_VAR_TYPE_INDEX;
expr->tee_local.var.index = local_index;
return append_expr(ctx, expr);
}
-static WasmResult on_unary_expr(WasmOpcode opcode, void* user_data) {
+static WabtResult on_unary_expr(WabtOpcode opcode, void* user_data) {
Context* ctx = user_data;
- WasmExpr* expr = wasm_new_unary_expr(ctx->allocator);
+ WabtExpr* expr = wabt_new_unary_expr(ctx->allocator);
expr->unary.opcode = opcode;
return append_expr(ctx, expr);
}
-static WasmResult on_unreachable_expr(void* user_data) {
+static WabtResult on_unreachable_expr(void* user_data) {
Context* ctx = user_data;
- WasmExpr* expr = wasm_new_unreachable_expr(ctx->allocator);
+ WabtExpr* expr = wabt_new_unreachable_expr(ctx->allocator);
return append_expr(ctx, expr);
}
-static WasmResult end_function_body(uint32_t index, void* user_data) {
+static WabtResult end_function_body(uint32_t index, void* user_data) {
Context* ctx = user_data;
CHECK_RESULT(pop_label(ctx));
ctx->current_func = NULL;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_elem_segment_count(uint32_t count, void* user_data) {
+static WabtResult on_elem_segment_count(uint32_t count, void* user_data) {
Context* ctx = user_data;
- wasm_reserve_elem_segment_ptrs(ctx->allocator, &ctx->module->elem_segments,
+ wabt_reserve_elem_segment_ptrs(ctx->allocator, &ctx->module->elem_segments,
count);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult begin_elem_segment(uint32_t index,
+static WabtResult begin_elem_segment(uint32_t index,
uint32_t table_index,
void* user_data) {
Context* ctx = user_data;
- WasmModuleField* field =
- wasm_append_module_field(ctx->allocator, ctx->module);
- field->type = WASM_MODULE_FIELD_TYPE_ELEM_SEGMENT;
+ WabtModuleField* field =
+ wabt_append_module_field(ctx->allocator, ctx->module);
+ field->type = WABT_MODULE_FIELD_TYPE_ELEM_SEGMENT;
- WasmElemSegment* segment = &field->elem_segment;
- WASM_ZERO_MEMORY(*segment);
- segment->table_var.type = WASM_VAR_TYPE_INDEX;
+ WabtElemSegment* segment = &field->elem_segment;
+ WABT_ZERO_MEMORY(*segment);
+ segment->table_var.type = WABT_VAR_TYPE_INDEX;
segment->table_var.index = table_index;
assert(index == ctx->module->elem_segments.size);
assert(index < ctx->module->elem_segments.capacity);
- WasmElemSegmentPtr* segment_ptr =
- wasm_append_elem_segment_ptr(ctx->allocator, &ctx->module->elem_segments);
+ WabtElemSegmentPtr* segment_ptr =
+ wabt_append_elem_segment_ptr(ctx->allocator, &ctx->module->elem_segments);
*segment_ptr = segment;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult begin_elem_segment_init_expr(uint32_t index,
+static WabtResult begin_elem_segment_init_expr(uint32_t index,
void* user_data) {
Context* ctx = user_data;
assert(index == ctx->module->elem_segments.size - 1);
- WasmElemSegment* segment = ctx->module->elem_segments.data[index];
+ WabtElemSegment* segment = ctx->module->elem_segments.data[index];
ctx->current_init_expr = &segment->offset;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult end_elem_segment_init_expr(uint32_t index, void* user_data) {
+static WabtResult end_elem_segment_init_expr(uint32_t index, void* user_data) {
Context* ctx = user_data;
ctx->current_init_expr = NULL;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_elem_segment_function_index_count(
- WasmBinaryReaderContext* context,
+static WabtResult on_elem_segment_function_index_count(
+ WabtBinaryReaderContext* context,
uint32_t index,
uint32_t count) {
Context* ctx = context->user_data;
assert(index == ctx->module->elem_segments.size - 1);
- WasmElemSegment* segment = ctx->module->elem_segments.data[index];
- wasm_reserve_vars(ctx->allocator, &segment->vars, count);
- return WASM_OK;
+ WabtElemSegment* segment = ctx->module->elem_segments.data[index];
+ wabt_reserve_vars(ctx->allocator, &segment->vars, count);
+ return WABT_OK;
}
-static WasmResult on_elem_segment_function_index(uint32_t index,
+static WabtResult on_elem_segment_function_index(uint32_t index,
uint32_t func_index,
void* user_data) {
Context* ctx = user_data;
assert(index == ctx->module->elem_segments.size - 1);
- WasmElemSegment* segment = ctx->module->elem_segments.data[index];
- WasmVar* var = wasm_append_var(ctx->allocator, &segment->vars);
- var->type = WASM_VAR_TYPE_INDEX;
+ WabtElemSegment* segment = ctx->module->elem_segments.data[index];
+ WabtVar* var = wabt_append_var(ctx->allocator, &segment->vars);
+ var->type = WABT_VAR_TYPE_INDEX;
var->index = func_index;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_data_segment_count(uint32_t count, void* user_data) {
+static WabtResult on_data_segment_count(uint32_t count, void* user_data) {
Context* ctx = user_data;
- wasm_reserve_data_segment_ptrs(ctx->allocator, &ctx->module->data_segments,
+ wabt_reserve_data_segment_ptrs(ctx->allocator, &ctx->module->data_segments,
count);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult begin_data_segment(uint32_t index,
+static WabtResult begin_data_segment(uint32_t index,
uint32_t memory_index,
void* user_data) {
Context* ctx = user_data;
- WasmModuleField* field =
- wasm_append_module_field(ctx->allocator, ctx->module);
- field->type = WASM_MODULE_FIELD_TYPE_DATA_SEGMENT;
+ WabtModuleField* field =
+ wabt_append_module_field(ctx->allocator, ctx->module);
+ field->type = WABT_MODULE_FIELD_TYPE_DATA_SEGMENT;
- WasmDataSegment* segment = &field->data_segment;
- WASM_ZERO_MEMORY(*segment);
- segment->memory_var.type = WASM_VAR_TYPE_INDEX;
+ WabtDataSegment* segment = &field->data_segment;
+ WABT_ZERO_MEMORY(*segment);
+ segment->memory_var.type = WABT_VAR_TYPE_INDEX;
segment->memory_var.index = memory_index;
assert(index == ctx->module->data_segments.size);
assert(index < ctx->module->data_segments.capacity);
- WasmDataSegmentPtr* segment_ptr =
- wasm_append_data_segment_ptr(ctx->allocator, &ctx->module->data_segments);
+ WabtDataSegmentPtr* segment_ptr =
+ wabt_append_data_segment_ptr(ctx->allocator, &ctx->module->data_segments);
*segment_ptr = segment;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult begin_data_segment_init_expr(uint32_t index,
+static WabtResult begin_data_segment_init_expr(uint32_t index,
void* user_data) {
Context* ctx = user_data;
assert(index == ctx->module->data_segments.size - 1);
- WasmDataSegment* segment = ctx->module->data_segments.data[index];
+ WabtDataSegment* segment = ctx->module->data_segments.data[index];
ctx->current_init_expr = &segment->offset;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult end_data_segment_init_expr(uint32_t index, void* user_data) {
+static WabtResult end_data_segment_init_expr(uint32_t index, void* user_data) {
Context* ctx = user_data;
ctx->current_init_expr = NULL;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_data_segment_data(uint32_t index,
+static WabtResult on_data_segment_data(uint32_t index,
const void* data,
uint32_t size,
void* user_data) {
Context* ctx = user_data;
assert(index == ctx->module->data_segments.size - 1);
- WasmDataSegment* segment = ctx->module->data_segments.data[index];
- segment->data = wasm_alloc(ctx->allocator, size, WASM_DEFAULT_ALIGN);
+ WabtDataSegment* segment = ctx->module->data_segments.data[index];
+ segment->data = wabt_alloc(ctx->allocator, size, WABT_DEFAULT_ALIGN);
segment->size = size;
memcpy(segment->data, data, size);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_function_names_count(uint32_t count, void* user_data) {
+static WabtResult on_function_names_count(uint32_t count, void* user_data) {
Context* ctx = user_data;
if (count > ctx->module->funcs.size) {
print_error(
ctx, "expected function name count (%u) <= function count (%" PRIzd ")",
count, ctx->module->funcs.size);
- return WASM_ERROR;
+ return WABT_ERROR;
}
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_function_name(uint32_t index,
- WasmStringSlice name,
+static WabtResult on_function_name(uint32_t index,
+ WabtStringSlice name,
void* user_data) {
Context* ctx = user_data;
- WasmStringSlice new_name;
+ WabtStringSlice new_name;
dup_name(ctx, &name, &new_name);
- WasmBinding* binding = wasm_insert_binding(
+ WabtBinding* binding = wabt_insert_binding(
ctx->allocator, &ctx->module->func_bindings, &new_name);
binding->index = index;
- WasmFunc* func = ctx->module->funcs.data[index];
+ WabtFunc* func = ctx->module->funcs.data[index];
func->name = new_name;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_local_names_count(uint32_t index,
+static WabtResult on_local_names_count(uint32_t index,
uint32_t count,
void* user_data) {
Context* ctx = user_data;
- WasmModule* module = ctx->module;
+ WabtModule* module = ctx->module;
assert(index < module->funcs.size);
- WasmFunc* func = module->funcs.data[index];
- uint32_t num_params_and_locals = wasm_get_num_params_and_locals(func);
+ WabtFunc* func = module->funcs.data[index];
+ uint32_t num_params_and_locals = wabt_get_num_params_and_locals(func);
if (count > num_params_and_locals) {
print_error(ctx, "expected local name count (%d) <= local count (%d)",
count, num_params_and_locals);
- return WASM_ERROR;
+ return WABT_ERROR;
}
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_init_expr_f32_const_expr(uint32_t index,
+static WabtResult on_init_expr_f32_const_expr(uint32_t index,
uint32_t value,
void* user_data) {
Context* ctx = user_data;
- WasmExpr* expr = wasm_new_const_expr(ctx->allocator);
- expr->const_.type = WASM_TYPE_F32;
+ WabtExpr* expr = wabt_new_const_expr(ctx->allocator);
+ expr->const_.type = WABT_TYPE_F32;
expr->const_.f32_bits = value;
*ctx->current_init_expr = expr;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_init_expr_f64_const_expr(uint32_t index,
+static WabtResult on_init_expr_f64_const_expr(uint32_t index,
uint64_t value,
void* user_data) {
Context* ctx = user_data;
- WasmExpr* expr = wasm_new_const_expr(ctx->allocator);
- expr->const_.type = WASM_TYPE_F64;
+ WabtExpr* expr = wabt_new_const_expr(ctx->allocator);
+ expr->const_.type = WABT_TYPE_F64;
expr->const_.f64_bits = value;
*ctx->current_init_expr = expr;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_init_expr_get_global_expr(uint32_t index,
+static WabtResult on_init_expr_get_global_expr(uint32_t index,
uint32_t global_index,
void* user_data) {
Context* ctx = user_data;
- WasmExpr* expr = wasm_new_get_global_expr(ctx->allocator);
- expr->get_global.var.type = WASM_VAR_TYPE_INDEX;
+ WabtExpr* expr = wabt_new_get_global_expr(ctx->allocator);
+ expr->get_global.var.type = WABT_VAR_TYPE_INDEX;
expr->get_global.var.index = global_index;
*ctx->current_init_expr = expr;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_init_expr_i32_const_expr(uint32_t index,
+static WabtResult on_init_expr_i32_const_expr(uint32_t index,
uint32_t value,
void* user_data) {
Context* ctx = user_data;
- WasmExpr* expr = wasm_new_const_expr(ctx->allocator);
- expr->const_.type = WASM_TYPE_I32;
+ WabtExpr* expr = wabt_new_const_expr(ctx->allocator);
+ expr->const_.type = WABT_TYPE_I32;
expr->const_.u32 = value;
*ctx->current_init_expr = expr;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_init_expr_i64_const_expr(uint32_t index,
+static WabtResult on_init_expr_i64_const_expr(uint32_t index,
uint64_t value,
void* user_data) {
Context* ctx = user_data;
- WasmExpr* expr = wasm_new_const_expr(ctx->allocator);
- expr->const_.type = WASM_TYPE_I64;
+ WabtExpr* expr = wabt_new_const_expr(ctx->allocator);
+ expr->const_.type = WABT_TYPE_I64;
expr->const_.u64 = value;
*ctx->current_init_expr = expr;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_local_name(uint32_t func_index,
+static WabtResult on_local_name(uint32_t func_index,
uint32_t local_index,
- WasmStringSlice name,
+ WabtStringSlice name,
void* user_data) {
Context* ctx = user_data;
- WasmModule* module = ctx->module;
- WasmFunc* func = module->funcs.data[func_index];
- uint32_t num_params = wasm_get_num_params(func);
- WasmStringSlice new_name;
+ WabtModule* module = ctx->module;
+ WabtFunc* func = module->funcs.data[func_index];
+ uint32_t num_params = wabt_get_num_params(func);
+ WabtStringSlice new_name;
dup_name(ctx, &name, &new_name);
- WasmBindingHash* bindings;
- WasmBinding* binding;
+ WabtBindingHash* bindings;
+ WabtBinding* binding;
uint32_t index;
if (local_index < num_params) {
/* param name */
@@ -1043,12 +1043,12 @@ static WasmResult on_local_name(uint32_t func_index,
bindings = &func->local_bindings;
index = local_index - num_params;
}
- binding = wasm_insert_binding(ctx->allocator, bindings, &new_name);
+ binding = wabt_insert_binding(ctx->allocator, bindings, &new_name);
binding->index = index;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmBinaryReader s_binary_reader = {
+static WabtBinaryReader s_binary_reader = {
.user_data = NULL,
.on_error = on_error,
@@ -1144,32 +1144,32 @@ static WasmBinaryReader s_binary_reader = {
.on_init_expr_i64_const_expr = on_init_expr_i64_const_expr,
};
-static void wasm_destroy_label_node(WasmAllocator* allocator, LabelNode* node) {
+static void wabt_destroy_label_node(WabtAllocator* allocator, LabelNode* node) {
if (*node->first)
- wasm_destroy_expr_list(allocator, *node->first);
+ wabt_destroy_expr_list(allocator, *node->first);
}
-WasmResult wasm_read_binary_ast(struct WasmAllocator* allocator,
+WabtResult wabt_read_binary_ast(struct WabtAllocator* allocator,
const void* data,
size_t size,
- const WasmReadBinaryOptions* options,
- WasmBinaryErrorHandler* error_handler,
- struct WasmModule* out_module) {
+ const WabtReadBinaryOptions* options,
+ WabtBinaryErrorHandler* error_handler,
+ struct WabtModule* out_module) {
Context ctx;
- WASM_ZERO_MEMORY(ctx);
+ WABT_ZERO_MEMORY(ctx);
ctx.allocator = allocator;
ctx.error_handler = error_handler;
ctx.module = out_module;
- WasmBinaryReader reader;
- WASM_ZERO_MEMORY(reader);
+ WabtBinaryReader reader;
+ WABT_ZERO_MEMORY(reader);
reader = s_binary_reader;
reader.user_data = &ctx;
- WasmResult result =
- wasm_read_binary(allocator, data, size, &reader, 1, options);
- WASM_DESTROY_VECTOR_AND_ELEMENTS(allocator, ctx.label_stack, label_node);
- if (WASM_FAILED(result))
- wasm_destroy_module(allocator, out_module);
+ WabtResult result =
+ wabt_read_binary(allocator, data, size, &reader, 1, options);
+ WABT_DESTROY_VECTOR_AND_ELEMENTS(allocator, ctx.label_stack, label_node);
+ if (WABT_FAILED(result))
+ wabt_destroy_module(allocator, out_module);
return result;
}
diff --git a/src/binary-reader-ast.h b/src/binary-reader-ast.h
index 8b8fcc0c..512a75ba 100644
--- a/src/binary-reader-ast.h
+++ b/src/binary-reader-ast.h
@@ -14,22 +14,22 @@
* limitations under the License.
*/
-#ifndef WASM_BINARY_READER_AST_H_
-#define WASM_BINARY_READER_AST_H_
+#ifndef WABT_BINARY_READER_AST_H_
+#define WABT_BINARY_READER_AST_H_
#include "common.h"
-struct WasmAllocator;
-struct WasmModule;
-struct WasmReadBinaryOptions;
+struct WabtAllocator;
+struct WabtModule;
+struct WabtReadBinaryOptions;
-WASM_EXTERN_C_BEGIN
-WasmResult wasm_read_binary_ast(struct WasmAllocator* allocator,
+WABT_EXTERN_C_BEGIN
+WabtResult wabt_read_binary_ast(struct WabtAllocator* allocator,
const void* data,
size_t size,
- const struct WasmReadBinaryOptions* options,
- WasmBinaryErrorHandler*,
- struct WasmModule* out_module);
-WASM_EXTERN_C_END
+ const struct WabtReadBinaryOptions* options,
+ WabtBinaryErrorHandler*,
+ struct WabtModule* out_module);
+WABT_EXTERN_C_END
-#endif /* WASM_BINARY_READER_AST_H_ */
+#endif /* WABT_BINARY_READER_AST_H_ */
diff --git a/src/binary-reader-interpreter.c b/src/binary-reader-interpreter.c
index 891cc7c6..c27e440b 100644
--- a/src/binary-reader-interpreter.c
+++ b/src/binary-reader-interpreter.c
@@ -36,8 +36,8 @@
#define CHECK_RESULT(expr) \
do { \
- if (WASM_FAILED(expr)) \
- return WASM_ERROR; \
+ if (WABT_FAILED(expr)) \
+ return WABT_ERROR; \
} while (0)
#define CHECK_DEPTH(ctx, depth) \
@@ -45,7 +45,7 @@
if ((depth) >= (ctx)->label_stack.size) { \
print_error((ctx), "invalid depth: %d (max %" PRIzd ")", (depth), \
((ctx)->label_stack.size)); \
- return WASM_ERROR; \
+ return WABT_ERROR; \
} \
} while (0)
@@ -56,7 +56,7 @@
if ((local_index) >= max_local_index) { \
print_error((ctx), "invalid local_index: %d (max %d)", (local_index), \
max_local_index); \
- return WASM_ERROR; \
+ return WABT_ERROR; \
} \
} while (0)
@@ -66,7 +66,7 @@
if ((global_index) >= max_global_index) { \
print_error((ctx), "invalid global_index: %d (max %d)", (global_index), \
max_global_index); \
- return WASM_ERROR; \
+ return WABT_ERROR; \
} \
} while (0)
@@ -76,11 +76,11 @@
#define RETURN_OK_IF_TOP_TYPE_IS_ANY(ctx) \
if (top_type_is_any(ctx)) \
- return WASM_OK
+ return WABT_OK
typedef uint32_t Uint32;
-WASM_DEFINE_VECTOR(uint32, Uint32);
-WASM_DEFINE_VECTOR(uint32_vector, Uint32Vector);
+WABT_DEFINE_VECTOR(uint32, Uint32);
+WABT_DEFINE_VECTOR(uint32_vector, Uint32Vector);
typedef enum LabelType {
LABEL_TYPE_FUNC,
@@ -92,27 +92,27 @@ typedef enum LabelType {
typedef struct Label {
LabelType label_type;
- WasmTypeVector sig;
+ WabtTypeVector sig;
uint32_t type_stack_limit;
uint32_t offset; /* branch location in the istream */
uint32_t fixup_offset;
} Label;
-WASM_DEFINE_VECTOR(label, Label);
+WABT_DEFINE_VECTOR(label, Label);
typedef struct Context {
- WasmAllocator* allocator;
- WasmBinaryReader* reader;
- WasmBinaryErrorHandler* error_handler;
- WasmAllocator* memory_allocator;
- WasmInterpreterEnvironment* env;
- WasmInterpreterModule* module;
- WasmInterpreterFunc* current_func;
- WasmTypeVector type_stack;
+ WabtAllocator* allocator;
+ WabtBinaryReader* reader;
+ WabtBinaryErrorHandler* error_handler;
+ WabtAllocator* memory_allocator;
+ WabtInterpreterEnvironment* env;
+ WabtInterpreterModule* module;
+ WabtInterpreterFunc* current_func;
+ WabtTypeVector type_stack;
LabelVector label_stack;
Uint32VectorVector func_fixups;
Uint32VectorVector depth_fixups;
uint32_t depth;
- WasmMemoryWriter istream_writer;
+ WabtMemoryWriter istream_writer;
uint32_t istream_offset;
/* mappings from module index space to env index space; this won't just be a
* translation, because imported values will be resolved as well */
@@ -124,10 +124,10 @@ typedef struct Context {
uint32_t num_global_imports;
/* values cached in the Context so they can be shared between callbacks */
- WasmInterpreterTypedValue init_expr_value;
+ WabtInterpreterTypedValue init_expr_value;
uint32_t table_offset;
- WasmBool is_host_import;
- WasmInterpreterModule* host_import_module;
+ WabtBool is_host_import;
+ WabtInterpreterModule* host_import_module;
uint32_t import_env_index;
} Context;
@@ -147,10 +147,10 @@ static void handle_error(uint32_t offset, const char* message, Context* ctx) {
}
}
-static void WASM_PRINTF_FORMAT(2, 3)
+static void WABT_PRINTF_FORMAT(2, 3)
print_error(Context* ctx, const char* format, ...) {
- WASM_SNPRINTF_ALLOCA(buffer, length, format);
- handle_error(WASM_INVALID_OFFSET, buffer, ctx);
+ WABT_SNPRINTF_ALLOCA(buffer, length, format);
+ handle_error(WABT_INVALID_OFFSET, buffer, ctx);
}
static uint32_t translate_sig_index_to_env(Context* ctx, uint32_t sig_index) {
@@ -158,14 +158,14 @@ static uint32_t translate_sig_index_to_env(Context* ctx, uint32_t sig_index) {
return ctx->sig_index_mapping.data[sig_index];
}
-static WasmInterpreterFuncSignature* get_signature_by_env_index(
+static WabtInterpreterFuncSignature* get_signature_by_env_index(
Context* ctx,
uint32_t sig_index) {
assert(sig_index < ctx->env->sigs.size);
return &ctx->env->sigs.data[sig_index];
}
-static WasmInterpreterFuncSignature* get_signature_by_module_index(
+static WabtInterpreterFuncSignature* get_signature_by_module_index(
Context* ctx,
uint32_t sig_index) {
return get_signature_by_env_index(ctx,
@@ -183,13 +183,13 @@ static uint32_t translate_module_func_index_to_defined(Context* ctx,
return func_index - ctx->num_func_imports;
}
-static WasmInterpreterFunc* get_func_by_env_index(Context* ctx,
+static WabtInterpreterFunc* get_func_by_env_index(Context* ctx,
uint32_t func_index) {
assert(func_index < ctx->env->funcs.size);
return &ctx->env->funcs.data[func_index];
}
-static WasmInterpreterFunc* get_func_by_module_index(Context* ctx,
+static WabtInterpreterFunc* get_func_by_module_index(Context* ctx,
uint32_t func_index) {
return get_func_by_env_index(ctx,
translate_func_index_to_env(ctx, func_index));
@@ -201,25 +201,25 @@ static uint32_t translate_global_index_to_env(Context* ctx,
return ctx->global_index_mapping.data[global_index];
}
-static WasmInterpreterGlobal* get_global_by_env_index(Context* ctx,
+static WabtInterpreterGlobal* get_global_by_env_index(Context* ctx,
uint32_t global_index) {
assert(global_index < ctx->env->globals.size);
return &ctx->env->globals.data[global_index];
}
-static WasmInterpreterGlobal* get_global_by_module_index(
+static WabtInterpreterGlobal* get_global_by_module_index(
Context* ctx,
uint32_t global_index) {
return get_global_by_env_index(
ctx, translate_global_index_to_env(ctx, global_index));
}
-static WasmType get_global_type_by_module_index(Context* ctx,
+static WabtType get_global_type_by_module_index(Context* ctx,
uint32_t global_index) {
return get_global_by_module_index(ctx, global_index)->typed_value.type;
}
-static WasmType get_local_type_by_index(WasmInterpreterFunc* func,
+static WabtType get_local_type_by_index(WabtInterpreterFunc* func,
uint32_t local_index) {
assert(!func->is_host);
assert(local_index < func->defined.param_and_local_types.size);
@@ -235,7 +235,7 @@ static uint32_t get_istream_offset(Context* ctx) {
return ctx->istream_offset;
}
-static WasmResult emit_data_at(Context* ctx,
+static WabtResult emit_data_at(Context* ctx,
size_t offset,
const void* data,
size_t size) {
@@ -243,86 +243,86 @@ static WasmResult emit_data_at(Context* ctx,
offset, data, size, ctx->istream_writer.base.user_data);
}
-static WasmResult emit_data(Context* ctx, const void* data, size_t size) {
+static WabtResult emit_data(Context* ctx, const void* data, size_t size) {
CHECK_RESULT(emit_data_at(ctx, ctx->istream_offset, data, size));
ctx->istream_offset += size;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult emit_opcode(Context* ctx, WasmOpcode opcode) {
+static WabtResult emit_opcode(Context* ctx, WabtOpcode opcode) {
return emit_data(ctx, &opcode, sizeof(uint8_t));
}
-static WasmResult emit_i8(Context* ctx, uint8_t value) {
+static WabtResult emit_i8(Context* ctx, uint8_t value) {
return emit_data(ctx, &value, sizeof(value));
}
-static WasmResult emit_i32(Context* ctx, uint32_t value) {
+static WabtResult emit_i32(Context* ctx, uint32_t value) {
return emit_data(ctx, &value, sizeof(value));
}
-static WasmResult emit_i64(Context* ctx, uint64_t value) {
+static WabtResult emit_i64(Context* ctx, uint64_t value) {
return emit_data(ctx, &value, sizeof(value));
}
-static WasmResult emit_i32_at(Context* ctx, uint32_t offset, uint32_t value) {
+static WabtResult emit_i32_at(Context* ctx, uint32_t offset, uint32_t value) {
return emit_data_at(ctx, offset, &value, sizeof(value));
}
-static WasmResult emit_drop_keep(Context* ctx, uint32_t drop, uint8_t keep) {
+static WabtResult emit_drop_keep(Context* ctx, uint32_t drop, uint8_t keep) {
assert(drop != UINT32_MAX);
assert(keep <= 1);
if (drop > 0) {
if (drop == 1 && keep == 0) {
LOGF("%3" PRIzd ": drop\n", ctx->type_stack.size);
- CHECK_RESULT(emit_opcode(ctx, WASM_OPCODE_DROP));
+ CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_DROP));
} else {
LOGF("%3" PRIzd ": drop_keep %u %u\n", ctx->type_stack.size, drop, keep);
- CHECK_RESULT(emit_opcode(ctx, WASM_OPCODE_DROP_KEEP));
+ CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_DROP_KEEP));
CHECK_RESULT(emit_i32(ctx, drop));
CHECK_RESULT(emit_i8(ctx, keep));
}
}
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult append_fixup(Context* ctx,
+static WabtResult append_fixup(Context* ctx,
Uint32VectorVector* fixups_vector,
uint32_t index) {
if (index >= fixups_vector->size)
- wasm_resize_uint32_vector_vector(ctx->allocator, fixups_vector, index + 1);
+ wabt_resize_uint32_vector_vector(ctx->allocator, fixups_vector, index + 1);
Uint32Vector* fixups = &fixups_vector->data[index];
uint32_t offset = get_istream_offset(ctx);
- wasm_append_uint32_value(ctx->allocator, fixups, &offset);
- return WASM_OK;
+ wabt_append_uint32_value(ctx->allocator, fixups, &offset);
+ return WABT_OK;
}
-static WasmResult emit_br_offset(Context* ctx,
+static WabtResult emit_br_offset(Context* ctx,
uint32_t depth,
uint32_t offset) {
- if (offset == WASM_INVALID_OFFSET)
+ if (offset == WABT_INVALID_OFFSET)
CHECK_RESULT(append_fixup(ctx, &ctx->depth_fixups, depth));
CHECK_RESULT(emit_i32(ctx, offset));
- return WASM_OK;
+ return WABT_OK;
}
static uint32_t get_label_br_arity(Label* label) {
return label->label_type != LABEL_TYPE_LOOP ? label->sig.size : 0;
}
-static WasmResult emit_br(Context* ctx, uint32_t depth) {
+static WabtResult emit_br(Context* ctx, uint32_t depth) {
Label* label = get_label(ctx, depth);
uint32_t arity = get_label_br_arity(label);
assert(ctx->type_stack.size >= label->type_stack_limit + arity);
uint32_t drop_count =
(ctx->type_stack.size - label->type_stack_limit) - arity;
CHECK_RESULT(emit_drop_keep(ctx, drop_count, arity));
- CHECK_RESULT(emit_opcode(ctx, WASM_OPCODE_BR));
+ CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_BR));
CHECK_RESULT(emit_br_offset(ctx, depth, label->offset));
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult emit_br_table_offset(Context* ctx, uint32_t depth) {
+static WabtResult emit_br_table_offset(Context* ctx, uint32_t depth) {
Label* label = get_label(ctx, depth);
uint32_t arity = get_label_br_arity(label);
assert(ctx->type_stack.size >= label->type_stack_limit + arity);
@@ -331,14 +331,14 @@ static WasmResult emit_br_table_offset(Context* ctx, uint32_t depth) {
CHECK_RESULT(emit_br_offset(ctx, depth, label->offset));
CHECK_RESULT(emit_i32(ctx, drop_count));
CHECK_RESULT(emit_i8(ctx, arity));
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult fixup_top_label(Context* ctx, uint32_t offset) {
+static WabtResult fixup_top_label(Context* ctx, uint32_t offset) {
uint32_t top = ctx->label_stack.size - 1;
if (top >= ctx->depth_fixups.size) {
/* nothing to fixup */
- return WASM_OK;
+ return WABT_OK;
}
Uint32Vector* fixups = &ctx->depth_fixups.data[top];
@@ -348,126 +348,126 @@ static WasmResult fixup_top_label(Context* ctx, uint32_t offset) {
/* reduce the size to 0 in case this gets reused. Keep the allocations for
* later use */
fixups->size = 0;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult emit_func_offset(Context* ctx,
- WasmInterpreterFunc* func,
+static WabtResult emit_func_offset(Context* ctx,
+ WabtInterpreterFunc* func,
uint32_t func_index) {
- if (func->defined.offset == WASM_INVALID_OFFSET) {
+ if (func->defined.offset == WABT_INVALID_OFFSET) {
uint32_t defined_index =
translate_module_func_index_to_defined(ctx, func_index);
CHECK_RESULT(append_fixup(ctx, &ctx->func_fixups, defined_index));
}
CHECK_RESULT(emit_i32(ctx, func->defined.offset));
- return WASM_OK;
+ return WABT_OK;
}
-static void on_error(WasmBinaryReaderContext* ctx, const char* message) {
+static void on_error(WabtBinaryReaderContext* ctx, const char* message) {
handle_error(ctx->offset, message, ctx->user_data);
}
-static WasmResult on_signature_count(uint32_t count, void* user_data) {
+static WabtResult on_signature_count(uint32_t count, void* user_data) {
Context* ctx = user_data;
- wasm_resize_uint32_vector(ctx->allocator, &ctx->sig_index_mapping, count);
+ wabt_resize_uint32_vector(ctx->allocator, &ctx->sig_index_mapping, count);
uint32_t i;
for (i = 0; i < count; ++i)
ctx->sig_index_mapping.data[i] = ctx->env->sigs.size + i;
- wasm_resize_interpreter_func_signature_vector(ctx->allocator, &ctx->env->sigs,
+ wabt_resize_interpreter_func_signature_vector(ctx->allocator, &ctx->env->sigs,
ctx->env->sigs.size + count);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_signature(uint32_t index,
+static WabtResult on_signature(uint32_t index,
uint32_t param_count,
- WasmType* param_types,
+ WabtType* param_types,
uint32_t result_count,
- WasmType* result_types,
+ WabtType* result_types,
void* user_data) {
Context* ctx = user_data;
- WasmInterpreterFuncSignature* sig = get_signature_by_module_index(ctx, index);
+ WabtInterpreterFuncSignature* sig = get_signature_by_module_index(ctx, index);
- wasm_reserve_types(ctx->allocator, &sig->param_types, param_count);
+ wabt_reserve_types(ctx->allocator, &sig->param_types, param_count);
sig->param_types.size = param_count;
- memcpy(sig->param_types.data, param_types, param_count * sizeof(WasmType));
+ memcpy(sig->param_types.data, param_types, param_count * sizeof(WabtType));
- wasm_reserve_types(ctx->allocator, &sig->result_types, result_count);
+ wabt_reserve_types(ctx->allocator, &sig->result_types, result_count);
sig->result_types.size = result_count;
- memcpy(sig->result_types.data, result_types, result_count * sizeof(WasmType));
- return WASM_OK;
+ memcpy(sig->result_types.data, result_types, result_count * sizeof(WabtType));
+ return WABT_OK;
}
-static WasmResult on_import_count(uint32_t count, void* user_data) {
+static WabtResult on_import_count(uint32_t count, void* user_data) {
Context* ctx = user_data;
- wasm_new_interpreter_import_array(ctx->allocator,
+ wabt_new_interpreter_import_array(ctx->allocator,
&ctx->module->defined.imports, count);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_import(uint32_t index,
- WasmStringSlice module_name,
- WasmStringSlice field_name,
+static WabtResult on_import(uint32_t index,
+ WabtStringSlice module_name,
+ WabtStringSlice field_name,
void* user_data) {
Context* ctx = user_data;
assert(index < ctx->module->defined.imports.size);
- WasmInterpreterImport* import = &ctx->module->defined.imports.data[index];
- import->module_name = wasm_dup_string_slice(ctx->allocator, module_name);
- import->field_name = wasm_dup_string_slice(ctx->allocator, field_name);
- int module_index = wasm_find_binding_index_by_name(
+ WabtInterpreterImport* import = &ctx->module->defined.imports.data[index];
+ import->module_name = wabt_dup_string_slice(ctx->allocator, module_name);
+ import->field_name = wabt_dup_string_slice(ctx->allocator, field_name);
+ int module_index = wabt_find_binding_index_by_name(
&ctx->env->registered_module_bindings, &import->module_name);
if (module_index < 0) {
print_error(ctx, "unknown import module \"" PRIstringslice "\"",
- WASM_PRINTF_STRING_SLICE_ARG(import->module_name));
- return WASM_ERROR;
+ WABT_PRINTF_STRING_SLICE_ARG(import->module_name));
+ return WABT_ERROR;
}
assert((size_t)module_index < ctx->env->modules.size);
- WasmInterpreterModule* module = &ctx->env->modules.data[module_index];
+ WabtInterpreterModule* module = &ctx->env->modules.data[module_index];
if (module->is_host) {
/* We don't yet know the kind of a host import module, so just assume it
* exists for now. We'll fail later (in on_import_* below) if it doesn't
* exist). */
- ctx->is_host_import = WASM_TRUE;
+ ctx->is_host_import = WABT_TRUE;
ctx->host_import_module = module;
} else {
- WasmInterpreterExport* export =
- wasm_get_interpreter_export_by_name(module, &import->field_name);
+ WabtInterpreterExport* export =
+ wabt_get_interpreter_export_by_name(module, &import->field_name);
if (!export) {
print_error(ctx, "unknown module field \"" PRIstringslice "\"",
- WASM_PRINTF_STRING_SLICE_ARG(import->field_name));
- return WASM_ERROR;
+ WABT_PRINTF_STRING_SLICE_ARG(import->field_name));
+ return WABT_ERROR;
}
import->kind = export->kind;
- ctx->is_host_import = WASM_FALSE;
+ ctx->is_host_import = WABT_FALSE;
ctx->import_env_index = export->index;
}
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult check_import_kind(Context* ctx,
- WasmInterpreterImport* import,
- WasmExternalKind expected_kind) {
+static WabtResult check_import_kind(Context* ctx,
+ WabtInterpreterImport* import,
+ WabtExternalKind expected_kind) {
if (import->kind != expected_kind) {
print_error(ctx, "expected import \"" PRIstringslice "." PRIstringslice
"\" to have kind %s, not %s",
- WASM_PRINTF_STRING_SLICE_ARG(import->module_name),
- WASM_PRINTF_STRING_SLICE_ARG(import->field_name),
- wasm_get_kind_name(expected_kind),
- wasm_get_kind_name(import->kind));
- return WASM_ERROR;
+ WABT_PRINTF_STRING_SLICE_ARG(import->module_name),
+ WABT_PRINTF_STRING_SLICE_ARG(import->field_name),
+ wabt_get_kind_name(expected_kind),
+ wabt_get_kind_name(import->kind));
+ return WABT_ERROR;
}
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult check_import_limits(Context* ctx,
- const WasmLimits* declared_limits,
- const WasmLimits* actual_limits) {
+static WabtResult check_import_limits(Context* ctx,
+ const WabtLimits* declared_limits,
+ const WabtLimits* actual_limits) {
if (actual_limits->initial < declared_limits->initial) {
print_error(ctx,
"actual size (%" PRIu64 ") smaller than declared (%" PRIu64 ")",
actual_limits->initial, declared_limits->initial);
- return WASM_ERROR;
+ return WABT_ERROR;
}
if (declared_limits->has_max) {
@@ -475,39 +475,39 @@ static WasmResult check_import_limits(Context* ctx,
print_error(ctx,
"max size (unspecified) larger than declared (%" PRIu64 ")",
declared_limits->max);
- return WASM_ERROR;
+ return WABT_ERROR;
} else if (actual_limits->max > declared_limits->max) {
print_error(ctx,
"max size (%" PRIu64 ") larger than declared (%" PRIu64 ")",
actual_limits->max, declared_limits->max);
- return WASM_ERROR;
+ return WABT_ERROR;
}
}
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult append_export(Context* ctx,
- WasmInterpreterModule* module,
- WasmExternalKind kind,
+static WabtResult append_export(Context* ctx,
+ WabtInterpreterModule* module,
+ WabtExternalKind kind,
uint32_t item_index,
- WasmStringSlice name) {
- if (wasm_find_binding_index_by_name(&module->export_bindings, &name) != -1) {
+ WabtStringSlice name) {
+ if (wabt_find_binding_index_by_name(&module->export_bindings, &name) != -1) {
print_error(ctx, "duplicate export \"" PRIstringslice "\"",
- WASM_PRINTF_STRING_SLICE_ARG(name));
- return WASM_ERROR;
+ WABT_PRINTF_STRING_SLICE_ARG(name));
+ return WABT_ERROR;
}
- WasmInterpreterExport* export =
- wasm_append_interpreter_export(ctx->allocator, &module->exports);
- export->name = wasm_dup_string_slice(ctx->allocator, name);
+ WabtInterpreterExport* export =
+ wabt_append_interpreter_export(ctx->allocator, &module->exports);
+ export->name = wabt_dup_string_slice(ctx->allocator, name);
export->kind = kind;
export->index = item_index;
- WasmBinding* binding = wasm_insert_binding(
+ WabtBinding* binding = wabt_insert_binding(
ctx->allocator, &module->export_bindings, &export->name);
binding->index = module->exports.size - 1;
- return WASM_OK;
+ return WABT_OK;
}
static void on_host_import_print_error(const char* msg, void* user_data) {
@@ -515,92 +515,92 @@ static void on_host_import_print_error(const char* msg, void* user_data) {
print_error(ctx, "%s", msg);
}
-static WasmPrintErrorCallback make_print_error_callback(Context* ctx) {
- WasmPrintErrorCallback result;
+static WabtPrintErrorCallback make_print_error_callback(Context* ctx) {
+ WabtPrintErrorCallback result;
result.print_error = on_host_import_print_error;
result.user_data = ctx;
return result;
}
-static WasmResult on_import_func(uint32_t import_index,
+static WabtResult on_import_func(uint32_t import_index,
uint32_t func_index,
uint32_t sig_index,
void* user_data) {
Context* ctx = user_data;
assert(import_index < ctx->module->defined.imports.size);
- WasmInterpreterImport* import =
+ WabtInterpreterImport* import =
&ctx->module->defined.imports.data[import_index];
assert(sig_index < ctx->env->sigs.size);
import->func.sig_index = translate_sig_index_to_env(ctx, sig_index);
uint32_t func_env_index;
if (ctx->is_host_import) {
- WasmInterpreterFunc* func =
- wasm_append_interpreter_func(ctx->allocator, &ctx->env->funcs);
- func->is_host = WASM_TRUE;
+ WabtInterpreterFunc* func =
+ wabt_append_interpreter_func(ctx->allocator, &ctx->env->funcs);
+ func->is_host = WABT_TRUE;
func->sig_index = import->func.sig_index;
func->host.module_name = import->module_name;
func->host.field_name = import->field_name;
- WasmInterpreterHostImportDelegate* host_delegate =
+ WabtInterpreterHostImportDelegate* host_delegate =
&ctx->host_import_module->host.import_delegate;
- WasmInterpreterFuncSignature* sig = &ctx->env->sigs.data[func->sig_index];
+ WabtInterpreterFuncSignature* sig = &ctx->env->sigs.data[func->sig_index];
CHECK_RESULT(host_delegate->import_func(import, func, sig,
make_print_error_callback(ctx),
host_delegate->user_data));
assert(func->host.callback);
func_env_index = ctx->env->funcs.size - 1;
- append_export(ctx, ctx->host_import_module, WASM_EXTERNAL_KIND_FUNC,
+ append_export(ctx, ctx->host_import_module, WABT_EXTERNAL_KIND_FUNC,
func_env_index, import->field_name);
} else {
- CHECK_RESULT(check_import_kind(ctx, import, WASM_EXTERNAL_KIND_FUNC));
+ CHECK_RESULT(check_import_kind(ctx, import, WABT_EXTERNAL_KIND_FUNC));
assert(ctx->import_env_index < ctx->env->funcs.size);
- WasmInterpreterFunc* func = &ctx->env->funcs.data[ctx->import_env_index];
- if (!wasm_func_signatures_are_equal(ctx->env, import->func.sig_index,
+ WabtInterpreterFunc* func = &ctx->env->funcs.data[ctx->import_env_index];
+ if (!wabt_func_signatures_are_equal(ctx->env, import->func.sig_index,
func->sig_index)) {
print_error(ctx, "import signature mismatch");
- return WASM_ERROR;
+ return WABT_ERROR;
}
func_env_index = ctx->import_env_index;
}
- wasm_append_uint32_value(ctx->allocator, &ctx->func_index_mapping,
+ wabt_append_uint32_value(ctx->allocator, &ctx->func_index_mapping,
&func_env_index);
ctx->num_func_imports++;
- return WASM_OK;
+ return WABT_OK;
}
-static void init_table_func_indexes(Context* ctx, WasmInterpreterTable* table) {
- wasm_new_uint32_array(ctx->allocator, &table->func_indexes,
+static void init_table_func_indexes(Context* ctx, WabtInterpreterTable* table) {
+ wabt_new_uint32_array(ctx->allocator, &table->func_indexes,
table->limits.initial);
size_t i;
for (i = 0; i < table->func_indexes.size; ++i)
- table->func_indexes.data[i] = WASM_INVALID_INDEX;
+ table->func_indexes.data[i] = WABT_INVALID_INDEX;
}
-static WasmResult on_import_table(uint32_t import_index,
+static WabtResult on_import_table(uint32_t import_index,
uint32_t table_index,
- WasmType elem_type,
- const WasmLimits* elem_limits,
+ WabtType elem_type,
+ const WabtLimits* elem_limits,
void* user_data) {
Context* ctx = user_data;
- if (ctx->module->table_index != WASM_INVALID_INDEX) {
+ if (ctx->module->table_index != WABT_INVALID_INDEX) {
print_error(ctx, "only one table allowed");
- return WASM_ERROR;
+ return WABT_ERROR;
}
assert(import_index < ctx->module->defined.imports.size);
- WasmInterpreterImport* import =
+ WabtInterpreterImport* import =
&ctx->module->defined.imports.data[import_index];
if (ctx->is_host_import) {
- WasmInterpreterTable* table =
- wasm_append_interpreter_table(ctx->allocator, &ctx->env->tables);
+ WabtInterpreterTable* table =
+ wabt_append_interpreter_table(ctx->allocator, &ctx->env->tables);
table->limits = *elem_limits;
init_table_func_indexes(ctx, table);
- WasmInterpreterHostImportDelegate* host_delegate =
+ WabtInterpreterHostImportDelegate* host_delegate =
&ctx->host_import_module->host.import_delegate;
CHECK_RESULT(host_delegate->import_table(import, table,
make_print_error_callback(ctx),
@@ -609,40 +609,40 @@ static WasmResult on_import_table(uint32_t import_index,
CHECK_RESULT(check_import_limits(ctx, elem_limits, &table->limits));
ctx->module->table_index = ctx->env->tables.size - 1;
- append_export(ctx, ctx->host_import_module, WASM_EXTERNAL_KIND_TABLE,
+ append_export(ctx, ctx->host_import_module, WABT_EXTERNAL_KIND_TABLE,
ctx->module->table_index, import->field_name);
} else {
- CHECK_RESULT(check_import_kind(ctx, import, WASM_EXTERNAL_KIND_TABLE));
+ CHECK_RESULT(check_import_kind(ctx, import, WABT_EXTERNAL_KIND_TABLE));
assert(ctx->import_env_index < ctx->env->tables.size);
- WasmInterpreterTable* table = &ctx->env->tables.data[ctx->import_env_index];
+ WabtInterpreterTable* table = &ctx->env->tables.data[ctx->import_env_index];
CHECK_RESULT(check_import_limits(ctx, elem_limits, &table->limits));
import->table.limits = *elem_limits;
ctx->module->table_index = ctx->import_env_index;
}
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_import_memory(uint32_t import_index,
+static WabtResult on_import_memory(uint32_t import_index,
uint32_t memory_index,
- const WasmLimits* page_limits,
+ const WabtLimits* page_limits,
void* user_data) {
Context* ctx = user_data;
- if (ctx->module->memory_index != WASM_INVALID_INDEX) {
+ if (ctx->module->memory_index != WABT_INVALID_INDEX) {
print_error(ctx, "only one memory allowed");
- return WASM_ERROR;
+ return WABT_ERROR;
}
assert(import_index < ctx->module->defined.imports.size);
- WasmInterpreterImport* import =
+ WabtInterpreterImport* import =
&ctx->module->defined.imports.data[import_index];
if (ctx->is_host_import) {
- WasmInterpreterMemory* memory =
- wasm_append_interpreter_memory(ctx->allocator, &ctx->env->memories);
+ WabtInterpreterMemory* memory =
+ wabt_append_interpreter_memory(ctx->allocator, &ctx->env->memories);
memory->allocator = ctx->memory_allocator;
- WasmInterpreterHostImportDelegate* host_delegate =
+ WabtInterpreterHostImportDelegate* host_delegate =
&ctx->host_import_module->host.import_delegate;
CHECK_RESULT(host_delegate->import_memory(import, memory,
make_print_error_callback(ctx),
@@ -652,330 +652,330 @@ static WasmResult on_import_memory(uint32_t import_index,
CHECK_RESULT(check_import_limits(ctx, page_limits, &memory->page_limits));
ctx->module->memory_index = ctx->env->memories.size - 1;
- append_export(ctx, ctx->host_import_module, WASM_EXTERNAL_KIND_MEMORY,
+ append_export(ctx, ctx->host_import_module, WABT_EXTERNAL_KIND_MEMORY,
ctx->module->memory_index, import->field_name);
} else {
- CHECK_RESULT(check_import_kind(ctx, import, WASM_EXTERNAL_KIND_MEMORY));
+ CHECK_RESULT(check_import_kind(ctx, import, WABT_EXTERNAL_KIND_MEMORY));
assert(ctx->import_env_index < ctx->env->memories.size);
- WasmInterpreterMemory* memory =
+ WabtInterpreterMemory* memory =
&ctx->env->memories.data[ctx->import_env_index];
CHECK_RESULT(check_import_limits(ctx, page_limits, &memory->page_limits));
import->memory.limits = *page_limits;
ctx->module->memory_index = ctx->import_env_index;
}
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_import_global(uint32_t import_index,
+static WabtResult on_import_global(uint32_t import_index,
uint32_t global_index,
- WasmType type,
- WasmBool mutable,
+ WabtType type,
+ WabtBool mutable,
void* user_data) {
Context* ctx = user_data;
assert(import_index < ctx->module->defined.imports.size);
- WasmInterpreterImport* import =
+ WabtInterpreterImport* import =
&ctx->module->defined.imports.data[import_index];
uint32_t global_env_index = ctx->env->globals.size - 1;
if (ctx->is_host_import) {
- WasmInterpreterGlobal* global =
- wasm_append_interpreter_global(ctx->allocator, &ctx->env->globals);
+ WabtInterpreterGlobal* global =
+ wabt_append_interpreter_global(ctx->allocator, &ctx->env->globals);
global->typed_value.type = type;
global->mutable_ = mutable;
- WasmInterpreterHostImportDelegate* host_delegate =
+ WabtInterpreterHostImportDelegate* host_delegate =
&ctx->host_import_module->host.import_delegate;
CHECK_RESULT(host_delegate->import_global(import, global,
make_print_error_callback(ctx),
host_delegate->user_data));
global_env_index = ctx->env->globals.size - 1;
- append_export(ctx, ctx->host_import_module, WASM_EXTERNAL_KIND_GLOBAL,
+ append_export(ctx, ctx->host_import_module, WABT_EXTERNAL_KIND_GLOBAL,
global_env_index, import->field_name);
} else {
- CHECK_RESULT(check_import_kind(ctx, import, WASM_EXTERNAL_KIND_GLOBAL));
+ CHECK_RESULT(check_import_kind(ctx, import, WABT_EXTERNAL_KIND_GLOBAL));
// TODO: check type and mutability
import->global.type = type;
import->global.mutable_ = mutable;
global_env_index = ctx->import_env_index;
}
- wasm_append_uint32_value(ctx->allocator, &ctx->global_index_mapping,
+ wabt_append_uint32_value(ctx->allocator, &ctx->global_index_mapping,
&global_env_index);
ctx->num_global_imports++;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_function_signatures_count(uint32_t count,
+static WabtResult on_function_signatures_count(uint32_t count,
void* user_data) {
Context* ctx = user_data;
size_t old_size = ctx->func_index_mapping.size;
- wasm_resize_uint32_vector(ctx->allocator, &ctx->func_index_mapping,
+ wabt_resize_uint32_vector(ctx->allocator, &ctx->func_index_mapping,
old_size + count);
uint32_t i;
for (i = 0; i < count; ++i)
ctx->func_index_mapping.data[old_size + i] = ctx->env->funcs.size + i;
- wasm_resize_interpreter_func_vector(ctx->allocator, &ctx->env->funcs,
+ wabt_resize_interpreter_func_vector(ctx->allocator, &ctx->env->funcs,
ctx->env->funcs.size + count);
- wasm_resize_uint32_vector_vector(ctx->allocator, &ctx->func_fixups, count);
- return WASM_OK;
+ wabt_resize_uint32_vector_vector(ctx->allocator, &ctx->func_fixups, count);
+ return WABT_OK;
}
-static WasmResult on_function_signature(uint32_t index,
+static WabtResult on_function_signature(uint32_t index,
uint32_t sig_index,
void* user_data) {
Context* ctx = user_data;
- WasmInterpreterFunc* func = get_func_by_module_index(ctx, index);
- func->defined.offset = WASM_INVALID_OFFSET;
+ WabtInterpreterFunc* func = get_func_by_module_index(ctx, index);
+ func->defined.offset = WABT_INVALID_OFFSET;
func->sig_index = translate_sig_index_to_env(ctx, sig_index);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_table(uint32_t index,
- WasmType elem_type,
- const WasmLimits* elem_limits,
+static WabtResult on_table(uint32_t index,
+ WabtType elem_type,
+ const WabtLimits* elem_limits,
void* user_data) {
Context* ctx = user_data;
- if (ctx->module->table_index != WASM_INVALID_INDEX) {
+ if (ctx->module->table_index != WABT_INVALID_INDEX) {
print_error(ctx, "only one table allowed");
- return WASM_ERROR;
+ return WABT_ERROR;
}
- WasmInterpreterTable* table =
- wasm_append_interpreter_table(ctx->allocator, &ctx->env->tables);
+ WabtInterpreterTable* table =
+ wabt_append_interpreter_table(ctx->allocator, &ctx->env->tables);
table->limits = *elem_limits;
init_table_func_indexes(ctx, table);
ctx->module->table_index = ctx->env->tables.size - 1;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_memory(uint32_t index,
- const WasmLimits* page_limits,
+static WabtResult on_memory(uint32_t index,
+ const WabtLimits* page_limits,
void* user_data) {
Context* ctx = user_data;
- if (ctx->module->memory_index != WASM_INVALID_INDEX) {
+ if (ctx->module->memory_index != WABT_INVALID_INDEX) {
print_error(ctx, "only one memory allowed");
- return WASM_ERROR;
+ return WABT_ERROR;
}
- WasmInterpreterMemory* memory =
- wasm_append_interpreter_memory(ctx->allocator, &ctx->env->memories);
+ WabtInterpreterMemory* memory =
+ wabt_append_interpreter_memory(ctx->allocator, &ctx->env->memories);
memory->allocator = ctx->memory_allocator;
memory->page_limits = *page_limits;
- memory->byte_size = page_limits->initial * WASM_PAGE_SIZE;
- memory->data = wasm_alloc_zero(ctx->memory_allocator, memory->byte_size,
- WASM_DEFAULT_ALIGN);
+ memory->byte_size = page_limits->initial * WABT_PAGE_SIZE;
+ memory->data = wabt_alloc_zero(ctx->memory_allocator, memory->byte_size,
+ WABT_DEFAULT_ALIGN);
ctx->module->memory_index = ctx->env->memories.size - 1;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_global_count(uint32_t count, void* user_data) {
+static WabtResult on_global_count(uint32_t count, void* user_data) {
Context* ctx = user_data;
size_t old_size = ctx->global_index_mapping.size;
- wasm_resize_uint32_vector(ctx->allocator, &ctx->global_index_mapping,
+ wabt_resize_uint32_vector(ctx->allocator, &ctx->global_index_mapping,
old_size + count);
uint32_t i;
for (i = 0; i < count; ++i)
ctx->global_index_mapping.data[old_size + i] = ctx->env->globals.size + i;
- wasm_resize_interpreter_global_vector(ctx->allocator, &ctx->env->globals,
+ wabt_resize_interpreter_global_vector(ctx->allocator, &ctx->env->globals,
ctx->env->globals.size + count);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult begin_global(uint32_t index,
- WasmType type,
- WasmBool mutable_,
+static WabtResult begin_global(uint32_t index,
+ WabtType type,
+ WabtBool mutable_,
void* user_data) {
Context* ctx = user_data;
- WasmInterpreterGlobal* global = get_global_by_module_index(ctx, index);
+ WabtInterpreterGlobal* global = get_global_by_module_index(ctx, index);
global->typed_value.type = type;
global->mutable_ = mutable_;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult end_global_init_expr(uint32_t index, void* user_data) {
+static WabtResult end_global_init_expr(uint32_t index, void* user_data) {
Context* ctx = user_data;
- WasmInterpreterGlobal* global = get_global_by_module_index(ctx, index);
+ WabtInterpreterGlobal* global = get_global_by_module_index(ctx, index);
if (ctx->init_expr_value.type != global->typed_value.type) {
print_error(ctx, "type mismatch in global, expected %s but got %s.",
- wasm_get_type_name(global->typed_value.type),
- wasm_get_type_name(ctx->init_expr_value.type));
- return WASM_ERROR;
+ wabt_get_type_name(global->typed_value.type),
+ wabt_get_type_name(ctx->init_expr_value.type));
+ return WABT_ERROR;
}
global->typed_value = ctx->init_expr_value;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_init_expr_f32_const_expr(uint32_t index,
+static WabtResult on_init_expr_f32_const_expr(uint32_t index,
uint32_t value_bits,
void* user_data) {
Context* ctx = user_data;
- ctx->init_expr_value.type = WASM_TYPE_F32;
+ ctx->init_expr_value.type = WABT_TYPE_F32;
ctx->init_expr_value.value.f32_bits = value_bits;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_init_expr_f64_const_expr(uint32_t index,
+static WabtResult on_init_expr_f64_const_expr(uint32_t index,
uint64_t value_bits,
void* user_data) {
Context* ctx = user_data;
- ctx->init_expr_value.type = WASM_TYPE_F64;
+ ctx->init_expr_value.type = WABT_TYPE_F64;
ctx->init_expr_value.value.f64_bits = value_bits;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_init_expr_get_global_expr(uint32_t index,
+static WabtResult on_init_expr_get_global_expr(uint32_t index,
uint32_t global_index,
void* user_data) {
Context* ctx = user_data;
if (global_index >= ctx->num_global_imports) {
print_error(ctx,
"initializer expression can only reference an imported global");
- return WASM_ERROR;
+ return WABT_ERROR;
}
- WasmInterpreterGlobal* ref_global =
+ WabtInterpreterGlobal* ref_global =
get_global_by_module_index(ctx, global_index);
if (ref_global->mutable_) {
print_error(ctx,
"initializer expression cannot reference a mutable global");
- return WASM_ERROR;
+ return WABT_ERROR;
}
ctx->init_expr_value = ref_global->typed_value;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_init_expr_i32_const_expr(uint32_t index,
+static WabtResult on_init_expr_i32_const_expr(uint32_t index,
uint32_t value,
void* user_data) {
Context* ctx = user_data;
- ctx->init_expr_value.type = WASM_TYPE_I32;
+ ctx->init_expr_value.type = WABT_TYPE_I32;
ctx->init_expr_value.value.i32 = value;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_init_expr_i64_const_expr(uint32_t index,
+static WabtResult on_init_expr_i64_const_expr(uint32_t index,
uint64_t value,
void* user_data) {
Context* ctx = user_data;
- ctx->init_expr_value.type = WASM_TYPE_I64;
+ ctx->init_expr_value.type = WABT_TYPE_I64;
ctx->init_expr_value.value.i64 = value;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_export(uint32_t index,
- WasmExternalKind kind,
+static WabtResult on_export(uint32_t index,
+ WabtExternalKind kind,
uint32_t item_index,
- WasmStringSlice name,
+ WabtStringSlice name,
void* user_data) {
Context* ctx = user_data;
switch (kind) {
- case WASM_EXTERNAL_KIND_FUNC:
+ case WABT_EXTERNAL_KIND_FUNC:
item_index = translate_func_index_to_env(ctx, item_index);
break;
- case WASM_EXTERNAL_KIND_TABLE:
+ case WABT_EXTERNAL_KIND_TABLE:
item_index = ctx->module->table_index;
break;
- case WASM_EXTERNAL_KIND_MEMORY:
+ case WABT_EXTERNAL_KIND_MEMORY:
item_index = ctx->module->memory_index;
break;
- case WASM_EXTERNAL_KIND_GLOBAL: {
+ case WABT_EXTERNAL_KIND_GLOBAL: {
item_index = translate_global_index_to_env(ctx, item_index);
- WasmInterpreterGlobal* global = &ctx->env->globals.data[item_index];
+ WabtInterpreterGlobal* global = &ctx->env->globals.data[item_index];
if (global->mutable_) {
print_error(ctx, "mutable globals cannot be exported");
- return WASM_ERROR;
+ return WABT_ERROR;
}
break;
}
- case WASM_NUM_EXTERNAL_KINDS:
+ case WABT_NUM_EXTERNAL_KINDS:
assert(0);
break;
}
return append_export(ctx, ctx->module, kind, item_index, name);
}
-static WasmResult on_start_function(uint32_t func_index, void* user_data) {
+static WabtResult on_start_function(uint32_t func_index, void* user_data) {
Context* ctx = user_data;
uint32_t start_func_index = translate_func_index_to_env(ctx, func_index);
- WasmInterpreterFunc* start_func =
+ WabtInterpreterFunc* start_func =
get_func_by_env_index(ctx, start_func_index);
- WasmInterpreterFuncSignature* sig =
+ WabtInterpreterFuncSignature* sig =
get_signature_by_env_index(ctx, start_func->sig_index);
if (sig->param_types.size != 0) {
print_error(ctx, "start function must be nullary");
- return WASM_ERROR;
+ return WABT_ERROR;
}
if (sig->result_types.size != 0) {
print_error(ctx, "start function must not return anything");
- return WASM_ERROR;
+ return WABT_ERROR;
}
ctx->module->defined.start_func_index = start_func_index;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult end_elem_segment_init_expr(uint32_t index, void* user_data) {
+static WabtResult end_elem_segment_init_expr(uint32_t index, void* user_data) {
Context* ctx = user_data;
- if (ctx->init_expr_value.type != WASM_TYPE_I32) {
+ if (ctx->init_expr_value.type != WABT_TYPE_I32) {
print_error(ctx, "type mismatch in elem segment, expected i32 but got %s",
- wasm_get_type_name(ctx->init_expr_value.type));
- return WASM_ERROR;
+ wabt_get_type_name(ctx->init_expr_value.type));
+ return WABT_ERROR;
}
ctx->table_offset = ctx->init_expr_value.value.i32;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_elem_segment_function_index_check(uint32_t index,
+static WabtResult on_elem_segment_function_index_check(uint32_t index,
uint32_t func_index,
void* user_data) {
Context* ctx = user_data;
- assert(ctx->module->table_index != WASM_INVALID_INDEX);
- WasmInterpreterTable* table =
+ assert(ctx->module->table_index != WABT_INVALID_INDEX);
+ WabtInterpreterTable* table =
&ctx->env->tables.data[ctx->module->table_index];
if (ctx->table_offset >= table->func_indexes.size) {
print_error(ctx,
"elem segment offset is out of bounds: %u >= max value %" PRIzd,
ctx->table_offset, table->func_indexes.size);
- return WASM_ERROR;
+ return WABT_ERROR;
}
uint32_t max_func_index = ctx->func_index_mapping.size;
if (func_index >= max_func_index) {
print_error(ctx, "invalid func_index: %d (max %d)", func_index,
max_func_index);
- return WASM_ERROR;
+ return WABT_ERROR;
}
table->func_indexes.data[ctx->table_offset++] =
translate_func_index_to_env(ctx, func_index);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_elem_segment_function_index(uint32_t index,
+static WabtResult on_elem_segment_function_index(uint32_t index,
uint32_t func_index,
void* user_data) {
Context* ctx = user_data;
- assert(ctx->module->table_index != WASM_INVALID_INDEX);
- WasmInterpreterTable* table =
+ assert(ctx->module->table_index != WABT_INVALID_INDEX);
+ WabtInterpreterTable* table =
&ctx->env->tables.data[ctx->module->table_index];
table->func_indexes.data[ctx->table_offset++] =
translate_func_index_to_env(ctx, func_index);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_data_segment_data_check(uint32_t index,
+static WabtResult on_data_segment_data_check(uint32_t index,
const void* src_data,
uint32_t size,
void* user_data) {
Context* ctx = user_data;
- assert(ctx->module->memory_index != WASM_INVALID_INDEX);
- WasmInterpreterMemory* memory =
+ assert(ctx->module->memory_index != WABT_INVALID_INDEX);
+ WabtInterpreterMemory* memory =
&ctx->env->memories.data[ctx->module->memory_index];
- if (ctx->init_expr_value.type != WASM_TYPE_I32) {
+ if (ctx->init_expr_value.type != WABT_TYPE_I32) {
print_error(ctx, "type mismatch in data segment, expected i32 but got %s",
- wasm_get_type_name(ctx->init_expr_value.type));
- return WASM_ERROR;
+ wabt_get_type_name(ctx->init_expr_value.type));
+ return WABT_ERROR;
}
uint32_t address = ctx->init_expr_value.value.i32;
uint64_t end_address = (uint64_t)address + (uint64_t)size;
@@ -983,23 +983,23 @@ static WasmResult on_data_segment_data_check(uint32_t index,
print_error(ctx, "data segment is out of bounds: [%u, %" PRIu64
") >= max value %u",
address, end_address, memory->byte_size);
- return WASM_ERROR;
+ return WABT_ERROR;
}
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_data_segment_data(uint32_t index,
+static WabtResult on_data_segment_data(uint32_t index,
const void* src_data,
uint32_t size,
void* user_data) {
Context* ctx = user_data;
- assert(ctx->module->memory_index != WASM_INVALID_INDEX);
- WasmInterpreterMemory* memory =
+ assert(ctx->module->memory_index != WABT_INVALID_INDEX);
+ WabtInterpreterMemory* memory =
&ctx->env->memories.data[ctx->module->memory_index];
uint32_t address = ctx->init_expr_value.value.i32;
uint8_t* dst_data = memory->data;
memcpy(&dst_data[address], src_data, size);
- return WASM_OK;
+ return WABT_OK;
}
static uint32_t translate_depth(Context* ctx, uint32_t depth) {
@@ -1009,26 +1009,26 @@ static uint32_t translate_depth(Context* ctx, uint32_t depth) {
static void push_label(Context* ctx,
LabelType label_type,
- const WasmTypeVector* sig,
+ const WabtTypeVector* sig,
uint32_t offset,
uint32_t fixup_offset) {
- Label* label = wasm_append_label(ctx->allocator, &ctx->label_stack);
+ Label* label = wabt_append_label(ctx->allocator, &ctx->label_stack);
label->label_type = label_type;
- wasm_extend_types(ctx->allocator, &label->sig, sig);
+ wabt_extend_types(ctx->allocator, &label->sig, sig);
label->type_stack_limit = ctx->type_stack.size;
label->offset = offset;
label->fixup_offset = fixup_offset;
LOGF(" : +depth %" PRIzd "\n", ctx->label_stack.size - 1);
}
-static void wasm_destroy_label(WasmAllocator* allocator, Label* label) {
- wasm_destroy_type_vector(allocator, &label->sig);
+static void wabt_destroy_label(WabtAllocator* allocator, Label* label) {
+ wabt_destroy_type_vector(allocator, &label->sig);
}
static void pop_label(Context* ctx) {
LOGF(" : -depth %" PRIzd "\n", ctx->label_stack.size - 1);
Label* label = top_label(ctx);
- wasm_destroy_label(ctx->allocator, label);
+ wabt_destroy_label(ctx->allocator, label);
ctx->label_stack.size--;
/* reduce the depth_fixups stack as well, but it may be smaller than
* label_stack so only do it conditionally. */
@@ -1037,35 +1037,35 @@ static void pop_label(Context* ctx) {
uint32_t to = ctx->depth_fixups.size;
uint32_t i;
for (i = from; i < to; ++i)
- wasm_destroy_uint32_vector(ctx->allocator, &ctx->depth_fixups.data[i]);
+ wabt_destroy_uint32_vector(ctx->allocator, &ctx->depth_fixups.data[i]);
ctx->depth_fixups.size = ctx->label_stack.size;
}
}
-static WasmType top_type(Context* ctx) {
+static WabtType top_type(Context* ctx) {
Label* label = top_label(ctx);
- WASM_USE(label);
+ WABT_USE(label);
assert(ctx->type_stack.size > label->type_stack_limit);
return ctx->type_stack.data[ctx->type_stack.size - 1];
}
-static WasmBool top_type_is_any(Context* ctx) {
+static WabtBool top_type_is_any(Context* ctx) {
if (ctx->type_stack.size >
ctx->current_func->defined.param_and_local_types.size) {
- WasmType top_type = ctx->type_stack.data[ctx->type_stack.size - 1];
- if (top_type == WASM_TYPE_ANY)
- return WASM_TRUE;
+ WabtType top_type = ctx->type_stack.data[ctx->type_stack.size - 1];
+ if (top_type == WABT_TYPE_ANY)
+ return WABT_TRUE;
}
- return WASM_FALSE;
+ return WABT_FALSE;
}
-/* TODO(binji): share a lot of the type-checking code w/ wasm-ast-checker.c */
-/* TODO(binji): flip actual + expected types, to match wasm-ast-checker.c */
+/* TODO(binji): share a lot of the type-checking code w/ wabt-ast-checker.c */
+/* TODO(binji): flip actual + expected types, to match wabt-ast-checker.c */
static size_t type_stack_limit(Context* ctx) {
return top_label(ctx)->type_stack_limit;
}
-static WasmResult check_type_stack_limit(Context* ctx,
+static WabtResult check_type_stack_limit(Context* ctx,
size_t expected,
const char* desc) {
RETURN_OK_IF_TOP_TYPE_IS_ANY(ctx);
@@ -1075,12 +1075,12 @@ static WasmResult check_type_stack_limit(Context* ctx,
print_error(ctx, "type stack size too small at %s. got %" PRIzd
", expected at least %" PRIzd,
desc, avail, expected);
- return WASM_ERROR;
+ return WABT_ERROR;
}
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult check_type_stack_limit_exact(Context* ctx,
+static WabtResult check_type_stack_limit_exact(Context* ctx,
size_t expected,
const char* desc) {
RETURN_OK_IF_TOP_TYPE_IS_ANY(ctx);
@@ -1089,30 +1089,30 @@ static WasmResult check_type_stack_limit_exact(Context* ctx,
if (expected != avail) {
print_error(ctx, "type stack at end of %s is %" PRIzd ". expected %" PRIzd,
desc, avail, expected);
- return WASM_ERROR;
+ return WABT_ERROR;
}
- return WASM_OK;
+ return WABT_OK;
}
static void reset_type_stack_to_limit(Context* ctx) {
ctx->type_stack.size = type_stack_limit(ctx);
}
-static WasmResult check_type(Context* ctx,
- WasmType expected,
- WasmType actual,
+static WabtResult check_type(Context* ctx,
+ WabtType expected,
+ WabtType actual,
const char* desc) {
RETURN_OK_IF_TOP_TYPE_IS_ANY(ctx);
if (expected != actual) {
print_error(ctx, "type mismatch in %s, expected %s but got %s.", desc,
- wasm_get_type_name(expected), wasm_get_type_name(actual));
- return WASM_ERROR;
+ wabt_get_type_name(expected), wabt_get_type_name(actual));
+ return WABT_ERROR;
}
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult check_n_types(Context* ctx,
- const WasmTypeVector* expected,
+static WabtResult check_n_types(Context* ctx,
+ const WabtTypeVector* expected,
const char* desc) {
RETURN_OK_IF_TOP_TYPE_IS_ANY(ctx);
CHECK_RESULT(check_type_stack_limit(ctx, expected->size, desc));
@@ -1123,85 +1123,85 @@ static WasmResult check_n_types(Context* ctx,
* type_stack must be [ ..., f64, i32, f32, i32] */
size_t i;
for (i = 0; i < expected->size; ++i) {
- WasmType actual =
+ WabtType actual =
ctx->type_stack.data[ctx->type_stack.size - expected->size + i];
CHECK_RESULT(
check_type(ctx, expected->data[expected->size - i - 1], actual, desc));
}
- return WASM_OK;
+ return WABT_OK;
}
-static WasmType pop_type(Context* ctx) {
- WasmType type = top_type(ctx);
- if (type != WASM_TYPE_ANY) {
+static WabtType pop_type(Context* ctx) {
+ WabtType type = top_type(ctx);
+ if (type != WABT_TYPE_ANY) {
LOGF("%3" PRIzd "->%3" PRIzd ": pop %s\n", ctx->type_stack.size,
- ctx->type_stack.size - 1, wasm_get_type_name(type));
+ ctx->type_stack.size - 1, wabt_get_type_name(type));
ctx->type_stack.size--;
}
return type;
}
-static void push_type(Context* ctx, WasmType type) {
+static void push_type(Context* ctx, WabtType type) {
RETURN_IF_TOP_TYPE_IS_ANY(ctx);
- if (type != WASM_TYPE_VOID) {
+ if (type != WABT_TYPE_VOID) {
LOGF("%3" PRIzd "->%3" PRIzd ": push %s\n", ctx->type_stack.size,
- ctx->type_stack.size + 1, wasm_get_type_name(type));
- wasm_append_type_value(ctx->allocator, &ctx->type_stack, &type);
+ ctx->type_stack.size + 1, wabt_get_type_name(type));
+ wabt_append_type_value(ctx->allocator, &ctx->type_stack, &type);
}
}
-static void push_types(Context* ctx, const WasmTypeVector* types) {
+static void push_types(Context* ctx, const WabtTypeVector* types) {
RETURN_IF_TOP_TYPE_IS_ANY(ctx);
size_t i;
for (i = 0; i < types->size; ++i)
push_type(ctx, types->data[i]);
}
-static WasmResult pop_and_check_1_type(Context* ctx,
- WasmType expected,
+static WabtResult pop_and_check_1_type(Context* ctx,
+ WabtType expected,
const char* desc) {
RETURN_OK_IF_TOP_TYPE_IS_ANY(ctx);
- if (WASM_SUCCEEDED(check_type_stack_limit(ctx, 1, desc))) {
- WasmType actual = pop_type(ctx);
+ if (WABT_SUCCEEDED(check_type_stack_limit(ctx, 1, desc))) {
+ WabtType actual = pop_type(ctx);
CHECK_RESULT(check_type(ctx, expected, actual, desc));
- return WASM_OK;
+ return WABT_OK;
}
- return WASM_ERROR;
+ return WABT_ERROR;
}
-static WasmResult pop_and_check_2_types(Context* ctx,
- WasmType expected1,
- WasmType expected2,
+static WabtResult pop_and_check_2_types(Context* ctx,
+ WabtType expected1,
+ WabtType expected2,
const char* desc) {
RETURN_OK_IF_TOP_TYPE_IS_ANY(ctx);
- if (WASM_SUCCEEDED(check_type_stack_limit(ctx, 2, desc))) {
- WasmType actual2 = pop_type(ctx);
- WasmType actual1 = pop_type(ctx);
+ if (WABT_SUCCEEDED(check_type_stack_limit(ctx, 2, desc))) {
+ WabtType actual2 = pop_type(ctx);
+ WabtType actual1 = pop_type(ctx);
CHECK_RESULT(check_type(ctx, expected1, actual1, desc));
CHECK_RESULT(check_type(ctx, expected2, actual2, desc));
- return WASM_OK;
+ return WABT_OK;
}
- return WASM_ERROR;
+ return WABT_ERROR;
}
-static WasmResult check_opcode1(Context* ctx, WasmOpcode opcode) {
+static WabtResult check_opcode1(Context* ctx, WabtOpcode opcode) {
RETURN_OK_IF_TOP_TYPE_IS_ANY(ctx);
- CHECK_RESULT(pop_and_check_1_type(ctx, wasm_get_opcode_param_type_1(opcode),
- wasm_get_opcode_name(opcode)));
- push_type(ctx, wasm_get_opcode_result_type(opcode));
- return WASM_OK;
+ CHECK_RESULT(pop_and_check_1_type(ctx, wabt_get_opcode_param_type_1(opcode),
+ wabt_get_opcode_name(opcode)));
+ push_type(ctx, wabt_get_opcode_result_type(opcode));
+ return WABT_OK;
}
-static WasmResult check_opcode2(Context* ctx, WasmOpcode opcode) {
+static WabtResult check_opcode2(Context* ctx, WabtOpcode opcode) {
RETURN_OK_IF_TOP_TYPE_IS_ANY(ctx);
- CHECK_RESULT(pop_and_check_2_types(ctx, wasm_get_opcode_param_type_1(opcode),
- wasm_get_opcode_param_type_2(opcode),
- wasm_get_opcode_name(opcode)));
- push_type(ctx, wasm_get_opcode_result_type(opcode));
- return WASM_OK;
+ CHECK_RESULT(pop_and_check_2_types(ctx, wabt_get_opcode_param_type_1(opcode),
+ wabt_get_opcode_param_type_2(opcode),
+ wabt_get_opcode_name(opcode)));
+ push_type(ctx, wabt_get_opcode_result_type(opcode));
+ return WABT_OK;
}
-static WasmResult drop_types_for_return(Context* ctx, uint32_t arity) {
+static WabtResult drop_types_for_return(Context* ctx, uint32_t arity) {
RETURN_OK_IF_TOP_TYPE_IS_ANY(ctx);
/* drop the locals and params, but keep the return value, if any. */
if (ctx->type_stack.size >= arity) {
@@ -1213,17 +1213,17 @@ static WasmResult drop_types_for_return(Context* ctx, uint32_t arity) {
* return. In that case the type stack should be empty */
assert(ctx->type_stack.size == 0);
}
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult begin_function_body(WasmBinaryReaderContext* context,
+static WabtResult begin_function_body(WabtBinaryReaderContext* context,
uint32_t index) {
Context* ctx = context->user_data;
- WasmInterpreterFunc* func = get_func_by_module_index(ctx, index);
- WasmInterpreterFuncSignature* sig =
+ WabtInterpreterFunc* func = get_func_by_module_index(ctx, index);
+ WabtInterpreterFuncSignature* sig =
get_signature_by_env_index(ctx, func->sig_index);
- func->is_host = WASM_FALSE;
+ func->is_host = WABT_FALSE;
func->defined.offset = get_istream_offset(ctx);
func->defined.local_decl_count = 0;
func->defined.local_count = 0;
@@ -1243,24 +1243,24 @@ static WasmResult begin_function_body(WasmBinaryReaderContext* context,
/* append param types */
for (i = 0; i < sig->param_types.size; ++i) {
- WasmType type = sig->param_types.data[i];
- wasm_append_type_value(ctx->allocator, &func->defined.param_and_local_types,
+ WabtType type = sig->param_types.data[i];
+ wabt_append_type_value(ctx->allocator, &func->defined.param_and_local_types,
&type);
- wasm_append_type_value(ctx->allocator, &ctx->type_stack, &type);
+ wabt_append_type_value(ctx->allocator, &ctx->type_stack, &type);
}
/* push implicit func label (equivalent to return) */
- push_label(ctx, LABEL_TYPE_FUNC, &sig->result_types, WASM_INVALID_OFFSET,
- WASM_INVALID_OFFSET);
- return WASM_OK;
+ push_label(ctx, LABEL_TYPE_FUNC, &sig->result_types, WABT_INVALID_OFFSET,
+ WABT_INVALID_OFFSET);
+ return WABT_OK;
}
-static WasmResult end_function_body(uint32_t index, void* user_data) {
+static WabtResult end_function_body(uint32_t index, void* user_data) {
Context* ctx = user_data;
Label* label = top_label(ctx);
if (!label || label->label_type != LABEL_TYPE_FUNC) {
print_error(ctx, "unexpected function end");
- return WASM_ERROR;
+ return WABT_ERROR;
}
CHECK_RESULT(check_n_types(ctx, &label->sig, "implicit return"));
@@ -1276,150 +1276,150 @@ static WasmResult end_function_body(uint32_t index, void* user_data) {
push_types(ctx, &label->sig);
}
CHECK_RESULT(drop_types_for_return(ctx, label->sig.size));
- CHECK_RESULT(emit_opcode(ctx, WASM_OPCODE_RETURN));
+ CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_RETURN));
pop_label(ctx);
ctx->current_func = NULL;
ctx->type_stack.size = 0;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_local_decl_count(uint32_t count, void* user_data) {
+static WabtResult on_local_decl_count(uint32_t count, void* user_data) {
Context* ctx = user_data;
- WasmInterpreterFunc* func = ctx->current_func;
+ WabtInterpreterFunc* func = ctx->current_func;
func->defined.local_decl_count = count;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_local_decl(uint32_t decl_index,
+static WabtResult on_local_decl(uint32_t decl_index,
uint32_t count,
- WasmType type,
+ WabtType type,
void* user_data) {
Context* ctx = user_data;
LOGF("%3" PRIzd ": alloca\n", ctx->type_stack.size);
- WasmInterpreterFunc* func = ctx->current_func;
+ WabtInterpreterFunc* func = ctx->current_func;
func->defined.local_count += count;
uint32_t i;
for (i = 0; i < count; ++i) {
- wasm_append_type_value(ctx->allocator, &func->defined.param_and_local_types,
+ wabt_append_type_value(ctx->allocator, &func->defined.param_and_local_types,
&type);
push_type(ctx, type);
}
if (decl_index == func->defined.local_decl_count - 1) {
/* last local declaration, allocate space for all locals. */
- CHECK_RESULT(emit_opcode(ctx, WASM_OPCODE_ALLOCA));
+ CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_ALLOCA));
CHECK_RESULT(emit_i32(ctx, func->defined.local_count));
/* fixup the function label's type_stack_limit to include these values. */
Label* label = top_label(ctx);
assert(label->label_type == LABEL_TYPE_FUNC);
label->type_stack_limit += func->defined.local_count;
}
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult check_has_memory(Context* ctx, WasmOpcode opcode) {
- if (ctx->module->memory_index == WASM_INVALID_INDEX) {
+static WabtResult check_has_memory(Context* ctx, WabtOpcode opcode) {
+ if (ctx->module->memory_index == WABT_INVALID_INDEX) {
print_error(ctx, "%s requires an imported or defined memory.",
- wasm_get_opcode_name(opcode));
- return WASM_ERROR;
+ wabt_get_opcode_name(opcode));
+ return WABT_ERROR;
}
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult check_align(Context* ctx,
+static WabtResult check_align(Context* ctx,
uint32_t alignment_log2,
uint32_t natural_alignment) {
if (alignment_log2 >= 32 || (1U << alignment_log2) > natural_alignment) {
print_error(ctx, "alignment must not be larger than natural alignment (%u)",
natural_alignment);
- return WASM_ERROR;
+ return WABT_ERROR;
}
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_unary_expr(WasmOpcode opcode, void* user_data) {
+static WabtResult on_unary_expr(WabtOpcode opcode, void* user_data) {
Context* ctx = user_data;
CHECK_RESULT(check_opcode1(ctx, opcode));
CHECK_RESULT(emit_opcode(ctx, opcode));
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_binary_expr(WasmOpcode opcode, void* user_data) {
+static WabtResult on_binary_expr(WabtOpcode opcode, void* user_data) {
Context* ctx = user_data;
CHECK_RESULT(check_opcode2(ctx, opcode));
CHECK_RESULT(emit_opcode(ctx, opcode));
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_block_expr(uint32_t num_types,
- WasmType* sig_types,
+static WabtResult on_block_expr(uint32_t num_types,
+ WabtType* sig_types,
void* user_data) {
Context* ctx = user_data;
- WasmTypeVector sig;
+ WabtTypeVector sig;
sig.size = num_types;
sig.data = sig_types;
- push_label(ctx, LABEL_TYPE_BLOCK, &sig, WASM_INVALID_OFFSET,
- WASM_INVALID_OFFSET);
- return WASM_OK;
+ push_label(ctx, LABEL_TYPE_BLOCK, &sig, WABT_INVALID_OFFSET,
+ WABT_INVALID_OFFSET);
+ return WABT_OK;
}
-static WasmResult on_loop_expr(uint32_t num_types,
- WasmType* sig_types,
+static WabtResult on_loop_expr(uint32_t num_types,
+ WabtType* sig_types,
void* user_data) {
Context* ctx = user_data;
- WasmTypeVector sig;
+ WabtTypeVector sig;
sig.size = num_types;
sig.data = sig_types;
push_label(ctx, LABEL_TYPE_LOOP, &sig, get_istream_offset(ctx),
- WASM_INVALID_OFFSET);
- return WASM_OK;
+ WABT_INVALID_OFFSET);
+ return WABT_OK;
}
-static WasmResult on_if_expr(uint32_t num_types,
- WasmType* sig_types,
+static WabtResult on_if_expr(uint32_t num_types,
+ WabtType* sig_types,
void* user_data) {
Context* ctx = user_data;
CHECK_RESULT(check_type_stack_limit(ctx, 1, "if"));
- CHECK_RESULT(pop_and_check_1_type(ctx, WASM_TYPE_I32, "if"));
- CHECK_RESULT(emit_opcode(ctx, WASM_OPCODE_BR_UNLESS));
+ CHECK_RESULT(pop_and_check_1_type(ctx, WABT_TYPE_I32, "if"));
+ CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_BR_UNLESS));
uint32_t fixup_offset = get_istream_offset(ctx);
- CHECK_RESULT(emit_i32(ctx, WASM_INVALID_OFFSET));
+ CHECK_RESULT(emit_i32(ctx, WABT_INVALID_OFFSET));
- WasmTypeVector sig;
+ WabtTypeVector sig;
sig.size = num_types;
sig.data = sig_types;
- push_label(ctx, LABEL_TYPE_IF, &sig, WASM_INVALID_OFFSET, fixup_offset);
- return WASM_OK;
+ push_label(ctx, LABEL_TYPE_IF, &sig, WABT_INVALID_OFFSET, fixup_offset);
+ return WABT_OK;
}
-static WasmResult on_else_expr(void* user_data) {
+static WabtResult on_else_expr(void* user_data) {
Context* ctx = user_data;
Label* label = top_label(ctx);
if (!label || label->label_type != LABEL_TYPE_IF) {
print_error(ctx, "unexpected else operator");
- return WASM_ERROR;
+ return WABT_ERROR;
}
CHECK_RESULT(check_n_types(ctx, &label->sig, "if true branch"));
label->label_type = LABEL_TYPE_ELSE;
uint32_t fixup_cond_offset = label->fixup_offset;
- CHECK_RESULT(emit_opcode(ctx, WASM_OPCODE_BR));
+ CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_BR));
label->fixup_offset = get_istream_offset(ctx);
- CHECK_RESULT(emit_i32(ctx, WASM_INVALID_OFFSET));
+ CHECK_RESULT(emit_i32(ctx, WABT_INVALID_OFFSET));
CHECK_RESULT(emit_i32_at(ctx, fixup_cond_offset, get_istream_offset(ctx)));
/* reset the type stack for the other branch arm */
ctx->type_stack.size = label->type_stack_limit;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_end_expr(void* user_data) {
+static WabtResult on_end_expr(void* user_data) {
Context* ctx = user_data;
Label* label = top_label(ctx);
if (!label) {
print_error(ctx, "unexpected end operator");
- return WASM_ERROR;
+ return WABT_ERROR;
}
const char* desc = NULL;
@@ -1442,7 +1442,7 @@ static WasmResult on_end_expr(void* user_data) {
case LABEL_TYPE_FUNC:
print_error(ctx, "unexpected end operator");
- return WASM_ERROR;
+ return WABT_ERROR;
}
CHECK_RESULT(check_n_types(ctx, &label->sig, desc));
@@ -1451,10 +1451,10 @@ static WasmResult on_end_expr(void* user_data) {
reset_type_stack_to_limit(ctx);
push_types(ctx, &label->sig);
pop_label(ctx);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_br_expr(uint32_t depth, void* user_data) {
+static WabtResult on_br_expr(uint32_t depth, void* user_data) {
Context* ctx = user_data;
CHECK_DEPTH(ctx, depth);
depth = translate_depth(ctx, depth);
@@ -1463,41 +1463,41 @@ static WasmResult on_br_expr(uint32_t depth, void* user_data) {
CHECK_RESULT(check_n_types(ctx, &label->sig, "br"));
CHECK_RESULT(emit_br(ctx, depth));
reset_type_stack_to_limit(ctx);
- push_type(ctx, WASM_TYPE_ANY);
- return WASM_OK;
+ push_type(ctx, WABT_TYPE_ANY);
+ return WABT_OK;
}
-static WasmResult on_br_if_expr(uint32_t depth, void* user_data) {
+static WabtResult on_br_if_expr(uint32_t depth, void* user_data) {
Context* ctx = user_data;
CHECK_DEPTH(ctx, depth);
depth = translate_depth(ctx, depth);
- CHECK_RESULT(pop_and_check_1_type(ctx, WASM_TYPE_I32, "br_if"));
+ CHECK_RESULT(pop_and_check_1_type(ctx, WABT_TYPE_I32, "br_if"));
Label* label = get_label(ctx, depth);
if (label->label_type != LABEL_TYPE_LOOP)
CHECK_RESULT(check_n_types(ctx, &label->sig, "br_if"));
/* flip the br_if so if <cond> is true it can drop values from the stack */
- CHECK_RESULT(emit_opcode(ctx, WASM_OPCODE_BR_UNLESS));
+ CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_BR_UNLESS));
uint32_t fixup_br_offset = get_istream_offset(ctx);
- CHECK_RESULT(emit_i32(ctx, WASM_INVALID_OFFSET));
+ CHECK_RESULT(emit_i32(ctx, WABT_INVALID_OFFSET));
CHECK_RESULT(emit_br(ctx, depth));
CHECK_RESULT(emit_i32_at(ctx, fixup_br_offset, get_istream_offset(ctx)));
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_br_table_expr(WasmBinaryReaderContext* context,
+static WabtResult on_br_table_expr(WabtBinaryReaderContext* context,
uint32_t num_targets,
uint32_t* target_depths,
uint32_t default_target_depth) {
Context* ctx = context->user_data;
- CHECK_RESULT(pop_and_check_1_type(ctx, WASM_TYPE_I32, "br_table"));
- CHECK_RESULT(emit_opcode(ctx, WASM_OPCODE_BR_TABLE));
+ CHECK_RESULT(pop_and_check_1_type(ctx, WABT_TYPE_I32, "br_table"));
+ CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_BR_TABLE));
CHECK_RESULT(emit_i32(ctx, num_targets));
uint32_t fixup_table_offset = get_istream_offset(ctx);
- CHECK_RESULT(emit_i32(ctx, WASM_INVALID_OFFSET));
+ CHECK_RESULT(emit_i32(ctx, WABT_INVALID_OFFSET));
/* not necessary for the interpreter, but it makes it easier to disassemble.
* This opcode specifies how many bytes of data follow. */
- CHECK_RESULT(emit_opcode(ctx, WASM_OPCODE_DATA));
- CHECK_RESULT(emit_i32(ctx, (num_targets + 1) * WASM_TABLE_ENTRY_SIZE));
+ CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_DATA));
+ CHECK_RESULT(emit_i32(ctx, (num_targets + 1) * WABT_TABLE_ENTRY_SIZE));
CHECK_RESULT(emit_i32_at(ctx, fixup_table_offset, get_istream_offset(ctx)));
uint32_t i;
@@ -1511,245 +1511,245 @@ static WasmResult on_br_table_expr(WasmBinaryReaderContext* context,
}
reset_type_stack_to_limit(ctx);
- push_type(ctx, WASM_TYPE_ANY);
- return WASM_OK;
+ push_type(ctx, WABT_TYPE_ANY);
+ return WABT_OK;
}
-static WasmResult on_call_expr(uint32_t func_index, void* user_data) {
+static WabtResult on_call_expr(uint32_t func_index, void* user_data) {
Context* ctx = user_data;
- WasmInterpreterFunc* func = get_func_by_module_index(ctx, func_index);
- WasmInterpreterFuncSignature* sig =
+ WabtInterpreterFunc* func = get_func_by_module_index(ctx, func_index);
+ WabtInterpreterFuncSignature* sig =
get_signature_by_env_index(ctx, func->sig_index);
CHECK_RESULT(check_type_stack_limit(ctx, sig->param_types.size, "call"));
uint32_t i;
for (i = sig->param_types.size; i > 0; --i) {
- WasmType arg = pop_type(ctx);
+ WabtType arg = pop_type(ctx);
CHECK_RESULT(check_type(ctx, sig->param_types.data[i - 1], arg, "call"));
}
if (func->is_host) {
- CHECK_RESULT(emit_opcode(ctx, WASM_OPCODE_CALL_HOST));
+ CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_CALL_HOST));
CHECK_RESULT(emit_i32(ctx, translate_func_index_to_env(ctx, func_index)));
} else {
- CHECK_RESULT(emit_opcode(ctx, WASM_OPCODE_CALL));
+ CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_CALL));
CHECK_RESULT(emit_func_offset(ctx, func, func_index));
}
push_types(ctx, &sig->result_types);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_call_indirect_expr(uint32_t sig_index, void* user_data) {
+static WabtResult on_call_indirect_expr(uint32_t sig_index, void* user_data) {
Context* ctx = user_data;
- if (ctx->module->table_index == WASM_INVALID_INDEX) {
+ if (ctx->module->table_index == WABT_INVALID_INDEX) {
print_error(ctx, "found call_indirect operator, but no table");
- return WASM_ERROR;
+ return WABT_ERROR;
}
- WasmInterpreterFuncSignature* sig =
+ WabtInterpreterFuncSignature* sig =
get_signature_by_module_index(ctx, sig_index);
- CHECK_RESULT(pop_and_check_1_type(ctx, WASM_TYPE_I32, "call_indirect"));
+ CHECK_RESULT(pop_and_check_1_type(ctx, WABT_TYPE_I32, "call_indirect"));
CHECK_RESULT(
check_type_stack_limit(ctx, sig->param_types.size, "call_indirect"));
uint32_t i;
for (i = sig->param_types.size; i > 0; --i) {
- WasmType arg = pop_type(ctx);
+ WabtType arg = pop_type(ctx);
CHECK_RESULT(
check_type(ctx, sig->param_types.data[i - 1], arg, "call_indirect"));
}
- CHECK_RESULT(emit_opcode(ctx, WASM_OPCODE_CALL_INDIRECT));
+ CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_CALL_INDIRECT));
CHECK_RESULT(emit_i32(ctx, ctx->module->table_index));
CHECK_RESULT(emit_i32(ctx, translate_sig_index_to_env(ctx, sig_index)));
push_types(ctx, &sig->result_types);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_drop_expr(void* user_data) {
+static WabtResult on_drop_expr(void* user_data) {
Context* ctx = user_data;
CHECK_RESULT(check_type_stack_limit(ctx, 1, "drop"));
- CHECK_RESULT(emit_opcode(ctx, WASM_OPCODE_DROP));
+ CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_DROP));
pop_type(ctx);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_i32_const_expr(uint32_t value, void* user_data) {
+static WabtResult on_i32_const_expr(uint32_t value, void* user_data) {
Context* ctx = user_data;
- CHECK_RESULT(emit_opcode(ctx, WASM_OPCODE_I32_CONST));
+ CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_I32_CONST));
CHECK_RESULT(emit_i32(ctx, value));
- push_type(ctx, WASM_TYPE_I32);
- return WASM_OK;
+ push_type(ctx, WABT_TYPE_I32);
+ return WABT_OK;
}
-static WasmResult on_i64_const_expr(uint64_t value, void* user_data) {
+static WabtResult on_i64_const_expr(uint64_t value, void* user_data) {
Context* ctx = user_data;
- CHECK_RESULT(emit_opcode(ctx, WASM_OPCODE_I64_CONST));
+ CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_I64_CONST));
CHECK_RESULT(emit_i64(ctx, value));
- push_type(ctx, WASM_TYPE_I64);
- return WASM_OK;
+ push_type(ctx, WABT_TYPE_I64);
+ return WABT_OK;
}
-static WasmResult on_f32_const_expr(uint32_t value_bits, void* user_data) {
+static WabtResult on_f32_const_expr(uint32_t value_bits, void* user_data) {
Context* ctx = user_data;
- CHECK_RESULT(emit_opcode(ctx, WASM_OPCODE_F32_CONST));
+ CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_F32_CONST));
CHECK_RESULT(emit_i32(ctx, value_bits));
- push_type(ctx, WASM_TYPE_F32);
- return WASM_OK;
+ push_type(ctx, WABT_TYPE_F32);
+ return WABT_OK;
}
-static WasmResult on_f64_const_expr(uint64_t value_bits, void* user_data) {
+static WabtResult on_f64_const_expr(uint64_t value_bits, void* user_data) {
Context* ctx = user_data;
- CHECK_RESULT(emit_opcode(ctx, WASM_OPCODE_F64_CONST));
+ CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_F64_CONST));
CHECK_RESULT(emit_i64(ctx, value_bits));
- push_type(ctx, WASM_TYPE_F64);
- return WASM_OK;
+ push_type(ctx, WABT_TYPE_F64);
+ return WABT_OK;
}
-static WasmResult on_get_global_expr(uint32_t global_index, void* user_data) {
+static WabtResult on_get_global_expr(uint32_t global_index, void* user_data) {
Context* ctx = user_data;
CHECK_GLOBAL(ctx, global_index);
- WasmType type = get_global_type_by_module_index(ctx, global_index);
- CHECK_RESULT(emit_opcode(ctx, WASM_OPCODE_GET_GLOBAL));
+ WabtType type = get_global_type_by_module_index(ctx, global_index);
+ CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_GET_GLOBAL));
CHECK_RESULT(emit_i32(ctx, translate_global_index_to_env(ctx, global_index)));
push_type(ctx, type);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_set_global_expr(uint32_t global_index, void* user_data) {
+static WabtResult on_set_global_expr(uint32_t global_index, void* user_data) {
Context* ctx = user_data;
CHECK_GLOBAL(ctx, global_index);
- WasmInterpreterGlobal* global = get_global_by_module_index(ctx, global_index);
- if (global->mutable_ != WASM_TRUE) {
+ WabtInterpreterGlobal* global = get_global_by_module_index(ctx, global_index);
+ if (global->mutable_ != WABT_TRUE) {
print_error(ctx, "can't set_global on immutable global at index %u.",
global_index);
- return WASM_ERROR;
+ return WABT_ERROR;
}
CHECK_RESULT(
pop_and_check_1_type(ctx, global->typed_value.type, "set_global"));
- CHECK_RESULT(emit_opcode(ctx, WASM_OPCODE_SET_GLOBAL));
+ CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_SET_GLOBAL));
CHECK_RESULT(emit_i32(ctx, translate_global_index_to_env(ctx, global_index)));
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_get_local_expr(uint32_t local_index, void* user_data) {
+static WabtResult on_get_local_expr(uint32_t local_index, void* user_data) {
Context* ctx = user_data;
CHECK_LOCAL(ctx, local_index);
- WasmType type = get_local_type_by_index(ctx->current_func, local_index);
- CHECK_RESULT(emit_opcode(ctx, WASM_OPCODE_GET_LOCAL));
+ WabtType type = get_local_type_by_index(ctx->current_func, local_index);
+ CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_GET_LOCAL));
CHECK_RESULT(emit_i32(ctx, translate_local_index(ctx, local_index)));
push_type(ctx, type);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_set_local_expr(uint32_t local_index, void* user_data) {
+static WabtResult on_set_local_expr(uint32_t local_index, void* user_data) {
Context* ctx = user_data;
CHECK_LOCAL(ctx, local_index);
- WasmType type = get_local_type_by_index(ctx->current_func, local_index);
+ WabtType type = get_local_type_by_index(ctx->current_func, local_index);
CHECK_RESULT(pop_and_check_1_type(ctx, type, "set_local"));
- CHECK_RESULT(emit_opcode(ctx, WASM_OPCODE_SET_LOCAL));
+ CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_SET_LOCAL));
CHECK_RESULT(emit_i32(ctx, translate_local_index(ctx, local_index)));
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_tee_local_expr(uint32_t local_index, void* user_data) {
+static WabtResult on_tee_local_expr(uint32_t local_index, void* user_data) {
Context* ctx = user_data;
CHECK_LOCAL(ctx, local_index);
- WasmType type = get_local_type_by_index(ctx->current_func, local_index);
+ WabtType type = get_local_type_by_index(ctx->current_func, local_index);
CHECK_RESULT(check_type_stack_limit(ctx, 1, "tee_local"));
- WasmType value = top_type(ctx);
+ WabtType value = top_type(ctx);
CHECK_RESULT(check_type(ctx, type, value, "tee_local"));
- CHECK_RESULT(emit_opcode(ctx, WASM_OPCODE_TEE_LOCAL));
+ CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_TEE_LOCAL));
CHECK_RESULT(emit_i32(ctx, translate_local_index(ctx, local_index)));
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_grow_memory_expr(void* user_data) {
+static WabtResult on_grow_memory_expr(void* user_data) {
Context* ctx = user_data;
- CHECK_RESULT(check_has_memory(ctx, WASM_OPCODE_GROW_MEMORY));
- CHECK_RESULT(pop_and_check_1_type(ctx, WASM_TYPE_I32, "grow_memory"));
- CHECK_RESULT(emit_opcode(ctx, WASM_OPCODE_GROW_MEMORY));
+ CHECK_RESULT(check_has_memory(ctx, WABT_OPCODE_GROW_MEMORY));
+ CHECK_RESULT(pop_and_check_1_type(ctx, WABT_TYPE_I32, "grow_memory"));
+ CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_GROW_MEMORY));
CHECK_RESULT(emit_i32(ctx, ctx->module->memory_index));
- push_type(ctx, WASM_TYPE_I32);
- return WASM_OK;
+ push_type(ctx, WABT_TYPE_I32);
+ return WABT_OK;
}
-static WasmResult on_load_expr(WasmOpcode opcode,
+static WabtResult on_load_expr(WabtOpcode opcode,
uint32_t alignment_log2,
uint32_t offset,
void* user_data) {
Context* ctx = user_data;
CHECK_RESULT(check_has_memory(ctx, opcode));
CHECK_RESULT(
- check_align(ctx, alignment_log2, wasm_get_opcode_memory_size(opcode)));
+ check_align(ctx, alignment_log2, wabt_get_opcode_memory_size(opcode)));
CHECK_RESULT(check_opcode1(ctx, opcode));
CHECK_RESULT(emit_opcode(ctx, opcode));
CHECK_RESULT(emit_i32(ctx, ctx->module->memory_index));
CHECK_RESULT(emit_i32(ctx, offset));
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_store_expr(WasmOpcode opcode,
+static WabtResult on_store_expr(WabtOpcode opcode,
uint32_t alignment_log2,
uint32_t offset,
void* user_data) {
Context* ctx = user_data;
CHECK_RESULT(check_has_memory(ctx, opcode));
CHECK_RESULT(
- check_align(ctx, alignment_log2, wasm_get_opcode_memory_size(opcode)));
+ check_align(ctx, alignment_log2, wabt_get_opcode_memory_size(opcode)));
CHECK_RESULT(check_opcode2(ctx, opcode));
CHECK_RESULT(emit_opcode(ctx, opcode));
CHECK_RESULT(emit_i32(ctx, ctx->module->memory_index));
CHECK_RESULT(emit_i32(ctx, offset));
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_current_memory_expr(void* user_data) {
+static WabtResult on_current_memory_expr(void* user_data) {
Context* ctx = user_data;
- CHECK_RESULT(check_has_memory(ctx, WASM_OPCODE_CURRENT_MEMORY));
- CHECK_RESULT(emit_opcode(ctx, WASM_OPCODE_CURRENT_MEMORY));
+ CHECK_RESULT(check_has_memory(ctx, WABT_OPCODE_CURRENT_MEMORY));
+ CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_CURRENT_MEMORY));
CHECK_RESULT(emit_i32(ctx, ctx->module->memory_index));
- push_type(ctx, WASM_TYPE_I32);
- return WASM_OK;
+ push_type(ctx, WABT_TYPE_I32);
+ return WABT_OK;
}
-static WasmResult on_nop_expr(void* user_data) {
- return WASM_OK;
+static WabtResult on_nop_expr(void* user_data) {
+ return WABT_OK;
}
-static WasmResult on_return_expr(void* user_data) {
+static WabtResult on_return_expr(void* user_data) {
Context* ctx = user_data;
- WasmInterpreterFuncSignature* sig =
+ WabtInterpreterFuncSignature* sig =
get_signature_by_env_index(ctx, ctx->current_func->sig_index);
CHECK_RESULT(check_n_types(ctx, &sig->result_types, "return"));
CHECK_RESULT(drop_types_for_return(ctx, sig->result_types.size));
- CHECK_RESULT(emit_opcode(ctx, WASM_OPCODE_RETURN));
+ CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_RETURN));
reset_type_stack_to_limit(ctx);
- push_type(ctx, WASM_TYPE_ANY);
- return WASM_OK;
+ push_type(ctx, WABT_TYPE_ANY);
+ return WABT_OK;
}
-static WasmResult on_select_expr(void* user_data) {
+static WabtResult on_select_expr(void* user_data) {
Context* ctx = user_data;
- CHECK_RESULT(pop_and_check_1_type(ctx, WASM_TYPE_I32, "select"));
+ CHECK_RESULT(pop_and_check_1_type(ctx, WABT_TYPE_I32, "select"));
CHECK_RESULT(check_type_stack_limit(ctx, 2, "select"));
- WasmType right = pop_type(ctx);
- WasmType left = pop_type(ctx);
+ WabtType right = pop_type(ctx);
+ WabtType left = pop_type(ctx);
CHECK_RESULT(check_type(ctx, left, right, "select"));
- CHECK_RESULT(emit_opcode(ctx, WASM_OPCODE_SELECT));
+ CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_SELECT));
push_type(ctx, left);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_unreachable_expr(void* user_data) {
+static WabtResult on_unreachable_expr(void* user_data) {
Context* ctx = user_data;
- CHECK_RESULT(emit_opcode(ctx, WASM_OPCODE_UNREACHABLE));
+ CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_UNREACHABLE));
reset_type_stack_to_limit(ctx);
- push_type(ctx, WASM_TYPE_ANY);
- return WASM_OK;
+ push_type(ctx, WABT_TYPE_ANY);
+ return WABT_OK;
}
-static WasmBinaryReader s_binary_reader = {
+static WabtBinaryReader s_binary_reader = {
.user_data = NULL,
.on_error = on_error,
@@ -1828,7 +1828,7 @@ static WasmBinaryReader s_binary_reader = {
};
/* Second pass to assign data and elem segments after they are checked above. */
-static WasmBinaryReader s_binary_reader_segments = {
+static WabtBinaryReader s_binary_reader_segments = {
.user_data = NULL,
.on_error = on_error,
@@ -1844,35 +1844,35 @@ static WasmBinaryReader s_binary_reader_segments = {
};
static void destroy_context(Context* ctx) {
- wasm_destroy_type_vector(ctx->allocator, &ctx->type_stack);
- WASM_DESTROY_VECTOR_AND_ELEMENTS(ctx->allocator, ctx->label_stack, label);
- WASM_DESTROY_VECTOR_AND_ELEMENTS(ctx->allocator, ctx->depth_fixups,
+ wabt_destroy_type_vector(ctx->allocator, &ctx->type_stack);
+ WABT_DESTROY_VECTOR_AND_ELEMENTS(ctx->allocator, ctx->label_stack, label);
+ WABT_DESTROY_VECTOR_AND_ELEMENTS(ctx->allocator, ctx->depth_fixups,
uint32_vector);
- WASM_DESTROY_VECTOR_AND_ELEMENTS(ctx->allocator, ctx->func_fixups,
+ WABT_DESTROY_VECTOR_AND_ELEMENTS(ctx->allocator, ctx->func_fixups,
uint32_vector);
- wasm_destroy_uint32_vector(ctx->allocator, &ctx->sig_index_mapping);
- wasm_destroy_uint32_vector(ctx->allocator, &ctx->func_index_mapping);
- wasm_destroy_uint32_vector(ctx->allocator, &ctx->global_index_mapping);
+ wabt_destroy_uint32_vector(ctx->allocator, &ctx->sig_index_mapping);
+ wabt_destroy_uint32_vector(ctx->allocator, &ctx->func_index_mapping);
+ wabt_destroy_uint32_vector(ctx->allocator, &ctx->global_index_mapping);
}
-WasmResult wasm_read_binary_interpreter(WasmAllocator* allocator,
- WasmAllocator* memory_allocator,
- WasmInterpreterEnvironment* env,
+WabtResult wabt_read_binary_interpreter(WabtAllocator* allocator,
+ WabtAllocator* memory_allocator,
+ WabtInterpreterEnvironment* env,
const void* data,
size_t size,
- const WasmReadBinaryOptions* options,
- WasmBinaryErrorHandler* error_handler,
- WasmInterpreterModule** out_module) {
+ const WabtReadBinaryOptions* options,
+ WabtBinaryErrorHandler* error_handler,
+ WabtInterpreterModule** out_module) {
Context ctx;
- WasmBinaryReader reader;
+ WabtBinaryReader reader;
- WasmInterpreterEnvironmentMark mark = wasm_mark_interpreter_environment(env);
+ WabtInterpreterEnvironmentMark mark = wabt_mark_interpreter_environment(env);
- WasmInterpreterModule* module =
- wasm_append_interpreter_module(allocator, &env->modules);
+ WabtInterpreterModule* module =
+ wabt_append_interpreter_module(allocator, &env->modules);
- WASM_ZERO_MEMORY(ctx);
- WASM_ZERO_MEMORY(reader);
+ WABT_ZERO_MEMORY(ctx);
+ WABT_ZERO_MEMORY(reader);
ctx.allocator = allocator;
ctx.reader = &reader;
@@ -1880,35 +1880,35 @@ WasmResult wasm_read_binary_interpreter(WasmAllocator* allocator,
ctx.memory_allocator = memory_allocator;
ctx.env = env;
ctx.module = module;
- ctx.module->is_host = WASM_FALSE;
- ctx.module->table_index = WASM_INVALID_INDEX;
- ctx.module->memory_index = WASM_INVALID_INDEX;
- ctx.module->defined.start_func_index = WASM_INVALID_INDEX;
+ ctx.module->is_host = WABT_FALSE;
+ ctx.module->table_index = WABT_INVALID_INDEX;
+ ctx.module->memory_index = WABT_INVALID_INDEX;
+ ctx.module->defined.start_func_index = WABT_INVALID_INDEX;
ctx.module->defined.istream_start = env->istream.size;
ctx.istream_offset = env->istream.size;
CHECK_RESULT(
- wasm_init_mem_writer_existing(&ctx.istream_writer, &env->istream));
+ wabt_init_mem_writer_existing(&ctx.istream_writer, &env->istream));
reader = s_binary_reader;
reader.user_data = &ctx;
const uint32_t num_function_passes = 1;
- WasmResult result = wasm_read_binary(allocator, data, size, &reader,
+ WabtResult result = wabt_read_binary(allocator, data, size, &reader,
num_function_passes, options);
- wasm_steal_mem_writer_output_buffer(&ctx.istream_writer, &env->istream);
- if (WASM_SUCCEEDED(result)) {
+ wabt_steal_mem_writer_output_buffer(&ctx.istream_writer, &env->istream);
+ if (WABT_SUCCEEDED(result)) {
/* Another pass on the read binary to assign data and elem segments. */
reader = s_binary_reader_segments;
reader.user_data = &ctx;
- result = wasm_read_binary(allocator, data, size, &reader,
+ result = wabt_read_binary(allocator, data, size, &reader,
num_function_passes, options);
- assert(WASM_SUCCEEDED(result));
+ assert(WABT_SUCCEEDED(result));
env->istream.size = ctx.istream_offset;
ctx.module->defined.istream_end = env->istream.size;
*out_module = module;
} else {
- wasm_reset_interpreter_environment_to_mark(allocator, env, mark);
+ wabt_reset_interpreter_environment_to_mark(allocator, env, mark);
*out_module = NULL;
}
destroy_context(&ctx);
diff --git a/src/binary-reader-interpreter.h b/src/binary-reader-interpreter.h
index 090667c1..4f1b9c14 100644
--- a/src/binary-reader-interpreter.h
+++ b/src/binary-reader-interpreter.h
@@ -14,26 +14,26 @@
* limitations under the License.
*/
-#ifndef WASM_BINARY_READER_INTERPRETER_H_
-#define WASM_BINARY_READER_INTERPRETER_H_
+#ifndef WABT_BINARY_READER_INTERPRETER_H_
+#define WABT_BINARY_READER_INTERPRETER_H_
#include "common.h"
-struct WasmAllocator;
-struct WasmInterpreterEnvironment;
-struct WasmInterpreterModule;
-struct WasmReadBinaryOptions;
+struct WabtAllocator;
+struct WabtInterpreterEnvironment;
+struct WabtInterpreterModule;
+struct WabtReadBinaryOptions;
-WASM_EXTERN_C_BEGIN
-WasmResult wasm_read_binary_interpreter(
- struct WasmAllocator* allocator,
- struct WasmAllocator* memory_allocator,
- struct WasmInterpreterEnvironment* env,
+WABT_EXTERN_C_BEGIN
+WabtResult wabt_read_binary_interpreter(
+ struct WabtAllocator* allocator,
+ struct WabtAllocator* memory_allocator,
+ struct WabtInterpreterEnvironment* env,
const void* data,
size_t size,
- const struct WasmReadBinaryOptions* options,
- WasmBinaryErrorHandler*,
- struct WasmInterpreterModule** out_module);
-WASM_EXTERN_C_END
+ const struct WabtReadBinaryOptions* options,
+ WabtBinaryErrorHandler*,
+ struct WabtInterpreterModule** out_module);
+WABT_EXTERN_C_END
-#endif /* WASM_BINARY_READER_INTERPRETER_H_ */
+#endif /* WABT_BINARY_READER_INTERPRETER_H_ */
diff --git a/src/binary-reader-linker.c b/src/binary-reader-linker.c
index 89e30811..21fd0a31 100644
--- a/src/binary-reader-linker.c
+++ b/src/binary-reader-linker.c
@@ -22,127 +22,127 @@
#define RELOC_SIZE 5
typedef struct Context {
- WasmAllocator* allocator;
- WasmLinkerInputBinary* binary;
+ WabtAllocator* allocator;
+ WabtLinkerInputBinary* binary;
- WasmSection* reloc_section;
+ WabtSection* reloc_section;
- WasmStringSlice import_name;
- WasmSection* current_section;
+ WabtStringSlice import_name;
+ WabtSection* current_section;
} Context;
-static WasmResult on_reloc_count(uint32_t count,
- WasmBinarySection section_code,
- WasmStringSlice section_name,
+static WabtResult on_reloc_count(uint32_t count,
+ WabtBinarySection section_code,
+ WabtStringSlice section_name,
void* user_data) {
Context* ctx = user_data;
- WasmLinkerInputBinary* binary = ctx->binary;
- if (section_code == WASM_BINARY_SECTION_CUSTOM) {
- WASM_FATAL("relocation for custom sections not yet supported\n");
+ WabtLinkerInputBinary* binary = ctx->binary;
+ if (section_code == WABT_BINARY_SECTION_CUSTOM) {
+ WABT_FATAL("relocation for custom sections not yet supported\n");
}
uint32_t i;
for (i = 0; i < binary->sections.size; i++) {
- WasmSection* sec = &binary->sections.data[i];
+ WabtSection* sec = &binary->sections.data[i];
if (sec->section_code != section_code)
continue;
ctx->reloc_section = sec;
- return WASM_OK;
+ return WABT_OK;
}
- WASM_FATAL("section not found: %d\n", section_code);
- return WASM_ERROR;
+ WABT_FATAL("section not found: %d\n", section_code);
+ return WABT_ERROR;
}
-static WasmResult on_reloc(WasmRelocType type,
+static WabtResult on_reloc(WabtRelocType type,
uint32_t offset,
void* user_data) {
Context* ctx = user_data;
if (offset + RELOC_SIZE > ctx->reloc_section->size) {
- WASM_FATAL("invalid relocation offset: %#x\n", offset);
+ WABT_FATAL("invalid relocation offset: %#x\n", offset);
}
- WasmReloc* reloc =
- wasm_append_reloc(ctx->allocator, &ctx->reloc_section->relocations);
+ WabtReloc* reloc =
+ wabt_append_reloc(ctx->allocator, &ctx->reloc_section->relocations);
reloc->type = type;
reloc->offset = offset;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_import(uint32_t index,
- WasmStringSlice module_name,
- WasmStringSlice field_name,
+static WabtResult on_import(uint32_t index,
+ WabtStringSlice module_name,
+ WabtStringSlice field_name,
void* user_data) {
Context* ctx = user_data;
- if (!wasm_string_slice_eq_cstr(&module_name, WASM_LINK_MODULE_NAME)) {
- WASM_FATAL("unsupported import module: " PRIstringslice,
- WASM_PRINTF_STRING_SLICE_ARG(module_name));
+ if (!wabt_string_slice_eq_cstr(&module_name, WABT_LINK_MODULE_NAME)) {
+ WABT_FATAL("unsupported import module: " PRIstringslice,
+ WABT_PRINTF_STRING_SLICE_ARG(module_name));
}
ctx->import_name = field_name;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_import_func(uint32_t import_index,
+static WabtResult on_import_func(uint32_t import_index,
uint32_t global_index,
uint32_t sig_index,
void* user_data) {
Context* ctx = user_data;
- WasmFunctionImport* import = wasm_append_function_import(
+ WabtFunctionImport* import = wabt_append_function_import(
ctx->allocator, &ctx->binary->function_imports);
import->name = ctx->import_name;
import->sig_index = sig_index;
- import->active = WASM_TRUE;
+ import->active = WABT_TRUE;
ctx->binary->active_function_imports++;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_import_global(uint32_t import_index,
+static WabtResult on_import_global(uint32_t import_index,
uint32_t global_index,
- WasmType type,
- WasmBool mutable,
+ WabtType type,
+ WabtBool mutable,
void* user_data) {
Context* ctx = user_data;
- WasmGlobalImport* import =
- wasm_append_global_import(ctx->allocator, &ctx->binary->global_imports);
+ WabtGlobalImport* import =
+ wabt_append_global_import(ctx->allocator, &ctx->binary->global_imports);
import->name = ctx->import_name;
import->type = type;
import->mutable = mutable;
ctx->binary->active_global_imports++;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult begin_section(WasmBinaryReaderContext* ctx,
- WasmBinarySection section_code,
+static WabtResult begin_section(WabtBinaryReaderContext* ctx,
+ WabtBinarySection section_code,
uint32_t size) {
Context* context = ctx->user_data;
- WasmLinkerInputBinary* binary = context->binary;
- WasmSection* sec = wasm_append_section(context->allocator, &binary->sections);
+ WabtLinkerInputBinary* binary = context->binary;
+ WabtSection* sec = wabt_append_section(context->allocator, &binary->sections);
context->current_section = sec;
sec->section_code = section_code;
sec->size = size;
sec->offset = ctx->offset;
sec->binary = binary;
- if (sec->section_code != WASM_BINARY_SECTION_CUSTOM &&
- sec->section_code != WASM_BINARY_SECTION_START) {
- size_t bytes_read = wasm_read_u32_leb128(
+ if (sec->section_code != WABT_BINARY_SECTION_CUSTOM &&
+ sec->section_code != WABT_BINARY_SECTION_START) {
+ size_t bytes_read = wabt_read_u32_leb128(
&binary->data[sec->offset], &binary->data[binary->size], &sec->count);
if (bytes_read == 0)
- WASM_FATAL("error reading section element count\n");
+ WABT_FATAL("error reading section element count\n");
sec->payload_offset = sec->offset + bytes_read;
sec->payload_size = sec->size - bytes_read;
}
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult begin_custom_section(WasmBinaryReaderContext* ctx,
+static WabtResult begin_custom_section(WabtBinaryReaderContext* ctx,
uint32_t size,
- WasmStringSlice section_name) {
+ WabtStringSlice section_name) {
Context* context = ctx->user_data;
- WasmLinkerInputBinary* binary = context->binary;
- WasmSection* sec = context->current_section;
+ WabtLinkerInputBinary* binary = context->binary;
+ WabtSection* sec = context->current_section;
sec->data_custom.name = section_name;
/* Modify section size and offset to not include the name itself. */
@@ -153,8 +153,8 @@ static WasmResult begin_custom_section(WasmBinaryReaderContext* ctx,
sec->payload_size = sec->size;
/* Special handling for certain CUSTOM sections */
- if (wasm_string_slice_eq_cstr(&section_name, "name")) {
- size_t bytes_read = wasm_read_u32_leb128(
+ if (wabt_string_slice_eq_cstr(&section_name, "name")) {
+ size_t bytes_read = wabt_read_u32_leb128(
&binary->data[sec->offset], &binary->data[binary->size], &sec->count);
sec->payload_offset += bytes_read;
sec->payload_size -= bytes_read;
@@ -165,117 +165,117 @@ static WasmResult begin_custom_section(WasmBinaryReaderContext* ctx,
uint32_t total_funcs = binary->function_imports.size;
for (i = 0; i < binary->sections.size; i++) {
if (binary->sections.data[i].section_code ==
- WASM_BINARY_SECTION_FUNCTION) {
+ WABT_BINARY_SECTION_FUNCTION) {
total_funcs += binary->sections.data[i].count;
break;
}
}
if (total_funcs != sec->count) {
- WASM_FATAL("name section count (%d) does not match function count (%d)\n",
+ WABT_FATAL("name section count (%d) does not match function count (%d)\n",
sec->count, total_funcs);
}
}
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_table(uint32_t index,
- WasmType elem_type,
- const WasmLimits* elem_limits,
+static WabtResult on_table(uint32_t index,
+ WabtType elem_type,
+ const WabtLimits* elem_limits,
void* user_data) {
if (elem_limits->has_max && (elem_limits->max != elem_limits->initial))
- WASM_FATAL("Tables with max != initial not supported by wasm-link\n");
+ WABT_FATAL("Tables with max != initial not supported by wabt-link\n");
Context* ctx = user_data;
ctx->binary->table_elem_count = elem_limits->initial;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_elem_segment_function_index_count(
- WasmBinaryReaderContext* ctx,
+static WabtResult on_elem_segment_function_index_count(
+ WabtBinaryReaderContext* ctx,
uint32_t index,
uint32_t count) {
Context* context = ctx->user_data;
- WasmSection* sec = context->current_section;
+ WabtSection* sec = context->current_section;
/* Modify the payload to include only the actual function indexes */
size_t delta = ctx->offset - sec->payload_offset;
sec->payload_offset += delta;
sec->payload_size -= delta;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_memory(uint32_t index,
- const WasmLimits* page_limits,
+static WabtResult on_memory(uint32_t index,
+ const WabtLimits* page_limits,
void* user_data) {
Context* ctx = user_data;
- WasmSection* sec = ctx->current_section;
+ WabtSection* sec = ctx->current_section;
sec->memory_limits = *page_limits;
ctx->binary->memory_page_count = page_limits->initial;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult begin_data_segment(uint32_t index,
+static WabtResult begin_data_segment(uint32_t index,
uint32_t memory_index,
void* user_data) {
Context* ctx = user_data;
- WasmSection* sec = ctx->current_section;
- WasmDataSegment* segment =
- wasm_append_data_segment(ctx->allocator, &sec->data_segments);
+ WabtSection* sec = ctx->current_section;
+ WabtDataSegment* segment =
+ wabt_append_data_segment(ctx->allocator, &sec->data_segments);
segment->memory_index = memory_index;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_init_expr_i32_const_expr(uint32_t index,
+static WabtResult on_init_expr_i32_const_expr(uint32_t index,
uint32_t value,
void* user_data) {
Context* ctx = user_data;
- WasmSection* sec = ctx->current_section;
- if (sec->section_code != WASM_BINARY_SECTION_DATA)
- return WASM_OK;
- WasmDataSegment* segment =
+ WabtSection* sec = ctx->current_section;
+ if (sec->section_code != WABT_BINARY_SECTION_DATA)
+ return WABT_OK;
+ WabtDataSegment* segment =
&sec->data_segments.data[sec->data_segments.size - 1];
segment->offset = value;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_data_segment_data(uint32_t index,
+static WabtResult on_data_segment_data(uint32_t index,
const void* src_data,
uint32_t size,
void* user_data) {
Context* ctx = user_data;
- WasmSection* sec = ctx->current_section;
- WasmDataSegment* segment =
+ WabtSection* sec = ctx->current_section;
+ WabtDataSegment* segment =
&sec->data_segments.data[sec->data_segments.size - 1];
segment->data = src_data;
segment->size = size;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_export(uint32_t index,
- WasmExternalKind kind,
+static WabtResult on_export(uint32_t index,
+ WabtExternalKind kind,
uint32_t item_index,
- WasmStringSlice name,
+ WabtStringSlice name,
void* user_data) {
Context* ctx = user_data;
- WasmExport* export =
- wasm_append_export(ctx->allocator, &ctx->binary->exports);
+ WabtExport* export =
+ wabt_append_export(ctx->allocator, &ctx->binary->exports);
export->name = name;
export->kind = kind;
export->index = item_index;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_function_name(uint32_t index,
- WasmStringSlice name,
+static WabtResult on_function_name(uint32_t index,
+ WabtStringSlice name,
void* user_data) {
Context* ctx = user_data;
- wasm_append_string_slice_value(ctx->allocator, &ctx->binary->debug_names,
+ wabt_append_string_slice_value(ctx->allocator, &ctx->binary->debug_names,
&name);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmBinaryReader s_binary_reader = {
+static WabtBinaryReader s_binary_reader = {
.begin_section = begin_section,
.begin_custom_section = begin_custom_section,
@@ -302,20 +302,20 @@ static WasmBinaryReader s_binary_reader = {
.on_function_name = on_function_name,
};
-WasmResult wasm_read_binary_linker(struct WasmAllocator* allocator,
- WasmLinkerInputBinary* input_info) {
+WabtResult wabt_read_binary_linker(struct WabtAllocator* allocator,
+ WabtLinkerInputBinary* input_info) {
Context context;
- WASM_ZERO_MEMORY(context);
+ WABT_ZERO_MEMORY(context);
context.allocator = allocator;
context.binary = input_info;
- WasmBinaryReader reader;
- WASM_ZERO_MEMORY(reader);
+ WabtBinaryReader reader;
+ WABT_ZERO_MEMORY(reader);
reader = s_binary_reader;
reader.user_data = &context;
- WasmReadBinaryOptions read_options = WASM_READ_BINARY_OPTIONS_DEFAULT;
- read_options.read_debug_names = WASM_TRUE;
- return wasm_read_binary(allocator, input_info->data, input_info->size,
+ WabtReadBinaryOptions read_options = WABT_READ_BINARY_OPTIONS_DEFAULT;
+ read_options.read_debug_names = WABT_TRUE;
+ return wabt_read_binary(allocator, input_info->data, input_info->size,
&reader, 1, &read_options);
}
diff --git a/src/binary-reader-linker.h b/src/binary-reader-linker.h
index cfdb2276..4371592e 100644
--- a/src/binary-reader-linker.h
+++ b/src/binary-reader-linker.h
@@ -14,20 +14,20 @@
* limitations under the License.
*/
-#ifndef WASM_BINARY_READER_LINKER_H_
-#define WASM_BINARY_READER_LINKER_H_
+#ifndef WABT_BINARY_READER_LINKER_H_
+#define WABT_BINARY_READER_LINKER_H_
#include "common.h"
#include "stream.h"
-struct WasmAllocator;
-struct WasmLinkerInputBinary;
+struct WabtAllocator;
+struct WabtLinkerInputBinary;
-WASM_EXTERN_C_BEGIN
+WABT_EXTERN_C_BEGIN
-WasmResult wasm_read_binary_linker(struct WasmAllocator* allocator,
- struct WasmLinkerInputBinary* input_info);
+WabtResult wabt_read_binary_linker(struct WabtAllocator* allocator,
+ struct WabtLinkerInputBinary* input_info);
-WASM_EXTERN_C_END
+WABT_EXTERN_C_END
-#endif /* WASM_BINARY_READER_LINKER_H_ */
+#endif /* WABT_BINARY_READER_LINKER_H_ */
diff --git a/src/binary-reader-objdump.c b/src/binary-reader-objdump.c
index dd8941e5..12d29244 100644
--- a/src/binary-reader-objdump.c
+++ b/src/binary-reader-objdump.c
@@ -26,38 +26,38 @@
#include "vector.h"
typedef uint32_t Uint32;
-WASM_DEFINE_VECTOR(uint32, Uint32);
+WABT_DEFINE_VECTOR(uint32, Uint32);
typedef struct Context {
- WasmObjdumpOptions* options;
- WasmAllocator* allocator;
- WasmStream* out_stream;
+ WabtObjdumpOptions* options;
+ WabtAllocator* allocator;
+ WabtStream* out_stream;
const uint8_t* data;
size_t size;
- WasmOpcode current_opcode;
+ WabtOpcode current_opcode;
size_t current_opcode_offset;
size_t last_opcode_end;
int indent_level;
- WasmBool print_details;
- WasmBool header_printed;
+ WabtBool print_details;
+ WabtBool header_printed;
int section_found;
- uint32_t section_starts[WASM_NUM_BINARY_SECTIONS];
- WasmBinarySection reloc_section;
+ uint32_t section_starts[WABT_NUM_BINARY_SECTIONS];
+ WabtBinarySection reloc_section;
- WasmStringSlice import_module_name;
- WasmStringSlice import_field_name;
+ WabtStringSlice import_module_name;
+ WabtStringSlice import_field_name;
uint32_t next_reloc;
} Context;
-static WasmBool should_print_details(Context* ctx) {
- if (ctx->options->mode != WASM_DUMP_DETAILS)
- return WASM_FALSE;
+static WabtBool should_print_details(Context* ctx) {
+ if (ctx->options->mode != WABT_DUMP_DETAILS)
+ return WABT_FALSE;
return ctx->print_details;
}
-static void WASM_PRINTF_FORMAT(2, 3)
+static void WABT_PRINTF_FORMAT(2, 3)
print_details(Context* ctx, const char* fmt, ...) {
if (!should_print_details(ctx))
return;
@@ -67,70 +67,70 @@ static void WASM_PRINTF_FORMAT(2, 3)
va_end(args);
}
-static WasmResult begin_section(WasmBinaryReaderContext* ctx,
- WasmBinarySection section_code,
+static WabtResult begin_section(WabtBinaryReaderContext* ctx,
+ WabtBinarySection section_code,
uint32_t size) {
Context* context = ctx->user_data;
context->section_starts[section_code] = ctx->offset;
- const char* name = wasm_get_section_name(section_code);
+ const char* name = wabt_get_section_name(section_code);
- WasmBool section_match = !context->options->section_name ||
+ WabtBool section_match = !context->options->section_name ||
!strcasecmp(context->options->section_name, name);
if (section_match)
- context->section_found = WASM_TRUE;
+ context->section_found = WABT_TRUE;
switch (context->options->mode) {
- case WASM_DUMP_PREPASS:
+ case WABT_DUMP_PREPASS:
break;
- case WASM_DUMP_HEADERS:
+ case WABT_DUMP_HEADERS:
printf("%9s start=%#010" PRIzx " end=%#010" PRIzx " (size=%#010x) ",
name, ctx->offset, ctx->offset + size, size);
break;
- case WASM_DUMP_DETAILS:
+ case WABT_DUMP_DETAILS:
if (section_match) {
- if (section_code != WASM_BINARY_SECTION_CODE)
+ if (section_code != WABT_BINARY_SECTION_CODE)
printf("%s:\n", name);
- context->print_details = WASM_TRUE;
+ context->print_details = WABT_TRUE;
} else {
- context->print_details = WASM_FALSE;
+ context->print_details = WABT_FALSE;
}
break;
- case WASM_DUMP_RAW_DATA:
+ case WABT_DUMP_RAW_DATA:
if (section_match) {
printf("\nContents of section %s:\n", name);
- wasm_write_memory_dump(context->out_stream, context->data + ctx->offset,
- size, ctx->offset, WASM_PRINT_CHARS, NULL, NULL);
+ wabt_write_memory_dump(context->out_stream, context->data + ctx->offset,
+ size, ctx->offset, WABT_PRINT_CHARS, NULL, NULL);
}
break;
- case WASM_DUMP_DISASSEMBLE:
+ case WABT_DUMP_DISASSEMBLE:
break;
}
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult begin_custom_section(WasmBinaryReaderContext* ctx,
+static WabtResult begin_custom_section(WabtBinaryReaderContext* ctx,
uint32_t size,
- WasmStringSlice section_name) {
+ WabtStringSlice section_name) {
Context* context = ctx->user_data;
print_details(context, " - name: \"" PRIstringslice "\"\n",
- WASM_PRINTF_STRING_SLICE_ARG(section_name));
- if (context->options->mode == WASM_DUMP_HEADERS) {
+ WABT_PRINTF_STRING_SLICE_ARG(section_name));
+ if (context->options->mode == WABT_DUMP_HEADERS) {
printf("\"" PRIstringslice "\"\n",
- WASM_PRINTF_STRING_SLICE_ARG(section_name));
+ WABT_PRINTF_STRING_SLICE_ARG(section_name));
}
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_count(uint32_t count, void* user_data) {
+static WabtResult on_count(uint32_t count, void* user_data) {
Context* ctx = user_data;
- if (ctx->options->mode == WASM_DUMP_HEADERS) {
+ if (ctx->options->mode == WABT_DUMP_HEADERS) {
printf("count: %d\n", count);
}
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult begin_module(uint32_t version, void* user_data) {
+static WabtResult begin_module(uint32_t version, void* user_data) {
Context* ctx = user_data;
if (ctx->options->print_header) {
const char *basename = strrchr(ctx->options->infile, '/');
@@ -139,65 +139,65 @@ static WasmResult begin_module(uint32_t version, void* user_data) {
else
basename = ctx->options->infile;
printf("%s:\tfile format wasm %#08x\n", basename, version);
- ctx->header_printed = WASM_TRUE;
+ ctx->header_printed = WABT_TRUE;
}
switch (ctx->options->mode) {
- case WASM_DUMP_HEADERS:
+ case WABT_DUMP_HEADERS:
printf("\n");
printf("Sections:\n\n");
break;
- case WASM_DUMP_DETAILS:
+ case WABT_DUMP_DETAILS:
printf("\n");
printf("Section Details:\n\n");
break;
- case WASM_DUMP_DISASSEMBLE:
+ case WABT_DUMP_DISASSEMBLE:
printf("\n");
printf("Code Disassembly:\n\n");
break;
- case WASM_DUMP_RAW_DATA:
- case WASM_DUMP_PREPASS:
+ case WABT_DUMP_RAW_DATA:
+ case WABT_DUMP_PREPASS:
break;
}
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult end_module(void *user_data) {
+static WabtResult end_module(void *user_data) {
Context* ctx = user_data;
if (ctx->options->section_name) {
if (!ctx->section_found) {
printf("Section not found: %s\n", ctx->options->section_name);
- return WASM_ERROR;
+ return WABT_ERROR;
}
}
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_opcode(WasmBinaryReaderContext* ctx, WasmOpcode opcode) {
+static WabtResult on_opcode(WabtBinaryReaderContext* ctx, WabtOpcode opcode) {
Context* context = ctx->user_data;
if (context->options->debug) {
- const char* opcode_name = wasm_get_opcode_name(opcode);
+ const char* opcode_name = wabt_get_opcode_name(opcode);
printf("on_opcode: %#" PRIzx ": %s\n", ctx->offset, opcode_name);
}
if (context->last_opcode_end) {
if (ctx->offset != context->last_opcode_end + 1) {
uint8_t missing_opcode = ctx->data[context->last_opcode_end];
- const char* opcode_name = wasm_get_opcode_name(missing_opcode);
+ const char* opcode_name = wabt_get_opcode_name(missing_opcode);
fprintf(stderr, "warning: %#" PRIzx " missing opcode callback at %#" PRIzx
" (%#02x=%s)\n",
ctx->offset, context->last_opcode_end + 1,
ctx->data[context->last_opcode_end], opcode_name);
- return WASM_ERROR;
+ return WABT_ERROR;
}
}
context->current_opcode_offset = ctx->offset;
context->current_opcode = opcode;
- return WASM_OK;
+ return WABT_OK;
}
#define IMMEDIATE_OCTET_COUNT 9
@@ -223,13 +223,13 @@ static void log_opcode(Context* ctx,
// Print disassemble
int j;
int indent_level = ctx->indent_level;
- if (ctx->current_opcode == WASM_OPCODE_ELSE)
+ if (ctx->current_opcode == WABT_OPCODE_ELSE)
indent_level--;
for (j = 0; j < indent_level; j++) {
printf(" ");
}
- const char* opcode_name = wasm_get_opcode_name(ctx->current_opcode);
+ const char* opcode_name = wabt_get_opcode_name(ctx->current_opcode);
printf("%s", opcode_name);
if (fmt) {
printf(" ");
@@ -245,70 +245,70 @@ static void log_opcode(Context* ctx,
if (ctx->options->relocs) {
if (ctx->next_reloc < ctx->options->code_relocations.size) {
- WasmReloc* reloc = &ctx->options->code_relocations.data[ctx->next_reloc];
- size_t code_start = ctx->section_starts[WASM_BINARY_SECTION_CODE];
+ WabtReloc* reloc = &ctx->options->code_relocations.data[ctx->next_reloc];
+ size_t code_start = ctx->section_starts[WABT_BINARY_SECTION_CODE];
size_t abs_offset = code_start + reloc->offset;
if (ctx->last_opcode_end > abs_offset) {
printf(" %06" PRIzx ": %s\n", abs_offset,
- wasm_get_reloc_type_name(reloc->type));
+ wabt_get_reloc_type_name(reloc->type));
ctx->next_reloc++;
}
}
}
}
-static WasmResult on_opcode_bare(WasmBinaryReaderContext* ctx) {
+static WabtResult on_opcode_bare(WabtBinaryReaderContext* ctx) {
Context* context = ctx->user_data;
log_opcode(context, ctx->data, 0, NULL);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_opcode_uint32(WasmBinaryReaderContext* ctx,
+static WabtResult on_opcode_uint32(WabtBinaryReaderContext* ctx,
uint32_t value) {
Context* context = ctx->user_data;
size_t immediate_len = ctx->offset - context->current_opcode_offset;
log_opcode(context, ctx->data, immediate_len, "%#x", value);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_opcode_uint32_uint32(WasmBinaryReaderContext* ctx,
+static WabtResult on_opcode_uint32_uint32(WabtBinaryReaderContext* ctx,
uint32_t value,
uint32_t value2) {
Context* context = ctx->user_data;
size_t immediate_len = ctx->offset - context->current_opcode_offset;
log_opcode(context, ctx->data, immediate_len, "%lu %lu", value, value2);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_opcode_uint64(WasmBinaryReaderContext* ctx,
+static WabtResult on_opcode_uint64(WabtBinaryReaderContext* ctx,
uint64_t value) {
Context* context = ctx->user_data;
size_t immediate_len = ctx->offset - context->current_opcode_offset;
log_opcode(context, ctx->data, immediate_len, "%d", value);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_opcode_f32(WasmBinaryReaderContext* ctx,
+static WabtResult on_opcode_f32(WabtBinaryReaderContext* ctx,
uint32_t value) {
Context* context = ctx->user_data;
size_t immediate_len = ctx->offset - context->current_opcode_offset;
- char buffer[WASM_MAX_FLOAT_HEX];
- wasm_write_float_hex(buffer, sizeof(buffer), value);
+ char buffer[WABT_MAX_FLOAT_HEX];
+ wabt_write_float_hex(buffer, sizeof(buffer), value);
log_opcode(context, ctx->data, immediate_len, buffer);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_opcode_f64(WasmBinaryReaderContext* ctx,
+static WabtResult on_opcode_f64(WabtBinaryReaderContext* ctx,
uint64_t value) {
Context* context = ctx->user_data;
size_t immediate_len = ctx->offset - context->current_opcode_offset;
- char buffer[WASM_MAX_DOUBLE_HEX];
- wasm_write_double_hex(buffer, sizeof(buffer), value);
+ char buffer[WABT_MAX_DOUBLE_HEX];
+ wabt_write_double_hex(buffer, sizeof(buffer), value);
log_opcode(context, ctx->data, immediate_len, buffer);
- return WASM_OK;
+ return WABT_OK;
}
-WasmResult on_br_table_expr(WasmBinaryReaderContext* ctx,
+WabtResult on_br_table_expr(WabtBinaryReaderContext* ctx,
uint32_t num_targets,
uint32_t* target_depths,
uint32_t default_target_depth) {
@@ -316,29 +316,29 @@ WasmResult on_br_table_expr(WasmBinaryReaderContext* ctx,
size_t immediate_len = ctx->offset - context->current_opcode_offset;
/* TODO(sbc): Print targets */
log_opcode(context, ctx->data, immediate_len, NULL);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_end_expr(void* user_data) {
+static WabtResult on_end_expr(void* user_data) {
Context* context = user_data;
context->indent_level--;
assert(context->indent_level >= 0);
log_opcode(context, NULL, 0, NULL);
- return WASM_OK;
+ return WABT_OK;
}
-static const char* wasm_type_name(WasmType type) {
+static const char* wabt_type_name(WabtType type) {
switch (type) {
- case WASM_TYPE_I32:
+ case WABT_TYPE_I32:
return "i32";
- case WASM_TYPE_I64:
+ case WABT_TYPE_I64:
return "i64";
- case WASM_TYPE_F32:
+ case WABT_TYPE_F32:
return "f32";
- case WASM_TYPE_F64:
+ case WABT_TYPE_F64:
return "f64";
default:
@@ -347,80 +347,80 @@ static const char* wasm_type_name(WasmType type) {
}
}
-static WasmResult on_opcode_block_sig(WasmBinaryReaderContext* ctx,
+static WabtResult on_opcode_block_sig(WabtBinaryReaderContext* ctx,
uint32_t num_types,
- WasmType* sig_types) {
+ WabtType* sig_types) {
Context* context = ctx->user_data;
if (num_types)
- log_opcode(context, ctx->data, 1, "%s", wasm_type_name(*sig_types));
+ log_opcode(context, ctx->data, 1, "%s", wabt_type_name(*sig_types));
else
log_opcode(context, ctx->data, 1, NULL);
context->indent_level++;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_signature(uint32_t index,
+static WabtResult on_signature(uint32_t index,
uint32_t param_count,
- WasmType* param_types,
+ WabtType* param_types,
uint32_t result_count,
- WasmType* result_types,
+ WabtType* result_types,
void* user_data) {
Context* ctx = user_data;
if (!should_print_details(ctx))
- return WASM_OK;
+ return WABT_OK;
printf(" - [%d] (", index);
uint32_t i;
for (i = 0; i < param_count; i++) {
if (i != 0) {
printf(", ");
}
- printf("%s", wasm_type_name(param_types[i]));
+ printf("%s", wabt_type_name(param_types[i]));
}
printf(") -> ");
if (result_count)
- printf("%s", wasm_type_name(result_types[0]));
+ printf("%s", wabt_type_name(result_types[0]));
else
printf("nil");
printf("\n");
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_function_signature(uint32_t index,
+static WabtResult on_function_signature(uint32_t index,
uint32_t sig_index,
void* user_data) {
print_details(user_data, " - func[%d] sig=%d\n", index, sig_index);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult begin_function_body(WasmBinaryReaderContext* context,
+static WabtResult begin_function_body(WabtBinaryReaderContext* context,
uint32_t index) {
Context* ctx = context->user_data;
- if (ctx->options->mode == WASM_DUMP_DISASSEMBLE) {
+ if (ctx->options->mode == WABT_DUMP_DISASSEMBLE) {
if (index < ctx->options->function_names.size)
printf("%06" PRIzx " <" PRIstringslice ">:\n", context->offset,
- WASM_PRINTF_STRING_SLICE_ARG(
+ WABT_PRINTF_STRING_SLICE_ARG(
ctx->options->function_names.data[index]));
else
printf("%06" PRIzx " func[%d]:\n", context->offset, index);
}
ctx->last_opcode_end = 0;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_import(uint32_t index,
- WasmStringSlice module_name,
- WasmStringSlice field_name,
+static WabtResult on_import(uint32_t index,
+ WabtStringSlice module_name,
+ WabtStringSlice field_name,
void* user_data) {
Context* ctx = user_data;
ctx->import_module_name = module_name;
ctx->import_field_name = field_name;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_import_func(uint32_t import_index,
+static WabtResult on_import_func(uint32_t import_index,
uint32_t func_index,
uint32_t sig_index,
void* user_data) {
@@ -428,54 +428,54 @@ static WasmResult on_import_func(uint32_t import_index,
print_details(user_data,
" - func[%d] sig=%d <- " PRIstringslice "." PRIstringslice "\n",
func_index, sig_index,
- WASM_PRINTF_STRING_SLICE_ARG(ctx->import_module_name),
- WASM_PRINTF_STRING_SLICE_ARG(ctx->import_field_name));
- return WASM_OK;
+ WABT_PRINTF_STRING_SLICE_ARG(ctx->import_module_name),
+ WABT_PRINTF_STRING_SLICE_ARG(ctx->import_field_name));
+ return WABT_OK;
}
-static WasmResult on_import_table(uint32_t import_index,
+static WabtResult on_import_table(uint32_t import_index,
uint32_t table_index,
- WasmType elem_type,
- const WasmLimits* elem_limits,
+ WabtType elem_type,
+ const WabtLimits* elem_limits,
void* user_data) {
Context* ctx = user_data;
print_details(
user_data, " - " PRIstringslice "." PRIstringslice
" -> table elem_type=%s init=%" PRId64 " max=%" PRId64 "\n",
- WASM_PRINTF_STRING_SLICE_ARG(ctx->import_module_name),
- WASM_PRINTF_STRING_SLICE_ARG(ctx->import_field_name),
- wasm_get_type_name(elem_type), elem_limits->initial, elem_limits->max);
- return WASM_OK;
+ WABT_PRINTF_STRING_SLICE_ARG(ctx->import_module_name),
+ WABT_PRINTF_STRING_SLICE_ARG(ctx->import_field_name),
+ wabt_get_type_name(elem_type), elem_limits->initial, elem_limits->max);
+ return WABT_OK;
}
-static WasmResult on_import_memory(uint32_t import_index,
+static WabtResult on_import_memory(uint32_t import_index,
uint32_t memory_index,
- const WasmLimits* page_limits,
+ const WabtLimits* page_limits,
void* user_data) {
Context* ctx = user_data;
print_details(user_data,
" - " PRIstringslice "." PRIstringslice " -> memory\n",
- WASM_PRINTF_STRING_SLICE_ARG(ctx->import_module_name),
- WASM_PRINTF_STRING_SLICE_ARG(ctx->import_field_name));
- return WASM_OK;
+ WABT_PRINTF_STRING_SLICE_ARG(ctx->import_module_name),
+ WABT_PRINTF_STRING_SLICE_ARG(ctx->import_field_name));
+ return WABT_OK;
}
-static WasmResult on_import_global(uint32_t import_index,
+static WabtResult on_import_global(uint32_t import_index,
uint32_t global_index,
- WasmType type,
- WasmBool mutable_,
+ WabtType type,
+ WabtBool mutable_,
void* user_data) {
Context* ctx = user_data;
print_details(user_data, " - global[%d] %s mutable=%d <- " PRIstringslice
"." PRIstringslice "\n",
- global_index, wasm_get_type_name(type), mutable_,
- WASM_PRINTF_STRING_SLICE_ARG(ctx->import_module_name),
- WASM_PRINTF_STRING_SLICE_ARG(ctx->import_field_name));
- return WASM_OK;
+ global_index, wabt_get_type_name(type), mutable_,
+ WABT_PRINTF_STRING_SLICE_ARG(ctx->import_module_name),
+ WABT_PRINTF_STRING_SLICE_ARG(ctx->import_field_name));
+ return WABT_OK;
}
-static WasmResult on_memory(uint32_t index,
- const WasmLimits* page_limits,
+static WabtResult on_memory(uint32_t index,
+ const WabtLimits* page_limits,
void* user_data) {
print_details(user_data, " - memory[%d] pages: initial=%" PRId64,
index,
@@ -483,177 +483,177 @@ static WasmResult on_memory(uint32_t index,
if (page_limits->has_max)
print_details(user_data, " max=%" PRId64, page_limits->max);
print_details(user_data, "\n");
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_table(uint32_t index,
- WasmType elem_type,
- const WasmLimits* elem_limits,
+static WabtResult on_table(uint32_t index,
+ WabtType elem_type,
+ const WabtLimits* elem_limits,
void* user_data) {
print_details(user_data, " - table[%d] type=%s initial=%" PRId64,
index,
- wasm_get_type_name(elem_type),
+ wabt_get_type_name(elem_type),
elem_limits->initial);
if (elem_limits->has_max)
print_details(user_data, " max=%" PRId64, elem_limits->max);
print_details(user_data, "\n");
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_export(uint32_t index,
- WasmExternalKind kind,
+static WabtResult on_export(uint32_t index,
+ WabtExternalKind kind,
uint32_t item_index,
- WasmStringSlice name,
+ WabtStringSlice name,
void* user_data) {
- print_details(user_data, " - %s[%d] ", wasm_get_kind_name(kind), item_index);
- print_details(user_data, PRIstringslice, WASM_PRINTF_STRING_SLICE_ARG(name));
+ print_details(user_data, " - %s[%d] ", wabt_get_kind_name(kind), item_index);
+ print_details(user_data, PRIstringslice, WABT_PRINTF_STRING_SLICE_ARG(name));
print_details(user_data, "\n");
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_elem_segment_function_index(uint32_t index,
+static WabtResult on_elem_segment_function_index(uint32_t index,
uint32_t func_index,
void* user_data) {
print_details(user_data, " - func[%d]\n", func_index);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult begin_elem_segment(uint32_t index,
+static WabtResult begin_elem_segment(uint32_t index,
uint32_t table_index,
void* user_data) {
print_details(user_data, " - segment[%d] table=%d\n", index, table_index);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult begin_global(uint32_t index,
- WasmType type,
- WasmBool mutable,
+static WabtResult begin_global(uint32_t index,
+ WabtType type,
+ WabtBool mutable,
void* user_data) {
print_details(user_data, " - global[%d] %s mutable=%d", index,
- wasm_get_type_name(type), mutable);
- return WASM_OK;
+ wabt_get_type_name(type), mutable);
+ return WABT_OK;
}
-static WasmResult on_init_expr_f32_const_expr(uint32_t index,
+static WabtResult on_init_expr_f32_const_expr(uint32_t index,
uint32_t value,
void* user_data) {
- char buffer[WASM_MAX_FLOAT_HEX];
- wasm_write_float_hex(buffer, sizeof(buffer), value);
+ char buffer[WABT_MAX_FLOAT_HEX];
+ wabt_write_float_hex(buffer, sizeof(buffer), value);
print_details(user_data, " - init f32=%s\n", buffer);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_init_expr_f64_const_expr(uint32_t index,
+static WabtResult on_init_expr_f64_const_expr(uint32_t index,
uint64_t value,
void* user_data) {
- char buffer[WASM_MAX_DOUBLE_HEX];
- wasm_write_float_hex(buffer, sizeof(buffer), value);
+ char buffer[WABT_MAX_DOUBLE_HEX];
+ wabt_write_float_hex(buffer, sizeof(buffer), value);
print_details(user_data, " - init f64=%s\n", buffer);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_init_expr_get_global_expr(uint32_t index,
+static WabtResult on_init_expr_get_global_expr(uint32_t index,
uint32_t global_index,
void* user_data) {
print_details(user_data, " - init global=%d\n", global_index);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_init_expr_i32_const_expr(uint32_t index,
+static WabtResult on_init_expr_i32_const_expr(uint32_t index,
uint32_t value,
void* user_data) {
print_details(user_data, " - init i32=%d\n", value);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_init_expr_i64_const_expr(uint32_t index,
+static WabtResult on_init_expr_i64_const_expr(uint32_t index,
uint64_t value,
void* user_data) {
print_details(user_data, " - init i64=%" PRId64 "\n", value);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_function_name(uint32_t index,
- WasmStringSlice name,
+static WabtResult on_function_name(uint32_t index,
+ WabtStringSlice name,
void* user_data) {
Context* ctx = user_data;
print_details(ctx, " - func[%d] " PRIstringslice "\n", index,
- WASM_PRINTF_STRING_SLICE_ARG(name));
- if (ctx->options->mode == WASM_DUMP_PREPASS)
- wasm_append_string_slice_value(ctx->allocator,
+ WABT_PRINTF_STRING_SLICE_ARG(name));
+ if (ctx->options->mode == WABT_DUMP_PREPASS)
+ wabt_append_string_slice_value(ctx->allocator,
&ctx->options->function_names, &name);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_local_name(uint32_t func_index,
+static WabtResult on_local_name(uint32_t func_index,
uint32_t local_index,
- WasmStringSlice name,
+ WabtStringSlice name,
void* user_data) {
if (name.length) {
print_details(user_data, " - local[%d] " PRIstringslice "\n", local_index,
- WASM_PRINTF_STRING_SLICE_ARG(name));
+ WABT_PRINTF_STRING_SLICE_ARG(name));
}
- return WASM_OK;
+ return WABT_OK;
}
-WasmResult on_reloc_count(uint32_t count,
- WasmBinarySection section_code,
- WasmStringSlice section_name,
+WabtResult on_reloc_count(uint32_t count,
+ WabtBinarySection section_code,
+ WabtStringSlice section_name,
void* user_data) {
Context* ctx = user_data;
ctx->reloc_section = section_code;
print_details(user_data, " - section: %s\n",
- wasm_get_section_name(section_code));
- return WASM_OK;
+ wabt_get_section_name(section_code));
+ return WABT_OK;
}
-WasmResult on_reloc(WasmRelocType type,
+WabtResult on_reloc(WabtRelocType type,
uint32_t offset,
void* user_data) {
Context* ctx = user_data;
uint32_t total_offset = ctx->section_starts[ctx->reloc_section] + offset;
print_details(user_data, " - %-18s offset=%#x (%#x)\n",
- wasm_get_reloc_type_name(type), total_offset, offset);
- if (ctx->options->mode == WASM_DUMP_PREPASS &&
- ctx->reloc_section == WASM_BINARY_SECTION_CODE) {
- WasmReloc reloc;
+ wabt_get_reloc_type_name(type), total_offset, offset);
+ if (ctx->options->mode == WABT_DUMP_PREPASS &&
+ ctx->reloc_section == WABT_BINARY_SECTION_CODE) {
+ WabtReloc reloc;
reloc.offset = offset;
reloc.type = type;
- wasm_append_reloc_value(ctx->allocator, &ctx->options->code_relocations,
+ wabt_append_reloc_value(ctx->allocator, &ctx->options->code_relocations,
&reloc);
}
- return WASM_OK;
+ return WABT_OK;
}
-static void on_error(WasmBinaryReaderContext* ctx, const char* message) {
- WasmDefaultErrorHandlerInfo info;
+static void on_error(WabtBinaryReaderContext* ctx, const char* message) {
+ WabtDefaultErrorHandlerInfo info;
info.header = "error reading binary";
info.out_file = stdout;
- info.print_header = WASM_PRINT_ERROR_HEADER_ONCE;
- wasm_default_binary_error_callback(ctx->offset, message, &info);
+ info.print_header = WABT_PRINT_ERROR_HEADER_ONCE;
+ wabt_default_binary_error_callback(ctx->offset, message, &info);
}
-static WasmResult begin_data_segment(uint32_t index,
+static WabtResult begin_data_segment(uint32_t index,
uint32_t memory_index,
void* user_data) {
Context* ctx = user_data;
print_details(ctx, " - memory[%d]", memory_index);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_data_segment_data(uint32_t index,
+static WabtResult on_data_segment_data(uint32_t index,
const void* src_data,
uint32_t size,
void* user_data) {
Context* ctx = user_data;
if (should_print_details(ctx)) {
- wasm_write_memory_dump(ctx->out_stream, src_data, size, 0, WASM_PRINT_CHARS,
+ wabt_write_memory_dump(ctx->out_stream, src_data, size, 0, WABT_PRINT_CHARS,
" - ", NULL);
}
- return WASM_OK;
+ return WABT_OK;
}
-static WasmBinaryReader s_binary_reader = {
+static WabtBinaryReader s_binary_reader = {
.user_data = NULL,
.begin_module = begin_module,
@@ -726,24 +726,24 @@ static WasmBinaryReader s_binary_reader = {
.on_init_expr_get_global_expr = on_init_expr_get_global_expr,
};
-WasmResult wasm_read_binary_objdump(struct WasmAllocator* allocator,
+WabtResult wabt_read_binary_objdump(struct WabtAllocator* allocator,
const uint8_t* data,
size_t size,
- WasmObjdumpOptions* options) {
+ WabtObjdumpOptions* options) {
Context context;
- WASM_ZERO_MEMORY(context);
+ WABT_ZERO_MEMORY(context);
context.allocator = allocator;
- context.header_printed = WASM_FALSE;
- context.print_details = WASM_FALSE;
- context.section_found = WASM_FALSE;
+ context.header_printed = WABT_FALSE;
+ context.print_details = WABT_FALSE;
+ context.section_found = WABT_FALSE;
context.data = data;
context.size = size;
context.options = options;
- context.out_stream = wasm_init_stdout_stream();
+ context.out_stream = wabt_init_stdout_stream();
- WasmBinaryReader reader;
- WASM_ZERO_MEMORY(reader);
- if (options->mode == WASM_DUMP_PREPASS) {
+ WabtBinaryReader reader;
+ WABT_ZERO_MEMORY(reader);
+ if (options->mode == WABT_DUMP_PREPASS) {
reader.on_function_name = on_function_name;
reader.on_reloc_count = on_reloc_count;
reader.on_reloc = on_reloc;
@@ -751,7 +751,7 @@ WasmResult wasm_read_binary_objdump(struct WasmAllocator* allocator,
reader = s_binary_reader;
}
- if (options->mode == WASM_DUMP_DISASSEMBLE) {
+ if (options->mode == WABT_DUMP_DISASSEMBLE) {
reader.on_opcode = on_opcode;
reader.on_opcode_bare = on_opcode_bare;
reader.on_opcode_uint32 = on_opcode_uint32;
@@ -766,7 +766,7 @@ WasmResult wasm_read_binary_objdump(struct WasmAllocator* allocator,
reader.user_data = &context;
- WasmReadBinaryOptions read_options = WASM_READ_BINARY_OPTIONS_DEFAULT;
- read_options.read_debug_names = WASM_TRUE;
- return wasm_read_binary(allocator, data, size, &reader, 1, &read_options);
+ WabtReadBinaryOptions read_options = WABT_READ_BINARY_OPTIONS_DEFAULT;
+ read_options.read_debug_names = WABT_TRUE;
+ return wabt_read_binary(allocator, data, size, &reader, 1, &read_options);
}
diff --git a/src/binary-reader-objdump.h b/src/binary-reader-objdump.h
index d39b42d7..3e029fcd 100644
--- a/src/binary-reader-objdump.h
+++ b/src/binary-reader-objdump.h
@@ -14,55 +14,55 @@
* limitations under the License.
*/
-#ifndef WASM_BINARY_READER_OBJDUMP_H_
-#define WASM_BINARY_READER_OBJDUMP_H_
+#ifndef WABT_BINARY_READER_OBJDUMP_H_
+#define WABT_BINARY_READER_OBJDUMP_H_
#include "common.h"
#include "stream.h"
#include "vector.h"
-struct WasmAllocator;
-struct WasmModule;
-struct WasmReadBinaryOptions;
+struct WabtAllocator;
+struct WabtModule;
+struct WabtReadBinaryOptions;
-typedef struct WasmReloc {
- WasmRelocType type;
+typedef struct WabtReloc {
+ WabtRelocType type;
size_t offset;
-} WasmReloc;
-WASM_DEFINE_VECTOR(reloc, WasmReloc);
+} WabtReloc;
+WABT_DEFINE_VECTOR(reloc, WabtReloc);
-WASM_DEFINE_VECTOR(string_slice, WasmStringSlice);
+WABT_DEFINE_VECTOR(string_slice, WabtStringSlice);
-typedef enum WasmObjdumpMode {
- WASM_DUMP_PREPASS,
- WASM_DUMP_HEADERS,
- WASM_DUMP_DETAILS,
- WASM_DUMP_DISASSEMBLE,
- WASM_DUMP_RAW_DATA,
-} WasmObjdumpMode;
+typedef enum WabtObjdumpMode {
+ WABT_DUMP_PREPASS,
+ WABT_DUMP_HEADERS,
+ WABT_DUMP_DETAILS,
+ WABT_DUMP_DISASSEMBLE,
+ WABT_DUMP_RAW_DATA,
+} WabtObjdumpMode;
-typedef struct WasmObjdumpOptions {
- WasmBool headers;
- WasmBool details;
- WasmBool raw;
- WasmBool disassemble;
- WasmBool debug;
- WasmBool relocs;
- WasmObjdumpMode mode;
+typedef struct WabtObjdumpOptions {
+ WabtBool headers;
+ WabtBool details;
+ WabtBool raw;
+ WabtBool disassemble;
+ WabtBool debug;
+ WabtBool relocs;
+ WabtObjdumpMode mode;
const char* infile;
const char* section_name;
- WasmBool print_header;
- WasmStringSliceVector function_names;
- WasmRelocVector code_relocations;
-} WasmObjdumpOptions;
+ WabtBool print_header;
+ WabtStringSliceVector function_names;
+ WabtRelocVector code_relocations;
+} WabtObjdumpOptions;
-WASM_EXTERN_C_BEGIN
+WABT_EXTERN_C_BEGIN
-WasmResult wasm_read_binary_objdump(struct WasmAllocator* allocator,
+WabtResult wabt_read_binary_objdump(struct WabtAllocator* allocator,
const uint8_t* data,
size_t size,
- WasmObjdumpOptions* options);
+ WabtObjdumpOptions* options);
-WASM_EXTERN_C_END
+WABT_EXTERN_C_END
-#endif /* WASM_BINARY_READER_OBJDUMP_H_ */
+#endif /* WABT_BINARY_READER_OBJDUMP_H_ */
diff --git a/src/binary-reader-opcnt.c b/src/binary-reader-opcnt.c
index 8d184e70..0a3a3035 100644
--- a/src/binary-reader-opcnt.c
+++ b/src/binary-reader-opcnt.c
@@ -27,117 +27,117 @@
#include "common.h"
typedef struct Context {
- WasmAllocator* allocator;
- WasmOpcntData* opcnt_data;
+ WabtAllocator* allocator;
+ WabtOpcntData* opcnt_data;
} Context;
-static WasmResult add_int_counter_value(struct WasmAllocator* allocator,
- WasmIntCounterVector* vec,
+static WabtResult add_int_counter_value(struct WabtAllocator* allocator,
+ WabtIntCounterVector* vec,
intmax_t value) {
size_t i;
for (i = 0; i < vec->size; ++i) {
if (vec->data[i].value == value) {
++vec->data[i].count;
- return WASM_OK;
+ return WABT_OK;
}
}
- WasmIntCounter counter;
+ WabtIntCounter counter;
counter.value = value;
counter.count = 1;
- wasm_append_int_counter_value(allocator, vec, &counter);
- return WASM_OK;
+ wabt_append_int_counter_value(allocator, vec, &counter);
+ return WABT_OK;
}
-static WasmResult add_int_pair_counter_value(struct WasmAllocator* allocator,
- WasmIntPairCounterVector* vec,
+static WabtResult add_int_pair_counter_value(struct WabtAllocator* allocator,
+ WabtIntPairCounterVector* vec,
intmax_t first, intmax_t second) {
size_t i;
for (i = 0; i < vec->size; ++i) {
if (vec->data[i].first == first && vec->data[i].second == second) {
++vec->data[i].count;
- return WASM_OK;
+ return WABT_OK;
}
}
- WasmIntPairCounter counter;
+ WabtIntPairCounter counter;
counter.first = first;
counter.second = second;
counter.count = 1;
- wasm_append_int_pair_counter_value(allocator, vec, &counter);
- return WASM_OK;
+ wabt_append_int_pair_counter_value(allocator, vec, &counter);
+ return WABT_OK;
}
-static WasmResult on_opcode(WasmBinaryReaderContext* context,
- WasmOpcode opcode) {
+static WabtResult on_opcode(WabtBinaryReaderContext* context,
+ WabtOpcode opcode) {
Context* ctx = context->user_data;
- WasmIntCounterVector* opcnt_vec = &ctx->opcnt_data->opcode_vec;
+ WabtIntCounterVector* opcnt_vec = &ctx->opcnt_data->opcode_vec;
while (opcode >= opcnt_vec->size) {
- WasmIntCounter Counter;
+ WabtIntCounter Counter;
Counter.value = opcnt_vec->size;
Counter.count = 0;
- wasm_append_int_counter_value(ctx->opcnt_data->allocator,
+ wabt_append_int_counter_value(ctx->opcnt_data->allocator,
opcnt_vec, &Counter);
}
++opcnt_vec->data[opcode].count;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_i32_const_expr(uint32_t value, void* user_data) {
+static WabtResult on_i32_const_expr(uint32_t value, void* user_data) {
Context* ctx = user_data;
return add_int_counter_value(ctx->opcnt_data->allocator,
&ctx->opcnt_data->i32_const_vec, (int32_t)value);
}
-static WasmResult on_get_local_expr(uint32_t local_index, void* user_data) {
+static WabtResult on_get_local_expr(uint32_t local_index, void* user_data) {
Context* ctx = user_data;
return add_int_counter_value(ctx->opcnt_data->allocator,
&ctx->opcnt_data->get_local_vec, local_index);
}
-static WasmResult on_set_local_expr(uint32_t local_index, void* user_data) {
+static WabtResult on_set_local_expr(uint32_t local_index, void* user_data) {
Context* ctx = user_data;
return add_int_counter_value(ctx->opcnt_data->allocator,
&ctx->opcnt_data->set_local_vec, local_index);
}
-static WasmResult on_tee_local_expr(uint32_t local_index, void* user_data) {
+static WabtResult on_tee_local_expr(uint32_t local_index, void* user_data) {
Context* ctx = user_data;
return add_int_counter_value(ctx->opcnt_data->allocator,
&ctx->opcnt_data->tee_local_vec, local_index);
}
-static WasmResult on_load_expr(WasmOpcode opcode,
+static WabtResult on_load_expr(WabtOpcode opcode,
uint32_t alignment_log2,
uint32_t offset,
void* user_data) {
Context* ctx = user_data;
- if (opcode == WASM_OPCODE_I32_LOAD)
+ if (opcode == WABT_OPCODE_I32_LOAD)
return add_int_pair_counter_value(ctx->opcnt_data->allocator,
&ctx->opcnt_data->i32_load_vec,
alignment_log2, offset);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_store_expr(WasmOpcode opcode,
+static WabtResult on_store_expr(WabtOpcode opcode,
uint32_t alignment_log2,
uint32_t offset,
void* user_data) {
Context* ctx = user_data;
- if (opcode == WASM_OPCODE_I32_STORE)
+ if (opcode == WABT_OPCODE_I32_STORE)
return add_int_pair_counter_value(ctx->opcnt_data->allocator,
&ctx->opcnt_data->i32_store_vec,
alignment_log2, offset);
- return WASM_OK;
+ return WABT_OK;
}
-static void on_error(WasmBinaryReaderContext* ctx, const char* message) {
- WasmDefaultErrorHandlerInfo info;
+static void on_error(WabtBinaryReaderContext* ctx, const char* message) {
+ WabtDefaultErrorHandlerInfo info;
info.header = "error reading binary";
info.out_file = stdout;
- info.print_header = WASM_PRINT_ERROR_HEADER_ONCE;
- wasm_default_binary_error_callback(ctx->offset, message, &info);
+ info.print_header = WABT_PRINT_ERROR_HEADER_ONCE;
+ wabt_default_binary_error_callback(ctx->offset, message, &info);
}
-static WasmBinaryReader s_binary_reader = {
+static WabtBinaryReader s_binary_reader = {
.user_data = NULL,
.on_error = on_error,
.on_opcode = on_opcode,
@@ -149,36 +149,36 @@ static WasmBinaryReader s_binary_reader = {
.on_store_expr = on_store_expr
};
-void wasm_init_opcnt_data(struct WasmAllocator* allocator,
- WasmOpcntData* data) {
- WASM_ZERO_MEMORY(*data);
+void wabt_init_opcnt_data(struct WabtAllocator* allocator,
+ WabtOpcntData* data) {
+ WABT_ZERO_MEMORY(*data);
data->allocator = allocator;
}
-void wasm_destroy_opcnt_data(struct WasmAllocator* allocator,
- WasmOpcntData* data) {
+void wabt_destroy_opcnt_data(struct WabtAllocator* allocator,
+ WabtOpcntData* data) {
assert(allocator == data->allocator);
- wasm_destroy_int_counter_vector(allocator, &data->opcode_vec);
- wasm_destroy_int_counter_vector(allocator, &data->i32_const_vec);
- wasm_destroy_int_counter_vector(allocator, &data->get_local_vec);
- wasm_destroy_int_pair_counter_vector(allocator, &data->i32_load_vec);
+ wabt_destroy_int_counter_vector(allocator, &data->opcode_vec);
+ wabt_destroy_int_counter_vector(allocator, &data->i32_const_vec);
+ wabt_destroy_int_counter_vector(allocator, &data->get_local_vec);
+ wabt_destroy_int_pair_counter_vector(allocator, &data->i32_load_vec);
}
-WasmResult wasm_read_binary_opcnt(struct WasmAllocator* allocator,
+WabtResult wabt_read_binary_opcnt(struct WabtAllocator* allocator,
const void* data,
size_t size,
- const struct WasmReadBinaryOptions* options,
- WasmOpcntData* opcnt_data) {
+ const struct WabtReadBinaryOptions* options,
+ WabtOpcntData* opcnt_data) {
Context ctx;
- WASM_ZERO_MEMORY(ctx);
+ WABT_ZERO_MEMORY(ctx);
ctx.allocator = allocator;
ctx.opcnt_data = opcnt_data;
- WasmBinaryReader reader;
- WASM_ZERO_MEMORY(reader);
+ WabtBinaryReader reader;
+ WABT_ZERO_MEMORY(reader);
reader = s_binary_reader;
reader.user_data = &ctx;
- return wasm_read_binary(allocator, data, size, &reader, 1, options);
+ return wabt_read_binary(allocator, data, size, &reader, 1, options);
}
diff --git a/src/binary-reader-opcnt.h b/src/binary-reader-opcnt.h
index 905fcbf5..a1314665 100644
--- a/src/binary-reader-opcnt.h
+++ b/src/binary-reader-opcnt.h
@@ -14,54 +14,54 @@
* limitations under the License.
*/
-#ifndef WASM_BINARY_READER_OPCNT_H_
-#define WASM_BINARY_READER_OPCNT_H_
+#ifndef WABT_BINARY_READER_OPCNT_H_
+#define WABT_BINARY_READER_OPCNT_H_
#include "common.h"
#include "vector.h"
-struct WasmAllocator;
-struct WasmModule;
-struct WasmReadBinaryOptions;
+struct WabtAllocator;
+struct WabtModule;
+struct WabtReadBinaryOptions;
-WASM_EXTERN_C_BEGIN
+WABT_EXTERN_C_BEGIN
-typedef struct WasmIntCounter {
+typedef struct WabtIntCounter {
intmax_t value;
size_t count;
-} WasmIntCounter;
+} WabtIntCounter;
-WASM_DEFINE_VECTOR(int_counter, WasmIntCounter)
+WABT_DEFINE_VECTOR(int_counter, WabtIntCounter)
-typedef struct WasmIntPairCounter {
+typedef struct WabtIntPairCounter {
intmax_t first;
intmax_t second;
size_t count;
-} WasmIntPairCounter;
+} WabtIntPairCounter;
-WASM_DEFINE_VECTOR(int_pair_counter, WasmIntPairCounter);
+WABT_DEFINE_VECTOR(int_pair_counter, WabtIntPairCounter);
-typedef struct WasmOpcntData {
- struct WasmAllocator* allocator;
- WasmIntCounterVector opcode_vec;
- WasmIntCounterVector i32_const_vec;
- WasmIntCounterVector get_local_vec;
- WasmIntCounterVector set_local_vec;
- WasmIntCounterVector tee_local_vec;
- WasmIntPairCounterVector i32_load_vec;
- WasmIntPairCounterVector i32_store_vec;
-} WasmOpcntData;
+typedef struct WabtOpcntData {
+ struct WabtAllocator* allocator;
+ WabtIntCounterVector opcode_vec;
+ WabtIntCounterVector i32_const_vec;
+ WabtIntCounterVector get_local_vec;
+ WabtIntCounterVector set_local_vec;
+ WabtIntCounterVector tee_local_vec;
+ WabtIntPairCounterVector i32_load_vec;
+ WabtIntPairCounterVector i32_store_vec;
+} WabtOpcntData;
-void wasm_init_opcnt_data(struct WasmAllocator* allocator, WasmOpcntData* data);
-void wasm_destroy_opcnt_data(struct WasmAllocator* allocator,
- WasmOpcntData* data);
+void wabt_init_opcnt_data(struct WabtAllocator* allocator, WabtOpcntData* data);
+void wabt_destroy_opcnt_data(struct WabtAllocator* allocator,
+ WabtOpcntData* data);
-WasmResult wasm_read_binary_opcnt(struct WasmAllocator* allocator,
+WabtResult wabt_read_binary_opcnt(struct WabtAllocator* allocator,
const void* data,
size_t size,
- const struct WasmReadBinaryOptions* options,
- WasmOpcntData* opcnt_data);
+ const struct WabtReadBinaryOptions* options,
+ WabtOpcntData* opcnt_data);
-WASM_EXTERN_C_END
+WABT_EXTERN_C_END
-#endif /* WASM_BINARY_READER_OPCNT_H_ */
+#endif /* WABT_BINARY_READER_OPCNT_H_ */
diff --git a/src/binary-reader.c b/src/binary-reader.c
index 896bb366..85cb48b9 100644
--- a/src/binary-reader.c
+++ b/src/binary-reader.c
@@ -40,22 +40,22 @@
#define INITIAL_BR_TABLE_TARGET_CAPACITY 1000
typedef uint32_t Uint32;
-WASM_DEFINE_VECTOR(type, WasmType)
-WASM_DEFINE_VECTOR(uint32, Uint32);
+WABT_DEFINE_VECTOR(type, WabtType)
+WABT_DEFINE_VECTOR(uint32, Uint32);
#define CALLBACK_CTX(member, ...) \
RAISE_ERROR_UNLESS( \
- WASM_SUCCEEDED( \
+ WABT_SUCCEEDED( \
ctx->reader->member \
? ctx->reader->member(get_user_context(ctx), __VA_ARGS__) \
- : WASM_OK), \
+ : WABT_OK), \
#member " callback failed")
#define CALLBACK_CTX0(member) \
RAISE_ERROR_UNLESS( \
- WASM_SUCCEEDED(ctx->reader->member \
+ WABT_SUCCEEDED(ctx->reader->member \
? ctx->reader->member(get_user_context(ctx)) \
- : WASM_OK), \
+ : WABT_OK), \
#member " callback failed")
#define CALLBACK_SECTION(member, section_size) \
@@ -63,41 +63,41 @@ WASM_DEFINE_VECTOR(uint32, Uint32);
#define CALLBACK0(member) \
RAISE_ERROR_UNLESS( \
- WASM_SUCCEEDED(ctx->reader->member \
+ WABT_SUCCEEDED(ctx->reader->member \
? ctx->reader->member(ctx->reader->user_data) \
- : WASM_OK), \
+ : WABT_OK), \
#member " callback failed")
#define CALLBACK(member, ...) \
RAISE_ERROR_UNLESS( \
- WASM_SUCCEEDED( \
+ WABT_SUCCEEDED( \
ctx->reader->member \
? ctx->reader->member(__VA_ARGS__, ctx->reader->user_data) \
- : WASM_OK), \
+ : WABT_OK), \
#member " callback failed")
#define FORWARD0(member) \
return ctx->reader->member ? ctx->reader->member(ctx->reader->user_data) \
- : WASM_OK
+ : WABT_OK
#define FORWARD_CTX0(member) \
if (!ctx->reader->member) \
- return WASM_OK; \
- WasmBinaryReaderContext new_ctx = *context; \
+ return WABT_OK; \
+ WabtBinaryReaderContext new_ctx = *context; \
new_ctx.user_data = ctx->reader->user_data; \
return ctx->reader->member(&new_ctx);
#define FORWARD_CTX(member, ...) \
if (!ctx->reader->member) \
- return WASM_OK; \
- WasmBinaryReaderContext new_ctx = *context; \
+ return WABT_OK; \
+ WabtBinaryReaderContext new_ctx = *context; \
new_ctx.user_data = ctx->reader->user_data; \
return ctx->reader->member(&new_ctx, __VA_ARGS__);
#define FORWARD(member, ...) \
return ctx->reader->member \
? ctx->reader->member(__VA_ARGS__, ctx->reader->user_data) \
- : WASM_OK
+ : WABT_OK
#define RAISE_ERROR(...) \
(ctx->reader->on_error ? raise_error(ctx, __VA_ARGS__) : (void)0)
@@ -107,18 +107,18 @@ WASM_DEFINE_VECTOR(uint32, Uint32);
RAISE_ERROR(__VA_ARGS__);
typedef struct Context {
- WasmAllocator* allocator;
+ WabtAllocator* allocator;
const uint8_t* data;
size_t data_size;
size_t offset;
size_t read_end; /* Either the section end or data_size. */
- WasmBinaryReaderContext user_ctx;
- WasmBinaryReader* reader;
+ WabtBinaryReaderContext user_ctx;
+ WabtBinaryReader* reader;
jmp_buf error_jmp_buf;
- WasmTypeVector param_types;
+ WabtTypeVector param_types;
Uint32Vector target_depths;
- const WasmReadBinaryOptions* options;
- WasmBinarySection last_known_section_code;
+ const WabtReadBinaryOptions* options;
+ WabtBinarySection last_known_section_code;
uint32_t num_signatures;
uint32_t num_imports;
uint32_t num_func_imports;
@@ -134,12 +134,12 @@ typedef struct Context {
} Context;
typedef struct LoggingContext {
- WasmStream* stream;
- WasmBinaryReader* reader;
+ WabtStream* stream;
+ WabtBinaryReader* reader;
int indent;
} LoggingContext;
-static WasmBinaryReaderContext* get_user_context(Context* ctx) {
+static WabtBinaryReaderContext* get_user_context(Context* ctx) {
ctx->user_ctx.user_data = ctx->reader->user_data;
ctx->user_ctx.data = ctx->data;
ctx->user_ctx.size = ctx->data_size;
@@ -147,9 +147,9 @@ static WasmBinaryReaderContext* get_user_context(Context* ctx) {
return &ctx->user_ctx;
}
-static void WASM_PRINTF_FORMAT(2, 3)
+static void WABT_PRINTF_FORMAT(2, 3)
raise_error(Context* ctx, const char* format, ...) {
- WASM_SNPRINTF_ALLOCA(buffer, length, format);
+ WABT_SNPRINTF_ALLOCA(buffer, length, format);
assert(ctx->reader->on_error);
ctx->reader->on_error(get_user_context(ctx), buffer);
longjmp(ctx->error_jmp_buf, 1);
@@ -198,7 +198,7 @@ static void in_f64(Context* ctx, uint64_t* out_value, const char* desc) {
((type)((value) << SHIFT_AMOUNT(type, sign_bit)) >> \
SHIFT_AMOUNT(type, sign_bit))
-size_t wasm_read_u32_leb128(const uint8_t* p,
+size_t wabt_read_u32_leb128(const uint8_t* p,
const uint8_t* end,
uint32_t* out_value) {
if (p < end && (p[0] & 0x80) == 0) {
@@ -229,13 +229,13 @@ size_t wasm_read_u32_leb128(const uint8_t* p,
static void in_u32_leb128(Context* ctx, uint32_t* out_value, const char* desc) {
const uint8_t* p = ctx->data + ctx->offset;
const uint8_t* end = ctx->data + ctx->read_end;
- size_t bytes_read = wasm_read_u32_leb128(p, end, out_value);
+ size_t bytes_read = wabt_read_u32_leb128(p, end, out_value);
if (!bytes_read)
RAISE_ERROR("unable to read u32 leb128: %s", desc);
ctx->offset += bytes_read;
}
-size_t wasm_read_i32_leb128(const uint8_t* p,
+size_t wabt_read_i32_leb128(const uint8_t* p,
const uint8_t* end,
uint32_t* out_value) {
if (p < end && (p[0] & 0x80) == 0) {
@@ -256,7 +256,7 @@ size_t wasm_read_i32_leb128(const uint8_t* p,
return 4;
} else if (p + 4 < end && (p[4] & 0x80) == 0) {
/* the top bits should be a sign-extension of the sign bit */
- WasmBool sign_bit_set = (p[4] & 0x8);
+ WabtBool sign_bit_set = (p[4] & 0x8);
int top_bits = p[4] & 0xf0;
if ((sign_bit_set && top_bits != 0x70) ||
(!sign_bit_set && top_bits != 0)) {
@@ -274,7 +274,7 @@ size_t wasm_read_i32_leb128(const uint8_t* p,
static void in_i32_leb128(Context* ctx, uint32_t* out_value, const char* desc) {
const uint8_t* p = ctx->data + ctx->offset;
const uint8_t* end = ctx->data + ctx->read_end;
- size_t bytes_read = wasm_read_i32_leb128(p, end, out_value);
+ size_t bytes_read = wabt_read_i32_leb128(p, end, out_value);
if (!bytes_read)
RAISE_ERROR("unable to read i32 leb128: %s", desc);
ctx->offset += bytes_read;
@@ -322,7 +322,7 @@ static void in_i64_leb128(Context* ctx, uint64_t* out_value, const char* desc) {
ctx->offset += 9;
} else if (p + 9 < end && (p[9] & 0x80) == 0) {
/* the top bits should be a sign-extension of the sign bit */
- WasmBool sign_bit_set = (p[9] & 0x1);
+ WabtBool sign_bit_set = (p[9] & 0x1);
int top_bits = p[9] & 0xfe;
if ((sign_bit_set && top_bits != 0x7e) ||
(!sign_bit_set && top_bits != 0)) {
@@ -351,7 +351,7 @@ static void in_i64_leb128(Context* ctx, uint64_t* out_value, const char* desc) {
#undef SHIFT_AMOUNT
#undef SIGN_EXTEND
-static void in_type(Context* ctx, WasmType* out_value, const char* desc) {
+static void in_type(Context* ctx, WabtType* out_value, const char* desc) {
uint32_t type = 0;
in_i32_leb128(ctx, &type, desc);
/* Must be in the vs7 range: [-128, 127). */
@@ -360,7 +360,7 @@ static void in_type(Context* ctx, WasmType* out_value, const char* desc) {
*out_value = type;
}
-static void in_str(Context* ctx, WasmStringSlice* out_str, const char* desc) {
+static void in_str(Context* ctx, WabtStringSlice* out_str, const char* desc) {
uint32_t str_len = 0;
in_u32_leb128(ctx, &str_len, "string length");
@@ -387,25 +387,25 @@ static void in_bytes(Context* ctx,
ctx->offset += data_size;
}
-static WasmBool is_valid_external_kind(uint8_t kind) {
- return kind < WASM_NUM_EXTERNAL_KINDS;
+static WabtBool is_valid_external_kind(uint8_t kind) {
+ return kind < WABT_NUM_EXTERNAL_KINDS;
}
-static WasmBool is_concrete_type(WasmType type) {
+static WabtBool is_concrete_type(WabtType type) {
switch (type) {
- case WASM_TYPE_I32:
- case WASM_TYPE_I64:
- case WASM_TYPE_F32:
- case WASM_TYPE_F64:
- return WASM_TRUE;
+ case WABT_TYPE_I32:
+ case WABT_TYPE_I64:
+ case WABT_TYPE_F32:
+ case WABT_TYPE_F64:
+ return WABT_TRUE;
default:
- return WASM_FALSE;
+ return WABT_FALSE;
}
}
-static WasmBool is_inline_sig_type(WasmType type) {
- return is_concrete_type(type) || type == WASM_TYPE_VOID;
+static WabtBool is_inline_sig_type(WabtType type) {
+ return is_concrete_type(type) || type == WABT_TYPE_VOID;
}
static uint32_t num_total_funcs(Context* ctx) {
@@ -425,8 +425,8 @@ static uint32_t num_total_globals(Context* ctx) {
}
static void destroy_context(Context* ctx) {
- wasm_destroy_type_vector(ctx->allocator, &ctx->param_types);
- wasm_destroy_uint32_vector(ctx->allocator, &ctx->target_depths);
+ wabt_destroy_type_vector(ctx->allocator, &ctx->param_types);
+ wabt_destroy_uint32_vector(ctx->allocator, &ctx->target_depths);
}
/* Logging */
@@ -447,15 +447,15 @@ static void write_indent(LoggingContext* ctx) {
static size_t s_indent_len = sizeof(s_indent) - 1;
size_t indent = ctx->indent;
while (indent > s_indent_len) {
- wasm_write_data(ctx->stream, s_indent, s_indent_len, NULL);
+ wabt_write_data(ctx->stream, s_indent, s_indent_len, NULL);
indent -= s_indent_len;
}
if (indent > 0) {
- wasm_write_data(ctx->stream, s_indent, indent, NULL);
+ wabt_write_data(ctx->stream, s_indent, indent, NULL);
}
}
-#define LOGF_NOINDENT(...) wasm_writef(ctx->stream, __VA_ARGS__)
+#define LOGF_NOINDENT(...) wabt_writef(ctx->stream, __VA_ARGS__)
#define LOGF(...) \
do { \
@@ -463,28 +463,28 @@ static void write_indent(LoggingContext* ctx) {
LOGF_NOINDENT(__VA_ARGS__); \
} while (0)
-static void logging_on_error(WasmBinaryReaderContext* ctx,
+static void logging_on_error(WabtBinaryReaderContext* ctx,
const char* message) {
LoggingContext* logging_ctx = ctx->user_data;
if (logging_ctx->reader->on_error) {
- WasmBinaryReaderContext new_ctx = *ctx;
+ WabtBinaryReaderContext new_ctx = *ctx;
new_ctx.user_data = logging_ctx->reader->user_data;
logging_ctx->reader->on_error(&new_ctx, message);
}
}
-static WasmResult logging_begin_custom_section(WasmBinaryReaderContext* context,
+static WabtResult logging_begin_custom_section(WabtBinaryReaderContext* context,
uint32_t size,
- WasmStringSlice section_name) {
+ WabtStringSlice section_name) {
LoggingContext* ctx = context->user_data;
LOGF("begin_custom_section: '" PRIstringslice "' size=%d\n",
- WASM_PRINTF_STRING_SLICE_ARG(section_name), size);
+ WABT_PRINTF_STRING_SLICE_ARG(section_name), size);
indent(ctx);
FORWARD_CTX(begin_custom_section, size, section_name);
}
#define LOGGING_BEGIN(name) \
- static WasmResult logging_begin_##name(WasmBinaryReaderContext* context, \
+ static WabtResult logging_begin_##name(WabtBinaryReaderContext* context, \
uint32_t size) { \
LoggingContext* ctx = context->user_data; \
LOGF("begin_" #name "\n"); \
@@ -493,7 +493,7 @@ static WasmResult logging_begin_custom_section(WasmBinaryReaderContext* context,
}
#define LOGGING_END(name) \
- static WasmResult logging_end_##name(WasmBinaryReaderContext* context) { \
+ static WabtResult logging_end_##name(WabtBinaryReaderContext* context) { \
LoggingContext* ctx = context->user_data; \
dedent(ctx); \
LOGF("end_" #name "\n"); \
@@ -501,14 +501,14 @@ static WasmResult logging_begin_custom_section(WasmBinaryReaderContext* context,
}
#define LOGGING_UINT32(name) \
- static WasmResult logging_##name(uint32_t value, void* user_data) { \
+ static WabtResult logging_##name(uint32_t value, void* user_data) { \
LoggingContext* ctx = user_data; \
LOGF(#name "(%u)\n", value); \
FORWARD(name, value); \
}
#define LOGGING_UINT32_CTX(name) \
- static WasmResult logging_##name(WasmBinaryReaderContext* context, \
+ static WabtResult logging_##name(WabtBinaryReaderContext* context, \
uint32_t value) { \
LoggingContext* ctx = context->user_data; \
LOGF(#name "(%u)\n", value); \
@@ -516,14 +516,14 @@ static WasmResult logging_begin_custom_section(WasmBinaryReaderContext* context,
}
#define LOGGING_UINT32_DESC(name, desc) \
- static WasmResult logging_##name(uint32_t value, void* user_data) { \
+ static WabtResult logging_##name(uint32_t value, void* user_data) { \
LoggingContext* ctx = user_data; \
LOGF(#name "(" desc ": %u)\n", value); \
FORWARD(name, value); \
}
#define LOGGING_UINT32_UINT32(name, desc0, desc1) \
- static WasmResult logging_##name(uint32_t value0, uint32_t value1, \
+ static WabtResult logging_##name(uint32_t value0, uint32_t value1, \
void* user_data) { \
LoggingContext* ctx = user_data; \
LOGF(#name "(" desc0 ": %u, " desc1 ": %u)\n", value0, value1); \
@@ -531,7 +531,7 @@ static WasmResult logging_begin_custom_section(WasmBinaryReaderContext* context,
}
#define LOGGING_UINT32_UINT32_CTX(name, desc0, desc1) \
- static WasmResult logging_##name(WasmBinaryReaderContext* context, \
+ static WabtResult logging_##name(WabtBinaryReaderContext* context, \
uint32_t value0, uint32_t value1) { \
LoggingContext* ctx = context->user_data; \
LOGF(#name "(" desc0 ": %u, " desc1 ": %u)\n", value0, value1); \
@@ -539,14 +539,14 @@ static WasmResult logging_begin_custom_section(WasmBinaryReaderContext* context,
}
#define LOGGING_OPCODE(name) \
- static WasmResult logging_##name(WasmOpcode opcode, void* user_data) { \
+ static WabtResult logging_##name(WabtOpcode opcode, void* user_data) { \
LoggingContext* ctx = user_data; \
- LOGF(#name "(\"%s\" (%u))\n", wasm_get_opcode_name(opcode), opcode); \
+ LOGF(#name "(\"%s\" (%u))\n", wabt_get_opcode_name(opcode), opcode); \
FORWARD(name, opcode); \
}
#define LOGGING0(name) \
- static WasmResult logging_##name(void* user_data) { \
+ static WabtResult logging_##name(void* user_data) { \
LoggingContext* ctx = user_data; \
LOGF(#name "\n"); \
FORWARD0(name); \
@@ -636,36 +636,36 @@ LOGGING_BEGIN(reloc_section)
LOGGING_END(reloc_section)
LOGGING_UINT32_UINT32(on_init_expr_get_global_expr, "index", "global_index")
-static void sprint_limits(char* dst, size_t size, const WasmLimits* limits) {
+static void sprint_limits(char* dst, size_t size, const WabtLimits* limits) {
int result;
if (limits->has_max) {
- result = wasm_snprintf(dst, size, "initial: %" PRIu64 ", max: %" PRIu64,
+ result = wabt_snprintf(dst, size, "initial: %" PRIu64 ", max: %" PRIu64,
limits->initial, limits->max);
} else {
- result = wasm_snprintf(dst, size, "initial: %" PRIu64, limits->initial);
+ result = wabt_snprintf(dst, size, "initial: %" PRIu64, limits->initial);
}
- WASM_USE(result);
+ WABT_USE(result);
assert((size_t)result < size);
}
static void log_types(LoggingContext* ctx,
uint32_t type_count,
- WasmType* types) {
+ WabtType* types) {
uint32_t i;
LOGF_NOINDENT("[");
for (i = 0; i < type_count; ++i) {
- LOGF_NOINDENT("%s", wasm_get_type_name(types[i]));
+ LOGF_NOINDENT("%s", wabt_get_type_name(types[i]));
if (i != type_count - 1)
LOGF_NOINDENT(", ");
}
LOGF_NOINDENT("]");
}
-static WasmResult logging_on_signature(uint32_t index,
+static WabtResult logging_on_signature(uint32_t index,
uint32_t param_count,
- WasmType* param_types,
+ WabtType* param_types,
uint32_t result_count,
- WasmType* result_types,
+ WabtType* result_types,
void* user_data) {
LoggingContext* ctx = user_data;
LOGF("on_signature(index: %u, params: ", index);
@@ -677,19 +677,19 @@ static WasmResult logging_on_signature(uint32_t index,
result_types);
}
-static WasmResult logging_on_import(uint32_t index,
- WasmStringSlice module_name,
- WasmStringSlice field_name,
+static WabtResult logging_on_import(uint32_t index,
+ WabtStringSlice module_name,
+ WabtStringSlice field_name,
void* user_data) {
LoggingContext* ctx = user_data;
LOGF("on_import(index: %u, module: \"" PRIstringslice
"\", field: \"" PRIstringslice "\")\n",
- index, WASM_PRINTF_STRING_SLICE_ARG(module_name),
- WASM_PRINTF_STRING_SLICE_ARG(field_name));
+ index, WABT_PRINTF_STRING_SLICE_ARG(module_name),
+ WABT_PRINTF_STRING_SLICE_ARG(field_name));
FORWARD(on_import, index, module_name, field_name);
}
-static WasmResult logging_on_import_func(uint32_t import_index,
+static WabtResult logging_on_import_func(uint32_t import_index,
uint32_t func_index,
uint32_t sig_index,
void* user_data) {
@@ -700,23 +700,23 @@ static WasmResult logging_on_import_func(uint32_t import_index,
}
-static WasmResult logging_on_import_table(uint32_t import_index,
+static WabtResult logging_on_import_table(uint32_t import_index,
uint32_t table_index,
- WasmType elem_type,
- const WasmLimits* elem_limits,
+ WabtType elem_type,
+ const WabtLimits* elem_limits,
void* user_data) {
LoggingContext* ctx = user_data;
char buf[100];
sprint_limits(buf, sizeof(buf), elem_limits);
LOGF(
"on_import_table(import_index: %u, table_index: %u, elem_type: %s, %s)\n",
- import_index, table_index, wasm_get_type_name(elem_type), buf);
+ import_index, table_index, wabt_get_type_name(elem_type), buf);
FORWARD(on_import_table, import_index, table_index, elem_type, elem_limits);
}
-static WasmResult logging_on_import_memory(uint32_t import_index,
+static WabtResult logging_on_import_memory(uint32_t import_index,
uint32_t memory_index,
- const WasmLimits* page_limits,
+ const WabtLimits* page_limits,
void* user_data) {
LoggingContext* ctx = user_data;
char buf[100];
@@ -726,34 +726,34 @@ static WasmResult logging_on_import_memory(uint32_t import_index,
FORWARD(on_import_memory, import_index, memory_index, page_limits);
}
-static WasmResult logging_on_import_global(uint32_t import_index,
+static WabtResult logging_on_import_global(uint32_t import_index,
uint32_t global_index,
- WasmType type,
- WasmBool mutable_,
+ WabtType type,
+ WabtBool mutable_,
void* user_data) {
LoggingContext* ctx = user_data;
LOGF(
"on_import_global(import_index: %u, global_index: %u, type: %s, mutable: "
"%s)\n",
- import_index, global_index, wasm_get_type_name(type),
+ import_index, global_index, wabt_get_type_name(type),
mutable_ ? "true" : "false");
FORWARD(on_import_global, import_index, global_index, type, mutable_);
}
-static WasmResult logging_on_table(uint32_t index,
- WasmType elem_type,
- const WasmLimits* elem_limits,
+static WabtResult logging_on_table(uint32_t index,
+ WabtType elem_type,
+ const WabtLimits* elem_limits,
void* user_data) {
LoggingContext* ctx = user_data;
char buf[100];
sprint_limits(buf, sizeof(buf), elem_limits);
LOGF("on_table(index: %u, elem_type: %s, %s)\n", index,
- wasm_get_type_name(elem_type), buf);
+ wabt_get_type_name(elem_type), buf);
FORWARD(on_table, index, elem_type, elem_limits);
}
-static WasmResult logging_on_memory(uint32_t index,
- const WasmLimits* page_limits,
+static WabtResult logging_on_memory(uint32_t index,
+ const WabtLimits* page_limits,
void* user_data) {
LoggingContext* ctx = user_data;
char buf[100];
@@ -762,30 +762,30 @@ static WasmResult logging_on_memory(uint32_t index,
FORWARD(on_memory, index, page_limits);
}
-static WasmResult logging_begin_global(uint32_t index,
- WasmType type,
- WasmBool mutable_,
+static WabtResult logging_begin_global(uint32_t index,
+ WabtType type,
+ WabtBool mutable_,
void* user_data) {
LoggingContext* ctx = user_data;
LOGF("begin_global(index: %u, type: %s, mutable: %s)\n", index,
- wasm_get_type_name(type), mutable_ ? "true" : "false");
+ wabt_get_type_name(type), mutable_ ? "true" : "false");
FORWARD(begin_global, index, type, mutable_);
}
-static WasmResult logging_on_export(uint32_t index,
- WasmExternalKind kind,
+static WabtResult logging_on_export(uint32_t index,
+ WabtExternalKind kind,
uint32_t item_index,
- WasmStringSlice name,
+ WabtStringSlice name,
void* user_data) {
LoggingContext* ctx = user_data;
LOGF("on_export(index: %u, kind: %s, item_index: %u, name: \"" PRIstringslice
"\")\n",
- index, wasm_get_kind_name(kind), item_index,
- WASM_PRINTF_STRING_SLICE_ARG(name));
+ index, wabt_get_kind_name(kind), item_index,
+ WABT_PRINTF_STRING_SLICE_ARG(name));
FORWARD(on_export, index, kind, item_index, name);
}
-static WasmResult logging_begin_function_body_pass(uint32_t index,
+static WabtResult logging_begin_function_body_pass(uint32_t index,
uint32_t pass,
void* user_data) {
LoggingContext* ctx = user_data;
@@ -794,18 +794,18 @@ static WasmResult logging_begin_function_body_pass(uint32_t index,
FORWARD(begin_function_body_pass, index, pass);
}
-static WasmResult logging_on_local_decl(uint32_t decl_index,
+static WabtResult logging_on_local_decl(uint32_t decl_index,
uint32_t count,
- WasmType type,
+ WabtType type,
void* user_data) {
LoggingContext* ctx = user_data;
LOGF("on_local_decl(index: %u, count: %u, type: %s)\n", decl_index, count,
- wasm_get_type_name(type));
+ wabt_get_type_name(type));
FORWARD(on_local_decl, decl_index, count, type);
}
-static WasmResult logging_on_block_expr(uint32_t num_types,
- WasmType* sig_types,
+static WabtResult logging_on_block_expr(uint32_t num_types,
+ WabtType* sig_types,
void* user_data) {
LoggingContext* ctx = user_data;
LOGF("on_block_expr(sig: ");
@@ -814,19 +814,19 @@ static WasmResult logging_on_block_expr(uint32_t num_types,
FORWARD(on_block_expr, num_types, sig_types);
}
-static WasmResult logging_on_br_expr(uint32_t depth, void* user_data) {
+static WabtResult logging_on_br_expr(uint32_t depth, void* user_data) {
LoggingContext* ctx = user_data;
LOGF("on_br_expr(depth: %u)\n", depth);
FORWARD(on_br_expr, depth);
}
-static WasmResult logging_on_br_if_expr(uint32_t depth, void* user_data) {
+static WabtResult logging_on_br_if_expr(uint32_t depth, void* user_data) {
LoggingContext* ctx = user_data;
LOGF("on_br_if_expr(depth: %u)\n", depth);
FORWARD(on_br_if_expr, depth);
}
-static WasmResult logging_on_br_table_expr(WasmBinaryReaderContext* context,
+static WabtResult logging_on_br_table_expr(WabtBinaryReaderContext* context,
uint32_t num_targets,
uint32_t* target_depths,
uint32_t default_target_depth) {
@@ -843,7 +843,7 @@ static WasmResult logging_on_br_table_expr(WasmBinaryReaderContext* context,
default_target_depth);
}
-static WasmResult logging_on_f32_const_expr(uint32_t value_bits,
+static WabtResult logging_on_f32_const_expr(uint32_t value_bits,
void* user_data) {
LoggingContext* ctx = user_data;
float value;
@@ -852,7 +852,7 @@ static WasmResult logging_on_f32_const_expr(uint32_t value_bits,
FORWARD(on_f32_const_expr, value_bits);
}
-static WasmResult logging_on_f64_const_expr(uint64_t value_bits,
+static WabtResult logging_on_f64_const_expr(uint64_t value_bits,
void* user_data) {
LoggingContext* ctx = user_data;
double value;
@@ -861,20 +861,20 @@ static WasmResult logging_on_f64_const_expr(uint64_t value_bits,
FORWARD(on_f64_const_expr, value_bits);
}
-static WasmResult logging_on_i32_const_expr(uint32_t value, void* user_data) {
+static WabtResult logging_on_i32_const_expr(uint32_t value, void* user_data) {
LoggingContext* ctx = user_data;
LOGF("on_i32_const_expr(%u (0x%x))\n", value, value);
FORWARD(on_i32_const_expr, value);
}
-static WasmResult logging_on_i64_const_expr(uint64_t value, void* user_data) {
+static WabtResult logging_on_i64_const_expr(uint64_t value, void* user_data) {
LoggingContext* ctx = user_data;
LOGF("on_i64_const_expr(%" PRIu64 " (0x%" PRIx64 "))\n", value, value);
FORWARD(on_i64_const_expr, value);
}
-static WasmResult logging_on_if_expr(uint32_t num_types,
- WasmType* sig_types,
+static WabtResult logging_on_if_expr(uint32_t num_types,
+ WabtType* sig_types,
void* user_data) {
LoggingContext* ctx = user_data;
LOGF("on_if_expr(sig: ");
@@ -883,18 +883,18 @@ static WasmResult logging_on_if_expr(uint32_t num_types,
FORWARD(on_if_expr, num_types, sig_types);
}
-static WasmResult logging_on_load_expr(WasmOpcode opcode,
+static WabtResult logging_on_load_expr(WabtOpcode opcode,
uint32_t alignment_log2,
uint32_t offset,
void* user_data) {
LoggingContext* ctx = user_data;
LOGF("on_load_expr(opcode: \"%s\" (%u), align log2: %u, offset: %u)\n",
- wasm_get_opcode_name(opcode), opcode, alignment_log2, offset);
+ wabt_get_opcode_name(opcode), opcode, alignment_log2, offset);
FORWARD(on_load_expr, opcode, alignment_log2, offset);
}
-static WasmResult logging_on_loop_expr(uint32_t num_types,
- WasmType* sig_types,
+static WabtResult logging_on_loop_expr(uint32_t num_types,
+ WabtType* sig_types,
void* user_data) {
LoggingContext* ctx = user_data;
LOGF("on_loop_expr(sig: ");
@@ -903,17 +903,17 @@ static WasmResult logging_on_loop_expr(uint32_t num_types,
FORWARD(on_loop_expr, num_types, sig_types);
}
-static WasmResult logging_on_store_expr(WasmOpcode opcode,
+static WabtResult logging_on_store_expr(WabtOpcode opcode,
uint32_t alignment_log2,
uint32_t offset,
void* user_data) {
LoggingContext* ctx = user_data;
LOGF("on_store_expr(opcode: \"%s\" (%u), align log2: %u, offset: %u)\n",
- wasm_get_opcode_name(opcode), opcode, alignment_log2, offset);
+ wabt_get_opcode_name(opcode), opcode, alignment_log2, offset);
FORWARD(on_store_expr, opcode, alignment_log2, offset);
}
-static WasmResult logging_end_function_body_pass(uint32_t index,
+static WabtResult logging_end_function_body_pass(uint32_t index,
uint32_t pass,
void* user_data) {
LoggingContext* ctx = user_data;
@@ -922,7 +922,7 @@ static WasmResult logging_end_function_body_pass(uint32_t index,
FORWARD(end_function_body_pass, index, pass);
}
-static WasmResult logging_on_data_segment_data(uint32_t index,
+static WabtResult logging_on_data_segment_data(uint32_t index,
const void* data,
uint32_t size,
void* user_data) {
@@ -931,27 +931,27 @@ static WasmResult logging_on_data_segment_data(uint32_t index,
FORWARD(on_data_segment_data, index, data, size);
}
-static WasmResult logging_on_function_name(uint32_t index,
- WasmStringSlice name,
+static WabtResult logging_on_function_name(uint32_t index,
+ WabtStringSlice name,
void* user_data) {
LoggingContext* ctx = user_data;
LOGF("on_function_name(index: %u, name: \"" PRIstringslice "\")\n", index,
- WASM_PRINTF_STRING_SLICE_ARG(name));
+ WABT_PRINTF_STRING_SLICE_ARG(name));
FORWARD(on_function_name, index, name);
}
-static WasmResult logging_on_local_name(uint32_t func_index,
+static WabtResult logging_on_local_name(uint32_t func_index,
uint32_t local_index,
- WasmStringSlice name,
+ WabtStringSlice name,
void* user_data) {
LoggingContext* ctx = user_data;
LOGF("on_local_name(func_index: %u, local_index: %u, name: \"" PRIstringslice
"\")\n",
- func_index, local_index, WASM_PRINTF_STRING_SLICE_ARG(name));
+ func_index, local_index, WABT_PRINTF_STRING_SLICE_ARG(name));
FORWARD(on_local_name, func_index, local_index, name);
}
-static WasmResult logging_on_init_expr_f32_const_expr(uint32_t index,
+static WabtResult logging_on_init_expr_f32_const_expr(uint32_t index,
uint32_t value_bits,
void* user_data) {
LoggingContext* ctx = user_data;
@@ -962,7 +962,7 @@ static WasmResult logging_on_init_expr_f32_const_expr(uint32_t index,
FORWARD(on_init_expr_f32_const_expr, index, value_bits);
}
-static WasmResult logging_on_init_expr_f64_const_expr(uint32_t index,
+static WabtResult logging_on_init_expr_f64_const_expr(uint32_t index,
uint64_t value_bits,
void* user_data) {
LoggingContext* ctx = user_data;
@@ -973,7 +973,7 @@ static WasmResult logging_on_init_expr_f64_const_expr(uint32_t index,
FORWARD(on_init_expr_f64_const_expr, index, value_bits);
}
-static WasmResult logging_on_init_expr_i32_const_expr(uint32_t index,
+static WabtResult logging_on_init_expr_i32_const_expr(uint32_t index,
uint32_t value,
void* user_data) {
LoggingContext* ctx = user_data;
@@ -981,7 +981,7 @@ static WasmResult logging_on_init_expr_i32_const_expr(uint32_t index,
FORWARD(on_init_expr_i32_const_expr, index, value);
}
-static WasmResult logging_on_init_expr_i64_const_expr(uint32_t index,
+static WabtResult logging_on_init_expr_i64_const_expr(uint32_t index,
uint64_t value,
void* user_data) {
LoggingContext* ctx = user_data;
@@ -990,19 +990,19 @@ static WasmResult logging_on_init_expr_i64_const_expr(uint32_t index,
FORWARD(on_init_expr_i64_const_expr, index, value);
}
-static WasmResult logging_on_reloc_count(uint32_t count,
- WasmBinarySection section_code,
- WasmStringSlice section_name,
+static WabtResult logging_on_reloc_count(uint32_t count,
+ WabtBinarySection section_code,
+ WabtStringSlice section_name,
void* user_data) {
LoggingContext* ctx = user_data;
LOGF("on_reloc_count(count: %d, section: %s, section_name: " PRIstringslice
")\n",
- count, wasm_get_section_name(section_code),
- WASM_PRINTF_STRING_SLICE_ARG(section_name));
+ count, wabt_get_section_name(section_code),
+ WABT_PRINTF_STRING_SLICE_ARG(section_name));
FORWARD(on_reloc_count, count, section_code, section_name);
}
-static WasmBinaryReader s_logging_binary_reader = {
+static WabtBinaryReader s_logging_binary_reader = {
.user_data = NULL,
.on_error = logging_on_error,
.begin_module = logging_begin_module,
@@ -1143,42 +1143,42 @@ static void read_init_expr(Context* ctx, uint32_t index) {
uint8_t opcode;
in_u8(ctx, &opcode, "opcode");
switch (opcode) {
- case WASM_OPCODE_I32_CONST: {
+ case WABT_OPCODE_I32_CONST: {
uint32_t value = 0;
in_i32_leb128(ctx, &value, "init_expr i32.const value");
CALLBACK(on_init_expr_i32_const_expr, index, value);
break;
}
- case WASM_OPCODE_I64_CONST: {
+ case WABT_OPCODE_I64_CONST: {
uint64_t value = 0;
in_i64_leb128(ctx, &value, "init_expr i64.const value");
CALLBACK(on_init_expr_i64_const_expr, index, value);
break;
}
- case WASM_OPCODE_F32_CONST: {
+ case WABT_OPCODE_F32_CONST: {
uint32_t value_bits = 0;
in_f32(ctx, &value_bits, "init_expr f32.const value");
CALLBACK(on_init_expr_f32_const_expr, index, value_bits);
break;
}
- case WASM_OPCODE_F64_CONST: {
+ case WABT_OPCODE_F64_CONST: {
uint64_t value_bits = 0;
in_f64(ctx, &value_bits, "init_expr f64.const value");
CALLBACK(on_init_expr_f64_const_expr, index, value_bits);
break;
}
- case WASM_OPCODE_GET_GLOBAL: {
+ case WABT_OPCODE_GET_GLOBAL: {
uint32_t global_index;
in_u32_leb128(ctx, &global_index, "init_expr get_global index");
CALLBACK(on_init_expr_get_global_expr, index, global_index);
break;
}
- case WASM_OPCODE_END:
+ case WABT_OPCODE_END:
return;
default:
@@ -1188,15 +1188,15 @@ static void read_init_expr(Context* ctx, uint32_t index) {
}
in_u8(ctx, &opcode, "opcode");
- RAISE_ERROR_UNLESS(opcode == WASM_OPCODE_END,
+ RAISE_ERROR_UNLESS(opcode == WABT_OPCODE_END,
"expected END opcode after initializer expression");
}
static void read_table(Context* ctx,
- WasmType* out_elem_type,
- WasmLimits* out_elem_limits) {
+ WabtType* out_elem_type,
+ WabtLimits* out_elem_limits) {
in_type(ctx, out_elem_type, "table elem type");
- RAISE_ERROR_UNLESS(*out_elem_type == WASM_TYPE_ANYFUNC,
+ RAISE_ERROR_UNLESS(*out_elem_type == WABT_TYPE_ANYFUNC,
"table elem type must by anyfunc");
uint32_t flags;
@@ -1204,7 +1204,7 @@ static void read_table(Context* ctx,
uint32_t max = 0;
in_u32_leb128(ctx, &flags, "table flags");
in_u32_leb128(ctx, &initial, "table initial elem count");
- WasmBool has_max = flags & WASM_BINARY_LIMITS_HAS_MAX_FLAG;
+ WabtBool has_max = flags & WABT_BINARY_LIMITS_HAS_MAX_FLAG;
if (has_max) {
in_u32_leb128(ctx, &max, "table max elem count");
RAISE_ERROR_UNLESS(initial <= max,
@@ -1216,17 +1216,17 @@ static void read_table(Context* ctx,
out_elem_limits->max = max;
}
-static void read_memory(Context* ctx, WasmLimits* out_page_limits) {
+static void read_memory(Context* ctx, WabtLimits* out_page_limits) {
uint32_t flags;
uint32_t initial;
uint32_t max = 0;
in_u32_leb128(ctx, &flags, "memory flags");
in_u32_leb128(ctx, &initial, "memory initial page count");
- WasmBool has_max = flags & WASM_BINARY_LIMITS_HAS_MAX_FLAG;
- RAISE_ERROR_UNLESS(initial <= WASM_MAX_PAGES, "invalid memory initial size");
+ WabtBool has_max = flags & WABT_BINARY_LIMITS_HAS_MAX_FLAG;
+ RAISE_ERROR_UNLESS(initial <= WABT_MAX_PAGES, "invalid memory initial size");
if (has_max) {
in_u32_leb128(ctx, &max, "memory max page count");
- RAISE_ERROR_UNLESS(max <= WASM_MAX_PAGES, "invalid memory max size");
+ RAISE_ERROR_UNLESS(max <= WABT_MAX_PAGES, "invalid memory max size");
RAISE_ERROR_UNLESS(initial <= max,
"memory initial size must be <= max size");
}
@@ -1237,9 +1237,9 @@ static void read_memory(Context* ctx, WasmLimits* out_page_limits) {
}
static void read_global_header(Context* ctx,
- WasmType* out_type,
- WasmBool* out_mutable) {
- WasmType global_type;
+ WabtType* out_type,
+ WabtBool* out_mutable) {
+ WabtType global_type;
uint8_t mutable_;
in_type(ctx, &global_type, "global type");
RAISE_ERROR_UNLESS(is_concrete_type(global_type),
@@ -1253,61 +1253,61 @@ static void read_global_header(Context* ctx,
}
static void read_function_body(Context* ctx, uint32_t end_offset) {
- WasmBool seen_end_opcode = WASM_FALSE;
+ WabtBool seen_end_opcode = WABT_FALSE;
while (ctx->offset < end_offset) {
uint8_t opcode;
in_u8(ctx, &opcode, "opcode");
CALLBACK_CTX(on_opcode, opcode);
switch (opcode) {
- case WASM_OPCODE_UNREACHABLE:
+ case WABT_OPCODE_UNREACHABLE:
CALLBACK0(on_unreachable_expr);
CALLBACK_CTX0(on_opcode_bare);
break;
- case WASM_OPCODE_BLOCK: {
- WasmType sig_type;
+ case WABT_OPCODE_BLOCK: {
+ WabtType sig_type;
in_type(ctx, &sig_type, "block signature type");
RAISE_ERROR_UNLESS(is_inline_sig_type(sig_type),
"expected valid block signature type");
- uint32_t num_types = sig_type == WASM_TYPE_VOID ? 0 : 1;
+ uint32_t num_types = sig_type == WABT_TYPE_VOID ? 0 : 1;
CALLBACK(on_block_expr, num_types, &sig_type);
CALLBACK_CTX(on_opcode_block_sig, num_types, &sig_type);
break;
}
- case WASM_OPCODE_LOOP: {
- WasmType sig_type;
+ case WABT_OPCODE_LOOP: {
+ WabtType sig_type;
in_type(ctx, &sig_type, "loop signature type");
RAISE_ERROR_UNLESS(is_inline_sig_type(sig_type),
"expected valid block signature type");
- uint32_t num_types = sig_type == WASM_TYPE_VOID ? 0 : 1;
+ uint32_t num_types = sig_type == WABT_TYPE_VOID ? 0 : 1;
CALLBACK(on_loop_expr, num_types, &sig_type);
CALLBACK_CTX(on_opcode_block_sig, num_types, &sig_type);
break;
}
- case WASM_OPCODE_IF: {
- WasmType sig_type;
+ case WABT_OPCODE_IF: {
+ WabtType sig_type;
in_type(ctx, &sig_type, "if signature type");
RAISE_ERROR_UNLESS(is_inline_sig_type(sig_type),
"expected valid block signature type");
- uint32_t num_types = sig_type == WASM_TYPE_VOID ? 0 : 1;
+ uint32_t num_types = sig_type == WABT_TYPE_VOID ? 0 : 1;
CALLBACK(on_if_expr, num_types, &sig_type);
CALLBACK_CTX(on_opcode_block_sig, num_types, &sig_type);
break;
}
- case WASM_OPCODE_ELSE:
+ case WABT_OPCODE_ELSE:
CALLBACK0(on_else_expr);
CALLBACK_CTX0(on_opcode_bare);
break;
- case WASM_OPCODE_SELECT:
+ case WABT_OPCODE_SELECT:
CALLBACK0(on_select_expr);
CALLBACK_CTX0(on_opcode_bare);
break;
- case WASM_OPCODE_BR: {
+ case WABT_OPCODE_BR: {
uint32_t depth;
in_u32_leb128(ctx, &depth, "br depth");
CALLBACK(on_br_expr, depth);
@@ -1315,7 +1315,7 @@ static void read_function_body(Context* ctx, uint32_t end_offset) {
break;
}
- case WASM_OPCODE_BR_IF: {
+ case WABT_OPCODE_BR_IF: {
uint32_t depth;
in_u32_leb128(ctx, &depth, "br_if depth");
CALLBACK(on_br_if_expr, depth);
@@ -1323,11 +1323,11 @@ static void read_function_body(Context* ctx, uint32_t end_offset) {
break;
}
- case WASM_OPCODE_BR_TABLE: {
+ case WABT_OPCODE_BR_TABLE: {
uint32_t num_targets;
in_u32_leb128(ctx, &num_targets, "br_table target count");
if (num_targets > ctx->target_depths.capacity) {
- wasm_reserve_uint32s(ctx->allocator, &ctx->target_depths,
+ wabt_reserve_uint32s(ctx->allocator, &ctx->target_depths,
num_targets);
ctx->target_depths.size = num_targets;
}
@@ -1348,29 +1348,29 @@ static void read_function_body(Context* ctx, uint32_t end_offset) {
break;
}
- case WASM_OPCODE_RETURN:
+ case WABT_OPCODE_RETURN:
CALLBACK0(on_return_expr);
CALLBACK_CTX0(on_opcode_bare);
break;
- case WASM_OPCODE_NOP:
+ case WABT_OPCODE_NOP:
CALLBACK0(on_nop_expr);
CALLBACK_CTX0(on_opcode_bare);
break;
- case WASM_OPCODE_DROP:
+ case WABT_OPCODE_DROP:
CALLBACK0(on_drop_expr);
CALLBACK_CTX0(on_opcode_bare);
break;
- case WASM_OPCODE_END:
+ case WABT_OPCODE_END:
if (ctx->offset == end_offset)
- seen_end_opcode = WASM_TRUE;
+ seen_end_opcode = WABT_TRUE;
else
CALLBACK0(on_end_expr);
break;
- case WASM_OPCODE_I32_CONST: {
+ case WABT_OPCODE_I32_CONST: {
uint32_t value = 0;
in_i32_leb128(ctx, &value, "i32.const value");
CALLBACK(on_i32_const_expr, value);
@@ -1378,7 +1378,7 @@ static void read_function_body(Context* ctx, uint32_t end_offset) {
break;
}
- case WASM_OPCODE_I64_CONST: {
+ case WABT_OPCODE_I64_CONST: {
uint64_t value = 0;
in_i64_leb128(ctx, &value, "i64.const value");
CALLBACK(on_i64_const_expr, value);
@@ -1386,7 +1386,7 @@ static void read_function_body(Context* ctx, uint32_t end_offset) {
break;
}
- case WASM_OPCODE_F32_CONST: {
+ case WABT_OPCODE_F32_CONST: {
uint32_t value_bits = 0;
in_f32(ctx, &value_bits, "f32.const value");
CALLBACK(on_f32_const_expr, value_bits);
@@ -1394,7 +1394,7 @@ static void read_function_body(Context* ctx, uint32_t end_offset) {
break;
}
- case WASM_OPCODE_F64_CONST: {
+ case WABT_OPCODE_F64_CONST: {
uint64_t value_bits = 0;
in_f64(ctx, &value_bits, "f64.const value");
CALLBACK(on_f64_const_expr, value_bits);
@@ -1402,7 +1402,7 @@ static void read_function_body(Context* ctx, uint32_t end_offset) {
break;
}
- case WASM_OPCODE_GET_GLOBAL: {
+ case WABT_OPCODE_GET_GLOBAL: {
uint32_t global_index;
in_u32_leb128(ctx, &global_index, "get_global global index");
CALLBACK(on_get_global_expr, global_index);
@@ -1410,7 +1410,7 @@ static void read_function_body(Context* ctx, uint32_t end_offset) {
break;
}
- case WASM_OPCODE_GET_LOCAL: {
+ case WABT_OPCODE_GET_LOCAL: {
uint32_t local_index;
in_u32_leb128(ctx, &local_index, "get_local local index");
CALLBACK(on_get_local_expr, local_index);
@@ -1418,7 +1418,7 @@ static void read_function_body(Context* ctx, uint32_t end_offset) {
break;
}
- case WASM_OPCODE_SET_GLOBAL: {
+ case WABT_OPCODE_SET_GLOBAL: {
uint32_t global_index;
in_u32_leb128(ctx, &global_index, "set_global global index");
CALLBACK(on_set_global_expr, global_index);
@@ -1426,7 +1426,7 @@ static void read_function_body(Context* ctx, uint32_t end_offset) {
break;
}
- case WASM_OPCODE_SET_LOCAL: {
+ case WABT_OPCODE_SET_LOCAL: {
uint32_t local_index;
in_u32_leb128(ctx, &local_index, "set_local local index");
CALLBACK(on_set_local_expr, local_index);
@@ -1434,7 +1434,7 @@ static void read_function_body(Context* ctx, uint32_t end_offset) {
break;
}
- case WASM_OPCODE_CALL: {
+ case WABT_OPCODE_CALL: {
uint32_t func_index;
in_u32_leb128(ctx, &func_index, "call function index");
RAISE_ERROR_UNLESS(func_index < num_total_funcs(ctx),
@@ -1444,7 +1444,7 @@ static void read_function_body(Context* ctx, uint32_t end_offset) {
break;
}
- case WASM_OPCODE_CALL_INDIRECT: {
+ case WABT_OPCODE_CALL_INDIRECT: {
uint32_t sig_index;
in_u32_leb128(ctx, &sig_index, "call_indirect signature index");
RAISE_ERROR_UNLESS(sig_index < ctx->num_signatures,
@@ -1458,7 +1458,7 @@ static void read_function_body(Context* ctx, uint32_t end_offset) {
break;
}
- case WASM_OPCODE_TEE_LOCAL: {
+ case WABT_OPCODE_TEE_LOCAL: {
uint32_t local_index;
in_u32_leb128(ctx, &local_index, "tee_local local index");
CALLBACK(on_tee_local_expr, local_index);
@@ -1466,20 +1466,20 @@ static void read_function_body(Context* ctx, uint32_t end_offset) {
break;
}
- case WASM_OPCODE_I32_LOAD8_S:
- case WASM_OPCODE_I32_LOAD8_U:
- case WASM_OPCODE_I32_LOAD16_S:
- case WASM_OPCODE_I32_LOAD16_U:
- case WASM_OPCODE_I64_LOAD8_S:
- case WASM_OPCODE_I64_LOAD8_U:
- case WASM_OPCODE_I64_LOAD16_S:
- case WASM_OPCODE_I64_LOAD16_U:
- case WASM_OPCODE_I64_LOAD32_S:
- case WASM_OPCODE_I64_LOAD32_U:
- case WASM_OPCODE_I32_LOAD:
- case WASM_OPCODE_I64_LOAD:
- case WASM_OPCODE_F32_LOAD:
- case WASM_OPCODE_F64_LOAD: {
+ case WABT_OPCODE_I32_LOAD8_S:
+ case WABT_OPCODE_I32_LOAD8_U:
+ case WABT_OPCODE_I32_LOAD16_S:
+ case WABT_OPCODE_I32_LOAD16_U:
+ case WABT_OPCODE_I64_LOAD8_S:
+ case WABT_OPCODE_I64_LOAD8_U:
+ case WABT_OPCODE_I64_LOAD16_S:
+ case WABT_OPCODE_I64_LOAD16_U:
+ case WABT_OPCODE_I64_LOAD32_S:
+ case WABT_OPCODE_I64_LOAD32_U:
+ case WABT_OPCODE_I32_LOAD:
+ case WABT_OPCODE_I64_LOAD:
+ case WABT_OPCODE_F32_LOAD:
+ case WABT_OPCODE_F64_LOAD: {
uint32_t alignment_log2;
in_u32_leb128(ctx, &alignment_log2, "load alignment");
uint32_t offset;
@@ -1490,15 +1490,15 @@ static void read_function_body(Context* ctx, uint32_t end_offset) {
break;
}
- case WASM_OPCODE_I32_STORE8:
- case WASM_OPCODE_I32_STORE16:
- case WASM_OPCODE_I64_STORE8:
- case WASM_OPCODE_I64_STORE16:
- case WASM_OPCODE_I64_STORE32:
- case WASM_OPCODE_I32_STORE:
- case WASM_OPCODE_I64_STORE:
- case WASM_OPCODE_F32_STORE:
- case WASM_OPCODE_F64_STORE: {
+ case WABT_OPCODE_I32_STORE8:
+ case WABT_OPCODE_I32_STORE16:
+ case WABT_OPCODE_I64_STORE8:
+ case WABT_OPCODE_I64_STORE16:
+ case WABT_OPCODE_I64_STORE32:
+ case WABT_OPCODE_I32_STORE:
+ case WABT_OPCODE_I64_STORE:
+ case WABT_OPCODE_F32_STORE:
+ case WABT_OPCODE_F64_STORE: {
uint32_t alignment_log2;
in_u32_leb128(ctx, &alignment_log2, "store alignment");
uint32_t offset;
@@ -1509,7 +1509,7 @@ static void read_function_body(Context* ctx, uint32_t end_offset) {
break;
}
- case WASM_OPCODE_CURRENT_MEMORY: {
+ case WABT_OPCODE_CURRENT_MEMORY: {
uint32_t reserved;
in_u32_leb128(ctx, &reserved, "current_memory reserved");
RAISE_ERROR_UNLESS(reserved == 0,
@@ -1519,7 +1519,7 @@ static void read_function_body(Context* ctx, uint32_t end_offset) {
break;
}
- case WASM_OPCODE_GROW_MEMORY: {
+ case WABT_OPCODE_GROW_MEMORY: {
uint32_t reserved;
in_u32_leb128(ctx, &reserved, "grow_memory reserved");
RAISE_ERROR_UNLESS(reserved == 0,
@@ -1529,141 +1529,141 @@ static void read_function_body(Context* ctx, uint32_t end_offset) {
break;
}
- case WASM_OPCODE_I32_ADD:
- case WASM_OPCODE_I32_SUB:
- case WASM_OPCODE_I32_MUL:
- case WASM_OPCODE_I32_DIV_S:
- case WASM_OPCODE_I32_DIV_U:
- case WASM_OPCODE_I32_REM_S:
- case WASM_OPCODE_I32_REM_U:
- case WASM_OPCODE_I32_AND:
- case WASM_OPCODE_I32_OR:
- case WASM_OPCODE_I32_XOR:
- case WASM_OPCODE_I32_SHL:
- case WASM_OPCODE_I32_SHR_U:
- case WASM_OPCODE_I32_SHR_S:
- case WASM_OPCODE_I32_ROTR:
- case WASM_OPCODE_I32_ROTL:
- case WASM_OPCODE_I64_ADD:
- case WASM_OPCODE_I64_SUB:
- case WASM_OPCODE_I64_MUL:
- case WASM_OPCODE_I64_DIV_S:
- case WASM_OPCODE_I64_DIV_U:
- case WASM_OPCODE_I64_REM_S:
- case WASM_OPCODE_I64_REM_U:
- case WASM_OPCODE_I64_AND:
- case WASM_OPCODE_I64_OR:
- case WASM_OPCODE_I64_XOR:
- case WASM_OPCODE_I64_SHL:
- case WASM_OPCODE_I64_SHR_U:
- case WASM_OPCODE_I64_SHR_S:
- case WASM_OPCODE_I64_ROTR:
- case WASM_OPCODE_I64_ROTL:
- case WASM_OPCODE_F32_ADD:
- case WASM_OPCODE_F32_SUB:
- case WASM_OPCODE_F32_MUL:
- case WASM_OPCODE_F32_DIV:
- case WASM_OPCODE_F32_MIN:
- case WASM_OPCODE_F32_MAX:
- case WASM_OPCODE_F32_COPYSIGN:
- case WASM_OPCODE_F64_ADD:
- case WASM_OPCODE_F64_SUB:
- case WASM_OPCODE_F64_MUL:
- case WASM_OPCODE_F64_DIV:
- case WASM_OPCODE_F64_MIN:
- case WASM_OPCODE_F64_MAX:
- case WASM_OPCODE_F64_COPYSIGN:
+ case WABT_OPCODE_I32_ADD:
+ case WABT_OPCODE_I32_SUB:
+ case WABT_OPCODE_I32_MUL:
+ case WABT_OPCODE_I32_DIV_S:
+ case WABT_OPCODE_I32_DIV_U:
+ case WABT_OPCODE_I32_REM_S:
+ case WABT_OPCODE_I32_REM_U:
+ case WABT_OPCODE_I32_AND:
+ case WABT_OPCODE_I32_OR:
+ case WABT_OPCODE_I32_XOR:
+ case WABT_OPCODE_I32_SHL:
+ case WABT_OPCODE_I32_SHR_U:
+ case WABT_OPCODE_I32_SHR_S:
+ case WABT_OPCODE_I32_ROTR:
+ case WABT_OPCODE_I32_ROTL:
+ case WABT_OPCODE_I64_ADD:
+ case WABT_OPCODE_I64_SUB:
+ case WABT_OPCODE_I64_MUL:
+ case WABT_OPCODE_I64_DIV_S:
+ case WABT_OPCODE_I64_DIV_U:
+ case WABT_OPCODE_I64_REM_S:
+ case WABT_OPCODE_I64_REM_U:
+ case WABT_OPCODE_I64_AND:
+ case WABT_OPCODE_I64_OR:
+ case WABT_OPCODE_I64_XOR:
+ case WABT_OPCODE_I64_SHL:
+ case WABT_OPCODE_I64_SHR_U:
+ case WABT_OPCODE_I64_SHR_S:
+ case WABT_OPCODE_I64_ROTR:
+ case WABT_OPCODE_I64_ROTL:
+ case WABT_OPCODE_F32_ADD:
+ case WABT_OPCODE_F32_SUB:
+ case WABT_OPCODE_F32_MUL:
+ case WABT_OPCODE_F32_DIV:
+ case WABT_OPCODE_F32_MIN:
+ case WABT_OPCODE_F32_MAX:
+ case WABT_OPCODE_F32_COPYSIGN:
+ case WABT_OPCODE_F64_ADD:
+ case WABT_OPCODE_F64_SUB:
+ case WABT_OPCODE_F64_MUL:
+ case WABT_OPCODE_F64_DIV:
+ case WABT_OPCODE_F64_MIN:
+ case WABT_OPCODE_F64_MAX:
+ case WABT_OPCODE_F64_COPYSIGN:
CALLBACK(on_binary_expr, opcode);
CALLBACK_CTX0(on_opcode_bare);
break;
- case WASM_OPCODE_I32_EQ:
- case WASM_OPCODE_I32_NE:
- case WASM_OPCODE_I32_LT_S:
- case WASM_OPCODE_I32_LE_S:
- case WASM_OPCODE_I32_LT_U:
- case WASM_OPCODE_I32_LE_U:
- case WASM_OPCODE_I32_GT_S:
- case WASM_OPCODE_I32_GE_S:
- case WASM_OPCODE_I32_GT_U:
- case WASM_OPCODE_I32_GE_U:
- case WASM_OPCODE_I64_EQ:
- case WASM_OPCODE_I64_NE:
- case WASM_OPCODE_I64_LT_S:
- case WASM_OPCODE_I64_LE_S:
- case WASM_OPCODE_I64_LT_U:
- case WASM_OPCODE_I64_LE_U:
- case WASM_OPCODE_I64_GT_S:
- case WASM_OPCODE_I64_GE_S:
- case WASM_OPCODE_I64_GT_U:
- case WASM_OPCODE_I64_GE_U:
- case WASM_OPCODE_F32_EQ:
- case WASM_OPCODE_F32_NE:
- case WASM_OPCODE_F32_LT:
- case WASM_OPCODE_F32_LE:
- case WASM_OPCODE_F32_GT:
- case WASM_OPCODE_F32_GE:
- case WASM_OPCODE_F64_EQ:
- case WASM_OPCODE_F64_NE:
- case WASM_OPCODE_F64_LT:
- case WASM_OPCODE_F64_LE:
- case WASM_OPCODE_F64_GT:
- case WASM_OPCODE_F64_GE:
+ case WABT_OPCODE_I32_EQ:
+ case WABT_OPCODE_I32_NE:
+ case WABT_OPCODE_I32_LT_S:
+ case WABT_OPCODE_I32_LE_S:
+ case WABT_OPCODE_I32_LT_U:
+ case WABT_OPCODE_I32_LE_U:
+ case WABT_OPCODE_I32_GT_S:
+ case WABT_OPCODE_I32_GE_S:
+ case WABT_OPCODE_I32_GT_U:
+ case WABT_OPCODE_I32_GE_U:
+ case WABT_OPCODE_I64_EQ:
+ case WABT_OPCODE_I64_NE:
+ case WABT_OPCODE_I64_LT_S:
+ case WABT_OPCODE_I64_LE_S:
+ case WABT_OPCODE_I64_LT_U:
+ case WABT_OPCODE_I64_LE_U:
+ case WABT_OPCODE_I64_GT_S:
+ case WABT_OPCODE_I64_GE_S:
+ case WABT_OPCODE_I64_GT_U:
+ case WABT_OPCODE_I64_GE_U:
+ case WABT_OPCODE_F32_EQ:
+ case WABT_OPCODE_F32_NE:
+ case WABT_OPCODE_F32_LT:
+ case WABT_OPCODE_F32_LE:
+ case WABT_OPCODE_F32_GT:
+ case WABT_OPCODE_F32_GE:
+ case WABT_OPCODE_F64_EQ:
+ case WABT_OPCODE_F64_NE:
+ case WABT_OPCODE_F64_LT:
+ case WABT_OPCODE_F64_LE:
+ case WABT_OPCODE_F64_GT:
+ case WABT_OPCODE_F64_GE:
CALLBACK(on_compare_expr, opcode);
CALLBACK_CTX0(on_opcode_bare);
break;
- case WASM_OPCODE_I32_CLZ:
- case WASM_OPCODE_I32_CTZ:
- case WASM_OPCODE_I32_POPCNT:
- case WASM_OPCODE_I64_CLZ:
- case WASM_OPCODE_I64_CTZ:
- case WASM_OPCODE_I64_POPCNT:
- case WASM_OPCODE_F32_ABS:
- case WASM_OPCODE_F32_NEG:
- case WASM_OPCODE_F32_CEIL:
- case WASM_OPCODE_F32_FLOOR:
- case WASM_OPCODE_F32_TRUNC:
- case WASM_OPCODE_F32_NEAREST:
- case WASM_OPCODE_F32_SQRT:
- case WASM_OPCODE_F64_ABS:
- case WASM_OPCODE_F64_NEG:
- case WASM_OPCODE_F64_CEIL:
- case WASM_OPCODE_F64_FLOOR:
- case WASM_OPCODE_F64_TRUNC:
- case WASM_OPCODE_F64_NEAREST:
- case WASM_OPCODE_F64_SQRT:
+ case WABT_OPCODE_I32_CLZ:
+ case WABT_OPCODE_I32_CTZ:
+ case WABT_OPCODE_I32_POPCNT:
+ case WABT_OPCODE_I64_CLZ:
+ case WABT_OPCODE_I64_CTZ:
+ case WABT_OPCODE_I64_POPCNT:
+ case WABT_OPCODE_F32_ABS:
+ case WABT_OPCODE_F32_NEG:
+ case WABT_OPCODE_F32_CEIL:
+ case WABT_OPCODE_F32_FLOOR:
+ case WABT_OPCODE_F32_TRUNC:
+ case WABT_OPCODE_F32_NEAREST:
+ case WABT_OPCODE_F32_SQRT:
+ case WABT_OPCODE_F64_ABS:
+ case WABT_OPCODE_F64_NEG:
+ case WABT_OPCODE_F64_CEIL:
+ case WABT_OPCODE_F64_FLOOR:
+ case WABT_OPCODE_F64_TRUNC:
+ case WABT_OPCODE_F64_NEAREST:
+ case WABT_OPCODE_F64_SQRT:
CALLBACK(on_unary_expr, opcode);
CALLBACK_CTX0(on_opcode_bare);
break;
- case WASM_OPCODE_I32_TRUNC_S_F32:
- case WASM_OPCODE_I32_TRUNC_S_F64:
- case WASM_OPCODE_I32_TRUNC_U_F32:
- case WASM_OPCODE_I32_TRUNC_U_F64:
- case WASM_OPCODE_I32_WRAP_I64:
- case WASM_OPCODE_I64_TRUNC_S_F32:
- case WASM_OPCODE_I64_TRUNC_S_F64:
- case WASM_OPCODE_I64_TRUNC_U_F32:
- case WASM_OPCODE_I64_TRUNC_U_F64:
- case WASM_OPCODE_I64_EXTEND_S_I32:
- case WASM_OPCODE_I64_EXTEND_U_I32:
- case WASM_OPCODE_F32_CONVERT_S_I32:
- case WASM_OPCODE_F32_CONVERT_U_I32:
- case WASM_OPCODE_F32_CONVERT_S_I64:
- case WASM_OPCODE_F32_CONVERT_U_I64:
- case WASM_OPCODE_F32_DEMOTE_F64:
- case WASM_OPCODE_F32_REINTERPRET_I32:
- case WASM_OPCODE_F64_CONVERT_S_I32:
- case WASM_OPCODE_F64_CONVERT_U_I32:
- case WASM_OPCODE_F64_CONVERT_S_I64:
- case WASM_OPCODE_F64_CONVERT_U_I64:
- case WASM_OPCODE_F64_PROMOTE_F32:
- case WASM_OPCODE_F64_REINTERPRET_I64:
- case WASM_OPCODE_I32_REINTERPRET_F32:
- case WASM_OPCODE_I64_REINTERPRET_F64:
- case WASM_OPCODE_I32_EQZ:
- case WASM_OPCODE_I64_EQZ:
+ case WABT_OPCODE_I32_TRUNC_S_F32:
+ case WABT_OPCODE_I32_TRUNC_S_F64:
+ case WABT_OPCODE_I32_TRUNC_U_F32:
+ case WABT_OPCODE_I32_TRUNC_U_F64:
+ case WABT_OPCODE_I32_WRAP_I64:
+ case WABT_OPCODE_I64_TRUNC_S_F32:
+ case WABT_OPCODE_I64_TRUNC_S_F64:
+ case WABT_OPCODE_I64_TRUNC_U_F32:
+ case WABT_OPCODE_I64_TRUNC_U_F64:
+ case WABT_OPCODE_I64_EXTEND_S_I32:
+ case WABT_OPCODE_I64_EXTEND_U_I32:
+ case WABT_OPCODE_F32_CONVERT_S_I32:
+ case WABT_OPCODE_F32_CONVERT_U_I32:
+ case WABT_OPCODE_F32_CONVERT_S_I64:
+ case WABT_OPCODE_F32_CONVERT_U_I64:
+ case WABT_OPCODE_F32_DEMOTE_F64:
+ case WABT_OPCODE_F32_REINTERPRET_I32:
+ case WABT_OPCODE_F64_CONVERT_S_I32:
+ case WABT_OPCODE_F64_CONVERT_U_I32:
+ case WABT_OPCODE_F64_CONVERT_S_I64:
+ case WABT_OPCODE_F64_CONVERT_U_I64:
+ case WABT_OPCODE_F64_PROMOTE_F32:
+ case WABT_OPCODE_F64_REINTERPRET_I64:
+ case WABT_OPCODE_I32_REINTERPRET_F32:
+ case WABT_OPCODE_I64_REINTERPRET_F64:
+ case WABT_OPCODE_I32_EQZ:
+ case WABT_OPCODE_I64_EQZ:
CALLBACK(on_convert_expr, opcode);
CALLBACK_CTX0(on_opcode_bare);
break;
@@ -1678,21 +1678,21 @@ static void read_function_body(Context* ctx, uint32_t end_offset) {
}
static void read_custom_section(Context* ctx, uint32_t section_size) {
- WasmStringSlice section_name;
+ WabtStringSlice section_name;
in_str(ctx, &section_name, "section name");
CALLBACK_CTX(begin_custom_section, section_size, section_name);
- WasmBool name_section_ok =
- ctx->last_known_section_code >= WASM_BINARY_SECTION_IMPORT;
+ WabtBool name_section_ok =
+ ctx->last_known_section_code >= WABT_BINARY_SECTION_IMPORT;
if (ctx->options->read_debug_names && name_section_ok &&
- strncmp(section_name.start, WASM_BINARY_SECTION_NAME,
+ strncmp(section_name.start, WABT_BINARY_SECTION_NAME,
section_name.length) == 0) {
CALLBACK_SECTION(begin_names_section, section_size);
uint32_t i, num_functions;
in_u32_leb128(ctx, &num_functions, "function name count");
CALLBACK(on_function_names_count, num_functions);
for (i = 0; i < num_functions; ++i) {
- WasmStringSlice function_name;
+ WabtStringSlice function_name;
in_str(ctx, &function_name, "function name");
CALLBACK(on_function_name, i, function_name);
@@ -1701,19 +1701,19 @@ static void read_custom_section(Context* ctx, uint32_t section_size) {
CALLBACK(on_local_names_count, i, num_locals);
uint32_t j;
for (j = 0; j < num_locals; ++j) {
- WasmStringSlice local_name;
+ WabtStringSlice local_name;
in_str(ctx, &local_name, "local name");
CALLBACK(on_local_name, i, j, local_name);
}
}
CALLBACK0(end_names_section);
- } else if (strncmp(section_name.start, WASM_BINARY_SECTION_RELOC,
- strlen(WASM_BINARY_SECTION_RELOC)) == 0) {
+ } else if (strncmp(section_name.start, WABT_BINARY_SECTION_RELOC,
+ strlen(WABT_BINARY_SECTION_RELOC)) == 0) {
CALLBACK_SECTION(begin_reloc_section, section_size);
uint32_t i, num_relocs, section;
in_u32_leb128(ctx, &section, "section");
- WASM_ZERO_MEMORY(section_name);
- if (section == WASM_BINARY_SECTION_CUSTOM)
+ WABT_ZERO_MEMORY(section_name);
+ if (section == WABT_BINARY_SECTION_CUSTOM)
in_str(ctx, &section_name, "section name");
in_u32_leb128(ctx, &num_relocs, "relocation count");
CALLBACK(on_reloc_count, num_relocs, section, section_name);
@@ -1738,19 +1738,19 @@ static void read_type_section(Context* ctx, uint32_t section_size) {
CALLBACK(on_signature_count, ctx->num_signatures);
for (i = 0; i < ctx->num_signatures; ++i) {
- WasmType form;
+ WabtType form;
in_type(ctx, &form, "type form");
- RAISE_ERROR_UNLESS(form == WASM_TYPE_FUNC, "unexpected type form");
+ RAISE_ERROR_UNLESS(form == WABT_TYPE_FUNC, "unexpected type form");
uint32_t num_params;
in_u32_leb128(ctx, &num_params, "function param count");
if (num_params > ctx->param_types.capacity)
- wasm_reserve_types(ctx->allocator, &ctx->param_types, num_params);
+ wabt_reserve_types(ctx->allocator, &ctx->param_types, num_params);
uint32_t j;
for (j = 0; j < num_params; ++j) {
- WasmType param_type;
+ WabtType param_type;
in_type(ctx, &param_type, "function param type");
RAISE_ERROR_UNLESS(is_concrete_type(param_type),
"expected valid param type");
@@ -1761,7 +1761,7 @@ static void read_type_section(Context* ctx, uint32_t section_size) {
in_u32_leb128(ctx, &num_results, "function result count");
RAISE_ERROR_UNLESS(num_results <= 1, "result count must be 0 or 1");
- WasmType result_type = WASM_TYPE_VOID;
+ WabtType result_type = WABT_TYPE_VOID;
if (num_results) {
in_type(ctx, &result_type, "function result type");
RAISE_ERROR_UNLESS(is_concrete_type(result_type),
@@ -1780,16 +1780,16 @@ static void read_import_section(Context* ctx, uint32_t section_size) {
in_u32_leb128(ctx, &ctx->num_imports, "import count");
CALLBACK(on_import_count, ctx->num_imports);
for (i = 0; i < ctx->num_imports; ++i) {
- WasmStringSlice module_name;
+ WabtStringSlice module_name;
in_str(ctx, &module_name, "import module name");
- WasmStringSlice field_name;
+ WabtStringSlice field_name;
in_str(ctx, &field_name, "import field name");
CALLBACK(on_import, i, module_name, field_name);
uint32_t kind;
in_u32_leb128(ctx, &kind, "import kind");
switch (kind) {
- case WASM_EXTERNAL_KIND_FUNC: {
+ case WABT_EXTERNAL_KIND_FUNC: {
uint32_t sig_index;
in_u32_leb128(ctx, &sig_index, "import signature index");
RAISE_ERROR_UNLESS(sig_index < ctx->num_signatures,
@@ -1799,9 +1799,9 @@ static void read_import_section(Context* ctx, uint32_t section_size) {
break;
}
- case WASM_EXTERNAL_KIND_TABLE: {
- WasmType elem_type;
- WasmLimits elem_limits;
+ case WABT_EXTERNAL_KIND_TABLE: {
+ WabtType elem_type;
+ WabtLimits elem_limits;
read_table(ctx, &elem_type, &elem_limits);
CALLBACK(on_import_table, i, ctx->num_table_imports, elem_type,
&elem_limits);
@@ -1809,17 +1809,17 @@ static void read_import_section(Context* ctx, uint32_t section_size) {
break;
}
- case WASM_EXTERNAL_KIND_MEMORY: {
- WasmLimits page_limits;
+ case WABT_EXTERNAL_KIND_MEMORY: {
+ WabtLimits page_limits;
read_memory(ctx, &page_limits);
CALLBACK(on_import_memory, i, ctx->num_memory_imports, &page_limits);
ctx->num_memory_imports++;
break;
}
- case WASM_EXTERNAL_KIND_GLOBAL: {
- WasmType type;
- WasmBool mutable_;
+ case WABT_EXTERNAL_KIND_GLOBAL: {
+ WabtType type;
+ WabtBool mutable_;
read_global_header(ctx, &type, &mutable_);
CALLBACK(on_import_global, i, ctx->num_global_imports, type, mutable_);
ctx->num_global_imports++;
@@ -1858,8 +1858,8 @@ static void read_table_section(Context* ctx, uint32_t section_size) {
CALLBACK(on_table_count, ctx->num_tables);
for (i = 0; i < ctx->num_tables; ++i) {
uint32_t table_index = ctx->num_table_imports + i;
- WasmType elem_type;
- WasmLimits elem_limits;
+ WabtType elem_type;
+ WabtLimits elem_limits;
read_table(ctx, &elem_type, &elem_limits);
CALLBACK(on_table, table_index, elem_type, &elem_limits);
}
@@ -1874,7 +1874,7 @@ static void read_memory_section(Context* ctx, uint32_t section_size) {
CALLBACK(on_memory_count, ctx->num_memories);
for (i = 0; i < ctx->num_memories; ++i) {
uint32_t memory_index = ctx->num_memory_imports + i;
- WasmLimits page_limits;
+ WabtLimits page_limits;
read_memory(ctx, &page_limits);
CALLBACK(on_memory, memory_index, &page_limits);
}
@@ -1888,8 +1888,8 @@ static void read_global_section(Context* ctx, uint32_t section_size) {
CALLBACK(on_global_count, ctx->num_globals);
for (i = 0; i < ctx->num_globals; ++i) {
uint32_t global_index = ctx->num_global_imports + i;
- WasmType global_type;
- WasmBool mutable_;
+ WabtType global_type;
+ WabtBool mutable_;
read_global_header(ctx, &global_type, &mutable_);
CALLBACK(begin_global, global_index, global_type, mutable_);
CALLBACK(begin_global_init_expr, global_index);
@@ -1906,7 +1906,7 @@ static void read_export_section(Context* ctx, uint32_t section_size) {
in_u32_leb128(ctx, &ctx->num_exports, "export count");
CALLBACK(on_export_count, ctx->num_exports);
for (i = 0; i < ctx->num_exports; ++i) {
- WasmStringSlice name;
+ WabtStringSlice name;
in_str(ctx, &name, "export item name");
uint8_t external_kind;
@@ -1917,23 +1917,23 @@ static void read_export_section(Context* ctx, uint32_t section_size) {
uint32_t item_index;
in_u32_leb128(ctx, &item_index, "export item index");
switch (external_kind) {
- case WASM_EXTERNAL_KIND_FUNC:
+ case WABT_EXTERNAL_KIND_FUNC:
RAISE_ERROR_UNLESS(item_index < num_total_funcs(ctx),
"invalid export func index: %d", item_index);
break;
- case WASM_EXTERNAL_KIND_TABLE:
+ case WABT_EXTERNAL_KIND_TABLE:
RAISE_ERROR_UNLESS(item_index < num_total_tables(ctx),
"invalid export table index");
break;
- case WASM_EXTERNAL_KIND_MEMORY:
+ case WABT_EXTERNAL_KIND_MEMORY:
RAISE_ERROR_UNLESS(item_index < num_total_memories(ctx),
"invalid export memory index");
break;
- case WASM_EXTERNAL_KIND_GLOBAL:
+ case WABT_EXTERNAL_KIND_GLOBAL:
RAISE_ERROR_UNLESS(item_index < num_total_globals(ctx),
"invalid export global index");
break;
- case WASM_NUM_EXTERNAL_KINDS:
+ case WABT_NUM_EXTERNAL_KINDS:
assert(0);
break;
}
@@ -2006,7 +2006,7 @@ static void read_code_section(Context* ctx, uint32_t section_size) {
for (k = 0; k < num_local_decls; ++k) {
uint32_t num_local_types;
in_u32_leb128(ctx, &num_local_types, "local type count");
- WasmType local_type;
+ WabtType local_type;
in_type(ctx, &local_type, "local type");
RAISE_ERROR_UNLESS(is_concrete_type(local_type),
"expected valid local type");
@@ -2058,25 +2058,25 @@ static void read_sections(Context* ctx) {
if (ctx->read_end > ctx->data_size)
RAISE_ERROR("invalid section size: extends past end");
- if (ctx->last_known_section_code != WASM_NUM_BINARY_SECTIONS &&
- section_code != WASM_BINARY_SECTION_CUSTOM &&
+ if (ctx->last_known_section_code != WABT_NUM_BINARY_SECTIONS &&
+ section_code != WABT_BINARY_SECTION_CUSTOM &&
section_code <= ctx->last_known_section_code) {
RAISE_ERROR("section %s out of order",
- wasm_get_section_name(section_code));
+ wabt_get_section_name(section_code));
}
CALLBACK_CTX(begin_section, section_code, section_size);
#define V(NAME, name, code) \
- case WASM_BINARY_SECTION_##NAME: \
+ case WABT_BINARY_SECTION_##NAME: \
read_##name##_section(ctx, section_size); \
break;
switch (section_code) {
- WASM_FOREACH_BINARY_SECTION(V)
+ WABT_FOREACH_BINARY_SECTION(V)
default:
RAISE_ERROR("invalid section code: %u; max is %u", section_code,
- WASM_NUM_BINARY_SECTIONS - 1);
+ WABT_NUM_BINARY_SECTIONS - 1);
}
#undef V
@@ -2086,27 +2086,27 @@ static void read_sections(Context* ctx) {
ctx->read_end);
}
- if (section_code != WASM_BINARY_SECTION_CUSTOM)
+ if (section_code != WABT_BINARY_SECTION_CUSTOM)
ctx->last_known_section_code = section_code;
}
}
-WasmResult wasm_read_binary(WasmAllocator* allocator,
+WabtResult wabt_read_binary(WabtAllocator* allocator,
const void* data,
size_t size,
- WasmBinaryReader* reader,
+ WabtBinaryReader* reader,
uint32_t num_function_passes,
- const WasmReadBinaryOptions* options) {
+ const WabtReadBinaryOptions* options) {
LoggingContext logging_context;
- WASM_ZERO_MEMORY(logging_context);
+ WABT_ZERO_MEMORY(logging_context);
logging_context.reader = reader;
logging_context.stream = options->log_stream;
- WasmBinaryReader logging_reader = s_logging_binary_reader;
+ WabtBinaryReader logging_reader = s_logging_binary_reader;
logging_reader.user_data = &logging_context;
Context context;
- WASM_ZERO_MEMORY(context);
+ WABT_ZERO_MEMORY(context);
/* all the macros assume a Context* named ctx */
Context* ctx = &context;
ctx->allocator = allocator;
@@ -2114,30 +2114,30 @@ WasmResult wasm_read_binary(WasmAllocator* allocator,
ctx->data_size = ctx->read_end = size;
ctx->reader = options->log_stream ? &logging_reader : reader;
ctx->options = options;
- ctx->last_known_section_code = WASM_NUM_BINARY_SECTIONS;
+ ctx->last_known_section_code = WABT_NUM_BINARY_SECTIONS;
if (setjmp(ctx->error_jmp_buf) == 1) {
destroy_context(ctx);
- return WASM_ERROR;
+ return WABT_ERROR;
}
- wasm_reserve_types(allocator, &ctx->param_types,
+ wabt_reserve_types(allocator, &ctx->param_types,
INITIAL_PARAM_TYPES_CAPACITY);
- wasm_reserve_uint32s(allocator, &ctx->target_depths,
+ wabt_reserve_uint32s(allocator, &ctx->target_depths,
INITIAL_BR_TABLE_TARGET_CAPACITY);
uint32_t magic;
in_u32(ctx, &magic, "magic");
- RAISE_ERROR_UNLESS(magic == WASM_BINARY_MAGIC, "bad magic value");
+ RAISE_ERROR_UNLESS(magic == WABT_BINARY_MAGIC, "bad magic value");
uint32_t version;
in_u32(ctx, &version, "version");
- RAISE_ERROR_UNLESS(version == WASM_BINARY_VERSION,
+ RAISE_ERROR_UNLESS(version == WABT_BINARY_VERSION,
"bad wasm file version: %#x (expected %#x)", version,
- WASM_BINARY_VERSION);
+ WABT_BINARY_VERSION);
CALLBACK(begin_module, version);
read_sections(ctx);
CALLBACK0(end_module);
destroy_context(ctx);
- return WASM_OK;
+ return WABT_OK;
}
diff --git a/src/binary-reader.h b/src/binary-reader.h
index efae1579..b202c4c4 100644
--- a/src/binary-reader.h
+++ b/src/binary-reader.h
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#ifndef WASM_BINARY_READER_H_
-#define WASM_BINARY_READER_H_
+#ifndef WABT_BINARY_READER_H_
+#define WABT_BINARY_READER_H_
#include <stddef.h>
#include <stdint.h>
@@ -23,321 +23,321 @@
#include "binary.h"
#include "common.h"
-struct WasmAllocator;
+struct WabtAllocator;
-#define WASM_READ_BINARY_OPTIONS_DEFAULT \
- { NULL, WASM_FALSE }
+#define WABT_READ_BINARY_OPTIONS_DEFAULT \
+ { NULL, WABT_FALSE }
-typedef struct WasmReadBinaryOptions {
- struct WasmStream* log_stream;
- WasmBool read_debug_names;
-} WasmReadBinaryOptions;
+typedef struct WabtReadBinaryOptions {
+ struct WabtStream* log_stream;
+ WabtBool read_debug_names;
+} WabtReadBinaryOptions;
-typedef struct WasmBinaryReaderContext {
+typedef struct WabtBinaryReaderContext {
const uint8_t* data;
size_t size;
size_t offset;
void* user_data;
-} WasmBinaryReaderContext;
+} WabtBinaryReaderContext;
-typedef struct WasmBinaryReader {
+typedef struct WabtBinaryReader {
void* user_data;
- void (*on_error)(WasmBinaryReaderContext* ctx, const char* message);
+ void (*on_error)(WabtBinaryReaderContext* ctx, const char* message);
/* module */
- WasmResult (*begin_module)(uint32_t version, void* user_data);
- WasmResult (*end_module)(void* user_data);
+ WabtResult (*begin_module)(uint32_t version, void* user_data);
+ WabtResult (*end_module)(void* user_data);
- WasmResult (*begin_section)(WasmBinaryReaderContext* ctx,
- WasmBinarySection section_type,
+ WabtResult (*begin_section)(WabtBinaryReaderContext* ctx,
+ WabtBinarySection section_type,
uint32_t size);
/* custom section */
- WasmResult (*begin_custom_section)(WasmBinaryReaderContext* ctx,
+ WabtResult (*begin_custom_section)(WabtBinaryReaderContext* ctx,
uint32_t size,
- WasmStringSlice section_name);
- WasmResult (*end_custom_section)(WasmBinaryReaderContext* ctx);
+ WabtStringSlice section_name);
+ WabtResult (*end_custom_section)(WabtBinaryReaderContext* ctx);
/* signatures section */
/* TODO(binji): rename to "type" section */
- WasmResult (*begin_signature_section)(WasmBinaryReaderContext* ctx,
+ WabtResult (*begin_signature_section)(WabtBinaryReaderContext* ctx,
uint32_t size);
- WasmResult (*on_signature_count)(uint32_t count, void* user_data);
- WasmResult (*on_signature)(uint32_t index,
+ WabtResult (*on_signature_count)(uint32_t count, void* user_data);
+ WabtResult (*on_signature)(uint32_t index,
uint32_t param_count,
- WasmType* param_types,
+ WabtType* param_types,
uint32_t result_count,
- WasmType* result_types,
+ WabtType* result_types,
void* user_data);
- WasmResult (*end_signature_section)(WasmBinaryReaderContext* ctx);
+ WabtResult (*end_signature_section)(WabtBinaryReaderContext* ctx);
/* import section */
- WasmResult (*begin_import_section)(WasmBinaryReaderContext* ctx,
+ WabtResult (*begin_import_section)(WabtBinaryReaderContext* ctx,
uint32_t size);
- WasmResult (*on_import_count)(uint32_t count, void* user_data);
- WasmResult (*on_import)(uint32_t index,
- WasmStringSlice module_name,
- WasmStringSlice field_name,
+ WabtResult (*on_import_count)(uint32_t count, void* user_data);
+ WabtResult (*on_import)(uint32_t index,
+ WabtStringSlice module_name,
+ WabtStringSlice field_name,
void* user_data);
- WasmResult (*on_import_func)(uint32_t import_index,
+ WabtResult (*on_import_func)(uint32_t import_index,
uint32_t func_index,
uint32_t sig_index,
void* user_data);
- WasmResult (*on_import_table)(uint32_t import_index,
+ WabtResult (*on_import_table)(uint32_t import_index,
uint32_t table_index,
- WasmType elem_type,
- const WasmLimits* elem_limits,
+ WabtType elem_type,
+ const WabtLimits* elem_limits,
void* user_data);
- WasmResult (*on_import_memory)(uint32_t import_index,
+ WabtResult (*on_import_memory)(uint32_t import_index,
uint32_t memory_index,
- const WasmLimits* page_limits,
+ const WabtLimits* page_limits,
void* user_data);
- WasmResult (*on_import_global)(uint32_t import_index,
+ WabtResult (*on_import_global)(uint32_t import_index,
uint32_t global_index,
- WasmType type,
- WasmBool mutable_,
+ WabtType type,
+ WabtBool mutable_,
void* user_data);
- WasmResult (*end_import_section)(WasmBinaryReaderContext* ctx);
+ WabtResult (*end_import_section)(WabtBinaryReaderContext* ctx);
/* function signatures section */
/* TODO(binji): rename to "function" section */
- WasmResult (*begin_function_signatures_section)(WasmBinaryReaderContext* ctx,
+ WabtResult (*begin_function_signatures_section)(WabtBinaryReaderContext* ctx,
uint32_t size);
- WasmResult (*on_function_signatures_count)(uint32_t count, void* user_data);
- WasmResult (*on_function_signature)(uint32_t index,
+ WabtResult (*on_function_signatures_count)(uint32_t count, void* user_data);
+ WabtResult (*on_function_signature)(uint32_t index,
uint32_t sig_index,
void* user_data);
- WasmResult (*end_function_signatures_section)(WasmBinaryReaderContext* ctx);
+ WabtResult (*end_function_signatures_section)(WabtBinaryReaderContext* ctx);
/* table section */
- WasmResult (*begin_table_section)(WasmBinaryReaderContext* ctx,
+ WabtResult (*begin_table_section)(WabtBinaryReaderContext* ctx,
uint32_t size);
- WasmResult (*on_table_count)(uint32_t count, void* user_data);
- WasmResult (*on_table)(uint32_t index,
- WasmType elem_type,
- const WasmLimits* elem_limits,
+ WabtResult (*on_table_count)(uint32_t count, void* user_data);
+ WabtResult (*on_table)(uint32_t index,
+ WabtType elem_type,
+ const WabtLimits* elem_limits,
void* user_data);
- WasmResult (*end_table_section)(WasmBinaryReaderContext* ctx);
+ WabtResult (*end_table_section)(WabtBinaryReaderContext* ctx);
/* memory section */
- WasmResult (*begin_memory_section)(WasmBinaryReaderContext* ctx,
+ WabtResult (*begin_memory_section)(WabtBinaryReaderContext* ctx,
uint32_t size);
- WasmResult (*on_memory_count)(uint32_t count, void* user_data);
- WasmResult (*on_memory)(uint32_t index,
- const WasmLimits* limits,
+ WabtResult (*on_memory_count)(uint32_t count, void* user_data);
+ WabtResult (*on_memory)(uint32_t index,
+ const WabtLimits* limits,
void* user_data);
- WasmResult (*end_memory_section)(WasmBinaryReaderContext* ctx);
+ WabtResult (*end_memory_section)(WabtBinaryReaderContext* ctx);
/* global section */
- WasmResult (*begin_global_section)(WasmBinaryReaderContext* ctx,
+ WabtResult (*begin_global_section)(WabtBinaryReaderContext* ctx,
uint32_t size);
- WasmResult (*on_global_count)(uint32_t count, void* user_data);
- WasmResult (*begin_global)(uint32_t index,
- WasmType type,
- WasmBool mutable_,
+ WabtResult (*on_global_count)(uint32_t count, void* user_data);
+ WabtResult (*begin_global)(uint32_t index,
+ WabtType type,
+ WabtBool mutable_,
void* user_data);
- WasmResult (*begin_global_init_expr)(uint32_t index, void* user_data);
- WasmResult (*end_global_init_expr)(uint32_t index, void* user_data);
- WasmResult (*end_global)(uint32_t index, void* user_data);
- WasmResult (*end_global_section)(WasmBinaryReaderContext* ctx);
+ WabtResult (*begin_global_init_expr)(uint32_t index, void* user_data);
+ WabtResult (*end_global_init_expr)(uint32_t index, void* user_data);
+ WabtResult (*end_global)(uint32_t index, void* user_data);
+ WabtResult (*end_global_section)(WabtBinaryReaderContext* ctx);
/* exports section */
- WasmResult (*begin_export_section)(WasmBinaryReaderContext* ctx,
+ WabtResult (*begin_export_section)(WabtBinaryReaderContext* ctx,
uint32_t size);
- WasmResult (*on_export_count)(uint32_t count, void* user_data);
- WasmResult (*on_export)(uint32_t index,
- WasmExternalKind kind,
+ WabtResult (*on_export_count)(uint32_t count, void* user_data);
+ WabtResult (*on_export)(uint32_t index,
+ WabtExternalKind kind,
uint32_t item_index,
- WasmStringSlice name,
+ WabtStringSlice name,
void* user_data);
- WasmResult (*end_export_section)(WasmBinaryReaderContext* ctx);
+ WabtResult (*end_export_section)(WabtBinaryReaderContext* ctx);
/* start section */
- WasmResult (*begin_start_section)(WasmBinaryReaderContext* ctx,
+ WabtResult (*begin_start_section)(WabtBinaryReaderContext* ctx,
uint32_t size);
- WasmResult (*on_start_function)(uint32_t func_index, void* user_data);
- WasmResult (*end_start_section)(WasmBinaryReaderContext* ctx);
+ WabtResult (*on_start_function)(uint32_t func_index, void* user_data);
+ WabtResult (*end_start_section)(WabtBinaryReaderContext* ctx);
/* function bodies section */
/* TODO(binji): rename to code section */
- WasmResult (*begin_function_bodies_section)(WasmBinaryReaderContext* ctx,
+ WabtResult (*begin_function_bodies_section)(WabtBinaryReaderContext* ctx,
uint32_t size);
- WasmResult (*on_function_bodies_count)(uint32_t count, void* user_data);
- WasmResult (*begin_function_body_pass)(uint32_t index,
+ WabtResult (*on_function_bodies_count)(uint32_t count, void* user_data);
+ WabtResult (*begin_function_body_pass)(uint32_t index,
uint32_t pass,
void* user_data);
- WasmResult (*begin_function_body)(WasmBinaryReaderContext* ctx,
+ WabtResult (*begin_function_body)(WabtBinaryReaderContext* ctx,
uint32_t index);
- WasmResult (*on_local_decl_count)(uint32_t count, void* user_data);
- WasmResult (*on_local_decl)(uint32_t decl_index,
+ WabtResult (*on_local_decl_count)(uint32_t count, void* user_data);
+ WabtResult (*on_local_decl)(uint32_t decl_index,
uint32_t count,
- WasmType type,
+ WabtType type,
void* user_data);
/* function expressions; called between begin_function_body and
end_function_body */
- WasmResult (*on_opcode)(WasmBinaryReaderContext* ctx, WasmOpcode Opcode);
- WasmResult (*on_opcode_bare)(WasmBinaryReaderContext* ctx);
- WasmResult (*on_opcode_uint32)(WasmBinaryReaderContext* ctx, uint32_t value);
- WasmResult (*on_opcode_uint32_uint32)(WasmBinaryReaderContext* ctx,
+ WabtResult (*on_opcode)(WabtBinaryReaderContext* ctx, WabtOpcode Opcode);
+ WabtResult (*on_opcode_bare)(WabtBinaryReaderContext* ctx);
+ WabtResult (*on_opcode_uint32)(WabtBinaryReaderContext* ctx, uint32_t value);
+ WabtResult (*on_opcode_uint32_uint32)(WabtBinaryReaderContext* ctx,
uint32_t value,
uint32_t value2);
- WasmResult (*on_opcode_uint64)(WasmBinaryReaderContext* ctx, uint64_t value);
- WasmResult (*on_opcode_f32)(WasmBinaryReaderContext* ctx, uint32_t value);
- WasmResult (*on_opcode_f64)(WasmBinaryReaderContext* ctx, uint64_t value);
- WasmResult (*on_opcode_block_sig)(WasmBinaryReaderContext* ctx,
+ WabtResult (*on_opcode_uint64)(WabtBinaryReaderContext* ctx, uint64_t value);
+ WabtResult (*on_opcode_f32)(WabtBinaryReaderContext* ctx, uint32_t value);
+ WabtResult (*on_opcode_f64)(WabtBinaryReaderContext* ctx, uint64_t value);
+ WabtResult (*on_opcode_block_sig)(WabtBinaryReaderContext* ctx,
uint32_t num_types,
- WasmType* sig_types);
- WasmResult (*on_binary_expr)(WasmOpcode opcode, void* user_data);
- WasmResult (*on_block_expr)(uint32_t num_types,
- WasmType* sig_types,
+ WabtType* sig_types);
+ WabtResult (*on_binary_expr)(WabtOpcode opcode, void* user_data);
+ WabtResult (*on_block_expr)(uint32_t num_types,
+ WabtType* sig_types,
void* user_data);
- WasmResult (*on_br_expr)(uint32_t depth, void* user_data);
- WasmResult (*on_br_if_expr)(uint32_t depth, void* user_data);
- WasmResult (*on_br_table_expr)(WasmBinaryReaderContext* ctx,
+ WabtResult (*on_br_expr)(uint32_t depth, void* user_data);
+ WabtResult (*on_br_if_expr)(uint32_t depth, void* user_data);
+ WabtResult (*on_br_table_expr)(WabtBinaryReaderContext* ctx,
uint32_t num_targets,
uint32_t* target_depths,
uint32_t default_target_depth);
- WasmResult (*on_call_expr)(uint32_t func_index, void* user_data);
- WasmResult (*on_call_import_expr)(uint32_t import_index, void* user_data);
- WasmResult (*on_call_indirect_expr)(uint32_t sig_index, void* user_data);
- WasmResult (*on_compare_expr)(WasmOpcode opcode, void* user_data);
- WasmResult (*on_convert_expr)(WasmOpcode opcode, void* user_data);
- WasmResult (*on_drop_expr)(void* user_data);
- WasmResult (*on_else_expr)(void* user_data);
- WasmResult (*on_end_expr)(void* user_data);
- WasmResult (*on_f32_const_expr)(uint32_t value_bits, void* user_data);
- WasmResult (*on_f64_const_expr)(uint64_t value_bits, void* user_data);
- WasmResult (*on_get_global_expr)(uint32_t global_index, void* user_data);
- WasmResult (*on_get_local_expr)(uint32_t local_index, void* user_data);
- WasmResult (*on_grow_memory_expr)(void* user_data);
- WasmResult (*on_i32_const_expr)(uint32_t value, void* user_data);
- WasmResult (*on_i64_const_expr)(uint64_t value, void* user_data);
- WasmResult (*on_if_expr)(uint32_t num_types,
- WasmType* sig_types,
+ WabtResult (*on_call_expr)(uint32_t func_index, void* user_data);
+ WabtResult (*on_call_import_expr)(uint32_t import_index, void* user_data);
+ WabtResult (*on_call_indirect_expr)(uint32_t sig_index, void* user_data);
+ WabtResult (*on_compare_expr)(WabtOpcode opcode, void* user_data);
+ WabtResult (*on_convert_expr)(WabtOpcode opcode, void* user_data);
+ WabtResult (*on_drop_expr)(void* user_data);
+ WabtResult (*on_else_expr)(void* user_data);
+ WabtResult (*on_end_expr)(void* user_data);
+ WabtResult (*on_f32_const_expr)(uint32_t value_bits, void* user_data);
+ WabtResult (*on_f64_const_expr)(uint64_t value_bits, void* user_data);
+ WabtResult (*on_get_global_expr)(uint32_t global_index, void* user_data);
+ WabtResult (*on_get_local_expr)(uint32_t local_index, void* user_data);
+ WabtResult (*on_grow_memory_expr)(void* user_data);
+ WabtResult (*on_i32_const_expr)(uint32_t value, void* user_data);
+ WabtResult (*on_i64_const_expr)(uint64_t value, void* user_data);
+ WabtResult (*on_if_expr)(uint32_t num_types,
+ WabtType* sig_types,
void* user_data);
- WasmResult (*on_load_expr)(WasmOpcode opcode,
+ WabtResult (*on_load_expr)(WabtOpcode opcode,
uint32_t alignment_log2,
uint32_t offset,
void* user_data);
- WasmResult (*on_loop_expr)(uint32_t num_types,
- WasmType* sig_types,
+ WabtResult (*on_loop_expr)(uint32_t num_types,
+ WabtType* sig_types,
void* user_data);
- WasmResult (*on_current_memory_expr)(void* user_data);
- WasmResult (*on_nop_expr)(void* user_data);
- WasmResult (*on_return_expr)(void* user_data);
- WasmResult (*on_select_expr)(void* user_data);
- WasmResult (*on_set_global_expr)(uint32_t global_index, void* user_data);
- WasmResult (*on_set_local_expr)(uint32_t local_index, void* user_data);
- WasmResult (*on_store_expr)(WasmOpcode opcode,
+ WabtResult (*on_current_memory_expr)(void* user_data);
+ WabtResult (*on_nop_expr)(void* user_data);
+ WabtResult (*on_return_expr)(void* user_data);
+ WabtResult (*on_select_expr)(void* user_data);
+ WabtResult (*on_set_global_expr)(uint32_t global_index, void* user_data);
+ WabtResult (*on_set_local_expr)(uint32_t local_index, void* user_data);
+ WabtResult (*on_store_expr)(WabtOpcode opcode,
uint32_t alignment_log2,
uint32_t offset,
void* user_data);
- WasmResult (*on_tee_local_expr)(uint32_t local_index, void* user_data);
- WasmResult (*on_unary_expr)(WasmOpcode opcode, void* user_data);
- WasmResult (*on_unreachable_expr)(void* user_data);
- WasmResult (*end_function_body)(uint32_t index, void* user_data);
- WasmResult (*end_function_body_pass)(uint32_t index,
+ WabtResult (*on_tee_local_expr)(uint32_t local_index, void* user_data);
+ WabtResult (*on_unary_expr)(WabtOpcode opcode, void* user_data);
+ WabtResult (*on_unreachable_expr)(void* user_data);
+ WabtResult (*end_function_body)(uint32_t index, void* user_data);
+ WabtResult (*end_function_body_pass)(uint32_t index,
uint32_t pass,
void* user_data);
- WasmResult (*end_function_bodies_section)(WasmBinaryReaderContext* ctx);
+ WabtResult (*end_function_bodies_section)(WabtBinaryReaderContext* ctx);
/* elem section */
- WasmResult (*begin_elem_section)(WasmBinaryReaderContext* ctx, uint32_t size);
- WasmResult (*on_elem_segment_count)(uint32_t count, void* user_data);
- WasmResult (*begin_elem_segment)(uint32_t index,
+ WabtResult (*begin_elem_section)(WabtBinaryReaderContext* ctx, uint32_t size);
+ WabtResult (*on_elem_segment_count)(uint32_t count, void* user_data);
+ WabtResult (*begin_elem_segment)(uint32_t index,
uint32_t table_index,
void* user_data);
- WasmResult (*begin_elem_segment_init_expr)(uint32_t index, void* user_data);
- WasmResult (*end_elem_segment_init_expr)(uint32_t index, void* user_data);
- WasmResult (*on_elem_segment_function_index_count)(
- WasmBinaryReaderContext* ctx,
+ WabtResult (*begin_elem_segment_init_expr)(uint32_t index, void* user_data);
+ WabtResult (*end_elem_segment_init_expr)(uint32_t index, void* user_data);
+ WabtResult (*on_elem_segment_function_index_count)(
+ WabtBinaryReaderContext* ctx,
uint32_t index,
uint32_t count);
- WasmResult (*on_elem_segment_function_index)(uint32_t index,
+ WabtResult (*on_elem_segment_function_index)(uint32_t index,
uint32_t func_index,
void* user_data);
- WasmResult (*end_elem_segment)(uint32_t index, void* user_data);
- WasmResult (*end_elem_section)(WasmBinaryReaderContext* ctx);
+ WabtResult (*end_elem_segment)(uint32_t index, void* user_data);
+ WabtResult (*end_elem_section)(WabtBinaryReaderContext* ctx);
/* data section */
- WasmResult (*begin_data_section)(WasmBinaryReaderContext* ctx, uint32_t size);
- WasmResult (*on_data_segment_count)(uint32_t count, void* user_data);
- WasmResult (*begin_data_segment)(uint32_t index,
+ WabtResult (*begin_data_section)(WabtBinaryReaderContext* ctx, uint32_t size);
+ WabtResult (*on_data_segment_count)(uint32_t count, void* user_data);
+ WabtResult (*begin_data_segment)(uint32_t index,
uint32_t memory_index,
void* user_data);
- WasmResult (*begin_data_segment_init_expr)(uint32_t index, void* user_data);
- WasmResult (*end_data_segment_init_expr)(uint32_t index, void* user_data);
- WasmResult (*on_data_segment_data)(uint32_t index,
+ WabtResult (*begin_data_segment_init_expr)(uint32_t index, void* user_data);
+ WabtResult (*end_data_segment_init_expr)(uint32_t index, void* user_data);
+ WabtResult (*on_data_segment_data)(uint32_t index,
const void* data,
uint32_t size,
void* user_data);
- WasmResult (*end_data_segment)(uint32_t index, void* user_data);
- WasmResult (*end_data_section)(WasmBinaryReaderContext* ctx);
+ WabtResult (*end_data_segment)(uint32_t index, void* user_data);
+ WabtResult (*end_data_section)(WabtBinaryReaderContext* ctx);
/* names section */
- WasmResult (*begin_names_section)(WasmBinaryReaderContext* ctx,
+ WabtResult (*begin_names_section)(WabtBinaryReaderContext* ctx,
uint32_t size);
- WasmResult (*on_function_names_count)(uint32_t count, void* user_data);
- WasmResult (*on_function_name)(uint32_t index,
- WasmStringSlice name,
+ WabtResult (*on_function_names_count)(uint32_t count, void* user_data);
+ WabtResult (*on_function_name)(uint32_t index,
+ WabtStringSlice name,
void* user_data);
- WasmResult (*on_local_names_count)(uint32_t index,
+ WabtResult (*on_local_names_count)(uint32_t index,
uint32_t count,
void* user_data);
- WasmResult (*on_local_name)(uint32_t func_index,
+ WabtResult (*on_local_name)(uint32_t func_index,
uint32_t local_index,
- WasmStringSlice name,
+ WabtStringSlice name,
void* user_data);
- WasmResult (*end_names_section)(WasmBinaryReaderContext* ctx);
+ WabtResult (*end_names_section)(WabtBinaryReaderContext* ctx);
/* names section */
- WasmResult (*begin_reloc_section)(WasmBinaryReaderContext* ctx,
+ WabtResult (*begin_reloc_section)(WabtBinaryReaderContext* ctx,
uint32_t size);
- WasmResult (*on_reloc_count)(uint32_t count,
- WasmBinarySection section_code,
- WasmStringSlice section_name,
+ WabtResult (*on_reloc_count)(uint32_t count,
+ WabtBinarySection section_code,
+ WabtStringSlice section_name,
void* user_data);
- WasmResult (*on_reloc)(WasmRelocType type,
+ WabtResult (*on_reloc)(WabtRelocType type,
uint32_t offset,
void* user_data);
- WasmResult (*end_reloc_section)(WasmBinaryReaderContext* ctx);
+ WabtResult (*end_reloc_section)(WabtBinaryReaderContext* ctx);
/* init_expr - used by elem, data and global sections; these functions are
* only called between calls to begin_*_init_expr and end_*_init_expr */
- WasmResult (*on_init_expr_f32_const_expr)(uint32_t index,
+ WabtResult (*on_init_expr_f32_const_expr)(uint32_t index,
uint32_t value,
void* user_data);
- WasmResult (*on_init_expr_f64_const_expr)(uint32_t index,
+ WabtResult (*on_init_expr_f64_const_expr)(uint32_t index,
uint64_t value,
void* user_data);
- WasmResult (*on_init_expr_get_global_expr)(uint32_t index,
+ WabtResult (*on_init_expr_get_global_expr)(uint32_t index,
uint32_t global_index,
void* user_data);
- WasmResult (*on_init_expr_i32_const_expr)(uint32_t index,
+ WabtResult (*on_init_expr_i32_const_expr)(uint32_t index,
uint32_t value,
void* user_data);
- WasmResult (*on_init_expr_i64_const_expr)(uint32_t index,
+ WabtResult (*on_init_expr_i64_const_expr)(uint32_t index,
uint64_t value,
void* user_data);
-} WasmBinaryReader;
+} WabtBinaryReader;
-WASM_EXTERN_C_BEGIN
-WasmResult wasm_read_binary(struct WasmAllocator* allocator,
+WABT_EXTERN_C_BEGIN
+WabtResult wabt_read_binary(struct WabtAllocator* allocator,
const void* data,
size_t size,
- WasmBinaryReader* reader,
+ WabtBinaryReader* reader,
uint32_t num_function_passes,
- const WasmReadBinaryOptions* options);
+ const WabtReadBinaryOptions* options);
-size_t wasm_read_u32_leb128(const uint8_t* ptr,
+size_t wabt_read_u32_leb128(const uint8_t* ptr,
const uint8_t* end,
uint32_t* out_value);
-size_t wasm_read_i32_leb128(const uint8_t* ptr,
+size_t wabt_read_i32_leb128(const uint8_t* ptr,
const uint8_t* end,
uint32_t* out_value);
-WASM_EXTERN_C_END
+WABT_EXTERN_C_END
-#endif /* WASM_BINARY_READER_H_ */
+#endif /* WABT_BINARY_READER_H_ */
diff --git a/src/binary-writer-spec.c b/src/binary-writer-spec.c
index 7bd0f29d..ff31b396 100644
--- a/src/binary-writer-spec.c
+++ b/src/binary-writer-spec.c
@@ -27,14 +27,14 @@
#include "writer.h"
typedef struct Context {
- WasmAllocator* allocator;
- WasmMemoryWriter json_writer;
- WasmStream json_stream;
- WasmStringSlice source_filename;
- WasmStringSlice module_filename_noext;
- WasmBool write_modules; /* Whether to write the modules files. */
- const WasmWriteBinarySpecOptions* spec_options;
- WasmResult result;
+ WabtAllocator* allocator;
+ WabtMemoryWriter json_writer;
+ WabtStream json_stream;
+ WabtStringSlice source_filename;
+ WabtStringSlice module_filename_noext;
+ WabtBool write_modules; /* Whether to write the modules files. */
+ const WabtWriteBinarySpecOptions* spec_options;
+ WabtResult result;
size_t num_modules;
} Context;
@@ -45,7 +45,7 @@ static void convert_backslash_to_slash(char* s, size_t length) {
s[i] = '/';
}
-static WasmStringSlice strip_extension(const char* s) {
+static WabtStringSlice strip_extension(const char* s) {
/* strip .json or .wasm, but leave other extensions, e.g.:
*
* s = "foo", => "foo"
@@ -54,7 +54,7 @@ static WasmStringSlice strip_extension(const char* s) {
* s = "foo.bar" => "foo.bar"
*/
if (s == NULL) {
- WasmStringSlice result;
+ WabtStringSlice result;
result.start = NULL;
result.length = 0;
return result;
@@ -65,7 +65,7 @@ static WasmStringSlice strip_extension(const char* s) {
if (ext_start == NULL)
ext_start = s + slen;
- WasmStringSlice result;
+ WabtStringSlice result;
result.start = s;
if (strcmp(ext_start, ".json") == 0 || strcmp(ext_start, ".wasm") == 0) {
@@ -76,7 +76,7 @@ static WasmStringSlice strip_extension(const char* s) {
return result;
}
-static WasmStringSlice get_basename(const char* s) {
+static WabtStringSlice get_basename(const char* s) {
/* strip everything up to and including the last slash, e.g.:
*
* s = "/foo/bar/baz", => "baz"
@@ -89,7 +89,7 @@ static WasmStringSlice get_basename(const char* s) {
if (last_slash != NULL)
start = last_slash + 1;
- WasmStringSlice result;
+ WabtStringSlice result;
result.start = start;
result.length = s + slen - start;
return result;
@@ -97,42 +97,42 @@ static WasmStringSlice get_basename(const char* s) {
static char* get_module_filename(Context* ctx) {
size_t buflen = ctx->module_filename_noext.length + 20;
- char* str = wasm_alloc(ctx->allocator, buflen, WASM_DEFAULT_ALIGN);
+ char* str = wabt_alloc(ctx->allocator, buflen, WABT_DEFAULT_ALIGN);
size_t length =
- wasm_snprintf(str, buflen, PRIstringslice ".%" PRIzd ".wasm",
- WASM_PRINTF_STRING_SLICE_ARG(ctx->module_filename_noext),
+ wabt_snprintf(str, buflen, PRIstringslice ".%" PRIzd ".wasm",
+ WABT_PRINTF_STRING_SLICE_ARG(ctx->module_filename_noext),
ctx->num_modules);
convert_backslash_to_slash(str, length);
return str;
}
static void write_string(Context* ctx, const char* s) {
- wasm_writef(&ctx->json_stream, "\"%s\"", s);
+ wabt_writef(&ctx->json_stream, "\"%s\"", s);
}
static void write_key(Context* ctx, const char* key) {
- wasm_writef(&ctx->json_stream, "\"%s\": ", key);
+ wabt_writef(&ctx->json_stream, "\"%s\": ", key);
}
static void write_separator(Context* ctx) {
- wasm_writef(&ctx->json_stream, ", ");
+ wabt_writef(&ctx->json_stream, ", ");
}
-static void write_escaped_string_slice(Context* ctx, WasmStringSlice ss) {
+static void write_escaped_string_slice(Context* ctx, WabtStringSlice ss) {
size_t i;
- wasm_write_char(&ctx->json_stream, '"');
+ wabt_write_char(&ctx->json_stream, '"');
for (i = 0; i < ss.length; ++i) {
uint8_t c = ss.start[i];
if (c < 0x20 || c == '\\' || c == '"') {
- wasm_writef(&ctx->json_stream, "\\u%04x", c);
+ wabt_writef(&ctx->json_stream, "\\u%04x", c);
} else {
- wasm_write_char(&ctx->json_stream, c);
+ wabt_write_char(&ctx->json_stream, c);
}
}
- wasm_write_char(&ctx->json_stream, '"');
+ wabt_write_char(&ctx->json_stream, '"');
}
-static void write_command_type(Context* ctx, const WasmCommand* command) {
+static void write_command_type(Context* ctx, const WabtCommand* command) {
static const char* s_command_names[] = {
"module",
"action",
@@ -147,69 +147,69 @@ static void write_command_type(Context* ctx, const WasmCommand* command) {
"assert_trap",
"assert_exhaustion",
};
- WASM_STATIC_ASSERT(WASM_ARRAY_SIZE(s_command_names) ==
- WASM_NUM_COMMAND_TYPES);
+ WABT_STATIC_ASSERT(WABT_ARRAY_SIZE(s_command_names) ==
+ WABT_NUM_COMMAND_TYPES);
write_key(ctx, "type");
assert(s_command_names[command->type] != NULL);
write_string(ctx, s_command_names[command->type]);
}
-static void write_location(Context* ctx, const WasmLocation* loc) {
+static void write_location(Context* ctx, const WabtLocation* loc) {
write_key(ctx, "line");
- wasm_writef(&ctx->json_stream, "%d", loc->line);
+ wabt_writef(&ctx->json_stream, "%d", loc->line);
}
-static void write_var(Context* ctx, const WasmVar* var) {
- if (var->type == WASM_VAR_TYPE_INDEX)
- wasm_writef(&ctx->json_stream, "\"%" PRIu64 "\"", var->index);
+static void write_var(Context* ctx, const WabtVar* var) {
+ if (var->type == WABT_VAR_TYPE_INDEX)
+ wabt_writef(&ctx->json_stream, "\"%" PRIu64 "\"", var->index);
else
write_escaped_string_slice(ctx, var->name);
}
-static void write_type_object(Context* ctx, WasmType type) {
- wasm_writef(&ctx->json_stream, "{");
+static void write_type_object(Context* ctx, WabtType type) {
+ wabt_writef(&ctx->json_stream, "{");
write_key(ctx, "type");
- write_string(ctx, wasm_get_type_name(type));
- wasm_writef(&ctx->json_stream, "}");
+ write_string(ctx, wabt_get_type_name(type));
+ wabt_writef(&ctx->json_stream, "}");
}
-static void write_const(Context* ctx, const WasmConst* const_) {
- wasm_writef(&ctx->json_stream, "{");
+static void write_const(Context* ctx, const WabtConst* const_) {
+ wabt_writef(&ctx->json_stream, "{");
write_key(ctx, "type");
/* Always write the values as strings, even though they may be representable
* as JSON numbers. This way the formatting is consistent. */
switch (const_->type) {
- case WASM_TYPE_I32:
+ case WABT_TYPE_I32:
write_string(ctx, "i32");
write_separator(ctx);
write_key(ctx, "value");
- wasm_writef(&ctx->json_stream, "\"%u\"", const_->u32);
+ wabt_writef(&ctx->json_stream, "\"%u\"", const_->u32);
break;
- case WASM_TYPE_I64:
+ case WABT_TYPE_I64:
write_string(ctx, "i64");
write_separator(ctx);
write_key(ctx, "value");
- wasm_writef(&ctx->json_stream, "\"%" PRIu64 "\"", const_->u64);
+ wabt_writef(&ctx->json_stream, "\"%" PRIu64 "\"", const_->u64);
break;
- case WASM_TYPE_F32: {
+ case WABT_TYPE_F32: {
/* TODO(binji): write as hex float */
write_string(ctx, "f32");
write_separator(ctx);
write_key(ctx, "value");
- wasm_writef(&ctx->json_stream, "\"%u\"", const_->f32_bits);
+ wabt_writef(&ctx->json_stream, "\"%u\"", const_->f32_bits);
break;
}
- case WASM_TYPE_F64: {
+ case WABT_TYPE_F64: {
/* TODO(binji): write as hex float */
write_string(ctx, "f64");
write_separator(ctx);
write_key(ctx, "value");
- wasm_writef(&ctx->json_stream, "\"%" PRIu64 "\"", const_->f64_bits);
+ wabt_writef(&ctx->json_stream, "\"%" PRIu64 "\"", const_->f64_bits);
break;
}
@@ -217,38 +217,38 @@ static void write_const(Context* ctx, const WasmConst* const_) {
assert(0);
}
- wasm_writef(&ctx->json_stream, "}");
+ wabt_writef(&ctx->json_stream, "}");
}
-static void write_const_vector(Context* ctx, const WasmConstVector* consts) {
- wasm_writef(&ctx->json_stream, "[");
+static void write_const_vector(Context* ctx, const WabtConstVector* consts) {
+ wabt_writef(&ctx->json_stream, "[");
size_t i;
for (i = 0; i < consts->size; ++i) {
- const WasmConst* const_ = &consts->data[i];
+ const WabtConst* const_ = &consts->data[i];
write_const(ctx, const_);
if (i != consts->size - 1)
write_separator(ctx);
}
- wasm_writef(&ctx->json_stream, "]");
+ wabt_writef(&ctx->json_stream, "]");
}
-static void write_action(Context* ctx, const WasmAction* action) {
+static void write_action(Context* ctx, const WabtAction* action) {
write_key(ctx, "action");
- wasm_writef(&ctx->json_stream, "{");
+ wabt_writef(&ctx->json_stream, "{");
write_key(ctx, "type");
- if (action->type == WASM_ACTION_TYPE_INVOKE) {
+ if (action->type == WABT_ACTION_TYPE_INVOKE) {
write_string(ctx, "invoke");
} else {
- assert(action->type == WASM_ACTION_TYPE_GET);
+ assert(action->type == WABT_ACTION_TYPE_GET);
write_string(ctx, "get");
}
write_separator(ctx);
- if (action->module_var.type != WASM_VAR_TYPE_INDEX) {
+ if (action->module_var.type != WABT_VAR_TYPE_INDEX) {
write_key(ctx, "module");
write_var(ctx, &action->module_var);
write_separator(ctx);
}
- if (action->type == WASM_ACTION_TYPE_INVOKE) {
+ if (action->type == WABT_ACTION_TYPE_INVOKE) {
write_key(ctx, "field");
write_escaped_string_slice(ctx, action->invoke.name);
write_separator(ctx);
@@ -258,51 +258,51 @@ static void write_action(Context* ctx, const WasmAction* action) {
write_key(ctx, "field");
write_escaped_string_slice(ctx, action->get.name);
}
- wasm_writef(&ctx->json_stream, "}");
+ wabt_writef(&ctx->json_stream, "}");
}
static void write_action_result_type(Context* ctx,
- WasmScript* script,
- const WasmAction* action) {
- const WasmModule* module =
- wasm_get_module_by_var(script, &action->module_var);
- const WasmExport* export;
- wasm_writef(&ctx->json_stream, "[");
+ WabtScript* script,
+ const WabtAction* action) {
+ const WabtModule* module =
+ wabt_get_module_by_var(script, &action->module_var);
+ const WabtExport* export;
+ wabt_writef(&ctx->json_stream, "[");
switch (action->type) {
- case WASM_ACTION_TYPE_INVOKE: {
- export = wasm_get_export_by_name(module, &action->invoke.name);
- assert(export->kind == WASM_EXTERNAL_KIND_FUNC);
- WasmFunc* func = wasm_get_func_by_var(module, &export->var);
- size_t num_results = wasm_get_num_results(func);
+ case WABT_ACTION_TYPE_INVOKE: {
+ export = wabt_get_export_by_name(module, &action->invoke.name);
+ assert(export->kind == WABT_EXTERNAL_KIND_FUNC);
+ WabtFunc* func = wabt_get_func_by_var(module, &export->var);
+ size_t num_results = wabt_get_num_results(func);
size_t i;
for (i = 0; i < num_results; ++i)
- write_type_object(ctx, wasm_get_result_type(func, i));
+ write_type_object(ctx, wabt_get_result_type(func, i));
break;
}
- case WASM_ACTION_TYPE_GET: {
- export = wasm_get_export_by_name(module, &action->get.name);
- assert(export->kind == WASM_EXTERNAL_KIND_GLOBAL);
- WasmGlobal* global = wasm_get_global_by_var(module, &export->var);
+ case WABT_ACTION_TYPE_GET: {
+ export = wabt_get_export_by_name(module, &action->get.name);
+ assert(export->kind == WABT_EXTERNAL_KIND_GLOBAL);
+ WabtGlobal* global = wabt_get_global_by_var(module, &export->var);
write_type_object(ctx, global->type);
break;
}
}
- wasm_writef(&ctx->json_stream, "]");
+ wabt_writef(&ctx->json_stream, "]");
}
static void write_module(Context* ctx,
char* filename,
- const WasmModule* module) {
- WasmMemoryWriter writer;
- WasmResult result = wasm_init_mem_writer(ctx->allocator, &writer);
- if (WASM_SUCCEEDED(result)) {
- WasmWriteBinaryOptions options = ctx->spec_options->write_binary_options;
- result = wasm_write_binary_module(ctx->allocator, &writer.base, module,
+ const WabtModule* module) {
+ WabtMemoryWriter writer;
+ WabtResult result = wabt_init_mem_writer(ctx->allocator, &writer);
+ if (WABT_SUCCEEDED(result)) {
+ WabtWriteBinaryOptions options = ctx->spec_options->write_binary_options;
+ result = wabt_write_binary_module(ctx->allocator, &writer.base, module,
&options);
- if (WASM_SUCCEEDED(result) && ctx->write_modules)
- result = wasm_write_output_buffer_to_file(&writer.buf, filename);
- wasm_close_mem_writer(&writer);
+ if (WABT_SUCCEEDED(result) && ctx->write_modules)
+ result = wabt_write_output_buffer_to_file(&writer.buf, filename);
+ wabt_close_mem_writer(&writer);
}
ctx->result = result;
@@ -310,27 +310,27 @@ static void write_module(Context* ctx,
static void write_raw_module(Context* ctx,
char* filename,
- const WasmRawModule* raw_module) {
- if (raw_module->type == WASM_RAW_MODULE_TYPE_TEXT) {
+ const WabtRawModule* raw_module) {
+ if (raw_module->type == WABT_RAW_MODULE_TYPE_TEXT) {
write_module(ctx, filename, raw_module->text);
} else if (ctx->write_modules) {
- WasmFileStream stream;
- WasmResult result = wasm_init_file_writer(&stream.writer, filename);
- if (WASM_SUCCEEDED(result)) {
- wasm_init_stream(&stream.base, &stream.writer.base, NULL);
- wasm_write_data(&stream.base, raw_module->binary.data,
+ WabtFileStream stream;
+ WabtResult result = wabt_init_file_writer(&stream.writer, filename);
+ if (WABT_SUCCEEDED(result)) {
+ wabt_init_stream(&stream.base, &stream.writer.base, NULL);
+ wabt_write_data(&stream.base, raw_module->binary.data,
raw_module->binary.size, "");
- wasm_close_file_writer(&stream.writer);
+ wabt_close_file_writer(&stream.writer);
}
ctx->result = result;
}
}
static void write_invalid_module(Context* ctx,
- const WasmRawModule* module,
- WasmStringSlice text) {
+ const WabtRawModule* module,
+ WabtStringSlice text) {
char* filename = get_module_filename(ctx);
- write_location(ctx, wasm_get_raw_module_location(module));
+ write_location(ctx, wabt_get_raw_module_location(module));
write_separator(ctx);
write_key(ctx, "filename");
write_escaped_string_slice(ctx, get_basename(filename));
@@ -338,32 +338,32 @@ static void write_invalid_module(Context* ctx,
write_key(ctx, "text");
write_escaped_string_slice(ctx, text);
write_raw_module(ctx, filename, module);
- wasm_free(ctx->allocator, filename);
+ wabt_free(ctx->allocator, filename);
}
-static void write_commands(Context* ctx, WasmScript* script) {
- wasm_writef(&ctx->json_stream, "{\"source_filename\": ");
+static void write_commands(Context* ctx, WabtScript* script) {
+ wabt_writef(&ctx->json_stream, "{\"source_filename\": ");
write_escaped_string_slice(ctx, ctx->source_filename);
- wasm_writef(&ctx->json_stream, ",\n \"commands\": [\n");
+ wabt_writef(&ctx->json_stream, ",\n \"commands\": [\n");
size_t i;
int last_module_index = -1;
for (i = 0; i < script->commands.size; ++i) {
- WasmCommand* command = &script->commands.data[i];
+ WabtCommand* command = &script->commands.data[i];
- if (command->type == WASM_COMMAND_TYPE_ASSERT_INVALID_NON_BINARY)
+ if (command->type == WABT_COMMAND_TYPE_ASSERT_INVALID_NON_BINARY)
continue;
if (i != 0)
write_separator(ctx);
- wasm_writef(&ctx->json_stream, "\n");
+ wabt_writef(&ctx->json_stream, "\n");
- wasm_writef(&ctx->json_stream, " {");
+ wabt_writef(&ctx->json_stream, " {");
write_command_type(ctx, command);
write_separator(ctx);
switch (command->type) {
- case WASM_COMMAND_TYPE_MODULE: {
- WasmModule* module = &command->module;
+ case WABT_COMMAND_TYPE_MODULE: {
+ WabtModule* module = &command->module;
char* filename = get_module_filename(ctx);
write_location(ctx, &module->loc);
write_separator(ctx);
@@ -375,60 +375,60 @@ static void write_commands(Context* ctx, WasmScript* script) {
write_key(ctx, "filename");
write_escaped_string_slice(ctx, get_basename(filename));
write_module(ctx, filename, module);
- wasm_free(ctx->allocator, filename);
+ wabt_free(ctx->allocator, filename);
ctx->num_modules++;
last_module_index = (int)i;
break;
}
- case WASM_COMMAND_TYPE_ACTION:
+ case WABT_COMMAND_TYPE_ACTION:
write_location(ctx, &command->action.loc);
write_separator(ctx);
write_action(ctx, &command->action);
break;
- case WASM_COMMAND_TYPE_REGISTER:
+ case WABT_COMMAND_TYPE_REGISTER:
write_location(ctx, &command->register_.var.loc);
write_separator(ctx);
- if (command->register_.var.type == WASM_VAR_TYPE_NAME) {
+ if (command->register_.var.type == WABT_VAR_TYPE_NAME) {
write_key(ctx, "name");
write_var(ctx, &command->register_.var);
write_separator(ctx);
} else {
/* If we're not registering by name, then we should only be
* registering the last module. */
- WASM_USE(last_module_index);
+ WABT_USE(last_module_index);
assert(command->register_.var.index == last_module_index);
}
write_key(ctx, "as");
write_escaped_string_slice(ctx, command->register_.module_name);
break;
- case WASM_COMMAND_TYPE_ASSERT_MALFORMED:
+ case WABT_COMMAND_TYPE_ASSERT_MALFORMED:
write_invalid_module(ctx, &command->assert_malformed.module,
command->assert_malformed.text);
ctx->num_modules++;
break;
- case WASM_COMMAND_TYPE_ASSERT_INVALID:
+ case WABT_COMMAND_TYPE_ASSERT_INVALID:
write_invalid_module(ctx, &command->assert_invalid.module,
command->assert_invalid.text);
ctx->num_modules++;
break;
- case WASM_COMMAND_TYPE_ASSERT_UNLINKABLE:
+ case WABT_COMMAND_TYPE_ASSERT_UNLINKABLE:
write_invalid_module(ctx, &command->assert_unlinkable.module,
command->assert_unlinkable.text);
ctx->num_modules++;
break;
- case WASM_COMMAND_TYPE_ASSERT_UNINSTANTIABLE:
+ case WABT_COMMAND_TYPE_ASSERT_UNINSTANTIABLE:
write_invalid_module(ctx, &command->assert_uninstantiable.module,
command->assert_uninstantiable.text);
ctx->num_modules++;
break;
- case WASM_COMMAND_TYPE_ASSERT_RETURN:
+ case WABT_COMMAND_TYPE_ASSERT_RETURN:
write_location(ctx, &command->assert_return.action.loc);
write_separator(ctx);
write_action(ctx, &command->assert_return.action);
@@ -437,7 +437,7 @@ static void write_commands(Context* ctx, WasmScript* script) {
write_const_vector(ctx, &command->assert_return.expected);
break;
- case WASM_COMMAND_TYPE_ASSERT_RETURN_NAN:
+ case WABT_COMMAND_TYPE_ASSERT_RETURN_NAN:
write_location(ctx, &command->assert_return_nan.action.loc);
write_separator(ctx);
write_action(ctx, &command->assert_return_nan.action);
@@ -447,7 +447,7 @@ static void write_commands(Context* ctx, WasmScript* script) {
&command->assert_return_nan.action);
break;
- case WASM_COMMAND_TYPE_ASSERT_TRAP:
+ case WABT_COMMAND_TYPE_ASSERT_TRAP:
write_location(ctx, &command->assert_trap.action.loc);
write_separator(ctx);
write_action(ctx, &command->assert_trap.action);
@@ -456,34 +456,34 @@ static void write_commands(Context* ctx, WasmScript* script) {
write_escaped_string_slice(ctx, command->assert_trap.text);
break;
- case WASM_COMMAND_TYPE_ASSERT_EXHAUSTION:
+ case WABT_COMMAND_TYPE_ASSERT_EXHAUSTION:
write_location(ctx, &command->assert_trap.action.loc);
write_separator(ctx);
write_action(ctx, &command->assert_trap.action);
break;
- case WASM_COMMAND_TYPE_ASSERT_INVALID_NON_BINARY:
- case WASM_NUM_COMMAND_TYPES:
+ case WABT_COMMAND_TYPE_ASSERT_INVALID_NON_BINARY:
+ case WABT_NUM_COMMAND_TYPES:
assert(0);
break;
}
- wasm_writef(&ctx->json_stream, "}");
+ wabt_writef(&ctx->json_stream, "}");
}
- wasm_writef(&ctx->json_stream, "]}\n");
+ wabt_writef(&ctx->json_stream, "]}\n");
}
-WasmResult wasm_write_binary_spec_script(
- WasmAllocator* allocator,
- WasmScript* script,
+WabtResult wabt_write_binary_spec_script(
+ WabtAllocator* allocator,
+ WabtScript* script,
const char* source_filename,
- const WasmWriteBinarySpecOptions* spec_options) {
+ const WabtWriteBinarySpecOptions* spec_options) {
assert(source_filename);
Context ctx;
- WASM_ZERO_MEMORY(ctx);
+ WABT_ZERO_MEMORY(ctx);
ctx.allocator = allocator;
ctx.spec_options = spec_options;
- ctx.result = WASM_OK;
+ ctx.result = WABT_OK;
ctx.source_filename.start = source_filename;
ctx.source_filename.length = strlen(source_filename);
ctx.module_filename_noext = strip_extension(
@@ -491,15 +491,15 @@ WasmResult wasm_write_binary_spec_script(
: source_filename);
ctx.write_modules = ctx.spec_options->json_filename != NULL;
- WasmResult result = wasm_init_mem_writer(ctx.allocator, &ctx.json_writer);
- if (WASM_SUCCEEDED(result)) {
- wasm_init_stream(&ctx.json_stream, &ctx.json_writer.base, NULL);
+ WabtResult result = wabt_init_mem_writer(ctx.allocator, &ctx.json_writer);
+ if (WABT_SUCCEEDED(result)) {
+ wabt_init_stream(&ctx.json_stream, &ctx.json_writer.base, NULL);
write_commands(&ctx, script);
if (ctx.spec_options->json_filename) {
- wasm_write_output_buffer_to_file(&ctx.json_writer.buf,
+ wabt_write_output_buffer_to_file(&ctx.json_writer.buf,
ctx.spec_options->json_filename);
}
- wasm_close_mem_writer(&ctx.json_writer);
+ wabt_close_mem_writer(&ctx.json_writer);
}
return ctx.result;
diff --git a/src/binary-writer-spec.h b/src/binary-writer-spec.h
index 78785245..5a9dea90 100644
--- a/src/binary-writer-spec.h
+++ b/src/binary-writer-spec.h
@@ -14,29 +14,29 @@
* limitations under the License.
*/
-#ifndef WASM_BINARY_WRITER_SPEC_H_
-#define WASM_BINARY_WRITER_SPEC_H_
+#ifndef WABT_BINARY_WRITER_SPEC_H_
+#define WABT_BINARY_WRITER_SPEC_H_
#include "ast.h"
#include "binary-writer.h"
#include "common.h"
-struct WasmAllocator;
-struct WasmWriter;
+struct WabtAllocator;
+struct WabtWriter;
-#define WASM_WRITE_BINARY_SPEC_OPTIONS_DEFAULT \
- { NULL, WASM_WRITE_BINARY_OPTIONS_DEFAULT }
+#define WABT_WRITE_BINARY_SPEC_OPTIONS_DEFAULT \
+ { NULL, WABT_WRITE_BINARY_OPTIONS_DEFAULT }
-typedef struct WasmWriteBinarySpecOptions {
+typedef struct WabtWriteBinarySpecOptions {
const char* json_filename;
- WasmWriteBinaryOptions write_binary_options;
-} WasmWriteBinarySpecOptions;
+ WabtWriteBinaryOptions write_binary_options;
+} WabtWriteBinarySpecOptions;
-WASM_EXTERN_C_BEGIN
-WasmResult wasm_write_binary_spec_script(struct WasmAllocator*,
- struct WasmScript*,
+WABT_EXTERN_C_BEGIN
+WabtResult wabt_write_binary_spec_script(struct WabtAllocator*,
+ struct WabtScript*,
const char* source_filename,
- const WasmWriteBinarySpecOptions*);
-WASM_EXTERN_C_END
+ const WabtWriteBinarySpecOptions*);
+WABT_EXTERN_C_END
-#endif /* WASM_BINARY_WRITER_SPEC_H_ */
+#endif /* WABT_BINARY_WRITER_SPEC_H_ */
diff --git a/src/binary-writer.c b/src/binary-writer.c
index 5d007400..82d5b430 100644
--- a/src/binary-writer.c
+++ b/src/binary-writer.c
@@ -41,36 +41,36 @@ static const size_t LEB_SECTION_SIZE_GUESS = 1;
fprintf(stderr, "%s:%d: allocation failed\n", __FILE__, __LINE__)
typedef struct Reloc {
- WasmRelocType type;
+ WabtRelocType type;
size_t offset;
} Reloc;
-WASM_DEFINE_VECTOR(reloc, Reloc);
+WABT_DEFINE_VECTOR(reloc, Reloc);
typedef struct RelocSection {
const char* name;
- WasmBinarySection section_code;
+ WabtBinarySection section_code;
RelocVector relocations;
} RelocSection;
-WASM_DEFINE_VECTOR(reloc_section, RelocSection);
+WABT_DEFINE_VECTOR(reloc_section, RelocSection);
typedef struct Context {
- WasmAllocator* allocator;
- WasmStream stream;
- WasmStream* log_stream;
- const WasmWriteBinaryOptions* options;
+ WabtAllocator* allocator;
+ WabtStream stream;
+ WabtStream* log_stream;
+ const WabtWriteBinaryOptions* options;
RelocSectionVector reloc_sections;
RelocSection* current_reloc_section;
size_t last_section_offset;
size_t last_section_leb_size_guess;
- WasmBinarySection last_section_type;
+ WabtBinarySection last_section_type;
size_t last_section_payload_offset;
} Context;
-void wasm_destroy_reloc_section(WasmAllocator* allocator,
+void wabt_destroy_reloc_section(WabtAllocator* allocator,
RelocSection* reloc_section) {
- wasm_destroy_reloc_vector(allocator, &reloc_section->relocations);
+ wabt_destroy_reloc_vector(allocator, &reloc_section->relocations);
}
static uint8_t log2_u32(uint32_t x) {
@@ -85,9 +85,9 @@ static uint8_t log2_u32(uint32_t x) {
static void write_header(Context* ctx, const char* name, int index) {
if (ctx->log_stream) {
if (index == PRINT_HEADER_NO_INDEX) {
- wasm_writef(ctx->log_stream, "; %s\n", name);
+ wabt_writef(ctx->log_stream, "; %s\n", name);
} else {
- wasm_writef(ctx->log_stream, "; %s %d\n", name, index);
+ wabt_writef(ctx->log_stream, "; %s %d\n", name, index);
}
}
}
@@ -104,15 +104,15 @@ static void write_header(Context* ctx, const char* name, int index) {
} \
} while (1)
-uint32_t wasm_u32_leb128_length(uint32_t value) {
- uint8_t data[MAX_U32_LEB128_BYTES] WASM_UNUSED;
+uint32_t wabt_u32_leb128_length(uint32_t value) {
+ uint8_t data[MAX_U32_LEB128_BYTES] WABT_UNUSED;
uint32_t i = 0;
LEB128_LOOP_UNTIL(value == 0);
return i;
}
/* returns the length of the leb128 */
-uint32_t wasm_write_u32_leb128_at(WasmStream* stream,
+uint32_t wabt_write_u32_leb128_at(WabtStream* stream,
uint32_t offset,
uint32_t value,
const char* desc) {
@@ -120,11 +120,11 @@ uint32_t wasm_write_u32_leb128_at(WasmStream* stream,
uint32_t i = 0;
LEB128_LOOP_UNTIL(value == 0);
uint32_t length = i;
- wasm_write_data_at(stream, offset, data, length, WASM_DONT_PRINT_CHARS, desc);
+ wabt_write_data_at(stream, offset, data, length, WABT_DONT_PRINT_CHARS, desc);
return length;
}
-uint32_t wasm_write_fixed_u32_leb128_raw(uint8_t* data,
+uint32_t wabt_write_fixed_u32_leb128_raw(uint8_t* data,
uint8_t* end,
uint32_t value) {
if (end - data < MAX_U32_LEB128_BYTES)
@@ -137,34 +137,34 @@ uint32_t wasm_write_fixed_u32_leb128_raw(uint8_t* data,
return MAX_U32_LEB128_BYTES;
}
-uint32_t wasm_write_fixed_u32_leb128_at(WasmStream* stream,
+uint32_t wabt_write_fixed_u32_leb128_at(WabtStream* stream,
uint32_t offset,
uint32_t value,
const char* desc) {
uint8_t data[MAX_U32_LEB128_BYTES];
uint32_t length =
- wasm_write_fixed_u32_leb128_raw(data, data + MAX_U32_LEB128_BYTES, value);
- wasm_write_data_at(stream, offset, data, length, WASM_DONT_PRINT_CHARS, desc);
+ wabt_write_fixed_u32_leb128_raw(data, data + MAX_U32_LEB128_BYTES, value);
+ wabt_write_data_at(stream, offset, data, length, WABT_DONT_PRINT_CHARS, desc);
return length;
}
-void wasm_write_u32_leb128(WasmStream* stream,
+void wabt_write_u32_leb128(WabtStream* stream,
uint32_t value,
const char* desc) {
uint32_t length =
- wasm_write_u32_leb128_at(stream, stream->offset, value, desc);
+ wabt_write_u32_leb128_at(stream, stream->offset, value, desc);
stream->offset += length;
}
-void wasm_write_fixed_u32_leb128(WasmStream* stream,
+void wabt_write_fixed_u32_leb128(WabtStream* stream,
uint32_t value,
const char* desc) {
uint32_t length =
- wasm_write_fixed_u32_leb128_at(stream, stream->offset, value, desc);
+ wabt_write_fixed_u32_leb128_at(stream, stream->offset, value, desc);
stream->offset += length;
}
-void wasm_write_i32_leb128(WasmStream* stream,
+void wabt_write_i32_leb128(WabtStream* stream,
int32_t value,
const char* desc) {
uint8_t data[MAX_U32_LEB128_BYTES];
@@ -175,12 +175,12 @@ void wasm_write_i32_leb128(WasmStream* stream,
LEB128_LOOP_UNTIL(value == 0 && !(byte & 0x40));
uint32_t length = i;
- wasm_write_data_at(stream, stream->offset, data, length,
- WASM_DONT_PRINT_CHARS, desc);
+ wabt_write_data_at(stream, stream->offset, data, length,
+ WABT_DONT_PRINT_CHARS, desc);
stream->offset += length;
}
-static void write_i64_leb128(WasmStream* stream,
+static void write_i64_leb128(WabtStream* stream,
int64_t value,
const char* desc) {
uint8_t data[MAX_U64_LEB128_BYTES];
@@ -191,8 +191,8 @@ static void write_i64_leb128(WasmStream* stream,
LEB128_LOOP_UNTIL(value == 0 && !(byte & 0x40));
int length = i;
- wasm_write_data_at(stream, stream->offset, data, length,
- WASM_DONT_PRINT_CHARS, desc);
+ wabt_write_data_at(stream, stream->offset, data, length,
+ WABT_DONT_PRINT_CHARS, desc);
stream->offset += length;
}
@@ -216,7 +216,7 @@ static uint32_t write_u32_leb128_space(Context* ctx,
uint32_t result = ctx->stream.offset;
uint32_t bytes_to_write =
ctx->options->canonicalize_lebs ? leb_size_guess : MAX_U32_LEB128_BYTES;
- wasm_write_data(&ctx->stream, data, bytes_to_write, desc);
+ wabt_write_data(&ctx->stream, data, bytes_to_write, desc);
return result;
}
@@ -230,55 +230,55 @@ static void write_fixup_u32_leb128_size(Context* ctx,
if (leb_size != leb_size_guess) {
uint32_t src_offset = offset + leb_size_guess;
uint32_t dst_offset = offset + leb_size;
- wasm_move_data(&ctx->stream, dst_offset, src_offset, size);
+ wabt_move_data(&ctx->stream, dst_offset, src_offset, size);
}
- wasm_write_u32_leb128_at(&ctx->stream, offset, size, desc);
+ wabt_write_u32_leb128_at(&ctx->stream, offset, size, desc);
ctx->stream.offset += leb_size - leb_size_guess;
} else {
uint32_t size = ctx->stream.offset - offset - MAX_U32_LEB128_BYTES;
- wasm_write_fixed_u32_leb128_at(&ctx->stream, offset, size, desc);
+ wabt_write_fixed_u32_leb128_at(&ctx->stream, offset, size, desc);
}
}
-void wasm_write_str(WasmStream* stream,
+void wabt_write_str(WabtStream* stream,
const char* s,
size_t length,
- WasmPrintChars print_chars,
+ WabtPrintChars print_chars,
const char* desc) {
- wasm_write_u32_leb128(stream, length, "string length");
- wasm_write_data_at(stream, stream->offset, s, length, print_chars, desc);
+ wabt_write_u32_leb128(stream, length, "string length");
+ wabt_write_data_at(stream, stream->offset, s, length, print_chars, desc);
stream->offset += length;
}
-void wasm_write_opcode(WasmStream* stream, uint8_t opcode) {
- wasm_write_u8(stream, opcode, wasm_get_opcode_name(opcode));
+void wabt_write_opcode(WabtStream* stream, uint8_t opcode) {
+ wabt_write_u8(stream, opcode, wabt_get_opcode_name(opcode));
}
-void wasm_write_type(WasmStream* stream, WasmType type) {
- wasm_write_i32_leb128(stream, type, wasm_get_type_name(type));
+void wabt_write_type(WabtStream* stream, WabtType type) {
+ wabt_write_i32_leb128(stream, type, wabt_get_type_name(type));
}
-static void write_inline_signature_type(WasmStream* stream,
- const WasmBlockSignature* sig) {
+static void write_inline_signature_type(WabtStream* stream,
+ const WabtBlockSignature* sig) {
if (sig->size == 0) {
- wasm_write_type(stream, WASM_TYPE_VOID);
+ wabt_write_type(stream, WABT_TYPE_VOID);
} else if (sig->size == 1) {
- wasm_write_type(stream, sig->data[0]);
+ wabt_write_type(stream, sig->data[0]);
} else {
/* this is currently unrepresentable */
- wasm_write_u8(stream, 0xff, "INVALID INLINE SIGNATURE");
+ wabt_write_u8(stream, 0xff, "INVALID INLINE SIGNATURE");
}
}
static void begin_known_section(Context* ctx,
- WasmBinarySection section_code,
+ WabtBinarySection section_code,
size_t leb_size_guess) {
assert(ctx->last_section_leb_size_guess == 0);
char desc[100];
- wasm_snprintf(desc, sizeof(desc), "section \"%s\" (%u)",
- wasm_get_section_name(section_code), section_code);
+ wabt_snprintf(desc, sizeof(desc), "section \"%s\" (%u)",
+ wabt_get_section_name(section_code), section_code);
write_header(ctx, desc, PRINT_HEADER_NO_INDEX);
- wasm_write_u8(&ctx->stream, section_code, "section code");
+ wabt_write_u8(&ctx->stream, section_code, "section code");
ctx->last_section_type = section_code;
ctx->last_section_leb_size_guess = leb_size_guess;
ctx->last_section_offset =
@@ -291,16 +291,16 @@ static void begin_custom_section(Context* ctx,
size_t leb_size_guess) {
assert(ctx->last_section_leb_size_guess == 0);
char desc[100];
- wasm_snprintf(desc, sizeof(desc), "section \"%s\"", name);
+ wabt_snprintf(desc, sizeof(desc), "section \"%s\"", name);
write_header(ctx, desc, PRINT_HEADER_NO_INDEX);
- wasm_write_u8(&ctx->stream, WASM_BINARY_SECTION_CUSTOM,
+ wabt_write_u8(&ctx->stream, WABT_BINARY_SECTION_CUSTOM,
"custom section code");
- ctx->last_section_type = WASM_BINARY_SECTION_CUSTOM;
+ ctx->last_section_type = WABT_BINARY_SECTION_CUSTOM;
ctx->last_section_leb_size_guess = leb_size_guess;
ctx->last_section_offset =
write_u32_leb128_space(ctx, leb_size_guess, "section size (guess)");
ctx->last_section_payload_offset = ctx->stream.offset;
- wasm_write_str(&ctx->stream, name, strlen(name), WASM_PRINT_CHARS,
+ wabt_write_str(&ctx->stream, name, strlen(name), WABT_PRINT_CHARS,
"custom section name");
}
@@ -312,29 +312,29 @@ static void end_section(Context* ctx) {
ctx->last_section_leb_size_guess = 0;
}
-static uint32_t get_label_var_depth(Context* ctx, const WasmVar* var) {
- assert(var->type == WASM_VAR_TYPE_INDEX);
+static uint32_t get_label_var_depth(Context* ctx, const WabtVar* var) {
+ assert(var->type == WABT_VAR_TYPE_INDEX);
return var->index;
}
static void write_expr_list(Context* ctx,
- const WasmModule* module,
- const WasmFunc* func,
- const WasmExpr* first_expr);
+ const WabtModule* module,
+ const WabtFunc* func,
+ const WabtExpr* first_expr);
-static void add_reloc(Context* ctx, WasmRelocType reloc_type) {
+static void add_reloc(Context* ctx, WabtRelocType reloc_type) {
// Add a new reloc section if needed
if (!ctx->current_reloc_section ||
ctx->current_reloc_section->section_code != ctx->last_section_type) {
ctx->current_reloc_section =
- wasm_append_reloc_section(ctx->allocator, &ctx->reloc_sections);
+ wabt_append_reloc_section(ctx->allocator, &ctx->reloc_sections);
ctx->current_reloc_section->name =
- wasm_get_section_name(ctx->last_section_type);
+ wabt_get_section_name(ctx->last_section_type);
ctx->current_reloc_section->section_code = ctx->last_section_type;
}
// Add a new relocation to the curent reloc section
- Reloc* r = wasm_append_reloc(ctx->allocator,
+ Reloc* r = wabt_append_reloc(ctx->allocator,
&ctx->current_reloc_section->relocations);
r->type = reloc_type;
r->offset = ctx->stream.offset - ctx->last_section_payload_offset;
@@ -343,233 +343,233 @@ static void add_reloc(Context* ctx, WasmRelocType reloc_type) {
static void write_u32_leb128_with_reloc(Context* ctx,
uint32_t value,
const char* desc,
- WasmRelocType reloc_type) {
+ WabtRelocType reloc_type) {
if (ctx->options->relocatable) {
add_reloc(ctx, reloc_type);
- wasm_write_fixed_u32_leb128(&ctx->stream, value, desc);
+ wabt_write_fixed_u32_leb128(&ctx->stream, value, desc);
} else {
- wasm_write_u32_leb128(&ctx->stream, value, desc);
+ wabt_write_u32_leb128(&ctx->stream, value, desc);
}
}
static void write_expr(Context* ctx,
- const WasmModule* module,
- const WasmFunc* func,
- const WasmExpr* expr) {
+ const WabtModule* module,
+ const WabtFunc* func,
+ const WabtExpr* expr) {
switch (expr->type) {
- case WASM_EXPR_TYPE_BINARY:
- wasm_write_opcode(&ctx->stream, expr->binary.opcode);
+ case WABT_EXPR_TYPE_BINARY:
+ wabt_write_opcode(&ctx->stream, expr->binary.opcode);
break;
- case WASM_EXPR_TYPE_BLOCK:
- wasm_write_opcode(&ctx->stream, WASM_OPCODE_BLOCK);
+ case WABT_EXPR_TYPE_BLOCK:
+ wabt_write_opcode(&ctx->stream, WABT_OPCODE_BLOCK);
write_inline_signature_type(&ctx->stream, &expr->block.sig);
write_expr_list(ctx, module, func, expr->block.first);
- wasm_write_opcode(&ctx->stream, WASM_OPCODE_END);
+ wabt_write_opcode(&ctx->stream, WABT_OPCODE_END);
break;
- case WASM_EXPR_TYPE_BR:
- wasm_write_opcode(&ctx->stream, WASM_OPCODE_BR);
- wasm_write_u32_leb128(
+ case WABT_EXPR_TYPE_BR:
+ wabt_write_opcode(&ctx->stream, WABT_OPCODE_BR);
+ wabt_write_u32_leb128(
&ctx->stream, get_label_var_depth(ctx, &expr->br.var), "break depth");
break;
- case WASM_EXPR_TYPE_BR_IF:
- wasm_write_opcode(&ctx->stream, WASM_OPCODE_BR_IF);
- wasm_write_u32_leb128(&ctx->stream,
+ case WABT_EXPR_TYPE_BR_IF:
+ wabt_write_opcode(&ctx->stream, WABT_OPCODE_BR_IF);
+ wabt_write_u32_leb128(&ctx->stream,
get_label_var_depth(ctx, &expr->br_if.var),
"break depth");
break;
- case WASM_EXPR_TYPE_BR_TABLE: {
- wasm_write_opcode(&ctx->stream, WASM_OPCODE_BR_TABLE);
- wasm_write_u32_leb128(&ctx->stream, expr->br_table.targets.size,
+ case WABT_EXPR_TYPE_BR_TABLE: {
+ wabt_write_opcode(&ctx->stream, WABT_OPCODE_BR_TABLE);
+ wabt_write_u32_leb128(&ctx->stream, expr->br_table.targets.size,
"num targets");
size_t i;
uint32_t depth;
for (i = 0; i < expr->br_table.targets.size; ++i) {
depth = get_label_var_depth(ctx, &expr->br_table.targets.data[i]);
- wasm_write_u32_leb128(&ctx->stream, depth, "break depth");
+ wabt_write_u32_leb128(&ctx->stream, depth, "break depth");
}
depth = get_label_var_depth(ctx, &expr->br_table.default_target);
- wasm_write_u32_leb128(&ctx->stream, depth, "break depth for default");
+ wabt_write_u32_leb128(&ctx->stream, depth, "break depth for default");
break;
}
- case WASM_EXPR_TYPE_CALL: {
- int index = wasm_get_func_index_by_var(module, &expr->call.var);
- wasm_write_opcode(&ctx->stream, WASM_OPCODE_CALL);
+ case WABT_EXPR_TYPE_CALL: {
+ int index = wabt_get_func_index_by_var(module, &expr->call.var);
+ wabt_write_opcode(&ctx->stream, WABT_OPCODE_CALL);
write_u32_leb128_with_reloc(ctx, index, "function index",
- WASM_RELOC_FUNC_INDEX_LEB);
+ WABT_RELOC_FUNC_INDEX_LEB);
break;
}
- case WASM_EXPR_TYPE_CALL_INDIRECT: {
+ case WABT_EXPR_TYPE_CALL_INDIRECT: {
int index =
- wasm_get_func_type_index_by_var(module, &expr->call_indirect.var);
- wasm_write_opcode(&ctx->stream, WASM_OPCODE_CALL_INDIRECT);
- wasm_write_u32_leb128(&ctx->stream, index, "signature index");
- wasm_write_u32_leb128(&ctx->stream, 0, "call_indirect reserved");
+ wabt_get_func_type_index_by_var(module, &expr->call_indirect.var);
+ wabt_write_opcode(&ctx->stream, WABT_OPCODE_CALL_INDIRECT);
+ wabt_write_u32_leb128(&ctx->stream, index, "signature index");
+ wabt_write_u32_leb128(&ctx->stream, 0, "call_indirect reserved");
break;
}
- case WASM_EXPR_TYPE_COMPARE:
- wasm_write_opcode(&ctx->stream, expr->compare.opcode);
+ case WABT_EXPR_TYPE_COMPARE:
+ wabt_write_opcode(&ctx->stream, expr->compare.opcode);
break;
- case WASM_EXPR_TYPE_CONST:
+ case WABT_EXPR_TYPE_CONST:
switch (expr->const_.type) {
- case WASM_TYPE_I32: {
- wasm_write_opcode(&ctx->stream, WASM_OPCODE_I32_CONST);
- wasm_write_i32_leb128(&ctx->stream, (int32_t)expr->const_.u32,
+ case WABT_TYPE_I32: {
+ wabt_write_opcode(&ctx->stream, WABT_OPCODE_I32_CONST);
+ wabt_write_i32_leb128(&ctx->stream, (int32_t)expr->const_.u32,
"i32 literal");
break;
}
- case WASM_TYPE_I64:
- wasm_write_opcode(&ctx->stream, WASM_OPCODE_I64_CONST);
+ case WABT_TYPE_I64:
+ wabt_write_opcode(&ctx->stream, WABT_OPCODE_I64_CONST);
write_i64_leb128(&ctx->stream, (int64_t)expr->const_.u64,
"i64 literal");
break;
- case WASM_TYPE_F32:
- wasm_write_opcode(&ctx->stream, WASM_OPCODE_F32_CONST);
- wasm_write_u32(&ctx->stream, expr->const_.f32_bits, "f32 literal");
+ case WABT_TYPE_F32:
+ wabt_write_opcode(&ctx->stream, WABT_OPCODE_F32_CONST);
+ wabt_write_u32(&ctx->stream, expr->const_.f32_bits, "f32 literal");
break;
- case WASM_TYPE_F64:
- wasm_write_opcode(&ctx->stream, WASM_OPCODE_F64_CONST);
- wasm_write_u64(&ctx->stream, expr->const_.f64_bits, "f64 literal");
+ case WABT_TYPE_F64:
+ wabt_write_opcode(&ctx->stream, WABT_OPCODE_F64_CONST);
+ wabt_write_u64(&ctx->stream, expr->const_.f64_bits, "f64 literal");
break;
default:
assert(0);
}
break;
- case WASM_EXPR_TYPE_CONVERT:
- wasm_write_opcode(&ctx->stream, expr->convert.opcode);
+ case WABT_EXPR_TYPE_CONVERT:
+ wabt_write_opcode(&ctx->stream, expr->convert.opcode);
break;
- case WASM_EXPR_TYPE_CURRENT_MEMORY:
- wasm_write_opcode(&ctx->stream, WASM_OPCODE_CURRENT_MEMORY);
- wasm_write_u32_leb128(&ctx->stream, 0, "current_memory reserved");
+ case WABT_EXPR_TYPE_CURRENT_MEMORY:
+ wabt_write_opcode(&ctx->stream, WABT_OPCODE_CURRENT_MEMORY);
+ wabt_write_u32_leb128(&ctx->stream, 0, "current_memory reserved");
break;
- case WASM_EXPR_TYPE_DROP:
- wasm_write_opcode(&ctx->stream, WASM_OPCODE_DROP);
+ case WABT_EXPR_TYPE_DROP:
+ wabt_write_opcode(&ctx->stream, WABT_OPCODE_DROP);
break;
- case WASM_EXPR_TYPE_GET_GLOBAL: {
- int index = wasm_get_global_index_by_var(module, &expr->get_global.var);
- wasm_write_opcode(&ctx->stream, WASM_OPCODE_GET_GLOBAL);
+ case WABT_EXPR_TYPE_GET_GLOBAL: {
+ int index = wabt_get_global_index_by_var(module, &expr->get_global.var);
+ wabt_write_opcode(&ctx->stream, WABT_OPCODE_GET_GLOBAL);
write_u32_leb128_with_reloc(ctx, index, "global index",
- WASM_RELOC_GLOBAL_INDEX_LEB);
+ WABT_RELOC_GLOBAL_INDEX_LEB);
break;
}
- case WASM_EXPR_TYPE_GET_LOCAL: {
- int index = wasm_get_local_index_by_var(func, &expr->get_local.var);
- wasm_write_opcode(&ctx->stream, WASM_OPCODE_GET_LOCAL);
- wasm_write_u32_leb128(&ctx->stream, index, "local index");
+ case WABT_EXPR_TYPE_GET_LOCAL: {
+ int index = wabt_get_local_index_by_var(func, &expr->get_local.var);
+ wabt_write_opcode(&ctx->stream, WABT_OPCODE_GET_LOCAL);
+ wabt_write_u32_leb128(&ctx->stream, index, "local index");
break;
}
- case WASM_EXPR_TYPE_GROW_MEMORY:
- wasm_write_opcode(&ctx->stream, WASM_OPCODE_GROW_MEMORY);
- wasm_write_u32_leb128(&ctx->stream, 0, "grow_memory reserved");
+ case WABT_EXPR_TYPE_GROW_MEMORY:
+ wabt_write_opcode(&ctx->stream, WABT_OPCODE_GROW_MEMORY);
+ wabt_write_u32_leb128(&ctx->stream, 0, "grow_memory reserved");
break;
- case WASM_EXPR_TYPE_IF:
- wasm_write_opcode(&ctx->stream, WASM_OPCODE_IF);
+ case WABT_EXPR_TYPE_IF:
+ wabt_write_opcode(&ctx->stream, WABT_OPCODE_IF);
write_inline_signature_type(&ctx->stream, &expr->if_.true_.sig);
write_expr_list(ctx, module, func, expr->if_.true_.first);
if (expr->if_.false_) {
- wasm_write_opcode(&ctx->stream, WASM_OPCODE_ELSE);
+ wabt_write_opcode(&ctx->stream, WABT_OPCODE_ELSE);
write_expr_list(ctx, module, func, expr->if_.false_);
}
- wasm_write_opcode(&ctx->stream, WASM_OPCODE_END);
+ wabt_write_opcode(&ctx->stream, WABT_OPCODE_END);
break;
- case WASM_EXPR_TYPE_LOAD: {
- wasm_write_opcode(&ctx->stream, expr->load.opcode);
+ case WABT_EXPR_TYPE_LOAD: {
+ wabt_write_opcode(&ctx->stream, expr->load.opcode);
uint32_t align =
- wasm_get_opcode_alignment(expr->load.opcode, expr->load.align);
- wasm_write_u8(&ctx->stream, log2_u32(align), "alignment");
- wasm_write_u32_leb128(&ctx->stream, (uint32_t)expr->load.offset,
+ wabt_get_opcode_alignment(expr->load.opcode, expr->load.align);
+ wabt_write_u8(&ctx->stream, log2_u32(align), "alignment");
+ wabt_write_u32_leb128(&ctx->stream, (uint32_t)expr->load.offset,
"load offset");
break;
}
- case WASM_EXPR_TYPE_LOOP:
- wasm_write_opcode(&ctx->stream, WASM_OPCODE_LOOP);
+ case WABT_EXPR_TYPE_LOOP:
+ wabt_write_opcode(&ctx->stream, WABT_OPCODE_LOOP);
write_inline_signature_type(&ctx->stream, &expr->loop.sig);
write_expr_list(ctx, module, func, expr->loop.first);
- wasm_write_opcode(&ctx->stream, WASM_OPCODE_END);
+ wabt_write_opcode(&ctx->stream, WABT_OPCODE_END);
break;
- case WASM_EXPR_TYPE_NOP:
- wasm_write_opcode(&ctx->stream, WASM_OPCODE_NOP);
+ case WABT_EXPR_TYPE_NOP:
+ wabt_write_opcode(&ctx->stream, WABT_OPCODE_NOP);
break;
- case WASM_EXPR_TYPE_RETURN:
- wasm_write_opcode(&ctx->stream, WASM_OPCODE_RETURN);
+ case WABT_EXPR_TYPE_RETURN:
+ wabt_write_opcode(&ctx->stream, WABT_OPCODE_RETURN);
break;
- case WASM_EXPR_TYPE_SELECT:
- wasm_write_opcode(&ctx->stream, WASM_OPCODE_SELECT);
+ case WABT_EXPR_TYPE_SELECT:
+ wabt_write_opcode(&ctx->stream, WABT_OPCODE_SELECT);
break;
- case WASM_EXPR_TYPE_SET_GLOBAL: {
- int index = wasm_get_global_index_by_var(module, &expr->get_global.var);
- wasm_write_opcode(&ctx->stream, WASM_OPCODE_SET_GLOBAL);
+ case WABT_EXPR_TYPE_SET_GLOBAL: {
+ int index = wabt_get_global_index_by_var(module, &expr->get_global.var);
+ wabt_write_opcode(&ctx->stream, WABT_OPCODE_SET_GLOBAL);
write_u32_leb128_with_reloc(ctx, index, "global index",
- WASM_RELOC_GLOBAL_INDEX_LEB);
+ WABT_RELOC_GLOBAL_INDEX_LEB);
break;
}
- case WASM_EXPR_TYPE_SET_LOCAL: {
- int index = wasm_get_local_index_by_var(func, &expr->get_local.var);
- wasm_write_opcode(&ctx->stream, WASM_OPCODE_SET_LOCAL);
- wasm_write_u32_leb128(&ctx->stream, index, "local index");
+ case WABT_EXPR_TYPE_SET_LOCAL: {
+ int index = wabt_get_local_index_by_var(func, &expr->get_local.var);
+ wabt_write_opcode(&ctx->stream, WABT_OPCODE_SET_LOCAL);
+ wabt_write_u32_leb128(&ctx->stream, index, "local index");
break;
}
- case WASM_EXPR_TYPE_STORE: {
- wasm_write_opcode(&ctx->stream, expr->store.opcode);
+ case WABT_EXPR_TYPE_STORE: {
+ wabt_write_opcode(&ctx->stream, expr->store.opcode);
uint32_t align =
- wasm_get_opcode_alignment(expr->store.opcode, expr->store.align);
- wasm_write_u8(&ctx->stream, log2_u32(align), "alignment");
- wasm_write_u32_leb128(&ctx->stream, (uint32_t)expr->store.offset,
+ wabt_get_opcode_alignment(expr->store.opcode, expr->store.align);
+ wabt_write_u8(&ctx->stream, log2_u32(align), "alignment");
+ wabt_write_u32_leb128(&ctx->stream, (uint32_t)expr->store.offset,
"store offset");
break;
}
- case WASM_EXPR_TYPE_TEE_LOCAL: {
- int index = wasm_get_local_index_by_var(func, &expr->get_local.var);
- wasm_write_opcode(&ctx->stream, WASM_OPCODE_TEE_LOCAL);
- wasm_write_u32_leb128(&ctx->stream, index, "local index");
+ case WABT_EXPR_TYPE_TEE_LOCAL: {
+ int index = wabt_get_local_index_by_var(func, &expr->get_local.var);
+ wabt_write_opcode(&ctx->stream, WABT_OPCODE_TEE_LOCAL);
+ wabt_write_u32_leb128(&ctx->stream, index, "local index");
break;
}
- case WASM_EXPR_TYPE_UNARY:
- wasm_write_opcode(&ctx->stream, expr->unary.opcode);
+ case WABT_EXPR_TYPE_UNARY:
+ wabt_write_opcode(&ctx->stream, expr->unary.opcode);
break;
- case WASM_EXPR_TYPE_UNREACHABLE:
- wasm_write_opcode(&ctx->stream, WASM_OPCODE_UNREACHABLE);
+ case WABT_EXPR_TYPE_UNREACHABLE:
+ wabt_write_opcode(&ctx->stream, WABT_OPCODE_UNREACHABLE);
break;
}
}
static void write_expr_list(Context* ctx,
- const WasmModule* module,
- const WasmFunc* func,
- const WasmExpr* first) {
- const WasmExpr* expr;
+ const WabtModule* module,
+ const WabtFunc* func,
+ const WabtExpr* first) {
+ const WabtExpr* expr;
for (expr = first; expr; expr = expr->next)
write_expr(ctx, module, func, expr);
}
static void write_init_expr(Context* ctx,
- const WasmModule* module,
- const WasmExpr* expr) {
+ const WabtModule* module,
+ const WabtExpr* expr) {
if (expr)
write_expr_list(ctx, module, NULL, expr);
- wasm_write_opcode(&ctx->stream, WASM_OPCODE_END);
+ wabt_write_opcode(&ctx->stream, WABT_OPCODE_END);
}
static void write_func_locals(Context* ctx,
- const WasmModule* module,
- const WasmFunc* func,
- const WasmTypeVector* local_types) {
+ const WabtModule* module,
+ const WabtFunc* func,
+ const WabtTypeVector* local_types) {
if (local_types->size == 0) {
- wasm_write_u32_leb128(&ctx->stream, 0, "local decl count");
+ wabt_write_u32_leb128(&ctx->stream, 0, "local decl count");
return;
}
- uint32_t num_params = wasm_get_num_params(func);
+ uint32_t num_params = wabt_get_num_params(func);
#define FIRST_LOCAL_INDEX (num_params)
#define LAST_LOCAL_INDEX (num_params + local_types->size)
#define GET_LOCAL_TYPE(x) (local_types->data[x - num_params])
/* loop through once to count the number of local declaration runs */
- WasmType current_type = GET_LOCAL_TYPE(FIRST_LOCAL_INDEX);
+ WabtType current_type = GET_LOCAL_TYPE(FIRST_LOCAL_INDEX);
uint32_t local_decl_count = 1;
uint32_t i;
for (i = FIRST_LOCAL_INDEX + 1; i < LAST_LOCAL_INDEX; ++i) {
- WasmType type = GET_LOCAL_TYPE(i);
+ WabtType type = GET_LOCAL_TYPE(i);
if (current_type != type) {
local_decl_count++;
current_type = type;
@@ -577,17 +577,17 @@ static void write_func_locals(Context* ctx,
}
/* loop through again to write everything out */
- wasm_write_u32_leb128(&ctx->stream, local_decl_count, "local decl count");
+ wabt_write_u32_leb128(&ctx->stream, local_decl_count, "local decl count");
current_type = GET_LOCAL_TYPE(FIRST_LOCAL_INDEX);
uint32_t local_type_count = 1;
for (i = FIRST_LOCAL_INDEX + 1; i <= LAST_LOCAL_INDEX; ++i) {
/* loop through an extra time to catch the final type transition */
- WasmType type = i == LAST_LOCAL_INDEX ? WASM_TYPE_VOID : GET_LOCAL_TYPE(i);
+ WabtType type = i == LAST_LOCAL_INDEX ? WABT_TYPE_VOID : GET_LOCAL_TYPE(i);
if (current_type == type) {
local_type_count++;
} else {
- wasm_write_u32_leb128(&ctx->stream, local_type_count, "local type count");
- wasm_write_type(&ctx->stream, current_type);
+ wabt_write_u32_leb128(&ctx->stream, local_type_count, "local type count");
+ wabt_write_type(&ctx->stream, current_type);
local_type_count = 1;
current_type = type;
}
@@ -595,113 +595,113 @@ static void write_func_locals(Context* ctx,
}
static void write_func(Context* ctx,
- const WasmModule* module,
- const WasmFunc* func) {
+ const WabtModule* module,
+ const WabtFunc* func) {
write_func_locals(ctx, module, func, &func->local_types);
write_expr_list(ctx, module, func, func->first_expr);
- wasm_write_opcode(&ctx->stream, WASM_OPCODE_END);
+ wabt_write_opcode(&ctx->stream, WABT_OPCODE_END);
}
-void wasm_write_limits(WasmStream* stream, const WasmLimits* limits) {
- uint32_t flags = limits->has_max ? WASM_BINARY_LIMITS_HAS_MAX_FLAG : 0;
- wasm_write_u32_leb128(stream, flags, "limits: flags");
- wasm_write_u32_leb128(stream, limits->initial, "limits: initial");
+void wabt_write_limits(WabtStream* stream, const WabtLimits* limits) {
+ uint32_t flags = limits->has_max ? WABT_BINARY_LIMITS_HAS_MAX_FLAG : 0;
+ wabt_write_u32_leb128(stream, flags, "limits: flags");
+ wabt_write_u32_leb128(stream, limits->initial, "limits: initial");
if (limits->has_max)
- wasm_write_u32_leb128(stream, limits->max, "limits: max");
+ wabt_write_u32_leb128(stream, limits->max, "limits: max");
}
-static void write_table(Context* ctx, const WasmTable* table) {
- wasm_write_type(&ctx->stream, WASM_TYPE_ANYFUNC);
- wasm_write_limits(&ctx->stream, &table->elem_limits);
+static void write_table(Context* ctx, const WabtTable* table) {
+ wabt_write_type(&ctx->stream, WABT_TYPE_ANYFUNC);
+ wabt_write_limits(&ctx->stream, &table->elem_limits);
}
-static void write_memory(Context* ctx, const WasmMemory* memory) {
- wasm_write_limits(&ctx->stream, &memory->page_limits);
+static void write_memory(Context* ctx, const WabtMemory* memory) {
+ wabt_write_limits(&ctx->stream, &memory->page_limits);
}
-static void write_global_header(Context* ctx, const WasmGlobal* global) {
- wasm_write_type(&ctx->stream, global->type);
- wasm_write_u8(&ctx->stream, global->mutable_, "global mutability");
+static void write_global_header(Context* ctx, const WabtGlobal* global) {
+ wabt_write_type(&ctx->stream, global->type);
+ wabt_write_u8(&ctx->stream, global->mutable_, "global mutability");
}
static void write_reloc_section(Context* ctx, RelocSection* reloc_section) {
char section_name[128];
- sprintf(section_name, "%s.%s", WASM_BINARY_SECTION_RELOC,
+ sprintf(section_name, "%s.%s", WABT_BINARY_SECTION_RELOC,
reloc_section->name);
begin_custom_section(ctx, section_name, LEB_SECTION_SIZE_GUESS);
- wasm_write_u32_leb128(&ctx->stream, reloc_section->section_code,
+ wabt_write_u32_leb128(&ctx->stream, reloc_section->section_code,
"reloc section type");
RelocVector* relocs = &reloc_section->relocations;
- wasm_write_u32_leb128(&ctx->stream, relocs->size, "num relocs");
+ wabt_write_u32_leb128(&ctx->stream, relocs->size, "num relocs");
size_t i;
for (i = 0; i < relocs->size; i++) {
- wasm_write_u32_leb128(&ctx->stream, relocs->data[i].type, "reloc type");
- wasm_write_u32_leb128(&ctx->stream, relocs->data[i].offset, "reloc offset");
+ wabt_write_u32_leb128(&ctx->stream, relocs->data[i].type, "reloc type");
+ wabt_write_u32_leb128(&ctx->stream, relocs->data[i].offset, "reloc offset");
}
end_section(ctx);
}
-static WasmResult write_module(Context* ctx, const WasmModule* module) {
+static WabtResult write_module(Context* ctx, const WabtModule* module) {
size_t i;
- wasm_write_u32(&ctx->stream, WASM_BINARY_MAGIC, "WASM_BINARY_MAGIC");
- wasm_write_u32(&ctx->stream, WASM_BINARY_VERSION, "WASM_BINARY_VERSION");
+ wabt_write_u32(&ctx->stream, WABT_BINARY_MAGIC, "WASM_BINARY_MAGIC");
+ wabt_write_u32(&ctx->stream, WABT_BINARY_VERSION, "WASM_BINARY_VERSION");
if (module->func_types.size) {
- begin_known_section(ctx, WASM_BINARY_SECTION_TYPE, LEB_SECTION_SIZE_GUESS);
- wasm_write_u32_leb128(&ctx->stream, module->func_types.size, "num types");
+ begin_known_section(ctx, WABT_BINARY_SECTION_TYPE, LEB_SECTION_SIZE_GUESS);
+ wabt_write_u32_leb128(&ctx->stream, module->func_types.size, "num types");
for (i = 0; i < module->func_types.size; ++i) {
- const WasmFuncType* func_type = module->func_types.data[i];
- const WasmFuncSignature* sig = &func_type->sig;
+ const WabtFuncType* func_type = module->func_types.data[i];
+ const WabtFuncSignature* sig = &func_type->sig;
write_header(ctx, "type", i);
- wasm_write_type(&ctx->stream, WASM_TYPE_FUNC);
+ wabt_write_type(&ctx->stream, WABT_TYPE_FUNC);
size_t j;
uint32_t num_params = sig->param_types.size;
uint32_t num_results = sig->result_types.size;
- wasm_write_u32_leb128(&ctx->stream, num_params, "num params");
+ wabt_write_u32_leb128(&ctx->stream, num_params, "num params");
for (j = 0; j < num_params; ++j)
- wasm_write_type(&ctx->stream, sig->param_types.data[j]);
+ wabt_write_type(&ctx->stream, sig->param_types.data[j]);
- wasm_write_u32_leb128(&ctx->stream, num_results, "num results");
+ wabt_write_u32_leb128(&ctx->stream, num_results, "num results");
for (j = 0; j < num_results; ++j)
- wasm_write_type(&ctx->stream, sig->result_types.data[j]);
+ wabt_write_type(&ctx->stream, sig->result_types.data[j]);
}
end_section(ctx);
}
if (module->imports.size) {
- begin_known_section(ctx, WASM_BINARY_SECTION_IMPORT,
+ begin_known_section(ctx, WABT_BINARY_SECTION_IMPORT,
LEB_SECTION_SIZE_GUESS);
- wasm_write_u32_leb128(&ctx->stream, module->imports.size, "num imports");
+ wabt_write_u32_leb128(&ctx->stream, module->imports.size, "num imports");
for (i = 0; i < module->imports.size; ++i) {
- const WasmImport* import = module->imports.data[i];
+ const WabtImport* import = module->imports.data[i];
write_header(ctx, "import header", i);
- wasm_write_str(&ctx->stream, import->module_name.start,
- import->module_name.length, WASM_PRINT_CHARS,
+ wabt_write_str(&ctx->stream, import->module_name.start,
+ import->module_name.length, WABT_PRINT_CHARS,
"import module name");
- wasm_write_str(&ctx->stream, import->field_name.start,
- import->field_name.length, WASM_PRINT_CHARS,
+ wabt_write_str(&ctx->stream, import->field_name.start,
+ import->field_name.length, WABT_PRINT_CHARS,
"import field name");
- wasm_write_u8(&ctx->stream, import->kind, "import kind");
+ wabt_write_u8(&ctx->stream, import->kind, "import kind");
switch (import->kind) {
- case WASM_EXTERNAL_KIND_FUNC:
- wasm_write_u32_leb128(&ctx->stream, wasm_get_func_type_index_by_decl(
+ case WABT_EXTERNAL_KIND_FUNC:
+ wabt_write_u32_leb128(&ctx->stream, wabt_get_func_type_index_by_decl(
module, &import->func.decl),
"import signature index");
break;
- case WASM_EXTERNAL_KIND_TABLE:
+ case WABT_EXTERNAL_KIND_TABLE:
write_table(ctx, &import->table);
break;
- case WASM_EXTERNAL_KIND_MEMORY:
+ case WABT_EXTERNAL_KIND_MEMORY:
write_memory(ctx, &import->memory);
break;
- case WASM_EXTERNAL_KIND_GLOBAL:
+ case WABT_EXTERNAL_KIND_GLOBAL:
write_global_header(ctx, &import->global);
break;
- case WASM_NUM_EXTERNAL_KINDS:
+ case WABT_NUM_EXTERNAL_KINDS:
assert(0);
break;
}
@@ -712,17 +712,17 @@ static WasmResult write_module(Context* ctx, const WasmModule* module) {
assert(module->funcs.size >= module->num_func_imports);
uint32_t num_funcs = module->funcs.size - module->num_func_imports;
if (num_funcs) {
- begin_known_section(ctx, WASM_BINARY_SECTION_FUNCTION,
+ begin_known_section(ctx, WABT_BINARY_SECTION_FUNCTION,
LEB_SECTION_SIZE_GUESS);
- wasm_write_u32_leb128(&ctx->stream, num_funcs, "num functions");
+ wabt_write_u32_leb128(&ctx->stream, num_funcs, "num functions");
for (i = 0; i < num_funcs; ++i) {
- const WasmFunc* func = module->funcs.data[i + module->num_func_imports];
+ const WabtFunc* func = module->funcs.data[i + module->num_func_imports];
char desc[100];
- wasm_snprintf(desc, sizeof(desc), "function %" PRIzd " signature index",
+ wabt_snprintf(desc, sizeof(desc), "function %" PRIzd " signature index",
i);
- wasm_write_u32_leb128(
- &ctx->stream, wasm_get_func_type_index_by_decl(module, &func->decl),
+ wabt_write_u32_leb128(
+ &ctx->stream, wabt_get_func_type_index_by_decl(module, &func->decl),
desc);
}
end_section(ctx);
@@ -731,10 +731,10 @@ static WasmResult write_module(Context* ctx, const WasmModule* module) {
assert(module->tables.size >= module->num_table_imports);
uint32_t num_tables = module->tables.size - module->num_table_imports;
if (num_tables) {
- begin_known_section(ctx, WASM_BINARY_SECTION_TABLE, LEB_SECTION_SIZE_GUESS);
- wasm_write_u32_leb128(&ctx->stream, num_tables, "num tables");
+ begin_known_section(ctx, WABT_BINARY_SECTION_TABLE, LEB_SECTION_SIZE_GUESS);
+ wabt_write_u32_leb128(&ctx->stream, num_tables, "num tables");
for (i = 0; i < num_tables; ++i) {
- const WasmTable* table =
+ const WabtTable* table =
module->tables.data[i + module->num_table_imports];
write_header(ctx, "table", i);
write_table(ctx, table);
@@ -745,11 +745,11 @@ static WasmResult write_module(Context* ctx, const WasmModule* module) {
assert(module->memories.size >= module->num_memory_imports);
uint32_t num_memories = module->memories.size - module->num_memory_imports;
if (num_memories) {
- begin_known_section(ctx, WASM_BINARY_SECTION_MEMORY,
+ begin_known_section(ctx, WABT_BINARY_SECTION_MEMORY,
LEB_SECTION_SIZE_GUESS);
- wasm_write_u32_leb128(&ctx->stream, num_memories, "num memories");
+ wabt_write_u32_leb128(&ctx->stream, num_memories, "num memories");
for (i = 0; i < num_memories; ++i) {
- const WasmMemory* memory =
+ const WabtMemory* memory =
module->memories.data[i + module->num_memory_imports];
write_header(ctx, "memory", i);
write_memory(ctx, memory);
@@ -760,12 +760,12 @@ static WasmResult write_module(Context* ctx, const WasmModule* module) {
assert(module->globals.size >= module->num_global_imports);
uint32_t num_globals = module->globals.size - module->num_global_imports;
if (num_globals) {
- begin_known_section(ctx, WASM_BINARY_SECTION_GLOBAL,
+ begin_known_section(ctx, WABT_BINARY_SECTION_GLOBAL,
LEB_SECTION_SIZE_GUESS);
- wasm_write_u32_leb128(&ctx->stream, num_globals, "num globals");
+ wabt_write_u32_leb128(&ctx->stream, num_globals, "num globals");
for (i = 0; i < num_globals; ++i) {
- const WasmGlobal* global =
+ const WabtGlobal* global =
module->globals.data[i + module->num_global_imports];
write_global_header(ctx, global);
write_init_expr(ctx, module, global->init_expr);
@@ -774,37 +774,37 @@ static WasmResult write_module(Context* ctx, const WasmModule* module) {
}
if (module->exports.size) {
- begin_known_section(ctx, WASM_BINARY_SECTION_EXPORT,
+ begin_known_section(ctx, WABT_BINARY_SECTION_EXPORT,
LEB_SECTION_SIZE_GUESS);
- wasm_write_u32_leb128(&ctx->stream, module->exports.size, "num exports");
+ wabt_write_u32_leb128(&ctx->stream, module->exports.size, "num exports");
for (i = 0; i < module->exports.size; ++i) {
- const WasmExport* export = module->exports.data[i];
- wasm_write_str(&ctx->stream, export->name.start, export->name.length,
- WASM_PRINT_CHARS, "export name");
- wasm_write_u8(&ctx->stream, export->kind, "export kind");
+ const WabtExport* export = module->exports.data[i];
+ wabt_write_str(&ctx->stream, export->name.start, export->name.length,
+ WABT_PRINT_CHARS, "export name");
+ wabt_write_u8(&ctx->stream, export->kind, "export kind");
switch (export->kind) {
- case WASM_EXTERNAL_KIND_FUNC: {
- int index = wasm_get_func_index_by_var(module, &export->var);
- wasm_write_u32_leb128(&ctx->stream, index, "export func index");
+ case WABT_EXTERNAL_KIND_FUNC: {
+ int index = wabt_get_func_index_by_var(module, &export->var);
+ wabt_write_u32_leb128(&ctx->stream, index, "export func index");
break;
}
- case WASM_EXTERNAL_KIND_TABLE: {
- int index = wasm_get_table_index_by_var(module, &export->var);
- wasm_write_u32_leb128(&ctx->stream, index, "export table index");
+ case WABT_EXTERNAL_KIND_TABLE: {
+ int index = wabt_get_table_index_by_var(module, &export->var);
+ wabt_write_u32_leb128(&ctx->stream, index, "export table index");
break;
}
- case WASM_EXTERNAL_KIND_MEMORY: {
- int index = wasm_get_memory_index_by_var(module, &export->var);
- wasm_write_u32_leb128(&ctx->stream, index, "export memory index");
+ case WABT_EXTERNAL_KIND_MEMORY: {
+ int index = wabt_get_memory_index_by_var(module, &export->var);
+ wabt_write_u32_leb128(&ctx->stream, index, "export memory index");
break;
}
- case WASM_EXTERNAL_KIND_GLOBAL: {
- int index = wasm_get_global_index_by_var(module, &export->var);
- wasm_write_u32_leb128(&ctx->stream, index, "export global index");
+ case WABT_EXTERNAL_KIND_GLOBAL: {
+ int index = wabt_get_global_index_by_var(module, &export->var);
+ wabt_write_u32_leb128(&ctx->stream, index, "export global index");
break;
}
- case WASM_NUM_EXTERNAL_KINDS:
+ case WABT_NUM_EXTERNAL_KINDS:
assert(0);
break;
}
@@ -813,45 +813,45 @@ static WasmResult write_module(Context* ctx, const WasmModule* module) {
}
if (module->start) {
- int start_func_index = wasm_get_func_index_by_var(module, module->start);
+ int start_func_index = wabt_get_func_index_by_var(module, module->start);
if (start_func_index != -1) {
- begin_known_section(ctx, WASM_BINARY_SECTION_START,
+ begin_known_section(ctx, WABT_BINARY_SECTION_START,
LEB_SECTION_SIZE_GUESS);
- wasm_write_u32_leb128(&ctx->stream, start_func_index, "start func index");
+ wabt_write_u32_leb128(&ctx->stream, start_func_index, "start func index");
end_section(ctx);
}
}
if (module->elem_segments.size) {
- begin_known_section(ctx, WASM_BINARY_SECTION_ELEM, LEB_SECTION_SIZE_GUESS);
- wasm_write_u32_leb128(&ctx->stream, module->elem_segments.size,
+ begin_known_section(ctx, WABT_BINARY_SECTION_ELEM, LEB_SECTION_SIZE_GUESS);
+ wabt_write_u32_leb128(&ctx->stream, module->elem_segments.size,
"num elem segments");
for (i = 0; i < module->elem_segments.size; ++i) {
- WasmElemSegment* segment = module->elem_segments.data[i];
+ WabtElemSegment* segment = module->elem_segments.data[i];
int table_index =
- wasm_get_table_index_by_var(module, &segment->table_var);
+ wabt_get_table_index_by_var(module, &segment->table_var);
write_header(ctx, "elem segment header", i);
- wasm_write_u32_leb128(&ctx->stream, table_index, "table index");
+ wabt_write_u32_leb128(&ctx->stream, table_index, "table index");
write_init_expr(ctx, module, segment->offset);
- wasm_write_u32_leb128(&ctx->stream, segment->vars.size,
+ wabt_write_u32_leb128(&ctx->stream, segment->vars.size,
"num function indices");
size_t j;
for (j = 0; j < segment->vars.size; ++j) {
- int index = wasm_get_func_index_by_var(module, &segment->vars.data[j]);
+ int index = wabt_get_func_index_by_var(module, &segment->vars.data[j]);
write_u32_leb128_with_reloc(ctx, index, "function index",
- WASM_RELOC_FUNC_INDEX_LEB);
+ WABT_RELOC_FUNC_INDEX_LEB);
}
}
end_section(ctx);
}
if (num_funcs) {
- begin_known_section(ctx, WASM_BINARY_SECTION_CODE, LEB_SECTION_SIZE_GUESS);
- wasm_write_u32_leb128(&ctx->stream, num_funcs, "num functions");
+ begin_known_section(ctx, WABT_BINARY_SECTION_CODE, LEB_SECTION_SIZE_GUESS);
+ wabt_write_u32_leb128(&ctx->stream, num_funcs, "num functions");
for (i = 0; i < num_funcs; ++i) {
write_header(ctx, "function body", i);
- const WasmFunc* func = module->funcs.data[i + module->num_func_imports];
+ const WabtFunc* func = module->funcs.data[i + module->num_func_imports];
/* TODO(binji): better guess of the size of the function body section */
const uint32_t leb_size_guess = 1;
@@ -865,91 +865,91 @@ static WasmResult write_module(Context* ctx, const WasmModule* module) {
}
if (module->data_segments.size) {
- begin_known_section(ctx, WASM_BINARY_SECTION_DATA, LEB_SECTION_SIZE_GUESS);
- wasm_write_u32_leb128(&ctx->stream, module->data_segments.size,
+ begin_known_section(ctx, WABT_BINARY_SECTION_DATA, LEB_SECTION_SIZE_GUESS);
+ wabt_write_u32_leb128(&ctx->stream, module->data_segments.size,
"num data segments");
for (i = 0; i < module->data_segments.size; ++i) {
- const WasmDataSegment* segment = module->data_segments.data[i];
+ const WabtDataSegment* segment = module->data_segments.data[i];
write_header(ctx, "data segment header", i);
int memory_index =
- wasm_get_memory_index_by_var(module, &segment->memory_var);
- wasm_write_u32_leb128(&ctx->stream, memory_index, "memory index");
+ wabt_get_memory_index_by_var(module, &segment->memory_var);
+ wabt_write_u32_leb128(&ctx->stream, memory_index, "memory index");
write_init_expr(ctx, module, segment->offset);
- wasm_write_u32_leb128(&ctx->stream, segment->size, "data segment size");
+ wabt_write_u32_leb128(&ctx->stream, segment->size, "data segment size");
write_header(ctx, "data segment data", i);
- wasm_write_data(&ctx->stream, segment->data, segment->size,
+ wabt_write_data(&ctx->stream, segment->data, segment->size,
"data segment data");
}
end_section(ctx);
}
if (ctx->options->write_debug_names) {
- WasmStringSliceVector index_to_name;
- WASM_ZERO_MEMORY(index_to_name);
+ WabtStringSliceVector index_to_name;
+ WABT_ZERO_MEMORY(index_to_name);
char desc[100];
- begin_custom_section(ctx, WASM_BINARY_SECTION_NAME, LEB_SECTION_SIZE_GUESS);
- wasm_write_u32_leb128(&ctx->stream, module->funcs.size, "num functions");
+ begin_custom_section(ctx, WABT_BINARY_SECTION_NAME, LEB_SECTION_SIZE_GUESS);
+ wabt_write_u32_leb128(&ctx->stream, module->funcs.size, "num functions");
for (i = 0; i < module->funcs.size; ++i) {
- const WasmFunc* func = module->funcs.data[i];
- uint32_t num_params = wasm_get_num_params(func);
+ const WabtFunc* func = module->funcs.data[i];
+ uint32_t num_params = wabt_get_num_params(func);
uint32_t num_locals = func->local_types.size;
- uint32_t num_params_and_locals = wasm_get_num_params_and_locals(func);
+ uint32_t num_params_and_locals = wabt_get_num_params_and_locals(func);
- wasm_snprintf(desc, sizeof(desc), "func name %" PRIzd, i);
- wasm_write_str(&ctx->stream, func->name.start, func->name.length,
- WASM_PRINT_CHARS, desc);
- wasm_write_u32_leb128(&ctx->stream, num_params_and_locals, "num locals");
+ wabt_snprintf(desc, sizeof(desc), "func name %" PRIzd, i);
+ wabt_write_str(&ctx->stream, func->name.start, func->name.length,
+ WABT_PRINT_CHARS, desc);
+ wabt_write_u32_leb128(&ctx->stream, num_params_and_locals, "num locals");
if (num_params_and_locals) {
- wasm_make_type_binding_reverse_mapping(
+ wabt_make_type_binding_reverse_mapping(
ctx->allocator, &func->decl.sig.param_types, &func->param_bindings,
&index_to_name);
size_t j;
for (j = 0; j < num_params; ++j) {
- WasmStringSlice name = index_to_name.data[j];
- wasm_snprintf(desc, sizeof(desc), "local name %" PRIzd, j);
- wasm_write_str(&ctx->stream, name.start, name.length,
- WASM_PRINT_CHARS, desc);
+ WabtStringSlice name = index_to_name.data[j];
+ wabt_snprintf(desc, sizeof(desc), "local name %" PRIzd, j);
+ wabt_write_str(&ctx->stream, name.start, name.length,
+ WABT_PRINT_CHARS, desc);
}
- wasm_make_type_binding_reverse_mapping(
+ wabt_make_type_binding_reverse_mapping(
ctx->allocator, &func->local_types, &func->local_bindings,
&index_to_name);
for (j = 0; j < num_locals; ++j) {
- WasmStringSlice name = index_to_name.data[j];
- wasm_snprintf(desc, sizeof(desc), "local name %" PRIzd,
+ WabtStringSlice name = index_to_name.data[j];
+ wabt_snprintf(desc, sizeof(desc), "local name %" PRIzd,
num_params + j);
- wasm_write_str(&ctx->stream, name.start, name.length,
- WASM_PRINT_CHARS, desc);
+ wabt_write_str(&ctx->stream, name.start, name.length,
+ WABT_PRINT_CHARS, desc);
}
}
}
end_section(ctx);
- wasm_destroy_string_slice_vector(ctx->allocator, &index_to_name);
+ wabt_destroy_string_slice_vector(ctx->allocator, &index_to_name);
}
if (ctx->options->relocatable) {
for (i = 0; i < ctx->reloc_sections.size; i++) {
write_reloc_section(ctx, &ctx->reloc_sections.data[i]);
}
- WASM_DESTROY_VECTOR_AND_ELEMENTS(ctx->allocator, ctx->reloc_sections,
+ WABT_DESTROY_VECTOR_AND_ELEMENTS(ctx->allocator, ctx->reloc_sections,
reloc_section);
}
return ctx->stream.result;
}
-WasmResult wasm_write_binary_module(WasmAllocator* allocator,
- WasmWriter* writer,
- const WasmModule* module,
- const WasmWriteBinaryOptions* options) {
+WabtResult wabt_write_binary_module(WabtAllocator* allocator,
+ WabtWriter* writer,
+ const WabtModule* module,
+ const WabtWriteBinaryOptions* options) {
Context ctx;
- WASM_ZERO_MEMORY(ctx);
+ WABT_ZERO_MEMORY(ctx);
ctx.allocator = allocator;
ctx.options = options;
ctx.log_stream = options->log_stream;
- wasm_init_stream(&ctx.stream, writer, ctx.log_stream);
+ wabt_init_stream(&ctx.stream, writer, ctx.log_stream);
return write_module(&ctx, module);
}
diff --git a/src/binary-writer.h b/src/binary-writer.h
index ae1e0aa2..9171b347 100644
--- a/src/binary-writer.h
+++ b/src/binary-writer.h
@@ -14,69 +14,69 @@
* limitations under the License.
*/
-#ifndef WASM_BINARY_WRITER_H_
-#define WASM_BINARY_WRITER_H_
+#ifndef WABT_BINARY_WRITER_H_
+#define WABT_BINARY_WRITER_H_
#include "common.h"
-struct WasmAllocator;
-struct WasmModule;
-struct WasmScript;
-struct WasmWriter;
-struct WasmStream;
-enum WasmPrintChars;
-
-#define WASM_WRITE_BINARY_OPTIONS_DEFAULT \
- { NULL, WASM_TRUE, WASM_FALSE, WASM_FALSE }
-
-typedef struct WasmWriteBinaryOptions {
- struct WasmStream* log_stream;
- WasmBool canonicalize_lebs;
- WasmBool relocatable;
- WasmBool write_debug_names;
-} WasmWriteBinaryOptions;
-
-WASM_EXTERN_C_BEGIN
-WasmResult wasm_write_binary_module(struct WasmAllocator*,
- struct WasmWriter*,
- const struct WasmModule*,
- const WasmWriteBinaryOptions*);
+struct WabtAllocator;
+struct WabtModule;
+struct WabtScript;
+struct WabtWriter;
+struct WabtStream;
+enum WabtPrintChars;
+
+#define WABT_WRITE_BINARY_OPTIONS_DEFAULT \
+ { NULL, WABT_TRUE, WABT_FALSE, WABT_FALSE }
+
+typedef struct WabtWriteBinaryOptions {
+ struct WabtStream* log_stream;
+ WabtBool canonicalize_lebs;
+ WabtBool relocatable;
+ WabtBool write_debug_names;
+} WabtWriteBinaryOptions;
+
+WABT_EXTERN_C_BEGIN
+WabtResult wabt_write_binary_module(struct WabtAllocator*,
+ struct WabtWriter*,
+ const struct WabtModule*,
+ const WabtWriteBinaryOptions*);
/* returns the length of the leb128 */
-uint32_t wasm_u32_leb128_length(uint32_t value);
+uint32_t wabt_u32_leb128_length(uint32_t value);
-void wasm_write_u32_leb128(struct WasmStream* stream,
+void wabt_write_u32_leb128(struct WabtStream* stream,
uint32_t value,
const char* desc);
-void wasm_write_i32_leb128(struct WasmStream* stream,
+void wabt_write_i32_leb128(struct WabtStream* stream,
int32_t value,
const char* desc);
-void wasm_write_fixed_u32_leb128(struct WasmStream* stream,
+void wabt_write_fixed_u32_leb128(struct WabtStream* stream,
uint32_t value,
const char* desc);
-uint32_t wasm_write_fixed_u32_leb128_at(struct WasmStream* stream,
+uint32_t wabt_write_fixed_u32_leb128_at(struct WabtStream* stream,
uint32_t offset,
uint32_t value,
const char* desc);
-uint32_t wasm_write_fixed_u32_leb128_raw(uint8_t* data,
+uint32_t wabt_write_fixed_u32_leb128_raw(uint8_t* data,
uint8_t* end,
uint32_t value);
-void wasm_write_type(struct WasmStream* stream, WasmType type);
+void wabt_write_type(struct WabtStream* stream, WabtType type);
-void wasm_write_str(struct WasmStream* stream,
+void wabt_write_str(struct WabtStream* stream,
const char* s,
size_t length,
- enum WasmPrintChars print_chars,
+ enum WabtPrintChars print_chars,
const char* desc);
-void wasm_write_opcode(struct WasmStream* stream, uint8_t opcode);
+void wabt_write_opcode(struct WabtStream* stream, uint8_t opcode);
-void wasm_write_limits(struct WasmStream* stream, const WasmLimits* limits);
-WASM_EXTERN_C_END
+void wabt_write_limits(struct WabtStream* stream, const WabtLimits* limits);
+WABT_EXTERN_C_END
-#endif /* WASM_BINARY_WRITER_H_ */
+#endif /* WABT_BINARY_WRITER_H_ */
diff --git a/src/binary.c b/src/binary.c
index d426b48c..970fccb4 100644
--- a/src/binary.c
+++ b/src/binary.c
@@ -16,8 +16,8 @@
#include "binary.h"
-const char* g_wasm_section_name[] = {
+const char* g_wabt_section_name[] = {
#define V(NAME, name, code) #NAME,
- WASM_FOREACH_BINARY_SECTION(V)
+ WABT_FOREACH_BINARY_SECTION(V)
#undef V
};
diff --git a/src/binary.h b/src/binary.h
index f157ff04..52fb9002 100644
--- a/src/binary.h
+++ b/src/binary.h
@@ -14,19 +14,19 @@
* limitations under the License.
*/
-#ifndef WASM_BINARY_H_
-#define WASM_BINARY_H_
+#ifndef WABT_BINARY_H_
+#define WABT_BINARY_H_
#include "common.h"
-#define WASM_BINARY_MAGIC 0x6d736100
-#define WASM_BINARY_VERSION 0x0d
-#define WASM_BINARY_LIMITS_HAS_MAX_FLAG 0x1
+#define WABT_BINARY_MAGIC 0x6d736100
+#define WABT_BINARY_VERSION 0x0d
+#define WABT_BINARY_LIMITS_HAS_MAX_FLAG 0x1
-#define WASM_BINARY_SECTION_NAME "name"
-#define WASM_BINARY_SECTION_RELOC "reloc"
+#define WABT_BINARY_SECTION_NAME "name"
+#define WABT_BINARY_SECTION_RELOC "reloc"
-#define WASM_FOREACH_BINARY_SECTION(V) \
+#define WABT_FOREACH_BINARY_SECTION(V) \
V(CUSTOM, custom, 0) \
V(TYPE, type, 1) \
V(IMPORT, import, 2) \
@@ -41,21 +41,21 @@
V(DATA, data, 11)
/* clang-format off */
-typedef enum WasmBinarySection {
-#define V(NAME, name, code) WASM_BINARY_SECTION_##NAME = code,
- WASM_FOREACH_BINARY_SECTION(V)
+typedef enum WabtBinarySection {
+#define V(NAME, name, code) WABT_BINARY_SECTION_##NAME = code,
+ WABT_FOREACH_BINARY_SECTION(V)
#undef V
- WASM_NUM_BINARY_SECTIONS
-} WasmBinarySection;
+ WABT_NUM_BINARY_SECTIONS
+} WabtBinarySection;
/* clang-format on */
-WASM_EXTERN_C_BEGIN
-extern const char* g_wasm_section_name[];
+WABT_EXTERN_C_BEGIN
+extern const char* g_wabt_section_name[];
-static WASM_INLINE const char* wasm_get_section_name(WasmBinarySection sec) {
- assert(sec < WASM_NUM_BINARY_SECTIONS);
- return g_wasm_section_name[sec];
+static WABT_INLINE const char* wabt_get_section_name(WabtBinarySection sec) {
+ assert(sec < WABT_NUM_BINARY_SECTIONS);
+ return g_wabt_section_name[sec];
}
-WASM_EXTERN_C_END
+WABT_EXTERN_C_END
-#endif /* WASM_BINARY_H_ */
+#endif /* WABT_BINARY_H_ */
diff --git a/src/binding-hash.c b/src/binding-hash.c
index b0c3dddc..4e83d18b 100644
--- a/src/binding-hash.c
+++ b/src/binding-hash.c
@@ -18,7 +18,7 @@
#define INITIAL_HASH_CAPACITY 8
-static size_t hash_name(const WasmStringSlice* name) {
+static size_t hash_name(const WabtStringSlice* name) {
// FNV-1a hash
const uint32_t fnv_prime = 0x01000193;
const uint8_t* bp = (const uint8_t*)name->start;
@@ -31,28 +31,28 @@ static size_t hash_name(const WasmStringSlice* name) {
return hval;
}
-static WasmBindingHashEntry* hash_main_entry(const WasmBindingHash* hash,
- const WasmStringSlice* name) {
+static WabtBindingHashEntry* hash_main_entry(const WabtBindingHash* hash,
+ const WabtStringSlice* name) {
return &hash->entries.data[hash_name(name) % hash->entries.capacity];
}
-WasmBool wasm_hash_entry_is_free(const WasmBindingHashEntry* entry) {
+WabtBool wabt_hash_entry_is_free(const WabtBindingHashEntry* entry) {
return !entry->binding.name.start;
}
-static WasmBindingHashEntry* hash_new_entry(WasmBindingHash* hash,
- const WasmStringSlice* name) {
- WasmBindingHashEntry* entry = hash_main_entry(hash, name);
- if (!wasm_hash_entry_is_free(entry)) {
+static WabtBindingHashEntry* hash_new_entry(WabtBindingHash* hash,
+ const WabtStringSlice* name) {
+ WabtBindingHashEntry* entry = hash_main_entry(hash, name);
+ if (!wabt_hash_entry_is_free(entry)) {
assert(hash->free_head);
- WasmBindingHashEntry* free_entry = hash->free_head;
+ WabtBindingHashEntry* free_entry = hash->free_head;
hash->free_head = free_entry->next;
if (free_entry->next)
free_entry->next->prev = NULL;
/* our main position is already claimed. Check to see if the entry in that
* position is in its main position */
- WasmBindingHashEntry* other_entry =
+ WabtBindingHashEntry* other_entry =
hash_main_entry(hash, &entry->binding.name);
if (other_entry == entry) {
/* yes, so add this new entry to the chain, even if it is already there */
@@ -62,7 +62,7 @@ static WasmBindingHashEntry* hash_new_entry(WasmBindingHash* hash,
entry = free_entry;
} else {
/* no, move the entry to the free entry */
- assert(!wasm_hash_entry_is_free(other_entry));
+ assert(!wabt_hash_entry_is_free(other_entry));
while (other_entry->next != entry)
other_entry = other_entry->next;
@@ -81,30 +81,30 @@ static WasmBindingHashEntry* hash_new_entry(WasmBindingHash* hash,
entry->next = NULL;
}
- WASM_ZERO_MEMORY(entry->binding);
+ WABT_ZERO_MEMORY(entry->binding);
entry->binding.name = *name;
entry->prev = NULL;
/* entry->next is set above */
return entry;
}
-static void hash_resize(WasmAllocator* allocator,
- WasmBindingHash* hash,
+static void hash_resize(WabtAllocator* allocator,
+ WabtBindingHash* hash,
size_t desired_capacity) {
- WasmBindingHash new_hash;
- WASM_ZERO_MEMORY(new_hash);
+ WabtBindingHash new_hash;
+ WABT_ZERO_MEMORY(new_hash);
/* TODO(binji): better plural */
- wasm_reserve_binding_hash_entrys(allocator, &new_hash.entries,
+ wabt_reserve_binding_hash_entrys(allocator, &new_hash.entries,
desired_capacity);
/* update the free list */
size_t i;
for (i = 0; i < new_hash.entries.capacity; ++i) {
- WasmBindingHashEntry* entry = &new_hash.entries.data[i];
+ WabtBindingHashEntry* entry = &new_hash.entries.data[i];
if (new_hash.free_head)
new_hash.free_head->prev = entry;
- WASM_ZERO_MEMORY(entry->binding.name);
+ WABT_ZERO_MEMORY(entry->binding.name);
entry->next = new_hash.free_head;
new_hash.free_head = entry;
}
@@ -112,24 +112,24 @@ static void hash_resize(WasmAllocator* allocator,
/* copy from the old hash to the new hash */
for (i = 0; i < hash->entries.capacity; ++i) {
- WasmBindingHashEntry* old_entry = &hash->entries.data[i];
- if (wasm_hash_entry_is_free(old_entry))
+ WabtBindingHashEntry* old_entry = &hash->entries.data[i];
+ if (wabt_hash_entry_is_free(old_entry))
continue;
- WasmStringSlice* name = &old_entry->binding.name;
- WasmBindingHashEntry* new_entry = hash_new_entry(&new_hash, name);
+ WabtStringSlice* name = &old_entry->binding.name;
+ WabtBindingHashEntry* new_entry = hash_new_entry(&new_hash, name);
new_entry->binding = old_entry->binding;
}
- /* we are sharing the WasmStringSlices, so we only need to destroy the old
+ /* we are sharing the WabtStringSlices, so we only need to destroy the old
* binding vector */
- wasm_destroy_binding_hash_entry_vector(allocator, &hash->entries);
+ wabt_destroy_binding_hash_entry_vector(allocator, &hash->entries);
*hash = new_hash;
}
-WasmBinding* wasm_insert_binding(WasmAllocator* allocator,
- WasmBindingHash* hash,
- const WasmStringSlice* name) {
+WabtBinding* wabt_insert_binding(WabtAllocator* allocator,
+ WabtBindingHash* hash,
+ const WabtStringSlice* name) {
if (hash->entries.size == 0)
hash_resize(allocator, hash, INITIAL_HASH_CAPACITY);
@@ -138,50 +138,50 @@ WasmBinding* wasm_insert_binding(WasmAllocator* allocator,
hash_resize(allocator, hash, hash->entries.capacity * 2);
}
- WasmBindingHashEntry* entry = hash_new_entry(hash, name);
+ WabtBindingHashEntry* entry = hash_new_entry(hash, name);
assert(entry);
hash->entries.size++;
return &entry->binding;
}
-int wasm_find_binding_index_by_name(const WasmBindingHash* hash,
- const WasmStringSlice* name) {
+int wabt_find_binding_index_by_name(const WabtBindingHash* hash,
+ const WabtStringSlice* name) {
if (hash->entries.capacity == 0)
return -1;
- WasmBindingHashEntry* entry = hash_main_entry(hash, name);
+ WabtBindingHashEntry* entry = hash_main_entry(hash, name);
do {
- if (wasm_string_slices_are_equal(&entry->binding.name, name))
+ if (wabt_string_slices_are_equal(&entry->binding.name, name))
return entry->binding.index;
entry = entry->next;
- } while (entry && !wasm_hash_entry_is_free(entry));
+ } while (entry && !wabt_hash_entry_is_free(entry));
return -1;
}
-void wasm_remove_binding(struct WasmAllocator* allocator,
- WasmBindingHash* hash,
- const WasmStringSlice* name) {
- int index = wasm_find_binding_index_by_name(hash, name);
+void wabt_remove_binding(struct WabtAllocator* allocator,
+ WabtBindingHash* hash,
+ const WabtStringSlice* name) {
+ int index = wabt_find_binding_index_by_name(hash, name);
if (index == -1)
return;
- WasmBindingHashEntry* entry = &hash->entries.data[index];
- wasm_destroy_string_slice(allocator, &entry->binding.name);
- WASM_ZERO_MEMORY(*entry);
+ WabtBindingHashEntry* entry = &hash->entries.data[index];
+ wabt_destroy_string_slice(allocator, &entry->binding.name);
+ WABT_ZERO_MEMORY(*entry);
}
-static void destroy_binding_hash_entry(WasmAllocator* allocator,
- WasmBindingHashEntry* entry) {
- wasm_destroy_string_slice(allocator, &entry->binding.name);
+static void destroy_binding_hash_entry(WabtAllocator* allocator,
+ WabtBindingHashEntry* entry) {
+ wabt_destroy_string_slice(allocator, &entry->binding.name);
}
-void wasm_destroy_binding_hash(WasmAllocator* allocator,
- WasmBindingHash* hash) {
- /* Can't use WASM_DESTROY_VECTOR_AND_ELEMENTS, because it loops over size, not
+void wabt_destroy_binding_hash(WabtAllocator* allocator,
+ WabtBindingHash* hash) {
+ /* Can't use WABT_DESTROY_VECTOR_AND_ELEMENTS, because it loops over size, not
* capacity. */
size_t i;
for (i = 0; i < hash->entries.capacity; ++i)
destroy_binding_hash_entry(allocator, &hash->entries.data[i]);
- wasm_destroy_binding_hash_entry_vector(allocator, &hash->entries);
+ wabt_destroy_binding_hash_entry_vector(allocator, &hash->entries);
}
diff --git a/src/binding-hash.h b/src/binding-hash.h
index 06aa2d27..0c3f4e46 100644
--- a/src/binding-hash.h
+++ b/src/binding-hash.h
@@ -14,44 +14,44 @@
* limitations under the License.
*/
-#ifndef WASM_BINDING_HASH_H_
-#define WASM_BINDING_HASH_H_
+#ifndef WABT_BINDING_HASH_H_
+#define WABT_BINDING_HASH_H_
#include "common.h"
#include "vector.h"
-struct WasmAllocator;
+struct WabtAllocator;
-typedef struct WasmBinding {
- WasmLocation loc;
- WasmStringSlice name;
+typedef struct WabtBinding {
+ WabtLocation loc;
+ WabtStringSlice name;
int index;
-} WasmBinding;
-
-typedef struct WasmBindingHashEntry {
- WasmBinding binding;
- struct WasmBindingHashEntry* next;
- struct WasmBindingHashEntry* prev; /* only valid when this entry is unused */
-} WasmBindingHashEntry;
-WASM_DEFINE_VECTOR(binding_hash_entry, WasmBindingHashEntry);
-
-typedef struct WasmBindingHash {
- WasmBindingHashEntryVector entries;
- WasmBindingHashEntry* free_head;
-} WasmBindingHash;
-
-WASM_EXTERN_C_BEGIN
-WasmBinding* wasm_insert_binding(struct WasmAllocator*,
- WasmBindingHash*,
- const WasmStringSlice*);
-void wasm_remove_binding(struct WasmAllocator*,
- WasmBindingHash*,
- const WasmStringSlice*);
-WasmBool wasm_hash_entry_is_free(const WasmBindingHashEntry*);
+} WabtBinding;
+
+typedef struct WabtBindingHashEntry {
+ WabtBinding binding;
+ struct WabtBindingHashEntry* next;
+ struct WabtBindingHashEntry* prev; /* only valid when this entry is unused */
+} WabtBindingHashEntry;
+WABT_DEFINE_VECTOR(binding_hash_entry, WabtBindingHashEntry);
+
+typedef struct WabtBindingHash {
+ WabtBindingHashEntryVector entries;
+ WabtBindingHashEntry* free_head;
+} WabtBindingHash;
+
+WABT_EXTERN_C_BEGIN
+WabtBinding* wabt_insert_binding(struct WabtAllocator*,
+ WabtBindingHash*,
+ const WabtStringSlice*);
+void wabt_remove_binding(struct WabtAllocator*,
+ WabtBindingHash*,
+ const WabtStringSlice*);
+WabtBool wabt_hash_entry_is_free(const WabtBindingHashEntry*);
/* returns -1 if the name is not in the hash */
-int wasm_find_binding_index_by_name(const WasmBindingHash*,
- const WasmStringSlice* name);
-void wasm_destroy_binding_hash(struct WasmAllocator*, WasmBindingHash*);
-WASM_EXTERN_C_END
+int wabt_find_binding_index_by_name(const WabtBindingHash*,
+ const WabtStringSlice* name);
+void wabt_destroy_binding_hash(struct WabtAllocator*, WabtBindingHash*);
+WABT_EXTERN_C_END
-#endif /* WASM_BINDING_HASH_H_ */
+#endif /* WABT_BINDING_HASH_H_ */
diff --git a/src/common.c b/src/common.c
index 07599eeb..7a2225c6 100644
--- a/src/common.c
+++ b/src/common.c
@@ -29,116 +29,116 @@
#include "allocator.h"
#define V(rtype, type1, type2, mem_size, code, NAME, text) \
- [code] = {text, WASM_TYPE_##rtype, WASM_TYPE_##type1, WASM_TYPE_##type2, \
+ [code] = {text, WABT_TYPE_##rtype, WABT_TYPE_##type1, WABT_TYPE_##type2, \
mem_size},
-WasmOpcodeInfo g_wasm_opcode_info[] = {WASM_FOREACH_OPCODE(V)};
+WabtOpcodeInfo g_wabt_opcode_info[] = {WABT_FOREACH_OPCODE(V)};
#undef V
-const char* g_wasm_kind_name[] = {"func", "table", "memory", "global"};
-WASM_STATIC_ASSERT(WASM_ARRAY_SIZE(g_wasm_kind_name) ==
- WASM_NUM_EXTERNAL_KINDS);
+const char* g_wabt_kind_name[] = {"func", "table", "memory", "global"};
+WABT_STATIC_ASSERT(WABT_ARRAY_SIZE(g_wabt_kind_name) ==
+ WABT_NUM_EXTERNAL_KINDS);
-const char* g_wasm_reloc_type_name[] = {
+const char* g_wabt_reloc_type_name[] = {
"R_FUNC_INDEX_LEB", "R_TABLE_INDEX_SLEB", "R_TABLE_INDEX_I32",
"R_GLOBAL_INDEX_LEB", "R_DATA"};
-WASM_STATIC_ASSERT(WASM_ARRAY_SIZE(g_wasm_reloc_type_name) ==
- WASM_NUM_RELOC_TYPES);
+WABT_STATIC_ASSERT(WABT_ARRAY_SIZE(g_wabt_reloc_type_name) ==
+ WABT_NUM_RELOC_TYPES);
-WasmBool wasm_is_naturally_aligned(WasmOpcode opcode, uint32_t alignment) {
- uint32_t opcode_align = wasm_get_opcode_memory_size(opcode);
- return alignment == WASM_USE_NATURAL_ALIGNMENT || alignment == opcode_align;
+WabtBool wabt_is_naturally_aligned(WabtOpcode opcode, uint32_t alignment) {
+ uint32_t opcode_align = wabt_get_opcode_memory_size(opcode);
+ return alignment == WABT_USE_NATURAL_ALIGNMENT || alignment == opcode_align;
}
-uint32_t wasm_get_opcode_alignment(WasmOpcode opcode, uint32_t alignment) {
- if (alignment == WASM_USE_NATURAL_ALIGNMENT)
- return wasm_get_opcode_memory_size(opcode);
+uint32_t wabt_get_opcode_alignment(WabtOpcode opcode, uint32_t alignment) {
+ if (alignment == WABT_USE_NATURAL_ALIGNMENT)
+ return wabt_get_opcode_memory_size(opcode);
return alignment;
}
-WasmStringSlice wasm_empty_string_slice(void) {
- WasmStringSlice result;
+WabtStringSlice wabt_empty_string_slice(void) {
+ WabtStringSlice result;
result.start = "";
result.length = 0;
return result;
}
-WasmBool wasm_string_slice_eq_cstr(const WasmStringSlice* s1, const char* s2) {
+WabtBool wabt_string_slice_eq_cstr(const WabtStringSlice* s1, const char* s2) {
size_t s2_len = strlen(s2);
if (s2_len != s1->length)
- return WASM_FALSE;
+ return WABT_FALSE;
- return strncmp(s1->start, s2, s2_len) == 0 ? WASM_TRUE : WASM_FALSE;
+ return strncmp(s1->start, s2, s2_len) == 0 ? WABT_TRUE : WABT_FALSE;
}
-WasmBool wasm_string_slice_startswith(const WasmStringSlice* s1,
+WabtBool wabt_string_slice_startswith(const WabtStringSlice* s1,
const char* s2) {
size_t s2_len = strlen(s2);
if (s2_len > s1->length)
- return WASM_FALSE;
+ return WABT_FALSE;
- return strncmp(s1->start, s2, s2_len) == 0 ? WASM_TRUE : WASM_FALSE;
+ return strncmp(s1->start, s2, s2_len) == 0 ? WABT_TRUE : WABT_FALSE;
}
-WasmStringSlice wasm_string_slice_from_cstr(const char* string) {
- WasmStringSlice result;
+WabtStringSlice wabt_string_slice_from_cstr(const char* string) {
+ WabtStringSlice result;
result.start = string;
result.length = strlen(string);
return result;
}
-WasmBool wasm_string_slice_is_empty(const WasmStringSlice* str) {
+WabtBool wabt_string_slice_is_empty(const WabtStringSlice* str) {
assert(str);
return str->start == NULL || str->length == 0;
}
-WasmBool wasm_string_slices_are_equal(const WasmStringSlice* a,
- const WasmStringSlice* b) {
+WabtBool wabt_string_slices_are_equal(const WabtStringSlice* a,
+ const WabtStringSlice* b) {
assert(a && b);
return a->start && b->start && a->length == b->length &&
memcmp(a->start, b->start, a->length) == 0;
}
-void wasm_destroy_string_slice(WasmAllocator* allocator, WasmStringSlice* str) {
+void wabt_destroy_string_slice(WabtAllocator* allocator, WabtStringSlice* str) {
assert(str);
- wasm_free(allocator, (void*)str->start);
+ wabt_free(allocator, (void*)str->start);
}
-WasmResult wasm_read_file(WasmAllocator* allocator,
+WabtResult wabt_read_file(WabtAllocator* allocator,
const char* filename,
void** out_data,
size_t* out_size) {
FILE* infile = fopen(filename, "rb");
if (!infile) {
fprintf(stderr, "unable to read file: %s\n", filename);
- return WASM_ERROR;
+ return WABT_ERROR;
}
if (fseek(infile, 0, SEEK_END) < 0) {
fprintf(stderr, "fseek to end failed.\n");
- return WASM_ERROR;
+ return WABT_ERROR;
}
long size = ftell(infile);
if (size < 0) {
fprintf(stderr, "ftell failed.\n");
- return WASM_ERROR;
+ return WABT_ERROR;
}
if (fseek(infile, 0, SEEK_SET) < 0) {
fprintf(stderr, "fseek to beginning failed.\n");
- return WASM_ERROR;
+ return WABT_ERROR;
}
- void* data = wasm_alloc(allocator, size, WASM_DEFAULT_ALIGN);
+ void* data = wabt_alloc(allocator, size, WABT_DEFAULT_ALIGN);
if (size != 0 && fread(data, size, 1, infile) != 1) {
fprintf(stderr, "fread failed.\n");
- return WASM_ERROR;
+ return WABT_ERROR;
}
*out_data = data;
*out_size = size;
fclose(infile);
- return WASM_OK;
+ return WABT_OK;
}
static void print_carets(FILE* out,
@@ -157,7 +157,7 @@ static void print_carets(FILE* out,
}
static void print_source_error(FILE* out,
- const WasmLocation* loc,
+ const WabtLocation* loc,
const char* error,
const char* source_line,
size_t source_line_length,
@@ -172,17 +172,17 @@ static void print_source_error(FILE* out,
}
}
-static void print_error_header(FILE* out, WasmDefaultErrorHandlerInfo* info) {
+static void print_error_header(FILE* out, WabtDefaultErrorHandlerInfo* info) {
if (info && info->header) {
switch (info->print_header) {
- case WASM_PRINT_ERROR_HEADER_NEVER:
+ case WABT_PRINT_ERROR_HEADER_NEVER:
break;
- case WASM_PRINT_ERROR_HEADER_ONCE:
- info->print_header = WASM_PRINT_ERROR_HEADER_NEVER;
+ case WABT_PRINT_ERROR_HEADER_ONCE:
+ info->print_header = WABT_PRINT_ERROR_HEADER_NEVER;
/* Fallthrough. */
- case WASM_PRINT_ERROR_HEADER_ALWAYS:
+ case WABT_PRINT_ERROR_HEADER_ALWAYS:
fprintf(out, "%s:\n", info->header);
break;
}
@@ -192,37 +192,37 @@ static void print_error_header(FILE* out, WasmDefaultErrorHandlerInfo* info) {
}
static FILE* get_default_error_handler_info_output_file(
- WasmDefaultErrorHandlerInfo* info) {
+ WabtDefaultErrorHandlerInfo* info) {
return info && info->out_file ? info->out_file : stderr;
}
-void wasm_default_source_error_callback(const WasmLocation* loc,
+void wabt_default_source_error_callback(const WabtLocation* loc,
const char* error,
const char* source_line,
size_t source_line_length,
size_t source_line_column_offset,
void* user_data) {
- WasmDefaultErrorHandlerInfo* info = user_data;
+ WabtDefaultErrorHandlerInfo* info = user_data;
FILE* out = get_default_error_handler_info_output_file(info);
print_error_header(out, info);
print_source_error(out, loc, error, source_line, source_line_length,
source_line_column_offset);
}
-void wasm_default_binary_error_callback(uint32_t offset,
+void wabt_default_binary_error_callback(uint32_t offset,
const char* error,
void* user_data) {
- WasmDefaultErrorHandlerInfo* info = user_data;
+ WabtDefaultErrorHandlerInfo* info = user_data;
FILE* out = get_default_error_handler_info_output_file(info);
print_error_header(out, info);
- if (offset == WASM_UNKNOWN_OFFSET)
+ if (offset == WABT_UNKNOWN_OFFSET)
fprintf(out, "error: %s\n", error);
else
fprintf(out, "error: @0x%08x: %s\n", offset, error);
fflush(out);
}
-void wasm_init_stdio() {
+void wabt_init_stdio() {
#if COMPILER_IS_MSVC
int result = _setmode(_fileno(stdout), _O_BINARY);
if (result == -1)
diff --git a/src/common.h b/src/common.h
index 231d1dc9..2f66cd44 100644
--- a/src/common.h
+++ b/src/common.h
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#ifndef WASM_COMMON_H_
-#define WASM_COMMON_H_
+#ifndef WABT_COMMON_H_
+#define WABT_COMMON_H_
#include <assert.h>
#include <stdarg.h>
@@ -26,158 +26,158 @@
#include "config.h"
#ifdef __cplusplus
-#define WASM_EXTERN_C extern "C"
-#define WASM_EXTERN_C_BEGIN extern "C" {
-#define WASM_EXTERN_C_END }
+#define WABT_EXTERN_C extern "C"
+#define WABT_EXTERN_C_BEGIN extern "C" {
+#define WABT_EXTERN_C_END }
#else
-#define WASM_EXTERN_C
-#define WASM_EXTERN_C_BEGIN
-#define WASM_EXTERN_C_END
+#define WABT_EXTERN_C
+#define WABT_EXTERN_C_BEGIN
+#define WABT_EXTERN_C_END
#endif
-#define WASM_FATAL(...) fprintf(stderr, __VA_ARGS__), exit(1)
-#define WASM_ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
-#define WASM_ZERO_MEMORY(var) memset((void*)&(var), 0, sizeof(var))
-#define WASM_USE(x) (void)x
+#define WABT_FATAL(...) fprintf(stderr, __VA_ARGS__), exit(1)
+#define WABT_ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
+#define WABT_ZERO_MEMORY(var) memset((void*)&(var), 0, sizeof(var))
+#define WABT_USE(x) (void)x
-#define WASM_UNKNOWN_OFFSET ((uint32_t)~0)
-#define WASM_PAGE_SIZE 0x10000 /* 64k */
-#define WASM_MAX_PAGES 0x10000 /* # of pages that fit in 32-bit address space */
-#define WASM_BYTES_TO_PAGES(x) ((x) >> 16)
-#define WASM_ALIGN_UP_TO_PAGE(x) \
- (((x) + WASM_PAGE_SIZE - 1) & ~(WASM_PAGE_SIZE - 1))
+#define WABT_UNKNOWN_OFFSET ((uint32_t)~0)
+#define WABT_PAGE_SIZE 0x10000 /* 64k */
+#define WABT_MAX_PAGES 0x10000 /* # of pages that fit in 32-bit address space */
+#define WABT_BYTES_TO_PAGES(x) ((x) >> 16)
+#define WABT_ALIGN_UP_TO_PAGE(x) \
+ (((x) + WABT_PAGE_SIZE - 1) & ~(WABT_PAGE_SIZE - 1))
#define PRIstringslice "%.*s"
-#define WASM_PRINTF_STRING_SLICE_ARG(x) (int)((x).length), (x).start
+#define WABT_PRINTF_STRING_SLICE_ARG(x) (int)((x).length), (x).start
-#define WASM_DEFAULT_SNPRINTF_ALLOCA_BUFSIZE 128
-#define WASM_SNPRINTF_ALLOCA(buffer, len, format) \
+#define WABT_DEFAULT_SNPRINTF_ALLOCA_BUFSIZE 128
+#define WABT_SNPRINTF_ALLOCA(buffer, len, format) \
va_list args; \
va_list args_copy; \
va_start(args, format); \
va_copy(args_copy, args); \
- char fixed_buf[WASM_DEFAULT_SNPRINTF_ALLOCA_BUFSIZE]; \
+ char fixed_buf[WABT_DEFAULT_SNPRINTF_ALLOCA_BUFSIZE]; \
char* buffer = fixed_buf; \
- size_t len = wasm_vsnprintf(fixed_buf, sizeof(fixed_buf), format, args); \
+ size_t len = wabt_vsnprintf(fixed_buf, sizeof(fixed_buf), format, args); \
va_end(args); \
if (len + 1 > sizeof(fixed_buf)) { \
buffer = alloca(len + 1); \
- len = wasm_vsnprintf(buffer, len + 1, format, args_copy); \
+ len = wabt_vsnprintf(buffer, len + 1, format, args_copy); \
} \
va_end(args_copy)
-struct WasmAllocator;
+struct WabtAllocator;
-typedef enum WasmBool {
- WASM_FALSE,
- WASM_TRUE,
-} WasmBool;
+typedef enum WabtBool {
+ WABT_FALSE,
+ WABT_TRUE,
+} WabtBool;
-typedef enum WasmResult {
- WASM_OK,
- WASM_ERROR,
-} WasmResult;
+typedef enum WabtResult {
+ WABT_OK,
+ WABT_ERROR,
+} WabtResult;
-#define WASM_SUCCEEDED(x) ((x) == WASM_OK)
-#define WASM_FAILED(x) ((x) == WASM_ERROR)
+#define WABT_SUCCEEDED(x) ((x) == WABT_OK)
+#define WABT_FAILED(x) ((x) == WABT_ERROR)
-typedef struct WasmStringSlice {
+typedef struct WabtStringSlice {
const char* start;
size_t length;
-} WasmStringSlice;
+} WabtStringSlice;
-typedef struct WasmLocation {
+typedef struct WabtLocation {
const char* filename;
int line;
int first_column;
int last_column;
-} WasmLocation;
+} WabtLocation;
-typedef void (*WasmSourceErrorCallback)(const WasmLocation*,
+typedef void (*WabtSourceErrorCallback)(const WabtLocation*,
const char* error,
const char* source_line,
size_t source_line_length,
size_t source_line_column_offset,
void* user_data);
-typedef struct WasmSourceErrorHandler {
- WasmSourceErrorCallback on_error;
+typedef struct WabtSourceErrorHandler {
+ WabtSourceErrorCallback on_error;
/* on_error will be called with with source_line trimmed to this length */
size_t source_line_max_length;
void* user_data;
-} WasmSourceErrorHandler;
+} WabtSourceErrorHandler;
-#define WASM_SOURCE_LINE_MAX_LENGTH_DEFAULT 80
-#define WASM_SOURCE_ERROR_HANDLER_DEFAULT \
+#define WABT_SOURCE_LINE_MAX_LENGTH_DEFAULT 80
+#define WABT_SOURCE_ERROR_HANDLER_DEFAULT \
{ \
- wasm_default_source_error_callback, WASM_SOURCE_LINE_MAX_LENGTH_DEFAULT, \
+ wabt_default_source_error_callback, WABT_SOURCE_LINE_MAX_LENGTH_DEFAULT, \
NULL \
}
-typedef void (*WasmBinaryErrorCallback)(uint32_t offset,
+typedef void (*WabtBinaryErrorCallback)(uint32_t offset,
const char* error,
void* user_data);
-typedef struct WasmBinaryErrorHandler {
- WasmBinaryErrorCallback on_error;
+typedef struct WabtBinaryErrorHandler {
+ WabtBinaryErrorCallback on_error;
void* user_data;
-} WasmBinaryErrorHandler;
+} WabtBinaryErrorHandler;
-#define WASM_BINARY_ERROR_HANDLER_DEFAULT \
- { wasm_default_binary_error_callback, NULL }
+#define WABT_BINARY_ERROR_HANDLER_DEFAULT \
+ { wabt_default_binary_error_callback, NULL }
/* This data structure is not required; it is just used by the default error
* handler callbacks. */
-typedef enum WasmPrintErrorHeader {
- WASM_PRINT_ERROR_HEADER_NEVER,
- WASM_PRINT_ERROR_HEADER_ONCE,
- WASM_PRINT_ERROR_HEADER_ALWAYS,
-} WasmPrintErrorHeader;
+typedef enum WabtPrintErrorHeader {
+ WABT_PRINT_ERROR_HEADER_NEVER,
+ WABT_PRINT_ERROR_HEADER_ONCE,
+ WABT_PRINT_ERROR_HEADER_ALWAYS,
+} WabtPrintErrorHeader;
-typedef struct WasmDefaultErrorHandlerInfo {
+typedef struct WabtDefaultErrorHandlerInfo {
const char* header;
FILE* out_file;
- WasmPrintErrorHeader print_header;
-} WasmDefaultErrorHandlerInfo;
+ WabtPrintErrorHeader print_header;
+} WabtDefaultErrorHandlerInfo;
/* matches binary format, do not change */
-typedef enum WasmType {
- WASM_TYPE_I32 = -0x01,
- WASM_TYPE_I64 = -0x02,
- WASM_TYPE_F32 = -0x03,
- WASM_TYPE_F64 = -0x04,
- WASM_TYPE_ANYFUNC = -0x10,
- WASM_TYPE_FUNC = -0x20,
- WASM_TYPE_VOID = -0x40,
- WASM_TYPE____ = WASM_TYPE_VOID, /* convenient for the opcode table below */
- WASM_TYPE_ANY = 0, /* Not actually specified, but useful for type-checking */
-} WasmType;
-
-typedef enum WasmRelocType {
- WASM_RELOC_FUNC_INDEX_LEB = 0, /* e.g. immediate of call instruction */
- WASM_RELOC_TABLE_INDEX_SLEB = 1, /* e.g. loading address of function */
- WASM_RELOC_TABLE_INDEX_I32 = 2, /* e.g. function address in DATA */
- WASM_RELOC_GLOBAL_INDEX_LEB = 3, /* e.g immediate of get_global inst */
- WASM_RELOC_DATA = 4,
- WASM_NUM_RELOC_TYPES,
-} WasmRelocType;
+typedef enum WabtType {
+ WABT_TYPE_I32 = -0x01,
+ WABT_TYPE_I64 = -0x02,
+ WABT_TYPE_F32 = -0x03,
+ WABT_TYPE_F64 = -0x04,
+ WABT_TYPE_ANYFUNC = -0x10,
+ WABT_TYPE_FUNC = -0x20,
+ WABT_TYPE_VOID = -0x40,
+ WABT_TYPE____ = WABT_TYPE_VOID, /* convenient for the opcode table below */
+ WABT_TYPE_ANY = 0, /* Not actually specified, but useful for type-checking */
+} WabtType;
+
+typedef enum WabtRelocType {
+ WABT_RELOC_FUNC_INDEX_LEB = 0, /* e.g. immediate of call instruction */
+ WABT_RELOC_TABLE_INDEX_SLEB = 1, /* e.g. loading address of function */
+ WABT_RELOC_TABLE_INDEX_I32 = 2, /* e.g. function address in DATA */
+ WABT_RELOC_GLOBAL_INDEX_LEB = 3, /* e.g immediate of get_global inst */
+ WABT_RELOC_DATA = 4,
+ WABT_NUM_RELOC_TYPES,
+} WabtRelocType;
/* matches binary format, do not change */
-typedef enum WasmExternalKind {
- WASM_EXTERNAL_KIND_FUNC = 0,
- WASM_EXTERNAL_KIND_TABLE = 1,
- WASM_EXTERNAL_KIND_MEMORY = 2,
- WASM_EXTERNAL_KIND_GLOBAL = 3,
- WASM_NUM_EXTERNAL_KINDS,
-} WasmExternalKind;
-
-typedef struct WasmLimits {
+typedef enum WabtExternalKind {
+ WABT_EXTERNAL_KIND_FUNC = 0,
+ WABT_EXTERNAL_KIND_TABLE = 1,
+ WABT_EXTERNAL_KIND_MEMORY = 2,
+ WABT_EXTERNAL_KIND_GLOBAL = 3,
+ WABT_NUM_EXTERNAL_KINDS,
+} WabtExternalKind;
+
+typedef struct WabtLimits {
uint64_t initial;
uint64_t max;
- WasmBool has_max;
-} WasmLimits;
+ WabtBool has_max;
+} WabtLimits;
-enum { WASM_USE_NATURAL_ALIGNMENT = 0xFFFFFFFF };
+enum { WABT_USE_NATURAL_ALIGNMENT = 0xFFFFFFFF };
/*
* tr: result type
@@ -190,7 +190,7 @@ enum { WASM_USE_NATURAL_ALIGNMENT = 0xFFFFFFFF };
*
* tr t1 t2 m code NAME text
* ============================ */
-#define WASM_FOREACH_OPCODE(V) \
+#define WABT_FOREACH_OPCODE(V) \
V(___, ___, ___, 0, 0x00, UNREACHABLE, "unreachable") \
V(___, ___, ___, 0, 0x01, NOP, "nop") \
V(___, ___, ___, 0, 0x02, BLOCK, "block") \
@@ -364,132 +364,132 @@ enum { WASM_USE_NATURAL_ALIGNMENT = 0xFFFFFFFF };
V(F32, I32, ___, 0, 0xbe, F32_REINTERPRET_I32, "f32.reinterpret/i32") \
V(F64, I64, ___, 0, 0xbf, F64_REINTERPRET_I64, "f64.reinterpret/i64")
-typedef enum WasmOpcode {
+typedef enum WabtOpcode {
#define V(rtype, type1, type2, mem_size, code, NAME, text) \
- WASM_OPCODE_##NAME = code,
- WASM_FOREACH_OPCODE(V)
+ WABT_OPCODE_##NAME = code,
+ WABT_FOREACH_OPCODE(V)
#undef V
- WASM_NUM_OPCODES
-} WasmOpcode;
+ WABT_NUM_OPCODES
+} WabtOpcode;
-typedef struct WasmOpcodeInfo {
+typedef struct WabtOpcodeInfo {
const char* name;
- WasmType result_type;
- WasmType param1_type;
- WasmType param2_type;
+ WabtType result_type;
+ WabtType param1_type;
+ WabtType param2_type;
int memory_size;
-} WasmOpcodeInfo;
-
-typedef enum WasmLiteralType {
- WASM_LITERAL_TYPE_INT,
- WASM_LITERAL_TYPE_FLOAT,
- WASM_LITERAL_TYPE_HEXFLOAT,
- WASM_LITERAL_TYPE_INFINITY,
- WASM_LITERAL_TYPE_NAN,
-} WasmLiteralType;
-
-typedef struct WasmLiteral {
- WasmLiteralType type;
- WasmStringSlice text;
-} WasmLiteral;
-
-WASM_EXTERN_C_BEGIN
+} WabtOpcodeInfo;
+
+typedef enum WabtLiteralType {
+ WABT_LITERAL_TYPE_INT,
+ WABT_LITERAL_TYPE_FLOAT,
+ WABT_LITERAL_TYPE_HEXFLOAT,
+ WABT_LITERAL_TYPE_INFINITY,
+ WABT_LITERAL_TYPE_NAN,
+} WabtLiteralType;
+
+typedef struct WabtLiteral {
+ WabtLiteralType type;
+ WabtStringSlice text;
+} WabtLiteral;
+
+WABT_EXTERN_C_BEGIN
/* return 1 if |alignment| matches the alignment of |opcode|, or if |alignment|
- * is WASM_USE_NATURAL_ALIGNMENT */
-WasmBool wasm_is_naturally_aligned(WasmOpcode opcode, uint32_t alignment);
+ * is WABT_USE_NATURAL_ALIGNMENT */
+WabtBool wabt_is_naturally_aligned(WabtOpcode opcode, uint32_t alignment);
-/* if |alignment| is WASM_USE_NATURAL_ALIGNMENT, return the alignment of
+/* if |alignment| is WABT_USE_NATURAL_ALIGNMENT, return the alignment of
* |opcode|, else return |alignment| */
-uint32_t wasm_get_opcode_alignment(WasmOpcode opcode, uint32_t alignment);
-
-WasmStringSlice wasm_empty_string_slice(void);
-WasmBool wasm_string_slice_eq_cstr(const WasmStringSlice* s1, const char* s2);
-WasmBool wasm_string_slice_startswith(const WasmStringSlice* s1, const char* s2);
-WasmStringSlice wasm_string_slice_from_cstr(const char* string);
-WasmBool wasm_string_slice_is_empty(const WasmStringSlice*);
-WasmBool wasm_string_slices_are_equal(const WasmStringSlice*,
- const WasmStringSlice*);
-void wasm_destroy_string_slice(struct WasmAllocator*, WasmStringSlice*);
-WasmResult wasm_read_file(struct WasmAllocator* allocator,
+uint32_t wabt_get_opcode_alignment(WabtOpcode opcode, uint32_t alignment);
+
+WabtStringSlice wabt_empty_string_slice(void);
+WabtBool wabt_string_slice_eq_cstr(const WabtStringSlice* s1, const char* s2);
+WabtBool wabt_string_slice_startswith(const WabtStringSlice* s1, const char* s2);
+WabtStringSlice wabt_string_slice_from_cstr(const char* string);
+WabtBool wabt_string_slice_is_empty(const WabtStringSlice*);
+WabtBool wabt_string_slices_are_equal(const WabtStringSlice*,
+ const WabtStringSlice*);
+void wabt_destroy_string_slice(struct WabtAllocator*, WabtStringSlice*);
+WabtResult wabt_read_file(struct WabtAllocator* allocator,
const char* filename,
void** out_data,
size_t* out_size);
-void wasm_default_source_error_callback(const WasmLocation*,
+void wabt_default_source_error_callback(const WabtLocation*,
const char* error,
const char* source_line,
size_t source_line_length,
size_t source_line_column_offset,
void* user_data);
-void wasm_default_binary_error_callback(uint32_t offset,
+void wabt_default_binary_error_callback(uint32_t offset,
const char* error,
void* user_data);
-void wasm_init_stdio();
+void wabt_init_stdio();
/* opcode info */
-extern WasmOpcodeInfo g_wasm_opcode_info[];
+extern WabtOpcodeInfo g_wabt_opcode_info[];
-static WASM_INLINE const char* wasm_get_opcode_name(WasmOpcode opcode) {
- assert(opcode < WASM_NUM_OPCODES);
- return g_wasm_opcode_info[opcode].name;
+static WABT_INLINE const char* wabt_get_opcode_name(WabtOpcode opcode) {
+ assert(opcode < WABT_NUM_OPCODES);
+ return g_wabt_opcode_info[opcode].name;
}
-static WASM_INLINE WasmType wasm_get_opcode_result_type(WasmOpcode opcode) {
- assert(opcode < WASM_NUM_OPCODES);
- return g_wasm_opcode_info[opcode].result_type;
+static WABT_INLINE WabtType wabt_get_opcode_result_type(WabtOpcode opcode) {
+ assert(opcode < WABT_NUM_OPCODES);
+ return g_wabt_opcode_info[opcode].result_type;
}
-static WASM_INLINE WasmType wasm_get_opcode_param_type_1(WasmOpcode opcode) {
- assert(opcode < WASM_NUM_OPCODES);
- return g_wasm_opcode_info[opcode].param1_type;
+static WABT_INLINE WabtType wabt_get_opcode_param_type_1(WabtOpcode opcode) {
+ assert(opcode < WABT_NUM_OPCODES);
+ return g_wabt_opcode_info[opcode].param1_type;
}
-static WASM_INLINE WasmType wasm_get_opcode_param_type_2(WasmOpcode opcode) {
- assert(opcode < WASM_NUM_OPCODES);
- return g_wasm_opcode_info[opcode].param2_type;
+static WABT_INLINE WabtType wabt_get_opcode_param_type_2(WabtOpcode opcode) {
+ assert(opcode < WABT_NUM_OPCODES);
+ return g_wabt_opcode_info[opcode].param2_type;
}
-static WASM_INLINE int wasm_get_opcode_memory_size(WasmOpcode opcode) {
- assert(opcode < WASM_NUM_OPCODES);
- return g_wasm_opcode_info[opcode].memory_size;
+static WABT_INLINE int wabt_get_opcode_memory_size(WabtOpcode opcode) {
+ assert(opcode < WABT_NUM_OPCODES);
+ return g_wabt_opcode_info[opcode].memory_size;
}
/* external kind */
-extern const char* g_wasm_kind_name[];
+extern const char* g_wabt_kind_name[];
-static WASM_INLINE const char* wasm_get_kind_name(WasmExternalKind kind) {
- assert(kind < WASM_NUM_EXTERNAL_KINDS);
- return g_wasm_kind_name[kind];
+static WABT_INLINE const char* wabt_get_kind_name(WabtExternalKind kind) {
+ assert(kind < WABT_NUM_EXTERNAL_KINDS);
+ return g_wabt_kind_name[kind];
}
/* reloc */
-extern const char* g_wasm_reloc_type_name[];
+extern const char* g_wabt_reloc_type_name[];
-static WASM_INLINE const char* wasm_get_reloc_type_name(WasmRelocType reloc) {
- assert(reloc < WASM_NUM_RELOC_TYPES);
- return g_wasm_reloc_type_name[reloc];
+static WABT_INLINE const char* wabt_get_reloc_type_name(WabtRelocType reloc) {
+ assert(reloc < WABT_NUM_RELOC_TYPES);
+ return g_wabt_reloc_type_name[reloc];
}
/* type */
-static WASM_INLINE const char* wasm_get_type_name(WasmType type) {
+static WABT_INLINE const char* wabt_get_type_name(WabtType type) {
switch (type) {
- case WASM_TYPE_I32: return "i32";
- case WASM_TYPE_I64: return "i64";
- case WASM_TYPE_F32: return "f32";
- case WASM_TYPE_F64: return "f64";
- case WASM_TYPE_ANYFUNC: return "anyfunc";
- case WASM_TYPE_FUNC: return "func";
- case WASM_TYPE_VOID: return "void";
- case WASM_TYPE_ANY: return "any";
+ case WABT_TYPE_I32: return "i32";
+ case WABT_TYPE_I64: return "i64";
+ case WABT_TYPE_F32: return "f32";
+ case WABT_TYPE_F64: return "f64";
+ case WABT_TYPE_ANYFUNC: return "anyfunc";
+ case WABT_TYPE_FUNC: return "func";
+ case WABT_TYPE_VOID: return "void";
+ case WABT_TYPE_ANY: return "any";
default: return NULL;
}
}
-WASM_EXTERN_C_END
+WABT_EXTERN_C_END
-#endif /* WASM_COMMON_H_ */
+#endif /* WABT_COMMON_H_ */
diff --git a/src/config.c b/src/config.c
index d59cfc86..e9dc087f 100644
--- a/src/config.c
+++ b/src/config.c
@@ -23,7 +23,7 @@
using _snprintf or vsnprintf will not-properly null-terminate, and will return
-1 instead of the number of characters needed on overflow. */
#if COMPILER_IS_MSVC
-int wasm_vsnprintf(char* str, size_t size, const char* format, va_list ap) {
+int wabt_vsnprintf(char* str, size_t size, const char* format, va_list ap) {
int result = -1;
if (size != 0)
result = _vsnprintf_s(str, size, _TRUNCATE, format, ap);
@@ -33,10 +33,10 @@ int wasm_vsnprintf(char* str, size_t size, const char* format, va_list ap) {
}
#if !HAVE_SNPRINTF
-int wasm_snprintf(char* str, size_t size, const char* format, ...) {
+int wabt_snprintf(char* str, size_t size, const char* format, ...) {
va_list args;
va_start(args, format);
- int result = wasm_vsnprintf(str, size, format, args);
+ int result = wabt_vsnprintf(str, size, format, args);
va_end(args);
return result;
}
diff --git a/src/config.h.in b/src/config.h.in
index 3f871d82..48393b84 100644
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -14,10 +14,10 @@
* limitations under the License.
*/
-#ifndef WASM_CONFIG_H_
-#define WASM_CONFIG_H_
+#ifndef WABT_CONFIG_H_
+#define WABT_CONFIG_H_
-/* TODO(binji): nice way to define these with WASM_ prefix? */
+/* TODO(binji): nice way to define these with WABT_ prefix? */
/* Whether <alloca.h> is available */
#cmakedefine01 HAVE_ALLOCA_H
@@ -61,35 +61,35 @@
#if COMPILER_IS_CLANG || COMPILER_IS_GNU
-#define WASM_UNUSED __attribute__ ((unused))
-#define WASM_WARN_UNUSED __attribute__ ((warn_unused_result))
-#define WASM_INLINE inline
-#define WASM_STATIC_ASSERT(x) _Static_assert((x), #x)
-#define WASM_UNLIKELY(x) __builtin_expect(!!(x), 0)
-#define WASM_LIKELY(x) __builtin_expect(!!(x), 1)
-#define WASM_PRINTF_FORMAT(format_arg, first_arg) \
+#define WABT_UNUSED __attribute__ ((unused))
+#define WABT_WARN_UNUSED __attribute__ ((warn_unused_result))
+#define WABT_INLINE inline
+#define WABT_STATIC_ASSERT(x) _Static_assert((x), #x)
+#define WABT_UNLIKELY(x) __builtin_expect(!!(x), 0)
+#define WABT_LIKELY(x) __builtin_expect(!!(x), 1)
+#define WABT_PRINTF_FORMAT(format_arg, first_arg) \
__attribute__((format(printf, (format_arg), (first_arg))))
#if SIZEOF_INT == 4
-#define wasm_clz_u32(x) __builtin_clz(x)
-#define wasm_ctz_u32(x) __builtin_ctz(x)
-#define wasm_popcount_u32(x) __builtin_popcount(x)
+#define wabt_clz_u32(x) __builtin_clz(x)
+#define wabt_ctz_u32(x) __builtin_ctz(x)
+#define wabt_popcount_u32(x) __builtin_popcount(x)
#elif SIZEOF_LONG == 4
-#define wasm_clz_u32(x) __builtin_clzl(x)
-#define wasm_ctz_u32(x) __builtin_ctzl(x)
-#define wasm_popcount_u32(x) __builtin_popcountl(x)
+#define wabt_clz_u32(x) __builtin_clzl(x)
+#define wabt_ctz_u32(x) __builtin_ctzl(x)
+#define wabt_popcount_u32(x) __builtin_popcountl(x)
#else
#error "don't know how to define 32-bit builtins"
#endif
#if SIZEOF_LONG == 8
-#define wasm_clz_u64(x) __builtin_clzl(x)
-#define wasm_ctz_u64(x) __builtin_ctzl(x)
-#define wasm_popcount_u64(x) __builtin_popcountl(x)
+#define wabt_clz_u64(x) __builtin_clzl(x)
+#define wabt_ctz_u64(x) __builtin_ctzl(x)
+#define wabt_popcount_u64(x) __builtin_popcountl(x)
#elif SIZEOF_LONG_LONG == 8
-#define wasm_clz_u64(x) __builtin_clzll(x)
-#define wasm_ctz_u64(x) __builtin_ctzll(x)
-#define wasm_popcount_u64(x) __builtin_popcountll(x)
+#define wabt_clz_u64(x) __builtin_clzll(x)
+#define wabt_ctz_u64(x) __builtin_ctzll(x)
+#define wabt_popcount_u64(x) __builtin_popcountll(x)
#else
#error "don't know how to define 64-bit builtins"
#endif
@@ -99,23 +99,23 @@
#elif COMPILER_IS_MSVC
#include <vcruntime_string.h>
-#define WASM_UNUSED
-#define WASM_WARN_UNUSED _Check_return_
-#define WASM_INLINE __inline
-#define WASM_STATIC_ASSERT(x) _STATIC_ASSERT(x)
-#define WASM_UNLIKELY(x) (x)
-#define WASM_LIKELY(x) (x)
-#define WASM_PRINTF_FORMAT(format_arg, first_arg)
+#define WABT_UNUSED
+#define WABT_WARN_UNUSED _Check_return_
+#define WABT_INLINE __inline
+#define WABT_STATIC_ASSERT(x) _STATIC_ASSERT(x)
+#define WABT_UNLIKELY(x) (x)
+#define WABT_LIKELY(x) (x)
+#define WABT_PRINTF_FORMAT(format_arg, first_arg)
#define WABT_UNREACHABLE __assume(0)
-__inline unsigned long wasm_clz_u32(unsigned long mask) {
+__inline unsigned long wabt_clz_u32(unsigned long mask) {
unsigned long index;
_BitScanReverse(&index, mask);
return sizeof(unsigned long) * 8 - (index + 1);
}
-__inline unsigned long wasm_clz_u64(unsigned __int64 mask) {
+__inline unsigned long wabt_clz_u64(unsigned __int64 mask) {
#if _M_X64
unsigned long index;
_BitScanReverse64(&index, mask);
@@ -138,13 +138,13 @@ __inline unsigned long wasm_clz_u64(unsigned __int64 mask) {
#endif
}
-__inline unsigned long wasm_ctz_u32(unsigned long mask) {
+__inline unsigned long wabt_ctz_u32(unsigned long mask) {
unsigned long index;
_BitScanForward(&index, mask);
return index;
}
-__inline unsigned long wasm_ctz_u64(unsigned __int64 mask) {
+__inline unsigned long wabt_ctz_u64(unsigned __int64 mask) {
#if _M_X64
unsigned long index;
_BitScanForward64(&index, mask);
@@ -152,19 +152,19 @@ __inline unsigned long wasm_ctz_u64(unsigned __int64 mask) {
#elif _M_IX86
unsigned long low_mask = (unsigned long)mask;
if (low_mask) {
- return wasm_ctz_u32(low_mask);
+ return wabt_ctz_u32(low_mask);
}
unsigned long high_mask;
memcpy(&high_mask, (unsigned char*)&mask + sizeof(unsigned long),
sizeof(unsigned long));
- return sizeof(unsigned long) * 8 + wasm_ctz_u32(high_mask);
+ return sizeof(unsigned long) * 8 + wabt_ctz_u32(high_mask);
#else
#error unexpected architecture
#endif
}
-#define wasm_popcount_u32 __popcnt
+#define wabt_popcount_u32 __popcnt
#if _M_X64
#elif _M_IX86
__inline unsigned __int64 __popcnt64(unsigned __int64 value) {
@@ -173,12 +173,12 @@ __inline unsigned __int64 __popcnt64(unsigned __int64 value) {
memcpy(&high_value, (unsigned char*)&value + sizeof(unsigned long),
sizeof(unsigned long));
memcpy(&low_value, &value, sizeof(unsigned long));
- return wasm_popcount_u32(high_value) + wasm_popcount_u32(low_value);
+ return wabt_popcount_u32(high_value) + wabt_popcount_u32(low_value);
}
#else
#error unexpected architecture
#endif
-#define wasm_popcount_u64 __popcnt64
+#define wabt_popcount_u64 __popcnt64
#else
@@ -215,20 +215,20 @@ __inline unsigned __int64 __popcnt64(unsigned __int64 value) {
#if HAVE_SNPRINTF
-#define wasm_snprintf snprintf
+#define wabt_snprintf snprintf
#elif COMPILER_IS_MSVC
/* can't just use _snprintf because it doesn't always null terminate */
#include <stdarg.h>
-int wasm_snprintf(char* str, size_t size, const char* format, ...);
+int wabt_snprintf(char* str, size_t size, const char* format, ...);
#else
#error no snprintf
#endif
#if COMPILER_IS_MSVC
/* can't just use vsnprintf because it doesn't always null terminate */
-int wasm_vsnprintf(char* str, size_t size, const char* format, va_list ap);
+int wabt_vsnprintf(char* str, size_t size, const char* format, va_list ap);
#else
-#define wasm_vsnprintf vsnprintf
+#define wabt_vsnprintf vsnprintf
#endif
#if !HAVE_SSIZE_T
@@ -243,4 +243,4 @@ typedef int ssize_t;
#endif
#endif
-#endif /* WASM_CONFIG_H_ */
+#endif /* WABT_CONFIG_H_ */
diff --git a/src/emscripten-exported.json b/src/emscripten-exported.json
index cc76519e..5319e237 100644
--- a/src/emscripten-exported.json
+++ b/src/emscripten-exported.json
@@ -1,208 +1,217 @@
-["_wasm_append_element",
-"_wasm_append_implicit_func_type",
-"_wasm_append_module_field",
-"_wasm_apply_names",
-"_wasm_ast_format_error",
-"_wasm_ast_lexer_get_allocator",
-"_wasm_ast_lexer_get_source_line",
-"_wasm_ast_lexer_lex",
-"_wasm_ast_parser_error",
-"_wasm_ast_parser_parse",
-"_wasm_call_host",
-"_wasm_check_assert_invalid_and_malformed",
-"_wasm_check_ast",
-"_wasm_check_names",
-"_wasm_close_file_writer",
-"_wasm_close_mem_writer",
-"_wasm_default_assert_invalid_source_error_callback",
-"_wasm_default_assert_malformed_source_error_callback",
-"_wasm_default_binary_error_callback",
-"_wasm_default_source_error_callback",
-"_wasm_destroy_action",
-"_wasm_destroy_ast_lexer",
-"_wasm_destroy_block",
-"_wasm_destroy_command",
-"_wasm_destroy_command_vector_and_elements",
-"_wasm_destroy_data_segment",
-"_wasm_destroy_elem_segment",
-"_wasm_destroy_export",
-"_wasm_destroy_exported_func",
-"_wasm_destroy_exported_memory",
-"_wasm_destroy_exported_table",
-"_wasm_destroy_expr",
-"_wasm_destroy_expr_list",
-"_wasm_destroy_func",
-"_wasm_destroy_func_declaration",
-"_wasm_destroy_func_fields",
-"_wasm_destroy_func_signature",
-"_wasm_destroy_func_type",
-"_wasm_destroy_global",
-"_wasm_destroy_import",
-"_wasm_destroy_interpreter_module",
-"_wasm_destroy_interpreter_thread",
-"_wasm_destroy_memory",
-"_wasm_destroy_module",
-"_wasm_destroy_opcnt_data",
-"_wasm_destroy_optional_export",
-"_wasm_destroy_output_buffer",
-"_wasm_destroy_raw_module",
-"_wasm_destroy_script",
-"_wasm_destroy_stack_allocator",
-"_wasm_destroy_string_slice",
-"_wasm_destroy_table",
-"_wasm_destroy_text_list",
-"_wasm_destroy_var",
-"_wasm_destroy_var_vector_and_elements",
-"_wasm_disassemble_module",
-"_wasm_empty_string_slice",
-"_wasm_ensure_capacity",
-"_wasm_extend_elements",
-"_wasm_generate_names",
-"_wasm_get_export_by_name",
-"_wasm_get_func_by_var",
-"_wasm_get_func_index_by_var",
-"_wasm_get_func_type_by_var",
-"_wasm_get_func_type_index_by_decl",
-"_wasm_get_func_type_index_by_sig",
-"_wasm_get_func_type_index_by_var",
-"_wasm_get_global_by_var",
-"_wasm_get_global_index_by_var",
-"_wasm_get_index_from_var",
-"_wasm_get_interpreter_export_by_name",
-"_wasm_get_interpreter_import_by_name",
-"_wasm_get_libc_allocator",
-"_wasm_get_local_index_by_var",
-"_wasm_get_memory_by_var",
-"_wasm_get_memory_index_by_var",
-"_wasm_get_opcode_alignment",
-"_wasm_get_table_by_var",
-"_wasm_get_table_index_by_var",
-"_wasm_hash_entry_is_free",
-"_wasm_init_file_stream_from_existing",
-"_wasm_init_file_writer",
-"_wasm_init_file_writer_existing",
-"_wasm_init_interpreter_thread",
-"_wasm_init_mem_writer",
-"_wasm_init_stack_allocator",
-"_wasm_init_stderr_stream",
-"_wasm_init_stdio",
-"_wasm_init_stdout_stream",
-"_wasm_init_stream",
-"_wasm_insert_binding",
-"_wasm_is_naturally_aligned",
-"_wasm_make_type_binding_reverse_mapping",
-"_wasm_move_data",
-"_wasm_new_ast_buffer_lexer",
-"_wasm_new_ast_file_lexer",
-"_wasm_new_binary_expr",
-"_wasm_new_block_expr",
-"_wasm_new_br_expr",
-"_wasm_new_br_if_expr",
-"_wasm_new_br_table_expr",
-"_wasm_new_call_expr",
-"_wasm_new_call_indirect_expr",
-"_wasm_new_compare_expr",
-"_wasm_new_const_expr",
-"_wasm_new_convert_expr",
-"_wasm_new_current_memory_expr",
-"_wasm_new_drop_expr",
-"_wasm_new_empty_expr",
-"_wasm_new_get_global_expr",
-"_wasm_new_get_local_expr",
-"_wasm_new_grow_memory_expr",
-"_wasm_new_if_expr",
-"_wasm_new_load_expr",
-"_wasm_new_loop_expr",
-"_wasm_new_nop_expr",
-"_wasm_new_opcnt_data",
-"_wasm_new_return_expr",
-"_wasm_new_select_expr",
-"_wasm_new_set_global_expr",
-"_wasm_new_set_local_expr",
-"_wasm_new_store_expr",
-"_wasm_new_tee_local_expr",
-"_wasm_new_unary_expr",
-"_wasm_new_unreachable_expr",
-"_wasm_offsetof_allocator_alloc",
-"_wasm_offsetof_allocator_destroy",
-"_wasm_offsetof_allocator_free",
-"_wasm_offsetof_allocator_mark",
-"_wasm_offsetof_allocator_print_stats",
-"_wasm_offsetof_allocator_realloc",
-"_wasm_offsetof_allocator_reset_to_mark",
-"_wasm_offsetof_binary_error_handler_on_error",
-"_wasm_offsetof_binary_error_handler_user_data",
-"_wasm_offsetof_location_filename",
-"_wasm_offsetof_location_first_column",
-"_wasm_offsetof_location_last_column",
-"_wasm_offsetof_location_line",
-"_wasm_offsetof_memory_writer_base",
-"_wasm_offsetof_memory_writer_buf",
-"_wasm_offsetof_output_buffer_allocator",
-"_wasm_offsetof_output_buffer_capacity",
-"_wasm_offsetof_output_buffer_size",
-"_wasm_offsetof_output_buffer_start",
-"_wasm_offsetof_read_binary_options_read_debug_names",
-"_wasm_offsetof_source_error_handler_on_error",
-"_wasm_offsetof_source_error_handler_source_line_max_length",
-"_wasm_offsetof_source_error_handler_user_data",
-"_wasm_offsetof_stack_allocator_allocator",
-"_wasm_offsetof_stream_log_stream",
-"_wasm_offsetof_stream_offset",
-"_wasm_offsetof_stream_result",
-"_wasm_offsetof_stream_writer",
-"_wasm_offsetof_string_slice_length",
-"_wasm_offsetof_string_slice_start",
-"_wasm_offsetof_write_binary_options_canonicalize_lebs",
-"_wasm_offsetof_write_binary_options_log_stream",
-"_wasm_offsetof_write_binary_options_write_debug_names",
-"_wasm_offsetof_writer_move_data",
-"_wasm_offsetof_writer_write_data",
-"_wasm_parse_ast",
-"_wasm_parse_double",
-"_wasm_parse_float",
-"_wasm_parse_hexdigit",
-"_wasm_parse_int32",
-"_wasm_parse_int64",
-"_wasm_parse_options",
-"_wasm_parse_uint64",
-"_wasm_print_help",
-"_wasm_push_thread_value",
-"_wasm_read_binary",
-"_wasm_read_binary_ast",
-"_wasm_read_binary_interpreter",
-"_wasm_read_binary_opcnt",
-"_wasm_read_file",
-"_wasm_resize_vector",
-"_wasm_run_interpreter",
-"_wasm_sizeof_allocator",
-"_wasm_sizeof_binary_error_handler",
-"_wasm_sizeof_location",
-"_wasm_sizeof_memory_writer",
-"_wasm_sizeof_output_buffer",
-"_wasm_sizeof_read_binary_options",
-"_wasm_sizeof_script",
-"_wasm_sizeof_source_error_handler",
-"_wasm_sizeof_stack_allocator",
-"_wasm_sizeof_stream",
-"_wasm_sizeof_string_slice",
-"_wasm_sizeof_write_binary_options",
-"_wasm_sizeof_writer",
-"_wasm_steal_mem_writer_output_buffer",
-"_wasm_string_slices_are_equal",
-"_wasm_trace_pc",
-"_wasm_visit_func",
-"_wasm_write_ast",
-"_wasm_write_binary_module",
-"_wasm_write_binary_script",
-"_wasm_write_binary_spec_script",
-"_wasm_write_data",
-"_wasm_write_data_at",
-"_wasm_write_double_hex",
-"_wasm_write_float_hex",
-"_wasm_write_memory_dump",
-"_wasm_write_output_buffer_to_file",
-"_wasm_write_u32",
-"_wasm_write_u64",
-"_wasm_write_u8",
-"_wasm_writef"]
+["_wabt_append_element",
+"_wabt_append_host_module",
+"_wabt_append_implicit_func_type",
+"_wabt_append_module_field",
+"_wabt_apply_names",
+"_wabt_ast_format_error",
+"_wabt_ast_lexer_get_allocator",
+"_wabt_ast_lexer_get_source_line",
+"_wabt_ast_lexer_lex",
+"_wabt_ast_parser_error",
+"_wabt_ast_parser_parse",
+"_wabt_call_host",
+"_wabt_check_assert_invalid_and_malformed",
+"_wabt_check_ast",
+"_wabt_check_names",
+"_wabt_close_file_writer",
+"_wabt_close_mem_writer",
+"_wabt_default_assert_invalid_source_error_callback",
+"_wabt_default_assert_malformed_source_error_callback",
+"_wabt_default_binary_error_callback",
+"_wabt_default_source_error_callback",
+"_wabt_destroy_action",
+"_wabt_destroy_ast_lexer",
+"_wabt_destroy_binding_hash",
+"_wabt_destroy_block",
+"_wabt_destroy_command",
+"_wabt_destroy_command_vector_and_elements",
+"_wabt_destroy_data_segment",
+"_wabt_destroy_elem_segment",
+"_wabt_destroy_export",
+"_wabt_destroy_exported_func",
+"_wabt_destroy_exported_memory",
+"_wabt_destroy_exported_table",
+"_wabt_destroy_expr",
+"_wabt_destroy_expr_list",
+"_wabt_destroy_func",
+"_wabt_destroy_func_declaration",
+"_wabt_destroy_func_fields",
+"_wabt_destroy_func_signature",
+"_wabt_destroy_func_type",
+"_wabt_destroy_global",
+"_wabt_destroy_import",
+"_wabt_destroy_interpreter_environment",
+"_wabt_destroy_interpreter_thread",
+"_wabt_destroy_memory",
+"_wabt_destroy_module",
+"_wabt_destroy_optional_export",
+"_wabt_destroy_output_buffer",
+"_wabt_destroy_raw_module",
+"_wabt_destroy_script",
+"_wabt_destroy_stack_allocator",
+"_wabt_destroy_string_slice",
+"_wabt_destroy_table",
+"_wabt_destroy_text_list",
+"_wabt_destroy_var",
+"_wabt_destroy_var_vector_and_elements",
+"_wabt_disassemble",
+"_wabt_disassemble_module",
+"_wabt_empty_string_slice",
+"_wabt_ensure_capacity",
+"_wabt_extend_elements",
+"_wabt_find_binding_index_by_name",
+"_wabt_generate_names",
+"_wabt_get_export_by_name",
+"_wabt_get_first_module",
+"_wabt_get_func_by_var",
+"_wabt_get_func_index_by_var",
+"_wabt_get_func_type_by_var",
+"_wabt_get_func_type_index_by_decl",
+"_wabt_get_func_type_index_by_sig",
+"_wabt_get_func_type_index_by_var",
+"_wabt_get_global_by_var",
+"_wabt_get_global_index_by_var",
+"_wabt_get_index_from_var",
+"_wabt_get_interpreter_export_by_name",
+"_wabt_get_libc_allocator",
+"_wabt_get_local_index_by_var",
+"_wabt_get_memory_by_var",
+"_wabt_get_memory_index_by_var",
+"_wabt_get_module_by_var",
+"_wabt_get_module_index_by_var",
+"_wabt_get_opcode_alignment",
+"_wabt_get_table_by_var",
+"_wabt_get_table_index_by_var",
+"_wabt_hash_entry_is_free",
+"_wabt_init_file_stream_from_existing",
+"_wabt_init_file_writer",
+"_wabt_init_file_writer_existing",
+"_wabt_init_interpreter_environment",
+"_wabt_init_interpreter_thread",
+"_wabt_init_mem_writer",
+"_wabt_init_mem_writer_existing",
+"_wabt_init_output_buffer",
+"_wabt_init_stack_allocator",
+"_wabt_init_stderr_stream",
+"_wabt_init_stdio",
+"_wabt_init_stdout_stream",
+"_wabt_init_stream",
+"_wabt_insert_binding",
+"_wabt_is_nan_f32",
+"_wabt_is_nan_f64",
+"_wabt_is_naturally_aligned",
+"_wabt_make_type_binding_reverse_mapping",
+"_wabt_move_data",
+"_wabt_new_ast_buffer_lexer",
+"_wabt_new_ast_file_lexer",
+"_wabt_new_binary_expr",
+"_wabt_new_block_expr",
+"_wabt_new_br_expr",
+"_wabt_new_br_if_expr",
+"_wabt_new_br_table_expr",
+"_wabt_new_call_expr",
+"_wabt_new_call_indirect_expr",
+"_wabt_new_compare_expr",
+"_wabt_new_const_expr",
+"_wabt_new_convert_expr",
+"_wabt_new_current_memory_expr",
+"_wabt_new_drop_expr",
+"_wabt_new_empty_expr",
+"_wabt_new_get_global_expr",
+"_wabt_new_get_local_expr",
+"_wabt_new_grow_memory_expr",
+"_wabt_new_if_expr",
+"_wabt_new_load_expr",
+"_wabt_new_loop_expr",
+"_wabt_new_nop_expr",
+"_wabt_new_return_expr",
+"_wabt_new_select_expr",
+"_wabt_new_set_global_expr",
+"_wabt_new_set_local_expr",
+"_wabt_new_store_expr",
+"_wabt_new_tee_local_expr",
+"_wabt_new_unary_expr",
+"_wabt_new_unreachable_expr",
+"_wabt_offsetof_allocator_alloc",
+"_wabt_offsetof_allocator_destroy",
+"_wabt_offsetof_allocator_free",
+"_wabt_offsetof_allocator_mark",
+"_wabt_offsetof_allocator_print_stats",
+"_wabt_offsetof_allocator_realloc",
+"_wabt_offsetof_allocator_reset_to_mark",
+"_wabt_offsetof_binary_error_handler_on_error",
+"_wabt_offsetof_binary_error_handler_user_data",
+"_wabt_offsetof_location_filename",
+"_wabt_offsetof_location_first_column",
+"_wabt_offsetof_location_last_column",
+"_wabt_offsetof_location_line",
+"_wabt_offsetof_memory_writer_base",
+"_wabt_offsetof_memory_writer_buf",
+"_wabt_offsetof_output_buffer_allocator",
+"_wabt_offsetof_output_buffer_capacity",
+"_wabt_offsetof_output_buffer_size",
+"_wabt_offsetof_output_buffer_start",
+"_wabt_offsetof_read_binary_options_read_debug_names",
+"_wabt_offsetof_source_error_handler_on_error",
+"_wabt_offsetof_source_error_handler_source_line_max_length",
+"_wabt_offsetof_source_error_handler_user_data",
+"_wabt_offsetof_stack_allocator_allocator",
+"_wabt_offsetof_stream_log_stream",
+"_wabt_offsetof_stream_offset",
+"_wabt_offsetof_stream_result",
+"_wabt_offsetof_stream_writer",
+"_wabt_offsetof_string_slice_length",
+"_wabt_offsetof_string_slice_start",
+"_wabt_offsetof_write_binary_options_canonicalize_lebs",
+"_wabt_offsetof_write_binary_options_log_stream",
+"_wabt_offsetof_write_binary_options_write_debug_names",
+"_wabt_offsetof_writer_move_data",
+"_wabt_offsetof_writer_write_data",
+"_wabt_parse_ast",
+"_wabt_parse_double",
+"_wabt_parse_float",
+"_wabt_parse_hexdigit",
+"_wabt_parse_int32",
+"_wabt_parse_int64",
+"_wabt_parse_options",
+"_wabt_parse_uint64",
+"_wabt_print_help",
+"_wabt_push_thread_value",
+"_wabt_read_binary",
+"_wabt_read_binary_ast",
+"_wabt_read_binary_interpreter",
+"_wabt_read_file",
+"_wabt_resize_vector",
+"_wabt_run_interpreter",
+"_wabt_sizeof_allocator",
+"_wabt_sizeof_binary_error_handler",
+"_wabt_sizeof_location",
+"_wabt_sizeof_memory_writer",
+"_wabt_sizeof_output_buffer",
+"_wabt_sizeof_read_binary_options",
+"_wabt_sizeof_script",
+"_wabt_sizeof_source_error_handler",
+"_wabt_sizeof_stack_allocator",
+"_wabt_sizeof_stream",
+"_wabt_sizeof_string_slice",
+"_wabt_sizeof_write_binary_options",
+"_wabt_sizeof_writer",
+"_wabt_steal_mem_writer_output_buffer",
+"_wabt_string_slice_from_cstr",
+"_wabt_string_slices_are_equal",
+"_wabt_trace_pc",
+"_wabt_visit_func",
+"_wabt_write_ast",
+"_wabt_write_binary_module",
+"_wabt_write_binary_script",
+"_wabt_write_binary_spec_script",
+"_wabt_write_data",
+"_wabt_write_data_at",
+"_wabt_write_double_hex",
+"_wabt_write_float_hex",
+"_wabt_write_memory_dump",
+"_wabt_write_output_buffer_to_file",
+"_wabt_write_u32",
+"_wabt_write_u64",
+"_wabt_write_u8",
+"_wabt_writef"] \ No newline at end of file
diff --git a/src/emscripten-helpers.c b/src/emscripten-helpers.c
index a08bd830..e4795352 100644
--- a/src/emscripten-helpers.c
+++ b/src/emscripten-helpers.c
@@ -14,28 +14,28 @@
* limitations under the License.
*/
-#ifndef WASM_EMSCRIPTEN_HELPERS_H_
-#define WASM_EMSCRIPTEN_HELPERS_H_
+#ifndef WABT_EMSCRIPTEN_HELPERS_H_
+#define WABT_EMSCRIPTEN_HELPERS_H_
#include <stddef.h>
-#include "wasm-allocator.h"
-#include "wasm-ast.h"
-#include "wasm-binary-reader.h"
-#include "wasm-binary-writer.h"
-#include "wasm-common.h"
-#include "wasm-stack-allocator.h"
-#include "wasm-stream.h"
-#include "wasm-writer.h"
+#include "allocator.h"
+#include "ast.h"
+#include "binary-reader.h"
+#include "binary-writer.h"
+#include "common.h"
+#include "stack-allocator.h"
+#include "stream.h"
+#include "writer.h"
/* TODO(binji): it would be nicer to generate this as static data, but it's not
* currently easy to do. Maybe use LLVM's python bindings for this? */
#define DEFINE_SIZEOF(Name, name) \
- size_t wasm_sizeof_##name(void) { return sizeof(Name); }
+ size_t wabt_sizeof_##name(void) { return sizeof(Name); }
#define DEFINE_OFFSETOF(Name, name, member) \
- size_t wasm_offsetof_##name##_##member(void) { \
+ size_t wabt_offsetof_##name##_##member(void) { \
return offsetof(Name, member); \
}
@@ -62,61 +62,61 @@
DEFINE_SIZEOF(Name, name) \
FOREACH(DEFINE_OFFSETOF, Name, name, __VA_ARGS__)
-WASM_EXTERN_C_BEGIN
+WABT_EXTERN_C_BEGIN
/* clang-format off */
DEFINE_STRUCT(
- WasmAllocator, allocator,
+ WabtAllocator, allocator,
alloc, realloc, free, destroy, mark, reset_to_mark, print_stats)
DEFINE_STRUCT(
- WasmBinaryErrorHandler, binary_error_handler,
+ WabtBinaryErrorHandler, binary_error_handler,
on_error, user_data)
DEFINE_STRUCT(
- WasmLocation, location,
+ WabtLocation, location,
filename, line, first_column, last_column)
DEFINE_STRUCT(
- WasmMemoryWriter, memory_writer,
+ WabtMemoryWriter, memory_writer,
base, buf)
DEFINE_STRUCT(
- WasmOutputBuffer, output_buffer,
+ WabtOutputBuffer, output_buffer,
allocator, start, size, capacity)
DEFINE_STRUCT(
- WasmReadBinaryOptions, read_binary_options,
+ WabtReadBinaryOptions, read_binary_options,
read_debug_names)
DEFINE_STRUCT0(
- WasmScript, script)
+ WabtScript, script)
DEFINE_STRUCT(
- WasmSourceErrorHandler, source_error_handler,
+ WabtSourceErrorHandler, source_error_handler,
on_error, source_line_max_length, user_data)
DEFINE_STRUCT(
- WasmStackAllocator, stack_allocator,
+ WabtStackAllocator, stack_allocator,
allocator);
DEFINE_STRUCT(
- WasmStream, stream,
+ WabtStream, stream,
writer, offset, result, log_stream)
DEFINE_STRUCT(
- WasmStringSlice, string_slice,
+ WabtStringSlice, string_slice,
start, length)
DEFINE_STRUCT(
- WasmWriter, writer,
+ WabtWriter, writer,
write_data, move_data)
DEFINE_STRUCT(
- WasmWriteBinaryOptions, write_binary_options,
+ WabtWriteBinaryOptions, write_binary_options,
log_stream, canonicalize_lebs, write_debug_names)
/* clang-format on */
-WASM_EXTERN_C_END
+WABT_EXTERN_C_END
-#endif /* WASM_EMSCRIPTEN_HELPERS_H_ */
+#endif /* WABT_EMSCRIPTEN_HELPERS_H_ */
diff --git a/src/generate-names.c b/src/generate-names.c
index 8ae41ebc..cab129ba 100644
--- a/src/generate-names.c
+++ b/src/generate-names.c
@@ -24,159 +24,159 @@
#define CHECK_RESULT(expr) \
do { \
- if (WASM_FAILED(expr)) \
- return WASM_ERROR; \
+ if (WABT_FAILED(expr)) \
+ return WABT_ERROR; \
} while (0)
typedef struct Context {
- WasmAllocator* allocator;
- WasmModule* module;
- WasmExprVisitor visitor;
- WasmStringSliceVector index_to_name;
+ WabtAllocator* allocator;
+ WabtModule* module;
+ WabtExprVisitor visitor;
+ WabtStringSliceVector index_to_name;
uint32_t label_count;
} Context;
-static WasmBool has_name(WasmStringSlice* str) {
+static WabtBool has_name(WabtStringSlice* str) {
return str->length > 0;
}
-static void generate_name(WasmAllocator* allocator,
+static void generate_name(WabtAllocator* allocator,
const char* prefix,
uint32_t index,
- WasmStringSlice* str) {
+ WabtStringSlice* str) {
size_t prefix_len = strlen(prefix);
size_t buffer_len = prefix_len + 20; /* add space for the number */
char* buffer = alloca(buffer_len);
- int actual_len = wasm_snprintf(buffer, buffer_len, "%s%u", prefix, index);
+ int actual_len = wabt_snprintf(buffer, buffer_len, "%s%u", prefix, index);
- WasmStringSlice buf;
+ WabtStringSlice buf;
buf.length = actual_len;
buf.start = buffer;
- *str = wasm_dup_string_slice(allocator, buf);
+ *str = wabt_dup_string_slice(allocator, buf);
}
-static void maybe_generate_name(WasmAllocator* allocator,
+static void maybe_generate_name(WabtAllocator* allocator,
const char* prefix,
uint32_t index,
- WasmStringSlice* str) {
+ WabtStringSlice* str) {
if (!has_name(str))
generate_name(allocator, prefix, index, str);
}
-static void generate_and_bind_name(WasmAllocator* allocator,
- WasmBindingHash* bindings,
+static void generate_and_bind_name(WabtAllocator* allocator,
+ WabtBindingHash* bindings,
const char* prefix,
uint32_t index,
- WasmStringSlice* str) {
+ WabtStringSlice* str) {
generate_name(allocator, prefix, index, str);
- WasmBinding* binding;
- binding = wasm_insert_binding(allocator, bindings, str);
+ WabtBinding* binding;
+ binding = wabt_insert_binding(allocator, bindings, str);
binding->index = index;
}
-static void maybe_generate_and_bind_name(WasmAllocator* allocator,
- WasmBindingHash* bindings,
+static void maybe_generate_and_bind_name(WabtAllocator* allocator,
+ WabtBindingHash* bindings,
const char* prefix,
uint32_t index,
- WasmStringSlice* str) {
+ WabtStringSlice* str) {
if (!has_name(str))
generate_and_bind_name(allocator, bindings, prefix, index, str);
}
-static void generate_and_bind_local_names(WasmAllocator* allocator,
- WasmStringSliceVector* index_to_name,
- WasmBindingHash* bindings,
+static void generate_and_bind_local_names(WabtAllocator* allocator,
+ WabtStringSliceVector* index_to_name,
+ WabtBindingHash* bindings,
const char* prefix) {
size_t i;
for (i = 0; i < index_to_name->size; ++i) {
- WasmStringSlice* old_name = &index_to_name->data[i];
+ WabtStringSlice* old_name = &index_to_name->data[i];
if (has_name(old_name))
continue;
- WasmStringSlice new_name;
+ WabtStringSlice new_name;
generate_and_bind_name(allocator, bindings, prefix, i, &new_name);
index_to_name->data[i] = new_name;
}
}
-static WasmResult begin_block_expr(WasmExpr* expr, void* user_data) {
+static WabtResult begin_block_expr(WabtExpr* expr, void* user_data) {
Context* ctx = user_data;
maybe_generate_name(ctx->allocator, "$B", ctx->label_count++,
&expr->block.label);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult begin_loop_expr(WasmExpr* expr, void* user_data) {
+static WabtResult begin_loop_expr(WabtExpr* expr, void* user_data) {
Context* ctx = user_data;
maybe_generate_name(ctx->allocator, "$L", ctx->label_count++,
&expr->loop.label);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult begin_if_expr(WasmExpr* expr, void* user_data) {
+static WabtResult begin_if_expr(WabtExpr* expr, void* user_data) {
Context* ctx = user_data;
maybe_generate_name(ctx->allocator, "$L", ctx->label_count++,
&expr->if_.true_.label);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult visit_func(Context* ctx,
+static WabtResult visit_func(Context* ctx,
uint32_t func_index,
- WasmFunc* func) {
+ WabtFunc* func) {
maybe_generate_and_bind_name(ctx->allocator, &ctx->module->func_bindings,
"$f", func_index, &func->name);
- wasm_make_type_binding_reverse_mapping(
+ wabt_make_type_binding_reverse_mapping(
ctx->allocator, &func->decl.sig.param_types, &func->param_bindings,
&ctx->index_to_name);
generate_and_bind_local_names(ctx->allocator, &ctx->index_to_name,
&func->param_bindings, "$p");
- wasm_make_type_binding_reverse_mapping(ctx->allocator, &func->local_types,
+ wabt_make_type_binding_reverse_mapping(ctx->allocator, &func->local_types,
&func->local_bindings,
&ctx->index_to_name);
generate_and_bind_local_names(ctx->allocator, &ctx->index_to_name,
&func->local_bindings, "$l");
ctx->label_count = 0;
- CHECK_RESULT(wasm_visit_func(func, &ctx->visitor));
- return WASM_OK;
+ CHECK_RESULT(wabt_visit_func(func, &ctx->visitor));
+ return WABT_OK;
}
-static WasmResult visit_global(Context* ctx,
+static WabtResult visit_global(Context* ctx,
uint32_t global_index,
- WasmGlobal* global) {
+ WabtGlobal* global) {
maybe_generate_and_bind_name(ctx->allocator, &ctx->module->global_bindings,
"$g", global_index, &global->name);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult visit_func_type(Context* ctx,
+static WabtResult visit_func_type(Context* ctx,
uint32_t func_type_index,
- WasmFuncType* func_type) {
+ WabtFuncType* func_type) {
maybe_generate_and_bind_name(ctx->allocator, &ctx->module->func_type_bindings,
"$t", func_type_index, &func_type->name);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult visit_table(Context* ctx,
+static WabtResult visit_table(Context* ctx,
uint32_t table_index,
- WasmTable* table) {
+ WabtTable* table) {
maybe_generate_and_bind_name(ctx->allocator, &ctx->module->table_bindings,
"$T", table_index, &table->name);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult visit_memory(Context* ctx,
+static WabtResult visit_memory(Context* ctx,
uint32_t memory_index,
- WasmMemory* memory) {
+ WabtMemory* memory) {
maybe_generate_and_bind_name(ctx->allocator, &ctx->module->memory_bindings,
"$M", memory_index, &memory->name);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult visit_module(Context* ctx, WasmModule* module) {
+static WabtResult visit_module(Context* ctx, WabtModule* module) {
size_t i;
for (i = 0; i < module->globals.size; ++i)
CHECK_RESULT(visit_global(ctx, i, module->globals.data[i]));
@@ -188,19 +188,19 @@ static WasmResult visit_module(Context* ctx, WasmModule* module) {
CHECK_RESULT(visit_table(ctx, i, module->tables.data[i]));
for (i = 0; i < module->memories.size; ++i)
CHECK_RESULT(visit_memory(ctx, i, module->memories.data[i]));
- return WASM_OK;
+ return WABT_OK;
}
-WasmResult wasm_generate_names(WasmAllocator* allocator, WasmModule* module) {
+WabtResult wabt_generate_names(WabtAllocator* allocator, WabtModule* module) {
Context ctx;
- WASM_ZERO_MEMORY(ctx);
+ WABT_ZERO_MEMORY(ctx);
ctx.allocator = allocator;
ctx.visitor.user_data = &ctx;
ctx.visitor.begin_block_expr = begin_block_expr;
ctx.visitor.begin_loop_expr = begin_loop_expr;
ctx.visitor.begin_if_expr = begin_if_expr;
ctx.module = module;
- WasmResult result = visit_module(&ctx, module);
- wasm_destroy_string_slice_vector(allocator, &ctx.index_to_name);
+ WabtResult result = visit_module(&ctx, module);
+ wabt_destroy_string_slice_vector(allocator, &ctx.index_to_name);
return result;
}
diff --git a/src/generate-names.h b/src/generate-names.h
index 0cd6d1c1..0d29bfb9 100644
--- a/src/generate-names.h
+++ b/src/generate-names.h
@@ -14,16 +14,16 @@
* limitations under the License.
*/
-#ifndef WASM_GENERATE_NAMES_H_
-#define WASM_GENERATE_NAMES_H_
+#ifndef WABT_GENERATE_NAMES_H_
+#define WABT_GENERATE_NAMES_H_
#include "common.h"
-struct WasmAllocator;
-struct WasmModule;
+struct WabtAllocator;
+struct WabtModule;
-WASM_EXTERN_C_BEGIN
-WasmResult wasm_generate_names(struct WasmAllocator*, struct WasmModule*);
-WASM_EXTERN_C_END
+WABT_EXTERN_C_BEGIN
+WabtResult wabt_generate_names(struct WabtAllocator*, struct WabtModule*);
+WABT_EXTERN_C_END
-#endif /* WASM_GENERATE_NAMES_H_ */
+#endif /* WABT_GENERATE_NAMES_H_ */
diff --git a/src/interpreter.c b/src/interpreter.c
index 7af2f587..d99da283 100644
--- a/src/interpreter.c
+++ b/src/interpreter.c
@@ -26,97 +26,97 @@
#define V(rtype, type1, type2, mem_size, code, NAME, text) [code] = text,
static const char* s_interpreter_opcode_name[] = {
- WASM_FOREACH_OPCODE(V)
- [WASM_OPCODE_ALLOCA] = "alloca",
- [WASM_OPCODE_BR_UNLESS] = "br_unless",
- [WASM_OPCODE_CALL_HOST] = "call_host",
- [WASM_OPCODE_DATA] = "data",
- [WASM_OPCODE_DROP_KEEP] = "drop_keep",
+ WABT_FOREACH_OPCODE(V)
+ [WABT_OPCODE_ALLOCA] = "alloca",
+ [WABT_OPCODE_BR_UNLESS] = "br_unless",
+ [WABT_OPCODE_CALL_HOST] = "call_host",
+ [WABT_OPCODE_DATA] = "data",
+ [WABT_OPCODE_DROP_KEEP] = "drop_keep",
};
#undef V
#define CHECK_RESULT(expr) \
do { \
- if (WASM_FAILED(expr)) \
- return WASM_ERROR; \
+ if (WABT_FAILED(expr)) \
+ return WABT_ERROR; \
} while (0)
-static const char* wasm_get_interpreter_opcode_name(uint8_t opcode) {
- assert(opcode < WASM_ARRAY_SIZE(s_interpreter_opcode_name));
+static const char* wabt_get_interpreter_opcode_name(uint8_t opcode) {
+ assert(opcode < WABT_ARRAY_SIZE(s_interpreter_opcode_name));
return s_interpreter_opcode_name[opcode];
}
-void wasm_init_interpreter_environment(WasmAllocator* allocator,
- WasmInterpreterEnvironment* env) {
- WASM_ZERO_MEMORY(*env);
- wasm_init_output_buffer(allocator, &env->istream, INITIAL_ISTREAM_CAPACITY);
+void wabt_init_interpreter_environment(WabtAllocator* allocator,
+ WabtInterpreterEnvironment* env) {
+ WABT_ZERO_MEMORY(*env);
+ wabt_init_output_buffer(allocator, &env->istream, INITIAL_ISTREAM_CAPACITY);
}
-static void wasm_destroy_interpreter_func_signature(
- WasmAllocator* allocator,
- WasmInterpreterFuncSignature* sig) {
- wasm_destroy_type_vector(allocator, &sig->param_types);
- wasm_destroy_type_vector(allocator, &sig->result_types);
+static void wabt_destroy_interpreter_func_signature(
+ WabtAllocator* allocator,
+ WabtInterpreterFuncSignature* sig) {
+ wabt_destroy_type_vector(allocator, &sig->param_types);
+ wabt_destroy_type_vector(allocator, &sig->result_types);
}
-static void wasm_destroy_interpreter_func(
- WasmAllocator* allocator,
- WasmInterpreterFunc* func) {
+static void wabt_destroy_interpreter_func(
+ WabtAllocator* allocator,
+ WabtInterpreterFunc* func) {
if (!func->is_host)
- wasm_destroy_type_vector(allocator, &func->defined.param_and_local_types);
+ wabt_destroy_type_vector(allocator, &func->defined.param_and_local_types);
}
-static void wasm_destroy_interpreter_memory(WasmAllocator* unused,
- WasmInterpreterMemory* memory) {
+static void wabt_destroy_interpreter_memory(WabtAllocator* unused,
+ WabtInterpreterMemory* memory) {
if (memory->allocator) {
- wasm_free(memory->allocator, memory->data);
+ wabt_free(memory->allocator, memory->data);
} else {
assert(memory->data == NULL);
}
}
-static void wasm_destroy_interpreter_table(WasmAllocator* allocator,
- WasmInterpreterTable* table) {
- wasm_destroy_uint32_array(allocator, &table->func_indexes);
+static void wabt_destroy_interpreter_table(WabtAllocator* allocator,
+ WabtInterpreterTable* table) {
+ wabt_destroy_uint32_array(allocator, &table->func_indexes);
}
-static void wasm_destroy_interpreter_import(WasmAllocator* allocator,
- WasmInterpreterImport* import) {
- wasm_destroy_string_slice(allocator, &import->module_name);
- wasm_destroy_string_slice(allocator, &import->field_name);
+static void wabt_destroy_interpreter_import(WabtAllocator* allocator,
+ WabtInterpreterImport* import) {
+ wabt_destroy_string_slice(allocator, &import->module_name);
+ wabt_destroy_string_slice(allocator, &import->field_name);
}
-static void wasm_destroy_interpreter_module(WasmAllocator* allocator,
- WasmInterpreterModule* module) {
- wasm_destroy_interpreter_export_vector(allocator, &module->exports);
- wasm_destroy_binding_hash(allocator, &module->export_bindings);
- wasm_destroy_string_slice(allocator, &module->name);
+static void wabt_destroy_interpreter_module(WabtAllocator* allocator,
+ WabtInterpreterModule* module) {
+ wabt_destroy_interpreter_export_vector(allocator, &module->exports);
+ wabt_destroy_binding_hash(allocator, &module->export_bindings);
+ wabt_destroy_string_slice(allocator, &module->name);
if (!module->is_host) {
- WASM_DESTROY_ARRAY_AND_ELEMENTS(allocator, module->defined.imports,
+ WABT_DESTROY_ARRAY_AND_ELEMENTS(allocator, module->defined.imports,
interpreter_import);
}
}
-void wasm_destroy_interpreter_environment(WasmAllocator* allocator,
- WasmInterpreterEnvironment* env) {
- WASM_DESTROY_VECTOR_AND_ELEMENTS(allocator, env->modules,
+void wabt_destroy_interpreter_environment(WabtAllocator* allocator,
+ WabtInterpreterEnvironment* env) {
+ WABT_DESTROY_VECTOR_AND_ELEMENTS(allocator, env->modules,
interpreter_module);
- WASM_DESTROY_VECTOR_AND_ELEMENTS(allocator, env->sigs,
+ WABT_DESTROY_VECTOR_AND_ELEMENTS(allocator, env->sigs,
interpreter_func_signature);
- WASM_DESTROY_VECTOR_AND_ELEMENTS(allocator, env->funcs, interpreter_func);
- WASM_DESTROY_VECTOR_AND_ELEMENTS(allocator, env->memories,
+ WABT_DESTROY_VECTOR_AND_ELEMENTS(allocator, env->funcs, interpreter_func);
+ WABT_DESTROY_VECTOR_AND_ELEMENTS(allocator, env->memories,
interpreter_memory);
- WASM_DESTROY_VECTOR_AND_ELEMENTS(allocator, env->tables, interpreter_table);
- wasm_destroy_interpreter_global_vector(allocator, &env->globals);
- wasm_destroy_output_buffer(&env->istream);
- wasm_destroy_binding_hash(allocator, &env->module_bindings);
- wasm_destroy_binding_hash(allocator, &env->registered_module_bindings);
+ WABT_DESTROY_VECTOR_AND_ELEMENTS(allocator, env->tables, interpreter_table);
+ wabt_destroy_interpreter_global_vector(allocator, &env->globals);
+ wabt_destroy_output_buffer(&env->istream);
+ wabt_destroy_binding_hash(allocator, &env->module_bindings);
+ wabt_destroy_binding_hash(allocator, &env->registered_module_bindings);
}
-WasmInterpreterEnvironmentMark wasm_mark_interpreter_environment(
- WasmInterpreterEnvironment* env) {
- WasmInterpreterEnvironmentMark mark;
- WASM_ZERO_MEMORY(mark);
+WabtInterpreterEnvironmentMark wabt_mark_interpreter_environment(
+ WabtInterpreterEnvironment* env) {
+ WabtInterpreterEnvironmentMark mark;
+ WABT_ZERO_MEMORY(mark);
mark.modules_size = env->modules.size;
mark.sigs_size = env->sigs.size;
mark.funcs_size = env->funcs.size;
@@ -127,36 +127,36 @@ WasmInterpreterEnvironmentMark wasm_mark_interpreter_environment(
return mark;
}
-void wasm_reset_interpreter_environment_to_mark(
- WasmAllocator* allocator,
- WasmInterpreterEnvironment* env,
- WasmInterpreterEnvironmentMark mark) {
+void wabt_reset_interpreter_environment_to_mark(
+ WabtAllocator* allocator,
+ WabtInterpreterEnvironment* env,
+ WabtInterpreterEnvironmentMark mark) {
size_t i;
#define DESTROY_PAST_MARK(destroy_name, names) \
do { \
assert(mark.names##_size <= env->names.size); \
for (i = mark.names##_size; i < env->names.size; ++i) \
- wasm_destroy_interpreter_##destroy_name(allocator, &env->names.data[i]); \
+ wabt_destroy_interpreter_##destroy_name(allocator, &env->names.data[i]); \
env->names.size = mark.names##_size; \
} while (0)
/* Destroy entries in the binding hash. */
for (i = mark.modules_size; i < env->modules.size; ++i) {
- const WasmStringSlice* name = &env->modules.data[i].name;
- if (!wasm_string_slice_is_empty(name))
- wasm_remove_binding(allocator, &env->module_bindings, name);
+ const WabtStringSlice* name = &env->modules.data[i].name;
+ if (!wabt_string_slice_is_empty(name))
+ wabt_remove_binding(allocator, &env->module_bindings, name);
}
/* registered_module_bindings maps from an arbitrary name to a module index,
* so we have to iterate through the entire table to find entries to remove.
*/
for (i = 0; i < env->registered_module_bindings.entries.capacity; ++i) {
- WasmBindingHashEntry* entry =
+ WabtBindingHashEntry* entry =
&env->registered_module_bindings.entries.data[i];
- if (!wasm_hash_entry_is_free(entry) &&
+ if (!wabt_hash_entry_is_free(entry) &&
entry->binding.index >= (int)mark.modules_size) {
- wasm_remove_binding(allocator, &env->registered_module_bindings,
+ wabt_remove_binding(allocator, &env->registered_module_bindings,
&entry->binding.name);
}
}
@@ -172,31 +172,31 @@ void wasm_reset_interpreter_environment_to_mark(
#undef DESTROY_PAST_MARK
}
-WasmInterpreterModule* wasm_append_host_module(WasmAllocator* allocator,
- WasmInterpreterEnvironment* env,
- WasmStringSlice name) {
- WasmInterpreterModule* module =
- wasm_append_interpreter_module(allocator, &env->modules);
- module->name = wasm_dup_string_slice(allocator, name);
- module->memory_index = WASM_INVALID_INDEX;
- module->table_index = WASM_INVALID_INDEX;
- module->is_host = WASM_TRUE;
-
- WasmStringSlice dup_name = wasm_dup_string_slice(allocator, name);
- WasmBinding* binding = wasm_insert_binding(
+WabtInterpreterModule* wabt_append_host_module(WabtAllocator* allocator,
+ WabtInterpreterEnvironment* env,
+ WabtStringSlice name) {
+ WabtInterpreterModule* module =
+ wabt_append_interpreter_module(allocator, &env->modules);
+ module->name = wabt_dup_string_slice(allocator, name);
+ module->memory_index = WABT_INVALID_INDEX;
+ module->table_index = WABT_INVALID_INDEX;
+ module->is_host = WABT_TRUE;
+
+ WabtStringSlice dup_name = wabt_dup_string_slice(allocator, name);
+ WabtBinding* binding = wabt_insert_binding(
allocator, &env->registered_module_bindings, &dup_name);
binding->index = env->modules.size - 1;
return module;
}
-void wasm_init_interpreter_thread(WasmAllocator* allocator,
- WasmInterpreterEnvironment* env,
- WasmInterpreterThread* thread,
- WasmInterpreterThreadOptions* options) {
- WASM_ZERO_MEMORY(*thread);
- wasm_new_interpreter_value_array(allocator, &thread->value_stack,
+void wabt_init_interpreter_thread(WabtAllocator* allocator,
+ WabtInterpreterEnvironment* env,
+ WabtInterpreterThread* thread,
+ WabtInterpreterThreadOptions* options) {
+ WABT_ZERO_MEMORY(*thread);
+ wabt_new_interpreter_value_array(allocator, &thread->value_stack,
options->value_stack_size);
- wasm_new_uint32_array(allocator, &thread->call_stack,
+ wabt_new_uint32_array(allocator, &thread->call_stack,
options->call_stack_size);
thread->allocator = allocator;
thread->env = env;
@@ -207,30 +207,30 @@ void wasm_init_interpreter_thread(WasmAllocator* allocator,
thread->pc = options->pc;
}
-WasmInterpreterResult wasm_push_thread_value(WasmInterpreterThread* thread,
- WasmInterpreterValue value) {
+WabtInterpreterResult wabt_push_thread_value(WabtInterpreterThread* thread,
+ WabtInterpreterValue value) {
if (thread->value_stack_top >= thread->value_stack_end)
- return WASM_INTERPRETER_TRAP_VALUE_STACK_EXHAUSTED;
+ return WABT_INTERPRETER_TRAP_VALUE_STACK_EXHAUSTED;
*thread->value_stack_top++ = value;
- return WASM_INTERPRETER_OK;
+ return WABT_INTERPRETER_OK;
}
-WasmInterpreterExport* wasm_get_interpreter_export_by_name(
- WasmInterpreterModule* module,
- const WasmStringSlice* name) {
+WabtInterpreterExport* wabt_get_interpreter_export_by_name(
+ WabtInterpreterModule* module,
+ const WabtStringSlice* name) {
int field_index =
- wasm_find_binding_index_by_name(&module->export_bindings, name);
+ wabt_find_binding_index_by_name(&module->export_bindings, name);
if (field_index < 0)
return NULL;
assert((size_t)field_index < module->exports.size);
return &module->exports.data[field_index];
}
-void wasm_destroy_interpreter_thread(WasmAllocator* allocator,
- WasmInterpreterThread* thread) {
- wasm_destroy_interpreter_value_array(allocator, &thread->value_stack);
- wasm_destroy_uint32_array(allocator, &thread->call_stack);
- wasm_destroy_interpreter_typed_value_vector(allocator, &thread->host_args);
+void wabt_destroy_interpreter_thread(WabtAllocator* allocator,
+ WabtInterpreterThread* thread) {
+ wabt_destroy_interpreter_value_array(allocator, &thread->value_stack);
+ wabt_destroy_uint32_array(allocator, &thread->call_stack);
+ wabt_destroy_interpreter_typed_value_vector(allocator, &thread->host_args);
}
/* 3 32222222 222...00
@@ -269,31 +269,31 @@ void wasm_destroy_interpreter_thread(WasmAllocator* allocator,
#define F32_SIG_MASK 0x7fffff
#define F32_SIGN_MASK 0x80000000U
-WASM_INLINE WasmBool is_nan_f32(uint32_t f32_bits) {
+WABT_INLINE WabtBool wabt_is_nan_f32(uint32_t f32_bits) {
return (f32_bits > F32_INF && f32_bits < F32_NEG_ZERO) ||
(f32_bits > F32_NEG_INF);
}
-static WASM_INLINE WasmBool is_zero_f32(uint32_t f32_bits) {
+static WABT_INLINE WabtBool is_zero_f32(uint32_t f32_bits) {
return f32_bits == 0 || f32_bits == F32_NEG_ZERO;
}
-static WASM_INLINE WasmBool is_in_range_i32_trunc_s_f32(uint32_t f32_bits) {
+static WABT_INLINE WabtBool is_in_range_i32_trunc_s_f32(uint32_t f32_bits) {
return (f32_bits < 0x4f000000U) ||
(f32_bits >= F32_NEG_ZERO && f32_bits <= 0xcf000000U);
}
-static WASM_INLINE WasmBool is_in_range_i64_trunc_s_f32(uint32_t f32_bits) {
+static WABT_INLINE WabtBool is_in_range_i64_trunc_s_f32(uint32_t f32_bits) {
return (f32_bits < 0x5f000000U) ||
(f32_bits >= F32_NEG_ZERO && f32_bits <= 0xdf000000U);
}
-static WASM_INLINE WasmBool is_in_range_i32_trunc_u_f32(uint32_t f32_bits) {
+static WABT_INLINE WabtBool is_in_range_i32_trunc_u_f32(uint32_t f32_bits) {
return (f32_bits < 0x4f800000U) ||
(f32_bits >= F32_NEG_ZERO && f32_bits < F32_NEG_ONE);
}
-static WASM_INLINE WasmBool is_in_range_i64_trunc_u_f32(uint32_t f32_bits) {
+static WABT_INLINE WabtBool is_in_range_i64_trunc_u_f32(uint32_t f32_bits) {
return (f32_bits < 0x5f800000U) ||
(f32_bits >= F32_NEG_ZERO && f32_bits < F32_NEG_ONE);
}
@@ -334,36 +334,36 @@ static WASM_INLINE WasmBool is_in_range_i64_trunc_u_f32(uint32_t f32_bits) {
#define F64_SIG_MASK 0xfffffffffffffULL
#define F64_SIGN_MASK 0x8000000000000000ULL
-WASM_INLINE WasmBool is_nan_f64(uint64_t f64_bits) {
+WABT_INLINE WabtBool wabt_is_nan_f64(uint64_t f64_bits) {
return (f64_bits > F64_INF && f64_bits < F64_NEG_ZERO) ||
(f64_bits > F64_NEG_INF);
}
-static WASM_INLINE WasmBool is_zero_f64(uint64_t f64_bits) {
+static WABT_INLINE WabtBool is_zero_f64(uint64_t f64_bits) {
return f64_bits == 0 || f64_bits == F64_NEG_ZERO;
}
-static WASM_INLINE WasmBool is_in_range_i32_trunc_s_f64(uint64_t f64_bits) {
+static WABT_INLINE WabtBool is_in_range_i32_trunc_s_f64(uint64_t f64_bits) {
return (f64_bits <= 0x41dfffffffc00000ULL) ||
(f64_bits >= F64_NEG_ZERO && f64_bits <= 0xc1e0000000000000ULL);
}
-static WASM_INLINE WasmBool is_in_range_i32_trunc_u_f64(uint64_t f64_bits) {
+static WABT_INLINE WabtBool is_in_range_i32_trunc_u_f64(uint64_t f64_bits) {
return (f64_bits <= 0x41efffffffe00000ULL) ||
(f64_bits >= F64_NEG_ZERO && f64_bits < F64_NEG_ONE);
}
-static WASM_INLINE WasmBool is_in_range_i64_trunc_s_f64(uint64_t f64_bits) {
+static WABT_INLINE WabtBool is_in_range_i64_trunc_s_f64(uint64_t f64_bits) {
return (f64_bits < 0x43e0000000000000ULL) ||
(f64_bits >= F64_NEG_ZERO && f64_bits <= 0xc3e0000000000000ULL);
}
-static WASM_INLINE WasmBool is_in_range_i64_trunc_u_f64(uint64_t f64_bits) {
+static WABT_INLINE WabtBool is_in_range_i64_trunc_u_f64(uint64_t f64_bits) {
return (f64_bits < 0x43f0000000000000ULL) ||
(f64_bits >= F64_NEG_ZERO && f64_bits < F64_NEG_ONE);
}
-static WASM_INLINE WasmBool is_in_range_f64_demote_f32(uint64_t f64_bits) {
+static WABT_INLINE WabtBool is_in_range_f64_demote_f32(uint64_t f64_bits) {
return (f64_bits <= 0x47efffffe0000000ULL) ||
(f64_bits >= F64_NEG_ZERO && f64_bits <= 0xc7efffffe0000000ULL);
}
@@ -372,23 +372,23 @@ static WASM_INLINE WasmBool is_in_range_f64_demote_f32(uint64_t f64_bits) {
* should be rounded to F32_MAX and not set to infinity. Unfortunately, UBSAN
* complains that the value is not representable as a float, so we'll special
* case them. */
-static WASM_INLINE WasmBool
+static WABT_INLINE WabtBool
is_in_range_f64_demote_f32_round_to_f32_max(uint64_t f64_bits) {
return f64_bits > 0x47efffffe0000000ULL && f64_bits < 0x47effffff0000000ULL;
}
-static WASM_INLINE WasmBool
+static WABT_INLINE WabtBool
is_in_range_f64_demote_f32_round_to_neg_f32_max(uint64_t f64_bits) {
return f64_bits > 0xc7efffffe0000000ULL && f64_bits < 0xc7effffff0000000ULL;
}
-#define IS_NAN_F32 is_nan_f32
-#define IS_NAN_F64 is_nan_f64
+#define IS_NAN_F32 wabt_is_nan_f32
+#define IS_NAN_F64 wabt_is_nan_f64
#define IS_ZERO_F32 is_zero_f32
#define IS_ZERO_F64 is_zero_f64
#define DEFINE_BITCAST(name, src, dst) \
- static WASM_INLINE dst name(src x) { \
+ static WABT_INLINE dst name(src x) { \
dst result; \
memcpy(&result, &x, sizeof(dst)); \
return result; \
@@ -462,12 +462,12 @@ DEFINE_BITCAST(bitcast_u64_to_f64, uint64_t, double)
#define TYPE_FIELD_NAME_F32 f32_bits
#define TYPE_FIELD_NAME_F64 f64_bits
-#define TRAP(type) return WASM_INTERPRETER_TRAP_##type
+#define TRAP(type) return WABT_INTERPRETER_TRAP_##type
#define TRAP_UNLESS(cond, type) TRAP_IF(!(cond), type)
#define TRAP_IF(cond, type) \
do { \
- if (WASM_UNLIKELY(cond)) \
- return WASM_INTERPRETER_TRAP_##type; \
+ if (WABT_UNLIKELY(cond)) \
+ return WABT_INTERPRETER_TRAP_##type; \
} while (0)
#define CHECK_STACK() \
@@ -475,7 +475,7 @@ DEFINE_BITCAST(bitcast_u64_to_f64, uint64_t, double)
VALUE_STACK_EXHAUSTED)
#define PUSH_NEG_1_AND_BREAK_IF(cond) \
- if (WASM_UNLIKELY(cond)) { \
+ if (WABT_UNLIKELY(cond)) { \
PUSH_I32(-1); \
break; \
}
@@ -527,7 +527,7 @@ DEFINE_BITCAST(bitcast_u64_to_f64, uint64_t, double)
#define GET_MEMORY(var) \
uint32_t memory_index = read_u32(&pc); \
assert(memory_index < env->memories.size); \
- WasmInterpreterMemory* var = &env->memories.data[memory_index]
+ WabtInterpreterMemory* var = &env->memories.data[memory_index]
#define LOAD(type, mem_type) \
do { \
@@ -588,7 +588,7 @@ DEFINE_BITCAST(bitcast_u64_to_f64, uint64_t, double)
VALUE_TYPE_##type rhs = POP_##type(); \
VALUE_TYPE_##type lhs = POP_##type(); \
uint32_t amount = rhs & SHIFT_MASK_##type; \
- if (WASM_LIKELY(amount != 0)) { \
+ if (WABT_LIKELY(amount != 0)) { \
PUSH_##type( \
(lhs ROT_##dir##_0_SHIFT_OP amount) | \
(lhs ROT_##dir##_1_SHIFT_OP((SHIFT_MASK_##type + 1) - amount))); \
@@ -626,7 +626,7 @@ DEFINE_BITCAST(bitcast_u64_to_f64, uint64_t, double)
VALUE_TYPE_##type rhs = POP_##type(); \
VALUE_TYPE_##type lhs = POP_##type(); \
TRAP_IF(rhs == 0, INTEGER_DIVIDE_BY_ZERO); \
- if (WASM_UNLIKELY(lhs == VALUE_TYPE_SIGNED_MAX_##type && \
+ if (WABT_UNLIKELY(lhs == VALUE_TYPE_SIGNED_MAX_##type && \
rhs == VALUE_TYPE_UNSIGNED_MAX_##type)) { \
PUSH_##type(0); \
} else { \
@@ -653,7 +653,7 @@ DEFINE_BITCAST(bitcast_u64_to_f64, uint64_t, double)
do { \
VALUE_TYPE_##type rhs = POP_##type(); \
VALUE_TYPE_##type lhs = POP_##type(); \
- if (WASM_UNLIKELY(IS_ZERO_##type(rhs))) { \
+ if (WABT_UNLIKELY(IS_ZERO_##type(rhs))) { \
if (IS_NAN_##type(lhs)) { \
PUSH_##type(lhs | type##_QUIET_NAN); \
} else if (IS_ZERO_##type(lhs)) { \
@@ -684,9 +684,9 @@ DEFINE_BITCAST(bitcast_u64_to_f64, uint64_t, double)
VALUE_TYPE_##type rhs = POP_##type(); \
VALUE_TYPE_##type lhs = POP_##type(); \
VALUE_TYPE_##type result; \
- if (WASM_UNLIKELY(IS_NAN_##type(lhs))) { \
+ if (WABT_UNLIKELY(IS_NAN_##type(lhs))) { \
result = lhs | type##_QUIET_NAN_BIT; \
- } else if (WASM_UNLIKELY(IS_NAN_##type(rhs))) { \
+ } else if (WABT_UNLIKELY(IS_NAN_##type(rhs))) { \
result = rhs | type##_QUIET_NAN_BIT; \
} else if ((lhs ^ rhs) & type##_SIGN_MASK) { \
/* min(-0.0, 0.0) => -0.0; since we know the sign bits are different, we \
@@ -702,80 +702,80 @@ DEFINE_BITCAST(bitcast_u64_to_f64, uint64_t, double)
PUSH_##type(result); \
} while (0)
-static WASM_INLINE uint32_t read_u32_at(const uint8_t* pc) {
+static WABT_INLINE uint32_t read_u32_at(const uint8_t* pc) {
uint32_t result;
memcpy(&result, pc, sizeof(uint32_t));
return result;
}
-static WASM_INLINE uint32_t read_u32(const uint8_t** pc) {
+static WABT_INLINE uint32_t read_u32(const uint8_t** pc) {
uint32_t result = read_u32_at(*pc);
*pc += sizeof(uint32_t);
return result;
}
-static WASM_INLINE uint64_t read_u64_at(const uint8_t* pc) {
+static WABT_INLINE uint64_t read_u64_at(const uint8_t* pc) {
uint64_t result;
memcpy(&result, pc, sizeof(uint64_t));
return result;
}
-static WASM_INLINE uint64_t read_u64(const uint8_t** pc) {
+static WABT_INLINE uint64_t read_u64(const uint8_t** pc) {
uint64_t result = read_u64_at(*pc);
*pc += sizeof(uint64_t);
return result;
}
-static WASM_INLINE void read_table_entry_at(const uint8_t* pc,
+static WABT_INLINE void read_table_entry_at(const uint8_t* pc,
uint32_t* out_offset,
uint32_t* out_drop,
uint8_t* out_keep) {
- *out_offset = read_u32_at(pc + WASM_TABLE_ENTRY_OFFSET_OFFSET);
- *out_drop = read_u32_at(pc + WASM_TABLE_ENTRY_DROP_OFFSET);
- *out_keep = *(pc + WASM_TABLE_ENTRY_KEEP_OFFSET);
+ *out_offset = read_u32_at(pc + WABT_TABLE_ENTRY_OFFSET_OFFSET);
+ *out_drop = read_u32_at(pc + WABT_TABLE_ENTRY_DROP_OFFSET);
+ *out_keep = *(pc + WABT_TABLE_ENTRY_KEEP_OFFSET);
}
-WasmBool wasm_func_signatures_are_equal(WasmInterpreterEnvironment* env,
+WabtBool wabt_func_signatures_are_equal(WabtInterpreterEnvironment* env,
uint32_t sig_index_0,
uint32_t sig_index_1) {
if (sig_index_0 == sig_index_1)
- return WASM_TRUE;
- WasmInterpreterFuncSignature* sig_0 = &env->sigs.data[sig_index_0];
- WasmInterpreterFuncSignature* sig_1 = &env->sigs.data[sig_index_1];
- return wasm_type_vectors_are_equal(&sig_0->param_types,
+ return WABT_TRUE;
+ WabtInterpreterFuncSignature* sig_0 = &env->sigs.data[sig_index_0];
+ WabtInterpreterFuncSignature* sig_1 = &env->sigs.data[sig_index_1];
+ return wabt_type_vectors_are_equal(&sig_0->param_types,
&sig_1->param_types) &&
- wasm_type_vectors_are_equal(&sig_0->result_types,
+ wabt_type_vectors_are_equal(&sig_0->result_types,
&sig_1->result_types);
}
-WasmInterpreterResult wasm_call_host(WasmInterpreterThread* thread,
- WasmInterpreterFunc* func) {
+WabtInterpreterResult wabt_call_host(WabtInterpreterThread* thread,
+ WabtInterpreterFunc* func) {
assert(func->is_host);
assert(func->sig_index < thread->env->sigs.size);
- WasmInterpreterFuncSignature* sig = &thread->env->sigs.data[func->sig_index];
+ WabtInterpreterFuncSignature* sig = &thread->env->sigs.data[func->sig_index];
uint32_t num_args = sig->param_types.size;
if (thread->host_args.size < num_args) {
- wasm_resize_interpreter_typed_value_vector(thread->allocator,
+ wabt_resize_interpreter_typed_value_vector(thread->allocator,
&thread->host_args, num_args);
}
uint32_t i;
for (i = num_args; i > 0; --i) {
- WasmInterpreterValue value = POP();
- WasmInterpreterTypedValue* arg = &thread->host_args.data[i - 1];
+ WabtInterpreterValue value = POP();
+ WabtInterpreterTypedValue* arg = &thread->host_args.data[i - 1];
arg->type = sig->param_types.data[i - 1];
arg->value = value;
}
uint32_t num_results = sig->result_types.size;
- WasmInterpreterTypedValue* call_result_values =
- alloca(sizeof(WasmInterpreterTypedValue) * num_results);
+ WabtInterpreterTypedValue* call_result_values =
+ alloca(sizeof(WabtInterpreterTypedValue) * num_results);
- WasmResult call_result = func->host.callback(
+ WabtResult call_result = func->host.callback(
func, sig, num_args, thread->host_args.data, num_results,
call_result_values, func->host.user_data);
- TRAP_IF(call_result != WASM_OK, HOST_TRAPPED);
+ TRAP_IF(call_result != WABT_OK, HOST_TRAPPED);
for (i = 0; i < num_results; ++i) {
TRAP_IF(call_result_values[i].type != sig->result_types.data[i],
@@ -783,16 +783,16 @@ WasmInterpreterResult wasm_call_host(WasmInterpreterThread* thread,
PUSH(call_result_values[i].value);
}
- return WASM_INTERPRETER_OK;
+ return WABT_INTERPRETER_OK;
}
-WasmInterpreterResult wasm_run_interpreter(WasmInterpreterThread* thread,
+WabtInterpreterResult wabt_run_interpreter(WabtInterpreterThread* thread,
uint32_t num_instructions,
uint32_t* call_stack_return_top) {
- WasmInterpreterResult result = WASM_INTERPRETER_OK;
+ WabtInterpreterResult result = WABT_INTERPRETER_OK;
assert(call_stack_return_top < thread->call_stack_end);
- WasmInterpreterEnvironment* env = thread->env;
+ WabtInterpreterEnvironment* env = thread->env;
const uint8_t* istream = env->istream.start;
const uint8_t* pc = &istream[thread->pc];
@@ -800,31 +800,31 @@ WasmInterpreterResult wasm_run_interpreter(WasmInterpreterThread* thread,
for (i = 0; i < num_instructions; ++i) {
uint8_t opcode = *pc++;
switch (opcode) {
- case WASM_OPCODE_SELECT: {
+ case WABT_OPCODE_SELECT: {
VALUE_TYPE_I32 cond = POP_I32();
- WasmInterpreterValue false_ = POP();
- WasmInterpreterValue true_ = POP();
+ WabtInterpreterValue false_ = POP();
+ WabtInterpreterValue true_ = POP();
PUSH(cond ? true_ : false_);
break;
}
- case WASM_OPCODE_BR:
+ case WABT_OPCODE_BR:
GOTO(read_u32(&pc));
break;
- case WASM_OPCODE_BR_IF: {
+ case WABT_OPCODE_BR_IF: {
uint32_t new_pc = read_u32(&pc);
if (POP_I32())
GOTO(new_pc);
break;
}
- case WASM_OPCODE_BR_TABLE: {
+ case WABT_OPCODE_BR_TABLE: {
uint32_t num_targets = read_u32(&pc);
uint32_t table_offset = read_u32(&pc);
VALUE_TYPE_I32 key = POP_I32();
uint32_t key_offset =
- (key >= num_targets ? num_targets : key) * WASM_TABLE_ENTRY_SIZE;
+ (key >= num_targets ? num_targets : key) * WABT_TABLE_ENTRY_SIZE;
const uint8_t* entry = istream + table_offset + key_offset;
uint32_t new_pc;
uint32_t drop_count;
@@ -835,87 +835,87 @@ WasmInterpreterResult wasm_run_interpreter(WasmInterpreterThread* thread,
break;
}
- case WASM_OPCODE_RETURN:
+ case WABT_OPCODE_RETURN:
if (thread->call_stack_top == call_stack_return_top) {
- result = WASM_INTERPRETER_RETURNED;
+ result = WABT_INTERPRETER_RETURNED;
goto exit_loop;
}
GOTO(POP_CALL());
break;
- case WASM_OPCODE_UNREACHABLE:
+ case WABT_OPCODE_UNREACHABLE:
TRAP(UNREACHABLE);
break;
- case WASM_OPCODE_I32_CONST:
+ case WABT_OPCODE_I32_CONST:
PUSH_I32(read_u32(&pc));
break;
- case WASM_OPCODE_I64_CONST:
+ case WABT_OPCODE_I64_CONST:
PUSH_I64(read_u64(&pc));
break;
- case WASM_OPCODE_F32_CONST:
+ case WABT_OPCODE_F32_CONST:
PUSH_F32(read_u32(&pc));
break;
- case WASM_OPCODE_F64_CONST:
+ case WABT_OPCODE_F64_CONST:
PUSH_F64(read_u64(&pc));
break;
- case WASM_OPCODE_GET_GLOBAL: {
+ case WABT_OPCODE_GET_GLOBAL: {
uint32_t index = read_u32(&pc);
assert(index < env->globals.size);
PUSH(env->globals.data[index].typed_value.value);
break;
}
- case WASM_OPCODE_SET_GLOBAL: {
+ case WABT_OPCODE_SET_GLOBAL: {
uint32_t index = read_u32(&pc);
assert(index < env->globals.size);
env->globals.data[index].typed_value.value = POP();
break;
}
- case WASM_OPCODE_GET_LOCAL: {
- WasmInterpreterValue value = PICK(read_u32(&pc));
+ case WABT_OPCODE_GET_LOCAL: {
+ WabtInterpreterValue value = PICK(read_u32(&pc));
PUSH(value);
break;
}
- case WASM_OPCODE_SET_LOCAL: {
- WasmInterpreterValue value = POP();
+ case WABT_OPCODE_SET_LOCAL: {
+ WabtInterpreterValue value = POP();
PICK(read_u32(&pc)) = value;
break;
}
- case WASM_OPCODE_TEE_LOCAL:
+ case WABT_OPCODE_TEE_LOCAL:
PICK(read_u32(&pc)) = TOP();
break;
- case WASM_OPCODE_CALL: {
+ case WABT_OPCODE_CALL: {
uint32_t offset = read_u32(&pc);
PUSH_CALL();
GOTO(offset);
break;
}
- case WASM_OPCODE_CALL_INDIRECT: {
+ case WABT_OPCODE_CALL_INDIRECT: {
uint32_t table_index = read_u32(&pc);
assert(table_index < env->tables.size);
- WasmInterpreterTable* table = &env->tables.data[table_index];
+ WabtInterpreterTable* table = &env->tables.data[table_index];
uint32_t sig_index = read_u32(&pc);
assert(sig_index < env->sigs.size);
VALUE_TYPE_I32 entry_index = POP_I32();
TRAP_IF(entry_index >= table->func_indexes.size, UNDEFINED_TABLE_INDEX);
uint32_t func_index = table->func_indexes.data[entry_index];
- TRAP_IF(func_index == WASM_INVALID_INDEX, UNINITIALIZED_TABLE_ELEMENT);
- WasmInterpreterFunc* func = &env->funcs.data[func_index];
+ TRAP_IF(func_index == WABT_INVALID_INDEX, UNINITIALIZED_TABLE_ELEMENT);
+ WabtInterpreterFunc* func = &env->funcs.data[func_index];
TRAP_UNLESS(
- wasm_func_signatures_are_equal(env, func->sig_index, sig_index),
+ wabt_func_signatures_are_equal(env, func->sig_index, sig_index),
INDIRECT_CALL_SIGNATURE_MISMATCH);
if (func->is_host) {
- wasm_call_host(thread, func);
+ wabt_call_host(thread, func);
} else {
PUSH_CALL();
GOTO(func->defined.offset);
@@ -923,113 +923,113 @@ WasmInterpreterResult wasm_run_interpreter(WasmInterpreterThread* thread,
break;
}
- case WASM_OPCODE_CALL_HOST: {
+ case WABT_OPCODE_CALL_HOST: {
uint32_t func_index = read_u32(&pc);
assert(func_index < env->funcs.size);
- WasmInterpreterFunc* func = &env->funcs.data[func_index];
- wasm_call_host(thread, func);
+ WabtInterpreterFunc* func = &env->funcs.data[func_index];
+ wabt_call_host(thread, func);
break;
}
- case WASM_OPCODE_I32_LOAD8_S:
+ case WABT_OPCODE_I32_LOAD8_S:
LOAD(I32, I8);
break;
- case WASM_OPCODE_I32_LOAD8_U:
+ case WABT_OPCODE_I32_LOAD8_U:
LOAD(I32, U8);
break;
- case WASM_OPCODE_I32_LOAD16_S:
+ case WABT_OPCODE_I32_LOAD16_S:
LOAD(I32, I16);
break;
- case WASM_OPCODE_I32_LOAD16_U:
+ case WABT_OPCODE_I32_LOAD16_U:
LOAD(I32, U16);
break;
- case WASM_OPCODE_I64_LOAD8_S:
+ case WABT_OPCODE_I64_LOAD8_S:
LOAD(I64, I8);
break;
- case WASM_OPCODE_I64_LOAD8_U:
+ case WABT_OPCODE_I64_LOAD8_U:
LOAD(I64, U8);
break;
- case WASM_OPCODE_I64_LOAD16_S:
+ case WABT_OPCODE_I64_LOAD16_S:
LOAD(I64, I16);
break;
- case WASM_OPCODE_I64_LOAD16_U:
+ case WABT_OPCODE_I64_LOAD16_U:
LOAD(I64, U16);
break;
- case WASM_OPCODE_I64_LOAD32_S:
+ case WABT_OPCODE_I64_LOAD32_S:
LOAD(I64, I32);
break;
- case WASM_OPCODE_I64_LOAD32_U:
+ case WABT_OPCODE_I64_LOAD32_U:
LOAD(I64, U32);
break;
- case WASM_OPCODE_I32_LOAD:
+ case WABT_OPCODE_I32_LOAD:
LOAD(I32, U32);
break;
- case WASM_OPCODE_I64_LOAD:
+ case WABT_OPCODE_I64_LOAD:
LOAD(I64, U64);
break;
- case WASM_OPCODE_F32_LOAD:
+ case WABT_OPCODE_F32_LOAD:
LOAD(F32, F32);
break;
- case WASM_OPCODE_F64_LOAD:
+ case WABT_OPCODE_F64_LOAD:
LOAD(F64, F64);
break;
- case WASM_OPCODE_I32_STORE8:
+ case WABT_OPCODE_I32_STORE8:
STORE(I32, U8);
break;
- case WASM_OPCODE_I32_STORE16:
+ case WABT_OPCODE_I32_STORE16:
STORE(I32, U16);
break;
- case WASM_OPCODE_I64_STORE8:
+ case WABT_OPCODE_I64_STORE8:
STORE(I64, U8);
break;
- case WASM_OPCODE_I64_STORE16:
+ case WABT_OPCODE_I64_STORE16:
STORE(I64, U16);
break;
- case WASM_OPCODE_I64_STORE32:
+ case WABT_OPCODE_I64_STORE32:
STORE(I64, U32);
break;
- case WASM_OPCODE_I32_STORE:
+ case WABT_OPCODE_I32_STORE:
STORE(I32, U32);
break;
- case WASM_OPCODE_I64_STORE:
+ case WABT_OPCODE_I64_STORE:
STORE(I64, U64);
break;
- case WASM_OPCODE_F32_STORE:
+ case WABT_OPCODE_F32_STORE:
STORE(F32, F32);
break;
- case WASM_OPCODE_F64_STORE:
+ case WABT_OPCODE_F64_STORE:
STORE(F64, F64);
break;
- case WASM_OPCODE_CURRENT_MEMORY: {
+ case WABT_OPCODE_CURRENT_MEMORY: {
GET_MEMORY(memory);
PUSH_I32(memory->page_limits.initial);
break;
}
- case WASM_OPCODE_GROW_MEMORY: {
+ case WABT_OPCODE_GROW_MEMORY: {
GET_MEMORY(memory);
uint32_t old_page_size = memory->page_limits.initial;
uint32_t old_byte_size = memory->byte_size;
@@ -1037,14 +1037,14 @@ WasmInterpreterResult wasm_run_interpreter(WasmInterpreterThread* thread,
uint32_t new_page_size = old_page_size + grow_pages;
uint32_t max_page_size = memory->page_limits.has_max
? memory->page_limits.max
- : WASM_MAX_PAGES;
+ : WABT_MAX_PAGES;
PUSH_NEG_1_AND_BREAK_IF(new_page_size > max_page_size);
- PUSH_NEG_1_AND_BREAK_IF((uint64_t)new_page_size * WASM_PAGE_SIZE >
+ PUSH_NEG_1_AND_BREAK_IF((uint64_t)new_page_size * WABT_PAGE_SIZE >
UINT32_MAX);
- uint32_t new_byte_size = new_page_size * WASM_PAGE_SIZE;
- WasmAllocator* allocator = memory->allocator;
- void* new_data = wasm_realloc(allocator, memory->data, new_byte_size,
- WASM_DEFAULT_ALIGN);
+ uint32_t new_byte_size = new_page_size * WABT_PAGE_SIZE;
+ WabtAllocator* allocator = memory->allocator;
+ void* new_data = wabt_realloc(allocator, memory->data, new_byte_size,
+ WABT_DEFAULT_ALIGN);
PUSH_NEG_1_AND_BREAK_IF(new_data == NULL);
memset((void*)((intptr_t)new_data + old_byte_size), 0,
new_byte_size - old_byte_size);
@@ -1055,507 +1055,507 @@ WasmInterpreterResult wasm_run_interpreter(WasmInterpreterThread* thread,
break;
}
- case WASM_OPCODE_I32_ADD:
+ case WABT_OPCODE_I32_ADD:
BINOP(I32, I32, +);
break;
- case WASM_OPCODE_I32_SUB:
+ case WABT_OPCODE_I32_SUB:
BINOP(I32, I32, -);
break;
- case WASM_OPCODE_I32_MUL:
+ case WABT_OPCODE_I32_MUL:
BINOP(I32, I32, *);
break;
- case WASM_OPCODE_I32_DIV_S:
+ case WABT_OPCODE_I32_DIV_S:
BINOP_DIV_S(I32);
break;
- case WASM_OPCODE_I32_DIV_U:
+ case WABT_OPCODE_I32_DIV_U:
BINOP_DIV_REM_U(I32, / );
break;
- case WASM_OPCODE_I32_REM_S:
+ case WABT_OPCODE_I32_REM_S:
BINOP_REM_S(I32);
break;
- case WASM_OPCODE_I32_REM_U:
+ case WABT_OPCODE_I32_REM_U:
BINOP_DIV_REM_U(I32, % );
break;
- case WASM_OPCODE_I32_AND:
+ case WABT_OPCODE_I32_AND:
BINOP(I32, I32, &);
break;
- case WASM_OPCODE_I32_OR:
+ case WABT_OPCODE_I32_OR:
BINOP(I32, I32, | );
break;
- case WASM_OPCODE_I32_XOR:
+ case WABT_OPCODE_I32_XOR:
BINOP(I32, I32, ^);
break;
- case WASM_OPCODE_I32_SHL:
+ case WABT_OPCODE_I32_SHL:
BINOP_SHIFT(I32, <<, UNSIGNED);
break;
- case WASM_OPCODE_I32_SHR_U:
+ case WABT_OPCODE_I32_SHR_U:
BINOP_SHIFT(I32, >>, UNSIGNED);
break;
- case WASM_OPCODE_I32_SHR_S:
+ case WABT_OPCODE_I32_SHR_S:
BINOP_SHIFT(I32, >>, SIGNED);
break;
- case WASM_OPCODE_I32_EQ:
+ case WABT_OPCODE_I32_EQ:
BINOP(I32, I32, == );
break;
- case WASM_OPCODE_I32_NE:
+ case WABT_OPCODE_I32_NE:
BINOP(I32, I32, != );
break;
- case WASM_OPCODE_I32_LT_S:
+ case WABT_OPCODE_I32_LT_S:
BINOP_SIGNED(I32, I32, < );
break;
- case WASM_OPCODE_I32_LE_S:
+ case WABT_OPCODE_I32_LE_S:
BINOP_SIGNED(I32, I32, <= );
break;
- case WASM_OPCODE_I32_LT_U:
+ case WABT_OPCODE_I32_LT_U:
BINOP(I32, I32, < );
break;
- case WASM_OPCODE_I32_LE_U:
+ case WABT_OPCODE_I32_LE_U:
BINOP(I32, I32, <= );
break;
- case WASM_OPCODE_I32_GT_S:
+ case WABT_OPCODE_I32_GT_S:
BINOP_SIGNED(I32, I32, > );
break;
- case WASM_OPCODE_I32_GE_S:
+ case WABT_OPCODE_I32_GE_S:
BINOP_SIGNED(I32, I32, >= );
break;
- case WASM_OPCODE_I32_GT_U:
+ case WABT_OPCODE_I32_GT_U:
BINOP(I32, I32, > );
break;
- case WASM_OPCODE_I32_GE_U:
+ case WABT_OPCODE_I32_GE_U:
BINOP(I32, I32, >= );
break;
- case WASM_OPCODE_I32_CLZ: {
+ case WABT_OPCODE_I32_CLZ: {
VALUE_TYPE_I32 value = POP_I32();
- PUSH_I32(value != 0 ? wasm_clz_u32(value) : 32);
+ PUSH_I32(value != 0 ? wabt_clz_u32(value) : 32);
break;
}
- case WASM_OPCODE_I32_CTZ: {
+ case WABT_OPCODE_I32_CTZ: {
VALUE_TYPE_I32 value = POP_I32();
- PUSH_I32(value != 0 ? wasm_ctz_u32(value) : 32);
+ PUSH_I32(value != 0 ? wabt_ctz_u32(value) : 32);
break;
}
- case WASM_OPCODE_I32_POPCNT: {
+ case WABT_OPCODE_I32_POPCNT: {
VALUE_TYPE_I32 value = POP_I32();
- PUSH_I32(wasm_popcount_u32(value));
+ PUSH_I32(wabt_popcount_u32(value));
break;
}
- case WASM_OPCODE_I32_EQZ: {
+ case WABT_OPCODE_I32_EQZ: {
VALUE_TYPE_I32 value = POP_I32();
PUSH_I32(value == 0);
break;
}
- case WASM_OPCODE_I64_ADD:
+ case WABT_OPCODE_I64_ADD:
BINOP(I64, I64, +);
break;
- case WASM_OPCODE_I64_SUB:
+ case WABT_OPCODE_I64_SUB:
BINOP(I64, I64, -);
break;
- case WASM_OPCODE_I64_MUL:
+ case WABT_OPCODE_I64_MUL:
BINOP(I64, I64, *);
break;
- case WASM_OPCODE_I64_DIV_S:
+ case WABT_OPCODE_I64_DIV_S:
BINOP_DIV_S(I64);
break;
- case WASM_OPCODE_I64_DIV_U:
+ case WABT_OPCODE_I64_DIV_U:
BINOP_DIV_REM_U(I64, / );
break;
- case WASM_OPCODE_I64_REM_S:
+ case WABT_OPCODE_I64_REM_S:
BINOP_REM_S(I64);
break;
- case WASM_OPCODE_I64_REM_U:
+ case WABT_OPCODE_I64_REM_U:
BINOP_DIV_REM_U(I64, % );
break;
- case WASM_OPCODE_I64_AND:
+ case WABT_OPCODE_I64_AND:
BINOP(I64, I64, &);
break;
- case WASM_OPCODE_I64_OR:
+ case WABT_OPCODE_I64_OR:
BINOP(I64, I64, | );
break;
- case WASM_OPCODE_I64_XOR:
+ case WABT_OPCODE_I64_XOR:
BINOP(I64, I64, ^);
break;
- case WASM_OPCODE_I64_SHL:
+ case WABT_OPCODE_I64_SHL:
BINOP_SHIFT(I64, <<, UNSIGNED);
break;
- case WASM_OPCODE_I64_SHR_U:
+ case WABT_OPCODE_I64_SHR_U:
BINOP_SHIFT(I64, >>, UNSIGNED);
break;
- case WASM_OPCODE_I64_SHR_S:
+ case WABT_OPCODE_I64_SHR_S:
BINOP_SHIFT(I64, >>, SIGNED);
break;
- case WASM_OPCODE_I64_EQ:
+ case WABT_OPCODE_I64_EQ:
BINOP(I32, I64, == );
break;
- case WASM_OPCODE_I64_NE:
+ case WABT_OPCODE_I64_NE:
BINOP(I32, I64, != );
break;
- case WASM_OPCODE_I64_LT_S:
+ case WABT_OPCODE_I64_LT_S:
BINOP_SIGNED(I32, I64, < );
break;
- case WASM_OPCODE_I64_LE_S:
+ case WABT_OPCODE_I64_LE_S:
BINOP_SIGNED(I32, I64, <= );
break;
- case WASM_OPCODE_I64_LT_U:
+ case WABT_OPCODE_I64_LT_U:
BINOP(I32, I64, < );
break;
- case WASM_OPCODE_I64_LE_U:
+ case WABT_OPCODE_I64_LE_U:
BINOP(I32, I64, <= );
break;
- case WASM_OPCODE_I64_GT_S:
+ case WABT_OPCODE_I64_GT_S:
BINOP_SIGNED(I32, I64, > );
break;
- case WASM_OPCODE_I64_GE_S:
+ case WABT_OPCODE_I64_GE_S:
BINOP_SIGNED(I32, I64, >= );
break;
- case WASM_OPCODE_I64_GT_U:
+ case WABT_OPCODE_I64_GT_U:
BINOP(I32, I64, > );
break;
- case WASM_OPCODE_I64_GE_U:
+ case WABT_OPCODE_I64_GE_U:
BINOP(I32, I64, >= );
break;
- case WASM_OPCODE_I64_CLZ: {
+ case WABT_OPCODE_I64_CLZ: {
VALUE_TYPE_I64 value = POP_I64();
- PUSH_I64(value != 0 ? wasm_clz_u64(value) : 64);
+ PUSH_I64(value != 0 ? wabt_clz_u64(value) : 64);
break;
}
- case WASM_OPCODE_I64_CTZ: {
+ case WABT_OPCODE_I64_CTZ: {
VALUE_TYPE_I64 value = POP_I64();
- PUSH_I64(value != 0 ? wasm_ctz_u64(value) : 64);
+ PUSH_I64(value != 0 ? wabt_ctz_u64(value) : 64);
break;
}
- case WASM_OPCODE_I64_POPCNT: {
+ case WABT_OPCODE_I64_POPCNT: {
VALUE_TYPE_I64 value = POP_I64();
- PUSH_I64(wasm_popcount_u64(value));
+ PUSH_I64(wabt_popcount_u64(value));
break;
}
- case WASM_OPCODE_F32_ADD:
+ case WABT_OPCODE_F32_ADD:
BINOP_FLOAT(F32, +);
break;
- case WASM_OPCODE_F32_SUB:
+ case WABT_OPCODE_F32_SUB:
BINOP_FLOAT(F32, -);
break;
- case WASM_OPCODE_F32_MUL:
+ case WABT_OPCODE_F32_MUL:
BINOP_FLOAT(F32, *);
break;
- case WASM_OPCODE_F32_DIV:
+ case WABT_OPCODE_F32_DIV:
BINOP_FLOAT_DIV(F32);
break;
- case WASM_OPCODE_F32_MIN:
+ case WABT_OPCODE_F32_MIN:
MINMAX_FLOAT(F32, MIN);
break;
- case WASM_OPCODE_F32_MAX:
+ case WABT_OPCODE_F32_MAX:
MINMAX_FLOAT(F32, MAX);
break;
- case WASM_OPCODE_F32_ABS:
+ case WABT_OPCODE_F32_ABS:
TOP().f32_bits &= ~F32_SIGN_MASK;
break;
- case WASM_OPCODE_F32_NEG:
+ case WABT_OPCODE_F32_NEG:
TOP().f32_bits ^= F32_SIGN_MASK;
break;
- case WASM_OPCODE_F32_COPYSIGN: {
+ case WABT_OPCODE_F32_COPYSIGN: {
VALUE_TYPE_F32 rhs = POP_F32();
VALUE_TYPE_F32 lhs = POP_F32();
PUSH_F32((lhs & ~F32_SIGN_MASK) | (rhs & F32_SIGN_MASK));
break;
}
- case WASM_OPCODE_F32_CEIL:
+ case WABT_OPCODE_F32_CEIL:
UNOP_FLOAT(F32, ceilf);
break;
- case WASM_OPCODE_F32_FLOOR:
+ case WABT_OPCODE_F32_FLOOR:
UNOP_FLOAT(F32, floorf);
break;
- case WASM_OPCODE_F32_TRUNC:
+ case WABT_OPCODE_F32_TRUNC:
UNOP_FLOAT(F32, truncf);
break;
- case WASM_OPCODE_F32_NEAREST:
+ case WABT_OPCODE_F32_NEAREST:
UNOP_FLOAT(F32, nearbyintf);
break;
- case WASM_OPCODE_F32_SQRT:
+ case WABT_OPCODE_F32_SQRT:
UNOP_FLOAT(F32, sqrtf);
break;
- case WASM_OPCODE_F32_EQ:
+ case WABT_OPCODE_F32_EQ:
BINOP_FLOAT_COMPARE(F32, == );
break;
- case WASM_OPCODE_F32_NE:
+ case WABT_OPCODE_F32_NE:
BINOP_FLOAT_COMPARE(F32, != );
break;
- case WASM_OPCODE_F32_LT:
+ case WABT_OPCODE_F32_LT:
BINOP_FLOAT_COMPARE(F32, < );
break;
- case WASM_OPCODE_F32_LE:
+ case WABT_OPCODE_F32_LE:
BINOP_FLOAT_COMPARE(F32, <= );
break;
- case WASM_OPCODE_F32_GT:
+ case WABT_OPCODE_F32_GT:
BINOP_FLOAT_COMPARE(F32, > );
break;
- case WASM_OPCODE_F32_GE:
+ case WABT_OPCODE_F32_GE:
BINOP_FLOAT_COMPARE(F32, >= );
break;
- case WASM_OPCODE_F64_ADD:
+ case WABT_OPCODE_F64_ADD:
BINOP_FLOAT(F64, +);
break;
- case WASM_OPCODE_F64_SUB:
+ case WABT_OPCODE_F64_SUB:
BINOP_FLOAT(F64, -);
break;
- case WASM_OPCODE_F64_MUL:
+ case WABT_OPCODE_F64_MUL:
BINOP_FLOAT(F64, *);
break;
- case WASM_OPCODE_F64_DIV:
+ case WABT_OPCODE_F64_DIV:
BINOP_FLOAT_DIV(F64);
break;
- case WASM_OPCODE_F64_MIN:
+ case WABT_OPCODE_F64_MIN:
MINMAX_FLOAT(F64, MIN);
break;
- case WASM_OPCODE_F64_MAX:
+ case WABT_OPCODE_F64_MAX:
MINMAX_FLOAT(F64, MAX);
break;
- case WASM_OPCODE_F64_ABS:
+ case WABT_OPCODE_F64_ABS:
TOP().f64_bits &= ~F64_SIGN_MASK;
break;
- case WASM_OPCODE_F64_NEG:
+ case WABT_OPCODE_F64_NEG:
TOP().f64_bits ^= F64_SIGN_MASK;
break;
- case WASM_OPCODE_F64_COPYSIGN: {
+ case WABT_OPCODE_F64_COPYSIGN: {
VALUE_TYPE_F64 rhs = POP_F64();
VALUE_TYPE_F64 lhs = POP_F64();
PUSH_F64((lhs & ~F64_SIGN_MASK) | (rhs & F64_SIGN_MASK));
break;
}
- case WASM_OPCODE_F64_CEIL:
+ case WABT_OPCODE_F64_CEIL:
UNOP_FLOAT(F64, ceil);
break;
- case WASM_OPCODE_F64_FLOOR:
+ case WABT_OPCODE_F64_FLOOR:
UNOP_FLOAT(F64, floor);
break;
- case WASM_OPCODE_F64_TRUNC:
+ case WABT_OPCODE_F64_TRUNC:
UNOP_FLOAT(F64, trunc);
break;
- case WASM_OPCODE_F64_NEAREST:
+ case WABT_OPCODE_F64_NEAREST:
UNOP_FLOAT(F64, nearbyint);
break;
- case WASM_OPCODE_F64_SQRT:
+ case WABT_OPCODE_F64_SQRT:
UNOP_FLOAT(F64, sqrt);
break;
- case WASM_OPCODE_F64_EQ:
+ case WABT_OPCODE_F64_EQ:
BINOP_FLOAT_COMPARE(F64, == );
break;
- case WASM_OPCODE_F64_NE:
+ case WABT_OPCODE_F64_NE:
BINOP_FLOAT_COMPARE(F64, != );
break;
- case WASM_OPCODE_F64_LT:
+ case WABT_OPCODE_F64_LT:
BINOP_FLOAT_COMPARE(F64, < );
break;
- case WASM_OPCODE_F64_LE:
+ case WABT_OPCODE_F64_LE:
BINOP_FLOAT_COMPARE(F64, <= );
break;
- case WASM_OPCODE_F64_GT:
+ case WABT_OPCODE_F64_GT:
BINOP_FLOAT_COMPARE(F64, > );
break;
- case WASM_OPCODE_F64_GE:
+ case WABT_OPCODE_F64_GE:
BINOP_FLOAT_COMPARE(F64, >= );
break;
- case WASM_OPCODE_I32_TRUNC_S_F32: {
+ case WABT_OPCODE_I32_TRUNC_S_F32: {
VALUE_TYPE_F32 value = POP_F32();
- TRAP_IF(is_nan_f32(value), INVALID_CONVERSION_TO_INTEGER);
+ TRAP_IF(wabt_is_nan_f32(value), INVALID_CONVERSION_TO_INTEGER);
TRAP_UNLESS(is_in_range_i32_trunc_s_f32(value), INTEGER_OVERFLOW);
PUSH_I32((int32_t)BITCAST_TO_F32(value));
break;
}
- case WASM_OPCODE_I32_TRUNC_S_F64: {
+ case WABT_OPCODE_I32_TRUNC_S_F64: {
VALUE_TYPE_F64 value = POP_F64();
- TRAP_IF(is_nan_f64(value), INVALID_CONVERSION_TO_INTEGER);
+ TRAP_IF(wabt_is_nan_f64(value), INVALID_CONVERSION_TO_INTEGER);
TRAP_UNLESS(is_in_range_i32_trunc_s_f64(value), INTEGER_OVERFLOW);
PUSH_I32((int32_t)BITCAST_TO_F64(value));
break;
}
- case WASM_OPCODE_I32_TRUNC_U_F32: {
+ case WABT_OPCODE_I32_TRUNC_U_F32: {
VALUE_TYPE_F32 value = POP_F32();
- TRAP_IF(is_nan_f32(value), INVALID_CONVERSION_TO_INTEGER);
+ TRAP_IF(wabt_is_nan_f32(value), INVALID_CONVERSION_TO_INTEGER);
TRAP_UNLESS(is_in_range_i32_trunc_u_f32(value), INTEGER_OVERFLOW);
PUSH_I32((uint32_t)BITCAST_TO_F32(value));
break;
}
- case WASM_OPCODE_I32_TRUNC_U_F64: {
+ case WABT_OPCODE_I32_TRUNC_U_F64: {
VALUE_TYPE_F64 value = POP_F64();
- TRAP_IF(is_nan_f64(value), INVALID_CONVERSION_TO_INTEGER);
+ TRAP_IF(wabt_is_nan_f64(value), INVALID_CONVERSION_TO_INTEGER);
TRAP_UNLESS(is_in_range_i32_trunc_u_f64(value), INTEGER_OVERFLOW);
PUSH_I32((uint32_t)BITCAST_TO_F64(value));
break;
}
- case WASM_OPCODE_I32_WRAP_I64: {
+ case WABT_OPCODE_I32_WRAP_I64: {
VALUE_TYPE_I64 value = POP_I64();
PUSH_I32((uint32_t)value);
break;
}
- case WASM_OPCODE_I64_TRUNC_S_F32: {
+ case WABT_OPCODE_I64_TRUNC_S_F32: {
VALUE_TYPE_F32 value = POP_F32();
- TRAP_IF(is_nan_f32(value), INVALID_CONVERSION_TO_INTEGER);
+ TRAP_IF(wabt_is_nan_f32(value), INVALID_CONVERSION_TO_INTEGER);
TRAP_UNLESS(is_in_range_i64_trunc_s_f32(value), INTEGER_OVERFLOW);
PUSH_I64((int64_t)BITCAST_TO_F32(value));
break;
}
- case WASM_OPCODE_I64_TRUNC_S_F64: {
+ case WABT_OPCODE_I64_TRUNC_S_F64: {
VALUE_TYPE_F64 value = POP_F64();
- TRAP_IF(is_nan_f64(value), INVALID_CONVERSION_TO_INTEGER);
+ TRAP_IF(wabt_is_nan_f64(value), INVALID_CONVERSION_TO_INTEGER);
TRAP_UNLESS(is_in_range_i64_trunc_s_f64(value), INTEGER_OVERFLOW);
PUSH_I64((int64_t)BITCAST_TO_F64(value));
break;
}
- case WASM_OPCODE_I64_TRUNC_U_F32: {
+ case WABT_OPCODE_I64_TRUNC_U_F32: {
VALUE_TYPE_F32 value = POP_F32();
- TRAP_IF(is_nan_f32(value), INVALID_CONVERSION_TO_INTEGER);
+ TRAP_IF(wabt_is_nan_f32(value), INVALID_CONVERSION_TO_INTEGER);
TRAP_UNLESS(is_in_range_i64_trunc_u_f32(value), INTEGER_OVERFLOW);
PUSH_I64((uint64_t)BITCAST_TO_F32(value));
break;
}
- case WASM_OPCODE_I64_TRUNC_U_F64: {
+ case WABT_OPCODE_I64_TRUNC_U_F64: {
VALUE_TYPE_F64 value = POP_F64();
- TRAP_IF(is_nan_f64(value), INVALID_CONVERSION_TO_INTEGER);
+ TRAP_IF(wabt_is_nan_f64(value), INVALID_CONVERSION_TO_INTEGER);
TRAP_UNLESS(is_in_range_i64_trunc_u_f64(value), INTEGER_OVERFLOW);
PUSH_I64((uint64_t)BITCAST_TO_F64(value));
break;
}
- case WASM_OPCODE_I64_EXTEND_S_I32: {
+ case WABT_OPCODE_I64_EXTEND_S_I32: {
VALUE_TYPE_I32 value = POP_I32();
PUSH_I64((int64_t)BITCAST_I32_TO_SIGNED(value));
break;
}
- case WASM_OPCODE_I64_EXTEND_U_I32: {
+ case WABT_OPCODE_I64_EXTEND_U_I32: {
VALUE_TYPE_I32 value = POP_I32();
PUSH_I64((uint64_t)value);
break;
}
- case WASM_OPCODE_F32_CONVERT_S_I32: {
+ case WABT_OPCODE_F32_CONVERT_S_I32: {
VALUE_TYPE_I32 value = POP_I32();
PUSH_F32(BITCAST_FROM_F32((float)BITCAST_I32_TO_SIGNED(value)));
break;
}
- case WASM_OPCODE_F32_CONVERT_U_I32: {
+ case WABT_OPCODE_F32_CONVERT_U_I32: {
VALUE_TYPE_I32 value = POP_I32();
PUSH_F32(BITCAST_FROM_F32((float)value));
break;
}
- case WASM_OPCODE_F32_CONVERT_S_I64: {
+ case WABT_OPCODE_F32_CONVERT_S_I64: {
VALUE_TYPE_I64 value = POP_I64();
PUSH_F32(BITCAST_FROM_F32((float)BITCAST_I64_TO_SIGNED(value)));
break;
}
- case WASM_OPCODE_F32_CONVERT_U_I64: {
+ case WABT_OPCODE_F32_CONVERT_U_I64: {
VALUE_TYPE_I64 value = POP_I64();
PUSH_F32(BITCAST_FROM_F32((float)value));
break;
}
- case WASM_OPCODE_F32_DEMOTE_F64: {
+ case WABT_OPCODE_F32_DEMOTE_F64: {
VALUE_TYPE_F64 value = POP_F64();
- if (WASM_LIKELY(is_in_range_f64_demote_f32(value))) {
+ if (WABT_LIKELY(is_in_range_f64_demote_f32(value))) {
PUSH_F32(BITCAST_FROM_F32((float)BITCAST_TO_F64(value)));
} else if (is_in_range_f64_demote_f32_round_to_f32_max(value)) {
PUSH_F32(F32_MAX);
@@ -1573,116 +1573,116 @@ WasmInterpreterResult wasm_run_interpreter(WasmInterpreterThread* thread,
break;
}
- case WASM_OPCODE_F32_REINTERPRET_I32: {
+ case WABT_OPCODE_F32_REINTERPRET_I32: {
VALUE_TYPE_I32 value = POP_I32();
PUSH_F32(value);
break;
}
- case WASM_OPCODE_F64_CONVERT_S_I32: {
+ case WABT_OPCODE_F64_CONVERT_S_I32: {
VALUE_TYPE_I32 value = POP_I32();
PUSH_F64(BITCAST_FROM_F64((double)BITCAST_I32_TO_SIGNED(value)));
break;
}
- case WASM_OPCODE_F64_CONVERT_U_I32: {
+ case WABT_OPCODE_F64_CONVERT_U_I32: {
VALUE_TYPE_I32 value = POP_I32();
PUSH_F64(BITCAST_FROM_F64((double)value));
break;
}
- case WASM_OPCODE_F64_CONVERT_S_I64: {
+ case WABT_OPCODE_F64_CONVERT_S_I64: {
VALUE_TYPE_I64 value = POP_I64();
PUSH_F64(BITCAST_FROM_F64((double)BITCAST_I64_TO_SIGNED(value)));
break;
}
- case WASM_OPCODE_F64_CONVERT_U_I64: {
+ case WABT_OPCODE_F64_CONVERT_U_I64: {
VALUE_TYPE_I64 value = POP_I64();
PUSH_F64(BITCAST_FROM_F64((double)value));
break;
}
- case WASM_OPCODE_F64_PROMOTE_F32: {
+ case WABT_OPCODE_F64_PROMOTE_F32: {
VALUE_TYPE_F32 value = POP_F32();
PUSH_F64(BITCAST_FROM_F64((double)BITCAST_TO_F32(value)));
break;
}
- case WASM_OPCODE_F64_REINTERPRET_I64: {
+ case WABT_OPCODE_F64_REINTERPRET_I64: {
VALUE_TYPE_I64 value = POP_I64();
PUSH_F64(value);
break;
}
- case WASM_OPCODE_I32_REINTERPRET_F32: {
+ case WABT_OPCODE_I32_REINTERPRET_F32: {
VALUE_TYPE_F32 value = POP_F32();
PUSH_I32(value);
break;
}
- case WASM_OPCODE_I64_REINTERPRET_F64: {
+ case WABT_OPCODE_I64_REINTERPRET_F64: {
VALUE_TYPE_F64 value = POP_F64();
PUSH_I64(value);
break;
}
- case WASM_OPCODE_I32_ROTR:
+ case WABT_OPCODE_I32_ROTR:
BINOP_ROT(I32, RIGHT);
break;
- case WASM_OPCODE_I32_ROTL:
+ case WABT_OPCODE_I32_ROTL:
BINOP_ROT(I32, LEFT);
break;
- case WASM_OPCODE_I64_ROTR:
+ case WABT_OPCODE_I64_ROTR:
BINOP_ROT(I64, RIGHT);
break;
- case WASM_OPCODE_I64_ROTL:
+ case WABT_OPCODE_I64_ROTL:
BINOP_ROT(I64, LEFT);
break;
- case WASM_OPCODE_I64_EQZ: {
+ case WABT_OPCODE_I64_EQZ: {
VALUE_TYPE_I64 value = POP_I64();
PUSH_I64(value == 0);
break;
}
- case WASM_OPCODE_ALLOCA: {
- WasmInterpreterValue* old_value_stack_top = thread->value_stack_top;
+ case WABT_OPCODE_ALLOCA: {
+ WabtInterpreterValue* old_value_stack_top = thread->value_stack_top;
thread->value_stack_top += read_u32(&pc);
CHECK_STACK();
memset(old_value_stack_top, 0,
(thread->value_stack_top - old_value_stack_top) *
- sizeof(WasmInterpreterValue));
+ sizeof(WabtInterpreterValue));
break;
}
- case WASM_OPCODE_BR_UNLESS: {
+ case WABT_OPCODE_BR_UNLESS: {
uint32_t new_pc = read_u32(&pc);
if (!POP_I32())
GOTO(new_pc);
break;
}
- case WASM_OPCODE_DROP:
+ case WABT_OPCODE_DROP:
(void)POP();
break;
- case WASM_OPCODE_DROP_KEEP: {
+ case WABT_OPCODE_DROP_KEEP: {
uint32_t drop_count = read_u32(&pc);
uint8_t keep_count = *pc++;
DROP_KEEP(drop_count, keep_count);
break;
}
- case WASM_OPCODE_DATA:
+ case WABT_OPCODE_DATA:
/* shouldn't ever execute this */
assert(0);
break;
- case WASM_OPCODE_NOP:
+ case WABT_OPCODE_NOP:
break;
default:
@@ -1696,370 +1696,370 @@ exit_loop:
return result;
}
-void wasm_trace_pc(WasmInterpreterThread* thread, WasmStream* stream) {
+void wabt_trace_pc(WabtInterpreterThread* thread, WabtStream* stream) {
const uint8_t* istream = thread->env->istream.start;
const uint8_t* pc = &istream[thread->pc];
size_t value_stack_depth = thread->value_stack_top - thread->value_stack.data;
size_t call_stack_depth = thread->call_stack_top - thread->call_stack.data;
- wasm_writef(stream, "#%" PRIzd ". %4" PRIzd ": V:%-3" PRIzd "| ",
+ wabt_writef(stream, "#%" PRIzd ". %4" PRIzd ": V:%-3" PRIzd "| ",
call_stack_depth, pc - (uint8_t*)thread->env->istream.start,
value_stack_depth);
uint8_t opcode = *pc++;
switch (opcode) {
- case WASM_OPCODE_SELECT:
- wasm_writef(stream, "%s %u, %" PRIu64 ", %" PRIu64 "\n",
- wasm_get_interpreter_opcode_name(opcode), PICK(3).i32,
+ case WABT_OPCODE_SELECT:
+ wabt_writef(stream, "%s %u, %" PRIu64 ", %" PRIu64 "\n",
+ wabt_get_interpreter_opcode_name(opcode), PICK(3).i32,
PICK(2).i64, PICK(1).i64);
break;
- case WASM_OPCODE_BR:
- wasm_writef(stream, "%s @%u\n", wasm_get_interpreter_opcode_name(opcode),
+ case WABT_OPCODE_BR:
+ wabt_writef(stream, "%s @%u\n", wabt_get_interpreter_opcode_name(opcode),
read_u32_at(pc));
break;
- case WASM_OPCODE_BR_IF:
- wasm_writef(stream, "%s @%u, %u\n",
- wasm_get_interpreter_opcode_name(opcode), read_u32_at(pc),
+ case WABT_OPCODE_BR_IF:
+ wabt_writef(stream, "%s @%u, %u\n",
+ wabt_get_interpreter_opcode_name(opcode), read_u32_at(pc),
TOP().i32);
break;
- case WASM_OPCODE_BR_TABLE: {
+ case WABT_OPCODE_BR_TABLE: {
uint32_t num_targets = read_u32_at(pc);
uint32_t table_offset = read_u32_at(pc + 4);
VALUE_TYPE_I32 key = TOP().i32;
- wasm_writef(stream, "%s %u, $#%u, table:$%u\n",
- wasm_get_interpreter_opcode_name(opcode), key, num_targets,
+ wabt_writef(stream, "%s %u, $#%u, table:$%u\n",
+ wabt_get_interpreter_opcode_name(opcode), key, num_targets,
table_offset);
break;
}
- case WASM_OPCODE_NOP:
- case WASM_OPCODE_RETURN:
- case WASM_OPCODE_UNREACHABLE:
- case WASM_OPCODE_DROP:
- wasm_writef(stream, "%s\n", wasm_get_interpreter_opcode_name(opcode));
+ case WABT_OPCODE_NOP:
+ case WABT_OPCODE_RETURN:
+ case WABT_OPCODE_UNREACHABLE:
+ case WABT_OPCODE_DROP:
+ wabt_writef(stream, "%s\n", wabt_get_interpreter_opcode_name(opcode));
break;
- case WASM_OPCODE_CURRENT_MEMORY: {
+ case WABT_OPCODE_CURRENT_MEMORY: {
uint32_t memory_index = read_u32(&pc);
- wasm_writef(stream, "%s $%u\n", wasm_get_interpreter_opcode_name(opcode),
+ wabt_writef(stream, "%s $%u\n", wabt_get_interpreter_opcode_name(opcode),
memory_index);
break;
}
- case WASM_OPCODE_I32_CONST:
- wasm_writef(stream, "%s $%u\n", wasm_get_interpreter_opcode_name(opcode),
+ case WABT_OPCODE_I32_CONST:
+ wabt_writef(stream, "%s $%u\n", wabt_get_interpreter_opcode_name(opcode),
read_u32_at(pc));
break;
- case WASM_OPCODE_I64_CONST:
- wasm_writef(stream, "%s $%" PRIu64 "\n",
- wasm_get_interpreter_opcode_name(opcode), read_u64_at(pc));
+ case WABT_OPCODE_I64_CONST:
+ wabt_writef(stream, "%s $%" PRIu64 "\n",
+ wabt_get_interpreter_opcode_name(opcode), read_u64_at(pc));
break;
- case WASM_OPCODE_F32_CONST:
- wasm_writef(stream, "%s $%g\n", wasm_get_interpreter_opcode_name(opcode),
+ case WABT_OPCODE_F32_CONST:
+ wabt_writef(stream, "%s $%g\n", wabt_get_interpreter_opcode_name(opcode),
bitcast_u32_to_f32(read_u32_at(pc)));
break;
- case WASM_OPCODE_F64_CONST:
- wasm_writef(stream, "%s $%g\n", wasm_get_interpreter_opcode_name(opcode),
+ case WABT_OPCODE_F64_CONST:
+ wabt_writef(stream, "%s $%g\n", wabt_get_interpreter_opcode_name(opcode),
bitcast_u64_to_f64(read_u64_at(pc)));
break;
- case WASM_OPCODE_GET_LOCAL:
- case WASM_OPCODE_GET_GLOBAL:
- wasm_writef(stream, "%s $%u\n", wasm_get_interpreter_opcode_name(opcode),
+ case WABT_OPCODE_GET_LOCAL:
+ case WABT_OPCODE_GET_GLOBAL:
+ wabt_writef(stream, "%s $%u\n", wabt_get_interpreter_opcode_name(opcode),
read_u32_at(pc));
break;
- case WASM_OPCODE_SET_LOCAL:
- case WASM_OPCODE_SET_GLOBAL:
- case WASM_OPCODE_TEE_LOCAL:
- wasm_writef(stream, "%s $%u, %u\n",
- wasm_get_interpreter_opcode_name(opcode), read_u32_at(pc),
+ case WABT_OPCODE_SET_LOCAL:
+ case WABT_OPCODE_SET_GLOBAL:
+ case WABT_OPCODE_TEE_LOCAL:
+ wabt_writef(stream, "%s $%u, %u\n",
+ wabt_get_interpreter_opcode_name(opcode), read_u32_at(pc),
TOP().i32);
break;
- case WASM_OPCODE_CALL:
- wasm_writef(stream, "%s @%u\n", wasm_get_interpreter_opcode_name(opcode),
+ case WABT_OPCODE_CALL:
+ wabt_writef(stream, "%s @%u\n", wabt_get_interpreter_opcode_name(opcode),
read_u32_at(pc));
break;
- case WASM_OPCODE_CALL_INDIRECT:
- wasm_writef(stream, "%s $%u, %u\n",
- wasm_get_interpreter_opcode_name(opcode), read_u32_at(pc),
+ case WABT_OPCODE_CALL_INDIRECT:
+ wabt_writef(stream, "%s $%u, %u\n",
+ wabt_get_interpreter_opcode_name(opcode), read_u32_at(pc),
TOP().i32);
break;
- case WASM_OPCODE_CALL_HOST:
- wasm_writef(stream, "%s $%u\n", wasm_get_interpreter_opcode_name(opcode),
+ case WABT_OPCODE_CALL_HOST:
+ wabt_writef(stream, "%s $%u\n", wabt_get_interpreter_opcode_name(opcode),
read_u32_at(pc));
break;
- case WASM_OPCODE_I32_LOAD8_S:
- case WASM_OPCODE_I32_LOAD8_U:
- case WASM_OPCODE_I32_LOAD16_S:
- case WASM_OPCODE_I32_LOAD16_U:
- case WASM_OPCODE_I64_LOAD8_S:
- case WASM_OPCODE_I64_LOAD8_U:
- case WASM_OPCODE_I64_LOAD16_S:
- case WASM_OPCODE_I64_LOAD16_U:
- case WASM_OPCODE_I64_LOAD32_S:
- case WASM_OPCODE_I64_LOAD32_U:
- case WASM_OPCODE_I32_LOAD:
- case WASM_OPCODE_I64_LOAD:
- case WASM_OPCODE_F32_LOAD:
- case WASM_OPCODE_F64_LOAD: {
+ case WABT_OPCODE_I32_LOAD8_S:
+ case WABT_OPCODE_I32_LOAD8_U:
+ case WABT_OPCODE_I32_LOAD16_S:
+ case WABT_OPCODE_I32_LOAD16_U:
+ case WABT_OPCODE_I64_LOAD8_S:
+ case WABT_OPCODE_I64_LOAD8_U:
+ case WABT_OPCODE_I64_LOAD16_S:
+ case WABT_OPCODE_I64_LOAD16_U:
+ case WABT_OPCODE_I64_LOAD32_S:
+ case WABT_OPCODE_I64_LOAD32_U:
+ case WABT_OPCODE_I32_LOAD:
+ case WABT_OPCODE_I64_LOAD:
+ case WABT_OPCODE_F32_LOAD:
+ case WABT_OPCODE_F64_LOAD: {
uint32_t memory_index = read_u32(&pc);
- wasm_writef(stream, "%s $%u:%u+$%u\n",
- wasm_get_interpreter_opcode_name(opcode), memory_index,
+ wabt_writef(stream, "%s $%u:%u+$%u\n",
+ wabt_get_interpreter_opcode_name(opcode), memory_index,
TOP().i32, read_u32_at(pc));
break;
}
- case WASM_OPCODE_I32_STORE8:
- case WASM_OPCODE_I32_STORE16:
- case WASM_OPCODE_I32_STORE: {
+ case WABT_OPCODE_I32_STORE8:
+ case WABT_OPCODE_I32_STORE16:
+ case WABT_OPCODE_I32_STORE: {
uint32_t memory_index = read_u32(&pc);
- wasm_writef(stream, "%s $%u:%u+$%u, %u\n",
- wasm_get_interpreter_opcode_name(opcode), memory_index,
+ wabt_writef(stream, "%s $%u:%u+$%u, %u\n",
+ wabt_get_interpreter_opcode_name(opcode), memory_index,
PICK(2).i32, read_u32_at(pc), PICK(1).i32);
break;
}
- case WASM_OPCODE_I64_STORE8:
- case WASM_OPCODE_I64_STORE16:
- case WASM_OPCODE_I64_STORE32:
- case WASM_OPCODE_I64_STORE: {
+ case WABT_OPCODE_I64_STORE8:
+ case WABT_OPCODE_I64_STORE16:
+ case WABT_OPCODE_I64_STORE32:
+ case WABT_OPCODE_I64_STORE: {
uint32_t memory_index = read_u32(&pc);
- wasm_writef(stream, "%s $%u:%u+$%u, %" PRIu64 "\n",
- wasm_get_interpreter_opcode_name(opcode), memory_index,
+ wabt_writef(stream, "%s $%u:%u+$%u, %" PRIu64 "\n",
+ wabt_get_interpreter_opcode_name(opcode), memory_index,
PICK(2).i32, read_u32_at(pc), PICK(1).i64);
break;
}
- case WASM_OPCODE_F32_STORE: {
+ case WABT_OPCODE_F32_STORE: {
uint32_t memory_index = read_u32(&pc);
- wasm_writef(stream, "%s $%u:%u+$%u, %g\n",
- wasm_get_interpreter_opcode_name(opcode), memory_index,
+ wabt_writef(stream, "%s $%u:%u+$%u, %g\n",
+ wabt_get_interpreter_opcode_name(opcode), memory_index,
PICK(2).i32, read_u32_at(pc),
bitcast_u32_to_f32(PICK(1).f32_bits));
break;
}
- case WASM_OPCODE_F64_STORE: {
+ case WABT_OPCODE_F64_STORE: {
uint32_t memory_index = read_u32(&pc);
- wasm_writef(stream, "%s $%u:%u+$%u, %g\n",
- wasm_get_interpreter_opcode_name(opcode), memory_index,
+ wabt_writef(stream, "%s $%u:%u+$%u, %g\n",
+ wabt_get_interpreter_opcode_name(opcode), memory_index,
PICK(2).i32, read_u32_at(pc),
bitcast_u64_to_f64(PICK(1).f64_bits));
break;
}
- case WASM_OPCODE_GROW_MEMORY: {
+ case WABT_OPCODE_GROW_MEMORY: {
uint32_t memory_index = read_u32(&pc);
- wasm_writef(stream, "%s $%u:%u\n",
- wasm_get_interpreter_opcode_name(opcode), memory_index,
+ wabt_writef(stream, "%s $%u:%u\n",
+ wabt_get_interpreter_opcode_name(opcode), memory_index,
TOP().i32);
break;
}
- case WASM_OPCODE_I32_ADD:
- case WASM_OPCODE_I32_SUB:
- case WASM_OPCODE_I32_MUL:
- case WASM_OPCODE_I32_DIV_S:
- case WASM_OPCODE_I32_DIV_U:
- case WASM_OPCODE_I32_REM_S:
- case WASM_OPCODE_I32_REM_U:
- case WASM_OPCODE_I32_AND:
- case WASM_OPCODE_I32_OR:
- case WASM_OPCODE_I32_XOR:
- case WASM_OPCODE_I32_SHL:
- case WASM_OPCODE_I32_SHR_U:
- case WASM_OPCODE_I32_SHR_S:
- case WASM_OPCODE_I32_EQ:
- case WASM_OPCODE_I32_NE:
- case WASM_OPCODE_I32_LT_S:
- case WASM_OPCODE_I32_LE_S:
- case WASM_OPCODE_I32_LT_U:
- case WASM_OPCODE_I32_LE_U:
- case WASM_OPCODE_I32_GT_S:
- case WASM_OPCODE_I32_GE_S:
- case WASM_OPCODE_I32_GT_U:
- case WASM_OPCODE_I32_GE_U:
- case WASM_OPCODE_I32_ROTR:
- case WASM_OPCODE_I32_ROTL:
- wasm_writef(stream, "%s %u, %u\n",
- wasm_get_interpreter_opcode_name(opcode), PICK(2).i32,
+ case WABT_OPCODE_I32_ADD:
+ case WABT_OPCODE_I32_SUB:
+ case WABT_OPCODE_I32_MUL:
+ case WABT_OPCODE_I32_DIV_S:
+ case WABT_OPCODE_I32_DIV_U:
+ case WABT_OPCODE_I32_REM_S:
+ case WABT_OPCODE_I32_REM_U:
+ case WABT_OPCODE_I32_AND:
+ case WABT_OPCODE_I32_OR:
+ case WABT_OPCODE_I32_XOR:
+ case WABT_OPCODE_I32_SHL:
+ case WABT_OPCODE_I32_SHR_U:
+ case WABT_OPCODE_I32_SHR_S:
+ case WABT_OPCODE_I32_EQ:
+ case WABT_OPCODE_I32_NE:
+ case WABT_OPCODE_I32_LT_S:
+ case WABT_OPCODE_I32_LE_S:
+ case WABT_OPCODE_I32_LT_U:
+ case WABT_OPCODE_I32_LE_U:
+ case WABT_OPCODE_I32_GT_S:
+ case WABT_OPCODE_I32_GE_S:
+ case WABT_OPCODE_I32_GT_U:
+ case WABT_OPCODE_I32_GE_U:
+ case WABT_OPCODE_I32_ROTR:
+ case WABT_OPCODE_I32_ROTL:
+ wabt_writef(stream, "%s %u, %u\n",
+ wabt_get_interpreter_opcode_name(opcode), PICK(2).i32,
PICK(1).i32);
break;
- case WASM_OPCODE_I32_CLZ:
- case WASM_OPCODE_I32_CTZ:
- case WASM_OPCODE_I32_POPCNT:
- case WASM_OPCODE_I32_EQZ:
- wasm_writef(stream, "%s %u\n", wasm_get_interpreter_opcode_name(opcode),
+ case WABT_OPCODE_I32_CLZ:
+ case WABT_OPCODE_I32_CTZ:
+ case WABT_OPCODE_I32_POPCNT:
+ case WABT_OPCODE_I32_EQZ:
+ wabt_writef(stream, "%s %u\n", wabt_get_interpreter_opcode_name(opcode),
TOP().i32);
break;
- case WASM_OPCODE_I64_ADD:
- case WASM_OPCODE_I64_SUB:
- case WASM_OPCODE_I64_MUL:
- case WASM_OPCODE_I64_DIV_S:
- case WASM_OPCODE_I64_DIV_U:
- case WASM_OPCODE_I64_REM_S:
- case WASM_OPCODE_I64_REM_U:
- case WASM_OPCODE_I64_AND:
- case WASM_OPCODE_I64_OR:
- case WASM_OPCODE_I64_XOR:
- case WASM_OPCODE_I64_SHL:
- case WASM_OPCODE_I64_SHR_U:
- case WASM_OPCODE_I64_SHR_S:
- case WASM_OPCODE_I64_EQ:
- case WASM_OPCODE_I64_NE:
- case WASM_OPCODE_I64_LT_S:
- case WASM_OPCODE_I64_LE_S:
- case WASM_OPCODE_I64_LT_U:
- case WASM_OPCODE_I64_LE_U:
- case WASM_OPCODE_I64_GT_S:
- case WASM_OPCODE_I64_GE_S:
- case WASM_OPCODE_I64_GT_U:
- case WASM_OPCODE_I64_GE_U:
- case WASM_OPCODE_I64_ROTR:
- case WASM_OPCODE_I64_ROTL:
- wasm_writef(stream, "%s %" PRIu64 ", %" PRIu64 "\n",
- wasm_get_interpreter_opcode_name(opcode), PICK(2).i64,
+ case WABT_OPCODE_I64_ADD:
+ case WABT_OPCODE_I64_SUB:
+ case WABT_OPCODE_I64_MUL:
+ case WABT_OPCODE_I64_DIV_S:
+ case WABT_OPCODE_I64_DIV_U:
+ case WABT_OPCODE_I64_REM_S:
+ case WABT_OPCODE_I64_REM_U:
+ case WABT_OPCODE_I64_AND:
+ case WABT_OPCODE_I64_OR:
+ case WABT_OPCODE_I64_XOR:
+ case WABT_OPCODE_I64_SHL:
+ case WABT_OPCODE_I64_SHR_U:
+ case WABT_OPCODE_I64_SHR_S:
+ case WABT_OPCODE_I64_EQ:
+ case WABT_OPCODE_I64_NE:
+ case WABT_OPCODE_I64_LT_S:
+ case WABT_OPCODE_I64_LE_S:
+ case WABT_OPCODE_I64_LT_U:
+ case WABT_OPCODE_I64_LE_U:
+ case WABT_OPCODE_I64_GT_S:
+ case WABT_OPCODE_I64_GE_S:
+ case WABT_OPCODE_I64_GT_U:
+ case WABT_OPCODE_I64_GE_U:
+ case WABT_OPCODE_I64_ROTR:
+ case WABT_OPCODE_I64_ROTL:
+ wabt_writef(stream, "%s %" PRIu64 ", %" PRIu64 "\n",
+ wabt_get_interpreter_opcode_name(opcode), PICK(2).i64,
PICK(1).i64);
break;
- case WASM_OPCODE_I64_CLZ:
- case WASM_OPCODE_I64_CTZ:
- case WASM_OPCODE_I64_POPCNT:
- case WASM_OPCODE_I64_EQZ:
- wasm_writef(stream, "%s %" PRIu64 "\n",
- wasm_get_interpreter_opcode_name(opcode), TOP().i64);
+ case WABT_OPCODE_I64_CLZ:
+ case WABT_OPCODE_I64_CTZ:
+ case WABT_OPCODE_I64_POPCNT:
+ case WABT_OPCODE_I64_EQZ:
+ wabt_writef(stream, "%s %" PRIu64 "\n",
+ wabt_get_interpreter_opcode_name(opcode), TOP().i64);
break;
- case WASM_OPCODE_F32_ADD:
- case WASM_OPCODE_F32_SUB:
- case WASM_OPCODE_F32_MUL:
- case WASM_OPCODE_F32_DIV:
- case WASM_OPCODE_F32_MIN:
- case WASM_OPCODE_F32_MAX:
- case WASM_OPCODE_F32_COPYSIGN:
- case WASM_OPCODE_F32_EQ:
- case WASM_OPCODE_F32_NE:
- case WASM_OPCODE_F32_LT:
- case WASM_OPCODE_F32_LE:
- case WASM_OPCODE_F32_GT:
- case WASM_OPCODE_F32_GE:
- wasm_writef(
- stream, "%s %g, %g\n", wasm_get_interpreter_opcode_name(opcode),
+ case WABT_OPCODE_F32_ADD:
+ case WABT_OPCODE_F32_SUB:
+ case WABT_OPCODE_F32_MUL:
+ case WABT_OPCODE_F32_DIV:
+ case WABT_OPCODE_F32_MIN:
+ case WABT_OPCODE_F32_MAX:
+ case WABT_OPCODE_F32_COPYSIGN:
+ case WABT_OPCODE_F32_EQ:
+ case WABT_OPCODE_F32_NE:
+ case WABT_OPCODE_F32_LT:
+ case WABT_OPCODE_F32_LE:
+ case WABT_OPCODE_F32_GT:
+ case WABT_OPCODE_F32_GE:
+ wabt_writef(
+ stream, "%s %g, %g\n", wabt_get_interpreter_opcode_name(opcode),
bitcast_u32_to_f32(PICK(2).i32), bitcast_u32_to_f32(PICK(1).i32));
break;
- case WASM_OPCODE_F32_ABS:
- case WASM_OPCODE_F32_NEG:
- case WASM_OPCODE_F32_CEIL:
- case WASM_OPCODE_F32_FLOOR:
- case WASM_OPCODE_F32_TRUNC:
- case WASM_OPCODE_F32_NEAREST:
- case WASM_OPCODE_F32_SQRT:
- wasm_writef(stream, "%s %g\n", wasm_get_interpreter_opcode_name(opcode),
+ case WABT_OPCODE_F32_ABS:
+ case WABT_OPCODE_F32_NEG:
+ case WABT_OPCODE_F32_CEIL:
+ case WABT_OPCODE_F32_FLOOR:
+ case WABT_OPCODE_F32_TRUNC:
+ case WABT_OPCODE_F32_NEAREST:
+ case WABT_OPCODE_F32_SQRT:
+ wabt_writef(stream, "%s %g\n", wabt_get_interpreter_opcode_name(opcode),
bitcast_u32_to_f32(TOP().i32));
break;
- case WASM_OPCODE_F64_ADD:
- case WASM_OPCODE_F64_SUB:
- case WASM_OPCODE_F64_MUL:
- case WASM_OPCODE_F64_DIV:
- case WASM_OPCODE_F64_MIN:
- case WASM_OPCODE_F64_MAX:
- case WASM_OPCODE_F64_COPYSIGN:
- case WASM_OPCODE_F64_EQ:
- case WASM_OPCODE_F64_NE:
- case WASM_OPCODE_F64_LT:
- case WASM_OPCODE_F64_LE:
- case WASM_OPCODE_F64_GT:
- case WASM_OPCODE_F64_GE:
- wasm_writef(
- stream, "%s %g, %g\n", wasm_get_interpreter_opcode_name(opcode),
+ case WABT_OPCODE_F64_ADD:
+ case WABT_OPCODE_F64_SUB:
+ case WABT_OPCODE_F64_MUL:
+ case WABT_OPCODE_F64_DIV:
+ case WABT_OPCODE_F64_MIN:
+ case WABT_OPCODE_F64_MAX:
+ case WABT_OPCODE_F64_COPYSIGN:
+ case WABT_OPCODE_F64_EQ:
+ case WABT_OPCODE_F64_NE:
+ case WABT_OPCODE_F64_LT:
+ case WABT_OPCODE_F64_LE:
+ case WABT_OPCODE_F64_GT:
+ case WABT_OPCODE_F64_GE:
+ wabt_writef(
+ stream, "%s %g, %g\n", wabt_get_interpreter_opcode_name(opcode),
bitcast_u64_to_f64(PICK(2).i64), bitcast_u64_to_f64(PICK(1).i64));
break;
- case WASM_OPCODE_F64_ABS:
- case WASM_OPCODE_F64_NEG:
- case WASM_OPCODE_F64_CEIL:
- case WASM_OPCODE_F64_FLOOR:
- case WASM_OPCODE_F64_TRUNC:
- case WASM_OPCODE_F64_NEAREST:
- case WASM_OPCODE_F64_SQRT:
- wasm_writef(stream, "%s %g\n", wasm_get_interpreter_opcode_name(opcode),
+ case WABT_OPCODE_F64_ABS:
+ case WABT_OPCODE_F64_NEG:
+ case WABT_OPCODE_F64_CEIL:
+ case WABT_OPCODE_F64_FLOOR:
+ case WABT_OPCODE_F64_TRUNC:
+ case WABT_OPCODE_F64_NEAREST:
+ case WABT_OPCODE_F64_SQRT:
+ wabt_writef(stream, "%s %g\n", wabt_get_interpreter_opcode_name(opcode),
bitcast_u64_to_f64(TOP().i64));
break;
- case WASM_OPCODE_I32_TRUNC_S_F32:
- case WASM_OPCODE_I32_TRUNC_U_F32:
- case WASM_OPCODE_I64_TRUNC_S_F32:
- case WASM_OPCODE_I64_TRUNC_U_F32:
- case WASM_OPCODE_F64_PROMOTE_F32:
- case WASM_OPCODE_I32_REINTERPRET_F32:
- wasm_writef(stream, "%s %g\n", wasm_get_interpreter_opcode_name(opcode),
+ case WABT_OPCODE_I32_TRUNC_S_F32:
+ case WABT_OPCODE_I32_TRUNC_U_F32:
+ case WABT_OPCODE_I64_TRUNC_S_F32:
+ case WABT_OPCODE_I64_TRUNC_U_F32:
+ case WABT_OPCODE_F64_PROMOTE_F32:
+ case WABT_OPCODE_I32_REINTERPRET_F32:
+ wabt_writef(stream, "%s %g\n", wabt_get_interpreter_opcode_name(opcode),
bitcast_u32_to_f32(TOP().i32));
break;
- case WASM_OPCODE_I32_TRUNC_S_F64:
- case WASM_OPCODE_I32_TRUNC_U_F64:
- case WASM_OPCODE_I64_TRUNC_S_F64:
- case WASM_OPCODE_I64_TRUNC_U_F64:
- case WASM_OPCODE_F32_DEMOTE_F64:
- case WASM_OPCODE_I64_REINTERPRET_F64:
- wasm_writef(stream, "%s %g\n", wasm_get_interpreter_opcode_name(opcode),
+ case WABT_OPCODE_I32_TRUNC_S_F64:
+ case WABT_OPCODE_I32_TRUNC_U_F64:
+ case WABT_OPCODE_I64_TRUNC_S_F64:
+ case WABT_OPCODE_I64_TRUNC_U_F64:
+ case WABT_OPCODE_F32_DEMOTE_F64:
+ case WABT_OPCODE_I64_REINTERPRET_F64:
+ wabt_writef(stream, "%s %g\n", wabt_get_interpreter_opcode_name(opcode),
bitcast_u64_to_f64(TOP().i64));
break;
- case WASM_OPCODE_I32_WRAP_I64:
- case WASM_OPCODE_F32_CONVERT_S_I64:
- case WASM_OPCODE_F32_CONVERT_U_I64:
- case WASM_OPCODE_F64_CONVERT_S_I64:
- case WASM_OPCODE_F64_CONVERT_U_I64:
- case WASM_OPCODE_F64_REINTERPRET_I64:
- wasm_writef(stream, "%s %" PRIu64 "\n",
- wasm_get_interpreter_opcode_name(opcode), TOP().i64);
+ case WABT_OPCODE_I32_WRAP_I64:
+ case WABT_OPCODE_F32_CONVERT_S_I64:
+ case WABT_OPCODE_F32_CONVERT_U_I64:
+ case WABT_OPCODE_F64_CONVERT_S_I64:
+ case WABT_OPCODE_F64_CONVERT_U_I64:
+ case WABT_OPCODE_F64_REINTERPRET_I64:
+ wabt_writef(stream, "%s %" PRIu64 "\n",
+ wabt_get_interpreter_opcode_name(opcode), TOP().i64);
break;
- case WASM_OPCODE_I64_EXTEND_S_I32:
- case WASM_OPCODE_I64_EXTEND_U_I32:
- case WASM_OPCODE_F32_CONVERT_S_I32:
- case WASM_OPCODE_F32_CONVERT_U_I32:
- case WASM_OPCODE_F32_REINTERPRET_I32:
- case WASM_OPCODE_F64_CONVERT_S_I32:
- case WASM_OPCODE_F64_CONVERT_U_I32:
- wasm_writef(stream, "%s %u\n", wasm_get_interpreter_opcode_name(opcode),
+ case WABT_OPCODE_I64_EXTEND_S_I32:
+ case WABT_OPCODE_I64_EXTEND_U_I32:
+ case WABT_OPCODE_F32_CONVERT_S_I32:
+ case WABT_OPCODE_F32_CONVERT_U_I32:
+ case WABT_OPCODE_F32_REINTERPRET_I32:
+ case WABT_OPCODE_F64_CONVERT_S_I32:
+ case WABT_OPCODE_F64_CONVERT_U_I32:
+ wabt_writef(stream, "%s %u\n", wabt_get_interpreter_opcode_name(opcode),
TOP().i32);
break;
- case WASM_OPCODE_ALLOCA:
- wasm_writef(stream, "%s $%u\n", wasm_get_interpreter_opcode_name(opcode),
+ case WABT_OPCODE_ALLOCA:
+ wabt_writef(stream, "%s $%u\n", wabt_get_interpreter_opcode_name(opcode),
read_u32_at(pc));
break;
- case WASM_OPCODE_BR_UNLESS:
- wasm_writef(stream, "%s @%u, %u\n",
- wasm_get_interpreter_opcode_name(opcode), read_u32_at(pc),
+ case WABT_OPCODE_BR_UNLESS:
+ wabt_writef(stream, "%s @%u, %u\n",
+ wabt_get_interpreter_opcode_name(opcode), read_u32_at(pc),
TOP().i32);
break;
- case WASM_OPCODE_DROP_KEEP:
- wasm_writef(stream, "%s $%u $%u\n",
- wasm_get_interpreter_opcode_name(opcode), read_u32_at(pc),
+ case WABT_OPCODE_DROP_KEEP:
+ wabt_writef(stream, "%s $%u $%u\n",
+ wabt_get_interpreter_opcode_name(opcode), read_u32_at(pc),
*(pc + 4));
break;
- case WASM_OPCODE_DATA:
+ case WABT_OPCODE_DATA:
/* shouldn't ever execute this */
assert(0);
break;
@@ -2070,8 +2070,8 @@ void wasm_trace_pc(WasmInterpreterThread* thread, WasmStream* stream) {
}
}
-void wasm_disassemble(WasmInterpreterEnvironment* env,
- WasmStream* stream,
+void wabt_disassemble(WabtInterpreterEnvironment* env,
+ WabtStream* stream,
uint32_t from,
uint32_t to) {
/* TODO(binji): mark function entries */
@@ -2084,312 +2084,312 @@ void wasm_disassemble(WasmInterpreterEnvironment* env,
const uint8_t* pc = &istream[from];
while ((uint32_t)(pc - istream) < to) {
- wasm_writef(stream, "%4" PRIzd "| ", pc - istream);
+ wabt_writef(stream, "%4" PRIzd "| ", pc - istream);
uint8_t opcode = *pc++;
switch (opcode) {
- case WASM_OPCODE_SELECT:
- wasm_writef(stream, "%s %%[-3], %%[-2], %%[-1]\n",
- wasm_get_interpreter_opcode_name(opcode));
+ case WABT_OPCODE_SELECT:
+ wabt_writef(stream, "%s %%[-3], %%[-2], %%[-1]\n",
+ wabt_get_interpreter_opcode_name(opcode));
break;
- case WASM_OPCODE_BR:
- wasm_writef(stream, "%s @%u\n",
- wasm_get_interpreter_opcode_name(opcode), read_u32(&pc));
+ case WABT_OPCODE_BR:
+ wabt_writef(stream, "%s @%u\n",
+ wabt_get_interpreter_opcode_name(opcode), read_u32(&pc));
break;
- case WASM_OPCODE_BR_IF:
- wasm_writef(stream, "%s @%u, %%[-1]\n",
- wasm_get_interpreter_opcode_name(opcode), read_u32(&pc));
+ case WABT_OPCODE_BR_IF:
+ wabt_writef(stream, "%s @%u, %%[-1]\n",
+ wabt_get_interpreter_opcode_name(opcode), read_u32(&pc));
break;
- case WASM_OPCODE_BR_TABLE: {
+ case WABT_OPCODE_BR_TABLE: {
uint32_t num_targets = read_u32(&pc);
uint32_t table_offset = read_u32(&pc);
- wasm_writef(stream, "%s %%[-1], $#%u, table:$%u\n",
- wasm_get_interpreter_opcode_name(opcode), num_targets,
+ wabt_writef(stream, "%s %%[-1], $#%u, table:$%u\n",
+ wabt_get_interpreter_opcode_name(opcode), num_targets,
table_offset);
break;
}
- case WASM_OPCODE_NOP:
- case WASM_OPCODE_RETURN:
- case WASM_OPCODE_UNREACHABLE:
- case WASM_OPCODE_DROP:
- wasm_writef(stream, "%s\n", wasm_get_interpreter_opcode_name(opcode));
+ case WABT_OPCODE_NOP:
+ case WABT_OPCODE_RETURN:
+ case WABT_OPCODE_UNREACHABLE:
+ case WABT_OPCODE_DROP:
+ wabt_writef(stream, "%s\n", wabt_get_interpreter_opcode_name(opcode));
break;
- case WASM_OPCODE_CURRENT_MEMORY: {
+ case WABT_OPCODE_CURRENT_MEMORY: {
uint32_t memory_index = read_u32(&pc);
- wasm_writef(stream, "%s $%u\n",
- wasm_get_interpreter_opcode_name(opcode), memory_index);
+ wabt_writef(stream, "%s $%u\n",
+ wabt_get_interpreter_opcode_name(opcode), memory_index);
break;
}
- case WASM_OPCODE_I32_CONST:
- wasm_writef(stream, "%s $%u\n",
- wasm_get_interpreter_opcode_name(opcode), read_u32(&pc));
+ case WABT_OPCODE_I32_CONST:
+ wabt_writef(stream, "%s $%u\n",
+ wabt_get_interpreter_opcode_name(opcode), read_u32(&pc));
break;
- case WASM_OPCODE_I64_CONST:
- wasm_writef(stream, "%s $%" PRIu64 "\n",
- wasm_get_interpreter_opcode_name(opcode), read_u64(&pc));
+ case WABT_OPCODE_I64_CONST:
+ wabt_writef(stream, "%s $%" PRIu64 "\n",
+ wabt_get_interpreter_opcode_name(opcode), read_u64(&pc));
break;
- case WASM_OPCODE_F32_CONST:
- wasm_writef(stream, "%s $%g\n",
- wasm_get_interpreter_opcode_name(opcode),
+ case WABT_OPCODE_F32_CONST:
+ wabt_writef(stream, "%s $%g\n",
+ wabt_get_interpreter_opcode_name(opcode),
bitcast_u32_to_f32(read_u32(&pc)));
break;
- case WASM_OPCODE_F64_CONST:
- wasm_writef(stream, "%s $%g\n",
- wasm_get_interpreter_opcode_name(opcode),
+ case WABT_OPCODE_F64_CONST:
+ wabt_writef(stream, "%s $%g\n",
+ wabt_get_interpreter_opcode_name(opcode),
bitcast_u64_to_f64(read_u64(&pc)));
break;
- case WASM_OPCODE_GET_LOCAL:
- case WASM_OPCODE_GET_GLOBAL:
- wasm_writef(stream, "%s $%u\n",
- wasm_get_interpreter_opcode_name(opcode), read_u32(&pc));
+ case WABT_OPCODE_GET_LOCAL:
+ case WABT_OPCODE_GET_GLOBAL:
+ wabt_writef(stream, "%s $%u\n",
+ wabt_get_interpreter_opcode_name(opcode), read_u32(&pc));
break;
- case WASM_OPCODE_SET_LOCAL:
- case WASM_OPCODE_SET_GLOBAL:
- case WASM_OPCODE_TEE_LOCAL:
- wasm_writef(stream, "%s $%u, %%[-1]\n",
- wasm_get_interpreter_opcode_name(opcode), read_u32(&pc));
+ case WABT_OPCODE_SET_LOCAL:
+ case WABT_OPCODE_SET_GLOBAL:
+ case WABT_OPCODE_TEE_LOCAL:
+ wabt_writef(stream, "%s $%u, %%[-1]\n",
+ wabt_get_interpreter_opcode_name(opcode), read_u32(&pc));
break;
- case WASM_OPCODE_CALL:
- wasm_writef(stream, "%s @%u\n",
- wasm_get_interpreter_opcode_name(opcode), read_u32(&pc));
+ case WABT_OPCODE_CALL:
+ wabt_writef(stream, "%s @%u\n",
+ wabt_get_interpreter_opcode_name(opcode), read_u32(&pc));
break;
- case WASM_OPCODE_CALL_INDIRECT: {
+ case WABT_OPCODE_CALL_INDIRECT: {
uint32_t table_index = read_u32(&pc);
- wasm_writef(stream, "%s $%u:%u, %%[-1]\n",
- wasm_get_interpreter_opcode_name(opcode), table_index,
+ wabt_writef(stream, "%s $%u:%u, %%[-1]\n",
+ wabt_get_interpreter_opcode_name(opcode), table_index,
read_u32(&pc));
break;
}
- case WASM_OPCODE_CALL_HOST:
- wasm_writef(stream, "%s $%u\n",
- wasm_get_interpreter_opcode_name(opcode), read_u32(&pc));
- break;
-
- case WASM_OPCODE_I32_LOAD8_S:
- case WASM_OPCODE_I32_LOAD8_U:
- case WASM_OPCODE_I32_LOAD16_S:
- case WASM_OPCODE_I32_LOAD16_U:
- case WASM_OPCODE_I64_LOAD8_S:
- case WASM_OPCODE_I64_LOAD8_U:
- case WASM_OPCODE_I64_LOAD16_S:
- case WASM_OPCODE_I64_LOAD16_U:
- case WASM_OPCODE_I64_LOAD32_S:
- case WASM_OPCODE_I64_LOAD32_U:
- case WASM_OPCODE_I32_LOAD:
- case WASM_OPCODE_I64_LOAD:
- case WASM_OPCODE_F32_LOAD:
- case WASM_OPCODE_F64_LOAD: {
+ case WABT_OPCODE_CALL_HOST:
+ wabt_writef(stream, "%s $%u\n",
+ wabt_get_interpreter_opcode_name(opcode), read_u32(&pc));
+ break;
+
+ case WABT_OPCODE_I32_LOAD8_S:
+ case WABT_OPCODE_I32_LOAD8_U:
+ case WABT_OPCODE_I32_LOAD16_S:
+ case WABT_OPCODE_I32_LOAD16_U:
+ case WABT_OPCODE_I64_LOAD8_S:
+ case WABT_OPCODE_I64_LOAD8_U:
+ case WABT_OPCODE_I64_LOAD16_S:
+ case WABT_OPCODE_I64_LOAD16_U:
+ case WABT_OPCODE_I64_LOAD32_S:
+ case WABT_OPCODE_I64_LOAD32_U:
+ case WABT_OPCODE_I32_LOAD:
+ case WABT_OPCODE_I64_LOAD:
+ case WABT_OPCODE_F32_LOAD:
+ case WABT_OPCODE_F64_LOAD: {
uint32_t memory_index = read_u32(&pc);
- wasm_writef(stream, "%s $%u:%%[-1]+$%u\n",
- wasm_get_interpreter_opcode_name(opcode), memory_index,
+ wabt_writef(stream, "%s $%u:%%[-1]+$%u\n",
+ wabt_get_interpreter_opcode_name(opcode), memory_index,
read_u32(&pc));
break;
}
- case WASM_OPCODE_I32_STORE8:
- case WASM_OPCODE_I32_STORE16:
- case WASM_OPCODE_I32_STORE:
- case WASM_OPCODE_I64_STORE8:
- case WASM_OPCODE_I64_STORE16:
- case WASM_OPCODE_I64_STORE32:
- case WASM_OPCODE_I64_STORE:
- case WASM_OPCODE_F32_STORE:
- case WASM_OPCODE_F64_STORE: {
+ case WABT_OPCODE_I32_STORE8:
+ case WABT_OPCODE_I32_STORE16:
+ case WABT_OPCODE_I32_STORE:
+ case WABT_OPCODE_I64_STORE8:
+ case WABT_OPCODE_I64_STORE16:
+ case WABT_OPCODE_I64_STORE32:
+ case WABT_OPCODE_I64_STORE:
+ case WABT_OPCODE_F32_STORE:
+ case WABT_OPCODE_F64_STORE: {
uint32_t memory_index = read_u32(&pc);
- wasm_writef(stream, "%s %%[-2]+$%u, $%u:%%[-1]\n",
- wasm_get_interpreter_opcode_name(opcode), memory_index,
+ wabt_writef(stream, "%s %%[-2]+$%u, $%u:%%[-1]\n",
+ wabt_get_interpreter_opcode_name(opcode), memory_index,
read_u32(&pc));
break;
}
- case WASM_OPCODE_I32_ADD:
- case WASM_OPCODE_I32_SUB:
- case WASM_OPCODE_I32_MUL:
- case WASM_OPCODE_I32_DIV_S:
- case WASM_OPCODE_I32_DIV_U:
- case WASM_OPCODE_I32_REM_S:
- case WASM_OPCODE_I32_REM_U:
- case WASM_OPCODE_I32_AND:
- case WASM_OPCODE_I32_OR:
- case WASM_OPCODE_I32_XOR:
- case WASM_OPCODE_I32_SHL:
- case WASM_OPCODE_I32_SHR_U:
- case WASM_OPCODE_I32_SHR_S:
- case WASM_OPCODE_I32_EQ:
- case WASM_OPCODE_I32_NE:
- case WASM_OPCODE_I32_LT_S:
- case WASM_OPCODE_I32_LE_S:
- case WASM_OPCODE_I32_LT_U:
- case WASM_OPCODE_I32_LE_U:
- case WASM_OPCODE_I32_GT_S:
- case WASM_OPCODE_I32_GE_S:
- case WASM_OPCODE_I32_GT_U:
- case WASM_OPCODE_I32_GE_U:
- case WASM_OPCODE_I32_ROTR:
- case WASM_OPCODE_I32_ROTL:
- case WASM_OPCODE_F32_ADD:
- case WASM_OPCODE_F32_SUB:
- case WASM_OPCODE_F32_MUL:
- case WASM_OPCODE_F32_DIV:
- case WASM_OPCODE_F32_MIN:
- case WASM_OPCODE_F32_MAX:
- case WASM_OPCODE_F32_COPYSIGN:
- case WASM_OPCODE_F32_EQ:
- case WASM_OPCODE_F32_NE:
- case WASM_OPCODE_F32_LT:
- case WASM_OPCODE_F32_LE:
- case WASM_OPCODE_F32_GT:
- case WASM_OPCODE_F32_GE:
- case WASM_OPCODE_I64_ADD:
- case WASM_OPCODE_I64_SUB:
- case WASM_OPCODE_I64_MUL:
- case WASM_OPCODE_I64_DIV_S:
- case WASM_OPCODE_I64_DIV_U:
- case WASM_OPCODE_I64_REM_S:
- case WASM_OPCODE_I64_REM_U:
- case WASM_OPCODE_I64_AND:
- case WASM_OPCODE_I64_OR:
- case WASM_OPCODE_I64_XOR:
- case WASM_OPCODE_I64_SHL:
- case WASM_OPCODE_I64_SHR_U:
- case WASM_OPCODE_I64_SHR_S:
- case WASM_OPCODE_I64_EQ:
- case WASM_OPCODE_I64_NE:
- case WASM_OPCODE_I64_LT_S:
- case WASM_OPCODE_I64_LE_S:
- case WASM_OPCODE_I64_LT_U:
- case WASM_OPCODE_I64_LE_U:
- case WASM_OPCODE_I64_GT_S:
- case WASM_OPCODE_I64_GE_S:
- case WASM_OPCODE_I64_GT_U:
- case WASM_OPCODE_I64_GE_U:
- case WASM_OPCODE_I64_ROTR:
- case WASM_OPCODE_I64_ROTL:
- case WASM_OPCODE_F64_ADD:
- case WASM_OPCODE_F64_SUB:
- case WASM_OPCODE_F64_MUL:
- case WASM_OPCODE_F64_DIV:
- case WASM_OPCODE_F64_MIN:
- case WASM_OPCODE_F64_MAX:
- case WASM_OPCODE_F64_COPYSIGN:
- case WASM_OPCODE_F64_EQ:
- case WASM_OPCODE_F64_NE:
- case WASM_OPCODE_F64_LT:
- case WASM_OPCODE_F64_LE:
- case WASM_OPCODE_F64_GT:
- case WASM_OPCODE_F64_GE:
- wasm_writef(stream, "%s %%[-2], %%[-1]\n",
- wasm_get_interpreter_opcode_name(opcode));
- break;
-
- case WASM_OPCODE_I32_CLZ:
- case WASM_OPCODE_I32_CTZ:
- case WASM_OPCODE_I32_POPCNT:
- case WASM_OPCODE_I32_EQZ:
- case WASM_OPCODE_I64_CLZ:
- case WASM_OPCODE_I64_CTZ:
- case WASM_OPCODE_I64_POPCNT:
- case WASM_OPCODE_I64_EQZ:
- case WASM_OPCODE_F32_ABS:
- case WASM_OPCODE_F32_NEG:
- case WASM_OPCODE_F32_CEIL:
- case WASM_OPCODE_F32_FLOOR:
- case WASM_OPCODE_F32_TRUNC:
- case WASM_OPCODE_F32_NEAREST:
- case WASM_OPCODE_F32_SQRT:
- case WASM_OPCODE_F64_ABS:
- case WASM_OPCODE_F64_NEG:
- case WASM_OPCODE_F64_CEIL:
- case WASM_OPCODE_F64_FLOOR:
- case WASM_OPCODE_F64_TRUNC:
- case WASM_OPCODE_F64_NEAREST:
- case WASM_OPCODE_F64_SQRT:
- case WASM_OPCODE_I32_TRUNC_S_F32:
- case WASM_OPCODE_I32_TRUNC_U_F32:
- case WASM_OPCODE_I64_TRUNC_S_F32:
- case WASM_OPCODE_I64_TRUNC_U_F32:
- case WASM_OPCODE_F64_PROMOTE_F32:
- case WASM_OPCODE_I32_REINTERPRET_F32:
- case WASM_OPCODE_I32_TRUNC_S_F64:
- case WASM_OPCODE_I32_TRUNC_U_F64:
- case WASM_OPCODE_I64_TRUNC_S_F64:
- case WASM_OPCODE_I64_TRUNC_U_F64:
- case WASM_OPCODE_F32_DEMOTE_F64:
- case WASM_OPCODE_I64_REINTERPRET_F64:
- case WASM_OPCODE_I32_WRAP_I64:
- case WASM_OPCODE_F32_CONVERT_S_I64:
- case WASM_OPCODE_F32_CONVERT_U_I64:
- case WASM_OPCODE_F64_CONVERT_S_I64:
- case WASM_OPCODE_F64_CONVERT_U_I64:
- case WASM_OPCODE_F64_REINTERPRET_I64:
- case WASM_OPCODE_I64_EXTEND_S_I32:
- case WASM_OPCODE_I64_EXTEND_U_I32:
- case WASM_OPCODE_F32_CONVERT_S_I32:
- case WASM_OPCODE_F32_CONVERT_U_I32:
- case WASM_OPCODE_F32_REINTERPRET_I32:
- case WASM_OPCODE_F64_CONVERT_S_I32:
- case WASM_OPCODE_F64_CONVERT_U_I32:
- wasm_writef(stream, "%s %%[-1]\n",
- wasm_get_interpreter_opcode_name(opcode));
- break;
-
- case WASM_OPCODE_GROW_MEMORY: {
+ case WABT_OPCODE_I32_ADD:
+ case WABT_OPCODE_I32_SUB:
+ case WABT_OPCODE_I32_MUL:
+ case WABT_OPCODE_I32_DIV_S:
+ case WABT_OPCODE_I32_DIV_U:
+ case WABT_OPCODE_I32_REM_S:
+ case WABT_OPCODE_I32_REM_U:
+ case WABT_OPCODE_I32_AND:
+ case WABT_OPCODE_I32_OR:
+ case WABT_OPCODE_I32_XOR:
+ case WABT_OPCODE_I32_SHL:
+ case WABT_OPCODE_I32_SHR_U:
+ case WABT_OPCODE_I32_SHR_S:
+ case WABT_OPCODE_I32_EQ:
+ case WABT_OPCODE_I32_NE:
+ case WABT_OPCODE_I32_LT_S:
+ case WABT_OPCODE_I32_LE_S:
+ case WABT_OPCODE_I32_LT_U:
+ case WABT_OPCODE_I32_LE_U:
+ case WABT_OPCODE_I32_GT_S:
+ case WABT_OPCODE_I32_GE_S:
+ case WABT_OPCODE_I32_GT_U:
+ case WABT_OPCODE_I32_GE_U:
+ case WABT_OPCODE_I32_ROTR:
+ case WABT_OPCODE_I32_ROTL:
+ case WABT_OPCODE_F32_ADD:
+ case WABT_OPCODE_F32_SUB:
+ case WABT_OPCODE_F32_MUL:
+ case WABT_OPCODE_F32_DIV:
+ case WABT_OPCODE_F32_MIN:
+ case WABT_OPCODE_F32_MAX:
+ case WABT_OPCODE_F32_COPYSIGN:
+ case WABT_OPCODE_F32_EQ:
+ case WABT_OPCODE_F32_NE:
+ case WABT_OPCODE_F32_LT:
+ case WABT_OPCODE_F32_LE:
+ case WABT_OPCODE_F32_GT:
+ case WABT_OPCODE_F32_GE:
+ case WABT_OPCODE_I64_ADD:
+ case WABT_OPCODE_I64_SUB:
+ case WABT_OPCODE_I64_MUL:
+ case WABT_OPCODE_I64_DIV_S:
+ case WABT_OPCODE_I64_DIV_U:
+ case WABT_OPCODE_I64_REM_S:
+ case WABT_OPCODE_I64_REM_U:
+ case WABT_OPCODE_I64_AND:
+ case WABT_OPCODE_I64_OR:
+ case WABT_OPCODE_I64_XOR:
+ case WABT_OPCODE_I64_SHL:
+ case WABT_OPCODE_I64_SHR_U:
+ case WABT_OPCODE_I64_SHR_S:
+ case WABT_OPCODE_I64_EQ:
+ case WABT_OPCODE_I64_NE:
+ case WABT_OPCODE_I64_LT_S:
+ case WABT_OPCODE_I64_LE_S:
+ case WABT_OPCODE_I64_LT_U:
+ case WABT_OPCODE_I64_LE_U:
+ case WABT_OPCODE_I64_GT_S:
+ case WABT_OPCODE_I64_GE_S:
+ case WABT_OPCODE_I64_GT_U:
+ case WABT_OPCODE_I64_GE_U:
+ case WABT_OPCODE_I64_ROTR:
+ case WABT_OPCODE_I64_ROTL:
+ case WABT_OPCODE_F64_ADD:
+ case WABT_OPCODE_F64_SUB:
+ case WABT_OPCODE_F64_MUL:
+ case WABT_OPCODE_F64_DIV:
+ case WABT_OPCODE_F64_MIN:
+ case WABT_OPCODE_F64_MAX:
+ case WABT_OPCODE_F64_COPYSIGN:
+ case WABT_OPCODE_F64_EQ:
+ case WABT_OPCODE_F64_NE:
+ case WABT_OPCODE_F64_LT:
+ case WABT_OPCODE_F64_LE:
+ case WABT_OPCODE_F64_GT:
+ case WABT_OPCODE_F64_GE:
+ wabt_writef(stream, "%s %%[-2], %%[-1]\n",
+ wabt_get_interpreter_opcode_name(opcode));
+ break;
+
+ case WABT_OPCODE_I32_CLZ:
+ case WABT_OPCODE_I32_CTZ:
+ case WABT_OPCODE_I32_POPCNT:
+ case WABT_OPCODE_I32_EQZ:
+ case WABT_OPCODE_I64_CLZ:
+ case WABT_OPCODE_I64_CTZ:
+ case WABT_OPCODE_I64_POPCNT:
+ case WABT_OPCODE_I64_EQZ:
+ case WABT_OPCODE_F32_ABS:
+ case WABT_OPCODE_F32_NEG:
+ case WABT_OPCODE_F32_CEIL:
+ case WABT_OPCODE_F32_FLOOR:
+ case WABT_OPCODE_F32_TRUNC:
+ case WABT_OPCODE_F32_NEAREST:
+ case WABT_OPCODE_F32_SQRT:
+ case WABT_OPCODE_F64_ABS:
+ case WABT_OPCODE_F64_NEG:
+ case WABT_OPCODE_F64_CEIL:
+ case WABT_OPCODE_F64_FLOOR:
+ case WABT_OPCODE_F64_TRUNC:
+ case WABT_OPCODE_F64_NEAREST:
+ case WABT_OPCODE_F64_SQRT:
+ case WABT_OPCODE_I32_TRUNC_S_F32:
+ case WABT_OPCODE_I32_TRUNC_U_F32:
+ case WABT_OPCODE_I64_TRUNC_S_F32:
+ case WABT_OPCODE_I64_TRUNC_U_F32:
+ case WABT_OPCODE_F64_PROMOTE_F32:
+ case WABT_OPCODE_I32_REINTERPRET_F32:
+ case WABT_OPCODE_I32_TRUNC_S_F64:
+ case WABT_OPCODE_I32_TRUNC_U_F64:
+ case WABT_OPCODE_I64_TRUNC_S_F64:
+ case WABT_OPCODE_I64_TRUNC_U_F64:
+ case WABT_OPCODE_F32_DEMOTE_F64:
+ case WABT_OPCODE_I64_REINTERPRET_F64:
+ case WABT_OPCODE_I32_WRAP_I64:
+ case WABT_OPCODE_F32_CONVERT_S_I64:
+ case WABT_OPCODE_F32_CONVERT_U_I64:
+ case WABT_OPCODE_F64_CONVERT_S_I64:
+ case WABT_OPCODE_F64_CONVERT_U_I64:
+ case WABT_OPCODE_F64_REINTERPRET_I64:
+ case WABT_OPCODE_I64_EXTEND_S_I32:
+ case WABT_OPCODE_I64_EXTEND_U_I32:
+ case WABT_OPCODE_F32_CONVERT_S_I32:
+ case WABT_OPCODE_F32_CONVERT_U_I32:
+ case WABT_OPCODE_F32_REINTERPRET_I32:
+ case WABT_OPCODE_F64_CONVERT_S_I32:
+ case WABT_OPCODE_F64_CONVERT_U_I32:
+ wabt_writef(stream, "%s %%[-1]\n",
+ wabt_get_interpreter_opcode_name(opcode));
+ break;
+
+ case WABT_OPCODE_GROW_MEMORY: {
uint32_t memory_index = read_u32(&pc);
- wasm_writef(stream, "%s $%u:%%[-1]\n",
- wasm_get_interpreter_opcode_name(opcode), memory_index);
+ wabt_writef(stream, "%s $%u:%%[-1]\n",
+ wabt_get_interpreter_opcode_name(opcode), memory_index);
break;
}
- case WASM_OPCODE_ALLOCA:
- wasm_writef(stream, "%s $%u\n",
- wasm_get_interpreter_opcode_name(opcode), read_u32(&pc));
+ case WABT_OPCODE_ALLOCA:
+ wabt_writef(stream, "%s $%u\n",
+ wabt_get_interpreter_opcode_name(opcode), read_u32(&pc));
break;
- case WASM_OPCODE_BR_UNLESS:
- wasm_writef(stream, "%s @%u, %%[-1]\n",
- wasm_get_interpreter_opcode_name(opcode), read_u32(&pc));
+ case WABT_OPCODE_BR_UNLESS:
+ wabt_writef(stream, "%s @%u, %%[-1]\n",
+ wabt_get_interpreter_opcode_name(opcode), read_u32(&pc));
break;
- case WASM_OPCODE_DROP_KEEP: {
+ case WABT_OPCODE_DROP_KEEP: {
uint32_t drop = read_u32(&pc);
uint32_t keep = *pc++;
- wasm_writef(stream, "%s $%u $%u\n",
- wasm_get_interpreter_opcode_name(opcode), drop, keep);
+ wabt_writef(stream, "%s $%u $%u\n",
+ wabt_get_interpreter_opcode_name(opcode), drop, keep);
break;
}
- case WASM_OPCODE_DATA: {
+ case WABT_OPCODE_DATA: {
uint32_t num_bytes = read_u32(&pc);
- wasm_writef(stream, "%s $%u\n",
- wasm_get_interpreter_opcode_name(opcode), num_bytes);
+ wabt_writef(stream, "%s $%u\n",
+ wabt_get_interpreter_opcode_name(opcode), num_bytes);
/* for now, the only reason this is emitted is for br_table, so display
* it as a list of table entries */
- if (num_bytes % WASM_TABLE_ENTRY_SIZE == 0) {
- uint32_t num_entries = num_bytes / WASM_TABLE_ENTRY_SIZE;
+ if (num_bytes % WABT_TABLE_ENTRY_SIZE == 0) {
+ uint32_t num_entries = num_bytes / WABT_TABLE_ENTRY_SIZE;
uint32_t i;
for (i = 0; i < num_entries; ++i) {
- wasm_writef(stream, "%4" PRIzd "| ", pc - istream);
+ wabt_writef(stream, "%4" PRIzd "| ", pc - istream);
uint32_t offset;
uint32_t drop;
uint8_t keep;
read_table_entry_at(pc, &offset, &drop, &keep);
- wasm_writef(stream, " entry %d: offset: %u drop: %u keep: %u\n", i,
+ wabt_writef(stream, " entry %d: offset: %u drop: %u keep: %u\n", i,
offset, drop, keep);
- pc += WASM_TABLE_ENTRY_SIZE;
+ pc += WABT_TABLE_ENTRY_SIZE;
}
} else {
/* just skip those data bytes */
@@ -2406,11 +2406,11 @@ void wasm_disassemble(WasmInterpreterEnvironment* env,
}
}
-void wasm_disassemble_module(WasmInterpreterEnvironment* env,
- WasmStream* stream,
- WasmInterpreterModule* module) {
+void wabt_disassemble_module(WabtInterpreterEnvironment* env,
+ WabtStream* stream,
+ WabtInterpreterModule* module) {
assert(!module->is_host);
- wasm_disassemble(env, stream, module->defined.istream_start,
+ wabt_disassemble(env, stream, module->defined.istream_start,
module->defined.istream_end);
}
diff --git a/src/interpreter.h b/src/interpreter.h
index 6db10fc9..0c0dde2a 100644
--- a/src/interpreter.h
+++ b/src/interpreter.h
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#ifndef WASM_INTERPRETER_H_
-#define WASM_INTERPRETER_H_
+#ifndef WABT_INTERPRETER_H_
+#define WABT_INTERPRETER_H_
#include <stdint.h>
@@ -25,7 +25,7 @@
#include "vector.h"
#include "writer.h"
-struct WasmStream;
+struct WabtStream;
#define FOREACH_INTERPRETER_RESULT(V) \
V(OK, "ok") \
@@ -64,181 +64,181 @@ struct WasmStream;
/* the expected export kind doesn't match. */ \
V(EXPORT_KIND_MISMATCH, "export kind mismatch")
-typedef enum WasmInterpreterResult {
-#define V(name, str) WASM_INTERPRETER_##name,
+typedef enum WabtInterpreterResult {
+#define V(name, str) WABT_INTERPRETER_##name,
FOREACH_INTERPRETER_RESULT(V)
#undef V
-} WasmInterpreterResult;
+} WabtInterpreterResult;
-#define WASM_INVALID_INDEX ((uint32_t)~0)
-#define WASM_INVALID_OFFSET ((uint32_t)~0)
-#define WASM_TABLE_ENTRY_SIZE (sizeof(uint32_t) * 2 + sizeof(uint8_t))
-#define WASM_TABLE_ENTRY_OFFSET_OFFSET 0
-#define WASM_TABLE_ENTRY_DROP_OFFSET sizeof(uint32_t)
-#define WASM_TABLE_ENTRY_KEEP_OFFSET (sizeof(uint32_t) * 2)
+#define WABT_INVALID_INDEX ((uint32_t)~0)
+#define WABT_INVALID_OFFSET ((uint32_t)~0)
+#define WABT_TABLE_ENTRY_SIZE (sizeof(uint32_t) * 2 + sizeof(uint8_t))
+#define WABT_TABLE_ENTRY_OFFSET_OFFSET 0
+#define WABT_TABLE_ENTRY_DROP_OFFSET sizeof(uint32_t)
+#define WABT_TABLE_ENTRY_KEEP_OFFSET (sizeof(uint32_t) * 2)
enum {
/* push space on the value stack for N entries */
- WASM_OPCODE_ALLOCA = WASM_NUM_OPCODES,
- WASM_OPCODE_BR_UNLESS,
- WASM_OPCODE_CALL_HOST,
- WASM_OPCODE_DATA,
- WASM_OPCODE_DROP_KEEP,
- WASM_NUM_INTERPRETER_OPCODES,
+ WABT_OPCODE_ALLOCA = WABT_NUM_OPCODES,
+ WABT_OPCODE_BR_UNLESS,
+ WABT_OPCODE_CALL_HOST,
+ WABT_OPCODE_DATA,
+ WABT_OPCODE_DROP_KEEP,
+ WABT_NUM_INTERPRETER_OPCODES,
};
-WASM_STATIC_ASSERT(WASM_NUM_INTERPRETER_OPCODES <= 256);
-
-typedef uint32_t WasmUint32;
-WASM_DEFINE_ARRAY(uint32, WasmUint32);
-
-/* TODO(binji): identical to WasmFuncSignature. Share? */
-typedef struct WasmInterpreterFuncSignature {
- WasmTypeVector param_types;
- WasmTypeVector result_types;
-} WasmInterpreterFuncSignature;
-WASM_DEFINE_VECTOR(interpreter_func_signature, WasmInterpreterFuncSignature);
-
-typedef struct WasmInterpreterTable {
- WasmLimits limits;
- WasmUint32Array func_indexes;
-} WasmInterpreterTable;
-WASM_DEFINE_VECTOR(interpreter_table, WasmInterpreterTable);
-
-typedef struct WasmInterpreterMemory {
- WasmAllocator* allocator;
+WABT_STATIC_ASSERT(WABT_NUM_INTERPRETER_OPCODES <= 256);
+
+typedef uint32_t WabtUint32;
+WABT_DEFINE_ARRAY(uint32, WabtUint32);
+
+/* TODO(binji): identical to WabtFuncSignature. Share? */
+typedef struct WabtInterpreterFuncSignature {
+ WabtTypeVector param_types;
+ WabtTypeVector result_types;
+} WabtInterpreterFuncSignature;
+WABT_DEFINE_VECTOR(interpreter_func_signature, WabtInterpreterFuncSignature);
+
+typedef struct WabtInterpreterTable {
+ WabtLimits limits;
+ WabtUint32Array func_indexes;
+} WabtInterpreterTable;
+WABT_DEFINE_VECTOR(interpreter_table, WabtInterpreterTable);
+
+typedef struct WabtInterpreterMemory {
+ WabtAllocator* allocator;
void* data;
- WasmLimits page_limits;
+ WabtLimits page_limits;
uint32_t byte_size; /* Cached from page_limits. */
-} WasmInterpreterMemory;
-WASM_DEFINE_VECTOR(interpreter_memory, WasmInterpreterMemory);
+} WabtInterpreterMemory;
+WABT_DEFINE_VECTOR(interpreter_memory, WabtInterpreterMemory);
-typedef union WasmInterpreterValue {
+typedef union WabtInterpreterValue {
uint32_t i32;
uint64_t i64;
uint32_t f32_bits;
uint64_t f64_bits;
-} WasmInterpreterValue;
-WASM_DEFINE_ARRAY(interpreter_value, WasmInterpreterValue);
-
-typedef struct WasmInterpreterTypedValue {
- WasmType type;
- WasmInterpreterValue value;
-} WasmInterpreterTypedValue;
-WASM_DEFINE_VECTOR(interpreter_typed_value, WasmInterpreterTypedValue);
-
-typedef struct WasmInterpreterGlobal {
- WasmInterpreterTypedValue typed_value;
- WasmBool mutable_;
+} WabtInterpreterValue;
+WABT_DEFINE_ARRAY(interpreter_value, WabtInterpreterValue);
+
+typedef struct WabtInterpreterTypedValue {
+ WabtType type;
+ WabtInterpreterValue value;
+} WabtInterpreterTypedValue;
+WABT_DEFINE_VECTOR(interpreter_typed_value, WabtInterpreterTypedValue);
+
+typedef struct WabtInterpreterGlobal {
+ WabtInterpreterTypedValue typed_value;
+ WabtBool mutable_;
uint32_t import_index; /* or INVALID_INDEX if not imported */
-} WasmInterpreterGlobal;
-WASM_DEFINE_VECTOR(interpreter_global, WasmInterpreterGlobal);
+} WabtInterpreterGlobal;
+WABT_DEFINE_VECTOR(interpreter_global, WabtInterpreterGlobal);
-typedef struct WasmInterpreterImport {
- WasmStringSlice module_name;
- WasmStringSlice field_name;
- WasmExternalKind kind;
+typedef struct WabtInterpreterImport {
+ WabtStringSlice module_name;
+ WabtStringSlice field_name;
+ WabtExternalKind kind;
union {
struct {
uint32_t sig_index;
} func;
struct {
- WasmLimits limits;
+ WabtLimits limits;
} table, memory;
struct {
- WasmType type;
- WasmBool mutable_;
+ WabtType type;
+ WabtBool mutable_;
} global;
};
-} WasmInterpreterImport;
-WASM_DEFINE_ARRAY(interpreter_import, WasmInterpreterImport);
+} WabtInterpreterImport;
+WABT_DEFINE_ARRAY(interpreter_import, WabtInterpreterImport);
-struct WasmInterpreterFunc;
+struct WabtInterpreterFunc;
-typedef WasmResult (*WasmInterpreterHostFuncCallback)(
- const struct WasmInterpreterFunc* func,
- const WasmInterpreterFuncSignature* sig,
+typedef WabtResult (*WabtInterpreterHostFuncCallback)(
+ const struct WabtInterpreterFunc* func,
+ const WabtInterpreterFuncSignature* sig,
uint32_t num_args,
- WasmInterpreterTypedValue* args,
+ WabtInterpreterTypedValue* args,
uint32_t num_results,
- WasmInterpreterTypedValue* out_results,
+ WabtInterpreterTypedValue* out_results,
void* user_data);
-typedef struct WasmInterpreterFunc {
+typedef struct WabtInterpreterFunc {
uint32_t sig_index;
- WasmBool is_host;
+ WabtBool is_host;
union {
struct {
uint32_t offset;
uint32_t local_decl_count;
uint32_t local_count;
- WasmTypeVector param_and_local_types;
+ WabtTypeVector param_and_local_types;
} defined;
struct {
- WasmStringSlice module_name;
- WasmStringSlice field_name;
- WasmInterpreterHostFuncCallback callback;
+ WabtStringSlice module_name;
+ WabtStringSlice field_name;
+ WabtInterpreterHostFuncCallback callback;
void* user_data;
} host;
};
-} WasmInterpreterFunc;
-WASM_DEFINE_VECTOR(interpreter_func, WasmInterpreterFunc);
+} WabtInterpreterFunc;
+WABT_DEFINE_VECTOR(interpreter_func, WabtInterpreterFunc);
-typedef struct WasmInterpreterExport {
- WasmStringSlice name; /* Owned by the export_bindings hash */
- WasmExternalKind kind;
+typedef struct WabtInterpreterExport {
+ WabtStringSlice name; /* Owned by the export_bindings hash */
+ WabtExternalKind kind;
uint32_t index;
-} WasmInterpreterExport;
-WASM_DEFINE_VECTOR(interpreter_export, WasmInterpreterExport);
+} WabtInterpreterExport;
+WABT_DEFINE_VECTOR(interpreter_export, WabtInterpreterExport);
-typedef struct WasmPrintErrorCallback {
+typedef struct WabtPrintErrorCallback {
void* user_data;
void (*print_error)(const char* msg, void* user_data);
-} WasmPrintErrorCallback;
+} WabtPrintErrorCallback;
-typedef struct WasmInterpreterHostImportDelegate {
+typedef struct WabtInterpreterHostImportDelegate {
void *user_data;
- WasmResult (*import_func)(WasmInterpreterImport*,
- WasmInterpreterFunc*,
- WasmInterpreterFuncSignature*,
- WasmPrintErrorCallback,
+ WabtResult (*import_func)(WabtInterpreterImport*,
+ WabtInterpreterFunc*,
+ WabtInterpreterFuncSignature*,
+ WabtPrintErrorCallback,
void* user_data);
- WasmResult (*import_table)(WasmInterpreterImport*,
- WasmInterpreterTable*,
- WasmPrintErrorCallback,
+ WabtResult (*import_table)(WabtInterpreterImport*,
+ WabtInterpreterTable*,
+ WabtPrintErrorCallback,
void* user_data);
- WasmResult (*import_memory)(WasmInterpreterImport*,
- WasmInterpreterMemory*,
- WasmPrintErrorCallback,
+ WabtResult (*import_memory)(WabtInterpreterImport*,
+ WabtInterpreterMemory*,
+ WabtPrintErrorCallback,
void* user_data);
- WasmResult (*import_global)(WasmInterpreterImport*,
- WasmInterpreterGlobal*,
- WasmPrintErrorCallback,
+ WabtResult (*import_global)(WabtInterpreterImport*,
+ WabtInterpreterGlobal*,
+ WabtPrintErrorCallback,
void* user_data);
-} WasmInterpreterHostImportDelegate;
+} WabtInterpreterHostImportDelegate;
-typedef struct WasmInterpreterModule {
- WasmStringSlice name;
- WasmInterpreterExportVector exports;
- WasmBindingHash export_bindings;
+typedef struct WabtInterpreterModule {
+ WabtStringSlice name;
+ WabtInterpreterExportVector exports;
+ WabtBindingHash export_bindings;
uint32_t memory_index; /* INVALID_INDEX if not defined */
uint32_t table_index; /* INVALID_INDEX if not defined */
- WasmBool is_host;
+ WabtBool is_host;
union {
struct {
- WasmInterpreterImportArray imports;
+ WabtInterpreterImportArray imports;
uint32_t start_func_index; /* INVALID_INDEX if not defined */
size_t istream_start;
size_t istream_end;
} defined;
struct {
- WasmInterpreterHostImportDelegate import_delegate;
+ WabtInterpreterHostImportDelegate import_delegate;
} host;
};
-} WasmInterpreterModule;
-WASM_DEFINE_VECTOR(interpreter_module, WasmInterpreterModule);
+} WabtInterpreterModule;
+WABT_DEFINE_VECTOR(interpreter_module, WabtInterpreterModule);
/* Used to track and reset the state of the environment. */
-typedef struct WasmInterpreterEnvironmentMark {
+typedef struct WabtInterpreterEnvironmentMark {
size_t modules_size;
size_t sigs_size;
size_t funcs_size;
@@ -246,89 +246,89 @@ typedef struct WasmInterpreterEnvironmentMark {
size_t tables_size;
size_t globals_size;
size_t istream_size;
-} WasmInterpreterEnvironmentMark;
-
-typedef struct WasmInterpreterEnvironment {
- WasmInterpreterModuleVector modules;
- WasmInterpreterFuncSignatureVector sigs;
- WasmInterpreterFuncVector funcs;
- WasmInterpreterMemoryVector memories;
- WasmInterpreterTableVector tables;
- WasmInterpreterGlobalVector globals;
- WasmOutputBuffer istream;
- WasmBindingHash module_bindings;
- WasmBindingHash registered_module_bindings;
-} WasmInterpreterEnvironment;
-
-typedef struct WasmInterpreterThread {
- WasmAllocator* allocator;
- WasmInterpreterEnvironment* env;
- WasmInterpreterValueArray value_stack;
- WasmUint32Array call_stack;
- WasmInterpreterValue* value_stack_top;
- WasmInterpreterValue* value_stack_end;
+} WabtInterpreterEnvironmentMark;
+
+typedef struct WabtInterpreterEnvironment {
+ WabtInterpreterModuleVector modules;
+ WabtInterpreterFuncSignatureVector sigs;
+ WabtInterpreterFuncVector funcs;
+ WabtInterpreterMemoryVector memories;
+ WabtInterpreterTableVector tables;
+ WabtInterpreterGlobalVector globals;
+ WabtOutputBuffer istream;
+ WabtBindingHash module_bindings;
+ WabtBindingHash registered_module_bindings;
+} WabtInterpreterEnvironment;
+
+typedef struct WabtInterpreterThread {
+ WabtAllocator* allocator;
+ WabtInterpreterEnvironment* env;
+ WabtInterpreterValueArray value_stack;
+ WabtUint32Array call_stack;
+ WabtInterpreterValue* value_stack_top;
+ WabtInterpreterValue* value_stack_end;
uint32_t* call_stack_top;
uint32_t* call_stack_end;
uint32_t pc;
/* a temporary buffer that is for passing args to host functions */
- WasmInterpreterTypedValueVector host_args;
-} WasmInterpreterThread;
+ WabtInterpreterTypedValueVector host_args;
+} WabtInterpreterThread;
-#define WASM_INTERPRETER_THREAD_OPTIONS_DEFAULT \
- { 512 * 1024 / sizeof(WasmInterpreterValue), 64 * 1024, WASM_INVALID_OFFSET }
+#define WABT_INTERPRETER_THREAD_OPTIONS_DEFAULT \
+ { 512 * 1024 / sizeof(WabtInterpreterValue), 64 * 1024, WABT_INVALID_OFFSET }
-typedef struct WasmInterpreterThreadOptions {
+typedef struct WabtInterpreterThreadOptions {
uint32_t value_stack_size;
uint32_t call_stack_size;
uint32_t pc;
-} WasmInterpreterThreadOptions;
+} WabtInterpreterThreadOptions;
-WASM_EXTERN_C_BEGIN
-WasmBool is_nan_f32(uint32_t f32_bits);
-WasmBool is_nan_f64(uint64_t f64_bits);
-WasmBool wasm_func_signatures_are_equal(WasmInterpreterEnvironment* env,
+WABT_EXTERN_C_BEGIN
+WabtBool wabt_is_nan_f32(uint32_t f32_bits);
+WabtBool wabt_is_nan_f64(uint64_t f64_bits);
+WabtBool wabt_func_signatures_are_equal(WabtInterpreterEnvironment* env,
uint32_t sig_index_0,
uint32_t sig_index_1);
-void wasm_init_interpreter_environment(WasmAllocator* allocator,
- WasmInterpreterEnvironment* env);
-void wasm_destroy_interpreter_environment(WasmAllocator* allocator,
- WasmInterpreterEnvironment* env);
-WasmInterpreterEnvironmentMark wasm_mark_interpreter_environment(
- WasmInterpreterEnvironment* env);
-void wasm_reset_interpreter_environment_to_mark(
- WasmAllocator* allocator,
- WasmInterpreterEnvironment* env,
- WasmInterpreterEnvironmentMark mark);
-WasmInterpreterModule* wasm_append_host_module(WasmAllocator* allocator,
- WasmInterpreterEnvironment* env,
- WasmStringSlice name);
-void wasm_init_interpreter_thread(WasmAllocator* allocator,
- WasmInterpreterEnvironment* env,
- WasmInterpreterThread* thread,
- WasmInterpreterThreadOptions* options);
-WasmInterpreterResult wasm_push_thread_value(WasmInterpreterThread* thread,
- WasmInterpreterValue value);
-void wasm_destroy_interpreter_thread(WasmAllocator* allocator,
- WasmInterpreterThread* thread);
-WasmInterpreterResult wasm_call_host(WasmInterpreterThread* thread,
- WasmInterpreterFunc* func);
-WasmInterpreterResult wasm_run_interpreter(WasmInterpreterThread* thread,
+void wabt_init_interpreter_environment(WabtAllocator* allocator,
+ WabtInterpreterEnvironment* env);
+void wabt_destroy_interpreter_environment(WabtAllocator* allocator,
+ WabtInterpreterEnvironment* env);
+WabtInterpreterEnvironmentMark wabt_mark_interpreter_environment(
+ WabtInterpreterEnvironment* env);
+void wabt_reset_interpreter_environment_to_mark(
+ WabtAllocator* allocator,
+ WabtInterpreterEnvironment* env,
+ WabtInterpreterEnvironmentMark mark);
+WabtInterpreterModule* wabt_append_host_module(WabtAllocator* allocator,
+ WabtInterpreterEnvironment* env,
+ WabtStringSlice name);
+void wabt_init_interpreter_thread(WabtAllocator* allocator,
+ WabtInterpreterEnvironment* env,
+ WabtInterpreterThread* thread,
+ WabtInterpreterThreadOptions* options);
+WabtInterpreterResult wabt_push_thread_value(WabtInterpreterThread* thread,
+ WabtInterpreterValue value);
+void wabt_destroy_interpreter_thread(WabtAllocator* allocator,
+ WabtInterpreterThread* thread);
+WabtInterpreterResult wabt_call_host(WabtInterpreterThread* thread,
+ WabtInterpreterFunc* func);
+WabtInterpreterResult wabt_run_interpreter(WabtInterpreterThread* thread,
uint32_t num_instructions,
uint32_t* call_stack_return_top);
-void wasm_trace_pc(WasmInterpreterThread* thread, struct WasmStream* stream);
-void wasm_disassemble(WasmInterpreterEnvironment* env,
- struct WasmStream* stream,
+void wabt_trace_pc(WabtInterpreterThread* thread, struct WabtStream* stream);
+void wabt_disassemble(WabtInterpreterEnvironment* env,
+ struct WabtStream* stream,
uint32_t from,
uint32_t to);
-void wasm_disassemble_module(WasmInterpreterEnvironment* env,
- struct WasmStream* stream,
- WasmInterpreterModule* module);
+void wabt_disassemble_module(WabtInterpreterEnvironment* env,
+ struct WabtStream* stream,
+ WabtInterpreterModule* module);
-WasmInterpreterExport* wasm_get_interpreter_export_by_name(
- WasmInterpreterModule* module,
- const WasmStringSlice* name);
-WASM_EXTERN_C_END
+WabtInterpreterExport* wabt_get_interpreter_export_by_name(
+ WabtInterpreterModule* module,
+ const WabtStringSlice* name);
+WABT_EXTERN_C_END
-#endif /* WASM_INTERPRETER_H_ */
+#endif /* WABT_INTERPRETER_H_ */
diff --git a/src/literal.c b/src/literal.c
index 04ae6ac3..c6967583 100644
--- a/src/literal.c
+++ b/src/literal.c
@@ -51,123 +51,123 @@
static const char s_hex_digits[] = "0123456789abcdef";
-WasmResult wasm_parse_hexdigit(char c, uint32_t* out) {
+WabtResult wabt_parse_hexdigit(char c, uint32_t* out) {
if ((unsigned int)(c - '0') <= 9) {
*out = c - '0';
- return WASM_OK;
+ return WABT_OK;
} else if ((unsigned int)(c - 'a') <= 6) {
*out = 10 + (c - 'a');
- return WASM_OK;
+ return WABT_OK;
} else if ((unsigned int)(c - 'A') <= 6) {
*out = 10 + (c - 'A');
- return WASM_OK;
+ return WABT_OK;
}
- return WASM_ERROR;
+ return WABT_ERROR;
}
/* return 1 if the non-NULL-terminated string starting with |start| and ending
with |end| starts with the NULL-terminated string |prefix|. */
-static WasmBool string_starts_with(const char* start,
+static WabtBool string_starts_with(const char* start,
const char* end,
const char* prefix) {
while (start < end && *prefix) {
if (*start != *prefix)
- return WASM_FALSE;
+ return WABT_FALSE;
start++;
prefix++;
}
return *prefix == 0;
}
-WasmResult wasm_parse_uint64(const char* s, const char* end, uint64_t* out) {
+WabtResult wabt_parse_uint64(const char* s, const char* end, uint64_t* out) {
if (s == end)
- return WASM_ERROR;
+ return WABT_ERROR;
uint64_t value = 0;
if (*s == '0' && s + 1 < end && s[1] == 'x') {
s += 2;
if (s == end)
- return WASM_ERROR;
+ return WABT_ERROR;
for (; s < end; ++s) {
uint32_t digit;
- if (WASM_FAILED(wasm_parse_hexdigit(*s, &digit)))
- return WASM_ERROR;
+ if (WABT_FAILED(wabt_parse_hexdigit(*s, &digit)))
+ return WABT_ERROR;
uint64_t old_value = value;
value = value * 16 + digit;
/* check for overflow */
if (old_value > value)
- return WASM_ERROR;
+ return WABT_ERROR;
}
} else {
for (; s < end; ++s) {
uint32_t digit = (*s - '0');
if (digit > 9)
- return WASM_ERROR;
+ return WABT_ERROR;
uint64_t old_value = value;
value = value * 10 + digit;
/* check for overflow */
if (old_value > value)
- return WASM_ERROR;
+ return WABT_ERROR;
}
}
if (s != end)
- return WASM_ERROR;
+ return WABT_ERROR;
*out = value;
- return WASM_OK;
+ return WABT_OK;
}
-WasmResult wasm_parse_int64(const char* s,
+WabtResult wabt_parse_int64(const char* s,
const char* end,
uint64_t* out,
- WasmParseIntType parse_type) {
- WasmBool has_sign = WASM_FALSE;
+ WabtParseIntType parse_type) {
+ WabtBool has_sign = WABT_FALSE;
if (*s == '-' || *s == '+') {
- if (parse_type == WASM_PARSE_UNSIGNED_ONLY)
- return WASM_ERROR;
+ if (parse_type == WABT_PARSE_UNSIGNED_ONLY)
+ return WABT_ERROR;
if (*s == '-')
- has_sign = WASM_TRUE;
+ has_sign = WABT_TRUE;
s++;
}
uint64_t value = 0;
- WasmResult result = wasm_parse_uint64(s, end, &value);
+ WabtResult result = wabt_parse_uint64(s, end, &value);
if (has_sign) {
if (value > (uint64_t)INT64_MAX + 1) /* abs(INT64_MIN) == INT64_MAX + 1 */
- return WASM_ERROR;
+ return WABT_ERROR;
value = UINT64_MAX - value + 1;
}
*out = value;
return result;
}
-WasmResult wasm_parse_int32(const char* s,
+WabtResult wabt_parse_int32(const char* s,
const char* end,
uint32_t* out,
- WasmParseIntType parse_type) {
+ WabtParseIntType parse_type) {
uint64_t value;
- WasmBool has_sign = WASM_FALSE;
+ WabtBool has_sign = WABT_FALSE;
if (*s == '-' || *s == '+') {
- if (parse_type == WASM_PARSE_UNSIGNED_ONLY)
- return WASM_ERROR;
+ if (parse_type == WABT_PARSE_UNSIGNED_ONLY)
+ return WABT_ERROR;
if (*s == '-')
- has_sign = WASM_TRUE;
+ has_sign = WABT_TRUE;
s++;
}
- if (WASM_FAILED(wasm_parse_uint64(s, end, &value)))
- return WASM_ERROR;
+ if (WABT_FAILED(wabt_parse_uint64(s, end, &value)))
+ return WABT_ERROR;
if (has_sign) {
if (value > (uint64_t)INT32_MAX + 1) /* abs(INT32_MIN) == INT32_MAX + 1 */
- return WASM_ERROR;
+ return WABT_ERROR;
value = UINT32_MAX - value + 1;
} else {
if (value > (uint64_t)UINT32_MAX)
- return WASM_ERROR;
+ return WABT_ERROR;
}
*out = (uint32_t)value;
- return WASM_OK;
+ return WABT_OK;
}
/* floats */
-static uint32_t make_float(WasmBool sign, int exp, uint32_t sig) {
+static uint32_t make_float(WabtBool sign, int exp, uint32_t sig) {
assert(exp >= F32_MIN_EXP && exp <= F32_MAX_EXP);
assert(sig <= F32_SIG_MASK);
return ((uint32_t)sign << F32_SIGN_SHIFT) |
@@ -184,12 +184,12 @@ static uint32_t shift_float_and_round_to_nearest(uint32_t significand,
return significand;
}
-static WasmResult parse_float_nan(const char* s,
+static WabtResult parse_float_nan(const char* s,
const char* end,
uint32_t* out_bits) {
- WasmBool is_neg = WASM_FALSE;
+ WabtBool is_neg = WABT_FALSE;
if (*s == '-') {
- is_neg = WASM_TRUE;
+ is_neg = WABT_TRUE;
s++;
} else if (*s == '+') {
s++;
@@ -205,31 +205,31 @@ static WasmResult parse_float_nan(const char* s,
for (; s < end; ++s) {
uint32_t digit;
- if (WASM_FAILED(wasm_parse_hexdigit(*s, &digit)))
- return WASM_ERROR;
+ if (WABT_FAILED(wabt_parse_hexdigit(*s, &digit)))
+ return WABT_ERROR;
tag = tag * 16 + digit;
/* check for overflow */
if (tag > F32_SIG_MASK)
- return WASM_ERROR;
+ return WABT_ERROR;
}
/* NaN cannot have a zero tag, that is reserved for infinity */
if (tag == 0)
- return WASM_ERROR;
+ return WABT_ERROR;
} else {
tag = F32_QUIET_NAN_TAG;
}
*out_bits = make_float(is_neg, F32_MAX_EXP, tag);
- return WASM_OK;
+ return WABT_OK;
}
static void parse_float_hex(const char* s,
const char* end,
uint32_t* out_bits) {
- WasmBool is_neg = WASM_FALSE;
+ WabtBool is_neg = WABT_FALSE;
if (*s == '-') {
- is_neg = WASM_TRUE;
+ is_neg = WABT_TRUE;
s++;
} else if (*s == '+') {
s++;
@@ -245,7 +245,7 @@ static void parse_float_hex(const char* s,
0x10000000.0p0 => significand = 1, significand_exponent = 28
0x0.000001p0 => significand = 1, significand_exponent = -24
*/
- WasmBool seen_dot = WASM_FALSE;
+ WabtBool seen_dot = WABT_FALSE;
uint32_t significand = 0;
/* how much to shift |significand| if a non-zero value is appended */
int significand_shift = 0;
@@ -257,9 +257,9 @@ static void parse_float_hex(const char* s,
if (significand != 0)
significand_exponent += significand_shift;
significand_shift = 0;
- seen_dot = WASM_TRUE;
+ seen_dot = WABT_TRUE;
continue;
- } else if (WASM_FAILED(wasm_parse_hexdigit(*s, &digit))) {
+ } else if (WABT_FAILED(wabt_parse_hexdigit(*s, &digit))) {
break;
}
significand_shift += HEX_DIGIT_BITS;
@@ -290,13 +290,13 @@ static void parse_float_hex(const char* s,
assert(s < end);
int exponent = 0;
- WasmBool exponent_is_neg = WASM_FALSE;
+ WabtBool exponent_is_neg = WABT_FALSE;
/* exponent is always positive, but significand_exponent is signed.
significand_exponent_add is negated if exponent will be negative, so it can
be easily summed to see if the exponent is too large (see below) */
int significand_exponent_add = 0;
if (*s == '-') {
- exponent_is_neg = WASM_TRUE;
+ exponent_is_neg = WABT_TRUE;
significand_exponent_add = -significand_exponent;
s++;
} else if (*s == '+') {
@@ -315,7 +315,7 @@ static void parse_float_hex(const char* s,
if (exponent_is_neg)
exponent = -exponent;
- significand_bits = sizeof(uint32_t) * 8 - wasm_clz_u32(significand);
+ significand_bits = sizeof(uint32_t) * 8 - wabt_clz_u32(significand);
/* -1 for the implicit 1 bit of the significand */
exponent += significand_exponent + significand_bits - 1;
@@ -365,9 +365,9 @@ static void parse_float_hex(const char* s,
static void parse_float_infinity(const char* s,
const char* end,
uint32_t* out_bits) {
- WasmBool is_neg = WASM_FALSE;
+ WabtBool is_neg = WABT_FALSE;
if (*s == '-') {
- is_neg = WASM_TRUE;
+ is_neg = WABT_TRUE;
s++;
} else if (*s == '+') {
s++;
@@ -376,13 +376,13 @@ static void parse_float_infinity(const char* s,
*out_bits = make_float(is_neg, F32_MAX_EXP, 0);
}
-WasmResult wasm_parse_float(WasmLiteralType literal_type,
+WabtResult wabt_parse_float(WabtLiteralType literal_type,
const char* s,
const char* end,
uint32_t* out_bits) {
switch (literal_type) {
- case WASM_LITERAL_TYPE_INT:
- case WASM_LITERAL_TYPE_FLOAT: {
+ case WABT_LITERAL_TYPE_INT:
+ case WABT_LITERAL_TYPE_FLOAT: {
errno = 0;
char* endptr;
float value;
@@ -390,37 +390,37 @@ WasmResult wasm_parse_float(WasmLiteralType literal_type,
if (endptr != end ||
((value == 0 || value == HUGE_VALF || value == -HUGE_VALF) &&
errno != 0))
- return WASM_ERROR;
+ return WABT_ERROR;
memcpy(out_bits, &value, sizeof(value));
- return WASM_OK;
+ return WABT_OK;
}
- case WASM_LITERAL_TYPE_HEXFLOAT:
+ case WABT_LITERAL_TYPE_HEXFLOAT:
parse_float_hex(s, end, out_bits);
- return WASM_OK;
+ return WABT_OK;
- case WASM_LITERAL_TYPE_INFINITY:
+ case WABT_LITERAL_TYPE_INFINITY:
parse_float_infinity(s, end, out_bits);
- return WASM_OK;
+ return WABT_OK;
- case WASM_LITERAL_TYPE_NAN:
+ case WABT_LITERAL_TYPE_NAN:
return parse_float_nan(s, end, out_bits);
default:
assert(0);
- return WASM_ERROR;
+ return WABT_ERROR;
}
}
-void wasm_write_float_hex(char* out, size_t size, uint32_t bits) {
+void wabt_write_float_hex(char* out, size_t size, uint32_t bits) {
/* 1234567890123456 */
/* -0x#.######p-### */
/* -nan:0x###### */
/* -infinity */
- char buffer[WASM_MAX_FLOAT_HEX];
+ char buffer[WABT_MAX_FLOAT_HEX];
char* p = buffer;
- WasmBool is_neg = (bits >> F32_SIGN_SHIFT);
+ WabtBool is_neg = (bits >> F32_SIGN_SHIFT);
int exp = ((bits >> F32_SIG_BITS) & F32_EXP_MASK) - F32_EXP_BIAS;
uint32_t sig = bits & F32_SIG_MASK;
@@ -452,7 +452,7 @@ void wasm_write_float_hex(char* out, size_t size, uint32_t bits) {
}
}
} else {
- WasmBool is_zero = sig == 0 && exp == F32_MIN_EXP;
+ WabtBool is_zero = sig == 0 && exp == F32_MIN_EXP;
strcpy(p, "0x");
p += 2;
*p++ = is_zero ? '0' : '1';
@@ -463,7 +463,7 @@ void wasm_write_float_hex(char* out, size_t size, uint32_t bits) {
if (sig) {
if (exp == F32_MIN_EXP) {
/* subnormal; shift the significand up, and shift out the implicit 1 */
- uint32_t leading_zeroes = wasm_clz_u32(sig);
+ uint32_t leading_zeroes = wabt_clz_u32(sig);
if (leading_zeroes < 31)
sig <<= leading_zeroes + 1;
else
@@ -503,7 +503,7 @@ void wasm_write_float_hex(char* out, size_t size, uint32_t bits) {
}
/* doubles */
-static uint64_t make_double(WasmBool sign, int exp, uint64_t sig) {
+static uint64_t make_double(WabtBool sign, int exp, uint64_t sig) {
assert(exp >= F64_MIN_EXP && exp <= F64_MAX_EXP);
assert(sig <= F64_SIG_MASK);
return ((uint64_t)sign << F64_SIGN_SHIFT) |
@@ -520,12 +520,12 @@ static uint64_t shift_double_and_round_to_nearest(uint64_t significand,
return significand;
}
-static WasmResult parse_double_nan(const char* s,
+static WabtResult parse_double_nan(const char* s,
const char* end,
uint64_t* out_bits) {
- WasmBool is_neg = WASM_FALSE;
+ WabtBool is_neg = WABT_FALSE;
if (*s == '-') {
- is_neg = WASM_TRUE;
+ is_neg = WABT_TRUE;
s++;
} else if (*s == '+') {
s++;
@@ -537,36 +537,36 @@ static WasmResult parse_double_nan(const char* s,
if (s != end) {
tag = 0;
if (!string_starts_with(s, end, ":0x"))
- return WASM_ERROR;
+ return WABT_ERROR;
s += 3;
for (; s < end; ++s) {
uint32_t digit;
- if (WASM_FAILED(wasm_parse_hexdigit(*s, &digit)))
- return WASM_ERROR;
+ if (WABT_FAILED(wabt_parse_hexdigit(*s, &digit)))
+ return WABT_ERROR;
tag = tag * 16 + digit;
/* check for overflow */
if (tag > F64_SIG_MASK)
- return WASM_ERROR;
+ return WABT_ERROR;
}
/* NaN cannot have a zero tag, that is reserved for infinity */
if (tag == 0)
- return WASM_ERROR;
+ return WABT_ERROR;
} else {
tag = F64_QUIET_NAN_TAG;
}
*out_bits = make_double(is_neg, F64_MAX_EXP, tag);
- return WASM_OK;
+ return WABT_OK;
}
static void parse_double_hex(const char* s,
const char* end,
uint64_t* out_bits) {
- WasmBool is_neg = WASM_FALSE;
+ WabtBool is_neg = WABT_FALSE;
if (*s == '-') {
- is_neg = WASM_TRUE;
+ is_neg = WABT_TRUE;
s++;
} else if (*s == '+') {
s++;
@@ -575,7 +575,7 @@ static void parse_double_hex(const char* s,
s += 2;
/* see the similar comment in parse_float_hex */
- WasmBool seen_dot = WASM_FALSE;
+ WabtBool seen_dot = WABT_FALSE;
uint64_t significand = 0;
/* how much to shift |significand| if a non-zero value is appended */
int significand_shift = 0;
@@ -587,9 +587,9 @@ static void parse_double_hex(const char* s,
if (significand != 0)
significand_exponent += significand_shift;
significand_shift = 0;
- seen_dot = WASM_TRUE;
+ seen_dot = WABT_TRUE;
continue;
- } else if (WASM_FAILED(wasm_parse_hexdigit(*s, &digit))) {
+ } else if (WABT_FAILED(wabt_parse_hexdigit(*s, &digit))) {
break;
}
significand_shift += HEX_DIGIT_BITS;
@@ -620,13 +620,13 @@ static void parse_double_hex(const char* s,
assert(s < end);
int exponent = 0;
- WasmBool exponent_is_neg = WASM_FALSE;
+ WabtBool exponent_is_neg = WABT_FALSE;
/* exponent is always positive, but significand_exponent is signed.
significand_exponent_add is negated if exponent will be negative, so it can
be easily summed to see if the exponent is too large (see below) */
int significand_exponent_add = 0;
if (*s == '-') {
- exponent_is_neg = WASM_TRUE;
+ exponent_is_neg = WABT_TRUE;
significand_exponent_add = -significand_exponent;
s++;
} else if (*s == '+') {
@@ -645,7 +645,7 @@ static void parse_double_hex(const char* s,
if (exponent_is_neg)
exponent = -exponent;
- significand_bits = sizeof(uint64_t) * 8 - wasm_clz_u64(significand);
+ significand_bits = sizeof(uint64_t) * 8 - wabt_clz_u64(significand);
/* -1 for the implicit 1 bit of the significand */
exponent += significand_exponent + significand_bits - 1;
@@ -695,9 +695,9 @@ static void parse_double_hex(const char* s,
static void parse_double_infinity(const char* s,
const char* end,
uint64_t* out_bits) {
- WasmBool is_neg = WASM_FALSE;
+ WabtBool is_neg = WABT_FALSE;
if (*s == '-') {
- is_neg = WASM_TRUE;
+ is_neg = WABT_TRUE;
s++;
} else if (*s == '+') {
s++;
@@ -706,13 +706,13 @@ static void parse_double_infinity(const char* s,
*out_bits = make_double(is_neg, F64_MAX_EXP, 0);
}
-WasmResult wasm_parse_double(WasmLiteralType literal_type,
+WabtResult wabt_parse_double(WabtLiteralType literal_type,
const char* s,
const char* end,
uint64_t* out_bits) {
switch (literal_type) {
- case WASM_LITERAL_TYPE_INT:
- case WASM_LITERAL_TYPE_FLOAT: {
+ case WABT_LITERAL_TYPE_INT:
+ case WABT_LITERAL_TYPE_FLOAT: {
errno = 0;
char* endptr;
double value;
@@ -720,37 +720,37 @@ WasmResult wasm_parse_double(WasmLiteralType literal_type,
if (endptr != end ||
((value == 0 || value == HUGE_VAL || value == -HUGE_VAL) &&
errno != 0))
- return WASM_ERROR;
+ return WABT_ERROR;
memcpy(out_bits, &value, sizeof(value));
- return WASM_OK;
+ return WABT_OK;
}
- case WASM_LITERAL_TYPE_HEXFLOAT:
+ case WABT_LITERAL_TYPE_HEXFLOAT:
parse_double_hex(s, end, out_bits);
- return WASM_OK;
+ return WABT_OK;
- case WASM_LITERAL_TYPE_INFINITY:
+ case WABT_LITERAL_TYPE_INFINITY:
parse_double_infinity(s, end, out_bits);
- return WASM_OK;
+ return WABT_OK;
- case WASM_LITERAL_TYPE_NAN:
+ case WABT_LITERAL_TYPE_NAN:
return parse_double_nan(s, end, out_bits);
default:
assert(0);
- return WASM_ERROR;
+ return WABT_ERROR;
}
}
-void wasm_write_double_hex(char* out, size_t size, uint64_t bits) {
+void wabt_write_double_hex(char* out, size_t size, uint64_t bits) {
/* 123456789012345678901234 */
/* -0x#.#############p-#### */
/* -nan:0x############# */
/* -infinity */
- char buffer[WASM_MAX_DOUBLE_HEX];
+ char buffer[WABT_MAX_DOUBLE_HEX];
char* p = buffer;
- WasmBool is_neg = (bits >> F64_SIGN_SHIFT);
+ WabtBool is_neg = (bits >> F64_SIGN_SHIFT);
int exp = ((bits >> F64_SIG_BITS) & F64_EXP_MASK) - F64_EXP_BIAS;
uint64_t sig = bits & F64_SIG_MASK;
@@ -782,7 +782,7 @@ void wasm_write_double_hex(char* out, size_t size, uint64_t bits) {
}
}
} else {
- WasmBool is_zero = sig == 0 && exp == F64_MIN_EXP;
+ WabtBool is_zero = sig == 0 && exp == F64_MIN_EXP;
strcpy(p, "0x");
p += 2;
*p++ = is_zero ? '0' : '1';
@@ -793,7 +793,7 @@ void wasm_write_double_hex(char* out, size_t size, uint64_t bits) {
if (sig) {
if (exp == F64_MIN_EXP) {
/* subnormal; shift the significand up, and shift out the implicit 1 */
- uint32_t leading_zeroes = wasm_clz_u64(sig);
+ uint32_t leading_zeroes = wabt_clz_u64(sig);
if (leading_zeroes < 63)
sig <<= leading_zeroes + 1;
else
diff --git a/src/literal.h b/src/literal.h
index e8b71d9c..9c8ccf8a 100644
--- a/src/literal.h
+++ b/src/literal.h
@@ -14,52 +14,52 @@
* limitations under the License.
*/
-#ifndef WASM_LITERAL_H_
-#define WASM_LITERAL_H_
+#ifndef WABT_LITERAL_H_
+#define WABT_LITERAL_H_
#include <stdint.h>
#include "common.h"
-/* These functions all return WASM_OK on success and WASM_ERROR on failure.
+/* These functions all return WABT_OK on success and WABT_ERROR on failure.
*
* NOTE: the functions are written for use with the re2c lexer, assuming that
* the literal has already matched the regular expressions defined there. As a
* result, the only validation that is done is for overflow, not for otherwise
* bogus input. */
-typedef enum WasmParseIntType {
- WASM_PARSE_UNSIGNED_ONLY = 0,
- WASM_PARSE_SIGNED_AND_UNSIGNED = 1,
-} WasmParseIntType;
+typedef enum WabtParseIntType {
+ WABT_PARSE_UNSIGNED_ONLY = 0,
+ WABT_PARSE_SIGNED_AND_UNSIGNED = 1,
+} WabtParseIntType;
/* Size of char buffer required to hold hex representation of a float/double */
-#define WASM_MAX_FLOAT_HEX 20
-#define WASM_MAX_DOUBLE_HEX 40
+#define WABT_MAX_FLOAT_HEX 20
+#define WABT_MAX_DOUBLE_HEX 40
-WASM_EXTERN_C_BEGIN
-WasmResult wasm_parse_hexdigit(char c, uint32_t* out);
-WasmResult wasm_parse_int32(const char* s,
+WABT_EXTERN_C_BEGIN
+WabtResult wabt_parse_hexdigit(char c, uint32_t* out);
+WabtResult wabt_parse_int32(const char* s,
const char* end,
uint32_t* out,
- WasmParseIntType parse_type);
-WasmResult wasm_parse_int64(const char* s,
+ WabtParseIntType parse_type);
+WabtResult wabt_parse_int64(const char* s,
const char* end,
uint64_t* out,
- WasmParseIntType parse_type);
-WasmResult wasm_parse_uint64(const char* s, const char* end, uint64_t* out);
-WasmResult wasm_parse_float(WasmLiteralType literal_type,
+ WabtParseIntType parse_type);
+WabtResult wabt_parse_uint64(const char* s, const char* end, uint64_t* out);
+WabtResult wabt_parse_float(WabtLiteralType literal_type,
const char* s,
const char* end,
uint32_t* out_bits);
-WasmResult wasm_parse_double(WasmLiteralType literal_type,
+WabtResult wabt_parse_double(WabtLiteralType literal_type,
const char* s,
const char* end,
uint64_t* out_bits);
-void wasm_write_float_hex(char* buffer, size_t size, uint32_t bits);
-void wasm_write_double_hex(char* buffer, size_t size, uint64_t bits);
+void wabt_write_float_hex(char* buffer, size_t size, uint32_t bits);
+void wabt_write_double_hex(char* buffer, size_t size, uint64_t bits);
-WASM_EXTERN_C_END
+WABT_EXTERN_C_END
-#endif /* WASM_LITERAL_H_ */
+#endif /* WABT_LITERAL_H_ */
diff --git a/src/option-parser.c b/src/option-parser.c
index fc680910..19e564cb 100644
--- a/src/option-parser.c
+++ b/src/option-parser.c
@@ -28,7 +28,7 @@
static int option_match(const char* s,
const char* full,
- WasmHasArgument has_argument) {
+ WabtHasArgument has_argument) {
int i;
for (i = 0; ; i++) {
if (full[i] == '\0') {
@@ -51,13 +51,13 @@ static int option_match(const char* s,
return i;
}
-static void WASM_PRINTF_FORMAT(2, 3)
- error(WasmOptionParser* parser, const char* format, ...) {
- WASM_SNPRINTF_ALLOCA(buffer, length, format);
+static void WABT_PRINTF_FORMAT(2, 3)
+ error(WabtOptionParser* parser, const char* format, ...) {
+ WABT_SNPRINTF_ALLOCA(buffer, length, format);
parser->on_error(parser, buffer);
}
-void wasm_parse_options(WasmOptionParser* parser,
+void wabt_parse_options(WabtOptionParser* parser,
int argc,
char** argv) {
parser->argv0 = argv[0];
@@ -74,7 +74,7 @@ void wasm_parse_options(WasmOptionParser* parser,
int best_length = 0;
int best_count = 0;
for (j = 0; j < parser->num_options; ++j) {
- WasmOption* option = &parser->options[j];
+ WabtOption* option = &parser->options[j];
if (option->long_name) {
int match_length =
option_match(&arg[2], option->long_name, option->has_argument);
@@ -96,7 +96,7 @@ void wasm_parse_options(WasmOptionParser* parser,
continue;
}
- WasmOption* best_option = &parser->options[best_index];
+ WabtOption* best_option = &parser->options[best_index];
const char* option_argument = NULL;
if (best_option->has_argument) {
if (arg[best_length] == '=') {
@@ -122,9 +122,9 @@ void wasm_parse_options(WasmOptionParser* parser,
/* allow short names to be combined, e.g. "-d -v" => "-dv" */
for (k = 1; arg[k]; ++k) {
- WasmBool matched = WASM_FALSE;
+ WabtBool matched = WABT_FALSE;
for (j = 0; j < parser->num_options; ++j) {
- WasmOption* option = &parser->options[j];
+ WabtOption* option = &parser->options[j];
if (option->short_name && arg[k] == option->short_name) {
const char* option_argument = NULL;
if (option->has_argument) {
@@ -145,7 +145,7 @@ void wasm_parse_options(WasmOptionParser* parser,
option_argument = argv[i];
}
parser->on_option(parser, option, option_argument);
- matched = WASM_TRUE;
+ matched = WABT_TRUE;
break;
}
}
@@ -163,7 +163,7 @@ void wasm_parse_options(WasmOptionParser* parser,
}
}
-void wasm_print_help(WasmOptionParser* parser, const char* program_name) {
+void wabt_print_help(WabtOptionParser* parser, const char* program_name) {
int i;
/* TODO(binji): do something more generic for filename here */
printf("usage: %s [options] filename\n\n", program_name);
@@ -173,14 +173,14 @@ void wasm_print_help(WasmOptionParser* parser, const char* program_name) {
const int extra_space = 8;
int longest_name_length = 0;
for (i = 0; i < parser->num_options; ++i) {
- WasmOption* option = &parser->options[i];
+ WabtOption* option = &parser->options[i];
int length;
if (option->long_name) {
if (option->metavar) {
length =
- wasm_snprintf(NULL, 0, "%s=%s", option->long_name, option->metavar);
+ wabt_snprintf(NULL, 0, "%s=%s", option->long_name, option->metavar);
} else {
- length = wasm_snprintf(NULL, 0, "%s", option->long_name);
+ length = wabt_snprintf(NULL, 0, "%s", option->long_name);
}
} else {
continue;
@@ -194,7 +194,7 @@ void wasm_print_help(WasmOptionParser* parser, const char* program_name) {
char* buffer = alloca(buffer_size);
for (i = 0; i < parser->num_options; ++i) {
- WasmOption* option = &parser->options[i];
+ WabtOption* option = &parser->options[i];
if (!option->short_name && !option->long_name)
continue;
@@ -205,11 +205,11 @@ void wasm_print_help(WasmOptionParser* parser, const char* program_name) {
char format[20];
if (option->long_name) {
- wasm_snprintf(format, sizeof(format), "--%%-%ds",
+ wabt_snprintf(format, sizeof(format), "--%%-%ds",
longest_name_length + extra_space);
if (option->metavar) {
- wasm_snprintf(buffer, buffer_size, "%s=%s", option->long_name,
+ wabt_snprintf(buffer, buffer_size, "%s=%s", option->long_name,
option->metavar);
printf(format, buffer);
} else {
@@ -217,7 +217,7 @@ void wasm_print_help(WasmOptionParser* parser, const char* program_name) {
}
} else {
/* +2 for the extra "--" above */
- wasm_snprintf(format, sizeof(format), "%%-%ds",
+ wabt_snprintf(format, sizeof(format), "%%-%ds",
longest_name_length + extra_space + 2);
printf(format, "");
}
diff --git a/src/option-parser.h b/src/option-parser.h
index 599089c8..e130f55f 100644
--- a/src/option-parser.h
+++ b/src/option-parser.h
@@ -14,53 +14,53 @@
* limitations under the License.
*/
-#ifndef WASM_OPTION_PARSER_H_
-#define WASM_OPTION_PARSER_H_
+#ifndef WABT_OPTION_PARSER_H_
+#define WABT_OPTION_PARSER_H_
#include "common.h"
-typedef enum WasmHasArgument {
- WASM_OPTION_NO_ARGUMENT,
- WASM_OPTION_HAS_ARGUMENT,
-} WasmHasArgument;
+typedef enum WabtHasArgument {
+ WABT_OPTION_NO_ARGUMENT,
+ WABT_OPTION_HAS_ARGUMENT,
+} WabtHasArgument;
-struct WasmOption;
-struct WasmOptionParser;
-typedef void (*WasmOptionCallback)(struct WasmOptionParser*,
- struct WasmOption*,
+struct WabtOption;
+struct WabtOptionParser;
+typedef void (*WabtOptionCallback)(struct WabtOptionParser*,
+ struct WabtOption*,
const char* argument);
-typedef void (*WasmArgumentCallback)(struct WasmOptionParser*,
+typedef void (*WabtArgumentCallback)(struct WabtOptionParser*,
const char* argument);
-typedef void (*WasmOptionErrorCallback)(struct WasmOptionParser*,
+typedef void (*WabtOptionErrorCallback)(struct WabtOptionParser*,
const char* message);
-typedef struct WasmOption {
+typedef struct WabtOption {
int id;
char short_name;
const char* long_name;
const char* metavar;
- WasmHasArgument has_argument;
+ WabtHasArgument has_argument;
const char* help;
-} WasmOption;
+} WabtOption;
-typedef struct WasmOptionParser {
+typedef struct WabtOptionParser {
const char* description;
- WasmOption* options;
+ WabtOption* options;
int num_options;
- WasmOptionCallback on_option;
- WasmArgumentCallback on_argument;
- WasmOptionErrorCallback on_error;
+ WabtOptionCallback on_option;
+ WabtArgumentCallback on_argument;
+ WabtOptionErrorCallback on_error;
void* user_data;
- /* cached after call to wasm_parse_options */
+ /* cached after call to wabt_parse_options */
char* argv0;
-} WasmOptionParser;
+} WabtOptionParser;
-WASM_EXTERN_C_BEGIN
-void wasm_parse_options(WasmOptionParser* parser,
+WABT_EXTERN_C_BEGIN
+void wabt_parse_options(WabtOptionParser* parser,
int argc,
char** argv);
-void wasm_print_help(WasmOptionParser* parser, const char* program_name);
-WASM_EXTERN_C_END
+void wabt_print_help(WabtOptionParser* parser, const char* program_name);
+WABT_EXTERN_C_END
-#endif /* WASM_OPTION_PARSER_H_ */
+#endif /* WABT_OPTION_PARSER_H_ */
diff --git a/src/prebuilt/ast-lexer-gen.c b/src/prebuilt/ast-lexer-gen.c
index f07359bf..7fa80aa3 100644
--- a/src/prebuilt/ast-lexer-gen.c
+++ b/src/prebuilt/ast-lexer-gen.c
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.13.5 */
+/* Generated by re2c 0.16 */
#line 1 "src/ast-lexer.c"
/*
* Copyright 2016 WebAssembly Community Group participants
@@ -45,11 +45,11 @@
#define RETURN(name) \
YY_USER_ACTION; \
- return WASM_TOKEN_TYPE_##name
+ return WABT_TOKEN_TYPE_##name
#define ERROR(...) \
YY_USER_ACTION; \
- wasm_ast_parser_error(loc, lexer, parser, __VA_ARGS__)
+ wabt_ast_parser_error(loc, lexer, parser, __VA_ARGS__)
#define BEGIN(c) \
do { \
@@ -57,7 +57,7 @@
} while (0)
#define FILL(n) \
do { \
- if (WASM_FAILED(fill(loc, lexer, parser, n))) { \
+ if (WABT_FAILED(fill(loc, lexer, parser, n))) { \
RETURN(EOF); \
continue; \
} \
@@ -85,21 +85,21 @@
lval->text.start = yytext + offset; \
lval->text.length = yyleng - offset
-#define TYPE(type_) lval->type = WASM_TYPE_##type_
+#define TYPE(type_) lval->type = WABT_TYPE_##type_
-#define OPCODE(name) lval->opcode = WASM_OPCODE_##name
+#define OPCODE(name) lval->opcode = WABT_OPCODE_##name
#define LITERAL(type_) \
- lval->literal.type = WASM_LITERAL_TYPE_##type_; \
+ lval->literal.type = WABT_LITERAL_TYPE_##type_; \
lval->literal.text.start = yytext; \
lval->literal.text.length = yyleng
-static WasmResult fill(WasmLocation* loc,
- WasmAstLexer* lexer,
- WasmAstParser* parser,
+static WabtResult fill(WabtLocation* loc,
+ WabtAstLexer* lexer,
+ WabtAstParser* parser,
size_t need) {
if (lexer->eof)
- return WASM_ERROR;
+ return WABT_ERROR;
size_t free = lexer->token - lexer->buffer;
assert((size_t)(lexer->cursor - lexer->buffer) >= free);
/* our buffer is too small, need to realloc */
@@ -116,12 +116,12 @@ static WasmResult fill(WasmLocation* loc,
/* TODO(binji): could just alloc instead, because we know we'll need to
* memmove below */
- char* new_buffer = wasm_realloc(lexer->allocator, lexer->buffer,
- new_buffer_size, WASM_DEFAULT_ALIGN);
+ char* new_buffer = wabt_realloc(lexer->allocator, lexer->buffer,
+ new_buffer_size, WABT_DEFAULT_ALIGN);
if (new_buffer == NULL) {
- wasm_ast_parser_error(loc, lexer, parser,
+ wabt_ast_parser_error(loc, lexer, parser,
"unable to reallocate lexer buffer.");
- return WASM_ERROR;
+ return WABT_ERROR;
}
memmove(new_buffer, lexer->token, lexer->limit - lexer->token);
lexer->buffer = new_buffer;
@@ -142,11 +142,11 @@ static WasmResult fill(WasmLocation* loc,
lexer->buffer_file_offset += free;
}
/* read the new data into the buffer */
- if (lexer->source.type == WASM_LEXER_SOURCE_TYPE_FILE) {
+ if (lexer->source.type == WABT_LEXER_SOURCE_TYPE_FILE) {
lexer->limit += fread(lexer->limit, 1, free, lexer->source.file);
} else {
/* TODO(binji): could lex directly from buffer */
- assert(lexer->source.type == WASM_LEXER_SOURCE_TYPE_BUFFER);
+ assert(lexer->source.type == WABT_LEXER_SOURCE_TYPE_BUFFER);
size_t read_size = free;
size_t offset = lexer->source.buffer.read_offset;
size_t bytes_left = lexer->source.buffer.size - offset;
@@ -161,17 +161,17 @@ static WasmResult fill(WasmLocation* loc,
* characters", that are not a lexeme nor a lexeme suffix. see
* http://re2c.org/examples/example_03.html */
if (lexer->limit < lexer->buffer + lexer->buffer_size - YYMAXFILL) {
- lexer->eof = WASM_TRUE;
+ lexer->eof = WABT_TRUE;
memset(lexer->limit, 0, YYMAXFILL);
lexer->limit += YYMAXFILL;
}
- return WASM_OK;
+ return WABT_OK;
}
-int wasm_ast_lexer_lex(WASM_AST_PARSER_STYPE* lval,
- WASM_AST_PARSER_LTYPE* loc,
- WasmAstLexer* lexer,
- WasmAstParser* parser) {
+int wabt_ast_lexer_lex(WABT_AST_PARSER_STYPE* lval,
+ WABT_AST_PARSER_LTYPE* loc,
+ WabtAstLexer* lexer,
+ WabtAstParser* parser) {
enum {
YYCOND_INIT,
YYCOND_BAD_TEXT,
@@ -201,66 +201,64 @@ int wasm_ast_lexer_lex(WASM_AST_PARSER_STYPE* lval,
}
/* *********************************** */
YYCOND_BAD_TEXT:
-
if ((lexer->limit - lexer->cursor) < 3) FILL(3);
yych = *lexer->cursor;
if (yych <= '!') {
if (yych <= '\t') {
- if (yych >= 0x01) goto yy4;
+ if (yych >= 0x01) goto yy5;
} else {
- if (yych <= '\n') goto yy6;
- if (yych <= 0x1F) goto yy4;
- goto yy8;
+ if (yych <= '\n') goto yy7;
+ if (yych <= 0x1F) goto yy5;
+ goto yy9;
}
} else {
if (yych <= '\\') {
- if (yych <= '"') goto yy10;
- if (yych <= '[') goto yy8;
- goto yy12;
+ if (yych <= '"') goto yy11;
+ if (yych <= '[') goto yy9;
+ goto yy13;
} else {
- if (yych == 0x7F) goto yy4;
- goto yy8;
+ if (yych == 0x7F) goto yy5;
+ goto yy9;
}
}
++lexer->cursor;
#line 235 "src/ast-lexer.c"
{ ERROR("unexpected EOF"); RETURN(EOF); }
-#line 229 "src/prebuilt/ast-lexer-gen.c"
-yy4:
- ++lexer->cursor;
+#line 228 "src/prebuilt/ast-lexer-gen.c"
yy5:
+ ++lexer->cursor;
+yy6:
#line 236 "src/ast-lexer.c"
{ ERROR("illegal character in string"); continue; }
-#line 235 "src/prebuilt/ast-lexer-gen.c"
-yy6:
+#line 234 "src/prebuilt/ast-lexer-gen.c"
+yy7:
++lexer->cursor;
BEGIN(YYCOND_i);
#line 231 "src/ast-lexer.c"
{ ERROR("newline in string"); NEWLINE; continue; }
-#line 241 "src/prebuilt/ast-lexer-gen.c"
-yy8:
- ++lexer->cursor;
+#line 240 "src/prebuilt/ast-lexer-gen.c"
yy9:
+ ++lexer->cursor;
#line 230 "src/ast-lexer.c"
{ continue; }
-#line 247 "src/prebuilt/ast-lexer-gen.c"
-yy10:
+#line 245 "src/prebuilt/ast-lexer-gen.c"
+yy11:
++lexer->cursor;
BEGIN(YYCOND_i);
#line 234 "src/ast-lexer.c"
{ TEXT; RETURN(TEXT); }
-#line 253 "src/prebuilt/ast-lexer-gen.c"
-yy12:
+#line 251 "src/prebuilt/ast-lexer-gen.c"
+yy13:
yych = *++lexer->cursor;
if (yych <= '@') {
if (yych <= '"') {
- if (yych == '\n') goto yy5;
- if (yych >= '"') goto yy15;
+ if (yych == '\n') goto yy6;
+ if (yych >= '"') goto yy9;
} else {
if (yych <= '\'') {
- if (yych >= '\'') goto yy15;
+ if (yych >= '\'') goto yy9;
} else {
- if (yych <= '/') goto yy13;
+ if (yych <= '/') goto yy14;
if (yych <= '9') goto yy16;
}
}
@@ -269,88 +267,85 @@ yy12:
if (yych <= '[') {
if (yych <= 'F') goto yy16;
} else {
- if (yych <= '\\') goto yy15;
+ if (yych <= '\\') goto yy9;
if (yych >= 'a') goto yy16;
}
} else {
if (yych <= 'n') {
- if (yych >= 'n') goto yy15;
+ if (yych >= 'n') goto yy9;
} else {
- if (yych == 't') goto yy15;
+ if (yych == 't') goto yy9;
}
}
}
-yy13:
- ++lexer->cursor;
yy14:
+ ++lexer->cursor;
+yy15:
#line 232 "src/ast-lexer.c"
{ ERROR("bad escape \"%.*s\"", (int)yyleng, yytext);
continue; }
-#line 290 "src/prebuilt/ast-lexer-gen.c"
-yy15:
- yych = *++lexer->cursor;
- goto yy9;
+#line 288 "src/prebuilt/ast-lexer-gen.c"
yy16:
- yych = *++lexer->cursor;
- if (yych <= '@') {
- if (yych <= '/') goto yy14;
- if (yych >= ':') goto yy14;
+ ++lexer->cursor;
+ if ((yych = *lexer->cursor) <= '@') {
+ if (yych <= '/') goto yy15;
+ if (yych <= '9') goto yy9;
+ goto yy15;
} else {
- if (yych <= 'F') goto yy17;
- if (yych <= '`') goto yy14;
- if (yych >= 'g') goto yy14;
+ if (yych <= 'F') goto yy9;
+ if (yych <= '`') goto yy15;
+ if (yych <= 'f') goto yy9;
+ goto yy15;
}
-yy17:
- ++lexer->cursor;
- yych = *lexer->cursor;
- goto yy9;
/* *********************************** */
YYCOND_BLOCK_COMMENT:
if ((lexer->limit - lexer->cursor) < 2) FILL(2);
yych = *lexer->cursor;
if (yych <= '\'') {
- if (yych <= 0x00) goto yy20;
- if (yych == '\n') goto yy24;
- goto yy22;
+ if (yych <= 0x00) goto yy19;
+ if (yych == '\n') goto yy23;
+ goto yy21;
} else {
- if (yych <= '(') goto yy26;
- if (yych == ';') goto yy27;
- goto yy22;
+ if (yych <= '(') goto yy25;
+ if (yych == ';') goto yy26;
+ goto yy21;
}
-yy20:
+yy19:
++lexer->cursor;
#line 458 "src/ast-lexer.c"
{ ERROR("unexpected EOF"); RETURN(EOF); }
-#line 325 "src/prebuilt/ast-lexer-gen.c"
-yy22:
+#line 318 "src/prebuilt/ast-lexer-gen.c"
+yy21:
++lexer->cursor;
-yy23:
+yy22:
#line 459 "src/ast-lexer.c"
{ continue; }
-#line 331 "src/prebuilt/ast-lexer-gen.c"
-yy24:
+#line 324 "src/prebuilt/ast-lexer-gen.c"
+yy23:
++lexer->cursor;
#line 457 "src/ast-lexer.c"
{ NEWLINE; continue; }
-#line 336 "src/prebuilt/ast-lexer-gen.c"
+#line 329 "src/prebuilt/ast-lexer-gen.c"
+yy25:
+ yych = *++lexer->cursor;
+ if (yych == ';') goto yy27;
+ goto yy22;
yy26:
yych = *++lexer->cursor;
- if (yych == ';') goto yy30;
- goto yy23;
+ if (yych == ')') goto yy29;
+ goto yy22;
yy27:
- yych = *++lexer->cursor;
- if (yych != ')') goto yy23;
+ ++lexer->cursor;
+#line 453 "src/ast-lexer.c"
+ { COMMENT_NESTING++; continue; }
+#line 342 "src/prebuilt/ast-lexer-gen.c"
+yy29:
++lexer->cursor;
#line 454 "src/ast-lexer.c"
{ if (--COMMENT_NESTING == 0)
BEGIN(YYCOND_INIT);
continue; }
#line 349 "src/prebuilt/ast-lexer-gen.c"
-yy30:
- ++lexer->cursor;
-#line 453 "src/ast-lexer.c"
- { COMMENT_NESTING++; continue; }
-#line 354 "src/prebuilt/ast-lexer-gen.c"
/* *********************************** */
YYCOND_LINE_COMMENT:
{
@@ -388,57 +383,51 @@ YYCOND_LINE_COMMENT:
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128,
};
- if ((lexer->limit - lexer->cursor) < 2) FILL(2);
+ if (lexer->limit <= lexer->cursor) FILL(1);
yych = *lexer->cursor;
- if (yych <= 0x00) goto yy35;
- if (yych == '\n') goto yy37;
+ if (yybm[0+yych] & 128) {
+ goto yy34;
+ }
goto yy36;
-yy34:
+yy33:
#line 451 "src/ast-lexer.c"
{ continue; }
-#line 400 "src/prebuilt/ast-lexer-gen.c"
-yy35:
- yych = *++lexer->cursor;
- goto yy40;
-yy36:
- yych = *++lexer->cursor;
- goto yy40;
-yy37:
- ++lexer->cursor;
- BEGIN(YYCOND_i);
-#line 450 "src/ast-lexer.c"
- { NEWLINE; continue; }
-#line 412 "src/prebuilt/ast-lexer-gen.c"
-yy39:
+#line 396 "src/prebuilt/ast-lexer-gen.c"
+yy34:
++lexer->cursor;
if (lexer->limit <= lexer->cursor) FILL(1);
yych = *lexer->cursor;
-yy40:
if (yybm[0+yych] & 128) {
- goto yy39;
+ goto yy34;
}
- goto yy34;
+ goto yy33;
+yy36:
+ ++lexer->cursor;
+ BEGIN(YYCOND_i);
+#line 450 "src/ast-lexer.c"
+ { NEWLINE; continue; }
+#line 410 "src/prebuilt/ast-lexer-gen.c"
}
/* *********************************** */
YYCOND_i:
{
static const unsigned char yybm[] = {
0, 0, 0, 0, 0, 0, 0, 0,
- 0, 128, 0, 0, 0, 128, 0, 0,
+ 0, 8, 0, 0, 0, 8, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
- 192, 72, 0, 72, 72, 72, 72, 72,
- 64, 64, 72, 72, 64, 72, 72, 72,
- 120, 120, 120, 120, 120, 120, 120, 120,
- 120, 120, 72, 64, 72, 72, 72, 72,
- 72, 104, 104, 104, 104, 104, 104, 72,
- 72, 72, 72, 72, 72, 72, 72, 72,
- 72, 72, 72, 72, 72, 72, 72, 72,
- 72, 72, 72, 64, 8, 64, 72, 72,
- 72, 104, 104, 104, 104, 104, 104, 72,
- 72, 72, 72, 72, 72, 72, 72, 72,
- 72, 72, 72, 72, 72, 72, 72, 72,
- 72, 72, 72, 64, 72, 64, 72, 0,
+ 72, 80, 0, 80, 80, 80, 80, 80,
+ 64, 64, 80, 80, 64, 80, 80, 80,
+ 240, 240, 240, 240, 240, 240, 240, 240,
+ 240, 240, 80, 64, 80, 80, 80, 80,
+ 80, 208, 208, 208, 208, 208, 208, 80,
+ 80, 80, 80, 80, 80, 80, 80, 80,
+ 80, 80, 80, 80, 80, 80, 80, 80,
+ 80, 80, 80, 64, 16, 64, 80, 80,
+ 80, 208, 208, 208, 208, 208, 208, 80,
+ 80, 80, 80, 80, 80, 80, 80, 80,
+ 80, 80, 80, 80, 80, 80, 80, 80,
+ 80, 80, 80, 64, 80, 64, 80, 0,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
@@ -458,12 +447,14 @@ YYCOND_i:
};
if ((lexer->limit - lexer->cursor) < 20) FILL(20);
yych = *lexer->cursor;
+ if (yybm[0+yych] & 8) {
+ goto yy44;
+ }
switch (yych) {
- case 0x00: goto yy43;
+ case 0x00: goto yy40;
case '\t':
- case '\r':
- case ' ': goto yy47;
- case '\n': goto yy49;
+ case '\n': goto yy47;
+ case ' ':
case '!':
case '#':
case '%':
@@ -518,14 +509,14 @@ YYCOND_i:
case 'y':
case 'z':
case '|':
- case '~': goto yy51;
- case '"': goto yy53;
- case '$': goto yy55;
- case '(': goto yy56;
- case ')': goto yy58;
+ case '~': goto yy49;
+ case '"': goto yy52;
+ case '$': goto yy54;
+ case '(': goto yy55;
+ case ')': goto yy57;
case '+':
- case '-': goto yy60;
- case '0': goto yy61;
+ case '-': goto yy59;
+ case '0': goto yy60;
case '1':
case '2':
case '3':
@@ -534,7 +525,7 @@ YYCOND_i:
case '6':
case '7':
case '8':
- case '9': goto yy63;
+ case '9': goto yy62;
case ';': goto yy64;
case 'a': goto yy65;
case 'b': goto yy66;
@@ -553,5344 +544,6126 @@ YYCOND_i:
case 's': goto yy79;
case 't': goto yy80;
case 'u': goto yy81;
- default: goto yy45;
+ default: goto yy42;
}
-yy43:
+yy40:
++lexer->cursor;
#line 465 "src/ast-lexer.c"
{ RETURN(EOF); }
-#line 563 "src/prebuilt/ast-lexer-gen.c"
-yy45:
+#line 554 "src/prebuilt/ast-lexer-gen.c"
+yy42:
++lexer->cursor;
-yy46:
+yy43:
#line 466 "src/ast-lexer.c"
{ ERROR("unexpected char"); continue; }
-#line 569 "src/prebuilt/ast-lexer-gen.c"
-yy47:
+#line 560 "src/prebuilt/ast-lexer-gen.c"
+yy44:
++lexer->cursor;
+ if (lexer->limit <= lexer->cursor) FILL(1);
yych = *lexer->cursor;
- goto yy1167;
-yy48:
+ if (yybm[0+yych] & 8) {
+ goto yy44;
+ }
#line 461 "src/ast-lexer.c"
{ continue; }
-#line 577 "src/prebuilt/ast-lexer-gen.c"
-yy49:
+#line 570 "src/prebuilt/ast-lexer-gen.c"
+yy47:
++lexer->cursor;
#line 460 "src/ast-lexer.c"
{ NEWLINE; continue; }
-#line 582 "src/prebuilt/ast-lexer-gen.c"
-yy51:
+#line 575 "src/prebuilt/ast-lexer-gen.c"
+yy49:
++lexer->cursor;
+ if (lexer->limit <= lexer->cursor) FILL(1);
yych = *lexer->cursor;
- goto yy83;
-yy52:
+yy50:
+ if (yybm[0+yych] & 16) {
+ goto yy49;
+ }
+yy51:
#line 462 "src/ast-lexer.c"
{ ERROR("unexpected token \"%.*s\"",
(int)yyleng, yytext);
continue; }
-#line 592 "src/prebuilt/ast-lexer-gen.c"
-yy53:
+#line 589 "src/prebuilt/ast-lexer-gen.c"
+yy52:
yych = *(lexer->marker = ++lexer->cursor);
- if (yych <= 0x1F) goto yy54;
- if (yych != 0x7F) goto yy1160;
-yy54:
+ if (yych <= 0x1F) goto yy53;
+ if (yych != 0x7F) goto yy83;
+yy53:
BEGIN(YYCOND_BAD_TEXT);
#line 229 "src/ast-lexer.c"
{ continue; }
-#line 601 "src/prebuilt/ast-lexer-gen.c"
-yy55:
+#line 598 "src/prebuilt/ast-lexer-gen.c"
+yy54:
yych = *++lexer->cursor;
if (yych <= ';') {
if (yych <= '\'') {
- if (yych == '!') goto yy1156;
- if (yych <= '"') goto yy52;
- goto yy1156;
+ if (yych == '!') goto yy88;
+ if (yych <= '"') goto yy51;
+ goto yy88;
} else {
if (yych <= '+') {
- if (yych <= ')') goto yy52;
- goto yy1156;
+ if (yych <= ')') goto yy51;
+ goto yy88;
} else {
- if (yych <= ',') goto yy52;
- if (yych <= ':') goto yy1156;
- goto yy52;
+ if (yych <= ',') goto yy51;
+ if (yych <= ':') goto yy88;
+ goto yy51;
}
}
} else {
if (yych <= 'z') {
if (yych <= '[') {
- if (yych <= 'Z') goto yy1156;
- goto yy52;
+ if (yych <= 'Z') goto yy88;
+ goto yy51;
} else {
- if (yych == ']') goto yy52;
- goto yy1156;
+ if (yych == ']') goto yy51;
+ goto yy88;
}
} else {
if (yych <= '|') {
- if (yych <= '{') goto yy52;
- goto yy1156;
+ if (yych <= '{') goto yy51;
+ goto yy88;
} else {
- if (yych == '~') goto yy1156;
- goto yy52;
+ if (yych == '~') goto yy88;
+ goto yy51;
}
}
}
-yy56:
+yy55:
++lexer->cursor;
- if ((yych = *lexer->cursor) == ';') goto yy1154;
+ if ((yych = *lexer->cursor) == ';') goto yy91;
#line 220 "src/ast-lexer.c"
{ RETURN(LPAR); }
-#line 643 "src/prebuilt/ast-lexer-gen.c"
-yy58:
+#line 640 "src/prebuilt/ast-lexer-gen.c"
+yy57:
++lexer->cursor;
#line 221 "src/ast-lexer.c"
{ RETURN(RPAR); }
-#line 648 "src/prebuilt/ast-lexer-gen.c"
-yy60:
+#line 645 "src/prebuilt/ast-lexer-gen.c"
+yy59:
yych = *++lexer->cursor;
if (yych <= 'h') {
- if (yych <= '/') goto yy83;
- if (yych <= '0') goto yy1144;
- if (yych <= '9') goto yy1146;
- goto yy83;
+ if (yych <= '/') goto yy50;
+ if (yych <= '0') goto yy93;
+ if (yych <= '9') goto yy95;
+ goto yy50;
} else {
- if (yych <= 'i') goto yy1148;
- if (yych == 'n') goto yy1149;
- goto yy83;
+ if (yych <= 'i') goto yy97;
+ if (yych == 'n') goto yy98;
+ goto yy50;
}
-yy61:
+yy60:
++lexer->cursor;
- if ((yych = *lexer->cursor) <= 'D') {
- if (yych <= ',') {
+ if (yybm[0+(yych = *lexer->cursor)] & 32) {
+ goto yy62;
+ }
+ if (yych <= 'E') {
+ if (yych <= '+') {
if (yych <= '"') {
- if (yych == '!') goto yy82;
+ if (yych == '!') goto yy49;
} else {
- if (yych <= '\'') goto yy82;
- if (yych <= ')') goto yy62;
- if (yych <= '+') goto yy82;
+ if (yych <= '\'') goto yy49;
+ if (yych >= '*') goto yy49;
}
} else {
- if (yych <= '/') {
- if (yych == '.') goto yy1125;
- goto yy82;
+ if (yych <= '.') {
+ if (yych <= ',') goto yy61;
+ if (yych <= '-') goto yy49;
+ goto yy99;
} else {
- if (yych <= '9') goto yy1128;
- if (yych != ';') goto yy82;
+ if (yych == ';') goto yy61;
+ if (yych <= 'D') goto yy49;
+ goto yy102;
}
}
} else {
- if (yych <= 'e') {
- if (yych <= '[') {
- if (yych <= 'E') goto yy1130;
- if (yych <= 'Z') goto yy82;
+ if (yych <= 'w') {
+ if (yych <= '\\') {
+ if (yych != '[') goto yy49;
} else {
- if (yych == ']') goto yy62;
- if (yych <= 'd') goto yy82;
- goto yy1130;
+ if (yych <= ']') goto yy61;
+ if (yych == 'e') goto yy102;
+ goto yy49;
}
} else {
if (yych <= '{') {
- if (yych == 'x') goto yy1134;
- if (yych <= 'z') goto yy82;
+ if (yych <= 'x') goto yy103;
+ if (yych <= 'z') goto yy49;
} else {
- if (yych == '}') goto yy62;
- if (yych <= '~') goto yy82;
+ if (yych == '}') goto yy61;
+ if (yych <= '~') goto yy49;
}
}
}
-yy62:
+yy61:
#line 222 "src/ast-lexer.c"
{ LITERAL(INT); RETURN(NAT); }
#line 704 "src/prebuilt/ast-lexer-gen.c"
-yy63:
- yych = *++lexer->cursor;
- if (yych <= ';') {
+yy62:
+ ++lexer->cursor;
+ if ((lexer->limit - lexer->cursor) < 3) FILL(3);
+ yych = *lexer->cursor;
+ if (yybm[0+yych] & 32) {
+ goto yy62;
+ }
+ if (yych <= 'D') {
if (yych <= '+') {
if (yych <= '"') {
- if (yych == '!') goto yy82;
- goto yy62;
+ if (yych == '!') goto yy49;
+ goto yy61;
} else {
- if (yych <= '\'') goto yy82;
- if (yych <= ')') goto yy62;
- goto yy82;
+ if (yych <= '\'') goto yy49;
+ if (yych <= ')') goto yy61;
+ goto yy49;
}
} else {
if (yych <= '.') {
- if (yych <= ',') goto yy62;
- if (yych <= '-') goto yy82;
- goto yy1125;
+ if (yych <= ',') goto yy61;
+ if (yych <= '-') goto yy49;
+ goto yy99;
} else {
- if (yych <= '/') goto yy82;
- if (yych <= '9') goto yy1128;
- if (yych <= ':') goto yy82;
- goto yy62;
+ if (yych == ';') goto yy61;
+ goto yy49;
}
}
} else {
if (yych <= 'd') {
- if (yych <= 'Z') {
- if (yych == 'E') goto yy1130;
- goto yy82;
+ if (yych <= '[') {
+ if (yych <= 'E') goto yy102;
+ if (yych <= 'Z') goto yy49;
+ goto yy61;
} else {
- if (yych == '\\') goto yy82;
- if (yych <= ']') goto yy62;
- goto yy82;
+ if (yych == ']') goto yy61;
+ goto yy49;
}
} else {
if (yych <= '{') {
- if (yych <= 'e') goto yy1130;
- if (yych <= 'z') goto yy82;
- goto yy62;
+ if (yych <= 'e') goto yy102;
+ if (yych <= 'z') goto yy49;
+ goto yy61;
} else {
- if (yych == '}') goto yy62;
- if (yych <= '~') goto yy82;
- goto yy62;
+ if (yych == '}') goto yy61;
+ if (yych <= '~') goto yy49;
+ goto yy61;
}
}
}
yy64:
yych = *++lexer->cursor;
- if (yych == ';') goto yy1123;
- goto yy46;
+ if (yych == ';') goto yy104;
+ goto yy43;
yy65:
yych = *++lexer->cursor;
if (yych <= 'm') {
- if (yych == 'l') goto yy1041;
- goto yy83;
+ if (yych == 'l') goto yy106;
+ goto yy50;
} else {
- if (yych <= 'n') goto yy1042;
- if (yych == 's') goto yy1043;
- goto yy83;
+ if (yych <= 'n') goto yy107;
+ if (yych == 's') goto yy108;
+ goto yy50;
}
yy66:
yych = *++lexer->cursor;
- if (yych == 'l') goto yy1024;
- if (yych == 'r') goto yy1025;
- goto yy83;
+ if (yych == 'l') goto yy109;
+ if (yych == 'r') goto yy110;
+ goto yy50;
yy67:
yych = *++lexer->cursor;
- if (yych == 'a') goto yy990;
- if (yych == 'u') goto yy991;
- goto yy83;
+ if (yych == 'a') goto yy112;
+ if (yych == 'u') goto yy113;
+ goto yy50;
yy68:
yych = *++lexer->cursor;
- if (yych == 'a') goto yy982;
- if (yych == 'r') goto yy983;
- goto yy83;
+ if (yych == 'a') goto yy114;
+ if (yych == 'r') goto yy115;
+ goto yy50;
yy69:
yych = *++lexer->cursor;
if (yych <= 'm') {
- if (yych == 'l') goto yy966;
- goto yy83;
+ if (yych == 'l') goto yy116;
+ goto yy50;
} else {
- if (yych <= 'n') goto yy967;
- if (yych == 'x') goto yy968;
- goto yy83;
+ if (yych <= 'n') goto yy117;
+ if (yych == 'x') goto yy118;
+ goto yy50;
}
yy70:
yych = *++lexer->cursor;
if (yych <= '5') {
- if (yych == '3') goto yy672;
- goto yy83;
+ if (yych == '3') goto yy119;
+ goto yy50;
} else {
- if (yych <= '6') goto yy673;
- if (yych == 'u') goto yy674;
- goto yy83;
+ if (yych <= '6') goto yy120;
+ if (yych == 'u') goto yy121;
+ goto yy50;
}
yy71:
yych = *++lexer->cursor;
if (yych <= 'k') {
- if (yych == 'e') goto yy638;
- goto yy83;
+ if (yych == 'e') goto yy122;
+ goto yy50;
} else {
- if (yych <= 'l') goto yy639;
- if (yych == 'r') goto yy640;
- goto yy83;
+ if (yych <= 'l') goto yy123;
+ if (yych == 'r') goto yy124;
+ goto yy50;
}
yy72:
yych = *++lexer->cursor;
if (yych <= 'e') {
if (yych <= '3') {
- if (yych <= '2') goto yy83;
- goto yy220;
+ if (yych <= '2') goto yy50;
+ goto yy125;
} else {
- if (yych == '6') goto yy221;
- goto yy83;
+ if (yych == '6') goto yy126;
+ goto yy50;
}
} else {
if (yych <= 'l') {
- if (yych <= 'f') goto yy222;
- goto yy83;
+ if (yych <= 'f') goto yy127;
+ goto yy50;
} else {
- if (yych <= 'm') goto yy224;
- if (yych <= 'n') goto yy225;
- goto yy83;
+ if (yych <= 'm') goto yy129;
+ if (yych <= 'n') goto yy130;
+ goto yy50;
}
}
yy73:
yych = *++lexer->cursor;
- if (yych == 'o') goto yy212;
- goto yy83;
+ if (yych == 'o') goto yy131;
+ goto yy50;
yy74:
yych = *++lexer->cursor;
if (yych <= 'n') {
- if (yych == 'e') goto yy197;
- goto yy83;
+ if (yych == 'e') goto yy132;
+ goto yy50;
} else {
- if (yych <= 'o') goto yy198;
- if (yych == 'u') goto yy199;
- goto yy83;
+ if (yych <= 'o') goto yy133;
+ if (yych == 'u') goto yy134;
+ goto yy50;
}
yy75:
yych = *++lexer->cursor;
- if (yych == 'a') goto yy186;
- if (yych == 'o') goto yy187;
- goto yy83;
+ if (yych == 'a') goto yy135;
+ if (yych == 'o') goto yy136;
+ goto yy50;
yy76:
yych = *++lexer->cursor;
- if (yych == 'f') goto yy166;
- if (yych == 'u') goto yy167;
- goto yy83;
+ if (yych == 'f') goto yy137;
+ if (yych == 'u') goto yy138;
+ goto yy50;
yy77:
yych = *++lexer->cursor;
- if (yych == 'a') goto yy161;
- goto yy83;
+ if (yych == 'a') goto yy139;
+ goto yy50;
yy78:
yych = *++lexer->cursor;
- if (yych == 'e') goto yy143;
- goto yy83;
+ if (yych == 'e') goto yy140;
+ goto yy50;
yy79:
yych = *++lexer->cursor;
- if (yych == 'e') goto yy117;
- if (yych == 't') goto yy118;
- goto yy83;
+ if (yych == 'e') goto yy141;
+ if (yych == 't') goto yy142;
+ goto yy50;
yy80:
yych = *++lexer->cursor;
if (yych <= 'e') {
- if (yych == 'a') goto yy95;
- if (yych <= 'd') goto yy83;
- goto yy96;
+ if (yych == 'a') goto yy143;
+ if (yych <= 'd') goto yy50;
+ goto yy144;
} else {
if (yych <= 'h') {
- if (yych <= 'g') goto yy83;
- goto yy97;
+ if (yych <= 'g') goto yy50;
+ goto yy145;
} else {
- if (yych == 'y') goto yy98;
- goto yy83;
+ if (yych == 'y') goto yy146;
+ goto yy50;
}
}
yy81:
yych = *++lexer->cursor;
- if (yych == 'n') goto yy84;
- goto yy83;
+ if (yych == 'n') goto yy147;
+ goto yy50;
yy82:
++lexer->cursor;
if (lexer->limit <= lexer->cursor) FILL(1);
yych = *lexer->cursor;
yy83:
- if (yybm[0+yych] & 8) {
+ if (yybm[0+yych] & 64) {
goto yy82;
}
- goto yy52;
+ if (yych <= 0x1F) goto yy84;
+ if (yych <= '"') goto yy85;
+ if (yych <= '\\') goto yy87;
yy84:
- yych = *++lexer->cursor;
- if (yych != 'r') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'e') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'a') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'c') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'h') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'a') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'b') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'l') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'e') goto yy83;
+ lexer->cursor = lexer->marker;
+ goto yy53;
+yy85:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+#line 228 "src/ast-lexer.c"
+ { TEXT; RETURN(TEXT); }
+#line 907 "src/prebuilt/ast-lexer-gen.c"
+yy87:
+ ++lexer->cursor;
+ if (lexer->limit <= lexer->cursor) FILL(1);
+ yych = *lexer->cursor;
+ if (yych <= 'F') {
+ if (yych <= '\'') {
+ if (yych == '"') goto yy82;
+ if (yych <= '&') goto yy84;
+ goto yy82;
+ } else {
+ if (yych <= '/') goto yy84;
+ if (yych <= '9') goto yy148;
+ if (yych <= '@') goto yy84;
+ goto yy148;
+ }
+ } else {
+ if (yych <= 'f') {
+ if (yych == '\\') goto yy82;
+ if (yych <= '`') goto yy84;
+ goto yy148;
+ } else {
+ if (yych <= 'n') {
+ if (yych <= 'm') goto yy84;
+ goto yy82;
+ } else {
+ if (yych == 't') goto yy82;
+ goto yy84;
+ }
+ }
}
-#line 417 "src/ast-lexer.c"
- { RETURN(UNREACHABLE); }
-#line 920 "src/prebuilt/ast-lexer-gen.c"
+yy88:
+ ++lexer->cursor;
+ if (lexer->limit <= lexer->cursor) FILL(1);
+ yych = *lexer->cursor;
+ if (yych <= ';') {
+ if (yych <= '\'') {
+ if (yych == '!') goto yy88;
+ if (yych >= '#') goto yy88;
+ } else {
+ if (yych <= '+') {
+ if (yych >= '*') goto yy88;
+ } else {
+ if (yych <= ',') goto yy90;
+ if (yych <= ':') goto yy88;
+ }
+ }
+ } else {
+ if (yych <= 'z') {
+ if (yych <= '[') {
+ if (yych <= 'Z') goto yy88;
+ } else {
+ if (yych != ']') goto yy88;
+ }
+ } else {
+ if (yych <= '|') {
+ if (yych >= '|') goto yy88;
+ } else {
+ if (yych == '~') goto yy88;
+ }
+ }
+ }
+yy90:
+#line 447 "src/ast-lexer.c"
+ { TEXT; RETURN(VAR); }
+#line 972 "src/prebuilt/ast-lexer-gen.c"
+yy91:
+ ++lexer->cursor;
+ BEGIN(YYCOND_BLOCK_COMMENT);
+#line 452 "src/ast-lexer.c"
+ { COMMENT_NESTING = 1; continue; }
+#line 978 "src/prebuilt/ast-lexer-gen.c"
+yy93:
+ ++lexer->cursor;
+ if ((yych = *lexer->cursor) <= 'D') {
+ if (yych <= ',') {
+ if (yych <= '"') {
+ if (yych == '!') goto yy49;
+ } else {
+ if (yych <= '\'') goto yy49;
+ if (yych <= ')') goto yy94;
+ if (yych <= '+') goto yy49;
+ }
+ } else {
+ if (yych <= '/') {
+ if (yych == '.') goto yy99;
+ goto yy49;
+ } else {
+ if (yych <= '9') goto yy95;
+ if (yych != ';') goto yy49;
+ }
+ }
+ } else {
+ if (yych <= 'e') {
+ if (yych <= '[') {
+ if (yych <= 'E') goto yy102;
+ if (yych <= 'Z') goto yy49;
+ } else {
+ if (yych == ']') goto yy94;
+ if (yych <= 'd') goto yy49;
+ goto yy102;
+ }
+ } else {
+ if (yych <= '{') {
+ if (yych == 'x') goto yy149;
+ if (yych <= 'z') goto yy49;
+ } else {
+ if (yych == '}') goto yy94;
+ if (yych <= '~') goto yy49;
+ }
+ }
+ }
+yy94:
+#line 223 "src/ast-lexer.c"
+ { LITERAL(INT); RETURN(INT); }
+#line 1022 "src/prebuilt/ast-lexer-gen.c"
yy95:
- yych = *++lexer->cursor;
- if (yych == 'b') goto yy113;
- goto yy83;
-yy96:
- yych = *++lexer->cursor;
- if (yych == 'e') goto yy105;
- goto yy83;
+ ++lexer->cursor;
+ if ((lexer->limit - lexer->cursor) < 3) FILL(3);
+ yych = *lexer->cursor;
+ if (yych <= ';') {
+ if (yych <= '+') {
+ if (yych <= '"') {
+ if (yych == '!') goto yy49;
+ goto yy94;
+ } else {
+ if (yych <= '\'') goto yy49;
+ if (yych <= ')') goto yy94;
+ goto yy49;
+ }
+ } else {
+ if (yych <= '.') {
+ if (yych <= ',') goto yy94;
+ if (yych <= '-') goto yy49;
+ goto yy99;
+ } else {
+ if (yych <= '/') goto yy49;
+ if (yych <= '9') goto yy95;
+ if (yych <= ':') goto yy49;
+ goto yy94;
+ }
+ }
+ } else {
+ if (yych <= 'd') {
+ if (yych <= 'Z') {
+ if (yych == 'E') goto yy102;
+ goto yy49;
+ } else {
+ if (yych == '\\') goto yy49;
+ if (yych <= ']') goto yy94;
+ goto yy49;
+ }
+ } else {
+ if (yych <= '{') {
+ if (yych <= 'e') goto yy102;
+ if (yych <= 'z') goto yy49;
+ goto yy94;
+ } else {
+ if (yych == '}') goto yy94;
+ if (yych <= '~') goto yy49;
+ goto yy94;
+ }
+ }
+ }
yy97:
yych = *++lexer->cursor;
- if (yych == 'e') goto yy102;
- goto yy83;
+ if (yych == 'n') goto yy150;
+ goto yy50;
yy98:
yych = *++lexer->cursor;
- if (yych != 'p') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'e') goto yy83;
+ if (yych == 'a') goto yy135;
+ goto yy50;
+yy99:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if ((lexer->limit - lexer->cursor) < 3) FILL(3);
+ yych = *lexer->cursor;
+ if (yych <= 'D') {
+ if (yych <= '+') {
+ if (yych <= '"') {
+ if (yych == '!') goto yy49;
+ } else {
+ if (yych <= '\'') goto yy49;
+ if (yych >= '*') goto yy49;
+ }
+ } else {
+ if (yych <= '9') {
+ if (yych <= ',') goto yy101;
+ if (yych <= '/') goto yy49;
+ goto yy99;
+ } else {
+ if (yych != ';') goto yy49;
+ }
+ }
+ } else {
+ if (yych <= 'd') {
+ if (yych <= '[') {
+ if (yych <= 'E') goto yy102;
+ if (yych <= 'Z') goto yy49;
+ } else {
+ if (yych != ']') goto yy49;
+ }
+ } else {
+ if (yych <= '{') {
+ if (yych <= 'e') goto yy102;
+ if (yych <= 'z') goto yy49;
+ } else {
+ if (yych == '}') goto yy101;
+ if (yych <= '~') goto yy49;
+ }
+ }
}
-#line 420 "src/ast-lexer.c"
- { RETURN(TYPE); }
-#line 944 "src/prebuilt/ast-lexer-gen.c"
+yy101:
+#line 224 "src/ast-lexer.c"
+ { LITERAL(FLOAT); RETURN(FLOAT); }
+#line 1121 "src/prebuilt/ast-lexer-gen.c"
yy102:
yych = *++lexer->cursor;
- if (yych != 'n') goto yy83;
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yych <= ',') {
+ if (yych == '+') goto yy151;
+ goto yy50;
+ } else {
+ if (yych <= '-') goto yy151;
+ if (yych <= '/') goto yy50;
+ if (yych <= '9') goto yy152;
+ goto yy50;
}
-#line 247 "src/ast-lexer.c"
- { RETURN(THEN); }
-#line 954 "src/prebuilt/ast-lexer-gen.c"
-yy105:
+yy103:
yych = *++lexer->cursor;
- if (yych != '_') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'l') goto yy83;
+ if (yybm[0+yych] & 128) {
+ goto yy154;
+ }
+ goto yy50;
+yy104:
+ ++lexer->cursor;
+ BEGIN(YYCOND_LINE_COMMENT);
+#line 449 "src/ast-lexer.c"
+ { continue; }
+#line 1144 "src/prebuilt/ast-lexer-gen.c"
+yy106:
yych = *++lexer->cursor;
- if (yych != 'o') goto yy83;
+ if (yych == 'i') goto yy156;
+ goto yy50;
+yy107:
yych = *++lexer->cursor;
- if (yych != 'c') goto yy83;
+ if (yych == 'y') goto yy157;
+ goto yy50;
+yy108:
yych = *++lexer->cursor;
- if (yych != 'a') goto yy83;
+ if (yych == 's') goto yy158;
+ goto yy50;
+yy109:
yych = *++lexer->cursor;
- if (yych != 'l') goto yy83;
+ if (yych == 'o') goto yy159;
+ goto yy50;
+yy110:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if ((yych = *lexer->cursor) <= 'Z') {
+ if (yych <= ')') {
+ if (yych <= '!') {
+ if (yych >= '!') goto yy49;
+ } else {
+ if (yych <= '"') goto yy111;
+ if (yych <= '\'') goto yy49;
+ }
+ } else {
+ if (yych <= ',') {
+ if (yych <= '+') goto yy49;
+ } else {
+ if (yych != ';') goto yy49;
+ }
+ }
+ } else {
+ if (yych <= '_') {
+ if (yych <= '\\') {
+ if (yych >= '\\') goto yy49;
+ } else {
+ if (yych <= ']') goto yy111;
+ if (yych <= '^') goto yy49;
+ goto yy160;
+ }
+ } else {
+ if (yych <= '|') {
+ if (yych != '{') goto yy49;
+ } else {
+ if (yych == '~') goto yy49;
+ }
+ }
}
-#line 261 "src/ast-lexer.c"
- { RETURN(TEE_LOCAL); }
-#line 974 "src/prebuilt/ast-lexer-gen.c"
+yy111:
+#line 250 "src/ast-lexer.c"
+ { RETURN(BR); }
+#line 1198 "src/prebuilt/ast-lexer-gen.c"
+yy112:
+ yych = *++lexer->cursor;
+ if (yych == 'l') goto yy161;
+ goto yy50;
yy113:
yych = *++lexer->cursor;
- if (yych != 'l') goto yy83;
+ if (yych == 'r') goto yy162;
+ goto yy50;
+yy114:
yych = *++lexer->cursor;
- if (yych != 'e') goto yy83;
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 427 "src/ast-lexer.c"
- { RETURN(TABLE); }
-#line 986 "src/prebuilt/ast-lexer-gen.c"
+ if (yych == 't') goto yy163;
+ goto yy50;
+yy115:
+ yych = *++lexer->cursor;
+ if (yych == 'o') goto yy164;
+ goto yy50;
+yy116:
+ yych = *++lexer->cursor;
+ if (yych == 'e') goto yy165;
+ if (yych == 's') goto yy166;
+ goto yy50;
yy117:
yych = *++lexer->cursor;
- if (yych == 'l') goto yy124;
- if (yych == 't') goto yy123;
- goto yy83;
+ if (yych == 'd') goto yy167;
+ goto yy50;
yy118:
yych = *++lexer->cursor;
- if (yych != 'a') goto yy83;
+ if (yych == 'p') goto yy169;
+ goto yy50;
+yy119:
yych = *++lexer->cursor;
- if (yych != 'r') goto yy83;
+ if (yych == '2') goto yy170;
+ goto yy50;
+yy120:
yych = *++lexer->cursor;
- if (yych != 't') goto yy83;
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 429 "src/ast-lexer.c"
- { RETURN(START); }
-#line 1005 "src/prebuilt/ast-lexer-gen.c"
+ if (yych == '4') goto yy172;
+ goto yy50;
+yy121:
+ yych = *++lexer->cursor;
+ if (yych == 'n') goto yy174;
+ goto yy50;
+yy122:
+ yych = *++lexer->cursor;
+ if (yych == 't') goto yy175;
+ goto yy50;
yy123:
yych = *++lexer->cursor;
- if (yych == '_') goto yy129;
- goto yy83;
+ if (yych == 'o') goto yy177;
+ goto yy50;
yy124:
yych = *++lexer->cursor;
- if (yych != 'e') goto yy83;
+ if (yych == 'o') goto yy178;
+ goto yy50;
+yy125:
yych = *++lexer->cursor;
- if (yych != 'c') goto yy83;
+ if (yych == '2') goto yy179;
+ goto yy50;
+yy126:
yych = *++lexer->cursor;
- if (yych != 't') goto yy83;
+ if (yych == '4') goto yy181;
+ goto yy50;
+yy127:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if ((yych = *lexer->cursor) <= 'Z') {
+ if (yych <= ')') {
+ if (yych <= '!') {
+ if (yych >= '!') goto yy49;
+ } else {
+ if (yych <= '"') goto yy128;
+ if (yych <= '\'') goto yy49;
+ }
+ } else {
+ if (yych <= ',') {
+ if (yych <= '+') goto yy49;
+ } else {
+ if (yych != ';') goto yy49;
+ }
+ }
+ } else {
+ if (yych <= '_') {
+ if (yych <= '\\') {
+ if (yych >= '\\') goto yy49;
+ } else {
+ if (yych <= ']') goto yy128;
+ if (yych <= '^') goto yy49;
+ goto yy183;
+ }
+ } else {
+ if (yych <= '|') {
+ if (yych != '{') goto yy49;
+ } else {
+ if (yych == '~') goto yy49;
+ }
+ }
}
-#line 416 "src/ast-lexer.c"
- { RETURN(SELECT); }
-#line 1023 "src/prebuilt/ast-lexer-gen.c"
+yy128:
+#line 245 "src/ast-lexer.c"
+ { RETURN(IF); }
+#line 1297 "src/prebuilt/ast-lexer-gen.c"
yy129:
yych = *++lexer->cursor;
- if (yych == 'g') goto yy131;
- if (yych != 'l') goto yy83;
+ if (yych == 'p') goto yy184;
+ goto yy50;
+yy130:
yych = *++lexer->cursor;
- if (yych == 'o') goto yy138;
- goto yy83;
+ if (yych <= 'o') {
+ if (yych == 'f') goto yy185;
+ goto yy50;
+ } else {
+ if (yych <= 'p') goto yy187;
+ if (yych == 'v') goto yy188;
+ goto yy50;
+ }
yy131:
yych = *++lexer->cursor;
- if (yych != 'l') goto yy83;
+ if (yych == 'c') goto yy189;
+ if (yych == 'o') goto yy190;
+ goto yy50;
+yy132:
yych = *++lexer->cursor;
- if (yych != 'o') goto yy83;
+ if (yych == 'm') goto yy191;
+ goto yy50;
+yy133:
yych = *++lexer->cursor;
- if (yych != 'b') goto yy83;
+ if (yych == 'd') goto yy192;
+ goto yy50;
+yy134:
yych = *++lexer->cursor;
- if (yych != 'a') goto yy83;
+ if (yych == 't') goto yy193;
+ goto yy50;
+yy135:
yych = *++lexer->cursor;
- if (yych != 'l') goto yy83;
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 263 "src/ast-lexer.c"
- { RETURN(SET_GLOBAL); }
-#line 1048 "src/prebuilt/ast-lexer-gen.c"
-yy138:
+ if (yych == 'n') goto yy195;
+ goto yy50;
+yy136:
yych = *++lexer->cursor;
- if (yych != 'c') goto yy83;
+ if (yych == 'p') goto yy197;
+ goto yy50;
+yy137:
yych = *++lexer->cursor;
- if (yych != 'a') goto yy83;
+ if (yych == 'f') goto yy199;
+ goto yy50;
+yy138:
yych = *++lexer->cursor;
- if (yych != 'l') goto yy83;
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 260 "src/ast-lexer.c"
- { RETURN(SET_LOCAL); }
-#line 1062 "src/prebuilt/ast-lexer-gen.c"
-yy143:
+ if (yych == 't') goto yy200;
+ goto yy50;
+yy139:
+ yych = *++lexer->cursor;
+ if (yych == 'r') goto yy201;
+ goto yy50;
+yy140:
yych = *++lexer->cursor;
if (yych <= 'r') {
- if (yych == 'g') goto yy146;
- goto yy83;
+ if (yych == 'g') goto yy202;
+ goto yy50;
} else {
- if (yych <= 's') goto yy145;
- if (yych >= 'u') goto yy83;
+ if (yych <= 's') goto yy203;
+ if (yych <= 't') goto yy204;
+ goto yy50;
}
+yy141:
yych = *++lexer->cursor;
- if (yych == 'u') goto yy157;
- goto yy83;
-yy145:
+ if (yych == 'l') goto yy205;
+ if (yych == 't') goto yy206;
+ goto yy50;
+yy142:
yych = *++lexer->cursor;
- if (yych == 'u') goto yy153;
- goto yy83;
-yy146:
+ if (yych == 'a') goto yy207;
+ goto yy50;
+yy143:
yych = *++lexer->cursor;
- if (yych != 'i') goto yy83;
+ if (yych == 'b') goto yy208;
+ goto yy50;
+yy144:
yych = *++lexer->cursor;
- if (yych != 's') goto yy83;
+ if (yych == 'e') goto yy209;
+ goto yy50;
+yy145:
yych = *++lexer->cursor;
- if (yych != 't') goto yy83;
+ if (yych == 'e') goto yy210;
+ goto yy50;
+yy146:
yych = *++lexer->cursor;
- if (yych != 'e') goto yy83;
+ if (yych == 'p') goto yy211;
+ goto yy50;
+yy147:
yych = *++lexer->cursor;
- if (yych != 'r') goto yy83;
+ if (yych == 'r') goto yy212;
+ goto yy50;
+yy148:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (lexer->limit <= lexer->cursor) FILL(1);
+ yych = *lexer->cursor;
+ if (yych <= '@') {
+ if (yych <= '/') goto yy84;
+ if (yych <= '9') goto yy82;
+ goto yy84;
+ } else {
+ if (yych <= 'F') goto yy82;
+ if (yych <= '`') goto yy84;
+ if (yych <= 'f') goto yy82;
+ goto yy84;
}
-#line 435 "src/ast-lexer.c"
- { RETURN(REGISTER); }
-#line 1096 "src/prebuilt/ast-lexer-gen.c"
-yy153:
+yy149:
+ yych = *++lexer->cursor;
+ if (yych <= '@') {
+ if (yych <= '/') goto yy50;
+ if (yych <= '9') goto yy213;
+ goto yy50;
+ } else {
+ if (yych <= 'F') goto yy213;
+ if (yych <= '`') goto yy50;
+ if (yych <= 'f') goto yy213;
+ goto yy50;
+ }
+yy150:
yych = *++lexer->cursor;
- if (yych != 'l') goto yy83;
+ if (yych == 'f') goto yy185;
+ goto yy50;
+yy151:
yych = *++lexer->cursor;
- if (yych != 't') goto yy83;
+ if (yych <= '/') goto yy50;
+ if (yych >= ':') goto yy50;
+yy152:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (lexer->limit <= lexer->cursor) FILL(1);
+ yych = *lexer->cursor;
+ if (yych <= ':') {
+ if (yych <= ')') {
+ if (yych <= '!') {
+ if (yych <= ' ') goto yy101;
+ goto yy49;
+ } else {
+ if (yych <= '"') goto yy101;
+ if (yych <= '\'') goto yy49;
+ goto yy101;
+ }
+ } else {
+ if (yych <= ',') {
+ if (yych <= '+') goto yy49;
+ goto yy101;
+ } else {
+ if (yych <= '/') goto yy49;
+ if (yych <= '9') goto yy152;
+ goto yy49;
+ }
+ }
+ } else {
+ if (yych <= ']') {
+ if (yych <= 'Z') {
+ if (yych <= ';') goto yy101;
+ goto yy49;
+ } else {
+ if (yych == '\\') goto yy49;
+ goto yy101;
+ }
+ } else {
+ if (yych <= '|') {
+ if (yych == '{') goto yy101;
+ goto yy49;
+ } else {
+ if (yych == '~') goto yy49;
+ goto yy101;
+ }
+ }
}
-#line 423 "src/ast-lexer.c"
- { RETURN(RESULT); }
-#line 1108 "src/prebuilt/ast-lexer-gen.c"
+yy154:
+ ++lexer->cursor;
+ if ((lexer->limit - lexer->cursor) < 3) FILL(3);
+ yych = *lexer->cursor;
+ if (yybm[0+yych] & 128) {
+ goto yy154;
+ }
+ if (yych <= ';') {
+ if (yych <= ')') {
+ if (yych <= '!') {
+ if (yych <= ' ') goto yy61;
+ goto yy49;
+ } else {
+ if (yych <= '"') goto yy61;
+ if (yych <= '\'') goto yy49;
+ goto yy61;
+ }
+ } else {
+ if (yych <= '-') {
+ if (yych == ',') goto yy61;
+ goto yy49;
+ } else {
+ if (yych <= '.') goto yy215;
+ if (yych <= ':') goto yy49;
+ goto yy61;
+ }
+ }
+ } else {
+ if (yych <= 'p') {
+ if (yych <= '\\') {
+ if (yych == '[') goto yy61;
+ goto yy49;
+ } else {
+ if (yych <= ']') goto yy61;
+ if (yych <= 'o') goto yy49;
+ goto yy217;
+ }
+ } else {
+ if (yych <= '|') {
+ if (yych == '{') goto yy61;
+ goto yy49;
+ } else {
+ if (yych == '~') goto yy49;
+ goto yy61;
+ }
+ }
+ }
+yy156:
+ yych = *++lexer->cursor;
+ if (yych == 'g') goto yy218;
+ goto yy50;
yy157:
yych = *++lexer->cursor;
- if (yych != 'r') goto yy83;
+ if (yych == 'f') goto yy219;
+ goto yy50;
+yy158:
yych = *++lexer->cursor;
- if (yych != 'n') goto yy83;
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 258 "src/ast-lexer.c"
- { RETURN(RETURN); }
-#line 1120 "src/prebuilt/ast-lexer-gen.c"
-yy161:
+ if (yych == 'e') goto yy220;
+ goto yy50;
+yy159:
yych = *++lexer->cursor;
- if (yych != 'r') goto yy83;
+ if (yych == 'c') goto yy221;
+ goto yy50;
+yy160:
yych = *++lexer->cursor;
- if (yych != 'a') goto yy83;
+ if (yych == 'i') goto yy222;
+ if (yych == 't') goto yy223;
+ goto yy50;
+yy161:
yych = *++lexer->cursor;
- if (yych != 'm') goto yy83;
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 422 "src/ast-lexer.c"
- { RETURN(PARAM); }
-#line 1134 "src/prebuilt/ast-lexer-gen.c"
-yy166:
+ if (yych == 'l') goto yy224;
+ goto yy50;
+yy162:
yych = *++lexer->cursor;
- if (yych == 'f') goto yy173;
- goto yy83;
-yy167:
+ if (yych == 'r') goto yy226;
+ goto yy50;
+yy163:
yych = *++lexer->cursor;
- if (yych != 't') goto yy83;
+ if (yych == 'a') goto yy227;
+ goto yy50;
+yy164:
yych = *++lexer->cursor;
- if (yych != 'p') goto yy83;
+ if (yych == 'p') goto yy229;
+ goto yy50;
+yy165:
yych = *++lexer->cursor;
- if (yych != 'u') goto yy83;
+ if (yych == 'm') goto yy231;
+ goto yy50;
+yy166:
yych = *++lexer->cursor;
- if (yych != 't') goto yy83;
+ if (yych == 'e') goto yy233;
+ goto yy50;
+yy167:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 446 "src/ast-lexer.c"
- { RETURN(OUTPUT); }
-#line 1154 "src/prebuilt/ast-lexer-gen.c"
-yy173:
- yych = *++lexer->cursor;
- if (yych != 's') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'e') goto yy83;
+#line 257 "src/ast-lexer.c"
+ { RETURN(END); }
+#line 1564 "src/prebuilt/ast-lexer-gen.c"
+yy169:
yych = *++lexer->cursor;
- if (yych != 't') goto yy83;
+ if (yych == 'o') goto yy235;
+ goto yy50;
+yy170:
++lexer->cursor;
- if ((yych = *lexer->cursor) <= '<') {
+ if ((yych = *lexer->cursor) <= ':') {
if (yych <= ')') {
if (yych <= '!') {
- if (yych >= '!') goto yy82;
+ if (yych >= '!') goto yy49;
} else {
- if (yych <= '"') goto yy177;
- if (yych <= '\'') goto yy82;
+ if (yych <= '"') goto yy171;
+ if (yych <= '\'') goto yy49;
}
} else {
if (yych <= ',') {
- if (yych <= '+') goto yy82;
+ if (yych <= '+') goto yy49;
} else {
- if (yych != ';') goto yy82;
+ if (yych == '.') goto yy236;
+ goto yy49;
}
}
} else {
if (yych <= ']') {
if (yych <= 'Z') {
- if (yych <= '=') goto yy178;
- goto yy82;
+ if (yych >= '<') goto yy49;
+ } else {
+ if (yych == '\\') goto yy49;
+ }
+ } else {
+ if (yych <= '|') {
+ if (yych != '{') goto yy49;
+ } else {
+ if (yych == '~') goto yy49;
+ }
+ }
+ }
+yy171:
+#line 239 "src/ast-lexer.c"
+ { TYPE(F32); RETURN(VALUE_TYPE); }
+#line 1605 "src/prebuilt/ast-lexer-gen.c"
+yy172:
+ ++lexer->cursor;
+ if ((yych = *lexer->cursor) <= ':') {
+ if (yych <= ')') {
+ if (yych <= '!') {
+ if (yych >= '!') goto yy49;
+ } else {
+ if (yych <= '"') goto yy173;
+ if (yych <= '\'') goto yy49;
+ }
+ } else {
+ if (yych <= ',') {
+ if (yych <= '+') goto yy49;
+ } else {
+ if (yych == '.') goto yy237;
+ goto yy49;
+ }
+ }
+ } else {
+ if (yych <= ']') {
+ if (yych <= 'Z') {
+ if (yych >= '<') goto yy49;
} else {
- if (yych == '\\') goto yy82;
+ if (yych == '\\') goto yy49;
}
} else {
if (yych <= '|') {
- if (yych != '{') goto yy82;
+ if (yych != '{') goto yy49;
} else {
- if (yych == '~') goto yy82;
+ if (yych == '~') goto yy49;
}
}
}
+yy173:
+#line 240 "src/ast-lexer.c"
+ { TYPE(F64); RETURN(VALUE_TYPE); }
+#line 1642 "src/prebuilt/ast-lexer-gen.c"
+yy174:
+ yych = *++lexer->cursor;
+ if (yych == 'c') goto yy238;
+ goto yy50;
+yy175:
+ ++lexer->cursor;
+ if ((yych = *lexer->cursor) <= 'Z') {
+ if (yych <= ')') {
+ if (yych <= '!') {
+ if (yych >= '!') goto yy49;
+ } else {
+ if (yych <= '"') goto yy176;
+ if (yych <= '\'') goto yy49;
+ }
+ } else {
+ if (yych <= ',') {
+ if (yych <= '+') goto yy49;
+ } else {
+ if (yych != ';') goto yy49;
+ }
+ }
+ } else {
+ if (yych <= '_') {
+ if (yych <= '\\') {
+ if (yych >= '\\') goto yy49;
+ } else {
+ if (yych <= ']') goto yy176;
+ if (yych <= '^') goto yy49;
+ goto yy240;
+ }
+ } else {
+ if (yych <= '|') {
+ if (yych != '{') goto yy49;
+ } else {
+ if (yych == '~') goto yy49;
+ }
+ }
+ }
+yy176:
+#line 437 "src/ast-lexer.c"
+ { RETURN(GET); }
+#line 1684 "src/prebuilt/ast-lexer-gen.c"
yy177:
-#line 432 "src/ast-lexer.c"
- { RETURN(OFFSET); }
-#line 1197 "src/prebuilt/ast-lexer-gen.c"
+ yych = *++lexer->cursor;
+ if (yych == 'b') goto yy241;
+ goto yy50;
yy178:
yych = *++lexer->cursor;
- if (yych <= '/') goto yy83;
- if (yych <= '0') goto yy179;
- if (yych <= '9') goto yy181;
- goto yy83;
+ if (yych == 'w') goto yy242;
+ goto yy50;
yy179:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 16) {
- goto yy181;
- }
- if (yych <= 'Z') {
+ if ((yych = *lexer->cursor) <= ':') {
if (yych <= ')') {
if (yych <= '!') {
- if (yych >= '!') goto yy82;
+ if (yych >= '!') goto yy49;
} else {
if (yych <= '"') goto yy180;
- if (yych <= '\'') goto yy82;
+ if (yych <= '\'') goto yy49;
}
} else {
if (yych <= ',') {
- if (yych <= '+') goto yy82;
+ if (yych <= '+') goto yy49;
} else {
- if (yych != ';') goto yy82;
+ if (yych == '.') goto yy243;
+ goto yy49;
}
}
} else {
- if (yych <= 'x') {
- if (yych <= '\\') {
- if (yych >= '\\') goto yy82;
+ if (yych <= ']') {
+ if (yych <= 'Z') {
+ if (yych >= '<') goto yy49;
} else {
- if (yych <= ']') goto yy180;
- if (yych <= 'w') goto yy82;
- goto yy183;
+ if (yych == '\\') goto yy49;
}
} else {
if (yych <= '|') {
- if (yych != '{') goto yy82;
+ if (yych != '{') goto yy49;
} else {
- if (yych == '~') goto yy82;
+ if (yych == '~') goto yy49;
}
}
}
yy180:
-#line 287 "src/ast-lexer.c"
- { TEXT_AT(7); RETURN(OFFSET_EQ_NAT); }
-#line 1244 "src/prebuilt/ast-lexer-gen.c"
+#line 237 "src/ast-lexer.c"
+ { TYPE(I32); RETURN(VALUE_TYPE); }
+#line 1729 "src/prebuilt/ast-lexer-gen.c"
yy181:
++lexer->cursor;
- if (lexer->limit <= lexer->cursor) FILL(1);
- yych = *lexer->cursor;
- if (yybm[0+yych] & 16) {
- goto yy181;
- }
- if (yych <= ';') {
- if (yych <= '\'') {
- if (yych == '!') goto yy82;
- if (yych <= '"') goto yy180;
- goto yy82;
+ if ((yych = *lexer->cursor) <= ':') {
+ if (yych <= ')') {
+ if (yych <= '!') {
+ if (yych >= '!') goto yy49;
+ } else {
+ if (yych <= '"') goto yy182;
+ if (yych <= '\'') goto yy49;
+ }
} else {
- if (yych <= '+') {
- if (yych <= ')') goto yy180;
- goto yy82;
+ if (yych <= ',') {
+ if (yych <= '+') goto yy49;
} else {
- if (yych <= ',') goto yy180;
- if (yych <= ':') goto yy82;
- goto yy180;
+ if (yych == '.') goto yy244;
+ goto yy49;
}
}
} else {
- if (yych <= 'z') {
- if (yych <= '[') {
- if (yych <= 'Z') goto yy82;
- goto yy180;
+ if (yych <= ']') {
+ if (yych <= 'Z') {
+ if (yych >= '<') goto yy49;
} else {
- if (yych == ']') goto yy180;
- goto yy82;
+ if (yych == '\\') goto yy49;
}
} else {
if (yych <= '|') {
- if (yych <= '{') goto yy180;
- goto yy82;
+ if (yych != '{') goto yy49;
} else {
- if (yych == '~') goto yy82;
- goto yy180;
+ if (yych == '~') goto yy49;
}
}
}
+yy182:
+#line 238 "src/ast-lexer.c"
+ { TYPE(I64); RETURN(VALUE_TYPE); }
+#line 1766 "src/prebuilt/ast-lexer-gen.c"
yy183:
yych = *++lexer->cursor;
- if (yybm[0+yych] & 32) {
- goto yy184;
- }
- goto yy83;
+ if (yych == 'e') goto yy245;
+ goto yy50;
yy184:
+ yych = *++lexer->cursor;
+ if (yych == 'o') goto yy246;
+ goto yy50;
+yy185:
++lexer->cursor;
- if (lexer->limit <= lexer->cursor) FILL(1);
- yych = *lexer->cursor;
- if (yybm[0+yych] & 32) {
- goto yy184;
- }
- if (yych <= ';') {
- if (yych <= '\'') {
- if (yych == '!') goto yy82;
- if (yych <= '"') goto yy180;
- goto yy82;
+ if ((yych = *lexer->cursor) <= 'Z') {
+ if (yych <= ')') {
+ if (yych <= '!') {
+ if (yych >= '!') goto yy49;
+ } else {
+ if (yych <= '"') goto yy186;
+ if (yych <= '\'') goto yy49;
+ }
} else {
- if (yych <= '+') {
- if (yych <= ')') goto yy180;
- goto yy82;
+ if (yych <= ',') {
+ if (yych <= '+') goto yy49;
} else {
- if (yych <= ',') goto yy180;
- if (yych <= ':') goto yy82;
- goto yy180;
+ if (yych != ';') goto yy49;
}
}
} else {
- if (yych <= 'z') {
- if (yych <= '[') {
- if (yych <= 'Z') goto yy82;
- goto yy180;
+ if (yych <= 'i') {
+ if (yych <= '\\') {
+ if (yych >= '\\') goto yy49;
} else {
- if (yych == ']') goto yy180;
- goto yy82;
+ if (yych <= ']') goto yy186;
+ if (yych <= 'h') goto yy49;
+ goto yy247;
}
} else {
if (yych <= '|') {
- if (yych <= '{') goto yy180;
- goto yy82;
+ if (yych != '{') goto yy49;
} else {
- if (yych == '~') goto yy82;
- goto yy180;
+ if (yych == '~') goto yy49;
}
}
}
yy186:
- yych = *++lexer->cursor;
- if (yych == 'n') goto yy190;
- goto yy83;
+#line 226 "src/ast-lexer.c"
+ { LITERAL(INFINITY); RETURN(FLOAT); }
+#line 1812 "src/prebuilt/ast-lexer-gen.c"
yy187:
yych = *++lexer->cursor;
- if (yych != 'p') goto yy83;
+ if (yych == 'u') goto yy248;
+ goto yy50;
+yy188:
+ yych = *++lexer->cursor;
+ if (yych == 'o') goto yy249;
+ goto yy50;
+yy189:
+ yych = *++lexer->cursor;
+ if (yych == 'a') goto yy250;
+ goto yy50;
+yy190:
+ yych = *++lexer->cursor;
+ if (yych == 'p') goto yy251;
+ goto yy50;
+yy191:
+ yych = *++lexer->cursor;
+ if (yych == 'o') goto yy253;
+ goto yy50;
+yy192:
+ yych = *++lexer->cursor;
+ if (yych == 'u') goto yy254;
+ goto yy50;
+yy193:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 243 "src/ast-lexer.c"
- { RETURN(NOP); }
-#line 1346 "src/prebuilt/ast-lexer-gen.c"
-yy190:
+#line 242 "src/ast-lexer.c"
+ { RETURN(MUT); }
+#line 1844 "src/prebuilt/ast-lexer-gen.c"
+yy195:
++lexer->cursor;
if ((yych = *lexer->cursor) <= ';') {
if (yych <= ')') {
if (yych <= '!') {
- if (yych >= '!') goto yy82;
+ if (yych >= '!') goto yy49;
} else {
- if (yych <= '"') goto yy191;
- if (yych <= '\'') goto yy82;
+ if (yych <= '"') goto yy196;
+ if (yych <= '\'') goto yy49;
}
} else {
if (yych <= ',') {
- if (yych <= '+') goto yy82;
+ if (yych <= '+') goto yy49;
} else {
- if (yych <= '9') goto yy82;
- if (yych <= ':') goto yy192;
+ if (yych <= '9') goto yy49;
+ if (yych <= ':') goto yy255;
}
}
} else {
if (yych <= 'z') {
if (yych <= '[') {
- if (yych <= 'Z') goto yy82;
+ if (yych <= 'Z') goto yy49;
} else {
- if (yych != ']') goto yy82;
+ if (yych != ']') goto yy49;
}
} else {
if (yych <= '|') {
- if (yych >= '|') goto yy82;
+ if (yych >= '|') goto yy49;
} else {
- if (yych == '~') goto yy82;
+ if (yych == '~') goto yy49;
}
}
}
-yy191:
+yy196:
#line 227 "src/ast-lexer.c"
{ LITERAL(NAN); RETURN(FLOAT); }
-#line 1383 "src/prebuilt/ast-lexer-gen.c"
-yy192:
+#line 1881 "src/prebuilt/ast-lexer-gen.c"
+yy197:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 243 "src/ast-lexer.c"
+ { RETURN(NOP); }
+#line 1889 "src/prebuilt/ast-lexer-gen.c"
+yy199:
yych = *++lexer->cursor;
- if (yych != '0') goto yy83;
+ if (yych == 's') goto yy256;
+ goto yy50;
+yy200:
yych = *++lexer->cursor;
- if (yych != 'x') goto yy83;
+ if (yych == 'p') goto yy257;
+ goto yy50;
+yy201:
yych = *++lexer->cursor;
- if (yych <= '@') {
- if (yych <= '/') goto yy83;
- if (yych >= ':') goto yy83;
- } else {
- if (yych <= 'F') goto yy195;
- if (yych <= '`') goto yy83;
- if (yych >= 'g') goto yy83;
- }
-yy195:
+ if (yych == 'a') goto yy258;
+ goto yy50;
+yy202:
+ yych = *++lexer->cursor;
+ if (yych == 'i') goto yy259;
+ goto yy50;
+yy203:
+ yych = *++lexer->cursor;
+ if (yych == 'u') goto yy260;
+ goto yy50;
+yy204:
+ yych = *++lexer->cursor;
+ if (yych == 'u') goto yy261;
+ goto yy50;
+yy205:
+ yych = *++lexer->cursor;
+ if (yych == 'e') goto yy262;
+ goto yy50;
+yy206:
+ yych = *++lexer->cursor;
+ if (yych == '_') goto yy263;
+ goto yy50;
+yy207:
+ yych = *++lexer->cursor;
+ if (yych == 'r') goto yy264;
+ goto yy50;
+yy208:
+ yych = *++lexer->cursor;
+ if (yych == 'l') goto yy265;
+ goto yy50;
+yy209:
+ yych = *++lexer->cursor;
+ if (yych == '_') goto yy266;
+ goto yy50;
+yy210:
+ yych = *++lexer->cursor;
+ if (yych == 'n') goto yy267;
+ goto yy50;
+yy211:
+ yych = *++lexer->cursor;
+ if (yych == 'e') goto yy269;
+ goto yy50;
+yy212:
+ yych = *++lexer->cursor;
+ if (yych == 'e') goto yy271;
+ goto yy50;
+yy213:
++lexer->cursor;
- if (lexer->limit <= lexer->cursor) FILL(1);
+ if ((lexer->limit - lexer->cursor) < 3) FILL(3);
yych = *lexer->cursor;
if (yych <= '@') {
- if (yych <= '+') {
+ if (yych <= ',') {
if (yych <= '"') {
- if (yych == '!') goto yy82;
- goto yy191;
+ if (yych == '!') goto yy49;
+ goto yy94;
} else {
- if (yych <= '\'') goto yy82;
- if (yych <= ')') goto yy191;
- goto yy82;
+ if (yych <= '\'') goto yy49;
+ if (yych <= ')') goto yy94;
+ if (yych <= '+') goto yy49;
+ goto yy94;
}
} else {
- if (yych <= '9') {
- if (yych <= ',') goto yy191;
- if (yych <= '/') goto yy82;
- goto yy195;
+ if (yych <= '/') {
+ if (yych != '.') goto yy49;
} else {
- if (yych == ';') goto yy191;
- goto yy82;
+ if (yych <= '9') goto yy213;
+ if (yych == ';') goto yy94;
+ goto yy49;
}
}
} else {
- if (yych <= '`') {
+ if (yych <= 'f') {
if (yych <= '[') {
- if (yych <= 'F') goto yy195;
- if (yych <= 'Z') goto yy82;
- goto yy191;
+ if (yych <= 'F') goto yy213;
+ if (yych <= 'Z') goto yy49;
+ goto yy94;
} else {
- if (yych == ']') goto yy191;
- goto yy82;
+ if (yych == ']') goto yy94;
+ if (yych <= '`') goto yy49;
+ goto yy213;
}
} else {
if (yych <= '{') {
- if (yych <= 'f') goto yy195;
- if (yych <= 'z') goto yy82;
- goto yy191;
+ if (yych == 'p') goto yy217;
+ if (yych <= 'z') goto yy49;
+ goto yy94;
} else {
- if (yych == '}') goto yy191;
- if (yych <= '~') goto yy82;
- goto yy191;
+ if (yych == '}') goto yy94;
+ if (yych <= '~') goto yy49;
+ goto yy94;
}
}
}
-yy197:
- yych = *++lexer->cursor;
- if (yych == 'm') goto yy207;
- goto yy83;
-yy198:
- yych = *++lexer->cursor;
- if (yych == 'd') goto yy202;
- goto yy83;
-yy199:
- yych = *++lexer->cursor;
- if (yych != 't') goto yy83;
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 242 "src/ast-lexer.c"
- { RETURN(MUT); }
-#line 1461 "src/prebuilt/ast-lexer-gen.c"
-yy202:
- yych = *++lexer->cursor;
- if (yych != 'u') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'l') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'e') goto yy83;
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 426 "src/ast-lexer.c"
- { RETURN(MODULE); }
-#line 1475 "src/prebuilt/ast-lexer-gen.c"
-yy207:
- yych = *++lexer->cursor;
- if (yych != 'o') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'r') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'y') goto yy83;
+yy215:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 428 "src/ast-lexer.c"
- { RETURN(MEMORY); }
-#line 1489 "src/prebuilt/ast-lexer-gen.c"
-yy212:
- yych = *++lexer->cursor;
- if (yych == 'c') goto yy214;
- if (yych != 'o') goto yy83;
- yych = *++lexer->cursor;
- if (yych == 'p') goto yy218;
- goto yy83;
-yy214:
- yych = *++lexer->cursor;
- if (yych != 'a') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'l') goto yy83;
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 424 "src/ast-lexer.c"
- { RETURN(LOCAL); }
-#line 1508 "src/prebuilt/ast-lexer-gen.c"
-yy218:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 249 "src/ast-lexer.c"
- { RETURN(LOOP); }
-#line 1516 "src/prebuilt/ast-lexer-gen.c"
-yy220:
- yych = *++lexer->cursor;
- if (yych == '2') goto yy455;
- goto yy83;
-yy221:
- yych = *++lexer->cursor;
- if (yych == '4') goto yy253;
- goto yy83;
-yy222:
- ++lexer->cursor;
- if ((yych = *lexer->cursor) <= 'Z') {
- if (yych <= ')') {
- if (yych <= '!') {
- if (yych >= '!') goto yy82;
+ if ((lexer->limit - lexer->cursor) < 3) FILL(3);
+ yych = *lexer->cursor;
+ if (yych <= 'F') {
+ if (yych <= '+') {
+ if (yych <= '"') {
+ if (yych == '!') goto yy49;
+ goto yy51;
} else {
- if (yych <= '"') goto yy223;
- if (yych <= '\'') goto yy82;
+ if (yych <= '\'') goto yy49;
+ if (yych <= ')') goto yy51;
+ goto yy49;
}
} else {
- if (yych <= ',') {
- if (yych <= '+') goto yy82;
+ if (yych <= '9') {
+ if (yych <= ',') goto yy51;
+ if (yych <= '/') goto yy49;
+ goto yy215;
} else {
- if (yych != ';') goto yy82;
+ if (yych == ';') goto yy51;
+ if (yych <= '@') goto yy49;
+ goto yy215;
}
}
} else {
- if (yych <= '_') {
+ if (yych <= 'o') {
if (yych <= '\\') {
- if (yych >= '\\') goto yy82;
+ if (yych == '[') goto yy51;
+ goto yy49;
} else {
- if (yych <= ']') goto yy223;
- if (yych <= '^') goto yy82;
- goto yy247;
+ if (yych <= ']') goto yy51;
+ if (yych <= '`') goto yy49;
+ if (yych <= 'f') goto yy215;
+ goto yy49;
}
} else {
- if (yych <= '|') {
- if (yych != '{') goto yy82;
+ if (yych <= '{') {
+ if (yych <= 'p') goto yy217;
+ if (yych <= 'z') goto yy49;
+ goto yy51;
} else {
- if (yych == '~') goto yy82;
+ if (yych == '}') goto yy51;
+ if (yych <= '~') goto yy49;
+ goto yy51;
}
}
}
-yy223:
-#line 245 "src/ast-lexer.c"
- { RETURN(IF); }
-#line 1562 "src/prebuilt/ast-lexer-gen.c"
-yy224:
- yych = *++lexer->cursor;
- if (yych == 'p') goto yy242;
- goto yy83;
-yy225:
+yy217:
yych = *++lexer->cursor;
- if (yych <= 'o') {
- if (yych != 'f') goto yy83;
+ if (yych <= ',') {
+ if (yych == '+') goto yy272;
+ goto yy50;
} else {
- if (yych <= 'p') goto yy229;
- if (yych == 'v') goto yy228;
- goto yy83;
+ if (yych <= '-') goto yy272;
+ if (yych <= '/') goto yy50;
+ if (yych <= '9') goto yy273;
+ goto yy50;
}
-yy226:
+yy218:
+ yych = *++lexer->cursor;
+ if (yych == 'n') goto yy276;
+ goto yy50;
+yy219:
+ yych = *++lexer->cursor;
+ if (yych == 'u') goto yy277;
+ goto yy50;
+yy220:
+ yych = *++lexer->cursor;
+ if (yych == 'r') goto yy278;
+ goto yy50;
+yy221:
+ yych = *++lexer->cursor;
+ if (yych == 'k') goto yy279;
+ goto yy50;
+yy222:
+ yych = *++lexer->cursor;
+ if (yych == 'f') goto yy281;
+ goto yy50;
+yy223:
+ yych = *++lexer->cursor;
+ if (yych == 'a') goto yy283;
+ goto yy50;
+yy224:
++lexer->cursor;
if ((yych = *lexer->cursor) <= 'Z') {
if (yych <= ')') {
if (yych <= '!') {
- if (yych >= '!') goto yy82;
+ if (yych >= '!') goto yy49;
} else {
- if (yych <= '"') goto yy227;
- if (yych <= '\'') goto yy82;
+ if (yych <= '"') goto yy225;
+ if (yych <= '\'') goto yy49;
}
} else {
if (yych <= ',') {
- if (yych <= '+') goto yy82;
+ if (yych <= '+') goto yy49;
} else {
- if (yych != ';') goto yy82;
+ if (yych != ';') goto yy49;
}
}
} else {
- if (yych <= 'i') {
+ if (yych <= '_') {
if (yych <= '\\') {
- if (yych >= '\\') goto yy82;
+ if (yych >= '\\') goto yy49;
} else {
- if (yych <= ']') goto yy227;
- if (yych <= 'h') goto yy82;
- goto yy237;
+ if (yych <= ']') goto yy225;
+ if (yych <= '^') goto yy49;
+ goto yy284;
}
} else {
if (yych <= '|') {
- if (yych != '{') goto yy82;
+ if (yych != '{') goto yy49;
} else {
- if (yych == '~') goto yy82;
+ if (yych == '~') goto yy49;
}
}
}
-yy227:
-#line 226 "src/ast-lexer.c"
- { LITERAL(INFINITY); RETURN(FLOAT); }
-#line 1613 "src/prebuilt/ast-lexer-gen.c"
-yy228:
+yy225:
+#line 253 "src/ast-lexer.c"
+ { RETURN(CALL); }
+#line 2113 "src/prebuilt/ast-lexer-gen.c"
+yy226:
yych = *++lexer->cursor;
- if (yych == 'o') goto yy233;
- goto yy83;
+ if (yych == 'e') goto yy285;
+ goto yy50;
+yy227:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 431 "src/ast-lexer.c"
+ { RETURN(DATA); }
+#line 2125 "src/prebuilt/ast-lexer-gen.c"
yy229:
- yych = *++lexer->cursor;
- if (yych != 'u') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 't') goto yy83;
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 445 "src/ast-lexer.c"
- { RETURN(INPUT); }
-#line 1629 "src/prebuilt/ast-lexer-gen.c"
+#line 256 "src/ast-lexer.c"
+ { RETURN(DROP); }
+#line 2133 "src/prebuilt/ast-lexer-gen.c"
+yy231:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 430 "src/ast-lexer.c"
+ { RETURN(ELEM); }
+#line 2141 "src/prebuilt/ast-lexer-gen.c"
yy233:
- yych = *++lexer->cursor;
- if (yych != 'k') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'e') goto yy83;
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 436 "src/ast-lexer.c"
- { RETURN(INVOKE); }
-#line 1641 "src/prebuilt/ast-lexer-gen.c"
-yy237:
+#line 248 "src/ast-lexer.c"
+ { RETURN(ELSE); }
+#line 2149 "src/prebuilt/ast-lexer-gen.c"
+yy235:
yych = *++lexer->cursor;
- if (yych != 'n') goto yy83;
+ if (yych == 'r') goto yy286;
+ goto yy50;
+yy236:
yych = *++lexer->cursor;
- if (yych != 'i') goto yy83;
+ switch (yych) {
+ case 'a': goto yy287;
+ case 'c': goto yy288;
+ case 'd': goto yy289;
+ case 'e': goto yy290;
+ case 'f': goto yy291;
+ case 'g': goto yy292;
+ case 'l': goto yy293;
+ case 'm': goto yy294;
+ case 'n': goto yy295;
+ case 'r': goto yy296;
+ case 's': goto yy297;
+ case 't': goto yy298;
+ default: goto yy50;
+ }
+yy237:
yych = *++lexer->cursor;
- if (yych != 't') goto yy83;
+ switch (yych) {
+ case 'a': goto yy299;
+ case 'c': goto yy300;
+ case 'd': goto yy301;
+ case 'e': goto yy302;
+ case 'f': goto yy303;
+ case 'g': goto yy304;
+ case 'l': goto yy305;
+ case 'm': goto yy306;
+ case 'n': goto yy307;
+ case 'p': goto yy308;
+ case 'r': goto yy309;
+ case 's': goto yy310;
+ case 't': goto yy311;
+ default: goto yy50;
+ }
+yy238:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 421 "src/ast-lexer.c"
+ { RETURN(FUNC); }
+#line 2196 "src/prebuilt/ast-lexer-gen.c"
+yy240:
yych = *++lexer->cursor;
- if (yych != 'y') goto yy83;
+ if (yych == 'g') goto yy312;
+ if (yych == 'l') goto yy313;
+ goto yy50;
+yy241:
yych = *++lexer->cursor;
- if (yybm[0+yych] & 8) {
- goto yy82;
- }
- goto yy227;
+ if (yych == 'a') goto yy314;
+ goto yy50;
yy242:
yych = *++lexer->cursor;
- if (yych != 'o') goto yy83;
+ if (yych == '_') goto yy315;
+ goto yy50;
+yy243:
yych = *++lexer->cursor;
- if (yych != 'r') goto yy83;
+ switch (yych) {
+ case 'a': goto yy316;
+ case 'c': goto yy317;
+ case 'd': goto yy318;
+ case 'e': goto yy319;
+ case 'g': goto yy320;
+ case 'l': goto yy321;
+ case 'm': goto yy322;
+ case 'n': goto yy323;
+ case 'o': goto yy324;
+ case 'p': goto yy325;
+ case 'r': goto yy326;
+ case 's': goto yy327;
+ case 't': goto yy328;
+ case 'w': goto yy329;
+ case 'x': goto yy330;
+ default: goto yy50;
+ }
+yy244:
yych = *++lexer->cursor;
- if (yych != 't') goto yy83;
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 433 "src/ast-lexer.c"
- { RETURN(IMPORT); }
-#line 1669 "src/prebuilt/ast-lexer-gen.c"
+ switch (yych) {
+ case 'a': goto yy331;
+ case 'c': goto yy332;
+ case 'd': goto yy333;
+ case 'e': goto yy334;
+ case 'g': goto yy335;
+ case 'l': goto yy336;
+ case 'm': goto yy337;
+ case 'n': goto yy338;
+ case 'o': goto yy339;
+ case 'p': goto yy340;
+ case 'r': goto yy341;
+ case 's': goto yy342;
+ case 't': goto yy343;
+ case 'x': goto yy344;
+ default: goto yy50;
+ }
+yy245:
+ yych = *++lexer->cursor;
+ if (yych == 'l') goto yy345;
+ goto yy50;
+yy246:
+ yych = *++lexer->cursor;
+ if (yych == 'r') goto yy346;
+ goto yy50;
yy247:
yych = *++lexer->cursor;
- if (yych != 'e') goto yy83;
+ if (yych == 'n') goto yy347;
+ goto yy50;
+yy248:
yych = *++lexer->cursor;
- if (yych != 'l') goto yy83;
+ if (yych == 't') goto yy348;
+ goto yy50;
+yy249:
yych = *++lexer->cursor;
- if (yych != 's') goto yy83;
+ if (yych == 'k') goto yy350;
+ goto yy50;
+yy250:
yych = *++lexer->cursor;
- if (yych != 'e') goto yy83;
+ if (yych == 'l') goto yy351;
+ goto yy50;
+yy251:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 246 "src/ast-lexer.c"
- { RETURN(IF); }
-#line 1685 "src/prebuilt/ast-lexer-gen.c"
+#line 249 "src/ast-lexer.c"
+ { RETURN(LOOP); }
+#line 2280 "src/prebuilt/ast-lexer-gen.c"
yy253:
- ++lexer->cursor;
- if ((yych = *lexer->cursor) <= ':') {
- if (yych <= ')') {
- if (yych <= '!') {
- if (yych >= '!') goto yy82;
- } else {
- if (yych <= '"') goto yy254;
- if (yych <= '\'') goto yy82;
- }
- } else {
- if (yych <= ',') {
- if (yych <= '+') goto yy82;
- } else {
- if (yych == '.') goto yy255;
- goto yy82;
- }
- }
- } else {
- if (yych <= ']') {
- if (yych <= 'Z') {
- if (yych >= '<') goto yy82;
- } else {
- if (yych == '\\') goto yy82;
- }
- } else {
- if (yych <= '|') {
- if (yych != '{') goto yy82;
- } else {
- if (yych == '~') goto yy82;
- }
- }
- }
+ yych = *++lexer->cursor;
+ if (yych == 'r') goto yy353;
+ goto yy50;
yy254:
-#line 238 "src/ast-lexer.c"
- { TYPE(I64); RETURN(VALUE_TYPE); }
-#line 1722 "src/prebuilt/ast-lexer-gen.c"
+ yych = *++lexer->cursor;
+ if (yych == 'l') goto yy354;
+ goto yy50;
yy255:
yych = *++lexer->cursor;
- switch (yych) {
- case 'a': goto yy261;
- case 'c': goto yy258;
- case 'd': goto yy263;
- case 'e': goto yy259;
- case 'g': goto yy268;
- case 'l': goto yy256;
- case 'm': goto yy262;
- case 'n': goto yy267;
- case 'o': goto yy265;
- case 'p': goto yy260;
- case 'r': goto yy264;
- case 's': goto yy257;
- case 't': goto yy269;
- case 'x': goto yy266;
- default: goto yy83;
- }
+ if (yych == '0') goto yy355;
+ goto yy50;
yy256:
yych = *++lexer->cursor;
- if (yych <= 'n') {
- if (yych == 'e') goto yy419;
- goto yy83;
- } else {
- if (yych <= 'o') goto yy420;
- if (yych == 't') goto yy421;
- goto yy83;
- }
+ if (yych == 'e') goto yy356;
+ goto yy50;
yy257:
yych = *++lexer->cursor;
- if (yych <= 's') {
- if (yych == 'h') goto yy394;
- goto yy83;
- } else {
- if (yych <= 't') goto yy395;
- if (yych <= 'u') goto yy396;
- goto yy83;
- }
+ if (yych == 'u') goto yy357;
+ goto yy50;
yy258:
yych = *++lexer->cursor;
- if (yych <= 'n') {
- if (yych == 'l') goto yy383;
- goto yy83;
- } else {
- if (yych <= 'o') goto yy384;
- if (yych == 't') goto yy385;
- goto yy83;
- }
+ if (yych == 'm') goto yy358;
+ goto yy50;
yy259:
yych = *++lexer->cursor;
- if (yych == 'q') goto yy361;
- if (yych == 'x') goto yy363;
- goto yy83;
+ if (yych == 's') goto yy360;
+ goto yy50;
yy260:
yych = *++lexer->cursor;
- if (yych == 'o') goto yy355;
- goto yy83;
+ if (yych == 'l') goto yy361;
+ goto yy50;
yy261:
yych = *++lexer->cursor;
- if (yych == 'd') goto yy349;
- if (yych == 'n') goto yy350;
- goto yy83;
+ if (yych == 'r') goto yy362;
+ goto yy50;
yy262:
yych = *++lexer->cursor;
- if (yych == 'u') goto yy346;
- goto yy83;
+ if (yych == 'c') goto yy363;
+ goto yy50;
yy263:
yych = *++lexer->cursor;
- if (yych == 'i') goto yy339;
- goto yy83;
+ if (yych == 'g') goto yy364;
+ if (yych == 'l') goto yy365;
+ goto yy50;
yy264:
yych = *++lexer->cursor;
- if (yych == 'e') goto yy312;
- if (yych == 'o') goto yy313;
- goto yy83;
+ if (yych == 't') goto yy366;
+ goto yy50;
yy265:
yych = *++lexer->cursor;
- if (yych == 'r') goto yy310;
- goto yy83;
+ if (yych == 'e') goto yy368;
+ goto yy50;
yy266:
yych = *++lexer->cursor;
- if (yych == 'o') goto yy307;
- goto yy83;
+ if (yych == 'l') goto yy370;
+ goto yy50;
yy267:
- yych = *++lexer->cursor;
- if (yych == 'e') goto yy305;
- goto yy83;
-yy268:
- yych = *++lexer->cursor;
- if (yych == 'e') goto yy293;
- if (yych == 't') goto yy294;
- goto yy83;
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 247 "src/ast-lexer.c"
+ { RETURN(THEN); }
+#line 2345 "src/prebuilt/ast-lexer-gen.c"
yy269:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 420 "src/ast-lexer.c"
+ { RETURN(TYPE); }
+#line 2353 "src/prebuilt/ast-lexer-gen.c"
+yy271:
yych = *++lexer->cursor;
- if (yych != 'r') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'u') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'n') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'c') goto yy83;
- yych = *++lexer->cursor;
- if (yych != '_') goto yy83;
+ if (yych == 'a') goto yy371;
+ goto yy50;
+yy272:
yych = *++lexer->cursor;
- if (yych == 's') goto yy275;
- if (yych == 'u') goto yy276;
- goto yy83;
+ if (yych <= '/') goto yy50;
+ if (yych >= ':') goto yy50;
+yy273:
+ ++lexer->cursor;
+ if (lexer->limit <= lexer->cursor) FILL(1);
+ yych = *lexer->cursor;
+ if (yych <= ':') {
+ if (yych <= ')') {
+ if (yych <= '!') {
+ if (yych >= '!') goto yy49;
+ } else {
+ if (yych <= '"') goto yy275;
+ if (yych <= '\'') goto yy49;
+ }
+ } else {
+ if (yych <= ',') {
+ if (yych <= '+') goto yy49;
+ } else {
+ if (yych <= '/') goto yy49;
+ if (yych <= '9') goto yy273;
+ goto yy49;
+ }
+ }
+ } else {
+ if (yych <= ']') {
+ if (yych <= 'Z') {
+ if (yych >= '<') goto yy49;
+ } else {
+ if (yych == '\\') goto yy49;
+ }
+ } else {
+ if (yych <= '|') {
+ if (yych != '{') goto yy49;
+ } else {
+ if (yych == '~') goto yy49;
+ }
+ }
+ }
yy275:
- yych = *++lexer->cursor;
- if (yych == '/') goto yy285;
- goto yy83;
+#line 225 "src/ast-lexer.c"
+ { LITERAL(HEXFLOAT); RETURN(FLOAT); }
+#line 2401 "src/prebuilt/ast-lexer-gen.c"
yy276:
yych = *++lexer->cursor;
- if (yych != '/') goto yy83;
+ if (yych == '=') goto yy372;
+ goto yy50;
+yy277:
yych = *++lexer->cursor;
- if (yych != 'f') goto yy83;
+ if (yych == 'n') goto yy373;
+ goto yy50;
+yy278:
yych = *++lexer->cursor;
- if (yych == '3') goto yy279;
- if (yych == '6') goto yy280;
- goto yy83;
+ if (yych == 't') goto yy374;
+ goto yy50;
yy279:
- yych = *++lexer->cursor;
- if (yych == '2') goto yy283;
- goto yy83;
-yy280:
- yych = *++lexer->cursor;
- if (yych != '4') goto yy83;
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 401 "src/ast-lexer.c"
- { OPCODE(I64_TRUNC_U_F64); RETURN(CONVERT); }
-#line 1857 "src/prebuilt/ast-lexer-gen.c"
-yy283:
+#line 244 "src/ast-lexer.c"
+ { RETURN(BLOCK); }
+#line 2421 "src/prebuilt/ast-lexer-gen.c"
+yy281:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 399 "src/ast-lexer.c"
- { OPCODE(I64_TRUNC_U_F32); RETURN(CONVERT); }
-#line 1865 "src/prebuilt/ast-lexer-gen.c"
+#line 251 "src/ast-lexer.c"
+ { RETURN(BR_IF); }
+#line 2429 "src/prebuilt/ast-lexer-gen.c"
+yy283:
+ yych = *++lexer->cursor;
+ if (yych == 'b') goto yy375;
+ goto yy50;
+yy284:
+ yych = *++lexer->cursor;
+ if (yych == 'i') goto yy376;
+ goto yy50;
yy285:
yych = *++lexer->cursor;
- if (yych != 'f') goto yy83;
+ if (yych == 'n') goto yy377;
+ goto yy50;
+yy286:
yych = *++lexer->cursor;
- if (yych == '3') goto yy287;
- if (yych == '6') goto yy288;
- goto yy83;
+ if (yych == 't') goto yy378;
+ goto yy50;
yy287:
yych = *++lexer->cursor;
- if (yych == '2') goto yy291;
- goto yy83;
+ if (yych == 'b') goto yy380;
+ if (yych == 'd') goto yy381;
+ goto yy50;
yy288:
yych = *++lexer->cursor;
- if (yych != '4') goto yy83;
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 397 "src/ast-lexer.c"
- { OPCODE(I64_TRUNC_S_F64); RETURN(CONVERT); }
-#line 1886 "src/prebuilt/ast-lexer-gen.c"
+ if (yych == 'e') goto yy382;
+ if (yych == 'o') goto yy383;
+ goto yy50;
+yy289:
+ yych = *++lexer->cursor;
+ if (yych == 'e') goto yy384;
+ if (yych == 'i') goto yy385;
+ goto yy50;
+yy290:
+ yych = *++lexer->cursor;
+ if (yych == 'q') goto yy386;
+ goto yy50;
yy291:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 395 "src/ast-lexer.c"
- { OPCODE(I64_TRUNC_S_F32); RETURN(CONVERT); }
-#line 1894 "src/prebuilt/ast-lexer-gen.c"
+ yych = *++lexer->cursor;
+ if (yych == 'l') goto yy388;
+ goto yy50;
+yy292:
+ yych = *++lexer->cursor;
+ if (yych == 'e') goto yy389;
+ if (yych == 't') goto yy391;
+ goto yy50;
yy293:
yych = *++lexer->cursor;
- if (yych == '_') goto yy300;
- goto yy83;
+ if (yych <= 'n') {
+ if (yych == 'e') goto yy393;
+ goto yy50;
+ } else {
+ if (yych <= 'o') goto yy395;
+ if (yych == 't') goto yy396;
+ goto yy50;
+ }
yy294:
yych = *++lexer->cursor;
- if (yych != '_') goto yy83;
+ if (yych <= 'h') {
+ if (yych == 'a') goto yy398;
+ goto yy50;
+ } else {
+ if (yych <= 'i') goto yy399;
+ if (yych == 'u') goto yy400;
+ goto yy50;
+ }
+yy295:
yych = *++lexer->cursor;
- if (yych == 's') goto yy296;
- if (yych == 'u') goto yy298;
- goto yy83;
+ if (yych == 'e') goto yy401;
+ goto yy50;
yy296:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ yych = *++lexer->cursor;
+ if (yych == 'e') goto yy403;
+ goto yy50;
+yy297:
+ yych = *++lexer->cursor;
+ if (yych <= 's') {
+ if (yych == 'q') goto yy404;
+ goto yy50;
+ } else {
+ if (yych <= 't') goto yy405;
+ if (yych <= 'u') goto yy406;
+ goto yy50;
}
-#line 372 "src/ast-lexer.c"
- { OPCODE(I64_GT_S); RETURN(COMPARE); }
-#line 1913 "src/prebuilt/ast-lexer-gen.c"
yy298:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 374 "src/ast-lexer.c"
- { OPCODE(I64_GT_U); RETURN(COMPARE); }
-#line 1921 "src/prebuilt/ast-lexer-gen.c"
+ yych = *++lexer->cursor;
+ if (yych == 'r') goto yy407;
+ goto yy50;
+yy299:
+ yych = *++lexer->cursor;
+ if (yych == 'b') goto yy408;
+ if (yych == 'd') goto yy409;
+ goto yy50;
yy300:
yych = *++lexer->cursor;
- if (yych == 's') goto yy301;
- if (yych == 'u') goto yy303;
- goto yy83;
+ if (yych == 'e') goto yy410;
+ if (yych == 'o') goto yy411;
+ goto yy50;
yy301:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 376 "src/ast-lexer.c"
- { OPCODE(I64_GE_S); RETURN(COMPARE); }
-#line 1934 "src/prebuilt/ast-lexer-gen.c"
+ yych = *++lexer->cursor;
+ if (yych == 'i') goto yy412;
+ goto yy50;
+yy302:
+ yych = *++lexer->cursor;
+ if (yych == 'q') goto yy413;
+ goto yy50;
yy303:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 378 "src/ast-lexer.c"
- { OPCODE(I64_GE_U); RETURN(COMPARE); }
-#line 1942 "src/prebuilt/ast-lexer-gen.c"
+ yych = *++lexer->cursor;
+ if (yych == 'l') goto yy415;
+ goto yy50;
+yy304:
+ yych = *++lexer->cursor;
+ if (yych == 'e') goto yy416;
+ if (yych == 't') goto yy418;
+ goto yy50;
yy305:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ yych = *++lexer->cursor;
+ if (yych <= 'n') {
+ if (yych == 'e') goto yy420;
+ goto yy50;
+ } else {
+ if (yych <= 'o') goto yy422;
+ if (yych == 't') goto yy423;
+ goto yy50;
}
-#line 362 "src/ast-lexer.c"
- { OPCODE(I64_NE); RETURN(COMPARE); }
-#line 1950 "src/prebuilt/ast-lexer-gen.c"
-yy307:
+yy306:
yych = *++lexer->cursor;
- if (yych != 'r') goto yy83;
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yych <= 'h') {
+ if (yych == 'a') goto yy425;
+ goto yy50;
+ } else {
+ if (yych <= 'i') goto yy426;
+ if (yych == 'u') goto yy427;
+ goto yy50;
}
-#line 334 "src/ast-lexer.c"
- { OPCODE(I64_XOR); RETURN(BINARY); }
-#line 1960 "src/prebuilt/ast-lexer-gen.c"
+yy307:
+ yych = *++lexer->cursor;
+ if (yych == 'e') goto yy428;
+ goto yy50;
+yy308:
+ yych = *++lexer->cursor;
+ if (yych == 'r') goto yy430;
+ goto yy50;
+yy309:
+ yych = *++lexer->cursor;
+ if (yych == 'e') goto yy431;
+ goto yy50;
yy310:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ yych = *++lexer->cursor;
+ if (yych <= 's') {
+ if (yych == 'q') goto yy432;
+ goto yy50;
+ } else {
+ if (yych <= 't') goto yy433;
+ if (yych <= 'u') goto yy434;
+ goto yy50;
}
-#line 332 "src/ast-lexer.c"
- { OPCODE(I64_OR); RETURN(BINARY); }
-#line 1968 "src/prebuilt/ast-lexer-gen.c"
+yy311:
+ yych = *++lexer->cursor;
+ if (yych == 'r') goto yy435;
+ goto yy50;
yy312:
yych = *++lexer->cursor;
- if (yych == 'i') goto yy320;
- if (yych == 'm') goto yy319;
- goto yy83;
+ if (yych == 'l') goto yy436;
+ goto yy50;
yy313:
yych = *++lexer->cursor;
- if (yych != 't') goto yy83;
+ if (yych == 'o') goto yy437;
+ goto yy50;
+yy314:
yych = *++lexer->cursor;
- if (yych == 'l') goto yy315;
- if (yych == 'r') goto yy317;
- goto yy83;
+ if (yych == 'l') goto yy438;
+ goto yy50;
yy315:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 342 "src/ast-lexer.c"
- { OPCODE(I64_ROTL); RETURN(BINARY); }
-#line 1988 "src/prebuilt/ast-lexer-gen.c"
+ yych = *++lexer->cursor;
+ if (yych == 'm') goto yy440;
+ goto yy50;
+yy316:
+ yych = *++lexer->cursor;
+ if (yych == 'd') goto yy441;
+ if (yych == 'n') goto yy442;
+ goto yy50;
yy317:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ yych = *++lexer->cursor;
+ if (yych <= 'n') {
+ if (yych == 'l') goto yy443;
+ goto yy50;
+ } else {
+ if (yych <= 'o') goto yy444;
+ if (yych == 't') goto yy445;
+ goto yy50;
}
-#line 344 "src/ast-lexer.c"
- { OPCODE(I64_ROTR); RETURN(BINARY); }
-#line 1996 "src/prebuilt/ast-lexer-gen.c"
+yy318:
+ yych = *++lexer->cursor;
+ if (yych == 'i') goto yy446;
+ goto yy50;
yy319:
yych = *++lexer->cursor;
- if (yych == '_') goto yy334;
- goto yy83;
+ if (yych == 'q') goto yy447;
+ goto yy50;
yy320:
yych = *++lexer->cursor;
- if (yych != 'n') goto yy83;
+ if (yych == 'e') goto yy449;
+ if (yych == 't') goto yy450;
+ goto yy50;
+yy321:
+ yych = *++lexer->cursor;
+ if (yych <= 'n') {
+ if (yych == 'e') goto yy451;
+ goto yy50;
+ } else {
+ if (yych <= 'o') goto yy452;
+ if (yych == 't') goto yy453;
+ goto yy50;
+ }
+yy322:
yych = *++lexer->cursor;
- if (yych != 't') goto yy83;
+ if (yych == 'u') goto yy454;
+ goto yy50;
+yy323:
yych = *++lexer->cursor;
- if (yych != 'e') goto yy83;
+ if (yych == 'e') goto yy455;
+ goto yy50;
+yy324:
yych = *++lexer->cursor;
- if (yych != 'r') goto yy83;
+ if (yych == 'r') goto yy457;
+ goto yy50;
+yy325:
yych = *++lexer->cursor;
- if (yych != 'p') goto yy83;
+ if (yych == 'o') goto yy459;
+ goto yy50;
+yy326:
yych = *++lexer->cursor;
- if (yych != 'r') goto yy83;
+ if (yych == 'e') goto yy460;
+ if (yych == 'o') goto yy461;
+ goto yy50;
+yy327:
yych = *++lexer->cursor;
- if (yych != 'e') goto yy83;
+ if (yych <= 's') {
+ if (yych == 'h') goto yy462;
+ goto yy50;
+ } else {
+ if (yych <= 't') goto yy463;
+ if (yych <= 'u') goto yy464;
+ goto yy50;
+ }
+yy328:
yych = *++lexer->cursor;
- if (yych != 't') goto yy83;
+ if (yych == 'r') goto yy465;
+ goto yy50;
+yy329:
yych = *++lexer->cursor;
- if (yych != '/') goto yy83;
+ if (yych == 'r') goto yy466;
+ goto yy50;
+yy330:
yych = *++lexer->cursor;
- if (yych != 'f') goto yy83;
+ if (yych == 'o') goto yy467;
+ goto yy50;
+yy331:
yych = *++lexer->cursor;
- if (yych != '6') goto yy83;
+ if (yych == 'd') goto yy468;
+ if (yych == 'n') goto yy469;
+ goto yy50;
+yy332:
yych = *++lexer->cursor;
- if (yych != '4') goto yy83;
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yych <= 'n') {
+ if (yych == 'l') goto yy470;
+ goto yy50;
+ } else {
+ if (yych <= 'o') goto yy471;
+ if (yych == 't') goto yy472;
+ goto yy50;
}
-#line 415 "src/ast-lexer.c"
- { OPCODE(I64_REINTERPRET_F64); RETURN(CONVERT); }
-#line 2032 "src/prebuilt/ast-lexer-gen.c"
+yy333:
+ yych = *++lexer->cursor;
+ if (yych == 'i') goto yy473;
+ goto yy50;
yy334:
yych = *++lexer->cursor;
- if (yych == 's') goto yy335;
- if (yych == 'u') goto yy337;
- goto yy83;
+ if (yych == 'q') goto yy474;
+ if (yych == 'x') goto yy476;
+ goto yy50;
yy335:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ yych = *++lexer->cursor;
+ if (yych == 'e') goto yy477;
+ if (yych == 't') goto yy478;
+ goto yy50;
+yy336:
+ yych = *++lexer->cursor;
+ if (yych <= 'n') {
+ if (yych == 'e') goto yy479;
+ goto yy50;
+ } else {
+ if (yych <= 'o') goto yy480;
+ if (yych == 't') goto yy481;
+ goto yy50;
}
-#line 326 "src/ast-lexer.c"
- { OPCODE(I64_REM_S); RETURN(BINARY); }
-#line 2045 "src/prebuilt/ast-lexer-gen.c"
yy337:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 328 "src/ast-lexer.c"
- { OPCODE(I64_REM_U); RETURN(BINARY); }
-#line 2053 "src/prebuilt/ast-lexer-gen.c"
+ yych = *++lexer->cursor;
+ if (yych == 'u') goto yy482;
+ goto yy50;
+yy338:
+ yych = *++lexer->cursor;
+ if (yych == 'e') goto yy483;
+ goto yy50;
yy339:
yych = *++lexer->cursor;
- if (yych != 'v') goto yy83;
+ if (yych == 'r') goto yy485;
+ goto yy50;
+yy340:
yych = *++lexer->cursor;
- if (yych != '_') goto yy83;
+ if (yych == 'o') goto yy487;
+ goto yy50;
+yy341:
yych = *++lexer->cursor;
- if (yych == 's') goto yy342;
- if (yych == 'u') goto yy344;
- goto yy83;
+ if (yych == 'e') goto yy488;
+ if (yych == 'o') goto yy489;
+ goto yy50;
yy342:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ yych = *++lexer->cursor;
+ if (yych <= 's') {
+ if (yych == 'h') goto yy490;
+ goto yy50;
+ } else {
+ if (yych <= 't') goto yy491;
+ if (yych <= 'u') goto yy492;
+ goto yy50;
}
-#line 322 "src/ast-lexer.c"
- { OPCODE(I64_DIV_S); RETURN(BINARY); }
-#line 2070 "src/prebuilt/ast-lexer-gen.c"
+yy343:
+ yych = *++lexer->cursor;
+ if (yych == 'r') goto yy493;
+ goto yy50;
yy344:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 324 "src/ast-lexer.c"
- { OPCODE(I64_DIV_U); RETURN(BINARY); }
-#line 2078 "src/prebuilt/ast-lexer-gen.c"
+ yych = *++lexer->cursor;
+ if (yych == 'o') goto yy494;
+ goto yy50;
+yy345:
+ yych = *++lexer->cursor;
+ if (yych == 's') goto yy495;
+ goto yy50;
yy346:
yych = *++lexer->cursor;
- if (yych != 'l') goto yy83;
+ if (yych == 't') goto yy496;
+ goto yy50;
+yy347:
+ yych = *++lexer->cursor;
+ if (yych == 'i') goto yy498;
+ goto yy50;
+yy348:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 320 "src/ast-lexer.c"
- { OPCODE(I64_MUL); RETURN(BINARY); }
-#line 2088 "src/prebuilt/ast-lexer-gen.c"
-yy349:
- yych = *++lexer->cursor;
- if (yych == 'd') goto yy353;
- goto yy83;
+#line 445 "src/ast-lexer.c"
+ { RETURN(INPUT); }
+#line 2783 "src/prebuilt/ast-lexer-gen.c"
yy350:
yych = *++lexer->cursor;
- if (yych != 'd') goto yy83;
+ if (yych == 'e') goto yy499;
+ goto yy50;
+yy351:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 330 "src/ast-lexer.c"
- { OPCODE(I64_AND); RETURN(BINARY); }
-#line 2102 "src/prebuilt/ast-lexer-gen.c"
+#line 424 "src/ast-lexer.c"
+ { RETURN(LOCAL); }
+#line 2795 "src/prebuilt/ast-lexer-gen.c"
yy353:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 316 "src/ast-lexer.c"
- { OPCODE(I64_ADD); RETURN(BINARY); }
-#line 2110 "src/prebuilt/ast-lexer-gen.c"
-yy355:
yych = *++lexer->cursor;
- if (yych != 'p') goto yy83;
+ if (yych == 'y') goto yy501;
+ goto yy50;
+yy354:
yych = *++lexer->cursor;
- if (yych != 'c') goto yy83;
+ if (yych == 'e') goto yy503;
+ goto yy50;
+yy355:
+ yych = *++lexer->cursor;
+ if (yych == 'x') goto yy505;
+ goto yy50;
+yy356:
yych = *++lexer->cursor;
- if (yych != 'n') goto yy83;
+ if (yych == 't') goto yy506;
+ goto yy50;
+yy357:
yych = *++lexer->cursor;
- if (yych != 't') goto yy83;
+ if (yych == 't') goto yy508;
+ goto yy50;
+yy358:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 300 "src/ast-lexer.c"
- { OPCODE(I64_POPCNT); RETURN(UNARY); }
-#line 2126 "src/prebuilt/ast-lexer-gen.c"
+#line 422 "src/ast-lexer.c"
+ { RETURN(PARAM); }
+#line 2823 "src/prebuilt/ast-lexer-gen.c"
+yy360:
+ yych = *++lexer->cursor;
+ if (yych == 't') goto yy510;
+ goto yy50;
yy361:
- ++lexer->cursor;
- if ((yych = *lexer->cursor) <= 'Z') {
- if (yych <= ')') {
- if (yych <= '!') {
- if (yych >= '!') goto yy82;
- } else {
- if (yych <= '"') goto yy362;
- if (yych <= '\'') goto yy82;
- }
- } else {
- if (yych <= ',') {
- if (yych <= '+') goto yy82;
- } else {
- if (yych != ';') goto yy82;
- }
- }
- } else {
- if (yych <= 'z') {
- if (yych <= '\\') {
- if (yych >= '\\') goto yy82;
- } else {
- if (yych <= ']') goto yy362;
- if (yych <= 'y') goto yy82;
- goto yy381;
- }
- } else {
- if (yych <= '|') {
- if (yych >= '|') goto yy82;
- } else {
- if (yych == '~') goto yy82;
- }
- }
- }
+ yych = *++lexer->cursor;
+ if (yych == 't') goto yy511;
+ goto yy50;
yy362:
-#line 360 "src/ast-lexer.c"
- { OPCODE(I64_EQ); RETURN(COMPARE); }
-#line 2164 "src/prebuilt/ast-lexer-gen.c"
+ yych = *++lexer->cursor;
+ if (yych == 'n') goto yy513;
+ goto yy50;
yy363:
yych = *++lexer->cursor;
- if (yych != 't') goto yy83;
+ if (yych == 't') goto yy515;
+ goto yy50;
+yy364:
yych = *++lexer->cursor;
- if (yych != 'e') goto yy83;
+ if (yych == 'l') goto yy517;
+ goto yy50;
+yy365:
yych = *++lexer->cursor;
- if (yych != 'n') goto yy83;
+ if (yych == 'o') goto yy518;
+ goto yy50;
+yy366:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 429 "src/ast-lexer.c"
+ { RETURN(START); }
+#line 2855 "src/prebuilt/ast-lexer-gen.c"
+yy368:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 427 "src/ast-lexer.c"
+ { RETURN(TABLE); }
+#line 2863 "src/prebuilt/ast-lexer-gen.c"
+yy370:
yych = *++lexer->cursor;
- if (yych != 'd') goto yy83;
+ if (yych == 'o') goto yy519;
+ goto yy50;
+yy371:
yych = *++lexer->cursor;
- if (yych != '_') goto yy83;
+ if (yych == 'c') goto yy520;
+ goto yy50;
+yy372:
yych = *++lexer->cursor;
- if (yych == 's') goto yy369;
- if (yych == 'u') goto yy370;
- goto yy83;
-yy369:
+ if (yych <= '/') goto yy50;
+ if (yych <= '0') goto yy521;
+ if (yych <= '9') goto yy523;
+ goto yy50;
+yy373:
yych = *++lexer->cursor;
- if (yych == '/') goto yy376;
- goto yy83;
-yy370:
+ if (yych == 'c') goto yy525;
+ goto yy50;
+yy374:
yych = *++lexer->cursor;
- if (yych != '/') goto yy83;
+ if (yych == '_') goto yy527;
+ goto yy50;
+yy375:
yych = *++lexer->cursor;
- if (yych != 'i') goto yy83;
+ if (yych == 'l') goto yy528;
+ goto yy50;
+yy376:
yych = *++lexer->cursor;
- if (yych != '3') goto yy83;
+ if (yych <= 'l') goto yy50;
+ if (yych <= 'm') goto yy529;
+ if (yych <= 'n') goto yy530;
+ goto yy50;
+yy377:
yych = *++lexer->cursor;
- if (yych != '2') goto yy83;
+ if (yych == 't') goto yy531;
+ goto yy50;
+yy378:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 392 "src/ast-lexer.c"
- { OPCODE(I64_EXTEND_U_I32); RETURN(CONVERT); }
-#line 2199 "src/prebuilt/ast-lexer-gen.c"
-yy376:
+#line 434 "src/ast-lexer.c"
+ { RETURN(EXPORT); }
+#line 2907 "src/prebuilt/ast-lexer-gen.c"
+yy380:
yych = *++lexer->cursor;
- if (yych != 'i') goto yy83;
+ if (yych == 's') goto yy532;
+ goto yy50;
+yy381:
yych = *++lexer->cursor;
- if (yych != '3') goto yy83;
+ if (yych == 'd') goto yy534;
+ goto yy50;
+yy382:
yych = *++lexer->cursor;
- if (yych != '2') goto yy83;
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 391 "src/ast-lexer.c"
- { OPCODE(I64_EXTEND_S_I32); RETURN(CONVERT); }
-#line 2213 "src/prebuilt/ast-lexer-gen.c"
-yy381:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 294 "src/ast-lexer.c"
- { OPCODE(I64_EQZ); RETURN(CONVERT); }
-#line 2221 "src/prebuilt/ast-lexer-gen.c"
+ if (yych == 'i') goto yy536;
+ goto yy50;
yy383:
yych = *++lexer->cursor;
- if (yych == 'z') goto yy392;
- goto yy83;
+ if (yych == 'n') goto yy537;
+ if (yych == 'p') goto yy538;
+ goto yy50;
yy384:
yych = *++lexer->cursor;
- if (yych == 'n') goto yy388;
- goto yy83;
+ if (yych == 'm') goto yy539;
+ goto yy50;
yy385:
yych = *++lexer->cursor;
- if (yych != 'z') goto yy83;
+ if (yych == 'v') goto yy540;
+ goto yy50;
+yy386:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 298 "src/ast-lexer.c"
- { OPCODE(I64_CTZ); RETURN(UNARY); }
-#line 2239 "src/prebuilt/ast-lexer-gen.c"
+#line 379 "src/ast-lexer.c"
+ { OPCODE(F32_EQ); RETURN(COMPARE); }
+#line 2940 "src/prebuilt/ast-lexer-gen.c"
yy388:
yych = *++lexer->cursor;
- if (yych != 's') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 't') goto yy83;
+ if (yych == 'o') goto yy542;
+ goto yy50;
+yy389:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 290 "src/ast-lexer.c"
- { TYPE(I64); RETURN(CONST); }
-#line 2251 "src/prebuilt/ast-lexer-gen.c"
-yy392:
+#line 389 "src/ast-lexer.c"
+ { OPCODE(F32_GE); RETURN(COMPARE); }
+#line 2952 "src/prebuilt/ast-lexer-gen.c"
+yy391:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 296 "src/ast-lexer.c"
- { OPCODE(I64_CLZ); RETURN(UNARY); }
-#line 2259 "src/prebuilt/ast-lexer-gen.c"
-yy394:
- yych = *++lexer->cursor;
- if (yych == 'l') goto yy411;
- if (yych == 'r') goto yy413;
- goto yy83;
+#line 387 "src/ast-lexer.c"
+ { OPCODE(F32_GT); RETURN(COMPARE); }
+#line 2960 "src/prebuilt/ast-lexer-gen.c"
+yy393:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 385 "src/ast-lexer.c"
+ { OPCODE(F32_LE); RETURN(COMPARE); }
+#line 2968 "src/prebuilt/ast-lexer-gen.c"
yy395:
yych = *++lexer->cursor;
- if (yych == 'o') goto yy399;
- goto yy83;
+ if (yych == 'a') goto yy543;
+ goto yy50;
yy396:
- yych = *++lexer->cursor;
- if (yych != 'b') goto yy83;
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 318 "src/ast-lexer.c"
- { OPCODE(I64_SUB); RETURN(BINARY); }
-#line 2278 "src/prebuilt/ast-lexer-gen.c"
+#line 383 "src/ast-lexer.c"
+ { OPCODE(F32_LT); RETURN(COMPARE); }
+#line 2980 "src/prebuilt/ast-lexer-gen.c"
+yy398:
+ yych = *++lexer->cursor;
+ if (yych == 'x') goto yy544;
+ goto yy50;
yy399:
yych = *++lexer->cursor;
- if (yych != 'r') goto yy83;
+ if (yych == 'n') goto yy546;
+ goto yy50;
+yy400:
yych = *++lexer->cursor;
- if (yych != 'e') goto yy83;
+ if (yych == 'l') goto yy548;
+ goto yy50;
+yy401:
++lexer->cursor;
- if ((yych = *lexer->cursor) <= '7') {
- if (yych <= '+') {
- if (yych <= '"') {
- if (yych == '!') goto yy82;
+ if ((yych = *lexer->cursor) <= '[') {
+ if (yych <= ')') {
+ if (yych <= '!') {
+ if (yych >= '!') goto yy49;
} else {
- if (yych <= '\'') goto yy82;
- if (yych >= '*') goto yy82;
+ if (yych <= '"') goto yy402;
+ if (yych <= '\'') goto yy49;
}
} else {
- if (yych <= '1') {
- if (yych <= ',') goto yy402;
- if (yych <= '0') goto yy82;
- goto yy403;
+ if (yych <= ':') {
+ if (yych != ',') goto yy49;
} else {
- if (yych == '3') goto yy404;
- goto yy82;
+ if (yych <= ';') goto yy402;
+ if (yych <= 'Z') goto yy49;
}
}
} else {
- if (yych <= '\\') {
- if (yych <= ';') {
- if (yych <= '8') goto yy405;
- if (yych <= ':') goto yy82;
+ if (yych <= 'g') {
+ if (yych <= '`') {
+ if (yych != ']') goto yy49;
} else {
- if (yych != '[') goto yy82;
+ if (yych <= 'a') goto yy550;
+ if (yych <= 'f') goto yy49;
+ goto yy551;
}
} else {
- if (yych <= '{') {
- if (yych <= ']') goto yy402;
- if (yych <= 'z') goto yy82;
+ if (yych <= '|') {
+ if (yych != '{') goto yy49;
} else {
- if (yych == '}') goto yy402;
- if (yych <= '~') goto yy82;
+ if (yych == '~') goto yy49;
}
}
}
yy402:
-#line 269 "src/ast-lexer.c"
- { OPCODE(I64_STORE); RETURN(STORE); }
-#line 2324 "src/prebuilt/ast-lexer-gen.c"
+#line 381 "src/ast-lexer.c"
+ { OPCODE(F32_NE); RETURN(COMPARE); }
+#line 3031 "src/prebuilt/ast-lexer-gen.c"
yy403:
yych = *++lexer->cursor;
- if (yych == '6') goto yy409;
- goto yy83;
+ if (yych == 'i') goto yy553;
+ goto yy50;
yy404:
yych = *++lexer->cursor;
- if (yych == '2') goto yy407;
- goto yy83;
+ if (yych == 'r') goto yy554;
+ goto yy50;
yy405:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 283 "src/ast-lexer.c"
- { OPCODE(I64_STORE8); RETURN(STORE); }
-#line 2340 "src/prebuilt/ast-lexer-gen.c"
+ yych = *++lexer->cursor;
+ if (yych == 'o') goto yy555;
+ goto yy50;
+yy406:
+ yych = *++lexer->cursor;
+ if (yych == 'b') goto yy556;
+ goto yy50;
yy407:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 286 "src/ast-lexer.c"
- { OPCODE(I64_STORE32); RETURN(STORE); }
-#line 2348 "src/prebuilt/ast-lexer-gen.c"
+ yych = *++lexer->cursor;
+ if (yych == 'u') goto yy558;
+ goto yy50;
+yy408:
+ yych = *++lexer->cursor;
+ if (yych == 's') goto yy559;
+ goto yy50;
yy409:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 285 "src/ast-lexer.c"
- { OPCODE(I64_STORE16); RETURN(STORE); }
-#line 2356 "src/prebuilt/ast-lexer-gen.c"
+ yych = *++lexer->cursor;
+ if (yych == 'd') goto yy561;
+ goto yy50;
+yy410:
+ yych = *++lexer->cursor;
+ if (yych == 'i') goto yy563;
+ goto yy50;
yy411:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 336 "src/ast-lexer.c"
- { OPCODE(I64_SHL); RETURN(BINARY); }
-#line 2364 "src/prebuilt/ast-lexer-gen.c"
-yy413:
yych = *++lexer->cursor;
- if (yych != '_') goto yy83;
+ if (yych == 'n') goto yy564;
+ if (yych == 'p') goto yy565;
+ goto yy50;
+yy412:
yych = *++lexer->cursor;
- if (yych == 's') goto yy415;
- if (yych == 'u') goto yy417;
- goto yy83;
+ if (yych == 'v') goto yy566;
+ goto yy50;
+yy413:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 380 "src/ast-lexer.c"
+ { OPCODE(F64_EQ); RETURN(COMPARE); }
+#line 3080 "src/prebuilt/ast-lexer-gen.c"
yy415:
+ yych = *++lexer->cursor;
+ if (yych == 'o') goto yy568;
+ goto yy50;
+yy416:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 338 "src/ast-lexer.c"
- { OPCODE(I64_SHR_S); RETURN(BINARY); }
-#line 2379 "src/prebuilt/ast-lexer-gen.c"
-yy417:
+#line 390 "src/ast-lexer.c"
+ { OPCODE(F64_GE); RETURN(COMPARE); }
+#line 3092 "src/prebuilt/ast-lexer-gen.c"
+yy418:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 340 "src/ast-lexer.c"
- { OPCODE(I64_SHR_U); RETURN(BINARY); }
-#line 2387 "src/prebuilt/ast-lexer-gen.c"
-yy419:
- yych = *++lexer->cursor;
- if (yych == '_') goto yy450;
- goto yy83;
+#line 388 "src/ast-lexer.c"
+ { OPCODE(F64_GT); RETURN(COMPARE); }
+#line 3100 "src/prebuilt/ast-lexer-gen.c"
yy420:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 386 "src/ast-lexer.c"
+ { OPCODE(F64_LE); RETURN(COMPARE); }
+#line 3108 "src/prebuilt/ast-lexer-gen.c"
+yy422:
yych = *++lexer->cursor;
- if (yych == 'a') goto yy427;
- goto yy83;
-yy421:
- yych = *++lexer->cursor;
- if (yych != '_') goto yy83;
- yych = *++lexer->cursor;
- if (yych == 's') goto yy423;
- if (yych == 'u') goto yy425;
- goto yy83;
+ if (yych == 'a') goto yy569;
+ goto yy50;
yy423:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 364 "src/ast-lexer.c"
- { OPCODE(I64_LT_S); RETURN(COMPARE); }
-#line 2410 "src/prebuilt/ast-lexer-gen.c"
+#line 384 "src/ast-lexer.c"
+ { OPCODE(F64_LT); RETURN(COMPARE); }
+#line 3120 "src/prebuilt/ast-lexer-gen.c"
yy425:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 366 "src/ast-lexer.c"
- { OPCODE(I64_LT_U); RETURN(COMPARE); }
-#line 2418 "src/prebuilt/ast-lexer-gen.c"
+ yych = *++lexer->cursor;
+ if (yych == 'x') goto yy570;
+ goto yy50;
+yy426:
+ yych = *++lexer->cursor;
+ if (yych == 'n') goto yy572;
+ goto yy50;
yy427:
yych = *++lexer->cursor;
- if (yych != 'd') goto yy83;
+ if (yych == 'l') goto yy574;
+ goto yy50;
+yy428:
++lexer->cursor;
- if ((yych = *lexer->cursor) <= '7') {
- if (yych <= '+') {
- if (yych <= '"') {
- if (yych == '!') goto yy82;
+ if ((yych = *lexer->cursor) <= '[') {
+ if (yych <= ')') {
+ if (yych <= '!') {
+ if (yych >= '!') goto yy49;
} else {
- if (yych <= '\'') goto yy82;
- if (yych >= '*') goto yy82;
+ if (yych <= '"') goto yy429;
+ if (yych <= '\'') goto yy49;
}
} else {
- if (yych <= '1') {
- if (yych <= ',') goto yy429;
- if (yych <= '0') goto yy82;
- goto yy431;
+ if (yych <= ':') {
+ if (yych != ',') goto yy49;
} else {
- if (yych == '3') goto yy432;
- goto yy82;
+ if (yych <= ';') goto yy429;
+ if (yych <= 'Z') goto yy49;
}
}
} else {
- if (yych <= '\\') {
- if (yych <= ';') {
- if (yych <= '8') goto yy430;
- if (yych <= ':') goto yy82;
+ if (yych <= 'g') {
+ if (yych <= '`') {
+ if (yych != ']') goto yy49;
} else {
- if (yych != '[') goto yy82;
+ if (yych <= 'a') goto yy576;
+ if (yych <= 'f') goto yy49;
+ goto yy577;
}
} else {
- if (yych <= '{') {
- if (yych <= ']') goto yy429;
- if (yych <= 'z') goto yy82;
+ if (yych <= '|') {
+ if (yych != '{') goto yy49;
} else {
- if (yych == '}') goto yy429;
- if (yych <= '~') goto yy82;
+ if (yych == '~') goto yy49;
}
}
}
yy429:
-#line 265 "src/ast-lexer.c"
- { OPCODE(I64_LOAD); RETURN(LOAD); }
-#line 2462 "src/prebuilt/ast-lexer-gen.c"
+#line 382 "src/ast-lexer.c"
+ { OPCODE(F64_NE); RETURN(COMPARE); }
+#line 3171 "src/prebuilt/ast-lexer-gen.c"
yy430:
yych = *++lexer->cursor;
- if (yych == '_') goto yy445;
- goto yy83;
+ if (yych == 'o') goto yy579;
+ goto yy50;
yy431:
yych = *++lexer->cursor;
- if (yych == '6') goto yy439;
- goto yy83;
+ if (yych == 'i') goto yy580;
+ goto yy50;
yy432:
yych = *++lexer->cursor;
- if (yych != '2') goto yy83;
+ if (yych == 'r') goto yy581;
+ goto yy50;
+yy433:
yych = *++lexer->cursor;
- if (yych != '_') goto yy83;
+ if (yych == 'o') goto yy582;
+ goto yy50;
+yy434:
yych = *++lexer->cursor;
- if (yych == 's') goto yy435;
- if (yych == 'u') goto yy437;
- goto yy83;
+ if (yych == 'b') goto yy583;
+ goto yy50;
yy435:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 280 "src/ast-lexer.c"
- { OPCODE(I64_LOAD32_S); RETURN(LOAD); }
-#line 2487 "src/prebuilt/ast-lexer-gen.c"
+ yych = *++lexer->cursor;
+ if (yych == 'u') goto yy585;
+ goto yy50;
+yy436:
+ yych = *++lexer->cursor;
+ if (yych == 'o') goto yy586;
+ goto yy50;
yy437:
+ yych = *++lexer->cursor;
+ if (yych == 'c') goto yy587;
+ goto yy50;
+yy438:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 281 "src/ast-lexer.c"
- { OPCODE(I64_LOAD32_U); RETURN(LOAD); }
-#line 2495 "src/prebuilt/ast-lexer-gen.c"
-yy439:
- yych = *++lexer->cursor;
- if (yych != '_') goto yy83;
+#line 425 "src/ast-lexer.c"
+ { RETURN(GLOBAL); }
+#line 3211 "src/prebuilt/ast-lexer-gen.c"
+yy440:
yych = *++lexer->cursor;
- if (yych == 's') goto yy441;
- if (yych == 'u') goto yy443;
- goto yy83;
+ if (yych == 'e') goto yy588;
+ goto yy50;
yy441:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 277 "src/ast-lexer.c"
- { OPCODE(I64_LOAD16_S); RETURN(LOAD); }
-#line 2510 "src/prebuilt/ast-lexer-gen.c"
+ yych = *++lexer->cursor;
+ if (yych == 'd') goto yy589;
+ goto yy50;
+yy442:
+ yych = *++lexer->cursor;
+ if (yych == 'd') goto yy591;
+ goto yy50;
yy443:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 279 "src/ast-lexer.c"
- { OPCODE(I64_LOAD16_U); RETURN(LOAD); }
-#line 2518 "src/prebuilt/ast-lexer-gen.c"
+ yych = *++lexer->cursor;
+ if (yych == 'z') goto yy593;
+ goto yy50;
+yy444:
+ yych = *++lexer->cursor;
+ if (yych == 'n') goto yy595;
+ goto yy50;
yy445:
yych = *++lexer->cursor;
- if (yych == 's') goto yy446;
- if (yych == 'u') goto yy448;
- goto yy83;
+ if (yych == 'z') goto yy596;
+ goto yy50;
yy446:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 273 "src/ast-lexer.c"
- { OPCODE(I64_LOAD8_S); RETURN(LOAD); }
-#line 2531 "src/prebuilt/ast-lexer-gen.c"
-yy448:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 275 "src/ast-lexer.c"
- { OPCODE(I64_LOAD8_U); RETURN(LOAD); }
-#line 2539 "src/prebuilt/ast-lexer-gen.c"
-yy450:
yych = *++lexer->cursor;
- if (yych == 's') goto yy451;
- if (yych == 'u') goto yy453;
- goto yy83;
-yy451:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 368 "src/ast-lexer.c"
- { OPCODE(I64_LE_S); RETURN(COMPARE); }
-#line 2552 "src/prebuilt/ast-lexer-gen.c"
-yy453:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 370 "src/ast-lexer.c"
- { OPCODE(I64_LE_U); RETURN(COMPARE); }
-#line 2560 "src/prebuilt/ast-lexer-gen.c"
-yy455:
+ if (yych == 'v') goto yy598;
+ goto yy50;
+yy447:
++lexer->cursor;
- if ((yych = *lexer->cursor) <= ':') {
+ if ((yych = *lexer->cursor) <= 'Z') {
if (yych <= ')') {
if (yych <= '!') {
- if (yych >= '!') goto yy82;
+ if (yych >= '!') goto yy49;
} else {
- if (yych <= '"') goto yy456;
- if (yych <= '\'') goto yy82;
+ if (yych <= '"') goto yy448;
+ if (yych <= '\'') goto yy49;
}
} else {
if (yych <= ',') {
- if (yych <= '+') goto yy82;
+ if (yych <= '+') goto yy49;
} else {
- if (yych == '.') goto yy457;
- goto yy82;
+ if (yych != ';') goto yy49;
}
}
} else {
- if (yych <= ']') {
- if (yych <= 'Z') {
- if (yych >= '<') goto yy82;
+ if (yych <= 'z') {
+ if (yych <= '\\') {
+ if (yych >= '\\') goto yy49;
} else {
- if (yych == '\\') goto yy82;
+ if (yych <= ']') goto yy448;
+ if (yych <= 'y') goto yy49;
+ goto yy599;
}
} else {
if (yych <= '|') {
- if (yych != '{') goto yy82;
+ if (yych >= '|') goto yy49;
} else {
- if (yych == '~') goto yy82;
+ if (yych == '~') goto yy49;
}
}
}
-yy456:
-#line 237 "src/ast-lexer.c"
- { TYPE(I32); RETURN(VALUE_TYPE); }
-#line 2597 "src/prebuilt/ast-lexer-gen.c"
-yy457:
+yy448:
+#line 359 "src/ast-lexer.c"
+ { OPCODE(I32_EQ); RETURN(COMPARE); }
+#line 3277 "src/prebuilt/ast-lexer-gen.c"
+yy449:
yych = *++lexer->cursor;
- switch (yych) {
- case 'a': goto yy463;
- case 'c': goto yy460;
- case 'd': goto yy465;
- case 'e': goto yy461;
- case 'g': goto yy470;
- case 'l': goto yy458;
- case 'm': goto yy464;
- case 'n': goto yy469;
- case 'o': goto yy467;
- case 'p': goto yy462;
- case 'r': goto yy466;
- case 's': goto yy459;
- case 't': goto yy472;
- case 'w': goto yy471;
- case 'x': goto yy468;
- default: goto yy83;
- }
-yy458:
+ if (yych == '_') goto yy601;
+ goto yy50;
+yy450:
yych = *++lexer->cursor;
- if (yych <= 'n') {
- if (yych == 'e') goto yy609;
- goto yy83;
- } else {
- if (yych <= 'o') goto yy610;
- if (yych == 't') goto yy611;
- goto yy83;
+ if (yych == '_') goto yy602;
+ goto yy50;
+yy451:
+ yych = *++lexer->cursor;
+ if (yych == '_') goto yy603;
+ goto yy50;
+yy452:
+ yych = *++lexer->cursor;
+ if (yych == 'a') goto yy604;
+ goto yy50;
+yy453:
+ yych = *++lexer->cursor;
+ if (yych == '_') goto yy605;
+ goto yy50;
+yy454:
+ yych = *++lexer->cursor;
+ if (yych == 'l') goto yy606;
+ goto yy50;
+yy455:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
+#line 361 "src/ast-lexer.c"
+ { OPCODE(I32_NE); RETURN(COMPARE); }
+#line 3309 "src/prebuilt/ast-lexer-gen.c"
+yy457:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 331 "src/ast-lexer.c"
+ { OPCODE(I32_OR); RETURN(BINARY); }
+#line 3317 "src/prebuilt/ast-lexer-gen.c"
yy459:
yych = *++lexer->cursor;
- if (yych <= 's') {
- if (yych == 'h') goto yy587;
- goto yy83;
- } else {
- if (yych <= 't') goto yy588;
- if (yych <= 'u') goto yy589;
- goto yy83;
- }
+ if (yych == 'p') goto yy608;
+ goto yy50;
yy460:
yych = *++lexer->cursor;
- if (yych <= 'n') {
- if (yych == 'l') goto yy576;
- goto yy83;
- } else {
- if (yych <= 'o') goto yy577;
- if (yych == 't') goto yy578;
- goto yy83;
- }
+ if (yych == 'i') goto yy609;
+ if (yych == 'm') goto yy610;
+ goto yy50;
yy461:
yych = *++lexer->cursor;
- if (yych == 'q') goto yy572;
- goto yy83;
+ if (yych == 't') goto yy611;
+ goto yy50;
yy462:
yych = *++lexer->cursor;
- if (yych == 'o') goto yy566;
- goto yy83;
+ if (yych == 'l') goto yy612;
+ if (yych == 'r') goto yy614;
+ goto yy50;
yy463:
yych = *++lexer->cursor;
- if (yych == 'd') goto yy560;
- if (yych == 'n') goto yy561;
- goto yy83;
+ if (yych == 'o') goto yy615;
+ goto yy50;
yy464:
yych = *++lexer->cursor;
- if (yych == 'u') goto yy557;
- goto yy83;
+ if (yych == 'b') goto yy616;
+ goto yy50;
yy465:
yych = *++lexer->cursor;
- if (yych == 'i') goto yy550;
- goto yy83;
+ if (yych == 'u') goto yy618;
+ goto yy50;
yy466:
yych = *++lexer->cursor;
- if (yych == 'e') goto yy523;
- if (yych == 'o') goto yy524;
- goto yy83;
+ if (yych == 'a') goto yy619;
+ goto yy50;
yy467:
yych = *++lexer->cursor;
- if (yych == 'r') goto yy521;
- goto yy83;
+ if (yych == 'r') goto yy620;
+ goto yy50;
yy468:
yych = *++lexer->cursor;
- if (yych == 'o') goto yy518;
- goto yy83;
+ if (yych == 'd') goto yy622;
+ goto yy50;
yy469:
yych = *++lexer->cursor;
- if (yych == 'e') goto yy516;
- goto yy83;
+ if (yych == 'd') goto yy624;
+ goto yy50;
yy470:
yych = *++lexer->cursor;
- if (yych == 'e') goto yy504;
- if (yych == 't') goto yy505;
- goto yy83;
+ if (yych == 'z') goto yy626;
+ goto yy50;
yy471:
yych = *++lexer->cursor;
- if (yych == 'r') goto yy496;
- goto yy83;
+ if (yych == 'n') goto yy628;
+ goto yy50;
yy472:
yych = *++lexer->cursor;
- if (yych != 'r') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'u') goto yy83;
+ if (yych == 'z') goto yy629;
+ goto yy50;
+yy473:
yych = *++lexer->cursor;
- if (yych != 'n') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'c') goto yy83;
+ if (yych == 'v') goto yy631;
+ goto yy50;
+yy474:
+ ++lexer->cursor;
+ if ((yych = *lexer->cursor) <= 'Z') {
+ if (yych <= ')') {
+ if (yych <= '!') {
+ if (yych >= '!') goto yy49;
+ } else {
+ if (yych <= '"') goto yy475;
+ if (yych <= '\'') goto yy49;
+ }
+ } else {
+ if (yych <= ',') {
+ if (yych <= '+') goto yy49;
+ } else {
+ if (yych != ';') goto yy49;
+ }
+ }
+ } else {
+ if (yych <= 'z') {
+ if (yych <= '\\') {
+ if (yych >= '\\') goto yy49;
+ } else {
+ if (yych <= ']') goto yy475;
+ if (yych <= 'y') goto yy49;
+ goto yy632;
+ }
+ } else {
+ if (yych <= '|') {
+ if (yych >= '|') goto yy49;
+ } else {
+ if (yych == '~') goto yy49;
+ }
+ }
+ }
+yy475:
+#line 360 "src/ast-lexer.c"
+ { OPCODE(I64_EQ); RETURN(COMPARE); }
+#line 3417 "src/prebuilt/ast-lexer-gen.c"
+yy476:
yych = *++lexer->cursor;
- if (yych != '_') goto yy83;
+ if (yych == 't') goto yy634;
+ goto yy50;
+yy477:
yych = *++lexer->cursor;
- if (yych == 's') goto yy478;
- if (yych == 'u') goto yy479;
- goto yy83;
+ if (yych == '_') goto yy635;
+ goto yy50;
yy478:
yych = *++lexer->cursor;
- if (yych == '/') goto yy488;
- goto yy83;
+ if (yych == '_') goto yy636;
+ goto yy50;
yy479:
yych = *++lexer->cursor;
- if (yych != '/') goto yy83;
+ if (yych == '_') goto yy637;
+ goto yy50;
+yy480:
yych = *++lexer->cursor;
- if (yych != 'f') goto yy83;
+ if (yych == 'a') goto yy638;
+ goto yy50;
+yy481:
yych = *++lexer->cursor;
- if (yych == '3') goto yy482;
- if (yych == '6') goto yy483;
- goto yy83;
+ if (yych == '_') goto yy639;
+ goto yy50;
yy482:
yych = *++lexer->cursor;
- if (yych == '2') goto yy486;
- goto yy83;
+ if (yych == 'l') goto yy640;
+ goto yy50;
yy483:
- yych = *++lexer->cursor;
- if (yych != '4') goto yy83;
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 400 "src/ast-lexer.c"
- { OPCODE(I32_TRUNC_U_F64); RETURN(CONVERT); }
-#line 2736 "src/prebuilt/ast-lexer-gen.c"
-yy486:
+#line 362 "src/ast-lexer.c"
+ { OPCODE(I64_NE); RETURN(COMPARE); }
+#line 3453 "src/prebuilt/ast-lexer-gen.c"
+yy485:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 398 "src/ast-lexer.c"
- { OPCODE(I32_TRUNC_U_F32); RETURN(CONVERT); }
-#line 2744 "src/prebuilt/ast-lexer-gen.c"
+#line 332 "src/ast-lexer.c"
+ { OPCODE(I64_OR); RETURN(BINARY); }
+#line 3461 "src/prebuilt/ast-lexer-gen.c"
+yy487:
+ yych = *++lexer->cursor;
+ if (yych == 'p') goto yy642;
+ goto yy50;
yy488:
yych = *++lexer->cursor;
- if (yych != 'f') goto yy83;
+ if (yych == 'i') goto yy643;
+ if (yych == 'm') goto yy644;
+ goto yy50;
+yy489:
yych = *++lexer->cursor;
- if (yych == '3') goto yy490;
- if (yych == '6') goto yy491;
- goto yy83;
+ if (yych == 't') goto yy645;
+ goto yy50;
yy490:
yych = *++lexer->cursor;
- if (yych == '2') goto yy494;
- goto yy83;
+ if (yych == 'l') goto yy646;
+ if (yych == 'r') goto yy648;
+ goto yy50;
yy491:
yych = *++lexer->cursor;
- if (yych != '4') goto yy83;
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 396 "src/ast-lexer.c"
- { OPCODE(I32_TRUNC_S_F64); RETURN(CONVERT); }
-#line 2765 "src/prebuilt/ast-lexer-gen.c"
-yy494:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 394 "src/ast-lexer.c"
- { OPCODE(I32_TRUNC_S_F32); RETURN(CONVERT); }
-#line 2773 "src/prebuilt/ast-lexer-gen.c"
-yy496:
- yych = *++lexer->cursor;
- if (yych != 'a') goto yy83;
+ if (yych == 'o') goto yy649;
+ goto yy50;
+yy492:
yych = *++lexer->cursor;
- if (yych != 'p') goto yy83;
+ if (yych == 'b') goto yy650;
+ goto yy50;
+yy493:
yych = *++lexer->cursor;
- if (yych != '/') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'i') goto yy83;
+ if (yych == 'u') goto yy652;
+ goto yy50;
+yy494:
yych = *++lexer->cursor;
- if (yych != '6') goto yy83;
+ if (yych == 'r') goto yy653;
+ goto yy50;
+yy495:
yych = *++lexer->cursor;
- if (yych != '4') goto yy83;
+ if (yych == 'e') goto yy655;
+ goto yy50;
+yy496:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 393 "src/ast-lexer.c"
- { OPCODE(I32_WRAP_I64); RETURN(CONVERT); }
-#line 2793 "src/prebuilt/ast-lexer-gen.c"
-yy504:
+#line 433 "src/ast-lexer.c"
+ { RETURN(IMPORT); }
+#line 3507 "src/prebuilt/ast-lexer-gen.c"
+yy498:
yych = *++lexer->cursor;
- if (yych == '_') goto yy511;
- goto yy83;
+ if (yych == 't') goto yy657;
+ goto yy50;
+yy499:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 436 "src/ast-lexer.c"
+ { RETURN(INVOKE); }
+#line 3519 "src/prebuilt/ast-lexer-gen.c"
+yy501:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 428 "src/ast-lexer.c"
+ { RETURN(MEMORY); }
+#line 3527 "src/prebuilt/ast-lexer-gen.c"
+yy503:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 426 "src/ast-lexer.c"
+ { RETURN(MODULE); }
+#line 3535 "src/prebuilt/ast-lexer-gen.c"
yy505:
yych = *++lexer->cursor;
- if (yych != '_') goto yy83;
- yych = *++lexer->cursor;
- if (yych == 's') goto yy507;
- if (yych == 'u') goto yy509;
- goto yy83;
-yy507:
+ if (yych <= '@') {
+ if (yych <= '/') goto yy50;
+ if (yych <= '9') goto yy658;
+ goto yy50;
+ } else {
+ if (yych <= 'F') goto yy658;
+ if (yych <= '`') goto yy50;
+ if (yych <= 'f') goto yy658;
+ goto yy50;
+ }
+yy506:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if ((yych = *lexer->cursor) <= '<') {
+ if (yych <= ')') {
+ if (yych <= '!') {
+ if (yych >= '!') goto yy49;
+ } else {
+ if (yych <= '"') goto yy507;
+ if (yych <= '\'') goto yy49;
+ }
+ } else {
+ if (yych <= ',') {
+ if (yych <= '+') goto yy49;
+ } else {
+ if (yych != ';') goto yy49;
+ }
+ }
+ } else {
+ if (yych <= ']') {
+ if (yych <= 'Z') {
+ if (yych <= '=') goto yy660;
+ goto yy49;
+ } else {
+ if (yych == '\\') goto yy49;
+ }
+ } else {
+ if (yych <= '|') {
+ if (yych != '{') goto yy49;
+ } else {
+ if (yych == '~') goto yy49;
+ }
+ }
}
-#line 371 "src/ast-lexer.c"
- { OPCODE(I32_GT_S); RETURN(COMPARE); }
-#line 2812 "src/prebuilt/ast-lexer-gen.c"
-yy509:
+yy507:
+#line 432 "src/ast-lexer.c"
+ { RETURN(OFFSET); }
+#line 3584 "src/prebuilt/ast-lexer-gen.c"
+yy508:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 373 "src/ast-lexer.c"
- { OPCODE(I32_GT_U); RETURN(COMPARE); }
-#line 2820 "src/prebuilt/ast-lexer-gen.c"
-yy511:
+#line 446 "src/ast-lexer.c"
+ { RETURN(OUTPUT); }
+#line 3592 "src/prebuilt/ast-lexer-gen.c"
+yy510:
yych = *++lexer->cursor;
- if (yych == 's') goto yy512;
- if (yych == 'u') goto yy514;
- goto yy83;
-yy512:
+ if (yych == 'e') goto yy661;
+ goto yy50;
+yy511:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 375 "src/ast-lexer.c"
- { OPCODE(I32_GE_S); RETURN(COMPARE); }
-#line 2833 "src/prebuilt/ast-lexer-gen.c"
-yy514:
+#line 423 "src/ast-lexer.c"
+ { RETURN(RESULT); }
+#line 3604 "src/prebuilt/ast-lexer-gen.c"
+yy513:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 377 "src/ast-lexer.c"
- { OPCODE(I32_GE_U); RETURN(COMPARE); }
-#line 2841 "src/prebuilt/ast-lexer-gen.c"
-yy516:
+#line 258 "src/ast-lexer.c"
+ { RETURN(RETURN); }
+#line 3612 "src/prebuilt/ast-lexer-gen.c"
+yy515:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 361 "src/ast-lexer.c"
- { OPCODE(I32_NE); RETURN(COMPARE); }
-#line 2849 "src/prebuilt/ast-lexer-gen.c"
+#line 416 "src/ast-lexer.c"
+ { RETURN(SELECT); }
+#line 3620 "src/prebuilt/ast-lexer-gen.c"
+yy517:
+ yych = *++lexer->cursor;
+ if (yych == 'o') goto yy662;
+ goto yy50;
yy518:
yych = *++lexer->cursor;
- if (yych != 'r') goto yy83;
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 333 "src/ast-lexer.c"
- { OPCODE(I32_XOR); RETURN(BINARY); }
-#line 2859 "src/prebuilt/ast-lexer-gen.c"
+ if (yych == 'c') goto yy663;
+ goto yy50;
+yy519:
+ yych = *++lexer->cursor;
+ if (yych == 'c') goto yy664;
+ goto yy50;
+yy520:
+ yych = *++lexer->cursor;
+ if (yych == 'h') goto yy665;
+ goto yy50;
yy521:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if ((yych = *lexer->cursor) <= ';') {
+ if (yych <= ')') {
+ if (yych <= '!') {
+ if (yych >= '!') goto yy49;
+ } else {
+ if (yych <= '"') goto yy522;
+ if (yych <= '\'') goto yy49;
+ }
+ } else {
+ if (yych <= '/') {
+ if (yych != ',') goto yy49;
+ } else {
+ if (yych <= '9') goto yy523;
+ if (yych <= ':') goto yy49;
+ }
+ }
+ } else {
+ if (yych <= 'x') {
+ if (yych <= '\\') {
+ if (yych != '[') goto yy49;
+ } else {
+ if (yych <= ']') goto yy522;
+ if (yych <= 'w') goto yy49;
+ goto yy666;
+ }
+ } else {
+ if (yych <= '|') {
+ if (yych != '{') goto yy49;
+ } else {
+ if (yych == '~') goto yy49;
+ }
+ }
}
-#line 331 "src/ast-lexer.c"
- { OPCODE(I32_OR); RETURN(BINARY); }
-#line 2867 "src/prebuilt/ast-lexer-gen.c"
+yy522:
+#line 288 "src/ast-lexer.c"
+ { TEXT_AT(6); RETURN(ALIGN_EQ_NAT); }
+#line 3675 "src/prebuilt/ast-lexer-gen.c"
yy523:
- yych = *++lexer->cursor;
- if (yych == 'i') goto yy531;
- if (yych == 'm') goto yy530;
- goto yy83;
-yy524:
- yych = *++lexer->cursor;
- if (yych != 't') goto yy83;
- yych = *++lexer->cursor;
- if (yych == 'l') goto yy526;
- if (yych == 'r') goto yy528;
- goto yy83;
-yy526:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (lexer->limit <= lexer->cursor) FILL(1);
+ yych = *lexer->cursor;
+ if (yych <= ':') {
+ if (yych <= ')') {
+ if (yych <= '!') {
+ if (yych <= ' ') goto yy522;
+ goto yy49;
+ } else {
+ if (yych <= '"') goto yy522;
+ if (yych <= '\'') goto yy49;
+ goto yy522;
+ }
+ } else {
+ if (yych <= ',') {
+ if (yych <= '+') goto yy49;
+ goto yy522;
+ } else {
+ if (yych <= '/') goto yy49;
+ if (yych <= '9') goto yy523;
+ goto yy49;
+ }
+ }
+ } else {
+ if (yych <= ']') {
+ if (yych <= 'Z') {
+ if (yych <= ';') goto yy522;
+ goto yy49;
+ } else {
+ if (yych == '\\') goto yy49;
+ goto yy522;
+ }
+ } else {
+ if (yych <= '|') {
+ if (yych == '{') goto yy522;
+ goto yy49;
+ } else {
+ if (yych == '~') goto yy49;
+ goto yy522;
+ }
+ }
}
-#line 341 "src/ast-lexer.c"
- { OPCODE(I32_ROTL); RETURN(BINARY); }
-#line 2887 "src/prebuilt/ast-lexer-gen.c"
-yy528:
+yy525:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 343 "src/ast-lexer.c"
- { OPCODE(I32_ROTR); RETURN(BINARY); }
-#line 2895 "src/prebuilt/ast-lexer-gen.c"
-yy530:
- yych = *++lexer->cursor;
- if (yych == '_') goto yy545;
- goto yy83;
-yy531:
- yych = *++lexer->cursor;
- if (yych != 'n') goto yy83;
+#line 241 "src/ast-lexer.c"
+ { RETURN(ANYFUNC); }
+#line 3726 "src/prebuilt/ast-lexer-gen.c"
+yy527:
yych = *++lexer->cursor;
- if (yych != 't') goto yy83;
+ switch (yych) {
+ case 'e': goto yy667;
+ case 'i': goto yy668;
+ case 'm': goto yy669;
+ case 'r': goto yy670;
+ case 't': goto yy671;
+ case 'u': goto yy672;
+ default: goto yy50;
+ }
+yy528:
yych = *++lexer->cursor;
- if (yych != 'e') goto yy83;
+ if (yych == 'e') goto yy673;
+ goto yy50;
+yy529:
yych = *++lexer->cursor;
- if (yych != 'r') goto yy83;
+ if (yych == 'p') goto yy675;
+ goto yy50;
+yy530:
yych = *++lexer->cursor;
- if (yych != 'p') goto yy83;
+ if (yych == 'd') goto yy676;
+ goto yy50;
+yy531:
yych = *++lexer->cursor;
- if (yych != 'r') goto yy83;
+ if (yych == '_') goto yy677;
+ goto yy50;
+yy532:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 303 "src/ast-lexer.c"
+ { OPCODE(F32_ABS); RETURN(UNARY); }
+#line 3761 "src/prebuilt/ast-lexer-gen.c"
+yy534:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 345 "src/ast-lexer.c"
+ { OPCODE(F32_ADD); RETURN(BINARY); }
+#line 3769 "src/prebuilt/ast-lexer-gen.c"
+yy536:
yych = *++lexer->cursor;
- if (yych != 'e') goto yy83;
+ if (yych == 'l') goto yy678;
+ goto yy50;
+yy537:
yych = *++lexer->cursor;
- if (yych != 't') goto yy83;
+ if (yych == 's') goto yy680;
+ if (yych == 'v') goto yy681;
+ goto yy50;
+yy538:
yych = *++lexer->cursor;
- if (yych != '/') goto yy83;
+ if (yych == 'y') goto yy682;
+ goto yy50;
+yy539:
yych = *++lexer->cursor;
- if (yych != 'f') goto yy83;
+ if (yych == 'o') goto yy683;
+ goto yy50;
+yy540:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 351 "src/ast-lexer.c"
+ { OPCODE(F32_DIV); RETURN(BINARY); }
+#line 3794 "src/prebuilt/ast-lexer-gen.c"
+yy542:
yych = *++lexer->cursor;
- if (yych != '3') goto yy83;
+ if (yych == 'o') goto yy684;
+ goto yy50;
+yy543:
yych = *++lexer->cursor;
- if (yych != '2') goto yy83;
+ if (yych == 'd') goto yy685;
+ goto yy50;
+yy544:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 413 "src/ast-lexer.c"
- { OPCODE(I32_REINTERPRET_F32); RETURN(CONVERT); }
-#line 2931 "src/prebuilt/ast-lexer-gen.c"
-yy545:
- yych = *++lexer->cursor;
- if (yych == 's') goto yy546;
- if (yych == 'u') goto yy548;
- goto yy83;
+#line 355 "src/ast-lexer.c"
+ { OPCODE(F32_MAX); RETURN(BINARY); }
+#line 3810 "src/prebuilt/ast-lexer-gen.c"
yy546:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 325 "src/ast-lexer.c"
- { OPCODE(I32_REM_S); RETURN(BINARY); }
-#line 2944 "src/prebuilt/ast-lexer-gen.c"
+#line 353 "src/ast-lexer.c"
+ { OPCODE(F32_MIN); RETURN(BINARY); }
+#line 3818 "src/prebuilt/ast-lexer-gen.c"
yy548:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 327 "src/ast-lexer.c"
- { OPCODE(I32_REM_U); RETURN(BINARY); }
-#line 2952 "src/prebuilt/ast-lexer-gen.c"
+#line 349 "src/ast-lexer.c"
+ { OPCODE(F32_MUL); RETURN(BINARY); }
+#line 3826 "src/prebuilt/ast-lexer-gen.c"
yy550:
yych = *++lexer->cursor;
- if (yych != 'v') goto yy83;
- yych = *++lexer->cursor;
- if (yych != '_') goto yy83;
- yych = *++lexer->cursor;
- if (yych == 's') goto yy553;
- if (yych == 'u') goto yy555;
- goto yy83;
-yy553:
+ if (yych == 'r') goto yy687;
+ goto yy50;
+yy551:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 321 "src/ast-lexer.c"
- { OPCODE(I32_DIV_S); RETURN(BINARY); }
-#line 2969 "src/prebuilt/ast-lexer-gen.c"
+#line 301 "src/ast-lexer.c"
+ { OPCODE(F32_NEG); RETURN(UNARY); }
+#line 3838 "src/prebuilt/ast-lexer-gen.c"
+yy553:
+ yych = *++lexer->cursor;
+ if (yych == 'n') goto yy688;
+ goto yy50;
+yy554:
+ yych = *++lexer->cursor;
+ if (yych == 't') goto yy689;
+ goto yy50;
yy555:
+ yych = *++lexer->cursor;
+ if (yych == 'r') goto yy691;
+ goto yy50;
+yy556:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 323 "src/ast-lexer.c"
- { OPCODE(I32_DIV_U); RETURN(BINARY); }
-#line 2977 "src/prebuilt/ast-lexer-gen.c"
-yy557:
+#line 347 "src/ast-lexer.c"
+ { OPCODE(F32_SUB); RETURN(BINARY); }
+#line 3858 "src/prebuilt/ast-lexer-gen.c"
+yy558:
yych = *++lexer->cursor;
- if (yych != 'l') goto yy83;
+ if (yych == 'n') goto yy692;
+ goto yy50;
+yy559:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 319 "src/ast-lexer.c"
- { OPCODE(I32_MUL); RETURN(BINARY); }
-#line 2987 "src/prebuilt/ast-lexer-gen.c"
-yy560:
- yych = *++lexer->cursor;
- if (yych == 'd') goto yy564;
- goto yy83;
+#line 304 "src/ast-lexer.c"
+ { OPCODE(F64_ABS); RETURN(UNARY); }
+#line 3870 "src/prebuilt/ast-lexer-gen.c"
yy561:
- yych = *++lexer->cursor;
- if (yych != 'd') goto yy83;
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 329 "src/ast-lexer.c"
- { OPCODE(I32_AND); RETURN(BINARY); }
-#line 3001 "src/prebuilt/ast-lexer-gen.c"
+#line 346 "src/ast-lexer.c"
+ { OPCODE(F64_ADD); RETURN(BINARY); }
+#line 3878 "src/prebuilt/ast-lexer-gen.c"
+yy563:
+ yych = *++lexer->cursor;
+ if (yych == 'l') goto yy693;
+ goto yy50;
yy564:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 315 "src/ast-lexer.c"
- { OPCODE(I32_ADD); RETURN(BINARY); }
-#line 3009 "src/prebuilt/ast-lexer-gen.c"
-yy566:
yych = *++lexer->cursor;
- if (yych != 'p') goto yy83;
+ if (yych == 's') goto yy695;
+ if (yych == 'v') goto yy696;
+ goto yy50;
+yy565:
yych = *++lexer->cursor;
- if (yych != 'c') goto yy83;
+ if (yych == 'y') goto yy697;
+ goto yy50;
+yy566:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 352 "src/ast-lexer.c"
+ { OPCODE(F64_DIV); RETURN(BINARY); }
+#line 3899 "src/prebuilt/ast-lexer-gen.c"
+yy568:
yych = *++lexer->cursor;
- if (yych != 'n') goto yy83;
+ if (yych == 'o') goto yy698;
+ goto yy50;
+yy569:
yych = *++lexer->cursor;
- if (yych != 't') goto yy83;
+ if (yych == 'd') goto yy699;
+ goto yy50;
+yy570:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 299 "src/ast-lexer.c"
- { OPCODE(I32_POPCNT); RETURN(UNARY); }
-#line 3025 "src/prebuilt/ast-lexer-gen.c"
+#line 356 "src/ast-lexer.c"
+ { OPCODE(F64_MAX); RETURN(BINARY); }
+#line 3915 "src/prebuilt/ast-lexer-gen.c"
yy572:
++lexer->cursor;
- if ((yych = *lexer->cursor) <= 'Z') {
- if (yych <= ')') {
- if (yych <= '!') {
- if (yych >= '!') goto yy82;
- } else {
- if (yych <= '"') goto yy573;
- if (yych <= '\'') goto yy82;
- }
- } else {
- if (yych <= ',') {
- if (yych <= '+') goto yy82;
- } else {
- if (yych != ';') goto yy82;
- }
- }
- } else {
- if (yych <= 'z') {
- if (yych <= '\\') {
- if (yych >= '\\') goto yy82;
- } else {
- if (yych <= ']') goto yy573;
- if (yych <= 'y') goto yy82;
- goto yy574;
- }
- } else {
- if (yych <= '|') {
- if (yych >= '|') goto yy82;
- } else {
- if (yych == '~') goto yy82;
- }
- }
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-yy573:
-#line 359 "src/ast-lexer.c"
- { OPCODE(I32_EQ); RETURN(COMPARE); }
-#line 3063 "src/prebuilt/ast-lexer-gen.c"
+#line 354 "src/ast-lexer.c"
+ { OPCODE(F64_MIN); RETURN(BINARY); }
+#line 3923 "src/prebuilt/ast-lexer-gen.c"
yy574:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 293 "src/ast-lexer.c"
- { OPCODE(I32_EQZ); RETURN(CONVERT); }
-#line 3071 "src/prebuilt/ast-lexer-gen.c"
+#line 350 "src/ast-lexer.c"
+ { OPCODE(F64_MUL); RETURN(BINARY); }
+#line 3931 "src/prebuilt/ast-lexer-gen.c"
yy576:
yych = *++lexer->cursor;
- if (yych == 'z') goto yy585;
- goto yy83;
+ if (yych == 'r') goto yy701;
+ goto yy50;
yy577:
- yych = *++lexer->cursor;
- if (yych == 'n') goto yy581;
- goto yy83;
-yy578:
- yych = *++lexer->cursor;
- if (yych != 'z') goto yy83;
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 297 "src/ast-lexer.c"
- { OPCODE(I32_CTZ); RETURN(UNARY); }
-#line 3089 "src/prebuilt/ast-lexer-gen.c"
+#line 302 "src/ast-lexer.c"
+ { OPCODE(F64_NEG); RETURN(UNARY); }
+#line 3943 "src/prebuilt/ast-lexer-gen.c"
+yy579:
+ yych = *++lexer->cursor;
+ if (yych == 'm') goto yy702;
+ goto yy50;
+yy580:
+ yych = *++lexer->cursor;
+ if (yych == 'n') goto yy703;
+ goto yy50;
yy581:
yych = *++lexer->cursor;
- if (yych != 's') goto yy83;
+ if (yych == 't') goto yy704;
+ goto yy50;
+yy582:
yych = *++lexer->cursor;
- if (yych != 't') goto yy83;
+ if (yych == 'r') goto yy706;
+ goto yy50;
+yy583:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 289 "src/ast-lexer.c"
- { TYPE(I32); RETURN(CONST); }
-#line 3101 "src/prebuilt/ast-lexer-gen.c"
+#line 348 "src/ast-lexer.c"
+ { OPCODE(F64_SUB); RETURN(BINARY); }
+#line 3967 "src/prebuilt/ast-lexer-gen.c"
yy585:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 295 "src/ast-lexer.c"
- { OPCODE(I32_CLZ); RETURN(UNARY); }
-#line 3109 "src/prebuilt/ast-lexer-gen.c"
+ yych = *++lexer->cursor;
+ if (yych == 'n') goto yy707;
+ goto yy50;
+yy586:
+ yych = *++lexer->cursor;
+ if (yych == 'b') goto yy708;
+ goto yy50;
yy587:
yych = *++lexer->cursor;
- if (yych == 'l') goto yy601;
- if (yych == 'r') goto yy603;
- goto yy83;
+ if (yych == 'a') goto yy709;
+ goto yy50;
yy588:
yych = *++lexer->cursor;
- if (yych == 'o') goto yy592;
- goto yy83;
+ if (yych == 'm') goto yy710;
+ goto yy50;
yy589:
- yych = *++lexer->cursor;
- if (yych != 'b') goto yy83;
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 317 "src/ast-lexer.c"
- { OPCODE(I32_SUB); RETURN(BINARY); }
-#line 3128 "src/prebuilt/ast-lexer-gen.c"
-yy592:
- yych = *++lexer->cursor;
- if (yych != 'r') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'e') goto yy83;
+#line 315 "src/ast-lexer.c"
+ { OPCODE(I32_ADD); RETURN(BINARY); }
+#line 3991 "src/prebuilt/ast-lexer-gen.c"
+yy591:
++lexer->cursor;
- if ((yych = *lexer->cursor) <= '8') {
- if (yych <= ')') {
- if (yych <= '!') {
- if (yych >= '!') goto yy82;
- } else {
- if (yych <= '"') goto yy595;
- if (yych <= '\'') goto yy82;
- }
- } else {
- if (yych <= '0') {
- if (yych != ',') goto yy82;
- } else {
- if (yych <= '1') goto yy596;
- if (yych <= '7') goto yy82;
- goto yy597;
- }
- }
- } else {
- if (yych <= ']') {
- if (yych <= 'Z') {
- if (yych != ';') goto yy82;
- } else {
- if (yych == '\\') goto yy82;
- }
- } else {
- if (yych <= '|') {
- if (yych != '{') goto yy82;
- } else {
- if (yych == '~') goto yy82;
- }
- }
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
+#line 329 "src/ast-lexer.c"
+ { OPCODE(I32_AND); RETURN(BINARY); }
+#line 3999 "src/prebuilt/ast-lexer-gen.c"
+yy593:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 295 "src/ast-lexer.c"
+ { OPCODE(I32_CLZ); RETURN(UNARY); }
+#line 4007 "src/prebuilt/ast-lexer-gen.c"
yy595:
-#line 268 "src/ast-lexer.c"
- { OPCODE(I32_STORE); RETURN(STORE); }
-#line 3170 "src/prebuilt/ast-lexer-gen.c"
-yy596:
yych = *++lexer->cursor;
- if (yych == '6') goto yy599;
- goto yy83;
-yy597:
+ if (yych == 's') goto yy711;
+ goto yy50;
+yy596:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 282 "src/ast-lexer.c"
- { OPCODE(I32_STORE8); RETURN(STORE); }
-#line 3182 "src/prebuilt/ast-lexer-gen.c"
+#line 297 "src/ast-lexer.c"
+ { OPCODE(I32_CTZ); RETURN(UNARY); }
+#line 4019 "src/prebuilt/ast-lexer-gen.c"
+yy598:
+ yych = *++lexer->cursor;
+ if (yych == '_') goto yy712;
+ goto yy50;
yy599:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 284 "src/ast-lexer.c"
- { OPCODE(I32_STORE16); RETURN(STORE); }
-#line 3190 "src/prebuilt/ast-lexer-gen.c"
+#line 293 "src/ast-lexer.c"
+ { OPCODE(I32_EQZ); RETURN(CONVERT); }
+#line 4031 "src/prebuilt/ast-lexer-gen.c"
yy601:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 335 "src/ast-lexer.c"
- { OPCODE(I32_SHL); RETURN(BINARY); }
-#line 3198 "src/prebuilt/ast-lexer-gen.c"
+ yych = *++lexer->cursor;
+ if (yych == 's') goto yy713;
+ if (yych == 'u') goto yy715;
+ goto yy50;
+yy602:
+ yych = *++lexer->cursor;
+ if (yych == 's') goto yy717;
+ if (yych == 'u') goto yy719;
+ goto yy50;
yy603:
yych = *++lexer->cursor;
- if (yych != '_') goto yy83;
+ if (yych == 's') goto yy721;
+ if (yych == 'u') goto yy723;
+ goto yy50;
+yy604:
yych = *++lexer->cursor;
- if (yych == 's') goto yy605;
- if (yych == 'u') goto yy607;
- goto yy83;
+ if (yych == 'd') goto yy725;
+ goto yy50;
yy605:
+ yych = *++lexer->cursor;
+ if (yych == 's') goto yy727;
+ if (yych == 'u') goto yy729;
+ goto yy50;
+yy606:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 337 "src/ast-lexer.c"
- { OPCODE(I32_SHR_S); RETURN(BINARY); }
-#line 3213 "src/prebuilt/ast-lexer-gen.c"
-yy607:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 339 "src/ast-lexer.c"
- { OPCODE(I32_SHR_U); RETURN(BINARY); }
-#line 3221 "src/prebuilt/ast-lexer-gen.c"
+#line 319 "src/ast-lexer.c"
+ { OPCODE(I32_MUL); RETURN(BINARY); }
+#line 4063 "src/prebuilt/ast-lexer-gen.c"
+yy608:
+ yych = *++lexer->cursor;
+ if (yych == 'c') goto yy731;
+ goto yy50;
yy609:
yych = *++lexer->cursor;
- if (yych == '_') goto yy633;
- goto yy83;
+ if (yych == 'n') goto yy732;
+ goto yy50;
yy610:
yych = *++lexer->cursor;
- if (yych == 'a') goto yy617;
- goto yy83;
+ if (yych == '_') goto yy733;
+ goto yy50;
yy611:
yych = *++lexer->cursor;
- if (yych != '_') goto yy83;
- yych = *++lexer->cursor;
- if (yych == 's') goto yy613;
- if (yych == 'u') goto yy615;
- goto yy83;
-yy613:
+ if (yych == 'l') goto yy734;
+ if (yych == 'r') goto yy736;
+ goto yy50;
+yy612:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 363 "src/ast-lexer.c"
- { OPCODE(I32_LT_S); RETURN(COMPARE); }
-#line 3244 "src/prebuilt/ast-lexer-gen.c"
+#line 335 "src/ast-lexer.c"
+ { OPCODE(I32_SHL); RETURN(BINARY); }
+#line 4088 "src/prebuilt/ast-lexer-gen.c"
+yy614:
+ yych = *++lexer->cursor;
+ if (yych == '_') goto yy738;
+ goto yy50;
yy615:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 365 "src/ast-lexer.c"
- { OPCODE(I32_LT_U); RETURN(COMPARE); }
-#line 3252 "src/prebuilt/ast-lexer-gen.c"
-yy617:
yych = *++lexer->cursor;
- if (yych != 'd') goto yy83;
+ if (yych == 'r') goto yy739;
+ goto yy50;
+yy616:
++lexer->cursor;
- if ((yych = *lexer->cursor) <= '8') {
- if (yych <= ')') {
- if (yych <= '!') {
- if (yych >= '!') goto yy82;
- } else {
- if (yych <= '"') goto yy619;
- if (yych <= '\'') goto yy82;
- }
- } else {
- if (yych <= '0') {
- if (yych != ',') goto yy82;
- } else {
- if (yych <= '1') goto yy621;
- if (yych <= '7') goto yy82;
- goto yy620;
- }
- }
- } else {
- if (yych <= ']') {
- if (yych <= 'Z') {
- if (yych != ';') goto yy82;
- } else {
- if (yych == '\\') goto yy82;
- }
- } else {
- if (yych <= '|') {
- if (yych != '{') goto yy82;
- } else {
- if (yych == '~') goto yy82;
- }
- }
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-yy619:
-#line 264 "src/ast-lexer.c"
- { OPCODE(I32_LOAD); RETURN(LOAD); }
-#line 3292 "src/prebuilt/ast-lexer-gen.c"
-yy620:
- yych = *++lexer->cursor;
- if (yych == '_') goto yy628;
- goto yy83;
-yy621:
- yych = *++lexer->cursor;
- if (yych != '6') goto yy83;
+#line 317 "src/ast-lexer.c"
+ { OPCODE(I32_SUB); RETURN(BINARY); }
+#line 4104 "src/prebuilt/ast-lexer-gen.c"
+yy618:
yych = *++lexer->cursor;
- if (yych != '_') goto yy83;
+ if (yych == 'n') goto yy740;
+ goto yy50;
+yy619:
yych = *++lexer->cursor;
- if (yych == 's') goto yy624;
- if (yych == 'u') goto yy626;
- goto yy83;
+ if (yych == 'p') goto yy741;
+ goto yy50;
+yy620:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 333 "src/ast-lexer.c"
+ { OPCODE(I32_XOR); RETURN(BINARY); }
+#line 4120 "src/prebuilt/ast-lexer-gen.c"
+yy622:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 316 "src/ast-lexer.c"
+ { OPCODE(I64_ADD); RETURN(BINARY); }
+#line 4128 "src/prebuilt/ast-lexer-gen.c"
yy624:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 276 "src/ast-lexer.c"
- { OPCODE(I32_LOAD16_S); RETURN(LOAD); }
-#line 3313 "src/prebuilt/ast-lexer-gen.c"
+#line 330 "src/ast-lexer.c"
+ { OPCODE(I64_AND); RETURN(BINARY); }
+#line 4136 "src/prebuilt/ast-lexer-gen.c"
yy626:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 278 "src/ast-lexer.c"
- { OPCODE(I32_LOAD16_U); RETURN(LOAD); }
-#line 3321 "src/prebuilt/ast-lexer-gen.c"
+#line 296 "src/ast-lexer.c"
+ { OPCODE(I64_CLZ); RETURN(UNARY); }
+#line 4144 "src/prebuilt/ast-lexer-gen.c"
yy628:
yych = *++lexer->cursor;
- if (yych == 's') goto yy629;
- if (yych == 'u') goto yy631;
- goto yy83;
+ if (yych == 's') goto yy742;
+ goto yy50;
yy629:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 272 "src/ast-lexer.c"
- { OPCODE(I32_LOAD8_S); RETURN(LOAD); }
-#line 3334 "src/prebuilt/ast-lexer-gen.c"
+#line 298 "src/ast-lexer.c"
+ { OPCODE(I64_CTZ); RETURN(UNARY); }
+#line 4156 "src/prebuilt/ast-lexer-gen.c"
yy631:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 274 "src/ast-lexer.c"
- { OPCODE(I32_LOAD8_U); RETURN(LOAD); }
-#line 3342 "src/prebuilt/ast-lexer-gen.c"
-yy633:
yych = *++lexer->cursor;
- if (yych == 's') goto yy634;
- if (yych == 'u') goto yy636;
- goto yy83;
-yy634:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 367 "src/ast-lexer.c"
- { OPCODE(I32_LE_S); RETURN(COMPARE); }
-#line 3355 "src/prebuilt/ast-lexer-gen.c"
-yy636:
+ if (yych == '_') goto yy743;
+ goto yy50;
+yy632:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 369 "src/ast-lexer.c"
- { OPCODE(I32_LE_U); RETURN(COMPARE); }
-#line 3363 "src/prebuilt/ast-lexer-gen.c"
-yy638:
- yych = *++lexer->cursor;
- if (yych == 't') goto yy656;
- goto yy83;
-yy639:
+#line 294 "src/ast-lexer.c"
+ { OPCODE(I64_EQZ); RETURN(CONVERT); }
+#line 4168 "src/prebuilt/ast-lexer-gen.c"
+yy634:
yych = *++lexer->cursor;
- if (yych == 'o') goto yy651;
- goto yy83;
-yy640:
+ if (yych == 'e') goto yy744;
+ goto yy50;
+yy635:
yych = *++lexer->cursor;
- if (yych != 'o') goto yy83;
+ if (yych == 's') goto yy745;
+ if (yych == 'u') goto yy747;
+ goto yy50;
+yy636:
yych = *++lexer->cursor;
- if (yych != 'w') goto yy83;
+ if (yych == 's') goto yy749;
+ if (yych == 'u') goto yy751;
+ goto yy50;
+yy637:
yych = *++lexer->cursor;
- if (yych != '_') goto yy83;
+ if (yych == 's') goto yy753;
+ if (yych == 'u') goto yy755;
+ goto yy50;
+yy638:
yych = *++lexer->cursor;
- if (yych != 'm') goto yy83;
+ if (yych == 'd') goto yy757;
+ goto yy50;
+yy639:
yych = *++lexer->cursor;
- if (yych != 'e') goto yy83;
+ if (yych == 's') goto yy759;
+ if (yych == 'u') goto yy761;
+ goto yy50;
+yy640:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 320 "src/ast-lexer.c"
+ { OPCODE(I64_MUL); RETURN(BINARY); }
+#line 4204 "src/prebuilt/ast-lexer-gen.c"
+yy642:
yych = *++lexer->cursor;
- if (yych != 'm') goto yy83;
+ if (yych == 'c') goto yy763;
+ goto yy50;
+yy643:
yych = *++lexer->cursor;
- if (yych != 'o') goto yy83;
+ if (yych == 'n') goto yy764;
+ goto yy50;
+yy644:
yych = *++lexer->cursor;
- if (yych != 'r') goto yy83;
+ if (yych == '_') goto yy765;
+ goto yy50;
+yy645:
yych = *++lexer->cursor;
- if (yych != 'y') goto yy83;
+ if (yych == 'l') goto yy766;
+ if (yych == 'r') goto yy768;
+ goto yy50;
+yy646:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 419 "src/ast-lexer.c"
- { RETURN(GROW_MEMORY); }
-#line 3397 "src/prebuilt/ast-lexer-gen.c"
-yy651:
+#line 336 "src/ast-lexer.c"
+ { OPCODE(I64_SHL); RETURN(BINARY); }
+#line 4229 "src/prebuilt/ast-lexer-gen.c"
+yy648:
yych = *++lexer->cursor;
- if (yych != 'b') goto yy83;
+ if (yych == '_') goto yy770;
+ goto yy50;
+yy649:
yych = *++lexer->cursor;
- if (yych != 'a') goto yy83;
+ if (yych == 'r') goto yy771;
+ goto yy50;
+yy650:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 318 "src/ast-lexer.c"
+ { OPCODE(I64_SUB); RETURN(BINARY); }
+#line 4245 "src/prebuilt/ast-lexer-gen.c"
+yy652:
yych = *++lexer->cursor;
- if (yych != 'l') goto yy83;
+ if (yych == 'n') goto yy772;
+ goto yy50;
+yy653:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 425 "src/ast-lexer.c"
- { RETURN(GLOBAL); }
-#line 3411 "src/prebuilt/ast-lexer-gen.c"
-yy656:
+#line 334 "src/ast-lexer.c"
+ { OPCODE(I64_XOR); RETURN(BINARY); }
+#line 4257 "src/prebuilt/ast-lexer-gen.c"
+yy655:
++lexer->cursor;
- if ((yych = *lexer->cursor) <= 'Z') {
- if (yych <= ')') {
- if (yych <= '!') {
- if (yych >= '!') goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 246 "src/ast-lexer.c"
+ { RETURN(IF); }
+#line 4265 "src/prebuilt/ast-lexer-gen.c"
+yy657:
+ yych = *++lexer->cursor;
+ if (yych == 'y') goto yy773;
+ goto yy50;
+yy658:
+ ++lexer->cursor;
+ if (lexer->limit <= lexer->cursor) FILL(1);
+ yych = *lexer->cursor;
+ if (yych <= '@') {
+ if (yych <= '+') {
+ if (yych <= '"') {
+ if (yych == '!') goto yy49;
+ goto yy196;
} else {
- if (yych <= '"') goto yy657;
- if (yych <= '\'') goto yy82;
+ if (yych <= '\'') goto yy49;
+ if (yych <= ')') goto yy196;
+ goto yy49;
}
} else {
- if (yych <= ',') {
- if (yych <= '+') goto yy82;
+ if (yych <= '9') {
+ if (yych <= ',') goto yy196;
+ if (yych <= '/') goto yy49;
+ goto yy658;
} else {
- if (yych != ';') goto yy82;
+ if (yych == ';') goto yy196;
+ goto yy49;
}
}
} else {
- if (yych <= '_') {
- if (yych <= '\\') {
- if (yych >= '\\') goto yy82;
+ if (yych <= '`') {
+ if (yych <= '[') {
+ if (yych <= 'F') goto yy658;
+ if (yych <= 'Z') goto yy49;
+ goto yy196;
} else {
- if (yych <= ']') goto yy657;
- if (yych <= '^') goto yy82;
- goto yy658;
+ if (yych == ']') goto yy196;
+ goto yy49;
}
} else {
- if (yych <= '|') {
- if (yych != '{') goto yy82;
+ if (yych <= '{') {
+ if (yych <= 'f') goto yy658;
+ if (yych <= 'z') goto yy49;
+ goto yy196;
} else {
- if (yych == '~') goto yy82;
+ if (yych == '}') goto yy196;
+ if (yych <= '~') goto yy49;
+ goto yy196;
}
}
}
-yy657:
-#line 437 "src/ast-lexer.c"
- { RETURN(GET); }
-#line 3449 "src/prebuilt/ast-lexer-gen.c"
-yy658:
+yy660:
yych = *++lexer->cursor;
- if (yych == 'g') goto yy660;
- if (yych != 'l') goto yy83;
+ if (yych <= '/') goto yy50;
+ if (yych <= '0') goto yy774;
+ if (yych <= '9') goto yy776;
+ goto yy50;
+yy661:
yych = *++lexer->cursor;
- if (yych == 'o') goto yy667;
- goto yy83;
-yy660:
+ if (yych == 'r') goto yy778;
+ goto yy50;
+yy662:
yych = *++lexer->cursor;
- if (yych != 'l') goto yy83;
+ if (yych == 'b') goto yy780;
+ goto yy50;
+yy663:
yych = *++lexer->cursor;
- if (yych != 'o') goto yy83;
+ if (yych == 'a') goto yy781;
+ goto yy50;
+yy664:
yych = *++lexer->cursor;
- if (yych != 'b') goto yy83;
+ if (yych == 'a') goto yy782;
+ goto yy50;
+yy665:
yych = *++lexer->cursor;
- if (yych != 'a') goto yy83;
+ if (yych == 'a') goto yy783;
+ goto yy50;
+yy666:
yych = *++lexer->cursor;
- if (yych != 'l') goto yy83;
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yych <= '@') {
+ if (yych <= '/') goto yy50;
+ if (yych <= '9') goto yy784;
+ goto yy50;
+ } else {
+ if (yych <= 'F') goto yy784;
+ if (yych <= '`') goto yy50;
+ if (yych <= 'f') goto yy784;
+ goto yy50;
}
-#line 262 "src/ast-lexer.c"
- { RETURN(GET_GLOBAL); }
-#line 3474 "src/prebuilt/ast-lexer-gen.c"
yy667:
yych = *++lexer->cursor;
- if (yych != 'c') goto yy83;
+ if (yych == 'x') goto yy786;
+ goto yy50;
+yy668:
yych = *++lexer->cursor;
- if (yych != 'a') goto yy83;
+ if (yych == 'n') goto yy787;
+ goto yy50;
+yy669:
yych = *++lexer->cursor;
- if (yych != 'l') goto yy83;
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 259 "src/ast-lexer.c"
- { RETURN(GET_LOCAL); }
-#line 3488 "src/prebuilt/ast-lexer-gen.c"
+ if (yych == 'a') goto yy788;
+ goto yy50;
+yy670:
+ yych = *++lexer->cursor;
+ if (yych == 'e') goto yy789;
+ goto yy50;
+yy671:
+ yych = *++lexer->cursor;
+ if (yych == 'r') goto yy790;
+ goto yy50;
yy672:
yych = *++lexer->cursor;
- if (yych == '2') goto yy823;
- goto yy83;
+ if (yych == 'n') goto yy791;
+ goto yy50;
yy673:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 252 "src/ast-lexer.c"
+ { RETURN(BR_TABLE); }
+#line 4385 "src/prebuilt/ast-lexer-gen.c"
+yy675:
yych = *++lexer->cursor;
- if (yych == '4') goto yy678;
- goto yy83;
-yy674:
+ if (yych == 'o') goto yy792;
+ goto yy50;
+yy676:
yych = *++lexer->cursor;
- if (yych != 'n') goto yy83;
+ if (yych == 'i') goto yy793;
+ goto yy50;
+yy677:
yych = *++lexer->cursor;
- if (yych != 'c') goto yy83;
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 421 "src/ast-lexer.c"
- { RETURN(FUNC); }
-#line 3508 "src/prebuilt/ast-lexer-gen.c"
+ if (yych == 'm') goto yy794;
+ goto yy50;
yy678:
++lexer->cursor;
- if ((yych = *lexer->cursor) <= ':') {
- if (yych <= ')') {
- if (yych <= '!') {
- if (yych >= '!') goto yy82;
- } else {
- if (yych <= '"') goto yy679;
- if (yych <= '\'') goto yy82;
- }
- } else {
- if (yych <= ',') {
- if (yych <= '+') goto yy82;
- } else {
- if (yych == '.') goto yy680;
- goto yy82;
- }
- }
- } else {
- if (yych <= ']') {
- if (yych <= 'Z') {
- if (yych >= '<') goto yy82;
- } else {
- if (yych == '\\') goto yy82;
- }
- } else {
- if (yych <= '|') {
- if (yych != '{') goto yy82;
- } else {
- if (yych == '~') goto yy82;
- }
- }
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-yy679:
-#line 240 "src/ast-lexer.c"
- { TYPE(F64); RETURN(VALUE_TYPE); }
-#line 3545 "src/prebuilt/ast-lexer-gen.c"
+#line 307 "src/ast-lexer.c"
+ { OPCODE(F32_CEIL); RETURN(UNARY); }
+#line 4405 "src/prebuilt/ast-lexer-gen.c"
yy680:
yych = *++lexer->cursor;
- switch (yych) {
- case 'a': goto yy685;
- case 'c': goto yy683;
- case 'd': goto yy689;
- case 'e': goto yy690;
- case 'f': goto yy686;
- case 'g': goto yy691;
- case 'l': goto yy681;
- case 'm': goto yy688;
- case 'n': goto yy684;
- case 'p': goto yy692;
- case 'r': goto yy693;
- case 's': goto yy682;
- case 't': goto yy687;
- default: goto yy83;
- }
+ if (yych == 't') goto yy795;
+ goto yy50;
yy681:
yych = *++lexer->cursor;
- if (yych <= 'n') {
- if (yych == 'e') goto yy815;
- goto yy83;
- } else {
- if (yych <= 'o') goto yy817;
- if (yych == 't') goto yy818;
- goto yy83;
- }
+ if (yych == 'e') goto yy797;
+ goto yy50;
yy682:
yych = *++lexer->cursor;
- if (yych <= 's') {
- if (yych == 'q') goto yy803;
- goto yy83;
- } else {
- if (yych <= 't') goto yy804;
- if (yych <= 'u') goto yy805;
- goto yy83;
- }
+ if (yych == 's') goto yy798;
+ goto yy50;
yy683:
yych = *++lexer->cursor;
- if (yych == 'e') goto yy764;
- if (yych == 'o') goto yy765;
- goto yy83;
+ if (yych == 't') goto yy799;
+ goto yy50;
yy684:
yych = *++lexer->cursor;
- if (yych == 'e') goto yy754;
- goto yy83;
+ if (yych == 'r') goto yy800;
+ goto yy50;
yy685:
- yych = *++lexer->cursor;
- if (yych == 'b') goto yy748;
- if (yych == 'd') goto yy749;
- goto yy83;
-yy686:
- yych = *++lexer->cursor;
- if (yych == 'l') goto yy743;
- goto yy83;
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 266 "src/ast-lexer.c"
+ { OPCODE(F32_LOAD); RETURN(LOAD); }
+#line 4433 "src/prebuilt/ast-lexer-gen.c"
yy687:
yych = *++lexer->cursor;
- if (yych == 'r') goto yy738;
- goto yy83;
+ if (yych == 'e') goto yy802;
+ goto yy50;
yy688:
yych = *++lexer->cursor;
- if (yych <= 'h') {
- if (yych == 'a') goto yy729;
- goto yy83;
- } else {
- if (yych <= 'i') goto yy730;
- if (yych == 'u') goto yy731;
- goto yy83;
- }
+ if (yych == 't') goto yy803;
+ goto yy50;
yy689:
- yych = *++lexer->cursor;
- if (yych == 'i') goto yy726;
- goto yy83;
-yy690:
- yych = *++lexer->cursor;
- if (yych == 'q') goto yy724;
- goto yy83;
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 305 "src/ast-lexer.c"
+ { OPCODE(F32_SQRT); RETURN(UNARY); }
+#line 4449 "src/prebuilt/ast-lexer-gen.c"
yy691:
yych = *++lexer->cursor;
- if (yych == 'e') goto yy720;
- if (yych == 't') goto yy722;
- goto yy83;
+ if (yych == 'e') goto yy804;
+ goto yy50;
yy692:
yych = *++lexer->cursor;
- if (yych == 'r') goto yy709;
- goto yy83;
+ if (yych == 'c') goto yy806;
+ goto yy50;
yy693:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 308 "src/ast-lexer.c"
+ { OPCODE(F64_CEIL); RETURN(UNARY); }
+#line 4465 "src/prebuilt/ast-lexer-gen.c"
+yy695:
yych = *++lexer->cursor;
- if (yych != 'e') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'i') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'n') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 't') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'e') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'r') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'p') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'r') goto yy83;
+ if (yych == 't') goto yy808;
+ goto yy50;
+yy696:
yych = *++lexer->cursor;
- if (yych != 'e') goto yy83;
+ if (yych == 'e') goto yy810;
+ goto yy50;
+yy697:
yych = *++lexer->cursor;
- if (yych != 't') goto yy83;
+ if (yych == 's') goto yy811;
+ goto yy50;
+yy698:
yych = *++lexer->cursor;
- if (yych != '/') goto yy83;
+ if (yych == 'r') goto yy812;
+ goto yy50;
+yy699:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 267 "src/ast-lexer.c"
+ { OPCODE(F64_LOAD); RETURN(LOAD); }
+#line 4489 "src/prebuilt/ast-lexer-gen.c"
+yy701:
yych = *++lexer->cursor;
- if (yych != 'i') goto yy83;
+ if (yych == 'e') goto yy814;
+ goto yy50;
+yy702:
yych = *++lexer->cursor;
- if (yych != '6') goto yy83;
+ if (yych == 'o') goto yy815;
+ goto yy50;
+yy703:
yych = *++lexer->cursor;
- if (yych != '4') goto yy83;
+ if (yych == 't') goto yy816;
+ goto yy50;
+yy704:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 414 "src/ast-lexer.c"
- { OPCODE(F64_REINTERPRET_I64); RETURN(CONVERT); }
-#line 3668 "src/prebuilt/ast-lexer-gen.c"
-yy709:
- yych = *++lexer->cursor;
- if (yych != 'o') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'm') goto yy83;
+#line 306 "src/ast-lexer.c"
+ { OPCODE(F64_SQRT); RETURN(UNARY); }
+#line 4509 "src/prebuilt/ast-lexer-gen.c"
+yy706:
yych = *++lexer->cursor;
- if (yych != 'o') goto yy83;
+ if (yych == 'e') goto yy817;
+ goto yy50;
+yy707:
yych = *++lexer->cursor;
- if (yych != 't') goto yy83;
+ if (yych == 'c') goto yy819;
+ goto yy50;
+yy708:
yych = *++lexer->cursor;
- if (yych != 'e') goto yy83;
+ if (yych == 'a') goto yy821;
+ goto yy50;
+yy709:
yych = *++lexer->cursor;
- if (yych != '/') goto yy83;
+ if (yych == 'l') goto yy822;
+ goto yy50;
+yy710:
yych = *++lexer->cursor;
- if (yych != 'f') goto yy83;
+ if (yych == 'o') goto yy824;
+ goto yy50;
+yy711:
yych = *++lexer->cursor;
- if (yych != '3') goto yy83;
+ if (yych == 't') goto yy825;
+ goto yy50;
+yy712:
yych = *++lexer->cursor;
- if (yych != '2') goto yy83;
+ if (yych == 's') goto yy827;
+ if (yych == 'u') goto yy829;
+ goto yy50;
+yy713:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 410 "src/ast-lexer.c"
- { OPCODE(F64_PROMOTE_F32); RETURN(CONVERT); }
-#line 3694 "src/prebuilt/ast-lexer-gen.c"
-yy720:
+#line 375 "src/ast-lexer.c"
+ { OPCODE(I32_GE_S); RETURN(COMPARE); }
+#line 4546 "src/prebuilt/ast-lexer-gen.c"
+yy715:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 390 "src/ast-lexer.c"
- { OPCODE(F64_GE); RETURN(COMPARE); }
-#line 3702 "src/prebuilt/ast-lexer-gen.c"
-yy722:
+#line 377 "src/ast-lexer.c"
+ { OPCODE(I32_GE_U); RETURN(COMPARE); }
+#line 4554 "src/prebuilt/ast-lexer-gen.c"
+yy717:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 388 "src/ast-lexer.c"
- { OPCODE(F64_GT); RETURN(COMPARE); }
-#line 3710 "src/prebuilt/ast-lexer-gen.c"
-yy724:
+#line 371 "src/ast-lexer.c"
+ { OPCODE(I32_GT_S); RETURN(COMPARE); }
+#line 4562 "src/prebuilt/ast-lexer-gen.c"
+yy719:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 373 "src/ast-lexer.c"
+ { OPCODE(I32_GT_U); RETURN(COMPARE); }
+#line 4570 "src/prebuilt/ast-lexer-gen.c"
+yy721:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 367 "src/ast-lexer.c"
+ { OPCODE(I32_LE_S); RETURN(COMPARE); }
+#line 4578 "src/prebuilt/ast-lexer-gen.c"
+yy723:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 369 "src/ast-lexer.c"
+ { OPCODE(I32_LE_U); RETURN(COMPARE); }
+#line 4586 "src/prebuilt/ast-lexer-gen.c"
+yy725:
+ ++lexer->cursor;
+ if ((yych = *lexer->cursor) <= '8') {
+ if (yych <= ')') {
+ if (yych <= '!') {
+ if (yych >= '!') goto yy49;
+ } else {
+ if (yych <= '"') goto yy726;
+ if (yych <= '\'') goto yy49;
+ }
+ } else {
+ if (yych <= '0') {
+ if (yych != ',') goto yy49;
+ } else {
+ if (yych <= '1') goto yy831;
+ if (yych <= '7') goto yy49;
+ goto yy832;
+ }
+ }
+ } else {
+ if (yych <= ']') {
+ if (yych <= 'Z') {
+ if (yych != ';') goto yy49;
+ } else {
+ if (yych == '\\') goto yy49;
+ }
+ } else {
+ if (yych <= '|') {
+ if (yych != '{') goto yy49;
+ } else {
+ if (yych == '~') goto yy49;
+ }
+ }
}
-#line 380 "src/ast-lexer.c"
- { OPCODE(F64_EQ); RETURN(COMPARE); }
-#line 3718 "src/prebuilt/ast-lexer-gen.c"
yy726:
- yych = *++lexer->cursor;
- if (yych != 'v') goto yy83;
+#line 264 "src/ast-lexer.c"
+ { OPCODE(I32_LOAD); RETURN(LOAD); }
+#line 4624 "src/prebuilt/ast-lexer-gen.c"
+yy727:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 352 "src/ast-lexer.c"
- { OPCODE(F64_DIV); RETURN(BINARY); }
-#line 3728 "src/prebuilt/ast-lexer-gen.c"
+#line 363 "src/ast-lexer.c"
+ { OPCODE(I32_LT_S); RETURN(COMPARE); }
+#line 4632 "src/prebuilt/ast-lexer-gen.c"
yy729:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 365 "src/ast-lexer.c"
+ { OPCODE(I32_LT_U); RETURN(COMPARE); }
+#line 4640 "src/prebuilt/ast-lexer-gen.c"
+yy731:
yych = *++lexer->cursor;
- if (yych == 'x') goto yy736;
- goto yy83;
-yy730:
+ if (yych == 'n') goto yy833;
+ goto yy50;
+yy732:
yych = *++lexer->cursor;
- if (yych == 'n') goto yy734;
- goto yy83;
-yy731:
+ if (yych == 't') goto yy834;
+ goto yy50;
+yy733:
yych = *++lexer->cursor;
- if (yych != 'l') goto yy83;
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 350 "src/ast-lexer.c"
- { OPCODE(F64_MUL); RETURN(BINARY); }
-#line 3746 "src/prebuilt/ast-lexer-gen.c"
+ if (yych == 's') goto yy835;
+ if (yych == 'u') goto yy837;
+ goto yy50;
yy734:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 354 "src/ast-lexer.c"
- { OPCODE(F64_MIN); RETURN(BINARY); }
-#line 3754 "src/prebuilt/ast-lexer-gen.c"
+#line 341 "src/ast-lexer.c"
+ { OPCODE(I32_ROTL); RETURN(BINARY); }
+#line 4661 "src/prebuilt/ast-lexer-gen.c"
yy736:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 356 "src/ast-lexer.c"
- { OPCODE(F64_MAX); RETURN(BINARY); }
-#line 3762 "src/prebuilt/ast-lexer-gen.c"
+#line 343 "src/ast-lexer.c"
+ { OPCODE(I32_ROTR); RETURN(BINARY); }
+#line 4669 "src/prebuilt/ast-lexer-gen.c"
yy738:
yych = *++lexer->cursor;
- if (yych != 'u') goto yy83;
+ if (yych == 's') goto yy839;
+ if (yych == 'u') goto yy841;
+ goto yy50;
+yy739:
yych = *++lexer->cursor;
- if (yych != 'n') goto yy83;
+ if (yych == 'e') goto yy843;
+ goto yy50;
+yy740:
yych = *++lexer->cursor;
- if (yych != 'c') goto yy83;
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 312 "src/ast-lexer.c"
- { OPCODE(F64_TRUNC); RETURN(UNARY); }
-#line 3776 "src/prebuilt/ast-lexer-gen.c"
-yy743:
+ if (yych == 'c') goto yy845;
+ goto yy50;
+yy741:
+ yych = *++lexer->cursor;
+ if (yych == '/') goto yy846;
+ goto yy50;
+yy742:
yych = *++lexer->cursor;
- if (yych != 'o') goto yy83;
+ if (yych == 't') goto yy847;
+ goto yy50;
+yy743:
yych = *++lexer->cursor;
- if (yych != 'o') goto yy83;
+ if (yych == 's') goto yy849;
+ if (yych == 'u') goto yy851;
+ goto yy50;
+yy744:
yych = *++lexer->cursor;
- if (yych != 'r') goto yy83;
+ if (yych == 'n') goto yy853;
+ goto yy50;
+yy745:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 310 "src/ast-lexer.c"
- { OPCODE(F64_FLOOR); RETURN(UNARY); }
-#line 3790 "src/prebuilt/ast-lexer-gen.c"
-yy748:
- yych = *++lexer->cursor;
- if (yych == 's') goto yy752;
- goto yy83;
+#line 376 "src/ast-lexer.c"
+ { OPCODE(I64_GE_S); RETURN(COMPARE); }
+#line 4707 "src/prebuilt/ast-lexer-gen.c"
+yy747:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 378 "src/ast-lexer.c"
+ { OPCODE(I64_GE_U); RETURN(COMPARE); }
+#line 4715 "src/prebuilt/ast-lexer-gen.c"
yy749:
- yych = *++lexer->cursor;
- if (yych != 'd') goto yy83;
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 346 "src/ast-lexer.c"
- { OPCODE(F64_ADD); RETURN(BINARY); }
-#line 3804 "src/prebuilt/ast-lexer-gen.c"
-yy752:
+#line 372 "src/ast-lexer.c"
+ { OPCODE(I64_GT_S); RETURN(COMPARE); }
+#line 4723 "src/prebuilt/ast-lexer-gen.c"
+yy751:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 304 "src/ast-lexer.c"
- { OPCODE(F64_ABS); RETURN(UNARY); }
-#line 3812 "src/prebuilt/ast-lexer-gen.c"
-yy754:
+#line 374 "src/ast-lexer.c"
+ { OPCODE(I64_GT_U); RETURN(COMPARE); }
+#line 4731 "src/prebuilt/ast-lexer-gen.c"
+yy753:
++lexer->cursor;
- if ((yych = *lexer->cursor) <= '[') {
- if (yych <= ')') {
- if (yych <= '!') {
- if (yych >= '!') goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 368 "src/ast-lexer.c"
+ { OPCODE(I64_LE_S); RETURN(COMPARE); }
+#line 4739 "src/prebuilt/ast-lexer-gen.c"
+yy755:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 370 "src/ast-lexer.c"
+ { OPCODE(I64_LE_U); RETURN(COMPARE); }
+#line 4747 "src/prebuilt/ast-lexer-gen.c"
+yy757:
+ ++lexer->cursor;
+ if ((yych = *lexer->cursor) <= '7') {
+ if (yych <= '+') {
+ if (yych <= '"') {
+ if (yych == '!') goto yy49;
} else {
- if (yych <= '"') goto yy755;
- if (yych <= '\'') goto yy82;
+ if (yych <= '\'') goto yy49;
+ if (yych >= '*') goto yy49;
}
} else {
- if (yych <= ':') {
- if (yych != ',') goto yy82;
+ if (yych <= '1') {
+ if (yych <= ',') goto yy758;
+ if (yych <= '0') goto yy49;
+ goto yy854;
} else {
- if (yych <= ';') goto yy755;
- if (yych <= 'Z') goto yy82;
+ if (yych == '3') goto yy855;
+ goto yy49;
}
}
} else {
- if (yych <= 'g') {
- if (yych <= '`') {
- if (yych != ']') goto yy82;
+ if (yych <= '\\') {
+ if (yych <= ';') {
+ if (yych <= '8') goto yy856;
+ if (yych <= ':') goto yy49;
} else {
- if (yych <= 'a') goto yy758;
- if (yych <= 'f') goto yy82;
- goto yy756;
+ if (yych != '[') goto yy49;
}
} else {
- if (yych <= '|') {
- if (yych != '{') goto yy82;
+ if (yych <= '{') {
+ if (yych <= ']') goto yy758;
+ if (yych <= 'z') goto yy49;
} else {
- if (yych == '~') goto yy82;
+ if (yych == '}') goto yy758;
+ if (yych <= '~') goto yy49;
}
}
}
-yy755:
-#line 382 "src/ast-lexer.c"
- { OPCODE(F64_NE); RETURN(COMPARE); }
-#line 3851 "src/prebuilt/ast-lexer-gen.c"
-yy756:
+yy758:
+#line 265 "src/ast-lexer.c"
+ { OPCODE(I64_LOAD); RETURN(LOAD); }
+#line 4789 "src/prebuilt/ast-lexer-gen.c"
+yy759:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 302 "src/ast-lexer.c"
- { OPCODE(F64_NEG); RETURN(UNARY); }
-#line 3859 "src/prebuilt/ast-lexer-gen.c"
-yy758:
- yych = *++lexer->cursor;
- if (yych != 'r') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'e') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 's') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 't') goto yy83;
+#line 364 "src/ast-lexer.c"
+ { OPCODE(I64_LT_S); RETURN(COMPARE); }
+#line 4797 "src/prebuilt/ast-lexer-gen.c"
+yy761:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 314 "src/ast-lexer.c"
- { OPCODE(F64_NEAREST); RETURN(UNARY); }
-#line 3875 "src/prebuilt/ast-lexer-gen.c"
+#line 366 "src/ast-lexer.c"
+ { OPCODE(I64_LT_U); RETURN(COMPARE); }
+#line 4805 "src/prebuilt/ast-lexer-gen.c"
+yy763:
+ yych = *++lexer->cursor;
+ if (yych == 'n') goto yy857;
+ goto yy50;
yy764:
yych = *++lexer->cursor;
- if (yych == 'i') goto yy800;
- goto yy83;
+ if (yych == 't') goto yy858;
+ goto yy50;
yy765:
yych = *++lexer->cursor;
- if (yych == 'n') goto yy766;
- if (yych == 'p') goto yy767;
- goto yy83;
+ if (yych == 's') goto yy859;
+ if (yych == 'u') goto yy861;
+ goto yy50;
yy766:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 342 "src/ast-lexer.c"
+ { OPCODE(I64_ROTL); RETURN(BINARY); }
+#line 4826 "src/prebuilt/ast-lexer-gen.c"
+yy768:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 344 "src/ast-lexer.c"
+ { OPCODE(I64_ROTR); RETURN(BINARY); }
+#line 4834 "src/prebuilt/ast-lexer-gen.c"
+yy770:
yych = *++lexer->cursor;
- if (yych == 's') goto yy774;
- if (yych == 'v') goto yy775;
- goto yy83;
-yy767:
- yych = *++lexer->cursor;
- if (yych != 'y') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 's') goto yy83;
+ if (yych == 's') goto yy863;
+ if (yych == 'u') goto yy865;
+ goto yy50;
+yy771:
yych = *++lexer->cursor;
- if (yych != 'i') goto yy83;
+ if (yych == 'e') goto yy867;
+ goto yy50;
+yy772:
yych = *++lexer->cursor;
- if (yych != 'g') goto yy83;
+ if (yych == 'c') goto yy869;
+ goto yy50;
+yy773:
yych = *++lexer->cursor;
- if (yych != 'n') goto yy83;
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+yych] & 16) {
+ goto yy49;
}
-#line 358 "src/ast-lexer.c"
- { OPCODE(F64_COPYSIGN); RETURN(BINARY); }
-#line 3907 "src/prebuilt/ast-lexer-gen.c"
+ goto yy186;
yy774:
- yych = *++lexer->cursor;
- if (yych == 't') goto yy798;
- goto yy83;
+ ++lexer->cursor;
+ if ((yych = *lexer->cursor) <= ';') {
+ if (yych <= ')') {
+ if (yych <= '!') {
+ if (yych >= '!') goto yy49;
+ } else {
+ if (yych <= '"') goto yy775;
+ if (yych <= '\'') goto yy49;
+ }
+ } else {
+ if (yych <= '/') {
+ if (yych != ',') goto yy49;
+ } else {
+ if (yych <= '9') goto yy776;
+ if (yych <= ':') goto yy49;
+ }
+ }
+ } else {
+ if (yych <= 'x') {
+ if (yych <= '\\') {
+ if (yych != '[') goto yy49;
+ } else {
+ if (yych <= ']') goto yy775;
+ if (yych <= 'w') goto yy49;
+ goto yy870;
+ }
+ } else {
+ if (yych <= '|') {
+ if (yych != '{') goto yy49;
+ } else {
+ if (yych == '~') goto yy49;
+ }
+ }
+ }
yy775:
- yych = *++lexer->cursor;
- if (yych != 'e') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'r') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 't') goto yy83;
- yych = *++lexer->cursor;
- if (yych != '_') goto yy83;
- yych = *++lexer->cursor;
- if (yych == 's') goto yy780;
- if (yych == 'u') goto yy781;
- goto yy83;
+#line 287 "src/ast-lexer.c"
+ { TEXT_AT(7); RETURN(OFFSET_EQ_NAT); }
+#line 4892 "src/prebuilt/ast-lexer-gen.c"
+yy776:
+ ++lexer->cursor;
+ if (lexer->limit <= lexer->cursor) FILL(1);
+ yych = *lexer->cursor;
+ if (yych <= ':') {
+ if (yych <= ')') {
+ if (yych <= '!') {
+ if (yych <= ' ') goto yy775;
+ goto yy49;
+ } else {
+ if (yych <= '"') goto yy775;
+ if (yych <= '\'') goto yy49;
+ goto yy775;
+ }
+ } else {
+ if (yych <= ',') {
+ if (yych <= '+') goto yy49;
+ goto yy775;
+ } else {
+ if (yych <= '/') goto yy49;
+ if (yych <= '9') goto yy776;
+ goto yy49;
+ }
+ }
+ } else {
+ if (yych <= ']') {
+ if (yych <= 'Z') {
+ if (yych <= ';') goto yy775;
+ goto yy49;
+ } else {
+ if (yych == '\\') goto yy49;
+ goto yy775;
+ }
+ } else {
+ if (yych <= '|') {
+ if (yych == '{') goto yy775;
+ goto yy49;
+ } else {
+ if (yych == '~') goto yy49;
+ goto yy775;
+ }
+ }
+ }
+yy778:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 435 "src/ast-lexer.c"
+ { RETURN(REGISTER); }
+#line 4943 "src/prebuilt/ast-lexer-gen.c"
yy780:
yych = *++lexer->cursor;
- if (yych == '/') goto yy790;
- goto yy83;
+ if (yych == 'a') goto yy871;
+ goto yy50;
yy781:
yych = *++lexer->cursor;
- if (yych != '/') goto yy83;
+ if (yych == 'l') goto yy872;
+ goto yy50;
+yy782:
yych = *++lexer->cursor;
- if (yych != 'i') goto yy83;
+ if (yych == 'l') goto yy874;
+ goto yy50;
+yy783:
yych = *++lexer->cursor;
- if (yych == '3') goto yy784;
- if (yych == '6') goto yy785;
- goto yy83;
+ if (yych == 'b') goto yy876;
+ goto yy50;
yy784:
- yych = *++lexer->cursor;
- if (yych == '2') goto yy788;
- goto yy83;
-yy785:
- yych = *++lexer->cursor;
- if (yych != '4') goto yy83;
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (lexer->limit <= lexer->cursor) FILL(1);
+ yych = *lexer->cursor;
+ if (yych <= '@') {
+ if (yych <= '+') {
+ if (yych <= '"') {
+ if (yych == '!') goto yy49;
+ goto yy522;
+ } else {
+ if (yych <= '\'') goto yy49;
+ if (yych <= ')') goto yy522;
+ goto yy49;
+ }
+ } else {
+ if (yych <= '9') {
+ if (yych <= ',') goto yy522;
+ if (yych <= '/') goto yy49;
+ goto yy784;
+ } else {
+ if (yych == ';') goto yy522;
+ goto yy49;
+ }
+ }
+ } else {
+ if (yych <= '`') {
+ if (yych <= '[') {
+ if (yych <= 'F') goto yy784;
+ if (yych <= 'Z') goto yy49;
+ goto yy522;
+ } else {
+ if (yych == ']') goto yy522;
+ goto yy49;
+ }
+ } else {
+ if (yych <= '{') {
+ if (yych <= 'f') goto yy784;
+ if (yych <= 'z') goto yy49;
+ goto yy522;
+ } else {
+ if (yych == '}') goto yy522;
+ if (yych <= '~') goto yy49;
+ goto yy522;
+ }
+ }
}
-#line 409 "src/ast-lexer.c"
- { OPCODE(F64_CONVERT_U_I64); RETURN(CONVERT); }
-#line 3951 "src/prebuilt/ast-lexer-gen.c"
+yy786:
+ yych = *++lexer->cursor;
+ if (yych == 'h') goto yy877;
+ goto yy50;
+yy787:
+ yych = *++lexer->cursor;
+ if (yych == 'v') goto yy878;
+ goto yy50;
yy788:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 407 "src/ast-lexer.c"
- { OPCODE(F64_CONVERT_U_I32); RETURN(CONVERT); }
-#line 3959 "src/prebuilt/ast-lexer-gen.c"
+ yych = *++lexer->cursor;
+ if (yych == 'l') goto yy879;
+ goto yy50;
+yy789:
+ yych = *++lexer->cursor;
+ if (yych == 't') goto yy880;
+ goto yy50;
yy790:
yych = *++lexer->cursor;
- if (yych != 'i') goto yy83;
+ if (yych == 'a') goto yy881;
+ goto yy50;
+yy791:
yych = *++lexer->cursor;
- if (yych == '3') goto yy792;
- if (yych == '6') goto yy793;
- goto yy83;
+ if (yych == 'l') goto yy882;
+ goto yy50;
yy792:
yych = *++lexer->cursor;
- if (yych == '2') goto yy796;
- goto yy83;
+ if (yych == 'r') goto yy883;
+ goto yy50;
yy793:
yych = *++lexer->cursor;
- if (yych != '4') goto yy83;
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 405 "src/ast-lexer.c"
- { OPCODE(F64_CONVERT_S_I64); RETURN(CONVERT); }
-#line 3980 "src/prebuilt/ast-lexer-gen.c"
-yy796:
+ if (yych == 'r') goto yy884;
+ goto yy50;
+yy794:
+ yych = *++lexer->cursor;
+ if (yych == 'e') goto yy885;
+ goto yy50;
+yy795:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 403 "src/ast-lexer.c"
- { OPCODE(F64_CONVERT_S_I32); RETURN(CONVERT); }
-#line 3988 "src/prebuilt/ast-lexer-gen.c"
+#line 291 "src/ast-lexer.c"
+ { TYPE(F32); RETURN(CONST); }
+#line 5049 "src/prebuilt/ast-lexer-gen.c"
+yy797:
+ yych = *++lexer->cursor;
+ if (yych == 'r') goto yy886;
+ goto yy50;
yy798:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 292 "src/ast-lexer.c"
- { TYPE(F64); RETURN(CONST); }
-#line 3996 "src/prebuilt/ast-lexer-gen.c"
-yy800:
yych = *++lexer->cursor;
- if (yych != 'l') goto yy83;
+ if (yych == 'i') goto yy887;
+ goto yy50;
+yy799:
+ yych = *++lexer->cursor;
+ if (yych == 'e') goto yy888;
+ goto yy50;
+yy800:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 308 "src/ast-lexer.c"
- { OPCODE(F64_CEIL); RETURN(UNARY); }
-#line 4006 "src/prebuilt/ast-lexer-gen.c"
+#line 309 "src/ast-lexer.c"
+ { OPCODE(F32_FLOOR); RETURN(UNARY); }
+#line 5069 "src/prebuilt/ast-lexer-gen.c"
+yy802:
+ yych = *++lexer->cursor;
+ if (yych == 's') goto yy889;
+ goto yy50;
yy803:
yych = *++lexer->cursor;
- if (yych == 'r') goto yy812;
- goto yy83;
+ if (yych == 'e') goto yy890;
+ goto yy50;
yy804:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 270 "src/ast-lexer.c"
+ { OPCODE(F32_STORE); RETURN(STORE); }
+#line 5085 "src/prebuilt/ast-lexer-gen.c"
+yy806:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 311 "src/ast-lexer.c"
+ { OPCODE(F32_TRUNC); RETURN(UNARY); }
+#line 5093 "src/prebuilt/ast-lexer-gen.c"
+yy808:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 292 "src/ast-lexer.c"
+ { TYPE(F64); RETURN(CONST); }
+#line 5101 "src/prebuilt/ast-lexer-gen.c"
+yy810:
yych = *++lexer->cursor;
- if (yych == 'o') goto yy808;
- goto yy83;
-yy805:
+ if (yych == 'r') goto yy891;
+ goto yy50;
+yy811:
yych = *++lexer->cursor;
- if (yych != 'b') goto yy83;
+ if (yych == 'i') goto yy892;
+ goto yy50;
+yy812:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 348 "src/ast-lexer.c"
- { OPCODE(F64_SUB); RETURN(BINARY); }
-#line 4024 "src/prebuilt/ast-lexer-gen.c"
-yy808:
+#line 310 "src/ast-lexer.c"
+ { OPCODE(F64_FLOOR); RETURN(UNARY); }
+#line 5117 "src/prebuilt/ast-lexer-gen.c"
+yy814:
yych = *++lexer->cursor;
- if (yych != 'r') goto yy83;
+ if (yych == 's') goto yy893;
+ goto yy50;
+yy815:
+ yych = *++lexer->cursor;
+ if (yych == 't') goto yy894;
+ goto yy50;
+yy816:
yych = *++lexer->cursor;
- if (yych != 'e') goto yy83;
+ if (yych == 'e') goto yy895;
+ goto yy50;
+yy817:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
#line 271 "src/ast-lexer.c"
{ OPCODE(F64_STORE); RETURN(STORE); }
-#line 4036 "src/prebuilt/ast-lexer-gen.c"
-yy812:
- yych = *++lexer->cursor;
- if (yych != 't') goto yy83;
+#line 5137 "src/prebuilt/ast-lexer-gen.c"
+yy819:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 306 "src/ast-lexer.c"
- { OPCODE(F64_SQRT); RETURN(UNARY); }
-#line 4046 "src/prebuilt/ast-lexer-gen.c"
-yy815:
+#line 312 "src/ast-lexer.c"
+ { OPCODE(F64_TRUNC); RETURN(UNARY); }
+#line 5145 "src/prebuilt/ast-lexer-gen.c"
+yy821:
+ yych = *++lexer->cursor;
+ if (yych == 'l') goto yy896;
+ goto yy50;
+yy822:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 386 "src/ast-lexer.c"
- { OPCODE(F64_LE); RETURN(COMPARE); }
-#line 4054 "src/prebuilt/ast-lexer-gen.c"
-yy817:
+#line 259 "src/ast-lexer.c"
+ { RETURN(GET_LOCAL); }
+#line 5157 "src/prebuilt/ast-lexer-gen.c"
+yy824:
yych = *++lexer->cursor;
- if (yych == 'a') goto yy820;
- goto yy83;
-yy818:
+ if (yych == 'r') goto yy898;
+ goto yy50;
+yy825:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 384 "src/ast-lexer.c"
- { OPCODE(F64_LT); RETURN(COMPARE); }
-#line 4066 "src/prebuilt/ast-lexer-gen.c"
-yy820:
+#line 289 "src/ast-lexer.c"
+ { TYPE(I32); RETURN(CONST); }
+#line 5169 "src/prebuilt/ast-lexer-gen.c"
+yy827:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 321 "src/ast-lexer.c"
+ { OPCODE(I32_DIV_S); RETURN(BINARY); }
+#line 5177 "src/prebuilt/ast-lexer-gen.c"
+yy829:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 323 "src/ast-lexer.c"
+ { OPCODE(I32_DIV_U); RETURN(BINARY); }
+#line 5185 "src/prebuilt/ast-lexer-gen.c"
+yy831:
yych = *++lexer->cursor;
- if (yych != 'd') goto yy83;
+ if (yych == '6') goto yy899;
+ goto yy50;
+yy832:
+ yych = *++lexer->cursor;
+ if (yych == '_') goto yy900;
+ goto yy50;
+yy833:
+ yych = *++lexer->cursor;
+ if (yych == 't') goto yy901;
+ goto yy50;
+yy834:
+ yych = *++lexer->cursor;
+ if (yych == 'e') goto yy903;
+ goto yy50;
+yy835:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 267 "src/ast-lexer.c"
- { OPCODE(F64_LOAD); RETURN(LOAD); }
-#line 4076 "src/prebuilt/ast-lexer-gen.c"
-yy823:
+#line 325 "src/ast-lexer.c"
+ { OPCODE(I32_REM_S); RETURN(BINARY); }
+#line 5209 "src/prebuilt/ast-lexer-gen.c"
+yy837:
++lexer->cursor;
- if ((yych = *lexer->cursor) <= ':') {
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 327 "src/ast-lexer.c"
+ { OPCODE(I32_REM_U); RETURN(BINARY); }
+#line 5217 "src/prebuilt/ast-lexer-gen.c"
+yy839:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 337 "src/ast-lexer.c"
+ { OPCODE(I32_SHR_S); RETURN(BINARY); }
+#line 5225 "src/prebuilt/ast-lexer-gen.c"
+yy841:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 339 "src/ast-lexer.c"
+ { OPCODE(I32_SHR_U); RETURN(BINARY); }
+#line 5233 "src/prebuilt/ast-lexer-gen.c"
+yy843:
+ ++lexer->cursor;
+ if ((yych = *lexer->cursor) <= '8') {
if (yych <= ')') {
if (yych <= '!') {
- if (yych >= '!') goto yy82;
+ if (yych >= '!') goto yy49;
} else {
- if (yych <= '"') goto yy824;
- if (yych <= '\'') goto yy82;
+ if (yych <= '"') goto yy844;
+ if (yych <= '\'') goto yy49;
}
} else {
- if (yych <= ',') {
- if (yych <= '+') goto yy82;
+ if (yych <= '0') {
+ if (yych != ',') goto yy49;
} else {
- if (yych == '.') goto yy825;
- goto yy82;
+ if (yych <= '1') goto yy904;
+ if (yych <= '7') goto yy49;
+ goto yy905;
}
}
} else {
if (yych <= ']') {
if (yych <= 'Z') {
- if (yych >= '<') goto yy82;
+ if (yych != ';') goto yy49;
} else {
- if (yych == '\\') goto yy82;
+ if (yych == '\\') goto yy49;
}
} else {
if (yych <= '|') {
- if (yych != '{') goto yy82;
+ if (yych != '{') goto yy49;
} else {
- if (yych == '~') goto yy82;
+ if (yych == '~') goto yy49;
}
}
}
-yy824:
-#line 239 "src/ast-lexer.c"
- { TYPE(F32); RETURN(VALUE_TYPE); }
-#line 4113 "src/prebuilt/ast-lexer-gen.c"
-yy825:
+yy844:
+#line 268 "src/ast-lexer.c"
+ { OPCODE(I32_STORE); RETURN(STORE); }
+#line 5271 "src/prebuilt/ast-lexer-gen.c"
+yy845:
yych = *++lexer->cursor;
- switch (yych) {
- case 'a': goto yy830;
- case 'c': goto yy828;
- case 'd': goto yy834;
- case 'e': goto yy835;
- case 'f': goto yy831;
- case 'g': goto yy836;
- case 'l': goto yy826;
- case 'm': goto yy833;
- case 'n': goto yy829;
- case 'r': goto yy837;
- case 's': goto yy827;
- case 't': goto yy832;
- default: goto yy83;
- }
-yy826:
+ if (yych == '_') goto yy907;
+ goto yy50;
+yy846:
yych = *++lexer->cursor;
- if (yych <= 'n') {
- if (yych == 'e') goto yy958;
- goto yy83;
- } else {
- if (yych <= 'o') goto yy960;
- if (yych == 't') goto yy961;
- goto yy83;
+ if (yych == 'i') goto yy908;
+ goto yy50;
+yy847:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-yy827:
- yych = *++lexer->cursor;
- if (yych <= 's') {
- if (yych == 'q') goto yy946;
- goto yy83;
- } else {
- if (yych <= 't') goto yy947;
- if (yych <= 'u') goto yy948;
- goto yy83;
+#line 290 "src/ast-lexer.c"
+ { TYPE(I64); RETURN(CONST); }
+#line 5287 "src/prebuilt/ast-lexer-gen.c"
+yy849:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 322 "src/ast-lexer.c"
+ { OPCODE(I64_DIV_S); RETURN(BINARY); }
+#line 5295 "src/prebuilt/ast-lexer-gen.c"
+yy851:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-yy828:
+#line 324 "src/ast-lexer.c"
+ { OPCODE(I64_DIV_U); RETURN(BINARY); }
+#line 5303 "src/prebuilt/ast-lexer-gen.c"
+yy853:
yych = *++lexer->cursor;
- if (yych == 'e') goto yy907;
- if (yych == 'o') goto yy908;
- goto yy83;
-yy829:
+ if (yych == 'd') goto yy909;
+ goto yy50;
+yy854:
yych = *++lexer->cursor;
- if (yych == 'e') goto yy897;
- goto yy83;
-yy830:
+ if (yych == '6') goto yy910;
+ goto yy50;
+yy855:
yych = *++lexer->cursor;
- if (yych == 'b') goto yy891;
- if (yych == 'd') goto yy892;
- goto yy83;
-yy831:
+ if (yych == '2') goto yy911;
+ goto yy50;
+yy856:
yych = *++lexer->cursor;
- if (yych == 'l') goto yy886;
- goto yy83;
-yy832:
+ if (yych == '_') goto yy912;
+ goto yy50;
+yy857:
yych = *++lexer->cursor;
- if (yych == 'r') goto yy881;
- goto yy83;
-yy833:
+ if (yych == 't') goto yy913;
+ goto yy50;
+yy858:
yych = *++lexer->cursor;
- if (yych <= 'h') {
- if (yych == 'a') goto yy872;
- goto yy83;
+ if (yych == 'e') goto yy915;
+ goto yy50;
+yy859:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 326 "src/ast-lexer.c"
+ { OPCODE(I64_REM_S); RETURN(BINARY); }
+#line 5335 "src/prebuilt/ast-lexer-gen.c"
+yy861:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 328 "src/ast-lexer.c"
+ { OPCODE(I64_REM_U); RETURN(BINARY); }
+#line 5343 "src/prebuilt/ast-lexer-gen.c"
+yy863:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 338 "src/ast-lexer.c"
+ { OPCODE(I64_SHR_S); RETURN(BINARY); }
+#line 5351 "src/prebuilt/ast-lexer-gen.c"
+yy865:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 340 "src/ast-lexer.c"
+ { OPCODE(I64_SHR_U); RETURN(BINARY); }
+#line 5359 "src/prebuilt/ast-lexer-gen.c"
+yy867:
+ ++lexer->cursor;
+ if ((yych = *lexer->cursor) <= '7') {
+ if (yych <= '+') {
+ if (yych <= '"') {
+ if (yych == '!') goto yy49;
+ } else {
+ if (yych <= '\'') goto yy49;
+ if (yych >= '*') goto yy49;
+ }
+ } else {
+ if (yych <= '1') {
+ if (yych <= ',') goto yy868;
+ if (yych <= '0') goto yy49;
+ goto yy916;
+ } else {
+ if (yych == '3') goto yy917;
+ goto yy49;
+ }
+ }
} else {
- if (yych <= 'i') goto yy873;
- if (yych == 'u') goto yy874;
- goto yy83;
+ if (yych <= '\\') {
+ if (yych <= ';') {
+ if (yych <= '8') goto yy918;
+ if (yych <= ':') goto yy49;
+ } else {
+ if (yych != '[') goto yy49;
+ }
+ } else {
+ if (yych <= '{') {
+ if (yych <= ']') goto yy868;
+ if (yych <= 'z') goto yy49;
+ } else {
+ if (yych == '}') goto yy868;
+ if (yych <= '~') goto yy49;
+ }
+ }
}
-yy834:
- yych = *++lexer->cursor;
- if (yych == 'e') goto yy859;
- if (yych == 'i') goto yy860;
- goto yy83;
-yy835:
- yych = *++lexer->cursor;
- if (yych == 'q') goto yy857;
- goto yy83;
-yy836:
- yych = *++lexer->cursor;
- if (yych == 'e') goto yy853;
- if (yych == 't') goto yy855;
- goto yy83;
-yy837:
+yy868:
+#line 269 "src/ast-lexer.c"
+ { OPCODE(I64_STORE); RETURN(STORE); }
+#line 5401 "src/prebuilt/ast-lexer-gen.c"
+yy869:
yych = *++lexer->cursor;
- if (yych != 'e') goto yy83;
+ if (yych == '_') goto yy920;
+ goto yy50;
+yy870:
yych = *++lexer->cursor;
- if (yych != 'i') goto yy83;
+ if (yych <= '@') {
+ if (yych <= '/') goto yy50;
+ if (yych <= '9') goto yy921;
+ goto yy50;
+ } else {
+ if (yych <= 'F') goto yy921;
+ if (yych <= '`') goto yy50;
+ if (yych <= 'f') goto yy921;
+ goto yy50;
+ }
+yy871:
yych = *++lexer->cursor;
- if (yych != 'n') goto yy83;
+ if (yych == 'l') goto yy923;
+ goto yy50;
+yy872:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 260 "src/ast-lexer.c"
+ { RETURN(SET_LOCAL); }
+#line 5429 "src/prebuilt/ast-lexer-gen.c"
+yy874:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 261 "src/ast-lexer.c"
+ { RETURN(TEE_LOCAL); }
+#line 5437 "src/prebuilt/ast-lexer-gen.c"
+yy876:
yych = *++lexer->cursor;
- if (yych != 't') goto yy83;
+ if (yych == 'l') goto yy925;
+ goto yy50;
+yy877:
yych = *++lexer->cursor;
- if (yych != 'e') goto yy83;
+ if (yych == 'a') goto yy926;
+ goto yy50;
+yy878:
yych = *++lexer->cursor;
- if (yych != 'r') goto yy83;
+ if (yych == 'a') goto yy927;
+ goto yy50;
+yy879:
yych = *++lexer->cursor;
- if (yych != 'p') goto yy83;
+ if (yych == 'f') goto yy928;
+ goto yy50;
+yy880:
yych = *++lexer->cursor;
- if (yych != 'r') goto yy83;
+ if (yych == 'u') goto yy929;
+ goto yy50;
+yy881:
yych = *++lexer->cursor;
- if (yych != 'e') goto yy83;
+ if (yych == 'p') goto yy930;
+ goto yy50;
+yy882:
yych = *++lexer->cursor;
- if (yych != 't') goto yy83;
+ if (yych == 'i') goto yy932;
+ goto yy50;
+yy883:
yych = *++lexer->cursor;
- if (yych != '/') goto yy83;
+ if (yych == 't') goto yy933;
+ goto yy50;
+yy884:
yych = *++lexer->cursor;
- if (yych != 'i') goto yy83;
+ if (yych == 'e') goto yy935;
+ goto yy50;
+yy885:
yych = *++lexer->cursor;
- if (yych != '3') goto yy83;
+ if (yych == 'm') goto yy936;
+ goto yy50;
+yy886:
yych = *++lexer->cursor;
- if (yych != '2') goto yy83;
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 412 "src/ast-lexer.c"
- { OPCODE(F32_REINTERPRET_I32); RETURN(CONVERT); }
-#line 4232 "src/prebuilt/ast-lexer-gen.c"
-yy853:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 389 "src/ast-lexer.c"
- { OPCODE(F32_GE); RETURN(COMPARE); }
-#line 4240 "src/prebuilt/ast-lexer-gen.c"
-yy855:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 387 "src/ast-lexer.c"
- { OPCODE(F32_GT); RETURN(COMPARE); }
-#line 4248 "src/prebuilt/ast-lexer-gen.c"
-yy857:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 379 "src/ast-lexer.c"
- { OPCODE(F32_EQ); RETURN(COMPARE); }
-#line 4256 "src/prebuilt/ast-lexer-gen.c"
-yy859:
+ if (yych == 't') goto yy937;
+ goto yy50;
+yy887:
yych = *++lexer->cursor;
- if (yych == 'm') goto yy863;
- goto yy83;
-yy860:
+ if (yych == 'g') goto yy938;
+ goto yy50;
+yy888:
yych = *++lexer->cursor;
- if (yych != 'v') goto yy83;
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 351 "src/ast-lexer.c"
- { OPCODE(F32_DIV); RETURN(BINARY); }
-#line 4270 "src/prebuilt/ast-lexer-gen.c"
-yy863:
+ if (yych == '/') goto yy939;
+ goto yy50;
+yy889:
yych = *++lexer->cursor;
- if (yych != 'o') goto yy83;
+ if (yych == 't') goto yy940;
+ goto yy50;
+yy890:
yych = *++lexer->cursor;
- if (yych != 't') goto yy83;
+ if (yych == 'r') goto yy942;
+ goto yy50;
+yy891:
yych = *++lexer->cursor;
- if (yych != 'e') goto yy83;
+ if (yych == 't') goto yy943;
+ goto yy50;
+yy892:
yych = *++lexer->cursor;
- if (yych != '/') goto yy83;
+ if (yych == 'g') goto yy944;
+ goto yy50;
+yy893:
yych = *++lexer->cursor;
- if (yych != 'f') goto yy83;
+ if (yych == 't') goto yy945;
+ goto yy50;
+yy894:
yych = *++lexer->cursor;
- if (yych != '6') goto yy83;
+ if (yych == 'e') goto yy947;
+ goto yy50;
+yy895:
yych = *++lexer->cursor;
- if (yych != '4') goto yy83;
+ if (yych == 'r') goto yy948;
+ goto yy50;
+yy896:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 411 "src/ast-lexer.c"
- { OPCODE(F32_DEMOTE_F64); RETURN(CONVERT); }
-#line 4292 "src/prebuilt/ast-lexer-gen.c"
-yy872:
+#line 262 "src/ast-lexer.c"
+ { RETURN(GET_GLOBAL); }
+#line 5525 "src/prebuilt/ast-lexer-gen.c"
+yy898:
yych = *++lexer->cursor;
- if (yych == 'x') goto yy879;
- goto yy83;
-yy873:
+ if (yych == 'y') goto yy949;
+ goto yy50;
+yy899:
yych = *++lexer->cursor;
- if (yych == 'n') goto yy877;
- goto yy83;
-yy874:
+ if (yych == '_') goto yy951;
+ goto yy50;
+yy900:
yych = *++lexer->cursor;
- if (yych != 'l') goto yy83;
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 349 "src/ast-lexer.c"
- { OPCODE(F32_MUL); RETURN(BINARY); }
-#line 4310 "src/prebuilt/ast-lexer-gen.c"
-yy877:
+ if (yych == 's') goto yy952;
+ if (yych == 'u') goto yy954;
+ goto yy50;
+yy901:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 353 "src/ast-lexer.c"
- { OPCODE(F32_MIN); RETURN(BINARY); }
-#line 4318 "src/prebuilt/ast-lexer-gen.c"
-yy879:
+#line 299 "src/ast-lexer.c"
+ { OPCODE(I32_POPCNT); RETURN(UNARY); }
+#line 5546 "src/prebuilt/ast-lexer-gen.c"
+yy903:
+ yych = *++lexer->cursor;
+ if (yych == 'r') goto yy956;
+ goto yy50;
+yy904:
+ yych = *++lexer->cursor;
+ if (yych == '6') goto yy957;
+ goto yy50;
+yy905:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 355 "src/ast-lexer.c"
- { OPCODE(F32_MAX); RETURN(BINARY); }
-#line 4326 "src/prebuilt/ast-lexer-gen.c"
-yy881:
+#line 282 "src/ast-lexer.c"
+ { OPCODE(I32_STORE8); RETURN(STORE); }
+#line 5562 "src/prebuilt/ast-lexer-gen.c"
+yy907:
yych = *++lexer->cursor;
- if (yych != 'u') goto yy83;
+ if (yych == 's') goto yy959;
+ if (yych == 'u') goto yy960;
+ goto yy50;
+yy908:
yych = *++lexer->cursor;
- if (yych != 'n') goto yy83;
+ if (yych == '6') goto yy961;
+ goto yy50;
+yy909:
yych = *++lexer->cursor;
- if (yych != 'c') goto yy83;
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 311 "src/ast-lexer.c"
- { OPCODE(F32_TRUNC); RETURN(UNARY); }
-#line 4340 "src/prebuilt/ast-lexer-gen.c"
-yy886:
+ if (yych == '_') goto yy962;
+ goto yy50;
+yy910:
yych = *++lexer->cursor;
- if (yych != 'o') goto yy83;
+ if (yych == '_') goto yy963;
+ goto yy50;
+yy911:
yych = *++lexer->cursor;
- if (yych != 'o') goto yy83;
+ if (yych == '_') goto yy964;
+ goto yy50;
+yy912:
yych = *++lexer->cursor;
- if (yych != 'r') goto yy83;
+ if (yych == 's') goto yy965;
+ if (yych == 'u') goto yy967;
+ goto yy50;
+yy913:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 309 "src/ast-lexer.c"
- { OPCODE(F32_FLOOR); RETURN(UNARY); }
-#line 4354 "src/prebuilt/ast-lexer-gen.c"
-yy891:
+#line 300 "src/ast-lexer.c"
+ { OPCODE(I64_POPCNT); RETURN(UNARY); }
+#line 5596 "src/prebuilt/ast-lexer-gen.c"
+yy915:
yych = *++lexer->cursor;
- if (yych == 's') goto yy895;
- goto yy83;
-yy892:
+ if (yych == 'r') goto yy969;
+ goto yy50;
+yy916:
yych = *++lexer->cursor;
- if (yych != 'd') goto yy83;
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 345 "src/ast-lexer.c"
- { OPCODE(F32_ADD); RETURN(BINARY); }
-#line 4368 "src/prebuilt/ast-lexer-gen.c"
-yy895:
+ if (yych == '6') goto yy970;
+ goto yy50;
+yy917:
+ yych = *++lexer->cursor;
+ if (yych == '2') goto yy972;
+ goto yy50;
+yy918:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 303 "src/ast-lexer.c"
- { OPCODE(F32_ABS); RETURN(UNARY); }
-#line 4376 "src/prebuilt/ast-lexer-gen.c"
-yy897:
+#line 283 "src/ast-lexer.c"
+ { OPCODE(I64_STORE8); RETURN(STORE); }
+#line 5616 "src/prebuilt/ast-lexer-gen.c"
+yy920:
+ yych = *++lexer->cursor;
+ if (yych == 's') goto yy974;
+ if (yych == 'u') goto yy975;
+ goto yy50;
+yy921:
++lexer->cursor;
- if ((yych = *lexer->cursor) <= '[') {
- if (yych <= ')') {
- if (yych <= '!') {
- if (yych >= '!') goto yy82;
+ if (lexer->limit <= lexer->cursor) FILL(1);
+ yych = *lexer->cursor;
+ if (yych <= '@') {
+ if (yych <= '+') {
+ if (yych <= '"') {
+ if (yych == '!') goto yy49;
+ goto yy775;
} else {
- if (yych <= '"') goto yy898;
- if (yych <= '\'') goto yy82;
+ if (yych <= '\'') goto yy49;
+ if (yych <= ')') goto yy775;
+ goto yy49;
}
} else {
- if (yych <= ':') {
- if (yych != ',') goto yy82;
+ if (yych <= '9') {
+ if (yych <= ',') goto yy775;
+ if (yych <= '/') goto yy49;
+ goto yy921;
} else {
- if (yych <= ';') goto yy898;
- if (yych <= 'Z') goto yy82;
+ if (yych == ';') goto yy775;
+ goto yy49;
}
}
} else {
- if (yych <= 'g') {
- if (yych <= '`') {
- if (yych != ']') goto yy82;
+ if (yych <= '`') {
+ if (yych <= '[') {
+ if (yych <= 'F') goto yy921;
+ if (yych <= 'Z') goto yy49;
+ goto yy775;
} else {
- if (yych <= 'a') goto yy901;
- if (yych <= 'f') goto yy82;
- goto yy899;
+ if (yych == ']') goto yy775;
+ goto yy49;
}
} else {
- if (yych <= '|') {
- if (yych != '{') goto yy82;
+ if (yych <= '{') {
+ if (yych <= 'f') goto yy921;
+ if (yych <= 'z') goto yy49;
+ goto yy775;
} else {
- if (yych == '~') goto yy82;
+ if (yych == '}') goto yy775;
+ if (yych <= '~') goto yy49;
+ goto yy775;
}
}
}
-yy898:
-#line 381 "src/ast-lexer.c"
- { OPCODE(F32_NE); RETURN(COMPARE); }
-#line 4415 "src/prebuilt/ast-lexer-gen.c"
-yy899:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 301 "src/ast-lexer.c"
- { OPCODE(F32_NEG); RETURN(UNARY); }
-#line 4423 "src/prebuilt/ast-lexer-gen.c"
-yy901:
- yych = *++lexer->cursor;
- if (yych != 'r') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'e') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 's') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 't') goto yy83;
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 313 "src/ast-lexer.c"
- { OPCODE(F32_NEAREST); RETURN(UNARY); }
-#line 4439 "src/prebuilt/ast-lexer-gen.c"
-yy907:
- yych = *++lexer->cursor;
- if (yych == 'i') goto yy943;
- goto yy83;
-yy908:
- yych = *++lexer->cursor;
- if (yych == 'n') goto yy909;
- if (yych == 'p') goto yy910;
- goto yy83;
-yy909:
- yych = *++lexer->cursor;
- if (yych == 's') goto yy917;
- if (yych == 'v') goto yy918;
- goto yy83;
-yy910:
- yych = *++lexer->cursor;
- if (yych != 'y') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 's') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'i') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'g') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'n') goto yy83;
+yy923:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 357 "src/ast-lexer.c"
- { OPCODE(F32_COPYSIGN); RETURN(BINARY); }
-#line 4471 "src/prebuilt/ast-lexer-gen.c"
-yy917:
- yych = *++lexer->cursor;
- if (yych == 't') goto yy941;
- goto yy83;
-yy918:
- yych = *++lexer->cursor;
- if (yych != 'e') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'r') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 't') goto yy83;
- yych = *++lexer->cursor;
- if (yych != '_') goto yy83;
- yych = *++lexer->cursor;
- if (yych == 's') goto yy923;
- if (yych == 'u') goto yy924;
- goto yy83;
-yy923:
- yych = *++lexer->cursor;
- if (yych == '/') goto yy933;
- goto yy83;
-yy924:
- yych = *++lexer->cursor;
- if (yych != '/') goto yy83;
+#line 263 "src/ast-lexer.c"
+ { RETURN(SET_GLOBAL); }
+#line 5675 "src/prebuilt/ast-lexer-gen.c"
+yy925:
yych = *++lexer->cursor;
- if (yych != 'i') goto yy83;
+ if (yych == 'e') goto yy976;
+ goto yy50;
+yy926:
yych = *++lexer->cursor;
- if (yych == '3') goto yy927;
- if (yych == '6') goto yy928;
- goto yy83;
+ if (yych == 'u') goto yy978;
+ goto yy50;
yy927:
yych = *++lexer->cursor;
- if (yych == '2') goto yy931;
- goto yy83;
+ if (yych == 'l') goto yy979;
+ goto yy50;
yy928:
yych = *++lexer->cursor;
- if (yych != '4') goto yy83;
+ if (yych == 'o') goto yy980;
+ goto yy50;
+yy929:
+ yych = *++lexer->cursor;
+ if (yych == 'r') goto yy981;
+ goto yy50;
+yy930:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 408 "src/ast-lexer.c"
- { OPCODE(F32_CONVERT_U_I64); RETURN(CONVERT); }
-#line 4515 "src/prebuilt/ast-lexer-gen.c"
-yy931:
+#line 443 "src/ast-lexer.c"
+ { RETURN(ASSERT_TRAP); }
+#line 5703 "src/prebuilt/ast-lexer-gen.c"
+yy932:
+ yych = *++lexer->cursor;
+ if (yych == 'n') goto yy982;
+ goto yy50;
+yy933:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 406 "src/ast-lexer.c"
- { OPCODE(F32_CONVERT_U_I32); RETURN(CONVERT); }
-#line 4523 "src/prebuilt/ast-lexer-gen.c"
-yy933:
- yych = *++lexer->cursor;
- if (yych != 'i') goto yy83;
- yych = *++lexer->cursor;
- if (yych == '3') goto yy935;
- if (yych == '6') goto yy936;
- goto yy83;
+#line 254 "src/ast-lexer.c"
+ { RETURN(CALL_IMPORT); }
+#line 5715 "src/prebuilt/ast-lexer-gen.c"
yy935:
yych = *++lexer->cursor;
- if (yych == '2') goto yy939;
- goto yy83;
+ if (yych == 'c') goto yy983;
+ goto yy50;
yy936:
yych = *++lexer->cursor;
- if (yych != '4') goto yy83;
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 404 "src/ast-lexer.c"
- { OPCODE(F32_CONVERT_S_I64); RETURN(CONVERT); }
-#line 4544 "src/prebuilt/ast-lexer-gen.c"
+ if (yych == 'o') goto yy984;
+ goto yy50;
+yy937:
+ yych = *++lexer->cursor;
+ if (yych == '_') goto yy985;
+ goto yy50;
+yy938:
+ yych = *++lexer->cursor;
+ if (yych == 'n') goto yy986;
+ goto yy50;
yy939:
+ yych = *++lexer->cursor;
+ if (yych == 'f') goto yy988;
+ goto yy50;
+yy940:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 402 "src/ast-lexer.c"
- { OPCODE(F32_CONVERT_S_I32); RETURN(CONVERT); }
-#line 4552 "src/prebuilt/ast-lexer-gen.c"
-yy941:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 291 "src/ast-lexer.c"
- { TYPE(F32); RETURN(CONST); }
-#line 4560 "src/prebuilt/ast-lexer-gen.c"
+#line 313 "src/ast-lexer.c"
+ { OPCODE(F32_NEAREST); RETURN(UNARY); }
+#line 5743 "src/prebuilt/ast-lexer-gen.c"
+yy942:
+ yych = *++lexer->cursor;
+ if (yych == 'p') goto yy989;
+ goto yy50;
yy943:
yych = *++lexer->cursor;
- if (yych != 'l') goto yy83;
+ if (yych == '_') goto yy990;
+ goto yy50;
+yy944:
+ yych = *++lexer->cursor;
+ if (yych == 'n') goto yy991;
+ goto yy50;
+yy945:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 307 "src/ast-lexer.c"
- { OPCODE(F32_CEIL); RETURN(UNARY); }
-#line 4570 "src/prebuilt/ast-lexer-gen.c"
-yy946:
- yych = *++lexer->cursor;
- if (yych == 'r') goto yy955;
- goto yy83;
+#line 314 "src/ast-lexer.c"
+ { OPCODE(F64_NEAREST); RETURN(UNARY); }
+#line 5763 "src/prebuilt/ast-lexer-gen.c"
yy947:
yych = *++lexer->cursor;
- if (yych == 'o') goto yy951;
- goto yy83;
+ if (yych == '/') goto yy993;
+ goto yy50;
yy948:
yych = *++lexer->cursor;
- if (yych != 'b') goto yy83;
+ if (yych == 'p') goto yy994;
+ goto yy50;
+yy949:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 347 "src/ast-lexer.c"
- { OPCODE(F32_SUB); RETURN(BINARY); }
-#line 4588 "src/prebuilt/ast-lexer-gen.c"
+#line 419 "src/ast-lexer.c"
+ { RETURN(GROW_MEMORY); }
+#line 5779 "src/prebuilt/ast-lexer-gen.c"
yy951:
yych = *++lexer->cursor;
- if (yych != 'r') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'e') goto yy83;
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 270 "src/ast-lexer.c"
- { OPCODE(F32_STORE); RETURN(STORE); }
-#line 4600 "src/prebuilt/ast-lexer-gen.c"
-yy955:
- yych = *++lexer->cursor;
- if (yych != 't') goto yy83;
+ if (yych == 's') goto yy995;
+ if (yych == 'u') goto yy997;
+ goto yy50;
+yy952:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 305 "src/ast-lexer.c"
- { OPCODE(F32_SQRT); RETURN(UNARY); }
-#line 4610 "src/prebuilt/ast-lexer-gen.c"
-yy958:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 385 "src/ast-lexer.c"
- { OPCODE(F32_LE); RETURN(COMPARE); }
-#line 4618 "src/prebuilt/ast-lexer-gen.c"
-yy960:
- yych = *++lexer->cursor;
- if (yych == 'a') goto yy963;
- goto yy83;
-yy961:
+#line 272 "src/ast-lexer.c"
+ { OPCODE(I32_LOAD8_S); RETURN(LOAD); }
+#line 5792 "src/prebuilt/ast-lexer-gen.c"
+yy954:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 383 "src/ast-lexer.c"
- { OPCODE(F32_LT); RETURN(COMPARE); }
-#line 4630 "src/prebuilt/ast-lexer-gen.c"
-yy963:
+#line 274 "src/ast-lexer.c"
+ { OPCODE(I32_LOAD8_U); RETURN(LOAD); }
+#line 5800 "src/prebuilt/ast-lexer-gen.c"
+yy956:
yych = *++lexer->cursor;
- if (yych != 'd') goto yy83;
+ if (yych == 'p') goto yy999;
+ goto yy50;
+yy957:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 266 "src/ast-lexer.c"
- { OPCODE(F32_LOAD); RETURN(LOAD); }
-#line 4640 "src/prebuilt/ast-lexer-gen.c"
-yy966:
+#line 284 "src/ast-lexer.c"
+ { OPCODE(I32_STORE16); RETURN(STORE); }
+#line 5812 "src/prebuilt/ast-lexer-gen.c"
+yy959:
yych = *++lexer->cursor;
- if (yych == 'e') goto yy977;
- if (yych == 's') goto yy976;
- goto yy83;
-yy967:
+ if (yych == '/') goto yy1000;
+ goto yy50;
+yy960:
yych = *++lexer->cursor;
- if (yych == 'd') goto yy974;
- goto yy83;
-yy968:
+ if (yych == '/') goto yy1001;
+ goto yy50;
+yy961:
yych = *++lexer->cursor;
- if (yych != 'p') goto yy83;
+ if (yych == '4') goto yy1002;
+ goto yy50;
+yy962:
yych = *++lexer->cursor;
- if (yych != 'o') goto yy83;
+ if (yych == 's') goto yy1004;
+ if (yych == 'u') goto yy1005;
+ goto yy50;
+yy963:
yych = *++lexer->cursor;
- if (yych != 'r') goto yy83;
+ if (yych == 's') goto yy1006;
+ if (yych == 'u') goto yy1008;
+ goto yy50;
+yy964:
yych = *++lexer->cursor;
- if (yych != 't') goto yy83;
+ if (yych == 's') goto yy1010;
+ if (yych == 'u') goto yy1012;
+ goto yy50;
+yy965:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 434 "src/ast-lexer.c"
- { RETURN(EXPORT); }
-#line 4665 "src/prebuilt/ast-lexer-gen.c"
-yy974:
+#line 273 "src/ast-lexer.c"
+ { OPCODE(I64_LOAD8_S); RETURN(LOAD); }
+#line 5847 "src/prebuilt/ast-lexer-gen.c"
+yy967:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 257 "src/ast-lexer.c"
- { RETURN(END); }
-#line 4673 "src/prebuilt/ast-lexer-gen.c"
-yy976:
- yych = *++lexer->cursor;
- if (yych == 'e') goto yy980;
- goto yy83;
-yy977:
+#line 275 "src/ast-lexer.c"
+ { OPCODE(I64_LOAD8_U); RETURN(LOAD); }
+#line 5855 "src/prebuilt/ast-lexer-gen.c"
+yy969:
yych = *++lexer->cursor;
- if (yych != 'm') goto yy83;
+ if (yych == 'p') goto yy1014;
+ goto yy50;
+yy970:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 430 "src/ast-lexer.c"
- { RETURN(ELEM); }
-#line 4687 "src/prebuilt/ast-lexer-gen.c"
-yy980:
+#line 285 "src/ast-lexer.c"
+ { OPCODE(I64_STORE16); RETURN(STORE); }
+#line 5867 "src/prebuilt/ast-lexer-gen.c"
+yy972:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 248 "src/ast-lexer.c"
- { RETURN(ELSE); }
-#line 4695 "src/prebuilt/ast-lexer-gen.c"
-yy982:
- yych = *++lexer->cursor;
- if (yych == 't') goto yy987;
- goto yy83;
-yy983:
+#line 286 "src/ast-lexer.c"
+ { OPCODE(I64_STORE32); RETURN(STORE); }
+#line 5875 "src/prebuilt/ast-lexer-gen.c"
+yy974:
yych = *++lexer->cursor;
- if (yych != 'o') goto yy83;
+ if (yych == '/') goto yy1015;
+ goto yy50;
+yy975:
yych = *++lexer->cursor;
- if (yych != 'p') goto yy83;
+ if (yych == '/') goto yy1016;
+ goto yy50;
+yy976:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 256 "src/ast-lexer.c"
- { RETURN(DROP); }
-#line 4711 "src/prebuilt/ast-lexer-gen.c"
-yy987:
+#line 417 "src/ast-lexer.c"
+ { RETURN(UNREACHABLE); }
+#line 5891 "src/prebuilt/ast-lexer-gen.c"
+yy978:
yych = *++lexer->cursor;
- if (yych != 'a') goto yy83;
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 431 "src/ast-lexer.c"
- { RETURN(DATA); }
-#line 4721 "src/prebuilt/ast-lexer-gen.c"
-yy990:
+ if (yych == 's') goto yy1017;
+ goto yy50;
+yy979:
yych = *++lexer->cursor;
- if (yych == 'l') goto yy1005;
- goto yy83;
-yy991:
+ if (yych == 'i') goto yy1018;
+ goto yy50;
+yy980:
yych = *++lexer->cursor;
- if (yych != 'r') goto yy83;
+ if (yych == 'r') goto yy1019;
+ goto yy50;
+yy981:
yych = *++lexer->cursor;
- if (yych != 'r') goto yy83;
+ if (yych == 'n') goto yy1020;
+ goto yy50;
+yy982:
yych = *++lexer->cursor;
- if (yych != 'e') goto yy83;
+ if (yych == 'k') goto yy1022;
+ goto yy50;
+yy983:
yych = *++lexer->cursor;
- if (yych != 'n') goto yy83;
+ if (yych == 't') goto yy1023;
+ goto yy50;
+yy984:
yych = *++lexer->cursor;
- if (yych != 't') goto yy83;
+ if (yych == 'r') goto yy1025;
+ goto yy50;
+yy985:
yych = *++lexer->cursor;
- if (yych != '_') goto yy83;
+ if (yych == 's') goto yy1026;
+ if (yych == 'u') goto yy1027;
+ goto yy50;
+yy986:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 357 "src/ast-lexer.c"
+ { OPCODE(F32_COPYSIGN); RETURN(BINARY); }
+#line 5932 "src/prebuilt/ast-lexer-gen.c"
+yy988:
yych = *++lexer->cursor;
- if (yych != 'm') goto yy83;
+ if (yych == '6') goto yy1028;
+ goto yy50;
+yy989:
yych = *++lexer->cursor;
- if (yych != 'e') goto yy83;
+ if (yych == 'r') goto yy1029;
+ goto yy50;
+yy990:
yych = *++lexer->cursor;
- if (yych != 'm') goto yy83;
+ if (yych == 's') goto yy1030;
+ if (yych == 'u') goto yy1031;
+ goto yy50;
+yy991:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 358 "src/ast-lexer.c"
+ { OPCODE(F64_COPYSIGN); RETURN(BINARY); }
+#line 5953 "src/prebuilt/ast-lexer-gen.c"
+yy993:
yych = *++lexer->cursor;
- if (yych != 'o') goto yy83;
+ if (yych == 'f') goto yy1032;
+ goto yy50;
+yy994:
yych = *++lexer->cursor;
- if (yych != 'r') goto yy83;
+ if (yych == 'r') goto yy1033;
+ goto yy50;
+yy995:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 276 "src/ast-lexer.c"
+ { OPCODE(I32_LOAD16_S); RETURN(LOAD); }
+#line 5969 "src/prebuilt/ast-lexer-gen.c"
+yy997:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 278 "src/ast-lexer.c"
+ { OPCODE(I32_LOAD16_U); RETURN(LOAD); }
+#line 5977 "src/prebuilt/ast-lexer-gen.c"
+yy999:
+ yych = *++lexer->cursor;
+ if (yych == 'r') goto yy1034;
+ goto yy50;
+yy1000:
yych = *++lexer->cursor;
- if (yych != 'y') goto yy83;
+ if (yych == 'f') goto yy1035;
+ goto yy50;
+yy1001:
+ yych = *++lexer->cursor;
+ if (yych == 'f') goto yy1036;
+ goto yy50;
+yy1002:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 418 "src/ast-lexer.c"
- { RETURN(CURRENT_MEMORY); }
-#line 4757 "src/prebuilt/ast-lexer-gen.c"
+#line 393 "src/ast-lexer.c"
+ { OPCODE(I32_WRAP_I64); RETURN(CONVERT); }
+#line 5997 "src/prebuilt/ast-lexer-gen.c"
+yy1004:
+ yych = *++lexer->cursor;
+ if (yych == '/') goto yy1037;
+ goto yy50;
yy1005:
yych = *++lexer->cursor;
- if (yych != 'l') goto yy83;
+ if (yych == '/') goto yy1038;
+ goto yy50;
+yy1006:
++lexer->cursor;
- if ((yych = *lexer->cursor) <= 'Z') {
- if (yych <= ')') {
- if (yych <= '!') {
- if (yych >= '!') goto yy82;
- } else {
- if (yych <= '"') goto yy1007;
- if (yych <= '\'') goto yy82;
- }
- } else {
- if (yych <= ',') {
- if (yych <= '+') goto yy82;
- } else {
- if (yych != ';') goto yy82;
- }
- }
- } else {
- if (yych <= '_') {
- if (yych <= '\\') {
- if (yych >= '\\') goto yy82;
- } else {
- if (yych <= ']') goto yy1007;
- if (yych <= '^') goto yy82;
- goto yy1008;
- }
- } else {
- if (yych <= '|') {
- if (yych != '{') goto yy82;
- } else {
- if (yych == '~') goto yy82;
- }
- }
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-yy1007:
-#line 253 "src/ast-lexer.c"
- { RETURN(CALL); }
-#line 4797 "src/prebuilt/ast-lexer-gen.c"
+#line 277 "src/ast-lexer.c"
+ { OPCODE(I64_LOAD16_S); RETURN(LOAD); }
+#line 6013 "src/prebuilt/ast-lexer-gen.c"
yy1008:
- yych = *++lexer->cursor;
- if (yych != 'i') goto yy83;
- yych = *++lexer->cursor;
- if (yych <= 'l') goto yy83;
- if (yych <= 'm') goto yy1010;
- if (yych <= 'n') goto yy1011;
- goto yy83;
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 279 "src/ast-lexer.c"
+ { OPCODE(I64_LOAD16_U); RETURN(LOAD); }
+#line 6021 "src/prebuilt/ast-lexer-gen.c"
yy1010:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 280 "src/ast-lexer.c"
+ { OPCODE(I64_LOAD32_S); RETURN(LOAD); }
+#line 6029 "src/prebuilt/ast-lexer-gen.c"
+yy1012:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 281 "src/ast-lexer.c"
+ { OPCODE(I64_LOAD32_U); RETURN(LOAD); }
+#line 6037 "src/prebuilt/ast-lexer-gen.c"
+yy1014:
yych = *++lexer->cursor;
- if (yych == 'p') goto yy1019;
- goto yy83;
-yy1011:
- yych = *++lexer->cursor;
- if (yych != 'd') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'i') goto yy83;
+ if (yych == 'r') goto yy1039;
+ goto yy50;
+yy1015:
yych = *++lexer->cursor;
- if (yych != 'r') goto yy83;
+ if (yych == 'f') goto yy1040;
+ goto yy50;
+yy1016:
yych = *++lexer->cursor;
- if (yych != 'e') goto yy83;
+ if (yych == 'f') goto yy1041;
+ goto yy50;
+yy1017:
yych = *++lexer->cursor;
- if (yych != 'c') goto yy83;
+ if (yych == 't') goto yy1042;
+ goto yy50;
+yy1018:
yych = *++lexer->cursor;
- if (yych != 't') goto yy83;
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 255 "src/ast-lexer.c"
- { RETURN(CALL_INDIRECT); }
-#line 4829 "src/prebuilt/ast-lexer-gen.c"
+ if (yych == 'd') goto yy1043;
+ goto yy50;
yy1019:
yych = *++lexer->cursor;
- if (yych != 'o') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'r') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 't') goto yy83;
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 254 "src/ast-lexer.c"
- { RETURN(CALL_IMPORT); }
-#line 4843 "src/prebuilt/ast-lexer-gen.c"
-yy1024:
- yych = *++lexer->cursor;
- if (yych == 'o') goto yy1037;
- goto yy83;
-yy1025:
+ if (yych == 'm') goto yy1045;
+ goto yy50;
+yy1020:
++lexer->cursor;
if ((yych = *lexer->cursor) <= 'Z') {
if (yych <= ')') {
if (yych <= '!') {
- if (yych >= '!') goto yy82;
+ if (yych >= '!') goto yy49;
} else {
- if (yych <= '"') goto yy1026;
- if (yych <= '\'') goto yy82;
+ if (yych <= '"') goto yy1021;
+ if (yych <= '\'') goto yy49;
}
} else {
if (yych <= ',') {
- if (yych <= '+') goto yy82;
+ if (yych <= '+') goto yy49;
} else {
- if (yych != ';') goto yy82;
+ if (yych != ';') goto yy49;
}
}
} else {
if (yych <= '_') {
if (yych <= '\\') {
- if (yych >= '\\') goto yy82;
+ if (yych >= '\\') goto yy49;
} else {
- if (yych <= ']') goto yy1026;
- if (yych <= '^') goto yy82;
- goto yy1027;
+ if (yych <= ']') goto yy1021;
+ if (yych <= '^') goto yy49;
+ goto yy1046;
}
} else {
if (yych <= '|') {
- if (yych != '{') goto yy82;
+ if (yych != '{') goto yy49;
} else {
- if (yych == '~') goto yy82;
+ if (yych == '~') goto yy49;
}
}
}
+yy1021:
+#line 441 "src/ast-lexer.c"
+ { RETURN(ASSERT_RETURN); }
+#line 6099 "src/prebuilt/ast-lexer-gen.c"
+yy1022:
+ yych = *++lexer->cursor;
+ if (yych == 'a') goto yy1047;
+ goto yy50;
+yy1023:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 255 "src/ast-lexer.c"
+ { RETURN(CALL_INDIRECT); }
+#line 6111 "src/prebuilt/ast-lexer-gen.c"
+yy1025:
+ yych = *++lexer->cursor;
+ if (yych == 'y') goto yy1048;
+ goto yy50;
yy1026:
-#line 250 "src/ast-lexer.c"
- { RETURN(BR); }
-#line 4885 "src/prebuilt/ast-lexer-gen.c"
+ yych = *++lexer->cursor;
+ if (yych == '/') goto yy1050;
+ goto yy50;
yy1027:
yych = *++lexer->cursor;
- if (yych == 'i') goto yy1028;
- if (yych == 't') goto yy1029;
- goto yy83;
+ if (yych == '/') goto yy1051;
+ goto yy50;
yy1028:
yych = *++lexer->cursor;
- if (yych == 'f') goto yy1035;
- goto yy83;
+ if (yych == '4') goto yy1052;
+ goto yy50;
yy1029:
yych = *++lexer->cursor;
- if (yych != 'a') goto yy83;
+ if (yych == 'e') goto yy1054;
+ goto yy50;
+yy1030:
yych = *++lexer->cursor;
- if (yych != 'b') goto yy83;
+ if (yych == '/') goto yy1055;
+ goto yy50;
+yy1031:
yych = *++lexer->cursor;
- if (yych != 'l') goto yy83;
+ if (yych == '/') goto yy1056;
+ goto yy50;
+yy1032:
yych = *++lexer->cursor;
- if (yych != 'e') goto yy83;
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 252 "src/ast-lexer.c"
- { RETURN(BR_TABLE); }
-#line 4910 "src/prebuilt/ast-lexer-gen.c"
+ if (yych == '3') goto yy1057;
+ goto yy50;
+yy1033:
+ yych = *++lexer->cursor;
+ if (yych == 'e') goto yy1058;
+ goto yy50;
+yy1034:
+ yych = *++lexer->cursor;
+ if (yych == 'e') goto yy1059;
+ goto yy50;
yy1035:
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 251 "src/ast-lexer.c"
- { RETURN(BR_IF); }
-#line 4918 "src/prebuilt/ast-lexer-gen.c"
+ yych = *++lexer->cursor;
+ if (yych == '3') goto yy1060;
+ if (yych == '6') goto yy1061;
+ goto yy50;
+yy1036:
+ yych = *++lexer->cursor;
+ if (yych == '3') goto yy1062;
+ if (yych == '6') goto yy1063;
+ goto yy50;
yy1037:
yych = *++lexer->cursor;
- if (yych != 'c') goto yy83;
+ if (yych == 'i') goto yy1064;
+ goto yy50;
+yy1038:
yych = *++lexer->cursor;
- if (yych != 'k') goto yy83;
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 244 "src/ast-lexer.c"
- { RETURN(BLOCK); }
-#line 4930 "src/prebuilt/ast-lexer-gen.c"
+ if (yych == 'i') goto yy1065;
+ goto yy50;
+yy1039:
+ yych = *++lexer->cursor;
+ if (yych == 'e') goto yy1066;
+ goto yy50;
+yy1040:
+ yych = *++lexer->cursor;
+ if (yych == '3') goto yy1067;
+ if (yych == '6') goto yy1068;
+ goto yy50;
yy1041:
yych = *++lexer->cursor;
- if (yych == 'i') goto yy1112;
- goto yy83;
+ if (yych == '3') goto yy1069;
+ if (yych == '6') goto yy1070;
+ goto yy50;
yy1042:
yych = *++lexer->cursor;
- if (yych == 'y') goto yy1106;
- goto yy83;
+ if (yych == 'i') goto yy1071;
+ goto yy50;
yy1043:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 439 "src/ast-lexer.c"
+ { RETURN(ASSERT_INVALID); }
+#line 6195 "src/prebuilt/ast-lexer-gen.c"
+yy1045:
yych = *++lexer->cursor;
- if (yych != 's') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'e') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'r') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 't') goto yy83;
+ if (yych == 'e') goto yy1072;
+ goto yy50;
+yy1046:
yych = *++lexer->cursor;
- if (yych != '_') goto yy83;
+ if (yych == 'n') goto yy1073;
+ goto yy50;
+yy1047:
yych = *++lexer->cursor;
- switch (yych) {
- case 'e': goto yy1049;
- case 'i': goto yy1050;
- case 'm': goto yy1051;
- case 'r': goto yy1052;
- case 't': goto yy1053;
- case 'u': goto yy1054;
- default: goto yy83;
- }
-yy1049:
- yych = *++lexer->cursor;
- if (yych == 'x') goto yy1096;
- goto yy83;
+ if (yych == 'b') goto yy1074;
+ goto yy50;
+yy1048:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 418 "src/ast-lexer.c"
+ { RETURN(CURRENT_MEMORY); }
+#line 6215 "src/prebuilt/ast-lexer-gen.c"
yy1050:
yych = *++lexer->cursor;
- if (yych == 'n') goto yy1089;
- goto yy83;
+ if (yych == 'i') goto yy1075;
+ goto yy50;
yy1051:
yych = *++lexer->cursor;
- if (yych == 'a') goto yy1080;
- goto yy83;
+ if (yych == 'i') goto yy1076;
+ goto yy50;
yy1052:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 411 "src/ast-lexer.c"
+ { OPCODE(F32_DEMOTE_F64); RETURN(CONVERT); }
+#line 6231 "src/prebuilt/ast-lexer-gen.c"
+yy1054:
yych = *++lexer->cursor;
- if (yych == 'e') goto yy1069;
- goto yy83;
-yy1053:
+ if (yych == 't') goto yy1077;
+ goto yy50;
+yy1055:
yych = *++lexer->cursor;
- if (yych == 'r') goto yy1065;
- goto yy83;
-yy1054:
+ if (yych == 'i') goto yy1078;
+ goto yy50;
+yy1056:
yych = *++lexer->cursor;
- if (yych != 'n') goto yy83;
+ if (yych == 'i') goto yy1079;
+ goto yy50;
+yy1057:
yych = *++lexer->cursor;
- if (yych != 'l') goto yy83;
+ if (yych == '2') goto yy1080;
+ goto yy50;
+yy1058:
yych = *++lexer->cursor;
- if (yych != 'i') goto yy83;
+ if (yych == 't') goto yy1082;
+ goto yy50;
+yy1059:
yych = *++lexer->cursor;
- if (yych != 'n') goto yy83;
+ if (yych == 't') goto yy1083;
+ goto yy50;
+yy1060:
yych = *++lexer->cursor;
- if (yych != 'k') goto yy83;
+ if (yych == '2') goto yy1084;
+ goto yy50;
+yy1061:
yych = *++lexer->cursor;
- if (yych != 'a') goto yy83;
+ if (yych == '4') goto yy1086;
+ goto yy50;
+yy1062:
yych = *++lexer->cursor;
- if (yych != 'b') goto yy83;
+ if (yych == '2') goto yy1088;
+ goto yy50;
+yy1063:
yych = *++lexer->cursor;
- if (yych != 'l') goto yy83;
+ if (yych == '4') goto yy1090;
+ goto yy50;
+yy1064:
yych = *++lexer->cursor;
- if (yych != 'e') goto yy83;
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 440 "src/ast-lexer.c"
- { RETURN(ASSERT_UNLINKABLE); }
-#line 5005 "src/prebuilt/ast-lexer-gen.c"
+ if (yych == '3') goto yy1092;
+ goto yy50;
yy1065:
yych = *++lexer->cursor;
- if (yych != 'a') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'p') goto yy83;
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 443 "src/ast-lexer.c"
- { RETURN(ASSERT_TRAP); }
-#line 5017 "src/prebuilt/ast-lexer-gen.c"
-yy1069:
+ if (yych == '3') goto yy1093;
+ goto yy50;
+yy1066:
yych = *++lexer->cursor;
- if (yych != 't') goto yy83;
+ if (yych == 't') goto yy1094;
+ goto yy50;
+yy1067:
yych = *++lexer->cursor;
- if (yych != 'u') goto yy83;
+ if (yych == '2') goto yy1095;
+ goto yy50;
+yy1068:
yych = *++lexer->cursor;
- if (yych != 'r') goto yy83;
+ if (yych == '4') goto yy1097;
+ goto yy50;
+yy1069:
yych = *++lexer->cursor;
- if (yych != 'n') goto yy83;
- ++lexer->cursor;
- if ((yych = *lexer->cursor) <= 'Z') {
- if (yych <= ')') {
- if (yych <= '!') {
- if (yych >= '!') goto yy82;
- } else {
- if (yych <= '"') goto yy1074;
- if (yych <= '\'') goto yy82;
- }
- } else {
- if (yych <= ',') {
- if (yych <= '+') goto yy82;
- } else {
- if (yych != ';') goto yy82;
- }
- }
- } else {
- if (yych <= '_') {
- if (yych <= '\\') {
- if (yych >= '\\') goto yy82;
- } else {
- if (yych <= ']') goto yy1074;
- if (yych <= '^') goto yy82;
- goto yy1075;
- }
- } else {
- if (yych <= '|') {
- if (yych != '{') goto yy82;
- } else {
- if (yych == '~') goto yy82;
- }
- }
- }
-yy1074:
-#line 441 "src/ast-lexer.c"
- { RETURN(ASSERT_RETURN); }
-#line 5063 "src/prebuilt/ast-lexer-gen.c"
-yy1075:
+ if (yych == '2') goto yy1099;
+ goto yy50;
+yy1070:
yych = *++lexer->cursor;
- if (yych != 'n') goto yy83;
+ if (yych == '4') goto yy1101;
+ goto yy50;
+yy1071:
yych = *++lexer->cursor;
- if (yych != 'a') goto yy83;
+ if (yych == 'o') goto yy1103;
+ goto yy50;
+yy1072:
yych = *++lexer->cursor;
- if (yych != 'n') goto yy83;
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 442 "src/ast-lexer.c"
- { RETURN(ASSERT_RETURN_NAN); }
-#line 5077 "src/prebuilt/ast-lexer-gen.c"
-yy1080:
+ if (yych == 'd') goto yy1104;
+ goto yy50;
+yy1073:
yych = *++lexer->cursor;
- if (yych != 'l') goto yy83;
+ if (yych == 'a') goto yy1106;
+ goto yy50;
+yy1074:
yych = *++lexer->cursor;
- if (yych != 'f') goto yy83;
+ if (yych == 'l') goto yy1107;
+ goto yy50;
+yy1075:
yych = *++lexer->cursor;
- if (yych != 'o') goto yy83;
+ if (yych == '3') goto yy1108;
+ if (yych == '6') goto yy1109;
+ goto yy50;
+yy1076:
yych = *++lexer->cursor;
- if (yych != 'r') goto yy83;
+ if (yych == '3') goto yy1110;
+ if (yych == '6') goto yy1111;
+ goto yy50;
+yy1077:
yych = *++lexer->cursor;
- if (yych != 'm') goto yy83;
+ if (yych == '/') goto yy1112;
+ goto yy50;
+yy1078:
yych = *++lexer->cursor;
- if (yych != 'e') goto yy83;
+ if (yych == '3') goto yy1113;
+ if (yych == '6') goto yy1114;
+ goto yy50;
+yy1079:
yych = *++lexer->cursor;
- if (yych != 'd') goto yy83;
+ if (yych == '3') goto yy1115;
+ if (yych == '6') goto yy1116;
+ goto yy50;
+yy1080:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 438 "src/ast-lexer.c"
- { RETURN(ASSERT_MALFORMED); }
-#line 5099 "src/prebuilt/ast-lexer-gen.c"
-yy1089:
- yych = *++lexer->cursor;
- if (yych != 'v') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'a') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'l') goto yy83;
+#line 410 "src/ast-lexer.c"
+ { OPCODE(F64_PROMOTE_F32); RETURN(CONVERT); }
+#line 6347 "src/prebuilt/ast-lexer-gen.c"
+yy1082:
yych = *++lexer->cursor;
- if (yych != 'i') goto yy83;
+ if (yych == '/') goto yy1117;
+ goto yy50;
+yy1083:
yych = *++lexer->cursor;
- if (yych != 'd') goto yy83;
+ if (yych == '/') goto yy1118;
+ goto yy50;
+yy1084:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 439 "src/ast-lexer.c"
- { RETURN(ASSERT_INVALID); }
-#line 5117 "src/prebuilt/ast-lexer-gen.c"
-yy1096:
- yych = *++lexer->cursor;
- if (yych != 'h') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'a') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 'u') goto yy83;
- yych = *++lexer->cursor;
- if (yych != 's') goto yy83;
+#line 394 "src/ast-lexer.c"
+ { OPCODE(I32_TRUNC_S_F32); RETURN(CONVERT); }
+#line 6363 "src/prebuilt/ast-lexer-gen.c"
+yy1086:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 396 "src/ast-lexer.c"
+ { OPCODE(I32_TRUNC_S_F64); RETURN(CONVERT); }
+#line 6371 "src/prebuilt/ast-lexer-gen.c"
+yy1088:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 398 "src/ast-lexer.c"
+ { OPCODE(I32_TRUNC_U_F32); RETURN(CONVERT); }
+#line 6379 "src/prebuilt/ast-lexer-gen.c"
+yy1090:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 400 "src/ast-lexer.c"
+ { OPCODE(I32_TRUNC_U_F64); RETURN(CONVERT); }
+#line 6387 "src/prebuilt/ast-lexer-gen.c"
+yy1092:
yych = *++lexer->cursor;
- if (yych != 't') goto yy83;
+ if (yych == '2') goto yy1119;
+ goto yy50;
+yy1093:
yych = *++lexer->cursor;
- if (yych != 'i') goto yy83;
+ if (yych == '2') goto yy1121;
+ goto yy50;
+yy1094:
yych = *++lexer->cursor;
- if (yych != 'o') goto yy83;
+ if (yych == '/') goto yy1123;
+ goto yy50;
+yy1095:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 395 "src/ast-lexer.c"
+ { OPCODE(I64_TRUNC_S_F32); RETURN(CONVERT); }
+#line 6407 "src/prebuilt/ast-lexer-gen.c"
+yy1097:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 397 "src/ast-lexer.c"
+ { OPCODE(I64_TRUNC_S_F64); RETURN(CONVERT); }
+#line 6415 "src/prebuilt/ast-lexer-gen.c"
+yy1099:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 399 "src/ast-lexer.c"
+ { OPCODE(I64_TRUNC_U_F32); RETURN(CONVERT); }
+#line 6423 "src/prebuilt/ast-lexer-gen.c"
+yy1101:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 401 "src/ast-lexer.c"
+ { OPCODE(I64_TRUNC_U_F64); RETURN(CONVERT); }
+#line 6431 "src/prebuilt/ast-lexer-gen.c"
+yy1103:
yych = *++lexer->cursor;
- if (yych != 'n') goto yy83;
+ if (yych == 'n') goto yy1124;
+ goto yy50;
+yy1104:
++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-#line 444 "src/ast-lexer.c"
- { RETURN(ASSERT_EXHAUSTION); }
-#line 5141 "src/prebuilt/ast-lexer-gen.c"
+#line 438 "src/ast-lexer.c"
+ { RETURN(ASSERT_MALFORMED); }
+#line 6443 "src/prebuilt/ast-lexer-gen.c"
yy1106:
yych = *++lexer->cursor;
- if (yych != 'f') goto yy83;
+ if (yych == 'n') goto yy1126;
+ goto yy50;
+yy1107:
yych = *++lexer->cursor;
- if (yych != 'u') goto yy83;
+ if (yych == 'e') goto yy1128;
+ goto yy50;
+yy1108:
yych = *++lexer->cursor;
- if (yych != 'n') goto yy83;
+ if (yych == '2') goto yy1130;
+ goto yy50;
+yy1109:
yych = *++lexer->cursor;
- if (yych != 'c') goto yy83;
- ++lexer->cursor;
- if (yybm[0+(yych = *lexer->cursor)] & 8) {
- goto yy82;
- }
-#line 241 "src/ast-lexer.c"
- { RETURN(ANYFUNC); }
-#line 5157 "src/prebuilt/ast-lexer-gen.c"
+ if (yych == '4') goto yy1132;
+ goto yy50;
+yy1110:
+ yych = *++lexer->cursor;
+ if (yych == '2') goto yy1134;
+ goto yy50;
+yy1111:
+ yych = *++lexer->cursor;
+ if (yych == '4') goto yy1136;
+ goto yy50;
yy1112:
yych = *++lexer->cursor;
- if (yych != 'g') goto yy83;
+ if (yych == 'i') goto yy1138;
+ goto yy50;
+yy1113:
yych = *++lexer->cursor;
- if (yych != 'n') goto yy83;
+ if (yych == '2') goto yy1139;
+ goto yy50;
+yy1114:
yych = *++lexer->cursor;
- if (yych != '=') goto yy83;
+ if (yych == '4') goto yy1141;
+ goto yy50;
+yy1115:
yych = *++lexer->cursor;
- if (yych <= '/') goto yy83;
- if (yych <= '0') goto yy1116;
- if (yych <= '9') goto yy1118;
- goto yy83;
+ if (yych == '2') goto yy1143;
+ goto yy50;
yy1116:
- ++lexer->cursor;
- if ((yych = *lexer->cursor) <= ';') {
- if (yych <= ')') {
- if (yych <= '!') {
- if (yych >= '!') goto yy82;
- } else {
- if (yych <= '"') goto yy1117;
- if (yych <= '\'') goto yy82;
- }
- } else {
- if (yych <= '/') {
- if (yych != ',') goto yy82;
- } else {
- if (yych <= '9') goto yy1118;
- if (yych <= ':') goto yy82;
- }
- }
- } else {
- if (yych <= 'x') {
- if (yych <= '\\') {
- if (yych != '[') goto yy82;
- } else {
- if (yych <= ']') goto yy1117;
- if (yych <= 'w') goto yy82;
- goto yy1120;
- }
- } else {
- if (yych <= '|') {
- if (yych != '{') goto yy82;
- } else {
- if (yych == '~') goto yy82;
- }
- }
- }
+ yych = *++lexer->cursor;
+ if (yych == '4') goto yy1145;
+ goto yy50;
yy1117:
-#line 288 "src/ast-lexer.c"
- { TEXT_AT(6); RETURN(ALIGN_EQ_NAT); }
-#line 5208 "src/prebuilt/ast-lexer-gen.c"
+ yych = *++lexer->cursor;
+ if (yych == 'i') goto yy1147;
+ goto yy50;
yy1118:
- ++lexer->cursor;
- if (lexer->limit <= lexer->cursor) FILL(1);
- yych = *lexer->cursor;
- if (yych <= ':') {
- if (yych <= ')') {
- if (yych <= '!') {
- if (yych <= ' ') goto yy1117;
- goto yy82;
- } else {
- if (yych <= '"') goto yy1117;
- if (yych <= '\'') goto yy82;
- goto yy1117;
- }
- } else {
- if (yych <= ',') {
- if (yych <= '+') goto yy82;
- goto yy1117;
- } else {
- if (yych <= '/') goto yy82;
- if (yych <= '9') goto yy1118;
- goto yy82;
- }
- }
- } else {
- if (yych <= ']') {
- if (yych <= 'Z') {
- if (yych <= ';') goto yy1117;
- goto yy82;
- } else {
- if (yych == '\\') goto yy82;
- goto yy1117;
- }
- } else {
- if (yych <= '|') {
- if (yych == '{') goto yy1117;
- goto yy82;
- } else {
- if (yych == '~') goto yy82;
- goto yy1117;
- }
- }
- }
-yy1120:
yych = *++lexer->cursor;
- if (yych <= '@') {
- if (yych <= '/') goto yy83;
- if (yych >= ':') goto yy83;
- } else {
- if (yych <= 'F') goto yy1121;
- if (yych <= '`') goto yy83;
- if (yych >= 'g') goto yy83;
+ if (yych == 'f') goto yy1148;
+ goto yy50;
+yy1119:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
+#line 391 "src/ast-lexer.c"
+ { OPCODE(I64_EXTEND_S_I32); RETURN(CONVERT); }
+#line 6503 "src/prebuilt/ast-lexer-gen.c"
yy1121:
++lexer->cursor;
- if (lexer->limit <= lexer->cursor) FILL(1);
- yych = *lexer->cursor;
- if (yych <= '@') {
- if (yych <= '+') {
- if (yych <= '"') {
- if (yych == '!') goto yy82;
- goto yy1117;
- } else {
- if (yych <= '\'') goto yy82;
- if (yych <= ')') goto yy1117;
- goto yy82;
- }
- } else {
- if (yych <= '9') {
- if (yych <= ',') goto yy1117;
- if (yych <= '/') goto yy82;
- goto yy1121;
- } else {
- if (yych == ';') goto yy1117;
- goto yy82;
- }
- }
- } else {
- if (yych <= '`') {
- if (yych <= '[') {
- if (yych <= 'F') goto yy1121;
- if (yych <= 'Z') goto yy82;
- goto yy1117;
- } else {
- if (yych == ']') goto yy1117;
- goto yy82;
- }
- } else {
- if (yych <= '{') {
- if (yych <= 'f') goto yy1121;
- if (yych <= 'z') goto yy82;
- goto yy1117;
- } else {
- if (yych == '}') goto yy1117;
- if (yych <= '~') goto yy82;
- goto yy1117;
- }
- }
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
+#line 392 "src/ast-lexer.c"
+ { OPCODE(I64_EXTEND_U_I32); RETURN(CONVERT); }
+#line 6511 "src/prebuilt/ast-lexer-gen.c"
yy1123:
+ yych = *++lexer->cursor;
+ if (yych == 'f') goto yy1149;
+ goto yy50;
+yy1124:
++lexer->cursor;
- BEGIN(YYCOND_LINE_COMMENT);
-#line 449 "src/ast-lexer.c"
- { continue; }
-#line 5313 "src/prebuilt/ast-lexer-gen.c"
-yy1125:
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 444 "src/ast-lexer.c"
+ { RETURN(ASSERT_EXHAUSTION); }
+#line 6523 "src/prebuilt/ast-lexer-gen.c"
+yy1126:
++lexer->cursor;
- if ((lexer->limit - lexer->cursor) < 3) FILL(3);
- yych = *lexer->cursor;
- if (yych <= 'D') {
- if (yych <= '+') {
- if (yych <= '"') {
- if (yych == '!') goto yy82;
- } else {
- if (yych <= '\'') goto yy82;
- if (yych >= '*') goto yy82;
- }
- } else {
- if (yych <= '9') {
- if (yych <= ',') goto yy1127;
- if (yych <= '/') goto yy82;
- goto yy1125;
- } else {
- if (yych != ';') goto yy82;
- }
- }
- } else {
- if (yych <= 'd') {
- if (yych <= '[') {
- if (yych <= 'E') goto yy1130;
- if (yych <= 'Z') goto yy82;
- } else {
- if (yych != ']') goto yy82;
- }
- } else {
- if (yych <= '{') {
- if (yych <= 'e') goto yy1130;
- if (yych <= 'z') goto yy82;
- } else {
- if (yych == '}') goto yy1127;
- if (yych <= '~') goto yy82;
- }
- }
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-yy1127:
-#line 224 "src/ast-lexer.c"
- { LITERAL(FLOAT); RETURN(FLOAT); }
-#line 5356 "src/prebuilt/ast-lexer-gen.c"
+#line 442 "src/ast-lexer.c"
+ { RETURN(ASSERT_RETURN_NAN); }
+#line 6531 "src/prebuilt/ast-lexer-gen.c"
yy1128:
++lexer->cursor;
- if ((lexer->limit - lexer->cursor) < 3) FILL(3);
- yych = *lexer->cursor;
- if (yych <= ';') {
- if (yych <= '+') {
- if (yych <= '"') {
- if (yych == '!') goto yy82;
- goto yy62;
- } else {
- if (yych <= '\'') goto yy82;
- if (yych <= ')') goto yy62;
- goto yy82;
- }
- } else {
- if (yych <= '.') {
- if (yych <= ',') goto yy62;
- if (yych <= '-') goto yy82;
- goto yy1125;
- } else {
- if (yych <= '/') goto yy82;
- if (yych <= '9') goto yy1128;
- if (yych <= ':') goto yy82;
- goto yy62;
- }
- }
- } else {
- if (yych <= 'd') {
- if (yych <= 'Z') {
- if (yych != 'E') goto yy82;
- } else {
- if (yych == '\\') goto yy82;
- if (yych <= ']') goto yy62;
- goto yy82;
- }
- } else {
- if (yych <= '{') {
- if (yych <= 'e') goto yy1130;
- if (yych <= 'z') goto yy82;
- goto yy62;
- } else {
- if (yych == '}') goto yy62;
- if (yych <= '~') goto yy82;
- goto yy62;
- }
- }
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
+#line 440 "src/ast-lexer.c"
+ { RETURN(ASSERT_UNLINKABLE); }
+#line 6539 "src/prebuilt/ast-lexer-gen.c"
yy1130:
- yych = *++lexer->cursor;
- if (yych <= ',') {
- if (yych != '+') goto yy83;
- } else {
- if (yych <= '-') goto yy1131;
- if (yych <= '/') goto yy83;
- if (yych <= '9') goto yy1132;
- goto yy83;
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-yy1131:
- yych = *++lexer->cursor;
- if (yych <= '/') goto yy83;
- if (yych >= ':') goto yy83;
+#line 402 "src/ast-lexer.c"
+ { OPCODE(F32_CONVERT_S_I32); RETURN(CONVERT); }
+#line 6547 "src/prebuilt/ast-lexer-gen.c"
yy1132:
++lexer->cursor;
- if (lexer->limit <= lexer->cursor) FILL(1);
- yych = *lexer->cursor;
- if (yych <= ':') {
- if (yych <= ')') {
- if (yych <= '!') {
- if (yych <= ' ') goto yy1127;
- goto yy82;
- } else {
- if (yych <= '"') goto yy1127;
- if (yych <= '\'') goto yy82;
- goto yy1127;
- }
- } else {
- if (yych <= ',') {
- if (yych <= '+') goto yy82;
- goto yy1127;
- } else {
- if (yych <= '/') goto yy82;
- if (yych <= '9') goto yy1132;
- goto yy82;
- }
- }
- } else {
- if (yych <= ']') {
- if (yych <= 'Z') {
- if (yych <= ';') goto yy1127;
- goto yy82;
- } else {
- if (yych == '\\') goto yy82;
- goto yy1127;
- }
- } else {
- if (yych <= '|') {
- if (yych == '{') goto yy1127;
- goto yy82;
- } else {
- if (yych == '~') goto yy82;
- goto yy1127;
- }
- }
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
+#line 404 "src/ast-lexer.c"
+ { OPCODE(F32_CONVERT_S_I64); RETURN(CONVERT); }
+#line 6555 "src/prebuilt/ast-lexer-gen.c"
yy1134:
- yych = *++lexer->cursor;
- if (yych <= '@') {
- if (yych <= '/') goto yy83;
- if (yych >= ':') goto yy83;
- } else {
- if (yych <= 'F') goto yy1135;
- if (yych <= '`') goto yy83;
- if (yych >= 'g') goto yy83;
- }
-yy1135:
++lexer->cursor;
- if ((lexer->limit - lexer->cursor) < 3) FILL(3);
- yych = *lexer->cursor;
- if (yych <= '@') {
- if (yych <= ',') {
- if (yych <= '"') {
- if (yych == '!') goto yy82;
- goto yy62;
- } else {
- if (yych <= '\'') goto yy82;
- if (yych <= ')') goto yy62;
- if (yych <= '+') goto yy82;
- goto yy62;
- }
- } else {
- if (yych <= '/') {
- if (yych != '.') goto yy82;
- } else {
- if (yych <= '9') goto yy1135;
- if (yych == ';') goto yy62;
- goto yy82;
- }
- }
- } else {
- if (yych <= 'f') {
- if (yych <= '[') {
- if (yych <= 'F') goto yy1135;
- if (yych <= 'Z') goto yy82;
- goto yy62;
- } else {
- if (yych == ']') goto yy62;
- if (yych <= '`') goto yy82;
- goto yy1135;
- }
- } else {
- if (yych <= '{') {
- if (yych == 'p') goto yy1139;
- if (yych <= 'z') goto yy82;
- goto yy62;
- } else {
- if (yych == '}') goto yy62;
- if (yych <= '~') goto yy82;
- goto yy62;
- }
- }
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-yy1137:
+#line 406 "src/ast-lexer.c"
+ { OPCODE(F32_CONVERT_U_I32); RETURN(CONVERT); }
+#line 6563 "src/prebuilt/ast-lexer-gen.c"
+yy1136:
++lexer->cursor;
- if ((lexer->limit - lexer->cursor) < 3) FILL(3);
- yych = *lexer->cursor;
- if (yych <= 'F') {
- if (yych <= '+') {
- if (yych <= '"') {
- if (yych == '!') goto yy82;
- goto yy52;
- } else {
- if (yych <= '\'') goto yy82;
- if (yych <= ')') goto yy52;
- goto yy82;
- }
- } else {
- if (yych <= '9') {
- if (yych <= ',') goto yy52;
- if (yych <= '/') goto yy82;
- goto yy1137;
- } else {
- if (yych == ';') goto yy52;
- if (yych <= '@') goto yy82;
- goto yy1137;
- }
- }
- } else {
- if (yych <= 'o') {
- if (yych <= '\\') {
- if (yych == '[') goto yy52;
- goto yy82;
- } else {
- if (yych <= ']') goto yy52;
- if (yych <= '`') goto yy82;
- if (yych <= 'f') goto yy1137;
- goto yy82;
- }
- } else {
- if (yych <= '{') {
- if (yych <= 'p') goto yy1139;
- if (yych <= 'z') goto yy82;
- goto yy52;
- } else {
- if (yych == '}') goto yy52;
- if (yych <= '~') goto yy82;
- goto yy52;
- }
- }
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-yy1139:
+#line 408 "src/ast-lexer.c"
+ { OPCODE(F32_CONVERT_U_I64); RETURN(CONVERT); }
+#line 6571 "src/prebuilt/ast-lexer-gen.c"
+yy1138:
yych = *++lexer->cursor;
- if (yych <= ',') {
- if (yych != '+') goto yy83;
- } else {
- if (yych <= '-') goto yy1140;
- if (yych <= '/') goto yy83;
- if (yych <= '9') goto yy1141;
- goto yy83;
+ if (yych == '3') goto yy1150;
+ goto yy50;
+yy1139:
+ ++lexer->cursor;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-yy1140:
- yych = *++lexer->cursor;
- if (yych <= '/') goto yy83;
- if (yych >= ':') goto yy83;
+#line 403 "src/ast-lexer.c"
+ { OPCODE(F64_CONVERT_S_I32); RETURN(CONVERT); }
+#line 6583 "src/prebuilt/ast-lexer-gen.c"
yy1141:
++lexer->cursor;
- if (lexer->limit <= lexer->cursor) FILL(1);
- yych = *lexer->cursor;
- if (yych <= ':') {
- if (yych <= ')') {
- if (yych <= '!') {
- if (yych >= '!') goto yy82;
- } else {
- if (yych <= '"') goto yy1143;
- if (yych <= '\'') goto yy82;
- }
- } else {
- if (yych <= ',') {
- if (yych <= '+') goto yy82;
- } else {
- if (yych <= '/') goto yy82;
- if (yych <= '9') goto yy1141;
- goto yy82;
- }
- }
- } else {
- if (yych <= ']') {
- if (yych <= 'Z') {
- if (yych >= '<') goto yy82;
- } else {
- if (yych == '\\') goto yy82;
- }
- } else {
- if (yych <= '|') {
- if (yych != '{') goto yy82;
- } else {
- if (yych == '~') goto yy82;
- }
- }
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
+#line 405 "src/ast-lexer.c"
+ { OPCODE(F64_CONVERT_S_I64); RETURN(CONVERT); }
+#line 6591 "src/prebuilt/ast-lexer-gen.c"
yy1143:
-#line 225 "src/ast-lexer.c"
- { LITERAL(HEXFLOAT); RETURN(FLOAT); }
-#line 5619 "src/prebuilt/ast-lexer-gen.c"
-yy1144:
++lexer->cursor;
- if ((yych = *lexer->cursor) <= 'D') {
- if (yych <= ',') {
- if (yych <= '"') {
- if (yych == '!') goto yy82;
- } else {
- if (yych <= '\'') goto yy82;
- if (yych <= ')') goto yy1145;
- if (yych <= '+') goto yy82;
- }
- } else {
- if (yych <= '/') {
- if (yych == '.') goto yy1125;
- goto yy82;
- } else {
- if (yych <= '9') goto yy1146;
- if (yych != ';') goto yy82;
- }
- }
- } else {
- if (yych <= 'e') {
- if (yych <= '[') {
- if (yych <= 'E') goto yy1130;
- if (yych <= 'Z') goto yy82;
- } else {
- if (yych == ']') goto yy1145;
- if (yych <= 'd') goto yy82;
- goto yy1130;
- }
- } else {
- if (yych <= '{') {
- if (yych == 'x') goto yy1151;
- if (yych <= 'z') goto yy82;
- } else {
- if (yych == '}') goto yy1145;
- if (yych <= '~') goto yy82;
- }
- }
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
+#line 407 "src/ast-lexer.c"
+ { OPCODE(F64_CONVERT_U_I32); RETURN(CONVERT); }
+#line 6599 "src/prebuilt/ast-lexer-gen.c"
yy1145:
-#line 223 "src/ast-lexer.c"
- { LITERAL(INT); RETURN(INT); }
-#line 5663 "src/prebuilt/ast-lexer-gen.c"
-yy1146:
++lexer->cursor;
- if ((lexer->limit - lexer->cursor) < 3) FILL(3);
- yych = *lexer->cursor;
- if (yych <= ';') {
- if (yych <= '+') {
- if (yych <= '"') {
- if (yych == '!') goto yy82;
- goto yy1145;
- } else {
- if (yych <= '\'') goto yy82;
- if (yych <= ')') goto yy1145;
- goto yy82;
- }
- } else {
- if (yych <= '.') {
- if (yych <= ',') goto yy1145;
- if (yych <= '-') goto yy82;
- goto yy1125;
- } else {
- if (yych <= '/') goto yy82;
- if (yych <= '9') goto yy1146;
- if (yych <= ':') goto yy82;
- goto yy1145;
- }
- }
- } else {
- if (yych <= 'd') {
- if (yych <= 'Z') {
- if (yych == 'E') goto yy1130;
- goto yy82;
- } else {
- if (yych == '\\') goto yy82;
- if (yych <= ']') goto yy1145;
- goto yy82;
- }
- } else {
- if (yych <= '{') {
- if (yych <= 'e') goto yy1130;
- if (yych <= 'z') goto yy82;
- goto yy1145;
- } else {
- if (yych == '}') goto yy1145;
- if (yych <= '~') goto yy82;
- goto yy1145;
- }
- }
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
+#line 409 "src/ast-lexer.c"
+ { OPCODE(F64_CONVERT_U_I64); RETURN(CONVERT); }
+#line 6607 "src/prebuilt/ast-lexer-gen.c"
+yy1147:
+ yych = *++lexer->cursor;
+ if (yych == '6') goto yy1151;
+ goto yy50;
yy1148:
yych = *++lexer->cursor;
- if (yych == 'n') goto yy1150;
- goto yy83;
+ if (yych == '3') goto yy1152;
+ goto yy50;
yy1149:
yych = *++lexer->cursor;
- if (yych == 'a') goto yy186;
- goto yy83;
+ if (yych == '6') goto yy1153;
+ goto yy50;
yy1150:
yych = *++lexer->cursor;
- if (yych == 'f') goto yy226;
- goto yy83;
+ if (yych == '2') goto yy1154;
+ goto yy50;
yy1151:
yych = *++lexer->cursor;
- if (yych <= '@') {
- if (yych <= '/') goto yy83;
- if (yych >= ':') goto yy83;
- } else {
- if (yych <= 'F') goto yy1152;
- if (yych <= '`') goto yy83;
- if (yych >= 'g') goto yy83;
- }
+ if (yych == '4') goto yy1156;
+ goto yy50;
yy1152:
- ++lexer->cursor;
- if ((lexer->limit - lexer->cursor) < 3) FILL(3);
- yych = *lexer->cursor;
- if (yych <= '@') {
- if (yych <= ',') {
- if (yych <= '"') {
- if (yych == '!') goto yy82;
- goto yy1145;
- } else {
- if (yych <= '\'') goto yy82;
- if (yych <= ')') goto yy1145;
- if (yych <= '+') goto yy82;
- goto yy1145;
- }
- } else {
- if (yych <= '/') {
- if (yych == '.') goto yy1137;
- goto yy82;
- } else {
- if (yych <= '9') goto yy1152;
- if (yych == ';') goto yy1145;
- goto yy82;
- }
- }
- } else {
- if (yych <= 'f') {
- if (yych <= '[') {
- if (yych <= 'F') goto yy1152;
- if (yych <= 'Z') goto yy82;
- goto yy1145;
- } else {
- if (yych == ']') goto yy1145;
- if (yych <= '`') goto yy82;
- goto yy1152;
- }
- } else {
- if (yych <= '{') {
- if (yych == 'p') goto yy1139;
- if (yych <= 'z') goto yy82;
- goto yy1145;
- } else {
- if (yych == '}') goto yy1145;
- if (yych <= '~') goto yy82;
- goto yy1145;
- }
- }
- }
+ yych = *++lexer->cursor;
+ if (yych == '2') goto yy1158;
+ goto yy50;
+yy1153:
+ yych = *++lexer->cursor;
+ if (yych == '4') goto yy1160;
+ goto yy50;
yy1154:
++lexer->cursor;
- BEGIN(YYCOND_BLOCK_COMMENT);
-#line 452 "src/ast-lexer.c"
- { COMMENT_NESTING = 1; continue; }
-#line 5787 "src/prebuilt/ast-lexer-gen.c"
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
+ }
+#line 412 "src/ast-lexer.c"
+ { OPCODE(F32_REINTERPRET_I32); RETURN(CONVERT); }
+#line 6643 "src/prebuilt/ast-lexer-gen.c"
yy1156:
++lexer->cursor;
- if (lexer->limit <= lexer->cursor) FILL(1);
- yych = *lexer->cursor;
- if (yych <= ';') {
- if (yych <= '\'') {
- if (yych == '!') goto yy1156;
- if (yych >= '#') goto yy1156;
- } else {
- if (yych <= '+') {
- if (yych >= '*') goto yy1156;
- } else {
- if (yych <= ',') goto yy1158;
- if (yych <= ':') goto yy1156;
- }
- }
- } else {
- if (yych <= 'z') {
- if (yych <= '[') {
- if (yych <= 'Z') goto yy1156;
- } else {
- if (yych != ']') goto yy1156;
- }
- } else {
- if (yych <= '|') {
- if (yych >= '|') goto yy1156;
- } else {
- if (yych == '~') goto yy1156;
- }
- }
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
+#line 414 "src/ast-lexer.c"
+ { OPCODE(F64_REINTERPRET_I64); RETURN(CONVERT); }
+#line 6651 "src/prebuilt/ast-lexer-gen.c"
yy1158:
-#line 447 "src/ast-lexer.c"
- { TEXT; RETURN(VAR); }
-#line 5822 "src/prebuilt/ast-lexer-gen.c"
-yy1159:
- ++lexer->cursor;
- if (lexer->limit <= lexer->cursor) FILL(1);
- yych = *lexer->cursor;
-yy1160:
- if (yybm[0+yych] & 64) {
- goto yy1159;
- }
- if (yych <= '!') goto yy1161;
- if (yych <= '"') goto yy1163;
- if (yych <= '~') goto yy1162;
-yy1161:
- lexer->cursor = lexer->marker;
- goto yy54;
-yy1162:
- ++lexer->cursor;
- if (lexer->limit <= lexer->cursor) FILL(1);
- yych = *lexer->cursor;
- if (yych <= 'F') {
- if (yych <= '\'') {
- if (yych == '"') goto yy1159;
- if (yych <= '&') goto yy1161;
- goto yy1159;
- } else {
- if (yych <= '/') goto yy1161;
- if (yych <= '9') goto yy1165;
- if (yych <= '@') goto yy1161;
- goto yy1165;
- }
- } else {
- if (yych <= 'f') {
- if (yych == '\\') goto yy1159;
- if (yych <= '`') goto yy1161;
- goto yy1165;
- } else {
- if (yych <= 'n') {
- if (yych <= 'm') goto yy1161;
- goto yy1159;
- } else {
- if (yych == 't') goto yy1159;
- goto yy1161;
- }
- }
- }
-yy1163:
++lexer->cursor;
-#line 228 "src/ast-lexer.c"
- { TEXT; RETURN(TEXT); }
-#line 5871 "src/prebuilt/ast-lexer-gen.c"
-yy1165:
- ++lexer->cursor;
- if (lexer->limit <= lexer->cursor) FILL(1);
- yych = *lexer->cursor;
- if (yych <= '@') {
- if (yych <= '/') goto yy1161;
- if (yych <= '9') goto yy1159;
- goto yy1161;
- } else {
- if (yych <= 'F') goto yy1159;
- if (yych <= '`') goto yy1161;
- if (yych <= 'f') goto yy1159;
- goto yy1161;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
-yy1166:
+#line 413 "src/ast-lexer.c"
+ { OPCODE(I32_REINTERPRET_F32); RETURN(CONVERT); }
+#line 6659 "src/prebuilt/ast-lexer-gen.c"
+yy1160:
++lexer->cursor;
- if (lexer->limit <= lexer->cursor) FILL(1);
- yych = *lexer->cursor;
-yy1167:
- if (yybm[0+yych] & 128) {
- goto yy1166;
+ if (yybm[0+(yych = *lexer->cursor)] & 16) {
+ goto yy49;
}
- goto yy48;
+#line 415 "src/ast-lexer.c"
+ { OPCODE(I64_REINTERPRET_F64); RETURN(CONVERT); }
+#line 6667 "src/prebuilt/ast-lexer-gen.c"
}
}
#line 467 "src/ast-lexer.c"
@@ -5898,11 +6671,11 @@ yy1167:
}
}
-static WasmAstLexer* wasm_new_lexer(WasmAllocator* allocator,
- WasmAstLexerSourceType type,
+static WabtAstLexer* wabt_new_lexer(WabtAllocator* allocator,
+ WabtAstLexerSourceType type,
const char* filename) {
- WasmAstLexer* lexer =
- wasm_alloc_zero(allocator, sizeof(WasmAstLexer), WASM_DEFAULT_ALIGN);
+ WabtAstLexer* lexer =
+ wabt_alloc_zero(allocator, sizeof(WabtAstLexer), WABT_DEFAULT_ALIGN);
lexer->allocator = allocator;
lexer->line = 1;
lexer->filename = filename;
@@ -5910,62 +6683,62 @@ static WasmAstLexer* wasm_new_lexer(WasmAllocator* allocator,
return lexer;
}
-WasmAstLexer* wasm_new_ast_file_lexer(WasmAllocator* allocator,
+WabtAstLexer* wabt_new_ast_file_lexer(WabtAllocator* allocator,
const char* filename) {
- WasmAstLexer* lexer =
- wasm_new_lexer(allocator, WASM_LEXER_SOURCE_TYPE_FILE, filename);
+ WabtAstLexer* lexer =
+ wabt_new_lexer(allocator, WABT_LEXER_SOURCE_TYPE_FILE, filename);
lexer->source.file = fopen(filename, "rb");
if (!lexer->source.file) {
- wasm_destroy_ast_lexer(lexer);
+ wabt_destroy_ast_lexer(lexer);
return NULL;
}
return lexer;
}
-WasmAstLexer* wasm_new_ast_buffer_lexer(WasmAllocator* allocator,
+WabtAstLexer* wabt_new_ast_buffer_lexer(WabtAllocator* allocator,
const char* filename,
const void* data,
size_t size) {
- WasmAstLexer* lexer =
- wasm_new_lexer(allocator, WASM_LEXER_SOURCE_TYPE_BUFFER, filename);
+ WabtAstLexer* lexer =
+ wabt_new_lexer(allocator, WABT_LEXER_SOURCE_TYPE_BUFFER, filename);
lexer->source.buffer.data = data;
lexer->source.buffer.size = size;
lexer->source.buffer.read_offset = 0;
return lexer;
}
-void wasm_destroy_ast_lexer(WasmAstLexer* lexer) {
- if (lexer->source.type == WASM_LEXER_SOURCE_TYPE_FILE && lexer->source.file)
+void wabt_destroy_ast_lexer(WabtAstLexer* lexer) {
+ if (lexer->source.type == WABT_LEXER_SOURCE_TYPE_FILE && lexer->source.file)
fclose(lexer->source.file);
- wasm_free(lexer->allocator, lexer->buffer);
- wasm_free(lexer->allocator, lexer);
+ wabt_free(lexer->allocator, lexer->buffer);
+ wabt_free(lexer->allocator, lexer);
}
-WasmAllocator* wasm_ast_lexer_get_allocator(WasmAstLexer* lexer) {
+WabtAllocator* wabt_ast_lexer_get_allocator(WabtAstLexer* lexer) {
return lexer->allocator;
}
-typedef enum WasmLineOffsetPosition {
- WASM_LINE_OFFSET_POSITION_START,
- WASM_LINE_OFFSET_POSITION_END,
-} WasmLineOffsetPosition;
+typedef enum WabtLineOffsetPosition {
+ WABT_LINE_OFFSET_POSITION_START,
+ WABT_LINE_OFFSET_POSITION_END,
+} WabtLineOffsetPosition;
-static WasmResult scan_forward_for_line_offset_in_buffer(
+static WabtResult scan_forward_for_line_offset_in_buffer(
const char* buffer_start,
const char* buffer_end,
int buffer_line,
size_t buffer_file_offset,
- WasmLineOffsetPosition find_position,
+ WabtLineOffsetPosition find_position,
int find_line,
int* out_line,
size_t* out_line_offset) {
int line = buffer_line;
int line_offset = 0;
const char* p;
- WasmBool is_previous_carriage = 0;
+ WabtBool is_previous_carriage = 0;
for (p = buffer_start; p < buffer_end; ++p) {
if (*p == '\n') {
- if (find_position == WASM_LINE_OFFSET_POSITION_START) {
+ if (find_position == WABT_LINE_OFFSET_POSITION_START) {
if (++line == find_line) {
line_offset = buffer_file_offset + (p - buffer_start) + 1;
break;
@@ -5980,11 +6753,11 @@ static WasmResult scan_forward_for_line_offset_in_buffer(
is_previous_carriage = *p == '\r';
}
- WasmResult result = WASM_OK;
+ WabtResult result = WABT_OK;
if (p == buffer_end) {
/* end of buffer */
- if (find_position == WASM_LINE_OFFSET_POSITION_START) {
- result = WASM_ERROR;
+ if (find_position == WABT_LINE_OFFSET_POSITION_START) {
+ result = WABT_ERROR;
} else {
line_offset = buffer_file_offset + (buffer_end - buffer_start);
}
@@ -5995,33 +6768,33 @@ static WasmResult scan_forward_for_line_offset_in_buffer(
return result;
}
-static WasmResult scan_forward_for_line_offset_in_file(
- WasmAstLexer* lexer,
+static WabtResult scan_forward_for_line_offset_in_file(
+ WabtAstLexer* lexer,
int line,
size_t line_start_offset,
- WasmLineOffsetPosition find_position,
+ WabtLineOffsetPosition find_position,
int find_line,
size_t* out_line_offset) {
FILE* lexer_file = lexer->source.file;
- WasmResult result = WASM_ERROR;
+ WabtResult result = WABT_ERROR;
long old_offset = ftell(lexer_file);
if (old_offset == -1)
- return WASM_ERROR;
+ return WABT_ERROR;
size_t buffer_file_offset = line_start_offset;
if (fseek(lexer_file, buffer_file_offset, SEEK_SET) == -1)
goto cleanup;
while (1) {
char buffer[8 * 1024];
- const size_t buffer_size = WASM_ARRAY_SIZE(buffer);
+ const size_t buffer_size = WABT_ARRAY_SIZE(buffer);
size_t read_bytes = fread(buffer, 1, buffer_size, lexer_file);
if (read_bytes == 0) {
/* end of buffer */
- if (find_position == WASM_LINE_OFFSET_POSITION_START) {
- result = WASM_ERROR;
+ if (find_position == WABT_LINE_OFFSET_POSITION_START) {
+ result = WABT_ERROR;
} else {
*out_line_offset = buffer_file_offset + read_bytes;
- result = WASM_OK;
+ result = WABT_OK;
}
goto cleanup;
}
@@ -6030,7 +6803,7 @@ static WasmResult scan_forward_for_line_offset_in_file(
result = scan_forward_for_line_offset_in_buffer(
buffer, buffer_end, line, buffer_file_offset, find_position, find_line,
&line, out_line_offset);
- if (result == WASM_OK)
+ if (result == WABT_OK)
goto cleanup;
buffer_file_offset += read_bytes;
@@ -6039,19 +6812,19 @@ static WasmResult scan_forward_for_line_offset_in_file(
cleanup:
/* if this fails, we're screwed */
if (fseek(lexer_file, old_offset, SEEK_SET) == -1)
- return WASM_ERROR;
+ return WABT_ERROR;
return result;
}
-static WasmResult scan_forward_for_line_offset(
- WasmAstLexer* lexer,
+static WabtResult scan_forward_for_line_offset(
+ WabtAstLexer* lexer,
int line,
size_t line_start_offset,
- WasmLineOffsetPosition find_position,
+ WabtLineOffsetPosition find_position,
int find_line,
size_t* out_line_offset) {
assert(line <= find_line);
- if (lexer->source.type == WASM_LEXER_SOURCE_TYPE_BUFFER) {
+ if (lexer->source.type == WABT_LEXER_SOURCE_TYPE_BUFFER) {
const char* source_buffer = lexer->source.buffer.data;
const char* buffer_start = source_buffer + line_start_offset;
const char* buffer_end = source_buffer + lexer->source.buffer.size;
@@ -6059,14 +6832,14 @@ static WasmResult scan_forward_for_line_offset(
buffer_start, buffer_end, line, line_start_offset, find_position,
find_line, &line, out_line_offset);
} else {
- assert(lexer->source.type == WASM_LEXER_SOURCE_TYPE_FILE);
+ assert(lexer->source.type == WABT_LEXER_SOURCE_TYPE_FILE);
return scan_forward_for_line_offset_in_file(lexer, line, line_start_offset,
find_position, find_line,
out_line_offset);
}
}
-static WasmResult get_line_start_offset(WasmAstLexer* lexer,
+static WabtResult get_line_start_offset(WabtAstLexer* lexer,
int line,
size_t* out_offset) {
int first_line = 1;
@@ -6076,38 +6849,38 @@ static WasmResult get_line_start_offset(WasmAstLexer* lexer,
if (line == current_line) {
*out_offset = current_offset;
- return WASM_OK;
+ return WABT_OK;
} else if (line == first_line) {
*out_offset = first_offset;
- return WASM_OK;
+ return WABT_OK;
} else if (line > current_line) {
return scan_forward_for_line_offset(lexer, current_line, current_offset,
- WASM_LINE_OFFSET_POSITION_START, line,
+ WABT_LINE_OFFSET_POSITION_START, line,
out_offset);
} else {
/* TODO(binji): optimize by storing more known line/offset pairs */
return scan_forward_for_line_offset(lexer, first_line, first_offset,
- WASM_LINE_OFFSET_POSITION_START, line,
+ WABT_LINE_OFFSET_POSITION_START, line,
out_offset);
}
}
-static WasmResult get_offsets_from_line(WasmAstLexer* lexer,
+static WabtResult get_offsets_from_line(WabtAstLexer* lexer,
int line,
size_t* out_line_start,
size_t* out_line_end) {
size_t line_start;
- if (WASM_FAILED(get_line_start_offset(lexer, line, &line_start)))
- return WASM_ERROR;
+ if (WABT_FAILED(get_line_start_offset(lexer, line, &line_start)))
+ return WABT_ERROR;
size_t line_end;
- if (WASM_FAILED(scan_forward_for_line_offset(lexer, line, line_start,
- WASM_LINE_OFFSET_POSITION_END,
+ if (WABT_FAILED(scan_forward_for_line_offset(lexer, line, line_start,
+ WABT_LINE_OFFSET_POSITION_END,
line, &line_end)))
- return WASM_ERROR;
+ return WABT_ERROR;
*out_line_start = line_start;
*out_line_end = line_end;
- return WASM_OK;
+ return WABT_OK;
}
static void clamp_source_line_offsets_to_location(size_t line_start,
@@ -6139,17 +6912,17 @@ static void clamp_source_line_offsets_to_location(size_t line_start,
*out_new_line_end = line_end;
}
-WasmResult wasm_ast_lexer_get_source_line(WasmAstLexer* lexer,
- const WasmLocation* loc,
+WabtResult wabt_ast_lexer_get_source_line(WabtAstLexer* lexer,
+ const WabtLocation* loc,
size_t line_max_length,
char* line,
size_t* out_line_length,
int* out_column_offset) {
- WasmResult result;
+ WabtResult result;
size_t line_start; /* inclusive */
size_t line_end; /* exclusive */
result = get_offsets_from_line(lexer, loc->line, &line_start, &line_end);
- if (WASM_FAILED(result))
+ if (WABT_FAILED(result))
return result;
size_t new_line_start;
@@ -6157,8 +6930,8 @@ WasmResult wasm_ast_lexer_get_source_line(WasmAstLexer* lexer,
clamp_source_line_offsets_to_location(line_start, line_end, loc->first_column,
loc->last_column, line_max_length,
&new_line_start, &new_line_end);
- WasmBool has_start_ellipsis = line_start != new_line_start;
- WasmBool has_end_ellipsis = line_end != new_line_end;
+ WabtBool has_start_ellipsis = line_start != new_line_start;
+ WabtBool has_end_ellipsis = line_end != new_line_end;
char* write_start = line;
size_t line_length = new_line_end - new_line_start;
@@ -6175,26 +6948,26 @@ WasmResult wasm_ast_lexer_get_source_line(WasmAstLexer* lexer,
read_length -= 3;
}
- if (lexer->source.type == WASM_LEXER_SOURCE_TYPE_BUFFER) {
+ if (lexer->source.type == WABT_LEXER_SOURCE_TYPE_BUFFER) {
char* buffer_read_start = (char*)lexer->source.buffer.data + read_start;
memcpy(write_start, buffer_read_start, read_length);
} else {
- assert(lexer->source.type == WASM_LEXER_SOURCE_TYPE_FILE);
+ assert(lexer->source.type == WABT_LEXER_SOURCE_TYPE_FILE);
FILE* lexer_file = lexer->source.file;
long old_offset = ftell(lexer_file);
if (old_offset == -1)
- return WASM_ERROR;
+ return WABT_ERROR;
if (fseek(lexer_file, read_start, SEEK_SET) == -1)
- return WASM_ERROR;
+ return WABT_ERROR;
if (fread(write_start, 1, read_length, lexer_file) < read_length)
- return WASM_ERROR;
+ return WABT_ERROR;
if (fseek(lexer_file, old_offset, SEEK_SET) == -1)
- return WASM_ERROR;
+ return WABT_ERROR;
}
line[line_length] = '\0';
*out_line_length = line_length;
*out_column_offset = new_line_start - line_start;
- return WASM_OK;
+ return WABT_OK;
}
diff --git a/src/prebuilt/ast-parser-gen.c b/src/prebuilt/ast-parser-gen.c
index 797ea43f..0a1dcbc2 100644
--- a/src/prebuilt/ast-parser-gen.c
+++ b/src/prebuilt/ast-parser-gen.c
@@ -59,14 +59,14 @@
#define YYPULL 1
/* Substitute the type names. */
-#define YYSTYPE WASM_AST_PARSER_STYPE
-#define YYLTYPE WASM_AST_PARSER_LTYPE
+#define YYSTYPE WABT_AST_PARSER_STYPE
+#define YYLTYPE WABT_AST_PARSER_LTYPE
/* Substitute the variable and function names. */
-#define yyparse wasm_ast_parser_parse
-#define yylex wasm_ast_parser_lex
-#define yyerror wasm_ast_parser_error
-#define yydebug wasm_ast_parser_debug
-#define yynerrs wasm_ast_parser_nerrs
+#define yyparse wabt_ast_parser_parse
+#define yylex wabt_ast_parser_lex
+#define yyerror wabt_ast_parser_error
+#define yydebug wabt_ast_parser_debug
+#define yynerrs wabt_ast_parser_nerrs
/* Copy the first part of user declarations. */
@@ -98,7 +98,7 @@
#define YYMAXDEPTH 10000000
#define DUPTEXT(dst, src) \
- (dst).start = wasm_strndup(parser->allocator, (src).start, (src).length); \
+ (dst).start = wabt_strndup(parser->allocator, (src).start, (src).length); \
(dst).length = (src).length
#define YYLLOC_DEFAULT(Current, Rhs, N) \
@@ -118,23 +118,23 @@
#define APPEND_FIELD_TO_LIST(module, field, KIND, kind, loc_, item) \
do { \
- field = wasm_append_module_field(parser->allocator, module); \
+ field = wabt_append_module_field(parser->allocator, module); \
field->loc = loc_; \
- field->type = WASM_MODULE_FIELD_TYPE_##KIND; \
+ field->type = WABT_MODULE_FIELD_TYPE_##KIND; \
field->kind = item; \
} while (0)
#define APPEND_ITEM_TO_VECTOR(module, Kind, kind, kinds, item_ptr) \
do { \
- Wasm##Kind* dummy = item_ptr; \
- wasm_append_##kind##_ptr_value(parser->allocator, &(module)->kinds, \
+ Wabt##Kind* dummy = item_ptr; \
+ wabt_append_##kind##_ptr_value(parser->allocator, &(module)->kinds, \
&dummy); \
} while (0)
#define INSERT_BINDING(module, kind, kinds, loc_, name) \
do \
if ((name).start) { \
- WasmBinding* binding = wasm_insert_binding( \
+ WabtBinding* binding = wabt_insert_binding( \
parser->allocator, &(module)->kind##_bindings, &(name)); \
binding->loc = loc_; \
binding->index = (module)->kinds.size - 1; \
@@ -144,10 +144,10 @@
#define APPEND_INLINE_EXPORT(module, KIND, loc_, value, index_) \
do \
if ((value).export_.has_export) { \
- WasmModuleField* export_field; \
+ WabtModuleField* export_field; \
APPEND_FIELD_TO_LIST(module, export_field, EXPORT, export_, loc_, \
(value).export_.export_); \
- export_field->export_.kind = WASM_EXTERNAL_KIND_##KIND; \
+ export_field->export_.kind = WABT_EXTERNAL_KIND_##KIND; \
export_field->export_.var.loc = loc_; \
export_field->export_.var.index = index_; \
APPEND_ITEM_TO_VECTOR(module, Export, export, exports, \
@@ -160,7 +160,7 @@
#define CHECK_IMPORT_ORDERING(module, kind, kinds, loc_) \
do { \
if ((module)->kinds.size != (module)->num_##kind##_imports) { \
- wasm_ast_parser_error( \
+ wabt_ast_parser_error( \
&loc_, lexer, parser, \
"imports must occur before all non-import definitions"); \
} \
@@ -168,77 +168,77 @@
#define CHECK_END_LABEL(loc, begin_label, end_label) \
do { \
- if (!wasm_string_slice_is_empty(&(end_label))) { \
- if (wasm_string_slice_is_empty(&(begin_label))) { \
- wasm_ast_parser_error(&loc, lexer, parser, \
+ if (!wabt_string_slice_is_empty(&(end_label))) { \
+ if (wabt_string_slice_is_empty(&(begin_label))) { \
+ wabt_ast_parser_error(&loc, lexer, parser, \
"unexpected label \"" PRIstringslice "\"", \
- WASM_PRINTF_STRING_SLICE_ARG(end_label)); \
- } else if (!wasm_string_slices_are_equal(&(begin_label), \
+ WABT_PRINTF_STRING_SLICE_ARG(end_label)); \
+ } else if (!wabt_string_slices_are_equal(&(begin_label), \
&(end_label))) { \
- wasm_ast_parser_error(&loc, lexer, parser, \
+ wabt_ast_parser_error(&loc, lexer, parser, \
"mismatching label \"" PRIstringslice \
"\" != \"" PRIstringslice "\"", \
- WASM_PRINTF_STRING_SLICE_ARG(begin_label), \
- WASM_PRINTF_STRING_SLICE_ARG(end_label)); \
+ WABT_PRINTF_STRING_SLICE_ARG(begin_label), \
+ WABT_PRINTF_STRING_SLICE_ARG(end_label)); \
} \
- wasm_destroy_string_slice(parser->allocator, &(end_label)); \
+ wabt_destroy_string_slice(parser->allocator, &(end_label)); \
} \
} while (0)
-#define YYMALLOC(size) wasm_alloc(parser->allocator, size, WASM_DEFAULT_ALIGN)
-#define YYFREE(p) wasm_free(parser->allocator, p)
+#define YYMALLOC(size) wabt_alloc(parser->allocator, size, WABT_DEFAULT_ALIGN)
+#define YYFREE(p) wabt_free(parser->allocator, p)
#define USE_NATURAL_ALIGNMENT (~0)
-static WasmExprList join_exprs1(WasmLocation* loc, WasmExpr* expr1);
-static WasmExprList join_exprs2(WasmLocation* loc, WasmExprList* expr1,
- WasmExpr* expr2);
+static WabtExprList join_exprs1(WabtLocation* loc, WabtExpr* expr1);
+static WabtExprList join_exprs2(WabtLocation* loc, WabtExprList* expr1,
+ WabtExpr* expr2);
-static WasmFuncField* new_func_field(WasmAllocator* allocator) {
- return wasm_alloc_zero(allocator, sizeof(WasmFuncField), WASM_DEFAULT_ALIGN);
+static WabtFuncField* new_func_field(WabtAllocator* allocator) {
+ return wabt_alloc_zero(allocator, sizeof(WabtFuncField), WABT_DEFAULT_ALIGN);
}
-static WasmFunc* new_func(WasmAllocator* allocator) {
- return wasm_alloc_zero(allocator, sizeof(WasmFunc), WASM_DEFAULT_ALIGN);
+static WabtFunc* new_func(WabtAllocator* allocator) {
+ return wabt_alloc_zero(allocator, sizeof(WabtFunc), WABT_DEFAULT_ALIGN);
}
-static WasmCommand* new_command(WasmAllocator* allocator) {
- return wasm_alloc_zero(allocator, sizeof(WasmCommand), WASM_DEFAULT_ALIGN);
+static WabtCommand* new_command(WabtAllocator* allocator) {
+ return wabt_alloc_zero(allocator, sizeof(WabtCommand), WABT_DEFAULT_ALIGN);
}
-static WasmModule* new_module(WasmAllocator* allocator) {
- return wasm_alloc_zero(allocator, sizeof(WasmModule), WASM_DEFAULT_ALIGN);
+static WabtModule* new_module(WabtAllocator* allocator) {
+ return wabt_alloc_zero(allocator, sizeof(WabtModule), WABT_DEFAULT_ALIGN);
}
-static WasmImport* new_import(WasmAllocator* allocator) {
- return wasm_alloc_zero(allocator, sizeof(WasmImport), WASM_DEFAULT_ALIGN);
+static WabtImport* new_import(WabtAllocator* allocator) {
+ return wabt_alloc_zero(allocator, sizeof(WabtImport), WABT_DEFAULT_ALIGN);
}
-static WasmTextListNode* new_text_list_node(WasmAllocator* allocator) {
- return wasm_alloc_zero(allocator, sizeof(WasmTextListNode),
- WASM_DEFAULT_ALIGN);
+static WabtTextListNode* new_text_list_node(WabtAllocator* allocator) {
+ return wabt_alloc_zero(allocator, sizeof(WabtTextListNode),
+ WABT_DEFAULT_ALIGN);
}
-static WasmResult parse_const(WasmType type, WasmLiteralType literal_type,
- const char* s, const char* end, WasmConst* out);
-static void dup_text_list(WasmAllocator*, WasmTextList* text_list,
+static WabtResult parse_const(WabtType type, WabtLiteralType literal_type,
+ const char* s, const char* end, WabtConst* out);
+static void dup_text_list(WabtAllocator*, WabtTextList* text_list,
void** out_data, size_t* out_size);
-static WasmBool is_empty_signature(WasmFuncSignature* sig);
+static WabtBool is_empty_signature(WabtFuncSignature* sig);
-static void append_implicit_func_declaration(WasmAllocator*, WasmLocation*,
- WasmModule*, WasmFuncDeclaration*);
+static void append_implicit_func_declaration(WabtAllocator*, WabtLocation*,
+ WabtModule*, WabtFuncDeclaration*);
typedef struct BinaryErrorCallbackData {
- WasmLocation* loc;
- WasmAstLexer* lexer;
- WasmAstParser* parser;
+ WabtLocation* loc;
+ WabtAstLexer* lexer;
+ WabtAstParser* parser;
} BinaryErrorCallbackData;
static void on_read_binary_error(uint32_t offset, const char* error,
void* user_data);
-#define wasm_ast_parser_lex wasm_ast_lexer_lex
+#define wabt_ast_parser_lex wabt_ast_lexer_lex
#line 245 "src/prebuilt/ast-parser-gen.c" /* yacc.c:339 */
@@ -261,130 +261,130 @@ static void on_read_binary_error(uint32_t offset, const char* error,
/* In a future release of Bison, this section will be replaced
by #include "ast-parser-gen.h". */
-#ifndef YY_WASM_AST_PARSER_SRC_PREBUILT_AST_PARSER_GEN_H_INCLUDED
-# define YY_WASM_AST_PARSER_SRC_PREBUILT_AST_PARSER_GEN_H_INCLUDED
+#ifndef YY_WABT_AST_PARSER_SRC_PREBUILT_AST_PARSER_GEN_H_INCLUDED
+# define YY_WABT_AST_PARSER_SRC_PREBUILT_AST_PARSER_GEN_H_INCLUDED
/* Debug traces. */
-#ifndef WASM_AST_PARSER_DEBUG
+#ifndef WABT_AST_PARSER_DEBUG
# if defined YYDEBUG
#if YYDEBUG
-# define WASM_AST_PARSER_DEBUG 1
+# define WABT_AST_PARSER_DEBUG 1
# else
-# define WASM_AST_PARSER_DEBUG 0
+# define WABT_AST_PARSER_DEBUG 0
# endif
# else /* ! defined YYDEBUG */
-# define WASM_AST_PARSER_DEBUG 0
+# define WABT_AST_PARSER_DEBUG 0
# endif /* ! defined YYDEBUG */
-#endif /* ! defined WASM_AST_PARSER_DEBUG */
-#if WASM_AST_PARSER_DEBUG
-extern int wasm_ast_parser_debug;
+#endif /* ! defined WABT_AST_PARSER_DEBUG */
+#if WABT_AST_PARSER_DEBUG
+extern int wabt_ast_parser_debug;
#endif
/* Token type. */
-#ifndef WASM_AST_PARSER_TOKENTYPE
-# define WASM_AST_PARSER_TOKENTYPE
- enum wasm_ast_parser_tokentype
+#ifndef WABT_AST_PARSER_TOKENTYPE
+# define WABT_AST_PARSER_TOKENTYPE
+ enum wabt_ast_parser_tokentype
{
- WASM_TOKEN_TYPE_EOF = 0,
- WASM_TOKEN_TYPE_LPAR = 258,
- WASM_TOKEN_TYPE_RPAR = 259,
- WASM_TOKEN_TYPE_NAT = 260,
- WASM_TOKEN_TYPE_INT = 261,
- WASM_TOKEN_TYPE_FLOAT = 262,
- WASM_TOKEN_TYPE_TEXT = 263,
- WASM_TOKEN_TYPE_VAR = 264,
- WASM_TOKEN_TYPE_VALUE_TYPE = 265,
- WASM_TOKEN_TYPE_ANYFUNC = 266,
- WASM_TOKEN_TYPE_MUT = 267,
- WASM_TOKEN_TYPE_NOP = 268,
- WASM_TOKEN_TYPE_DROP = 269,
- WASM_TOKEN_TYPE_BLOCK = 270,
- WASM_TOKEN_TYPE_END = 271,
- WASM_TOKEN_TYPE_IF = 272,
- WASM_TOKEN_TYPE_THEN = 273,
- WASM_TOKEN_TYPE_ELSE = 274,
- WASM_TOKEN_TYPE_LOOP = 275,
- WASM_TOKEN_TYPE_BR = 276,
- WASM_TOKEN_TYPE_BR_IF = 277,
- WASM_TOKEN_TYPE_BR_TABLE = 278,
- WASM_TOKEN_TYPE_CALL = 279,
- WASM_TOKEN_TYPE_CALL_IMPORT = 280,
- WASM_TOKEN_TYPE_CALL_INDIRECT = 281,
- WASM_TOKEN_TYPE_RETURN = 282,
- WASM_TOKEN_TYPE_GET_LOCAL = 283,
- WASM_TOKEN_TYPE_SET_LOCAL = 284,
- WASM_TOKEN_TYPE_TEE_LOCAL = 285,
- WASM_TOKEN_TYPE_GET_GLOBAL = 286,
- WASM_TOKEN_TYPE_SET_GLOBAL = 287,
- WASM_TOKEN_TYPE_LOAD = 288,
- WASM_TOKEN_TYPE_STORE = 289,
- WASM_TOKEN_TYPE_OFFSET_EQ_NAT = 290,
- WASM_TOKEN_TYPE_ALIGN_EQ_NAT = 291,
- WASM_TOKEN_TYPE_CONST = 292,
- WASM_TOKEN_TYPE_UNARY = 293,
- WASM_TOKEN_TYPE_BINARY = 294,
- WASM_TOKEN_TYPE_COMPARE = 295,
- WASM_TOKEN_TYPE_CONVERT = 296,
- WASM_TOKEN_TYPE_SELECT = 297,
- WASM_TOKEN_TYPE_UNREACHABLE = 298,
- WASM_TOKEN_TYPE_CURRENT_MEMORY = 299,
- WASM_TOKEN_TYPE_GROW_MEMORY = 300,
- WASM_TOKEN_TYPE_FUNC = 301,
- WASM_TOKEN_TYPE_START = 302,
- WASM_TOKEN_TYPE_TYPE = 303,
- WASM_TOKEN_TYPE_PARAM = 304,
- WASM_TOKEN_TYPE_RESULT = 305,
- WASM_TOKEN_TYPE_LOCAL = 306,
- WASM_TOKEN_TYPE_GLOBAL = 307,
- WASM_TOKEN_TYPE_MODULE = 308,
- WASM_TOKEN_TYPE_TABLE = 309,
- WASM_TOKEN_TYPE_ELEM = 310,
- WASM_TOKEN_TYPE_MEMORY = 311,
- WASM_TOKEN_TYPE_DATA = 312,
- WASM_TOKEN_TYPE_OFFSET = 313,
- WASM_TOKEN_TYPE_IMPORT = 314,
- WASM_TOKEN_TYPE_EXPORT = 315,
- WASM_TOKEN_TYPE_REGISTER = 316,
- WASM_TOKEN_TYPE_INVOKE = 317,
- WASM_TOKEN_TYPE_GET = 318,
- WASM_TOKEN_TYPE_ASSERT_MALFORMED = 319,
- WASM_TOKEN_TYPE_ASSERT_INVALID = 320,
- WASM_TOKEN_TYPE_ASSERT_UNLINKABLE = 321,
- WASM_TOKEN_TYPE_ASSERT_RETURN = 322,
- WASM_TOKEN_TYPE_ASSERT_RETURN_NAN = 323,
- WASM_TOKEN_TYPE_ASSERT_TRAP = 324,
- WASM_TOKEN_TYPE_ASSERT_EXHAUSTION = 325,
- WASM_TOKEN_TYPE_INPUT = 326,
- WASM_TOKEN_TYPE_OUTPUT = 327,
- WASM_TOKEN_TYPE_LOW = 328
+ WABT_TOKEN_TYPE_EOF = 0,
+ WABT_TOKEN_TYPE_LPAR = 258,
+ WABT_TOKEN_TYPE_RPAR = 259,
+ WABT_TOKEN_TYPE_NAT = 260,
+ WABT_TOKEN_TYPE_INT = 261,
+ WABT_TOKEN_TYPE_FLOAT = 262,
+ WABT_TOKEN_TYPE_TEXT = 263,
+ WABT_TOKEN_TYPE_VAR = 264,
+ WABT_TOKEN_TYPE_VALUE_TYPE = 265,
+ WABT_TOKEN_TYPE_ANYFUNC = 266,
+ WABT_TOKEN_TYPE_MUT = 267,
+ WABT_TOKEN_TYPE_NOP = 268,
+ WABT_TOKEN_TYPE_DROP = 269,
+ WABT_TOKEN_TYPE_BLOCK = 270,
+ WABT_TOKEN_TYPE_END = 271,
+ WABT_TOKEN_TYPE_IF = 272,
+ WABT_TOKEN_TYPE_THEN = 273,
+ WABT_TOKEN_TYPE_ELSE = 274,
+ WABT_TOKEN_TYPE_LOOP = 275,
+ WABT_TOKEN_TYPE_BR = 276,
+ WABT_TOKEN_TYPE_BR_IF = 277,
+ WABT_TOKEN_TYPE_BR_TABLE = 278,
+ WABT_TOKEN_TYPE_CALL = 279,
+ WABT_TOKEN_TYPE_CALL_IMPORT = 280,
+ WABT_TOKEN_TYPE_CALL_INDIRECT = 281,
+ WABT_TOKEN_TYPE_RETURN = 282,
+ WABT_TOKEN_TYPE_GET_LOCAL = 283,
+ WABT_TOKEN_TYPE_SET_LOCAL = 284,
+ WABT_TOKEN_TYPE_TEE_LOCAL = 285,
+ WABT_TOKEN_TYPE_GET_GLOBAL = 286,
+ WABT_TOKEN_TYPE_SET_GLOBAL = 287,
+ WABT_TOKEN_TYPE_LOAD = 288,
+ WABT_TOKEN_TYPE_STORE = 289,
+ WABT_TOKEN_TYPE_OFFSET_EQ_NAT = 290,
+ WABT_TOKEN_TYPE_ALIGN_EQ_NAT = 291,
+ WABT_TOKEN_TYPE_CONST = 292,
+ WABT_TOKEN_TYPE_UNARY = 293,
+ WABT_TOKEN_TYPE_BINARY = 294,
+ WABT_TOKEN_TYPE_COMPARE = 295,
+ WABT_TOKEN_TYPE_CONVERT = 296,
+ WABT_TOKEN_TYPE_SELECT = 297,
+ WABT_TOKEN_TYPE_UNREACHABLE = 298,
+ WABT_TOKEN_TYPE_CURRENT_MEMORY = 299,
+ WABT_TOKEN_TYPE_GROW_MEMORY = 300,
+ WABT_TOKEN_TYPE_FUNC = 301,
+ WABT_TOKEN_TYPE_START = 302,
+ WABT_TOKEN_TYPE_TYPE = 303,
+ WABT_TOKEN_TYPE_PARAM = 304,
+ WABT_TOKEN_TYPE_RESULT = 305,
+ WABT_TOKEN_TYPE_LOCAL = 306,
+ WABT_TOKEN_TYPE_GLOBAL = 307,
+ WABT_TOKEN_TYPE_MODULE = 308,
+ WABT_TOKEN_TYPE_TABLE = 309,
+ WABT_TOKEN_TYPE_ELEM = 310,
+ WABT_TOKEN_TYPE_MEMORY = 311,
+ WABT_TOKEN_TYPE_DATA = 312,
+ WABT_TOKEN_TYPE_OFFSET = 313,
+ WABT_TOKEN_TYPE_IMPORT = 314,
+ WABT_TOKEN_TYPE_EXPORT = 315,
+ WABT_TOKEN_TYPE_REGISTER = 316,
+ WABT_TOKEN_TYPE_INVOKE = 317,
+ WABT_TOKEN_TYPE_GET = 318,
+ WABT_TOKEN_TYPE_ASSERT_MALFORMED = 319,
+ WABT_TOKEN_TYPE_ASSERT_INVALID = 320,
+ WABT_TOKEN_TYPE_ASSERT_UNLINKABLE = 321,
+ WABT_TOKEN_TYPE_ASSERT_RETURN = 322,
+ WABT_TOKEN_TYPE_ASSERT_RETURN_NAN = 323,
+ WABT_TOKEN_TYPE_ASSERT_TRAP = 324,
+ WABT_TOKEN_TYPE_ASSERT_EXHAUSTION = 325,
+ WABT_TOKEN_TYPE_INPUT = 326,
+ WABT_TOKEN_TYPE_OUTPUT = 327,
+ WABT_TOKEN_TYPE_LOW = 328
};
#endif
/* Value type. */
-#if ! defined WASM_AST_PARSER_STYPE && ! defined WASM_AST_PARSER_STYPE_IS_DECLARED
-typedef WasmToken WASM_AST_PARSER_STYPE;
-# define WASM_AST_PARSER_STYPE_IS_TRIVIAL 1
-# define WASM_AST_PARSER_STYPE_IS_DECLARED 1
+#if ! defined WABT_AST_PARSER_STYPE && ! defined WABT_AST_PARSER_STYPE_IS_DECLARED
+typedef WabtToken WABT_AST_PARSER_STYPE;
+# define WABT_AST_PARSER_STYPE_IS_TRIVIAL 1
+# define WABT_AST_PARSER_STYPE_IS_DECLARED 1
#endif
/* Location type. */
-#if ! defined WASM_AST_PARSER_LTYPE && ! defined WASM_AST_PARSER_LTYPE_IS_DECLARED
-typedef struct WASM_AST_PARSER_LTYPE WASM_AST_PARSER_LTYPE;
-struct WASM_AST_PARSER_LTYPE
+#if ! defined WABT_AST_PARSER_LTYPE && ! defined WABT_AST_PARSER_LTYPE_IS_DECLARED
+typedef struct WABT_AST_PARSER_LTYPE WABT_AST_PARSER_LTYPE;
+struct WABT_AST_PARSER_LTYPE
{
int first_line;
int first_column;
int last_line;
int last_column;
};
-# define WASM_AST_PARSER_LTYPE_IS_DECLARED 1
-# define WASM_AST_PARSER_LTYPE_IS_TRIVIAL 1
+# define WABT_AST_PARSER_LTYPE_IS_DECLARED 1
+# define WABT_AST_PARSER_LTYPE_IS_TRIVIAL 1
#endif
-int wasm_ast_parser_parse (WasmAstLexer* lexer, WasmAstParser* parser);
+int wabt_ast_parser_parse (WabtAstLexer* lexer, WabtAstParser* parser);
-#endif /* !YY_WASM_AST_PARSER_SRC_PREBUILT_AST_PARSER_GEN_H_INCLUDED */
+#endif /* !YY_WABT_AST_PARSER_SRC_PREBUILT_AST_PARSER_GEN_H_INCLUDED */
/* Copy the second part of user declarations. */
@@ -569,8 +569,8 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */
#if (! defined yyoverflow \
&& (! defined __cplusplus \
- || (defined WASM_AST_PARSER_LTYPE_IS_TRIVIAL && WASM_AST_PARSER_LTYPE_IS_TRIVIAL \
- && defined WASM_AST_PARSER_STYPE_IS_TRIVIAL && WASM_AST_PARSER_STYPE_IS_TRIVIAL)))
+ || (defined WABT_AST_PARSER_LTYPE_IS_TRIVIAL && WABT_AST_PARSER_LTYPE_IS_TRIVIAL \
+ && defined WABT_AST_PARSER_STYPE_IS_TRIVIAL && WABT_AST_PARSER_STYPE_IS_TRIVIAL)))
/* A type that is properly aligned for any stack member. */
union yyalloc
@@ -690,7 +690,7 @@ static const yytype_uint8 yytranslate[] =
65, 66, 67, 68, 69, 70, 71, 72, 73
};
-#if WASM_AST_PARSER_DEBUG
+#if WABT_AST_PARSER_DEBUG
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
static const yytype_uint16 yyrline[] =
{
@@ -715,7 +715,7 @@ static const yytype_uint16 yyrline[] =
};
#endif
-#if WASM_AST_PARSER_DEBUG || YYERROR_VERBOSE || 1
+#if WABT_AST_PARSER_DEBUG || YYERROR_VERBOSE || 1
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
static const char *const yytname[] =
@@ -1219,7 +1219,7 @@ while (0)
/* Enable debugging if requested. */
-#if WASM_AST_PARSER_DEBUG
+#if WABT_AST_PARSER_DEBUG
# ifndef YYFPRINTF
# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
@@ -1238,7 +1238,7 @@ do { \
we won't break user code: when these are the locations we know. */
#ifndef YY_LOCATION_PRINT
-# if defined WASM_AST_PARSER_LTYPE_IS_TRIVIAL && WASM_AST_PARSER_LTYPE_IS_TRIVIAL
+# if defined WABT_AST_PARSER_LTYPE_IS_TRIVIAL && WABT_AST_PARSER_LTYPE_IS_TRIVIAL
/* Print *YYLOCP on YYO. Private, do not rely on its existence. */
@@ -1294,7 +1294,7 @@ do { \
`----------------------------------------*/
static void
-yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, WasmAstLexer* lexer, WasmAstParser* parser)
+yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, WabtAstLexer* lexer, WabtAstParser* parser)
{
FILE *yyo = yyoutput;
YYUSE (yyo);
@@ -1316,7 +1316,7 @@ yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvalue
`--------------------------------*/
static void
-yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, WasmAstLexer* lexer, WasmAstParser* parser)
+yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, WabtAstLexer* lexer, WabtAstParser* parser)
{
YYFPRINTF (yyoutput, "%s %s (",
yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
@@ -1356,7 +1356,7 @@ do { \
`------------------------------------------------*/
static void
-yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, WasmAstLexer* lexer, WasmAstParser* parser)
+yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, WabtAstLexer* lexer, WabtAstParser* parser)
{
unsigned long int yylno = yyrline[yyrule];
int yynrhs = yyr2[yyrule];
@@ -1384,12 +1384,12 @@ do { \
/* Nonzero means print parse trace. It is left uninitialized so that
multiple parsers can coexist. */
int yydebug;
-#else /* !WASM_AST_PARSER_DEBUG */
+#else /* !WABT_AST_PARSER_DEBUG */
# define YYDPRINTF(Args)
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
# define YY_STACK_PRINT(Bottom, Top)
# define YY_REDUCE_PRINT(Rule)
-#endif /* !WASM_AST_PARSER_DEBUG */
+#endif /* !WABT_AST_PARSER_DEBUG */
/* YYINITDEPTH -- initial size of the parser's stacks. */
@@ -1636,7 +1636,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
`-----------------------------------------------*/
static void
-yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, WasmAstLexer* lexer, WasmAstParser* parser)
+yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, WabtAstLexer* lexer, WabtAstParser* parser)
{
YYUSE (yyvaluep);
YYUSE (yylocationp);
@@ -1693,289 +1693,289 @@ yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocatio
case 75: /* non_empty_text_list */
#line 282 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_text_list(parser->allocator, &((*yyvaluep).text_list)); }
+ { wabt_destroy_text_list(parser->allocator, &((*yyvaluep).text_list)); }
#line 1698 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 76: /* text_list */
#line 282 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_text_list(parser->allocator, &((*yyvaluep).text_list)); }
+ { wabt_destroy_text_list(parser->allocator, &((*yyvaluep).text_list)); }
#line 1704 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 77: /* quoted_text */
#line 281 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_string_slice(parser->allocator, &((*yyvaluep).text)); }
+ { wabt_destroy_string_slice(parser->allocator, &((*yyvaluep).text)); }
#line 1710 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 78: /* value_type_list */
#line 283 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_type_vector(parser->allocator, &((*yyvaluep).types)); }
+ { wabt_destroy_type_vector(parser->allocator, &((*yyvaluep).types)); }
#line 1716 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 81: /* func_type */
#line 273 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_func_signature(parser->allocator, &((*yyvaluep).func_sig)); }
+ { wabt_destroy_func_signature(parser->allocator, &((*yyvaluep).func_sig)); }
#line 1722 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 82: /* func_sig */
#line 273 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_func_signature(parser->allocator, &((*yyvaluep).func_sig)); }
+ { wabt_destroy_func_signature(parser->allocator, &((*yyvaluep).func_sig)); }
#line 1728 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 86: /* type_use */
#line 285 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_var(parser->allocator, &((*yyvaluep).var)); }
+ { wabt_destroy_var(parser->allocator, &((*yyvaluep).var)); }
#line 1734 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 88: /* literal */
#line 279 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_string_slice(parser->allocator, &((*yyvaluep).literal).text); }
+ { wabt_destroy_string_slice(parser->allocator, &((*yyvaluep).literal).text); }
#line 1740 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 89: /* var */
#line 285 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_var(parser->allocator, &((*yyvaluep).var)); }
+ { wabt_destroy_var(parser->allocator, &((*yyvaluep).var)); }
#line 1746 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 90: /* var_list */
#line 284 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_var_vector_and_elements(parser->allocator, &((*yyvaluep).vars)); }
+ { wabt_destroy_var_vector_and_elements(parser->allocator, &((*yyvaluep).vars)); }
#line 1752 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 91: /* bind_var_opt */
#line 281 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_string_slice(parser->allocator, &((*yyvaluep).text)); }
+ { wabt_destroy_string_slice(parser->allocator, &((*yyvaluep).text)); }
#line 1758 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 92: /* bind_var */
#line 281 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_string_slice(parser->allocator, &((*yyvaluep).text)); }
+ { wabt_destroy_string_slice(parser->allocator, &((*yyvaluep).text)); }
#line 1764 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 93: /* labeling_opt */
#line 281 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_string_slice(parser->allocator, &((*yyvaluep).text)); }
+ { wabt_destroy_string_slice(parser->allocator, &((*yyvaluep).text)); }
#line 1770 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 96: /* instr */
#line 270 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_expr_list(parser->allocator, ((*yyvaluep).expr_list).first); }
+ { wabt_destroy_expr_list(parser->allocator, ((*yyvaluep).expr_list).first); }
#line 1776 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 97: /* plain_instr */
#line 269 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_expr(parser->allocator, ((*yyvaluep).expr)); }
+ { wabt_destroy_expr(parser->allocator, ((*yyvaluep).expr)); }
#line 1782 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 98: /* block_instr */
#line 269 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_expr(parser->allocator, ((*yyvaluep).expr)); }
+ { wabt_destroy_expr(parser->allocator, ((*yyvaluep).expr)); }
#line 1788 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 99: /* block */
#line 260 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_block(parser->allocator, &((*yyvaluep).block)); }
+ { wabt_destroy_block(parser->allocator, &((*yyvaluep).block)); }
#line 1794 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 100: /* expr */
#line 270 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_expr_list(parser->allocator, ((*yyvaluep).expr_list).first); }
+ { wabt_destroy_expr_list(parser->allocator, ((*yyvaluep).expr_list).first); }
#line 1800 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 101: /* expr1 */
#line 270 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_expr_list(parser->allocator, ((*yyvaluep).expr_list).first); }
+ { wabt_destroy_expr_list(parser->allocator, ((*yyvaluep).expr_list).first); }
#line 1806 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 102: /* if_ */
#line 270 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_expr_list(parser->allocator, ((*yyvaluep).expr_list).first); }
+ { wabt_destroy_expr_list(parser->allocator, ((*yyvaluep).expr_list).first); }
#line 1812 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 103: /* instr_list */
#line 270 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_expr_list(parser->allocator, ((*yyvaluep).expr_list).first); }
+ { wabt_destroy_expr_list(parser->allocator, ((*yyvaluep).expr_list).first); }
#line 1818 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 104: /* expr_list */
#line 270 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_expr_list(parser->allocator, ((*yyvaluep).expr_list).first); }
+ { wabt_destroy_expr_list(parser->allocator, ((*yyvaluep).expr_list).first); }
#line 1824 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 105: /* const_expr */
#line 270 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_expr_list(parser->allocator, ((*yyvaluep).expr_list).first); }
+ { wabt_destroy_expr_list(parser->allocator, ((*yyvaluep).expr_list).first); }
#line 1830 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 106: /* func_fields */
#line 271 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_func_fields(parser->allocator, ((*yyvaluep).func_fields)); }
+ { wabt_destroy_func_fields(parser->allocator, ((*yyvaluep).func_fields)); }
#line 1836 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 107: /* func_body */
#line 271 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_func_fields(parser->allocator, ((*yyvaluep).func_fields)); }
+ { wabt_destroy_func_fields(parser->allocator, ((*yyvaluep).func_fields)); }
#line 1842 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 108: /* func_info */
#line 272 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_func(parser->allocator, ((*yyvaluep).func)); wasm_free(parser->allocator, ((*yyvaluep).func)); }
+ { wabt_destroy_func(parser->allocator, ((*yyvaluep).func)); wabt_free(parser->allocator, ((*yyvaluep).func)); }
#line 1848 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 109: /* func */
#line 266 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_exported_func(parser->allocator, &((*yyvaluep).exported_func)); }
+ { wabt_destroy_exported_func(parser->allocator, &((*yyvaluep).exported_func)); }
#line 1854 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 110: /* offset */
#line 270 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_expr_list(parser->allocator, ((*yyvaluep).expr_list).first); }
+ { wabt_destroy_expr_list(parser->allocator, ((*yyvaluep).expr_list).first); }
#line 1860 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 111: /* elem */
#line 264 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_elem_segment(parser->allocator, &((*yyvaluep).elem_segment)); }
+ { wabt_destroy_elem_segment(parser->allocator, &((*yyvaluep).elem_segment)); }
#line 1866 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 112: /* table */
#line 268 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_exported_table(parser->allocator, &((*yyvaluep).exported_table)); }
+ { wabt_destroy_exported_table(parser->allocator, &((*yyvaluep).exported_table)); }
#line 1872 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 113: /* data */
#line 276 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_data_segment(parser->allocator, &((*yyvaluep).data_segment)); }
+ { wabt_destroy_data_segment(parser->allocator, &((*yyvaluep).data_segment)); }
#line 1878 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 114: /* memory */
#line 267 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_exported_memory(parser->allocator, &((*yyvaluep).exported_memory)); }
+ { wabt_destroy_exported_memory(parser->allocator, &((*yyvaluep).exported_memory)); }
#line 1884 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 116: /* import_kind */
#line 275 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_import(parser->allocator, ((*yyvaluep).import)); wasm_free(parser->allocator, ((*yyvaluep).import)); }
+ { wabt_destroy_import(parser->allocator, ((*yyvaluep).import)); wabt_free(parser->allocator, ((*yyvaluep).import)); }
#line 1890 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 117: /* import */
#line 275 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_import(parser->allocator, ((*yyvaluep).import)); wasm_free(parser->allocator, ((*yyvaluep).import)); }
+ { wabt_destroy_import(parser->allocator, ((*yyvaluep).import)); wabt_free(parser->allocator, ((*yyvaluep).import)); }
#line 1896 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 118: /* inline_import */
#line 275 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_import(parser->allocator, ((*yyvaluep).import)); wasm_free(parser->allocator, ((*yyvaluep).import)); }
+ { wabt_destroy_import(parser->allocator, ((*yyvaluep).import)); wabt_free(parser->allocator, ((*yyvaluep).import)); }
#line 1902 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 119: /* export_kind */
#line 265 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_export(parser->allocator, &((*yyvaluep).export_)); }
+ { wabt_destroy_export(parser->allocator, &((*yyvaluep).export_)); }
#line 1908 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 120: /* export */
#line 265 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_export(parser->allocator, &((*yyvaluep).export_)); }
+ { wabt_destroy_export(parser->allocator, &((*yyvaluep).export_)); }
#line 1914 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 123: /* type_def */
#line 274 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_func_type(parser->allocator, &((*yyvaluep).func_type)); }
+ { wabt_destroy_func_type(parser->allocator, &((*yyvaluep).func_type)); }
#line 1920 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 124: /* start */
#line 285 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_var(parser->allocator, &((*yyvaluep).var)); }
+ { wabt_destroy_var(parser->allocator, &((*yyvaluep).var)); }
#line 1926 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 125: /* module_fields */
#line 277 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_module(parser->allocator, ((*yyvaluep).module)); wasm_free(parser->allocator, ((*yyvaluep).module)); }
+ { wabt_destroy_module(parser->allocator, ((*yyvaluep).module)); wabt_free(parser->allocator, ((*yyvaluep).module)); }
#line 1932 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 126: /* raw_module */
#line 278 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_raw_module(parser->allocator, &((*yyvaluep).raw_module)); }
+ { wabt_destroy_raw_module(parser->allocator, &((*yyvaluep).raw_module)); }
#line 1938 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 127: /* module */
#line 277 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_module(parser->allocator, ((*yyvaluep).module)); wasm_free(parser->allocator, ((*yyvaluep).module)); }
+ { wabt_destroy_module(parser->allocator, ((*yyvaluep).module)); wabt_free(parser->allocator, ((*yyvaluep).module)); }
#line 1944 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 128: /* script_var_opt */
#line 285 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_var(parser->allocator, &((*yyvaluep).var)); }
+ { wabt_destroy_var(parser->allocator, &((*yyvaluep).var)); }
#line 1950 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 130: /* assertion */
#line 261 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_command(parser->allocator, ((*yyvaluep).command)); wasm_free(parser->allocator, ((*yyvaluep).command)); }
+ { wabt_destroy_command(parser->allocator, ((*yyvaluep).command)); wabt_free(parser->allocator, ((*yyvaluep).command)); }
#line 1956 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 131: /* cmd */
#line 261 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_command(parser->allocator, ((*yyvaluep).command)); wasm_free(parser->allocator, ((*yyvaluep).command)); }
+ { wabt_destroy_command(parser->allocator, ((*yyvaluep).command)); wabt_free(parser->allocator, ((*yyvaluep).command)); }
#line 1962 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 132: /* cmd_list */
#line 262 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_command_vector_and_elements(parser->allocator, &((*yyvaluep).commands)); }
+ { wabt_destroy_command_vector_and_elements(parser->allocator, &((*yyvaluep).commands)); }
#line 1968 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 134: /* const_list */
#line 263 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_const_vector(parser->allocator, &((*yyvaluep).consts)); }
+ { wabt_destroy_const_vector(parser->allocator, &((*yyvaluep).consts)); }
#line 1974 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
case 135: /* script */
#line 280 "src/ast-parser.y" /* yacc.c:1257 */
- { wasm_destroy_script(&((*yyvaluep).script)); }
+ { wabt_destroy_script(&((*yyvaluep).script)); }
#line 1980 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
break;
@@ -1994,7 +1994,7 @@ yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocatio
`----------*/
int
-yyparse (WasmAstLexer* lexer, WasmAstParser* parser)
+yyparse (WabtAstLexer* lexer, WabtAstParser* parser)
{
/* The lookahead symbol. */
int yychar;
@@ -2008,7 +2008,7 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
/* Location data for the lookahead symbol. */
static YYLTYPE yyloc_default
-# if defined WASM_AST_PARSER_LTYPE_IS_TRIVIAL && WASM_AST_PARSER_LTYPE_IS_TRIVIAL
+# if defined WABT_AST_PARSER_LTYPE_IS_TRIVIAL && WABT_AST_PARSER_LTYPE_IS_TRIVIAL
= { 1, 1, 1, 1 }
# endif
;
@@ -2270,7 +2270,7 @@ yyreduce:
case 2:
#line 298 "src/ast-parser.y" /* yacc.c:1646 */
{
- WasmTextListNode* node = new_text_list_node(parser->allocator);
+ WabtTextListNode* node = new_text_list_node(parser->allocator);
DUPTEXT(node->text, (yyvsp[0].text));
node->next = NULL;
(yyval.text_list).first = (yyval.text_list).last = node;
@@ -2282,7 +2282,7 @@ yyreduce:
#line 304 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.text_list) = (yyvsp[-1].text_list);
- WasmTextListNode* node = new_text_list_node(parser->allocator);
+ WabtTextListNode* node = new_text_list_node(parser->allocator);
DUPTEXT(node->text, (yyvsp[0].text));
node->next = NULL;
(yyval.text_list).last->next = node;
@@ -2300,10 +2300,10 @@ yyreduce:
case 6:
#line 319 "src/ast-parser.y" /* yacc.c:1646 */
{
- WasmTextListNode node;
+ WabtTextListNode node;
node.text = (yyvsp[0].text);
node.next = NULL;
- WasmTextList text_list;
+ WabtTextList text_list;
text_list.first = &node;
text_list.last = &node;
void* data;
@@ -2317,7 +2317,7 @@ yyreduce:
case 7:
#line 337 "src/ast-parser.y" /* yacc.c:1646 */
- { WASM_ZERO_MEMORY((yyval.types)); }
+ { WABT_ZERO_MEMORY((yyval.types)); }
#line 2322 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
break;
@@ -2325,7 +2325,7 @@ yyreduce:
#line 338 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.types) = (yyvsp[-1].types);
- wasm_append_type_value(parser->allocator, &(yyval.types), &(yyvsp[0].type));
+ wabt_append_type_value(parser->allocator, &(yyval.types), &(yyvsp[0].type));
}
#line 2331 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
break;
@@ -2339,9 +2339,9 @@ yyreduce:
case 10:
#line 347 "src/ast-parser.y" /* yacc.c:1646 */
{
- WASM_ZERO_MEMORY((yyval.global));
+ WABT_ZERO_MEMORY((yyval.global));
(yyval.global).type = (yyvsp[0].type);
- (yyval.global).mutable_ = WASM_FALSE;
+ (yyval.global).mutable_ = WABT_FALSE;
}
#line 2347 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
break;
@@ -2349,9 +2349,9 @@ yyreduce:
case 11:
#line 352 "src/ast-parser.y" /* yacc.c:1646 */
{
- WASM_ZERO_MEMORY((yyval.global));
+ WABT_ZERO_MEMORY((yyval.global));
(yyval.global).type = (yyvsp[-1].type);
- (yyval.global).mutable_ = WASM_TRUE;
+ (yyval.global).mutable_ = WABT_TRUE;
}
#line 2357 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
break;
@@ -2364,14 +2364,14 @@ yyreduce:
case 13:
#line 362 "src/ast-parser.y" /* yacc.c:1646 */
- { WASM_ZERO_MEMORY((yyval.func_sig)); }
+ { WABT_ZERO_MEMORY((yyval.func_sig)); }
#line 2369 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
break;
case 14:
#line 363 "src/ast-parser.y" /* yacc.c:1646 */
{
- WASM_ZERO_MEMORY((yyval.func_sig));
+ WABT_ZERO_MEMORY((yyval.func_sig));
(yyval.func_sig).param_types = (yyvsp[-1].types);
}
#line 2378 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
@@ -2380,7 +2380,7 @@ yyreduce:
case 15:
#line 367 "src/ast-parser.y" /* yacc.c:1646 */
{
- WASM_ZERO_MEMORY((yyval.func_sig));
+ WABT_ZERO_MEMORY((yyval.func_sig));
(yyval.func_sig).param_types = (yyvsp[-5].types);
(yyval.func_sig).result_types = (yyvsp[-1].types);
}
@@ -2390,7 +2390,7 @@ yyreduce:
case 16:
#line 372 "src/ast-parser.y" /* yacc.c:1646 */
{
- WASM_ZERO_MEMORY((yyval.func_sig));
+ WABT_ZERO_MEMORY((yyval.func_sig));
(yyval.func_sig).result_types = (yyvsp[-1].types);
}
#line 2397 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
@@ -2411,7 +2411,7 @@ yyreduce:
case 19:
#line 385 "src/ast-parser.y" /* yacc.c:1646 */
{
- (yyval.limits).has_max = WASM_FALSE;
+ (yyval.limits).has_max = WABT_FALSE;
(yyval.limits).initial = (yyvsp[0].u64);
(yyval.limits).max = 0;
}
@@ -2421,7 +2421,7 @@ yyreduce:
case 20:
#line 390 "src/ast-parser.y" /* yacc.c:1646 */
{
- (yyval.limits).has_max = WASM_TRUE;
+ (yyval.limits).has_max = WABT_TRUE;
(yyval.limits).initial = (yyvsp[-1].u64);
(yyval.limits).max = (yyvsp[0].u64);
}
@@ -2437,11 +2437,11 @@ yyreduce:
case 22:
#line 403 "src/ast-parser.y" /* yacc.c:1646 */
{
- if (WASM_FAILED(wasm_parse_uint64((yyvsp[0].literal).text.start,
+ if (WABT_FAILED(wabt_parse_uint64((yyvsp[0].literal).text.start,
(yyvsp[0].literal).text.start + (yyvsp[0].literal).text.length, &(yyval.u64)))) {
- wasm_ast_parser_error(&(yylsp[0]), lexer, parser,
+ wabt_ast_parser_error(&(yylsp[0]), lexer, parser,
"invalid int " PRIstringslice "\"",
- WASM_PRINTF_STRING_SLICE_ARG((yyvsp[0].literal).text));
+ WABT_PRINTF_STRING_SLICE_ARG((yyvsp[0].literal).text));
}
}
#line 2448 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
@@ -2478,7 +2478,7 @@ yyreduce:
#line 429 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.var).loc = (yylsp[0]);
- (yyval.var).type = WASM_VAR_TYPE_INDEX;
+ (yyval.var).type = WABT_VAR_TYPE_INDEX;
(yyval.var).index = (yyvsp[0].u64);
}
#line 2485 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
@@ -2488,7 +2488,7 @@ yyreduce:
#line 434 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.var).loc = (yylsp[0]);
- (yyval.var).type = WASM_VAR_TYPE_NAME;
+ (yyval.var).type = WABT_VAR_TYPE_NAME;
DUPTEXT((yyval.var).name, (yyvsp[0].text));
}
#line 2495 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
@@ -2496,7 +2496,7 @@ yyreduce:
case 28:
#line 441 "src/ast-parser.y" /* yacc.c:1646 */
- { WASM_ZERO_MEMORY((yyval.vars)); }
+ { WABT_ZERO_MEMORY((yyval.vars)); }
#line 2501 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
break;
@@ -2504,14 +2504,14 @@ yyreduce:
#line 442 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.vars) = (yyvsp[-1].vars);
- wasm_append_var_value(parser->allocator, &(yyval.vars), &(yyvsp[0].var));
+ wabt_append_var_value(parser->allocator, &(yyval.vars), &(yyvsp[0].var));
}
#line 2510 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
break;
case 30:
#line 448 "src/ast-parser.y" /* yacc.c:1646 */
- { WASM_ZERO_MEMORY((yyval.text)); }
+ { WABT_ZERO_MEMORY((yyval.text)); }
#line 2516 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
break;
@@ -2523,7 +2523,7 @@ yyreduce:
case 33:
#line 456 "src/ast-parser.y" /* yacc.c:1646 */
- { WASM_ZERO_MEMORY((yyval.text)); }
+ { WABT_ZERO_MEMORY((yyval.text)); }
#line 2528 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
break;
@@ -2536,11 +2536,11 @@ yyreduce:
case 36:
#line 462 "src/ast-parser.y" /* yacc.c:1646 */
{
- if (WASM_FAILED(wasm_parse_int64((yyvsp[0].text).start, (yyvsp[0].text).start + (yyvsp[0].text).length, &(yyval.u64),
- WASM_PARSE_SIGNED_AND_UNSIGNED))) {
- wasm_ast_parser_error(&(yylsp[0]), lexer, parser,
+ if (WABT_FAILED(wabt_parse_int64((yyvsp[0].text).start, (yyvsp[0].text).start + (yyvsp[0].text).length, &(yyval.u64),
+ WABT_PARSE_SIGNED_AND_UNSIGNED))) {
+ wabt_ast_parser_error(&(yylsp[0]), lexer, parser,
"invalid offset \"" PRIstringslice "\"",
- WASM_PRINTF_STRING_SLICE_ARG((yyvsp[0].text)));
+ WABT_PRINTF_STRING_SLICE_ARG((yyvsp[0].text)));
}
}
#line 2547 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
@@ -2555,11 +2555,11 @@ yyreduce:
case 38:
#line 473 "src/ast-parser.y" /* yacc.c:1646 */
{
- if (WASM_FAILED(wasm_parse_int32((yyvsp[0].text).start, (yyvsp[0].text).start + (yyvsp[0].text).length, &(yyval.u32),
- WASM_PARSE_UNSIGNED_ONLY))) {
- wasm_ast_parser_error(&(yylsp[0]), lexer, parser,
+ if (WABT_FAILED(wabt_parse_int32((yyvsp[0].text).start, (yyvsp[0].text).start + (yyvsp[0].text).length, &(yyval.u32),
+ WABT_PARSE_UNSIGNED_ONLY))) {
+ wabt_ast_parser_error(&(yylsp[0]), lexer, parser,
"invalid alignment \"" PRIstringslice "\"",
- WASM_PRINTF_STRING_SLICE_ARG((yyvsp[0].text)));
+ WABT_PRINTF_STRING_SLICE_ARG((yyvsp[0].text)));
}
}
#line 2566 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
@@ -2586,7 +2586,7 @@ yyreduce:
case 42:
#line 489 "src/ast-parser.y" /* yacc.c:1646 */
{
- (yyval.expr) = wasm_new_unreachable_expr(parser->allocator);
+ (yyval.expr) = wabt_new_unreachable_expr(parser->allocator);
}
#line 2592 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
break;
@@ -2594,7 +2594,7 @@ yyreduce:
case 43:
#line 492 "src/ast-parser.y" /* yacc.c:1646 */
{
- (yyval.expr) = wasm_new_nop_expr(parser->allocator);
+ (yyval.expr) = wabt_new_nop_expr(parser->allocator);
}
#line 2600 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
break;
@@ -2602,7 +2602,7 @@ yyreduce:
case 44:
#line 495 "src/ast-parser.y" /* yacc.c:1646 */
{
- (yyval.expr) = wasm_new_drop_expr(parser->allocator);
+ (yyval.expr) = wabt_new_drop_expr(parser->allocator);
}
#line 2608 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
break;
@@ -2610,7 +2610,7 @@ yyreduce:
case 45:
#line 498 "src/ast-parser.y" /* yacc.c:1646 */
{
- (yyval.expr) = wasm_new_select_expr(parser->allocator);
+ (yyval.expr) = wabt_new_select_expr(parser->allocator);
}
#line 2616 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
break;
@@ -2618,7 +2618,7 @@ yyreduce:
case 46:
#line 501 "src/ast-parser.y" /* yacc.c:1646 */
{
- (yyval.expr) = wasm_new_br_expr(parser->allocator);
+ (yyval.expr) = wabt_new_br_expr(parser->allocator);
(yyval.expr)->br.var = (yyvsp[0].var);
}
#line 2625 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
@@ -2627,7 +2627,7 @@ yyreduce:
case 47:
#line 505 "src/ast-parser.y" /* yacc.c:1646 */
{
- (yyval.expr) = wasm_new_br_if_expr(parser->allocator);
+ (yyval.expr) = wabt_new_br_if_expr(parser->allocator);
(yyval.expr)->br_if.var = (yyvsp[0].var);
}
#line 2634 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
@@ -2636,7 +2636,7 @@ yyreduce:
case 48:
#line 509 "src/ast-parser.y" /* yacc.c:1646 */
{
- (yyval.expr) = wasm_new_br_table_expr(parser->allocator);
+ (yyval.expr) = wabt_new_br_table_expr(parser->allocator);
(yyval.expr)->br_table.targets = (yyvsp[-1].vars);
(yyval.expr)->br_table.default_target = (yyvsp[0].var);
}
@@ -2646,7 +2646,7 @@ yyreduce:
case 49:
#line 514 "src/ast-parser.y" /* yacc.c:1646 */
{
- (yyval.expr) = wasm_new_return_expr(parser->allocator);
+ (yyval.expr) = wabt_new_return_expr(parser->allocator);
}
#line 2652 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
break;
@@ -2654,7 +2654,7 @@ yyreduce:
case 50:
#line 517 "src/ast-parser.y" /* yacc.c:1646 */
{
- (yyval.expr) = wasm_new_call_expr(parser->allocator);
+ (yyval.expr) = wabt_new_call_expr(parser->allocator);
(yyval.expr)->call.var = (yyvsp[0].var);
}
#line 2661 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
@@ -2663,7 +2663,7 @@ yyreduce:
case 51:
#line 521 "src/ast-parser.y" /* yacc.c:1646 */
{
- (yyval.expr) = wasm_new_call_indirect_expr(parser->allocator);
+ (yyval.expr) = wabt_new_call_indirect_expr(parser->allocator);
(yyval.expr)->call_indirect.var = (yyvsp[0].var);
}
#line 2670 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
@@ -2672,7 +2672,7 @@ yyreduce:
case 52:
#line 525 "src/ast-parser.y" /* yacc.c:1646 */
{
- (yyval.expr) = wasm_new_get_local_expr(parser->allocator);
+ (yyval.expr) = wabt_new_get_local_expr(parser->allocator);
(yyval.expr)->get_local.var = (yyvsp[0].var);
}
#line 2679 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
@@ -2681,7 +2681,7 @@ yyreduce:
case 53:
#line 529 "src/ast-parser.y" /* yacc.c:1646 */
{
- (yyval.expr) = wasm_new_set_local_expr(parser->allocator);
+ (yyval.expr) = wabt_new_set_local_expr(parser->allocator);
(yyval.expr)->set_local.var = (yyvsp[0].var);
}
#line 2688 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
@@ -2690,7 +2690,7 @@ yyreduce:
case 54:
#line 533 "src/ast-parser.y" /* yacc.c:1646 */
{
- (yyval.expr) = wasm_new_tee_local_expr(parser->allocator);
+ (yyval.expr) = wabt_new_tee_local_expr(parser->allocator);
(yyval.expr)->tee_local.var = (yyvsp[0].var);
}
#line 2697 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
@@ -2699,7 +2699,7 @@ yyreduce:
case 55:
#line 537 "src/ast-parser.y" /* yacc.c:1646 */
{
- (yyval.expr) = wasm_new_get_global_expr(parser->allocator);
+ (yyval.expr) = wabt_new_get_global_expr(parser->allocator);
(yyval.expr)->get_global.var = (yyvsp[0].var);
}
#line 2706 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
@@ -2708,7 +2708,7 @@ yyreduce:
case 56:
#line 541 "src/ast-parser.y" /* yacc.c:1646 */
{
- (yyval.expr) = wasm_new_set_global_expr(parser->allocator);
+ (yyval.expr) = wabt_new_set_global_expr(parser->allocator);
(yyval.expr)->set_global.var = (yyvsp[0].var);
}
#line 2715 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
@@ -2717,7 +2717,7 @@ yyreduce:
case 57:
#line 545 "src/ast-parser.y" /* yacc.c:1646 */
{
- (yyval.expr) = wasm_new_load_expr(parser->allocator);
+ (yyval.expr) = wabt_new_load_expr(parser->allocator);
(yyval.expr)->load.opcode = (yyvsp[-2].opcode);
(yyval.expr)->load.offset = (yyvsp[-1].u64);
(yyval.expr)->load.align = (yyvsp[0].u32);
@@ -2728,7 +2728,7 @@ yyreduce:
case 58:
#line 551 "src/ast-parser.y" /* yacc.c:1646 */
{
- (yyval.expr) = wasm_new_store_expr(parser->allocator);
+ (yyval.expr) = wabt_new_store_expr(parser->allocator);
(yyval.expr)->store.opcode = (yyvsp[-2].opcode);
(yyval.expr)->store.offset = (yyvsp[-1].u64);
(yyval.expr)->store.align = (yyvsp[0].u32);
@@ -2739,16 +2739,16 @@ yyreduce:
case 59:
#line 557 "src/ast-parser.y" /* yacc.c:1646 */
{
- (yyval.expr) = wasm_new_const_expr(parser->allocator);
+ (yyval.expr) = wabt_new_const_expr(parser->allocator);
(yyval.expr)->const_.loc = (yylsp[-1]);
- if (WASM_FAILED(parse_const((yyvsp[-1].type), (yyvsp[0].literal).type, (yyvsp[0].literal).text.start,
+ if (WABT_FAILED(parse_const((yyvsp[-1].type), (yyvsp[0].literal).type, (yyvsp[0].literal).text.start,
(yyvsp[0].literal).text.start + (yyvsp[0].literal).text.length,
&(yyval.expr)->const_))) {
- wasm_ast_parser_error(&(yylsp[0]), lexer, parser,
+ wabt_ast_parser_error(&(yylsp[0]), lexer, parser,
"invalid literal \"" PRIstringslice "\"",
- WASM_PRINTF_STRING_SLICE_ARG((yyvsp[0].literal).text));
+ WABT_PRINTF_STRING_SLICE_ARG((yyvsp[0].literal).text));
}
- wasm_free(parser->allocator, (char*)(yyvsp[0].literal).text.start);
+ wabt_free(parser->allocator, (char*)(yyvsp[0].literal).text.start);
}
#line 2754 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
break;
@@ -2756,7 +2756,7 @@ yyreduce:
case 60:
#line 569 "src/ast-parser.y" /* yacc.c:1646 */
{
- (yyval.expr) = wasm_new_unary_expr(parser->allocator);
+ (yyval.expr) = wabt_new_unary_expr(parser->allocator);
(yyval.expr)->unary.opcode = (yyvsp[0].opcode);
}
#line 2763 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
@@ -2765,7 +2765,7 @@ yyreduce:
case 61:
#line 573 "src/ast-parser.y" /* yacc.c:1646 */
{
- (yyval.expr) = wasm_new_binary_expr(parser->allocator);
+ (yyval.expr) = wabt_new_binary_expr(parser->allocator);
(yyval.expr)->binary.opcode = (yyvsp[0].opcode);
}
#line 2772 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
@@ -2774,7 +2774,7 @@ yyreduce:
case 62:
#line 577 "src/ast-parser.y" /* yacc.c:1646 */
{
- (yyval.expr) = wasm_new_compare_expr(parser->allocator);
+ (yyval.expr) = wabt_new_compare_expr(parser->allocator);
(yyval.expr)->compare.opcode = (yyvsp[0].opcode);
}
#line 2781 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
@@ -2783,7 +2783,7 @@ yyreduce:
case 63:
#line 581 "src/ast-parser.y" /* yacc.c:1646 */
{
- (yyval.expr) = wasm_new_convert_expr(parser->allocator);
+ (yyval.expr) = wabt_new_convert_expr(parser->allocator);
(yyval.expr)->convert.opcode = (yyvsp[0].opcode);
}
#line 2790 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
@@ -2792,7 +2792,7 @@ yyreduce:
case 64:
#line 585 "src/ast-parser.y" /* yacc.c:1646 */
{
- (yyval.expr) = wasm_new_current_memory_expr(parser->allocator);
+ (yyval.expr) = wabt_new_current_memory_expr(parser->allocator);
}
#line 2798 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
break;
@@ -2800,7 +2800,7 @@ yyreduce:
case 65:
#line 588 "src/ast-parser.y" /* yacc.c:1646 */
{
- (yyval.expr) = wasm_new_grow_memory_expr(parser->allocator);
+ (yyval.expr) = wabt_new_grow_memory_expr(parser->allocator);
}
#line 2806 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
break;
@@ -2808,7 +2808,7 @@ yyreduce:
case 66:
#line 593 "src/ast-parser.y" /* yacc.c:1646 */
{
- (yyval.expr) = wasm_new_block_expr(parser->allocator);
+ (yyval.expr) = wabt_new_block_expr(parser->allocator);
(yyval.expr)->block = (yyvsp[-2].block);
(yyval.expr)->block.label = (yyvsp[-3].text);
CHECK_END_LABEL((yylsp[0]), (yyval.expr)->block.label, (yyvsp[0].text));
@@ -2819,7 +2819,7 @@ yyreduce:
case 67:
#line 599 "src/ast-parser.y" /* yacc.c:1646 */
{
- (yyval.expr) = wasm_new_loop_expr(parser->allocator);
+ (yyval.expr) = wabt_new_loop_expr(parser->allocator);
(yyval.expr)->loop = (yyvsp[-2].block);
(yyval.expr)->loop.label = (yyvsp[-3].text);
CHECK_END_LABEL((yylsp[0]), (yyval.expr)->block.label, (yyvsp[0].text));
@@ -2830,7 +2830,7 @@ yyreduce:
case 68:
#line 605 "src/ast-parser.y" /* yacc.c:1646 */
{
- (yyval.expr) = wasm_new_if_expr(parser->allocator);
+ (yyval.expr) = wabt_new_if_expr(parser->allocator);
(yyval.expr)->if_.true_ = (yyvsp[-2].block);
(yyval.expr)->if_.true_.label = (yyvsp[-3].text);
CHECK_END_LABEL((yylsp[0]), (yyval.expr)->block.label, (yyvsp[0].text));
@@ -2841,7 +2841,7 @@ yyreduce:
case 69:
#line 611 "src/ast-parser.y" /* yacc.c:1646 */
{
- (yyval.expr) = wasm_new_if_expr(parser->allocator);
+ (yyval.expr) = wabt_new_if_expr(parser->allocator);
(yyval.expr)->if_.true_ = (yyvsp[-5].block);
(yyval.expr)->if_.true_.label = (yyvsp[-6].text);
(yyval.expr)->if_.false_ = (yyvsp[-2].expr_list).first;
@@ -2854,7 +2854,7 @@ yyreduce:
case 70:
#line 621 "src/ast-parser.y" /* yacc.c:1646 */
{
- WASM_ZERO_MEMORY((yyval.block));
+ WABT_ZERO_MEMORY((yyval.block));
(yyval.block).sig = (yyvsp[-1].types);
(yyval.block).first = (yyvsp[0].expr_list).first;
}
@@ -2878,7 +2878,7 @@ yyreduce:
case 73:
#line 636 "src/ast-parser.y" /* yacc.c:1646 */
{
- WasmExpr* expr = wasm_new_block_expr(parser->allocator);
+ WabtExpr* expr = wabt_new_block_expr(parser->allocator);
expr->block = (yyvsp[0].block);
expr->block.label = (yyvsp[-1].text);
(yyval.expr_list) = join_exprs1(&(yylsp[-2]), expr);
@@ -2889,7 +2889,7 @@ yyreduce:
case 74:
#line 642 "src/ast-parser.y" /* yacc.c:1646 */
{
- WasmExpr* expr = wasm_new_loop_expr(parser->allocator);
+ WabtExpr* expr = wabt_new_loop_expr(parser->allocator);
expr->loop = (yyvsp[0].block);
expr->loop.label = (yyvsp[-1].text);
(yyval.expr_list) = join_exprs1(&(yylsp[-2]), expr);
@@ -2901,8 +2901,8 @@ yyreduce:
#line 648 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.expr_list) = (yyvsp[0].expr_list);
- WasmExpr* if_ = (yyvsp[0].expr_list).last;
- assert(if_->type == WASM_EXPR_TYPE_IF);
+ WabtExpr* if_ = (yyvsp[0].expr_list).last;
+ assert(if_->type == WABT_EXPR_TYPE_IF);
if_->if_.true_.label = (yyvsp[-2].text);
if_->if_.true_.sig = (yyvsp[-1].types);
}
@@ -2912,7 +2912,7 @@ yyreduce:
case 76:
#line 657 "src/ast-parser.y" /* yacc.c:1646 */
{
- WasmExpr* expr = wasm_new_if_expr(parser->allocator);
+ WabtExpr* expr = wabt_new_if_expr(parser->allocator);
expr->if_.true_.first = (yyvsp[-5].expr_list).first;
expr->if_.false_ = (yyvsp[-1].expr_list).first;
(yyval.expr_list) = join_exprs1(&(yylsp[-7]), expr);
@@ -2923,7 +2923,7 @@ yyreduce:
case 77:
#line 663 "src/ast-parser.y" /* yacc.c:1646 */
{
- WasmExpr* expr = wasm_new_if_expr(parser->allocator);
+ WabtExpr* expr = wabt_new_if_expr(parser->allocator);
expr->if_.true_.first = (yyvsp[-1].expr_list).first;
(yyval.expr_list) = join_exprs1(&(yylsp[-3]), expr);
}
@@ -2933,7 +2933,7 @@ yyreduce:
case 78:
#line 668 "src/ast-parser.y" /* yacc.c:1646 */
{
- WasmExpr* expr = wasm_new_if_expr(parser->allocator);
+ WabtExpr* expr = wabt_new_if_expr(parser->allocator);
expr->if_.true_.first = (yyvsp[-5].expr_list).first;
expr->if_.false_ = (yyvsp[-1].expr_list).first;
(yyval.expr_list) = join_exprs2(&(yylsp[-8]), &(yyvsp[-8].expr_list), expr);
@@ -2944,7 +2944,7 @@ yyreduce:
case 79:
#line 674 "src/ast-parser.y" /* yacc.c:1646 */
{
- WasmExpr* expr = wasm_new_if_expr(parser->allocator);
+ WabtExpr* expr = wabt_new_if_expr(parser->allocator);
expr->if_.true_.first = (yyvsp[-1].expr_list).first;
(yyval.expr_list) = join_exprs2(&(yylsp[-4]), &(yyvsp[-4].expr_list), expr);
}
@@ -2954,7 +2954,7 @@ yyreduce:
case 80:
#line 679 "src/ast-parser.y" /* yacc.c:1646 */
{
- WasmExpr* expr = wasm_new_if_expr(parser->allocator);
+ WabtExpr* expr = wabt_new_if_expr(parser->allocator);
expr->if_.true_.first = (yyvsp[-1].expr_list).first;
expr->if_.false_ = (yyvsp[0].expr_list).first;
(yyval.expr_list) = join_exprs2(&(yylsp[-2]), &(yyvsp[-2].expr_list), expr);
@@ -2965,7 +2965,7 @@ yyreduce:
case 81:
#line 685 "src/ast-parser.y" /* yacc.c:1646 */
{
- WasmExpr* expr = wasm_new_if_expr(parser->allocator);
+ WabtExpr* expr = wabt_new_if_expr(parser->allocator);
expr->if_.true_.first = (yyvsp[0].expr_list).first;
(yyval.expr_list) = join_exprs2(&(yylsp[-1]), &(yyvsp[-1].expr_list), expr);
}
@@ -2974,7 +2974,7 @@ yyreduce:
case 82:
#line 693 "src/ast-parser.y" /* yacc.c:1646 */
- { WASM_ZERO_MEMORY((yyval.expr_list)); }
+ { WABT_ZERO_MEMORY((yyval.expr_list)); }
#line 2979 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
break;
@@ -2991,7 +2991,7 @@ yyreduce:
case 84:
#line 702 "src/ast-parser.y" /* yacc.c:1646 */
- { WASM_ZERO_MEMORY((yyval.expr_list)); }
+ { WABT_ZERO_MEMORY((yyval.expr_list)); }
#line 2996 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
break;
@@ -3010,7 +3010,7 @@ yyreduce:
#line 717 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.func_fields) = new_func_field(parser->allocator);
- (yyval.func_fields)->type = WASM_FUNC_FIELD_TYPE_RESULT_TYPES;
+ (yyval.func_fields)->type = WABT_FUNC_FIELD_TYPE_RESULT_TYPES;
(yyval.func_fields)->types = (yyvsp[-2].types);
(yyval.func_fields)->next = (yyvsp[0].func_fields);
}
@@ -3021,7 +3021,7 @@ yyreduce:
#line 723 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.func_fields) = new_func_field(parser->allocator);
- (yyval.func_fields)->type = WASM_FUNC_FIELD_TYPE_PARAM_TYPES;
+ (yyval.func_fields)->type = WABT_FUNC_FIELD_TYPE_PARAM_TYPES;
(yyval.func_fields)->types = (yyvsp[-2].types);
(yyval.func_fields)->next = (yyvsp[0].func_fields);
}
@@ -3032,7 +3032,7 @@ yyreduce:
#line 729 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.func_fields) = new_func_field(parser->allocator);
- (yyval.func_fields)->type = WASM_FUNC_FIELD_TYPE_BOUND_PARAM;
+ (yyval.func_fields)->type = WABT_FUNC_FIELD_TYPE_BOUND_PARAM;
(yyval.func_fields)->bound_type.loc = (yylsp[-4]);
(yyval.func_fields)->bound_type.name = (yyvsp[-3].text);
(yyval.func_fields)->bound_type.type = (yyvsp[-2].type);
@@ -3045,7 +3045,7 @@ yyreduce:
#line 739 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.func_fields) = new_func_field(parser->allocator);
- (yyval.func_fields)->type = WASM_FUNC_FIELD_TYPE_EXPRS;
+ (yyval.func_fields)->type = WABT_FUNC_FIELD_TYPE_EXPRS;
(yyval.func_fields)->first_expr = (yyvsp[0].expr_list).first;
(yyval.func_fields)->next = NULL;
}
@@ -3056,7 +3056,7 @@ yyreduce:
#line 745 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.func_fields) = new_func_field(parser->allocator);
- (yyval.func_fields)->type = WASM_FUNC_FIELD_TYPE_LOCAL_TYPES;
+ (yyval.func_fields)->type = WABT_FUNC_FIELD_TYPE_LOCAL_TYPES;
(yyval.func_fields)->types = (yyvsp[-2].types);
(yyval.func_fields)->next = (yyvsp[0].func_fields);
}
@@ -3067,7 +3067,7 @@ yyreduce:
#line 751 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.func_fields) = new_func_field(parser->allocator);
- (yyval.func_fields)->type = WASM_FUNC_FIELD_TYPE_BOUND_LOCAL;
+ (yyval.func_fields)->type = WABT_FUNC_FIELD_TYPE_BOUND_LOCAL;
(yyval.func_fields)->bound_type.loc = (yylsp[-4]);
(yyval.func_fields)->bound_type.name = (yyvsp[-3].text);
(yyval.func_fields)->bound_type.type = (yyvsp[-2].type);
@@ -3080,31 +3080,31 @@ yyreduce:
#line 761 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.func) = new_func(parser->allocator);
- WasmFuncField* field = (yyvsp[0].func_fields);
+ WabtFuncField* field = (yyvsp[0].func_fields);
while (field) {
- WasmFuncField* next = field->next;
+ WabtFuncField* next = field->next;
switch (field->type) {
- case WASM_FUNC_FIELD_TYPE_EXPRS:
+ case WABT_FUNC_FIELD_TYPE_EXPRS:
(yyval.func)->first_expr = field->first_expr;
break;
- case WASM_FUNC_FIELD_TYPE_PARAM_TYPES:
- case WASM_FUNC_FIELD_TYPE_LOCAL_TYPES: {
- WasmTypeVector* types =
- field->type == WASM_FUNC_FIELD_TYPE_PARAM_TYPES
+ case WABT_FUNC_FIELD_TYPE_PARAM_TYPES:
+ case WABT_FUNC_FIELD_TYPE_LOCAL_TYPES: {
+ WabtTypeVector* types =
+ field->type == WABT_FUNC_FIELD_TYPE_PARAM_TYPES
? &(yyval.func)->decl.sig.param_types
: &(yyval.func)->local_types;
- wasm_extend_types(parser->allocator, types, &field->types);
- wasm_destroy_type_vector(parser->allocator, &field->types);
+ wabt_extend_types(parser->allocator, types, &field->types);
+ wabt_destroy_type_vector(parser->allocator, &field->types);
break;
}
- case WASM_FUNC_FIELD_TYPE_BOUND_PARAM:
- case WASM_FUNC_FIELD_TYPE_BOUND_LOCAL: {
- WasmTypeVector* types;
- WasmBindingHash* bindings;
- if (field->type == WASM_FUNC_FIELD_TYPE_BOUND_PARAM) {
+ case WABT_FUNC_FIELD_TYPE_BOUND_PARAM:
+ case WABT_FUNC_FIELD_TYPE_BOUND_LOCAL: {
+ WabtTypeVector* types;
+ WabtBindingHash* bindings;
+ if (field->type == WABT_FUNC_FIELD_TYPE_BOUND_PARAM) {
types = &(yyval.func)->decl.sig.param_types;
bindings = &(yyval.func)->param_bindings;
} else {
@@ -3112,22 +3112,22 @@ yyreduce:
bindings = &(yyval.func)->local_bindings;
}
- wasm_append_type_value(parser->allocator, types,
+ wabt_append_type_value(parser->allocator, types,
&field->bound_type.type);
- WasmBinding* binding = wasm_insert_binding(
+ WabtBinding* binding = wabt_insert_binding(
parser->allocator, bindings, &field->bound_type.name);
binding->loc = field->bound_type.loc;
binding->index = types->size - 1;
break;
}
- case WASM_FUNC_FIELD_TYPE_RESULT_TYPES:
+ case WABT_FUNC_FIELD_TYPE_RESULT_TYPES:
(yyval.func)->decl.sig.result_types = field->types;
break;
}
/* we steal memory from the func field, but not the linked list nodes */
- wasm_free(parser->allocator, field);
+ wabt_free(parser->allocator, field);
field = next;
}
}
@@ -3137,9 +3137,9 @@ yyreduce:
case 95:
#line 816 "src/ast-parser.y" /* yacc.c:1646 */
{
- WASM_ZERO_MEMORY((yyval.exported_func));
+ WABT_ZERO_MEMORY((yyval.exported_func));
(yyval.exported_func).func = (yyvsp[-1].func);
- (yyval.exported_func).func->decl.flags |= WASM_FUNC_DECLARATION_FLAG_HAS_FUNC_TYPE;
+ (yyval.exported_func).func->decl.flags |= WABT_FUNC_DECLARATION_FLAG_HAS_FUNC_TYPE;
(yyval.exported_func).func->decl.type_var = (yyvsp[-2].var);
(yyval.exported_func).func->name = (yyvsp[-4].text);
(yyval.exported_func).export_ = (yyvsp[-3].optional_export);
@@ -3150,9 +3150,9 @@ yyreduce:
case 96:
#line 825 "src/ast-parser.y" /* yacc.c:1646 */
{
- WASM_ZERO_MEMORY((yyval.exported_func));
+ WABT_ZERO_MEMORY((yyval.exported_func));
(yyval.exported_func).func = (yyvsp[-1].func);
- (yyval.exported_func).func->decl.flags |= WASM_FUNC_DECLARATION_FLAG_HAS_FUNC_TYPE;
+ (yyval.exported_func).func->decl.flags |= WABT_FUNC_DECLARATION_FLAG_HAS_FUNC_TYPE;
(yyval.exported_func).func->decl.type_var = (yyvsp[-2].var);
(yyval.exported_func).func->name = (yyvsp[-3].text);
}
@@ -3162,7 +3162,7 @@ yyreduce:
case 97:
#line 832 "src/ast-parser.y" /* yacc.c:1646 */
{
- WASM_ZERO_MEMORY((yyval.exported_func));
+ WABT_ZERO_MEMORY((yyval.exported_func));
(yyval.exported_func).func = (yyvsp[-1].func);
(yyval.exported_func).func->name = (yyvsp[-3].text);
(yyval.exported_func).export_ = (yyvsp[-2].optional_export);
@@ -3173,7 +3173,7 @@ yyreduce:
case 98:
#line 839 "src/ast-parser.y" /* yacc.c:1646 */
{
- WASM_ZERO_MEMORY((yyval.exported_func));
+ WABT_ZERO_MEMORY((yyval.exported_func));
(yyval.exported_func).func = (yyvsp[-1].func);
(yyval.exported_func).func->name = (yyvsp[-2].text);
}
@@ -3191,7 +3191,7 @@ yyreduce:
case 101:
#line 856 "src/ast-parser.y" /* yacc.c:1646 */
{
- WASM_ZERO_MEMORY((yyval.elem_segment));
+ WABT_ZERO_MEMORY((yyval.elem_segment));
(yyval.elem_segment).table_var = (yyvsp[-3].var);
(yyval.elem_segment).offset = (yyvsp[-2].expr_list).first;
(yyval.elem_segment).vars = (yyvsp[-1].vars);
@@ -3202,9 +3202,9 @@ yyreduce:
case 102:
#line 862 "src/ast-parser.y" /* yacc.c:1646 */
{
- WASM_ZERO_MEMORY((yyval.elem_segment));
+ WABT_ZERO_MEMORY((yyval.elem_segment));
(yyval.elem_segment).table_var.loc = (yylsp[-3]);
- (yyval.elem_segment).table_var.type = WASM_VAR_TYPE_INDEX;
+ (yyval.elem_segment).table_var.type = WABT_VAR_TYPE_INDEX;
(yyval.elem_segment).table_var.index = 0;
(yyval.elem_segment).offset = (yyvsp[-2].expr_list).first;
(yyval.elem_segment).vars = (yyvsp[-1].vars);
@@ -3217,7 +3217,7 @@ yyreduce:
{
(yyval.exported_table).table = (yyvsp[-1].table);
(yyval.exported_table).table.name = (yyvsp[-3].text);
- (yyval.exported_table).has_elem_segment = WASM_FALSE;
+ (yyval.exported_table).has_elem_segment = WABT_FALSE;
(yyval.exported_table).export_ = (yyvsp[-2].optional_export);
}
#line 3224 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
@@ -3226,17 +3226,17 @@ yyreduce:
case 104:
#line 880 "src/ast-parser.y" /* yacc.c:1646 */
{
- WasmExpr* expr = wasm_new_const_expr(parser->allocator);
+ WabtExpr* expr = wabt_new_const_expr(parser->allocator);
expr->loc = (yylsp[-8]);
- expr->const_.type = WASM_TYPE_I32;
+ expr->const_.type = WABT_TYPE_I32;
expr->const_.u32 = 0;
- WASM_ZERO_MEMORY((yyval.exported_table));
+ WABT_ZERO_MEMORY((yyval.exported_table));
(yyval.exported_table).table.name = (yyvsp[-7].text);
(yyval.exported_table).table.elem_limits.initial = (yyvsp[-2].vars).size;
(yyval.exported_table).table.elem_limits.max = (yyvsp[-2].vars).size;
- (yyval.exported_table).table.elem_limits.has_max = WASM_TRUE;
- (yyval.exported_table).has_elem_segment = WASM_TRUE;
+ (yyval.exported_table).table.elem_limits.has_max = WABT_TRUE;
+ (yyval.exported_table).has_elem_segment = WABT_TRUE;
(yyval.exported_table).elem_segment.offset = expr;
(yyval.exported_table).elem_segment.vars = (yyvsp[-2].vars);
(yyval.exported_table).export_ = (yyvsp[-6].optional_export);
@@ -3247,11 +3247,11 @@ yyreduce:
case 105:
#line 899 "src/ast-parser.y" /* yacc.c:1646 */
{
- WASM_ZERO_MEMORY((yyval.data_segment));
+ WABT_ZERO_MEMORY((yyval.data_segment));
(yyval.data_segment).memory_var = (yyvsp[-3].var);
(yyval.data_segment).offset = (yyvsp[-2].expr_list).first;
dup_text_list(parser->allocator, &(yyvsp[-1].text_list), &(yyval.data_segment).data, &(yyval.data_segment).size);
- wasm_destroy_text_list(parser->allocator, &(yyvsp[-1].text_list));
+ wabt_destroy_text_list(parser->allocator, &(yyvsp[-1].text_list));
}
#line 3257 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
break;
@@ -3259,13 +3259,13 @@ yyreduce:
case 106:
#line 906 "src/ast-parser.y" /* yacc.c:1646 */
{
- WASM_ZERO_MEMORY((yyval.data_segment));
+ WABT_ZERO_MEMORY((yyval.data_segment));
(yyval.data_segment).memory_var.loc = (yylsp[-3]);
- (yyval.data_segment).memory_var.type = WASM_VAR_TYPE_INDEX;
+ (yyval.data_segment).memory_var.type = WABT_VAR_TYPE_INDEX;
(yyval.data_segment).memory_var.index = 0;
(yyval.data_segment).offset = (yyvsp[-2].expr_list).first;
dup_text_list(parser->allocator, &(yyvsp[-1].text_list), &(yyval.data_segment).data, &(yyval.data_segment).size);
- wasm_destroy_text_list(parser->allocator, &(yyvsp[-1].text_list));
+ wabt_destroy_text_list(parser->allocator, &(yyvsp[-1].text_list));
}
#line 3271 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
break;
@@ -3273,10 +3273,10 @@ yyreduce:
case 107:
#line 918 "src/ast-parser.y" /* yacc.c:1646 */
{
- WASM_ZERO_MEMORY((yyval.exported_memory));
+ WABT_ZERO_MEMORY((yyval.exported_memory));
(yyval.exported_memory).memory = (yyvsp[-1].memory);
(yyval.exported_memory).memory.name = (yyvsp[-3].text);
- (yyval.exported_memory).has_data_segment = WASM_FALSE;
+ (yyval.exported_memory).has_data_segment = WABT_FALSE;
(yyval.exported_memory).export_ = (yyvsp[-2].optional_export);
}
#line 3283 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
@@ -3285,23 +3285,23 @@ yyreduce:
case 108:
#line 925 "src/ast-parser.y" /* yacc.c:1646 */
{
- WasmExpr* expr = wasm_new_const_expr(parser->allocator);
+ WabtExpr* expr = wabt_new_const_expr(parser->allocator);
expr->loc = (yylsp[-7]);
- expr->const_.type = WASM_TYPE_I32;
+ expr->const_.type = WABT_TYPE_I32;
expr->const_.u32 = 0;
- WASM_ZERO_MEMORY((yyval.exported_memory));
- (yyval.exported_memory).has_data_segment = WASM_TRUE;
+ WABT_ZERO_MEMORY((yyval.exported_memory));
+ (yyval.exported_memory).has_data_segment = WABT_TRUE;
(yyval.exported_memory).data_segment.offset = expr;
dup_text_list(parser->allocator, &(yyvsp[-2].text_list), &(yyval.exported_memory).data_segment.data,
&(yyval.exported_memory).data_segment.size);
- wasm_destroy_text_list(parser->allocator, &(yyvsp[-2].text_list));
- uint32_t byte_size = WASM_ALIGN_UP_TO_PAGE((yyval.exported_memory).data_segment.size);
- uint32_t page_size = WASM_BYTES_TO_PAGES(byte_size);
+ wabt_destroy_text_list(parser->allocator, &(yyvsp[-2].text_list));
+ uint32_t byte_size = WABT_ALIGN_UP_TO_PAGE((yyval.exported_memory).data_segment.size);
+ uint32_t page_size = WABT_BYTES_TO_PAGES(byte_size);
(yyval.exported_memory).memory.name = (yyvsp[-6].text);
(yyval.exported_memory).memory.page_limits.initial = page_size;
(yyval.exported_memory).memory.page_limits.max = page_size;
- (yyval.exported_memory).memory.page_limits.has_max = WASM_TRUE;
+ (yyval.exported_memory).memory.page_limits.has_max = WABT_TRUE;
(yyval.exported_memory).export_ = (yyvsp[-5].optional_export);
}
#line 3308 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
@@ -3310,24 +3310,24 @@ yyreduce:
case 109:
#line 946 "src/ast-parser.y" /* yacc.c:1646 */
{
- WasmExpr* expr = wasm_new_const_expr(parser->allocator);
+ WabtExpr* expr = wabt_new_const_expr(parser->allocator);
expr->loc = (yylsp[-6]);
- expr->const_.type = WASM_TYPE_I32;
+ expr->const_.type = WABT_TYPE_I32;
expr->const_.u32 = 0;
- WASM_ZERO_MEMORY((yyval.exported_memory));
- (yyval.exported_memory).has_data_segment = WASM_TRUE;
+ WABT_ZERO_MEMORY((yyval.exported_memory));
+ (yyval.exported_memory).has_data_segment = WABT_TRUE;
(yyval.exported_memory).data_segment.offset = expr;
dup_text_list(parser->allocator, &(yyvsp[-2].text_list), &(yyval.exported_memory).data_segment.data,
&(yyval.exported_memory).data_segment.size);
- wasm_destroy_text_list(parser->allocator, &(yyvsp[-2].text_list));
- uint32_t byte_size = WASM_ALIGN_UP_TO_PAGE((yyval.exported_memory).data_segment.size);
- uint32_t page_size = WASM_BYTES_TO_PAGES(byte_size);
+ wabt_destroy_text_list(parser->allocator, &(yyvsp[-2].text_list));
+ uint32_t byte_size = WABT_ALIGN_UP_TO_PAGE((yyval.exported_memory).data_segment.size);
+ uint32_t page_size = WABT_BYTES_TO_PAGES(byte_size);
(yyval.exported_memory).memory.name = (yyvsp[-5].text);
(yyval.exported_memory).memory.page_limits.initial = page_size;
(yyval.exported_memory).memory.page_limits.max = page_size;
- (yyval.exported_memory).memory.page_limits.has_max = WASM_TRUE;
- (yyval.exported_memory).export_.has_export = WASM_FALSE;
+ (yyval.exported_memory).memory.page_limits.has_max = WABT_TRUE;
+ (yyval.exported_memory).export_.has_export = WABT_FALSE;
}
#line 3333 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
break;
@@ -3335,7 +3335,7 @@ yyreduce:
case 110:
#line 969 "src/ast-parser.y" /* yacc.c:1646 */
{
- WASM_ZERO_MEMORY((yyval.exported_global));
+ WABT_ZERO_MEMORY((yyval.exported_global));
(yyval.exported_global).global = (yyvsp[-2].global);
(yyval.exported_global).global.name = (yyvsp[-4].text);
(yyval.exported_global).global.init_expr = (yyvsp[-1].expr_list).first;
@@ -3347,11 +3347,11 @@ yyreduce:
case 111:
#line 976 "src/ast-parser.y" /* yacc.c:1646 */
{
- WASM_ZERO_MEMORY((yyval.exported_global));
+ WABT_ZERO_MEMORY((yyval.exported_global));
(yyval.exported_global).global = (yyvsp[-2].global);
(yyval.exported_global).global.name = (yyvsp[-3].text);
(yyval.exported_global).global.init_expr = (yyvsp[-1].expr_list).first;
- (yyval.exported_global).export_.has_export = WASM_FALSE;
+ (yyval.exported_global).export_.has_export = WABT_FALSE;
}
#line 3357 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
break;
@@ -3360,9 +3360,9 @@ yyreduce:
#line 989 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.import) = new_import(parser->allocator);
- (yyval.import)->kind = WASM_EXTERNAL_KIND_FUNC;
+ (yyval.import)->kind = WABT_EXTERNAL_KIND_FUNC;
(yyval.import)->func.name = (yyvsp[-2].text);
- (yyval.import)->func.decl.flags = WASM_FUNC_DECLARATION_FLAG_HAS_FUNC_TYPE;
+ (yyval.import)->func.decl.flags = WABT_FUNC_DECLARATION_FLAG_HAS_FUNC_TYPE;
(yyval.import)->func.decl.type_var = (yyvsp[-1].var);
}
#line 3369 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
@@ -3372,7 +3372,7 @@ yyreduce:
#line 996 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.import) = new_import(parser->allocator);
- (yyval.import)->kind = WASM_EXTERNAL_KIND_FUNC;
+ (yyval.import)->kind = WABT_EXTERNAL_KIND_FUNC;
(yyval.import)->func.name = (yyvsp[-2].text);
(yyval.import)->func.decl.sig = (yyvsp[-1].func_sig);
}
@@ -3383,7 +3383,7 @@ yyreduce:
#line 1002 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.import) = new_import(parser->allocator);
- (yyval.import)->kind = WASM_EXTERNAL_KIND_TABLE;
+ (yyval.import)->kind = WABT_EXTERNAL_KIND_TABLE;
(yyval.import)->table = (yyvsp[-1].table);
(yyval.import)->table.name = (yyvsp[-2].text);
}
@@ -3394,7 +3394,7 @@ yyreduce:
#line 1008 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.import) = new_import(parser->allocator);
- (yyval.import)->kind = WASM_EXTERNAL_KIND_MEMORY;
+ (yyval.import)->kind = WABT_EXTERNAL_KIND_MEMORY;
(yyval.import)->memory = (yyvsp[-1].memory);
(yyval.import)->memory.name = (yyvsp[-2].text);
}
@@ -3405,7 +3405,7 @@ yyreduce:
#line 1014 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.import) = new_import(parser->allocator);
- (yyval.import)->kind = WASM_EXTERNAL_KIND_GLOBAL;
+ (yyval.import)->kind = WABT_EXTERNAL_KIND_GLOBAL;
(yyval.import)->global = (yyvsp[-1].global);
(yyval.import)->global.name = (yyvsp[-2].text);
}
@@ -3426,9 +3426,9 @@ yyreduce:
#line 1027 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.import) = (yyvsp[-2].import);
- (yyval.import)->kind = WASM_EXTERNAL_KIND_FUNC;
+ (yyval.import)->kind = WABT_EXTERNAL_KIND_FUNC;
(yyval.import)->func.name = (yyvsp[-3].text);
- (yyval.import)->func.decl.flags = WASM_FUNC_DECLARATION_FLAG_HAS_FUNC_TYPE;
+ (yyval.import)->func.decl.flags = WABT_FUNC_DECLARATION_FLAG_HAS_FUNC_TYPE;
(yyval.import)->func.decl.type_var = (yyvsp[-1].var);
}
#line 3435 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
@@ -3438,7 +3438,7 @@ yyreduce:
#line 1034 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.import) = (yyvsp[-2].import);
- (yyval.import)->kind = WASM_EXTERNAL_KIND_FUNC;
+ (yyval.import)->kind = WABT_EXTERNAL_KIND_FUNC;
(yyval.import)->func.name = (yyvsp[-3].text);
(yyval.import)->func.decl.sig = (yyvsp[-1].func_sig);
}
@@ -3449,7 +3449,7 @@ yyreduce:
#line 1040 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.import) = (yyvsp[-2].import);
- (yyval.import)->kind = WASM_EXTERNAL_KIND_TABLE;
+ (yyval.import)->kind = WABT_EXTERNAL_KIND_TABLE;
(yyval.import)->table = (yyvsp[-1].table);
(yyval.import)->table.name = (yyvsp[-3].text);
}
@@ -3460,7 +3460,7 @@ yyreduce:
#line 1046 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.import) = (yyvsp[-2].import);
- (yyval.import)->kind = WASM_EXTERNAL_KIND_MEMORY;
+ (yyval.import)->kind = WABT_EXTERNAL_KIND_MEMORY;
(yyval.import)->memory = (yyvsp[-1].memory);
(yyval.import)->memory.name = (yyvsp[-3].text);
}
@@ -3471,7 +3471,7 @@ yyreduce:
#line 1052 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.import) = (yyvsp[-2].import);
- (yyval.import)->kind = WASM_EXTERNAL_KIND_GLOBAL;
+ (yyval.import)->kind = WABT_EXTERNAL_KIND_GLOBAL;
(yyval.import)->global = (yyvsp[-1].global);
(yyval.import)->global.name = (yyvsp[-3].text);
}
@@ -3491,8 +3491,8 @@ yyreduce:
case 124:
#line 1069 "src/ast-parser.y" /* yacc.c:1646 */
{
- WASM_ZERO_MEMORY((yyval.export_));
- (yyval.export_).kind = WASM_EXTERNAL_KIND_FUNC;
+ WABT_ZERO_MEMORY((yyval.export_));
+ (yyval.export_).kind = WABT_EXTERNAL_KIND_FUNC;
(yyval.export_).var = (yyvsp[-1].var);
}
#line 3499 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
@@ -3501,8 +3501,8 @@ yyreduce:
case 125:
#line 1074 "src/ast-parser.y" /* yacc.c:1646 */
{
- WASM_ZERO_MEMORY((yyval.export_));
- (yyval.export_).kind = WASM_EXTERNAL_KIND_TABLE;
+ WABT_ZERO_MEMORY((yyval.export_));
+ (yyval.export_).kind = WABT_EXTERNAL_KIND_TABLE;
(yyval.export_).var = (yyvsp[-1].var);
}
#line 3509 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
@@ -3511,8 +3511,8 @@ yyreduce:
case 126:
#line 1079 "src/ast-parser.y" /* yacc.c:1646 */
{
- WASM_ZERO_MEMORY((yyval.export_));
- (yyval.export_).kind = WASM_EXTERNAL_KIND_MEMORY;
+ WABT_ZERO_MEMORY((yyval.export_));
+ (yyval.export_).kind = WABT_EXTERNAL_KIND_MEMORY;
(yyval.export_).var = (yyvsp[-1].var);
}
#line 3519 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
@@ -3521,8 +3521,8 @@ yyreduce:
case 127:
#line 1084 "src/ast-parser.y" /* yacc.c:1646 */
{
- WASM_ZERO_MEMORY((yyval.export_));
- (yyval.export_).kind = WASM_EXTERNAL_KIND_GLOBAL;
+ WABT_ZERO_MEMORY((yyval.export_));
+ (yyval.export_).kind = WABT_EXTERNAL_KIND_GLOBAL;
(yyval.export_).var = (yyvsp[-1].var);
}
#line 3529 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
@@ -3540,8 +3540,8 @@ yyreduce:
case 129:
#line 1098 "src/ast-parser.y" /* yacc.c:1646 */
{
- WASM_ZERO_MEMORY((yyval.optional_export));
- (yyval.optional_export).has_export = WASM_FALSE;
+ WABT_ZERO_MEMORY((yyval.optional_export));
+ (yyval.optional_export).has_export = WABT_FALSE;
}
#line 3547 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
break;
@@ -3549,8 +3549,8 @@ yyreduce:
case 131:
#line 1105 "src/ast-parser.y" /* yacc.c:1646 */
{
- WASM_ZERO_MEMORY((yyval.optional_export));
- (yyval.optional_export).has_export = WASM_TRUE;
+ WABT_ZERO_MEMORY((yyval.optional_export));
+ (yyval.optional_export).has_export = WABT_TRUE;
(yyval.optional_export).export_.name = (yyvsp[-1].text);
}
#line 3557 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
@@ -3559,7 +3559,7 @@ yyreduce:
case 132:
#line 1116 "src/ast-parser.y" /* yacc.c:1646 */
{
- WASM_ZERO_MEMORY((yyval.func_type));
+ WABT_ZERO_MEMORY((yyval.func_type));
(yyval.func_type).sig = (yyvsp[-1].func_sig);
}
#line 3566 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
@@ -3592,7 +3592,7 @@ yyreduce:
#line 1134 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.module) = (yyvsp[-1].module);
- WasmModuleField* field;
+ WabtModuleField* field;
APPEND_FIELD_TO_LIST((yyval.module), field, FUNC_TYPE, func_type, (yylsp[0]), (yyvsp[0].func_type));
APPEND_ITEM_TO_VECTOR((yyval.module), FuncType, func_type, func_types,
&field->func_type);
@@ -3605,7 +3605,7 @@ yyreduce:
#line 1142 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.module) = (yyvsp[-1].module);
- WasmModuleField* field;
+ WabtModuleField* field;
APPEND_FIELD_TO_LIST((yyval.module), field, GLOBAL, global, (yylsp[0]), (yyvsp[0].exported_global).global);
APPEND_ITEM_TO_VECTOR((yyval.module), Global, global, globals, &field->global);
INSERT_BINDING((yyval.module), global, globals, (yylsp[0]), (yyvsp[0].exported_global).global.name);
@@ -3618,14 +3618,14 @@ yyreduce:
#line 1150 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.module) = (yyvsp[-1].module);
- WasmModuleField* field;
+ WabtModuleField* field;
APPEND_FIELD_TO_LIST((yyval.module), field, TABLE, table, (yylsp[0]), (yyvsp[0].exported_table).table);
APPEND_ITEM_TO_VECTOR((yyval.module), Table, table, tables, &field->table);
INSERT_BINDING((yyval.module), table, tables, (yylsp[0]), (yyvsp[0].exported_table).table.name);
APPEND_INLINE_EXPORT((yyval.module), TABLE, (yylsp[0]), (yyvsp[0].exported_table), (yyval.module)->tables.size - 1);
if ((yyvsp[0].exported_table).has_elem_segment) {
- WasmModuleField* elem_segment_field;
+ WabtModuleField* elem_segment_field;
APPEND_FIELD_TO_LIST((yyval.module), elem_segment_field, ELEM_SEGMENT, elem_segment,
(yylsp[0]), (yyvsp[0].exported_table).elem_segment);
APPEND_ITEM_TO_VECTOR((yyval.module), ElemSegment, elem_segment, elem_segments,
@@ -3640,14 +3640,14 @@ yyreduce:
#line 1167 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.module) = (yyvsp[-1].module);
- WasmModuleField* field;
+ WabtModuleField* field;
APPEND_FIELD_TO_LIST((yyval.module), field, MEMORY, memory, (yylsp[0]), (yyvsp[0].exported_memory).memory);
APPEND_ITEM_TO_VECTOR((yyval.module), Memory, memory, memories, &field->memory);
INSERT_BINDING((yyval.module), memory, memories, (yylsp[0]), (yyvsp[0].exported_memory).memory.name);
APPEND_INLINE_EXPORT((yyval.module), MEMORY, (yylsp[0]), (yyvsp[0].exported_memory), (yyval.module)->memories.size - 1);
if ((yyvsp[0].exported_memory).has_data_segment) {
- WasmModuleField* data_segment_field;
+ WabtModuleField* data_segment_field;
APPEND_FIELD_TO_LIST((yyval.module), data_segment_field, DATA_SEGMENT, data_segment,
(yylsp[0]), (yyvsp[0].exported_memory).data_segment);
APPEND_ITEM_TO_VECTOR((yyval.module), DataSegment, data_segment, data_segments,
@@ -3661,14 +3661,14 @@ yyreduce:
#line 1183 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.module) = (yyvsp[-1].module);
- WasmModuleField* field;
+ WabtModuleField* field;
APPEND_FIELD_TO_LIST((yyval.module), field, FUNC, func, (yylsp[0]), *(yyvsp[0].exported_func).func);
append_implicit_func_declaration(parser->allocator, &(yylsp[0]), (yyval.module),
&field->func.decl);
APPEND_ITEM_TO_VECTOR((yyval.module), Func, func, funcs, &field->func);
INSERT_BINDING((yyval.module), func, funcs, (yylsp[0]), (yyvsp[0].exported_func).func->name);
APPEND_INLINE_EXPORT((yyval.module), FUNC, (yylsp[0]), (yyvsp[0].exported_func), (yyval.module)->funcs.size - 1);
- wasm_free(parser->allocator, (yyvsp[0].exported_func).func);
+ wabt_free(parser->allocator, (yyvsp[0].exported_func).func);
}
#line 3674 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
break;
@@ -3677,7 +3677,7 @@ yyreduce:
#line 1194 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.module) = (yyvsp[-1].module);
- WasmModuleField* field;
+ WabtModuleField* field;
APPEND_FIELD_TO_LIST((yyval.module), field, ELEM_SEGMENT, elem_segment, (yylsp[0]), (yyvsp[0].elem_segment));
APPEND_ITEM_TO_VECTOR((yyval.module), ElemSegment, elem_segment, elem_segments,
&field->elem_segment);
@@ -3689,7 +3689,7 @@ yyreduce:
#line 1201 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.module) = (yyvsp[-1].module);
- WasmModuleField* field;
+ WabtModuleField* field;
APPEND_FIELD_TO_LIST((yyval.module), field, DATA_SEGMENT, data_segment, (yylsp[0]), (yyvsp[0].data_segment));
APPEND_ITEM_TO_VECTOR((yyval.module), DataSegment, data_segment, data_segments,
&field->data_segment);
@@ -3701,7 +3701,7 @@ yyreduce:
#line 1208 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.module) = (yyvsp[-1].module);
- WasmModuleField* field;
+ WabtModuleField* field;
APPEND_FIELD_TO_LIST((yyval.module), field, START, start, (yylsp[0]), (yyvsp[0].var));
(yyval.module)->start = &field->start;
}
@@ -3712,42 +3712,42 @@ yyreduce:
#line 1214 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.module) = (yyvsp[-1].module);
- WasmModuleField* field;
+ WabtModuleField* field;
APPEND_FIELD_TO_LIST((yyval.module), field, IMPORT, import, (yylsp[0]), *(yyvsp[0].import));
CHECK_IMPORT_ORDERING((yyval.module), func, funcs, (yylsp[0]));
CHECK_IMPORT_ORDERING((yyval.module), table, tables, (yylsp[0]));
CHECK_IMPORT_ORDERING((yyval.module), memory, memories, (yylsp[0]));
CHECK_IMPORT_ORDERING((yyval.module), global, globals, (yylsp[0]));
switch ((yyvsp[0].import)->kind) {
- case WASM_EXTERNAL_KIND_FUNC:
+ case WABT_EXTERNAL_KIND_FUNC:
append_implicit_func_declaration(parser->allocator, &(yylsp[0]), (yyval.module),
&field->import.func.decl);
APPEND_ITEM_TO_VECTOR((yyval.module), Func, func, funcs, &field->import.func);
INSERT_BINDING((yyval.module), func, funcs, (yylsp[0]), field->import.func.name);
(yyval.module)->num_func_imports++;
break;
- case WASM_EXTERNAL_KIND_TABLE:
+ case WABT_EXTERNAL_KIND_TABLE:
APPEND_ITEM_TO_VECTOR((yyval.module), Table, table, tables, &field->import.table);
INSERT_BINDING((yyval.module), table, tables, (yylsp[0]), field->import.table.name);
(yyval.module)->num_table_imports++;
break;
- case WASM_EXTERNAL_KIND_MEMORY:
+ case WABT_EXTERNAL_KIND_MEMORY:
APPEND_ITEM_TO_VECTOR((yyval.module), Memory, memory, memories,
&field->import.memory);
INSERT_BINDING((yyval.module), memory, memories, (yylsp[0]), field->import.memory.name);
(yyval.module)->num_memory_imports++;
break;
- case WASM_EXTERNAL_KIND_GLOBAL:
+ case WABT_EXTERNAL_KIND_GLOBAL:
APPEND_ITEM_TO_VECTOR((yyval.module), Global, global, globals,
&field->import.global);
INSERT_BINDING((yyval.module), global, globals, (yylsp[0]), field->import.global.name);
(yyval.module)->num_global_imports++;
break;
- case WASM_NUM_EXTERNAL_KINDS:
+ case WABT_NUM_EXTERNAL_KINDS:
assert(0);
break;
}
- wasm_free(parser->allocator, (yyvsp[0].import));
+ wabt_free(parser->allocator, (yyvsp[0].import));
APPEND_ITEM_TO_VECTOR((yyval.module), Import, import, imports, &field->import);
}
#line 3754 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
@@ -3757,7 +3757,7 @@ yyreduce:
#line 1254 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.module) = (yyvsp[-1].module);
- WasmModuleField* field = wasm_append_module_field(parser->allocator, (yyval.module));
+ WabtModuleField* field = wabt_append_module_field(parser->allocator, (yyval.module));
APPEND_FIELD_TO_LIST((yyval.module), field, EXPORT, export_, (yylsp[0]), (yyvsp[0].export_));
APPEND_ITEM_TO_VECTOR((yyval.module), Export, export, exports, &field->export_);
INSERT_BINDING((yyval.module), export, exports, (yylsp[0]), (yyvsp[0].export_).name);
@@ -3768,7 +3768,7 @@ yyreduce:
case 146:
#line 1264 "src/ast-parser.y" /* yacc.c:1646 */
{
- (yyval.raw_module).type = WASM_RAW_MODULE_TYPE_TEXT;
+ (yyval.raw_module).type = WABT_RAW_MODULE_TYPE_TEXT;
(yyval.raw_module).text = (yyvsp[-1].module);
(yyval.raw_module).text->name = (yyvsp[-2].text);
(yyval.raw_module).text->loc = (yylsp[-3]);
@@ -3777,14 +3777,14 @@ yyreduce:
* explicitly */
size_t i;
for (i = 0; i < (yyvsp[-1].module)->funcs.size; ++i) {
- WasmFunc* func = (yyvsp[-1].module)->funcs.data[i];
- if (wasm_decl_has_func_type(&func->decl) &&
+ WabtFunc* func = (yyvsp[-1].module)->funcs.data[i];
+ if (wabt_decl_has_func_type(&func->decl) &&
is_empty_signature(&func->decl.sig)) {
- WasmFuncType* func_type =
- wasm_get_func_type_by_var((yyvsp[-1].module), &func->decl.type_var);
+ WabtFuncType* func_type =
+ wabt_get_func_type_by_var((yyvsp[-1].module), &func->decl.type_var);
if (func_type) {
func->decl.sig = func_type->sig;
- func->decl.flags |= WASM_FUNC_DECLARATION_FLAG_SHARED_SIGNATURE;
+ func->decl.flags |= WABT_FUNC_DECLARATION_FLAG_SHARED_SIGNATURE;
}
}
}
@@ -3795,11 +3795,11 @@ yyreduce:
case 147:
#line 1286 "src/ast-parser.y" /* yacc.c:1646 */
{
- (yyval.raw_module).type = WASM_RAW_MODULE_TYPE_BINARY;
+ (yyval.raw_module).type = WABT_RAW_MODULE_TYPE_BINARY;
(yyval.raw_module).binary.name = (yyvsp[-2].text);
(yyval.raw_module).binary.loc = (yylsp[-3]);
dup_text_list(parser->allocator, &(yyvsp[-1].text_list), &(yyval.raw_module).binary.data, &(yyval.raw_module).binary.size);
- wasm_destroy_text_list(parser->allocator, &(yyvsp[-1].text_list));
+ wabt_destroy_text_list(parser->allocator, &(yyvsp[-1].text_list));
}
#line 3805 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
break;
@@ -3807,22 +3807,22 @@ yyreduce:
case 148:
#line 1296 "src/ast-parser.y" /* yacc.c:1646 */
{
- if ((yyvsp[0].raw_module).type == WASM_RAW_MODULE_TYPE_TEXT) {
+ if ((yyvsp[0].raw_module).type == WABT_RAW_MODULE_TYPE_TEXT) {
(yyval.module) = (yyvsp[0].raw_module).text;
} else {
- assert((yyvsp[0].raw_module).type == WASM_RAW_MODULE_TYPE_BINARY);
+ assert((yyvsp[0].raw_module).type == WABT_RAW_MODULE_TYPE_BINARY);
(yyval.module) = new_module(parser->allocator);
- WasmReadBinaryOptions options = WASM_READ_BINARY_OPTIONS_DEFAULT;
+ WabtReadBinaryOptions options = WABT_READ_BINARY_OPTIONS_DEFAULT;
BinaryErrorCallbackData user_data;
user_data.loc = &(yyvsp[0].raw_module).binary.loc;
user_data.lexer = lexer;
user_data.parser = parser;
- WasmBinaryErrorHandler error_handler;
+ WabtBinaryErrorHandler error_handler;
error_handler.on_error = on_read_binary_error;
error_handler.user_data = &user_data;
- wasm_read_binary_ast(parser->allocator, (yyvsp[0].raw_module).binary.data, (yyvsp[0].raw_module).binary.size,
+ wabt_read_binary_ast(parser->allocator, (yyvsp[0].raw_module).binary.data, (yyvsp[0].raw_module).binary.size,
&options, &error_handler, (yyval.module));
- wasm_free(parser->allocator, (yyvsp[0].raw_module).binary.data);
+ wabt_free(parser->allocator, (yyvsp[0].raw_module).binary.data);
(yyval.module)->name = (yyvsp[0].raw_module).binary.name;
(yyval.module)->loc = (yyvsp[0].raw_module).binary.loc;
}
@@ -3833,8 +3833,8 @@ yyreduce:
case 149:
#line 1322 "src/ast-parser.y" /* yacc.c:1646 */
{
- WASM_ZERO_MEMORY((yyval.var));
- (yyval.var).type = WASM_VAR_TYPE_INDEX;
+ WABT_ZERO_MEMORY((yyval.var));
+ (yyval.var).type = WABT_VAR_TYPE_INDEX;
(yyval.var).index = INVALID_VAR_INDEX;
}
#line 3841 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
@@ -3843,8 +3843,8 @@ yyreduce:
case 150:
#line 1327 "src/ast-parser.y" /* yacc.c:1646 */
{
- WASM_ZERO_MEMORY((yyval.var));
- (yyval.var).type = WASM_VAR_TYPE_NAME;
+ WABT_ZERO_MEMORY((yyval.var));
+ (yyval.var).type = WABT_VAR_TYPE_NAME;
DUPTEXT((yyval.var).name, (yyvsp[0].text));
}
#line 3851 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
@@ -3853,10 +3853,10 @@ yyreduce:
case 151:
#line 1335 "src/ast-parser.y" /* yacc.c:1646 */
{
- WASM_ZERO_MEMORY((yyval.action));
+ WABT_ZERO_MEMORY((yyval.action));
(yyval.action).loc = (yylsp[-4]);
(yyval.action).module_var = (yyvsp[-3].var);
- (yyval.action).type = WASM_ACTION_TYPE_INVOKE;
+ (yyval.action).type = WABT_ACTION_TYPE_INVOKE;
(yyval.action).invoke.name = (yyvsp[-2].text);
(yyval.action).invoke.args = (yyvsp[-1].consts);
}
@@ -3866,10 +3866,10 @@ yyreduce:
case 152:
#line 1343 "src/ast-parser.y" /* yacc.c:1646 */
{
- WASM_ZERO_MEMORY((yyval.action));
+ WABT_ZERO_MEMORY((yyval.action));
(yyval.action).loc = (yylsp[-3]);
(yyval.action).module_var = (yyvsp[-2].var);
- (yyval.action).type = WASM_ACTION_TYPE_GET;
+ (yyval.action).type = WABT_ACTION_TYPE_GET;
(yyval.action).invoke.name = (yyvsp[-1].text);
}
#line 3876 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
@@ -3879,7 +3879,7 @@ yyreduce:
#line 1353 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.command) = new_command(parser->allocator);
- (yyval.command)->type = WASM_COMMAND_TYPE_ASSERT_MALFORMED;
+ (yyval.command)->type = WABT_COMMAND_TYPE_ASSERT_MALFORMED;
(yyval.command)->assert_malformed.module = (yyvsp[-2].raw_module);
(yyval.command)->assert_malformed.text = (yyvsp[-1].text);
}
@@ -3890,7 +3890,7 @@ yyreduce:
#line 1359 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.command) = new_command(parser->allocator);
- (yyval.command)->type = WASM_COMMAND_TYPE_ASSERT_INVALID;
+ (yyval.command)->type = WABT_COMMAND_TYPE_ASSERT_INVALID;
(yyval.command)->assert_invalid.module = (yyvsp[-2].raw_module);
(yyval.command)->assert_invalid.text = (yyvsp[-1].text);
}
@@ -3901,7 +3901,7 @@ yyreduce:
#line 1365 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.command) = new_command(parser->allocator);
- (yyval.command)->type = WASM_COMMAND_TYPE_ASSERT_UNLINKABLE;
+ (yyval.command)->type = WABT_COMMAND_TYPE_ASSERT_UNLINKABLE;
(yyval.command)->assert_unlinkable.module = (yyvsp[-2].raw_module);
(yyval.command)->assert_unlinkable.text = (yyvsp[-1].text);
}
@@ -3912,7 +3912,7 @@ yyreduce:
#line 1371 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.command) = new_command(parser->allocator);
- (yyval.command)->type = WASM_COMMAND_TYPE_ASSERT_UNINSTANTIABLE;
+ (yyval.command)->type = WABT_COMMAND_TYPE_ASSERT_UNINSTANTIABLE;
(yyval.command)->assert_uninstantiable.module = (yyvsp[-2].raw_module);
(yyval.command)->assert_uninstantiable.text = (yyvsp[-1].text);
}
@@ -3923,7 +3923,7 @@ yyreduce:
#line 1377 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.command) = new_command(parser->allocator);
- (yyval.command)->type = WASM_COMMAND_TYPE_ASSERT_RETURN;
+ (yyval.command)->type = WABT_COMMAND_TYPE_ASSERT_RETURN;
(yyval.command)->assert_return.action = (yyvsp[-2].action);
(yyval.command)->assert_return.expected = (yyvsp[-1].consts);
}
@@ -3934,7 +3934,7 @@ yyreduce:
#line 1383 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.command) = new_command(parser->allocator);
- (yyval.command)->type = WASM_COMMAND_TYPE_ASSERT_RETURN_NAN;
+ (yyval.command)->type = WABT_COMMAND_TYPE_ASSERT_RETURN_NAN;
(yyval.command)->assert_return_nan.action = (yyvsp[-1].action);
}
#line 3941 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
@@ -3944,7 +3944,7 @@ yyreduce:
#line 1388 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.command) = new_command(parser->allocator);
- (yyval.command)->type = WASM_COMMAND_TYPE_ASSERT_TRAP;
+ (yyval.command)->type = WABT_COMMAND_TYPE_ASSERT_TRAP;
(yyval.command)->assert_trap.action = (yyvsp[-2].action);
(yyval.command)->assert_trap.text = (yyvsp[-1].text);
}
@@ -3955,7 +3955,7 @@ yyreduce:
#line 1394 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.command) = new_command(parser->allocator);
- (yyval.command)->type = WASM_COMMAND_TYPE_ASSERT_EXHAUSTION;
+ (yyval.command)->type = WABT_COMMAND_TYPE_ASSERT_EXHAUSTION;
(yyval.command)->assert_trap.action = (yyvsp[-2].action);
(yyval.command)->assert_trap.text = (yyvsp[-1].text);
}
@@ -3966,7 +3966,7 @@ yyreduce:
#line 1403 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.command) = new_command(parser->allocator);
- (yyval.command)->type = WASM_COMMAND_TYPE_ACTION;
+ (yyval.command)->type = WABT_COMMAND_TYPE_ACTION;
(yyval.command)->action = (yyvsp[0].action);
}
#line 3973 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
@@ -3976,9 +3976,9 @@ yyreduce:
#line 1409 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.command) = new_command(parser->allocator);
- (yyval.command)->type = WASM_COMMAND_TYPE_MODULE;
+ (yyval.command)->type = WABT_COMMAND_TYPE_MODULE;
(yyval.command)->module = *(yyvsp[0].module);
- wasm_free(parser->allocator, (yyvsp[0].module));
+ wabt_free(parser->allocator, (yyvsp[0].module));
}
#line 3984 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
break;
@@ -3987,7 +3987,7 @@ yyreduce:
#line 1415 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.command) = new_command(parser->allocator);
- (yyval.command)->type = WASM_COMMAND_TYPE_REGISTER;
+ (yyval.command)->type = WABT_COMMAND_TYPE_REGISTER;
(yyval.command)->register_.module_name = (yyvsp[-2].text);
(yyval.command)->register_.var = (yyvsp[-1].var);
(yyval.command)->register_.var.loc = (yylsp[-1]);
@@ -3997,7 +3997,7 @@ yyreduce:
case 165:
#line 1424 "src/ast-parser.y" /* yacc.c:1646 */
- { WASM_ZERO_MEMORY((yyval.commands)); }
+ { WABT_ZERO_MEMORY((yyval.commands)); }
#line 4002 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
break;
@@ -4005,8 +4005,8 @@ yyreduce:
#line 1425 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.commands) = (yyvsp[-1].commands);
- wasm_append_command_value(parser->allocator, &(yyval.commands), (yyvsp[0].command));
- wasm_free(parser->allocator, (yyvsp[0].command));
+ wabt_append_command_value(parser->allocator, &(yyval.commands), (yyvsp[0].command));
+ wabt_free(parser->allocator, (yyvsp[0].command));
}
#line 4012 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
break;
@@ -4015,20 +4015,20 @@ yyreduce:
#line 1433 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.const_).loc = (yylsp[-2]);
- if (WASM_FAILED(parse_const((yyvsp[-2].type), (yyvsp[-1].literal).type, (yyvsp[-1].literal).text.start,
+ if (WABT_FAILED(parse_const((yyvsp[-2].type), (yyvsp[-1].literal).type, (yyvsp[-1].literal).text.start,
(yyvsp[-1].literal).text.start + (yyvsp[-1].literal).text.length, &(yyval.const_)))) {
- wasm_ast_parser_error(&(yylsp[-1]), lexer, parser,
+ wabt_ast_parser_error(&(yylsp[-1]), lexer, parser,
"invalid literal \"" PRIstringslice "\"",
- WASM_PRINTF_STRING_SLICE_ARG((yyvsp[-1].literal).text));
+ WABT_PRINTF_STRING_SLICE_ARG((yyvsp[-1].literal).text));
}
- wasm_free(parser->allocator, (char*)(yyvsp[-1].literal).text.start);
+ wabt_free(parser->allocator, (char*)(yyvsp[-1].literal).text.start);
}
#line 4027 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
break;
case 168:
#line 1445 "src/ast-parser.y" /* yacc.c:1646 */
- { WASM_ZERO_MEMORY((yyval.consts)); }
+ { WABT_ZERO_MEMORY((yyval.consts)); }
#line 4033 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
break;
@@ -4036,7 +4036,7 @@ yyreduce:
#line 1446 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.consts) = (yyvsp[-1].consts);
- wasm_append_const_value(parser->allocator, &(yyval.consts), &(yyvsp[0].const_));
+ wabt_append_const_value(parser->allocator, &(yyval.consts), &(yyvsp[0].const_));
}
#line 4042 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
break;
@@ -4044,54 +4044,54 @@ yyreduce:
case 170:
#line 1453 "src/ast-parser.y" /* yacc.c:1646 */
{
- WASM_ZERO_MEMORY((yyval.script));
+ WABT_ZERO_MEMORY((yyval.script));
(yyval.script).allocator = parser->allocator;
(yyval.script).commands = (yyvsp[0].commands);
int last_module_index = -1;
size_t i;
for (i = 0; i < (yyval.script).commands.size; ++i) {
- WasmCommand* command = &(yyval.script).commands.data[i];
- WasmVar* module_var = NULL;
+ WabtCommand* command = &(yyval.script).commands.data[i];
+ WabtVar* module_var = NULL;
switch (command->type) {
- case WASM_COMMAND_TYPE_MODULE: {
+ case WABT_COMMAND_TYPE_MODULE: {
last_module_index = i;
/* Wire up module name bindings. */
- WasmModule* module = &command->module;
+ WabtModule* module = &command->module;
if (module->name.length == 0)
continue;
- WasmStringSlice module_name =
- wasm_dup_string_slice(parser->allocator, module->name);
- WasmBinding* binding = wasm_insert_binding(
+ WabtStringSlice module_name =
+ wabt_dup_string_slice(parser->allocator, module->name);
+ WabtBinding* binding = wabt_insert_binding(
parser->allocator, &(yyval.script).module_bindings, &module_name);
binding->loc = module->loc;
binding->index = i;
break;
}
- case WASM_COMMAND_TYPE_ASSERT_RETURN:
+ case WABT_COMMAND_TYPE_ASSERT_RETURN:
module_var = &command->assert_return.action.module_var;
goto has_module_var;
- case WASM_COMMAND_TYPE_ASSERT_RETURN_NAN:
+ case WABT_COMMAND_TYPE_ASSERT_RETURN_NAN:
module_var = &command->assert_return_nan.action.module_var;
goto has_module_var;
- case WASM_COMMAND_TYPE_ASSERT_TRAP:
- case WASM_COMMAND_TYPE_ASSERT_EXHAUSTION:
+ case WABT_COMMAND_TYPE_ASSERT_TRAP:
+ case WABT_COMMAND_TYPE_ASSERT_EXHAUSTION:
module_var = &command->assert_trap.action.module_var;
goto has_module_var;
- case WASM_COMMAND_TYPE_ACTION:
+ case WABT_COMMAND_TYPE_ACTION:
module_var = &command->action.module_var;
goto has_module_var;
- case WASM_COMMAND_TYPE_REGISTER:
+ case WABT_COMMAND_TYPE_REGISTER:
module_var = &command->register_.var;
goto has_module_var;
has_module_var: {
/* Resolve actions with an invalid index to use the preceding
* module. */
- if (module_var->type == WASM_VAR_TYPE_INDEX &&
+ if (module_var->type == WABT_VAR_TYPE_INDEX &&
module_var->index == INVALID_VAR_INDEX) {
module_var->index = last_module_index;
}
@@ -4346,7 +4346,7 @@ yyreturn:
#line 1522 "src/ast-parser.y" /* yacc.c:1906 */
-static void append_expr_list(WasmExprList* expr_list, WasmExprList* expr) {
+static void append_expr_list(WabtExprList* expr_list, WabtExprList* expr) {
if (!expr->first)
return;
if (expr_list->last)
@@ -4357,7 +4357,7 @@ static void append_expr_list(WasmExprList* expr_list, WasmExprList* expr) {
expr_list->size += expr->size;
}
-static void append_expr(WasmExprList* expr_list, WasmExpr* expr) {
+static void append_expr(WabtExprList* expr_list, WabtExpr* expr) {
if (expr_list->last)
expr_list->last->next = expr;
else
@@ -4366,49 +4366,49 @@ static void append_expr(WasmExprList* expr_list, WasmExpr* expr) {
expr_list->size++;
}
-static WasmExprList join_exprs1(WasmLocation* loc, WasmExpr* expr1) {
- WasmExprList result;
- WASM_ZERO_MEMORY(result);
+static WabtExprList join_exprs1(WabtLocation* loc, WabtExpr* expr1) {
+ WabtExprList result;
+ WABT_ZERO_MEMORY(result);
append_expr(&result, expr1);
expr1->loc = *loc;
return result;
}
-static WasmExprList join_exprs2(WasmLocation* loc, WasmExprList* expr1,
- WasmExpr* expr2) {
- WasmExprList result;
- WASM_ZERO_MEMORY(result);
+static WabtExprList join_exprs2(WabtLocation* loc, WabtExprList* expr1,
+ WabtExpr* expr2) {
+ WabtExprList result;
+ WABT_ZERO_MEMORY(result);
append_expr_list(&result, expr1);
append_expr(&result, expr2);
expr2->loc = *loc;
return result;
}
-static WasmResult parse_const(WasmType type,
- WasmLiteralType literal_type,
+static WabtResult parse_const(WabtType type,
+ WabtLiteralType literal_type,
const char* s,
const char* end,
- WasmConst* out) {
+ WabtConst* out) {
out->type = type;
switch (type) {
- case WASM_TYPE_I32:
- return wasm_parse_int32(s, end, &out->u32,
- WASM_PARSE_SIGNED_AND_UNSIGNED);
- case WASM_TYPE_I64:
- return wasm_parse_int64(s, end, &out->u64,
- WASM_PARSE_SIGNED_AND_UNSIGNED);
- case WASM_TYPE_F32:
- return wasm_parse_float(literal_type, s, end, &out->f32_bits);
- case WASM_TYPE_F64:
- return wasm_parse_double(literal_type, s, end, &out->f64_bits);
+ case WABT_TYPE_I32:
+ return wabt_parse_int32(s, end, &out->u32,
+ WABT_PARSE_SIGNED_AND_UNSIGNED);
+ case WABT_TYPE_I64:
+ return wabt_parse_int64(s, end, &out->u64,
+ WABT_PARSE_SIGNED_AND_UNSIGNED);
+ case WABT_TYPE_F32:
+ return wabt_parse_float(literal_type, s, end, &out->f32_bits);
+ case WABT_TYPE_F64:
+ return wabt_parse_double(literal_type, s, end, &out->f64_bits);
default:
assert(0);
break;
}
- return WASM_ERROR;
+ return WABT_ERROR;
}
-static size_t copy_string_contents(WasmStringSlice* text, char* dest) {
+static size_t copy_string_contents(WabtStringSlice* text, char* dest) {
const char* src = text->start + 1;
const char* end = text->start + text->length - 1;
@@ -4438,8 +4438,8 @@ static size_t copy_string_contents(WasmStringSlice* text, char* dest) {
* sequence */
uint32_t hi;
uint32_t lo;
- if (WASM_SUCCEEDED(wasm_parse_hexdigit(src[0], &hi)) &&
- WASM_SUCCEEDED(wasm_parse_hexdigit(src[1], &lo))) {
+ if (WABT_SUCCEEDED(wabt_parse_hexdigit(src[0], &hi)) &&
+ WABT_SUCCEEDED(wabt_parse_hexdigit(src[1], &lo))) {
*dest++ = (hi << 4) | lo;
} else {
assert(0);
@@ -4457,13 +4457,13 @@ static size_t copy_string_contents(WasmStringSlice* text, char* dest) {
return dest - dest_start;
}
-static void dup_text_list(WasmAllocator* allocator,
- WasmTextList* text_list,
+static void dup_text_list(WabtAllocator* allocator,
+ WabtTextList* text_list,
void** out_data,
size_t* out_size) {
/* walk the linked list to see how much total space is needed */
size_t total_size = 0;
- WasmTextListNode* node;
+ WabtTextListNode* node;
for (node = text_list->first; node; node = node->next) {
/* Always allocate enough space for the entire string including the escape
* characters. It will only get shorter, and this way we only have to
@@ -4473,7 +4473,7 @@ static void dup_text_list(WasmAllocator* allocator,
size_t size = (end > src) ? (end - src) : 0;
total_size += size;
}
- char* result = wasm_alloc(allocator, total_size, 1);
+ char* result = wabt_alloc(allocator, total_size, 1);
char* dest = result;
for (node = text_list->first; node; node = node->next) {
size_t actual_size = copy_string_contents(&node->text, dest);
@@ -4483,56 +4483,56 @@ static void dup_text_list(WasmAllocator* allocator,
*out_size = dest - result;
}
-static WasmBool is_empty_signature(WasmFuncSignature* sig) {
+static WabtBool is_empty_signature(WabtFuncSignature* sig) {
return sig->result_types.size == 0 && sig->param_types.size == 0;
}
-static void append_implicit_func_declaration(WasmAllocator* allocator,
- WasmLocation* loc,
- WasmModule* module,
- WasmFuncDeclaration* decl) {
- if (wasm_decl_has_func_type(decl))
+static void append_implicit_func_declaration(WabtAllocator* allocator,
+ WabtLocation* loc,
+ WabtModule* module,
+ WabtFuncDeclaration* decl) {
+ if (wabt_decl_has_func_type(decl))
return;
- int sig_index = wasm_get_func_type_index_by_decl(module, decl);
+ int sig_index = wabt_get_func_type_index_by_decl(module, decl);
if (sig_index == -1) {
- wasm_append_implicit_func_type(allocator, loc, module, &decl->sig);
+ wabt_append_implicit_func_type(allocator, loc, module, &decl->sig);
} else {
/* signature already exists, share that one and destroy this one */
- wasm_destroy_func_signature(allocator, &decl->sig);
- WasmFuncSignature* sig = &module->func_types.data[sig_index]->sig;
+ wabt_destroy_func_signature(allocator, &decl->sig);
+ WabtFuncSignature* sig = &module->func_types.data[sig_index]->sig;
decl->sig = *sig;
}
- decl->flags |= WASM_FUNC_DECLARATION_FLAG_SHARED_SIGNATURE;
+ decl->flags |= WABT_FUNC_DECLARATION_FLAG_SHARED_SIGNATURE;
}
-WasmResult wasm_parse_ast(WasmAstLexer* lexer,
- struct WasmScript* out_script,
- WasmSourceErrorHandler* error_handler) {
- WasmAstParser parser;
- WASM_ZERO_MEMORY(parser);
- WasmAllocator* allocator = wasm_ast_lexer_get_allocator(lexer);
+WabtResult wabt_parse_ast(WabtAstLexer* lexer,
+ struct WabtScript* out_script,
+ WabtSourceErrorHandler* error_handler) {
+ WabtAstParser parser;
+ WABT_ZERO_MEMORY(parser);
+ WabtAllocator* allocator = wabt_ast_lexer_get_allocator(lexer);
parser.allocator = allocator;
parser.script.allocator = allocator;
parser.error_handler = error_handler;
- int result = wasm_ast_parser_parse(lexer, &parser);
+ int result = wabt_ast_parser_parse(lexer, &parser);
*out_script = parser.script;
- return result == 0 && parser.errors == 0 ? WASM_OK : WASM_ERROR;
+ return result == 0 && parser.errors == 0 ? WABT_OK : WABT_ERROR;
}
static void on_read_binary_error(uint32_t offset, const char* error,
void* user_data) {
BinaryErrorCallbackData* data = user_data;
- if (offset == WASM_UNKNOWN_OFFSET) {
- wasm_ast_parser_error(data->loc, data->lexer, data->parser,
+ if (offset == WABT_UNKNOWN_OFFSET) {
+ wabt_ast_parser_error(data->loc, data->lexer, data->parser,
"error in binary module: %s", error);
} else {
- wasm_ast_parser_error(data->loc, data->lexer, data->parser,
+ wabt_ast_parser_error(data->loc, data->lexer, data->parser,
"error in binary module: @0x%08x: %s", offset, error);
}
}
/* see comment above definition of YYMAXDEPTH at the top of this file */
-WASM_STATIC_ASSERT(YYSTACK_ALLOC_MAXIMUM >= UINT32_MAX);
-WASM_STATIC_ASSERT(YYSTACK_BYTES((uint64_t)YYMAXDEPTH) <= UINT32_MAX);
+WABT_STATIC_ASSERT(YYSTACK_ALLOC_MAXIMUM >= UINT32_MAX);
+WABT_STATIC_ASSERT(YYSTACK_BYTES((uint64_t)YYMAXDEPTH) <= UINT32_MAX);
diff --git a/src/prebuilt/ast-parser-gen.h b/src/prebuilt/ast-parser-gen.h
index 7661d3de..11b9f11b 100644
--- a/src/prebuilt/ast-parser-gen.h
+++ b/src/prebuilt/ast-parser-gen.h
@@ -30,127 +30,127 @@
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
-#ifndef YY_WASM_AST_PARSER_SRC_PREBUILT_AST_PARSER_GEN_H_INCLUDED
-# define YY_WASM_AST_PARSER_SRC_PREBUILT_AST_PARSER_GEN_H_INCLUDED
+#ifndef YY_WABT_AST_PARSER_SRC_PREBUILT_AST_PARSER_GEN_H_INCLUDED
+# define YY_WABT_AST_PARSER_SRC_PREBUILT_AST_PARSER_GEN_H_INCLUDED
/* Debug traces. */
-#ifndef WASM_AST_PARSER_DEBUG
+#ifndef WABT_AST_PARSER_DEBUG
# if defined YYDEBUG
#if YYDEBUG
-# define WASM_AST_PARSER_DEBUG 1
+# define WABT_AST_PARSER_DEBUG 1
# else
-# define WASM_AST_PARSER_DEBUG 0
+# define WABT_AST_PARSER_DEBUG 0
# endif
# else /* ! defined YYDEBUG */
-# define WASM_AST_PARSER_DEBUG 0
+# define WABT_AST_PARSER_DEBUG 0
# endif /* ! defined YYDEBUG */
-#endif /* ! defined WASM_AST_PARSER_DEBUG */
-#if WASM_AST_PARSER_DEBUG
-extern int wasm_ast_parser_debug;
+#endif /* ! defined WABT_AST_PARSER_DEBUG */
+#if WABT_AST_PARSER_DEBUG
+extern int wabt_ast_parser_debug;
#endif
/* Token type. */
-#ifndef WASM_AST_PARSER_TOKENTYPE
-# define WASM_AST_PARSER_TOKENTYPE
- enum wasm_ast_parser_tokentype
+#ifndef WABT_AST_PARSER_TOKENTYPE
+# define WABT_AST_PARSER_TOKENTYPE
+ enum wabt_ast_parser_tokentype
{
- WASM_TOKEN_TYPE_EOF = 0,
- WASM_TOKEN_TYPE_LPAR = 258,
- WASM_TOKEN_TYPE_RPAR = 259,
- WASM_TOKEN_TYPE_NAT = 260,
- WASM_TOKEN_TYPE_INT = 261,
- WASM_TOKEN_TYPE_FLOAT = 262,
- WASM_TOKEN_TYPE_TEXT = 263,
- WASM_TOKEN_TYPE_VAR = 264,
- WASM_TOKEN_TYPE_VALUE_TYPE = 265,
- WASM_TOKEN_TYPE_ANYFUNC = 266,
- WASM_TOKEN_TYPE_MUT = 267,
- WASM_TOKEN_TYPE_NOP = 268,
- WASM_TOKEN_TYPE_DROP = 269,
- WASM_TOKEN_TYPE_BLOCK = 270,
- WASM_TOKEN_TYPE_END = 271,
- WASM_TOKEN_TYPE_IF = 272,
- WASM_TOKEN_TYPE_THEN = 273,
- WASM_TOKEN_TYPE_ELSE = 274,
- WASM_TOKEN_TYPE_LOOP = 275,
- WASM_TOKEN_TYPE_BR = 276,
- WASM_TOKEN_TYPE_BR_IF = 277,
- WASM_TOKEN_TYPE_BR_TABLE = 278,
- WASM_TOKEN_TYPE_CALL = 279,
- WASM_TOKEN_TYPE_CALL_IMPORT = 280,
- WASM_TOKEN_TYPE_CALL_INDIRECT = 281,
- WASM_TOKEN_TYPE_RETURN = 282,
- WASM_TOKEN_TYPE_GET_LOCAL = 283,
- WASM_TOKEN_TYPE_SET_LOCAL = 284,
- WASM_TOKEN_TYPE_TEE_LOCAL = 285,
- WASM_TOKEN_TYPE_GET_GLOBAL = 286,
- WASM_TOKEN_TYPE_SET_GLOBAL = 287,
- WASM_TOKEN_TYPE_LOAD = 288,
- WASM_TOKEN_TYPE_STORE = 289,
- WASM_TOKEN_TYPE_OFFSET_EQ_NAT = 290,
- WASM_TOKEN_TYPE_ALIGN_EQ_NAT = 291,
- WASM_TOKEN_TYPE_CONST = 292,
- WASM_TOKEN_TYPE_UNARY = 293,
- WASM_TOKEN_TYPE_BINARY = 294,
- WASM_TOKEN_TYPE_COMPARE = 295,
- WASM_TOKEN_TYPE_CONVERT = 296,
- WASM_TOKEN_TYPE_SELECT = 297,
- WASM_TOKEN_TYPE_UNREACHABLE = 298,
- WASM_TOKEN_TYPE_CURRENT_MEMORY = 299,
- WASM_TOKEN_TYPE_GROW_MEMORY = 300,
- WASM_TOKEN_TYPE_FUNC = 301,
- WASM_TOKEN_TYPE_START = 302,
- WASM_TOKEN_TYPE_TYPE = 303,
- WASM_TOKEN_TYPE_PARAM = 304,
- WASM_TOKEN_TYPE_RESULT = 305,
- WASM_TOKEN_TYPE_LOCAL = 306,
- WASM_TOKEN_TYPE_GLOBAL = 307,
- WASM_TOKEN_TYPE_MODULE = 308,
- WASM_TOKEN_TYPE_TABLE = 309,
- WASM_TOKEN_TYPE_ELEM = 310,
- WASM_TOKEN_TYPE_MEMORY = 311,
- WASM_TOKEN_TYPE_DATA = 312,
- WASM_TOKEN_TYPE_OFFSET = 313,
- WASM_TOKEN_TYPE_IMPORT = 314,
- WASM_TOKEN_TYPE_EXPORT = 315,
- WASM_TOKEN_TYPE_REGISTER = 316,
- WASM_TOKEN_TYPE_INVOKE = 317,
- WASM_TOKEN_TYPE_GET = 318,
- WASM_TOKEN_TYPE_ASSERT_MALFORMED = 319,
- WASM_TOKEN_TYPE_ASSERT_INVALID = 320,
- WASM_TOKEN_TYPE_ASSERT_UNLINKABLE = 321,
- WASM_TOKEN_TYPE_ASSERT_RETURN = 322,
- WASM_TOKEN_TYPE_ASSERT_RETURN_NAN = 323,
- WASM_TOKEN_TYPE_ASSERT_TRAP = 324,
- WASM_TOKEN_TYPE_ASSERT_EXHAUSTION = 325,
- WASM_TOKEN_TYPE_INPUT = 326,
- WASM_TOKEN_TYPE_OUTPUT = 327,
- WASM_TOKEN_TYPE_LOW = 328
+ WABT_TOKEN_TYPE_EOF = 0,
+ WABT_TOKEN_TYPE_LPAR = 258,
+ WABT_TOKEN_TYPE_RPAR = 259,
+ WABT_TOKEN_TYPE_NAT = 260,
+ WABT_TOKEN_TYPE_INT = 261,
+ WABT_TOKEN_TYPE_FLOAT = 262,
+ WABT_TOKEN_TYPE_TEXT = 263,
+ WABT_TOKEN_TYPE_VAR = 264,
+ WABT_TOKEN_TYPE_VALUE_TYPE = 265,
+ WABT_TOKEN_TYPE_ANYFUNC = 266,
+ WABT_TOKEN_TYPE_MUT = 267,
+ WABT_TOKEN_TYPE_NOP = 268,
+ WABT_TOKEN_TYPE_DROP = 269,
+ WABT_TOKEN_TYPE_BLOCK = 270,
+ WABT_TOKEN_TYPE_END = 271,
+ WABT_TOKEN_TYPE_IF = 272,
+ WABT_TOKEN_TYPE_THEN = 273,
+ WABT_TOKEN_TYPE_ELSE = 274,
+ WABT_TOKEN_TYPE_LOOP = 275,
+ WABT_TOKEN_TYPE_BR = 276,
+ WABT_TOKEN_TYPE_BR_IF = 277,
+ WABT_TOKEN_TYPE_BR_TABLE = 278,
+ WABT_TOKEN_TYPE_CALL = 279,
+ WABT_TOKEN_TYPE_CALL_IMPORT = 280,
+ WABT_TOKEN_TYPE_CALL_INDIRECT = 281,
+ WABT_TOKEN_TYPE_RETURN = 282,
+ WABT_TOKEN_TYPE_GET_LOCAL = 283,
+ WABT_TOKEN_TYPE_SET_LOCAL = 284,
+ WABT_TOKEN_TYPE_TEE_LOCAL = 285,
+ WABT_TOKEN_TYPE_GET_GLOBAL = 286,
+ WABT_TOKEN_TYPE_SET_GLOBAL = 287,
+ WABT_TOKEN_TYPE_LOAD = 288,
+ WABT_TOKEN_TYPE_STORE = 289,
+ WABT_TOKEN_TYPE_OFFSET_EQ_NAT = 290,
+ WABT_TOKEN_TYPE_ALIGN_EQ_NAT = 291,
+ WABT_TOKEN_TYPE_CONST = 292,
+ WABT_TOKEN_TYPE_UNARY = 293,
+ WABT_TOKEN_TYPE_BINARY = 294,
+ WABT_TOKEN_TYPE_COMPARE = 295,
+ WABT_TOKEN_TYPE_CONVERT = 296,
+ WABT_TOKEN_TYPE_SELECT = 297,
+ WABT_TOKEN_TYPE_UNREACHABLE = 298,
+ WABT_TOKEN_TYPE_CURRENT_MEMORY = 299,
+ WABT_TOKEN_TYPE_GROW_MEMORY = 300,
+ WABT_TOKEN_TYPE_FUNC = 301,
+ WABT_TOKEN_TYPE_START = 302,
+ WABT_TOKEN_TYPE_TYPE = 303,
+ WABT_TOKEN_TYPE_PARAM = 304,
+ WABT_TOKEN_TYPE_RESULT = 305,
+ WABT_TOKEN_TYPE_LOCAL = 306,
+ WABT_TOKEN_TYPE_GLOBAL = 307,
+ WABT_TOKEN_TYPE_MODULE = 308,
+ WABT_TOKEN_TYPE_TABLE = 309,
+ WABT_TOKEN_TYPE_ELEM = 310,
+ WABT_TOKEN_TYPE_MEMORY = 311,
+ WABT_TOKEN_TYPE_DATA = 312,
+ WABT_TOKEN_TYPE_OFFSET = 313,
+ WABT_TOKEN_TYPE_IMPORT = 314,
+ WABT_TOKEN_TYPE_EXPORT = 315,
+ WABT_TOKEN_TYPE_REGISTER = 316,
+ WABT_TOKEN_TYPE_INVOKE = 317,
+ WABT_TOKEN_TYPE_GET = 318,
+ WABT_TOKEN_TYPE_ASSERT_MALFORMED = 319,
+ WABT_TOKEN_TYPE_ASSERT_INVALID = 320,
+ WABT_TOKEN_TYPE_ASSERT_UNLINKABLE = 321,
+ WABT_TOKEN_TYPE_ASSERT_RETURN = 322,
+ WABT_TOKEN_TYPE_ASSERT_RETURN_NAN = 323,
+ WABT_TOKEN_TYPE_ASSERT_TRAP = 324,
+ WABT_TOKEN_TYPE_ASSERT_EXHAUSTION = 325,
+ WABT_TOKEN_TYPE_INPUT = 326,
+ WABT_TOKEN_TYPE_OUTPUT = 327,
+ WABT_TOKEN_TYPE_LOW = 328
};
#endif
/* Value type. */
-#if ! defined WASM_AST_PARSER_STYPE && ! defined WASM_AST_PARSER_STYPE_IS_DECLARED
-typedef WasmToken WASM_AST_PARSER_STYPE;
-# define WASM_AST_PARSER_STYPE_IS_TRIVIAL 1
-# define WASM_AST_PARSER_STYPE_IS_DECLARED 1
+#if ! defined WABT_AST_PARSER_STYPE && ! defined WABT_AST_PARSER_STYPE_IS_DECLARED
+typedef WabtToken WABT_AST_PARSER_STYPE;
+# define WABT_AST_PARSER_STYPE_IS_TRIVIAL 1
+# define WABT_AST_PARSER_STYPE_IS_DECLARED 1
#endif
/* Location type. */
-#if ! defined WASM_AST_PARSER_LTYPE && ! defined WASM_AST_PARSER_LTYPE_IS_DECLARED
-typedef struct WASM_AST_PARSER_LTYPE WASM_AST_PARSER_LTYPE;
-struct WASM_AST_PARSER_LTYPE
+#if ! defined WABT_AST_PARSER_LTYPE && ! defined WABT_AST_PARSER_LTYPE_IS_DECLARED
+typedef struct WABT_AST_PARSER_LTYPE WABT_AST_PARSER_LTYPE;
+struct WABT_AST_PARSER_LTYPE
{
int first_line;
int first_column;
int last_line;
int last_column;
};
-# define WASM_AST_PARSER_LTYPE_IS_DECLARED 1
-# define WASM_AST_PARSER_LTYPE_IS_TRIVIAL 1
+# define WABT_AST_PARSER_LTYPE_IS_DECLARED 1
+# define WABT_AST_PARSER_LTYPE_IS_TRIVIAL 1
#endif
-int wasm_ast_parser_parse (WasmAstLexer* lexer, WasmAstParser* parser);
+int wabt_ast_parser_parse (WabtAstLexer* lexer, WabtAstParser* parser);
-#endif /* !YY_WASM_AST_PARSER_SRC_PREBUILT_AST_PARSER_GEN_H_INCLUDED */
+#endif /* !YY_WABT_AST_PARSER_SRC_PREBUILT_AST_PARSER_GEN_H_INCLUDED */
diff --git a/src/prebuilt/ast-parser-gen.output b/src/prebuilt/ast-parser-gen.output
new file mode 100644
index 00000000..7d0a0aad
--- /dev/null
+++ b/src/prebuilt/ast-parser-gen.output
@@ -0,0 +1,4922 @@
+Terminals unused in grammar
+
+ CALL_IMPORT
+ INPUT
+ OUTPUT
+
+
+Grammar
+
+ 0 $accept: script_start "EOF"
+
+ 1 non_empty_text_list: TEXT
+ 2 | non_empty_text_list TEXT
+
+ 3 text_list: %empty
+ 4 | non_empty_text_list
+
+ 5 quoted_text: TEXT
+
+ 6 value_type_list: %empty
+ 7 | value_type_list VALUE_TYPE
+
+ 8 elem_type: ANYFUNC
+
+ 9 global_type: VALUE_TYPE
+ 10 | "(" MUT VALUE_TYPE ")"
+
+ 11 func_type: "(" FUNC func_sig ")"
+
+ 12 func_sig: %empty
+ 13 | "(" PARAM value_type_list ")"
+ 14 | "(" PARAM value_type_list ")" "(" RESULT value_type_list ")"
+ 15 | "(" RESULT value_type_list ")"
+
+ 16 table_sig: limits elem_type
+
+ 17 memory_sig: limits
+
+ 18 limits: nat
+ 19 | nat nat
+
+ 20 type_use: "(" TYPE var ")"
+
+ 21 nat: NAT
+
+ 22 literal: NAT
+ 23 | INT
+ 24 | FLOAT
+
+ 25 var: nat
+ 26 | VAR
+
+ 27 var_list: %empty
+ 28 | var_list var
+
+ 29 bind_var_opt: %empty
+ 30 | bind_var
+
+ 31 bind_var: VAR
+
+ 32 labeling_opt: %empty
+ 33 | bind_var
+
+ 34 offset_opt: %empty
+ 35 | OFFSET_EQ_NAT
+
+ 36 align_opt: %empty
+ 37 | ALIGN_EQ_NAT
+
+ 38 instr: plain_instr
+ 39 | block_instr
+ 40 | expr
+
+ 41 plain_instr: UNREACHABLE
+ 42 | NOP
+ 43 | DROP
+ 44 | SELECT
+ 45 | BR var
+ 46 | BR_IF var
+ 47 | BR_TABLE var_list var
+ 48 | RETURN
+ 49 | CALL var
+ 50 | CALL_INDIRECT var
+ 51 | GET_LOCAL var
+ 52 | SET_LOCAL var
+ 53 | TEE_LOCAL var
+ 54 | GET_GLOBAL var
+ 55 | SET_GLOBAL var
+ 56 | LOAD offset_opt align_opt
+ 57 | STORE offset_opt align_opt
+ 58 | CONST literal
+ 59 | UNARY
+ 60 | BINARY
+ 61 | COMPARE
+ 62 | CONVERT
+ 63 | CURRENT_MEMORY
+ 64 | GROW_MEMORY
+
+ 65 block_instr: BLOCK labeling_opt block END labeling_opt
+ 66 | LOOP labeling_opt block END labeling_opt
+ 67 | IF labeling_opt block END labeling_opt
+ 68 | IF labeling_opt block ELSE labeling_opt instr_list END labeling_opt
+
+ 69 block: value_type_list instr_list
+
+ 70 expr: "(" expr1 ")"
+
+ 71 expr1: plain_instr expr_list
+ 72 | BLOCK labeling_opt block
+ 73 | LOOP labeling_opt block
+ 74 | IF labeling_opt value_type_list if_
+
+ 75 if_: "(" THEN instr_list ")" "(" ELSE instr_list ")"
+ 76 | "(" THEN instr_list ")"
+ 77 | expr "(" THEN instr_list ")" "(" ELSE instr_list ")"
+ 78 | expr "(" THEN instr_list ")"
+ 79 | expr expr expr
+ 80 | expr expr
+
+ 81 instr_list: %empty
+ 82 | instr instr_list
+
+ 83 expr_list: %empty
+ 84 | expr expr_list
+
+ 85 const_expr: instr_list
+
+ 86 func_fields: func_body
+ 87 | "(" RESULT value_type_list ")" func_body
+ 88 | "(" PARAM value_type_list ")" func_fields
+ 89 | "(" PARAM bind_var VALUE_TYPE ")" func_fields
+
+ 90 func_body: instr_list
+ 91 | "(" LOCAL value_type_list ")" func_body
+ 92 | "(" LOCAL bind_var VALUE_TYPE ")" func_body
+
+ 93 func_info: func_fields
+
+ 94 func: "(" FUNC bind_var_opt inline_export type_use func_info ")"
+ 95 | "(" FUNC bind_var_opt type_use func_info ")"
+ 96 | "(" FUNC bind_var_opt inline_export func_info ")"
+ 97 | "(" FUNC bind_var_opt func_info ")"
+
+ 98 offset: "(" OFFSET const_expr ")"
+ 99 | expr
+
+ 100 elem: "(" ELEM var offset var_list ")"
+ 101 | "(" ELEM offset var_list ")"
+
+ 102 table: "(" TABLE bind_var_opt inline_export_opt table_sig ")"
+ 103 | "(" TABLE bind_var_opt inline_export_opt elem_type "(" ELEM var_list ")" ")"
+
+ 104 data: "(" DATA var offset text_list ")"
+ 105 | "(" DATA offset text_list ")"
+
+ 106 memory: "(" MEMORY bind_var_opt inline_export_opt memory_sig ")"
+ 107 | "(" MEMORY bind_var_opt inline_export "(" DATA text_list ")" ")"
+ 108 | "(" MEMORY bind_var_opt "(" DATA text_list ")" ")"
+
+ 109 global: "(" GLOBAL bind_var_opt inline_export global_type const_expr ")"
+ 110 | "(" GLOBAL bind_var_opt global_type const_expr ")"
+
+ 111 import_kind: "(" FUNC bind_var_opt type_use ")"
+ 112 | "(" FUNC bind_var_opt func_sig ")"
+ 113 | "(" TABLE bind_var_opt table_sig ")"
+ 114 | "(" MEMORY bind_var_opt memory_sig ")"
+ 115 | "(" GLOBAL bind_var_opt global_type ")"
+
+ 116 import: "(" IMPORT quoted_text quoted_text import_kind ")"
+ 117 | "(" FUNC bind_var_opt inline_import type_use ")"
+ 118 | "(" FUNC bind_var_opt inline_import func_sig ")"
+ 119 | "(" TABLE bind_var_opt inline_import table_sig ")"
+ 120 | "(" MEMORY bind_var_opt inline_import memory_sig ")"
+ 121 | "(" GLOBAL bind_var_opt inline_import global_type ")"
+
+ 122 inline_import: "(" IMPORT quoted_text quoted_text ")"
+
+ 123 export_kind: "(" FUNC var ")"
+ 124 | "(" TABLE var ")"
+ 125 | "(" MEMORY var ")"
+ 126 | "(" GLOBAL var ")"
+
+ 127 export: "(" EXPORT quoted_text export_kind ")"
+
+ 128 inline_export_opt: %empty
+ 129 | inline_export
+
+ 130 inline_export: "(" EXPORT quoted_text ")"
+
+ 131 type_def: "(" TYPE func_type ")"
+ 132 | "(" TYPE bind_var func_type ")"
+
+ 133 start: "(" START var ")"
+
+ 134 module_fields: %empty
+ 135 | module_fields type_def
+ 136 | module_fields global
+ 137 | module_fields table
+ 138 | module_fields memory
+ 139 | module_fields func
+ 140 | module_fields elem
+ 141 | module_fields data
+ 142 | module_fields start
+ 143 | module_fields import
+ 144 | module_fields export
+
+ 145 raw_module: "(" MODULE bind_var_opt module_fields ")"
+ 146 | "(" MODULE bind_var_opt non_empty_text_list ")"
+
+ 147 module: raw_module
+
+ 148 script_var_opt: %empty
+ 149 | VAR
+
+ 150 action: "(" INVOKE script_var_opt quoted_text const_list ")"
+ 151 | "(" GET script_var_opt quoted_text ")"
+
+ 152 assertion: "(" ASSERT_MALFORMED raw_module quoted_text ")"
+ 153 | "(" ASSERT_INVALID raw_module quoted_text ")"
+ 154 | "(" ASSERT_UNLINKABLE raw_module quoted_text ")"
+ 155 | "(" ASSERT_TRAP raw_module quoted_text ")"
+ 156 | "(" ASSERT_RETURN action const_list ")"
+ 157 | "(" ASSERT_RETURN_NAN action ")"
+ 158 | "(" ASSERT_TRAP action quoted_text ")"
+ 159 | "(" ASSERT_EXHAUSTION action quoted_text ")"
+
+ 160 cmd: action
+ 161 | assertion
+ 162 | module
+ 163 | "(" REGISTER quoted_text script_var_opt ")"
+
+ 164 cmd_list: %empty
+ 165 | cmd_list cmd
+
+ 166 const: "(" CONST literal ")"
+
+ 167 const_list: %empty
+ 168 | const_list const
+
+ 169 script: cmd_list
+
+ 170 script_start: script
+
+
+Terminals, with rules where they appear
+
+"EOF" (0) 0
+error (256)
+"(" (258) 10 11 13 14 15 20 70 75 76 77 78 87 88 89 91 92 94 95 96
+ 97 98 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
+ 115 116 117 118 119 120 121 122 123 124 125 126 127 130 131 132
+ 133 145 146 150 151 152 153 154 155 156 157 158 159 163 166
+")" (259) 10 11 13 14 15 20 70 75 76 77 78 87 88 89 91 92 94 95 96
+ 97 98 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
+ 115 116 117 118 119 120 121 122 123 124 125 126 127 130 131 132
+ 133 145 146 150 151 152 153 154 155 156 157 158 159 163 166
+NAT (260) 21 22
+INT (261) 23
+FLOAT (262) 24
+TEXT (263) 1 2 5
+VAR (264) 26 31 149
+VALUE_TYPE (265) 7 9 10 89 92
+ANYFUNC (266) 8
+MUT (267) 10
+NOP (268) 42
+DROP (269) 43
+BLOCK (270) 65 72
+END (271) 65 66 67 68
+IF (272) 67 68 74
+THEN (273) 75 76 77 78
+ELSE (274) 68 75 77
+LOOP (275) 66 73
+BR (276) 45
+BR_IF (277) 46
+BR_TABLE (278) 47
+CALL (279) 49
+CALL_IMPORT (280)
+CALL_INDIRECT (281) 50
+RETURN (282) 48
+GET_LOCAL (283) 51
+SET_LOCAL (284) 52
+TEE_LOCAL (285) 53
+GET_GLOBAL (286) 54
+SET_GLOBAL (287) 55
+LOAD (288) 56
+STORE (289) 57
+OFFSET_EQ_NAT (290) 35
+ALIGN_EQ_NAT (291) 37
+CONST (292) 58 166
+UNARY (293) 59
+BINARY (294) 60
+COMPARE (295) 61
+CONVERT (296) 62
+SELECT (297) 44
+UNREACHABLE (298) 41
+CURRENT_MEMORY (299) 63
+GROW_MEMORY (300) 64
+FUNC (301) 11 94 95 96 97 111 112 117 118 123
+START (302) 133
+TYPE (303) 20 131 132
+PARAM (304) 13 14 88 89
+RESULT (305) 14 15 87
+LOCAL (306) 91 92
+GLOBAL (307) 109 110 115 121 126
+MODULE (308) 145 146
+TABLE (309) 102 103 113 119 124
+ELEM (310) 100 101 103
+MEMORY (311) 106 107 108 114 120 125
+DATA (312) 104 105 107 108
+OFFSET (313) 98
+IMPORT (314) 116 122
+EXPORT (315) 127 130
+REGISTER (316) 163
+INVOKE (317) 150
+GET (318) 151
+ASSERT_MALFORMED (319) 152
+ASSERT_INVALID (320) 153
+ASSERT_UNLINKABLE (321) 154
+ASSERT_RETURN (322) 156
+ASSERT_RETURN_NAN (323) 157
+ASSERT_TRAP (324) 155 158
+ASSERT_EXHAUSTION (325) 159
+INPUT (326)
+OUTPUT (327)
+LOW (328)
+
+
+Nonterminals, with rules where they appear
+
+$accept (74)
+ on left: 0
+non_empty_text_list (75)
+ on left: 1 2, on right: 2 4 146
+text_list (76)
+ on left: 3 4, on right: 104 105 107 108
+quoted_text (77)
+ on left: 5, on right: 116 122 127 130 150 151 152 153 154 155 158
+ 159 163
+value_type_list (78)
+ on left: 6 7, on right: 7 13 14 15 69 74 87 88 91
+elem_type (79)
+ on left: 8, on right: 16 103
+global_type (80)
+ on left: 9 10, on right: 109 110 115 121
+func_type (81)
+ on left: 11, on right: 131 132
+func_sig (82)
+ on left: 12 13 14 15, on right: 11 112 118
+table_sig (83)
+ on left: 16, on right: 102 113 119
+memory_sig (84)
+ on left: 17, on right: 106 114 120
+limits (85)
+ on left: 18 19, on right: 16 17
+type_use (86)
+ on left: 20, on right: 94 95 111 117
+nat (87)
+ on left: 21, on right: 18 19 25
+literal (88)
+ on left: 22 23 24, on right: 58 166
+var (89)
+ on left: 25 26, on right: 20 28 45 46 47 49 50 51 52 53 54 55 100
+ 104 123 124 125 126 133
+var_list (90)
+ on left: 27 28, on right: 28 47 100 101 103
+bind_var_opt (91)
+ on left: 29 30, on right: 94 95 96 97 102 103 106 107 108 109 110
+ 111 112 113 114 115 117 118 119 120 121 145 146
+bind_var (92)
+ on left: 31, on right: 30 33 89 92 132
+labeling_opt (93)
+ on left: 32 33, on right: 65 66 67 68 72 73 74
+offset_opt (94)
+ on left: 34 35, on right: 56 57
+align_opt (95)
+ on left: 36 37, on right: 56 57
+instr (96)
+ on left: 38 39 40, on right: 82
+plain_instr (97)
+ on left: 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
+ 59 60 61 62 63 64, on right: 38 71
+block_instr (98)
+ on left: 65 66 67 68, on right: 39
+block (99)
+ on left: 69, on right: 65 66 67 68 72 73
+expr (100)
+ on left: 70, on right: 40 77 78 79 80 84 99
+expr1 (101)
+ on left: 71 72 73 74, on right: 70
+if_ (102)
+ on left: 75 76 77 78 79 80, on right: 74
+instr_list (103)
+ on left: 81 82, on right: 68 69 75 76 77 78 82 85 90
+expr_list (104)
+ on left: 83 84, on right: 71 84
+const_expr (105)
+ on left: 85, on right: 98 109 110
+func_fields (106)
+ on left: 86 87 88 89, on right: 88 89 93
+func_body (107)
+ on left: 90 91 92, on right: 86 87 91 92
+func_info (108)
+ on left: 93, on right: 94 95 96 97
+func (109)
+ on left: 94 95 96 97, on right: 139
+offset (110)
+ on left: 98 99, on right: 100 101 104 105
+elem (111)
+ on left: 100 101, on right: 140
+table (112)
+ on left: 102 103, on right: 137
+data (113)
+ on left: 104 105, on right: 141
+memory (114)
+ on left: 106 107 108, on right: 138
+global (115)
+ on left: 109 110, on right: 136
+import_kind (116)
+ on left: 111 112 113 114 115, on right: 116
+import (117)
+ on left: 116 117 118 119 120 121, on right: 143
+inline_import (118)
+ on left: 122, on right: 117 118 119 120 121
+export_kind (119)
+ on left: 123 124 125 126, on right: 127
+export (120)
+ on left: 127, on right: 144
+inline_export_opt (121)
+ on left: 128 129, on right: 102 103 106
+inline_export (122)
+ on left: 130, on right: 94 96 107 109 129
+type_def (123)
+ on left: 131 132, on right: 135
+start (124)
+ on left: 133, on right: 142
+module_fields (125)
+ on left: 134 135 136 137 138 139 140 141 142 143 144, on right:
+ 135 136 137 138 139 140 141 142 143 144 145
+raw_module (126)
+ on left: 145 146, on right: 147 152 153 154 155
+module (127)
+ on left: 147, on right: 162
+script_var_opt (128)
+ on left: 148 149, on right: 150 151 163
+action (129)
+ on left: 150 151, on right: 156 157 158 159 160
+assertion (130)
+ on left: 152 153 154 155 156 157 158 159, on right: 161
+cmd (131)
+ on left: 160 161 162 163, on right: 165
+cmd_list (132)
+ on left: 164 165, on right: 165 169
+const (133)
+ on left: 166, on right: 168
+const_list (134)
+ on left: 167 168, on right: 150 156 168
+script (135)
+ on left: 169, on right: 170
+script_start (136)
+ on left: 170, on right: 0
+
+
+State 0
+
+ 0 $accept: . script_start "EOF"
+
+ $default reduce using rule 164 (cmd_list)
+
+ cmd_list go to state 1
+ script go to state 2
+ script_start go to state 3
+
+
+State 1
+
+ 165 cmd_list: cmd_list . cmd
+ 169 script: cmd_list .
+
+ "(" shift, and go to state 4
+
+ $default reduce using rule 169 (script)
+
+ raw_module go to state 5
+ module go to state 6
+ action go to state 7
+ assertion go to state 8
+ cmd go to state 9
+
+
+State 2
+
+ 170 script_start: script .
+
+ $default reduce using rule 170 (script_start)
+
+
+State 3
+
+ 0 $accept: script_start . "EOF"
+
+ "EOF" shift, and go to state 10
+
+
+State 4
+
+ 145 raw_module: "(" . MODULE bind_var_opt module_fields ")"
+ 146 | "(" . MODULE bind_var_opt non_empty_text_list ")"
+ 150 action: "(" . INVOKE script_var_opt quoted_text const_list ")"
+ 151 | "(" . GET script_var_opt quoted_text ")"
+ 152 assertion: "(" . ASSERT_MALFORMED raw_module quoted_text ")"
+ 153 | "(" . ASSERT_INVALID raw_module quoted_text ")"
+ 154 | "(" . ASSERT_UNLINKABLE raw_module quoted_text ")"
+ 155 | "(" . ASSERT_TRAP raw_module quoted_text ")"
+ 156 | "(" . ASSERT_RETURN action const_list ")"
+ 157 | "(" . ASSERT_RETURN_NAN action ")"
+ 158 | "(" . ASSERT_TRAP action quoted_text ")"
+ 159 | "(" . ASSERT_EXHAUSTION action quoted_text ")"
+ 163 cmd: "(" . REGISTER quoted_text script_var_opt ")"
+
+ MODULE shift, and go to state 11
+ REGISTER shift, and go to state 12
+ INVOKE shift, and go to state 13
+ GET shift, and go to state 14
+ ASSERT_MALFORMED shift, and go to state 15
+ ASSERT_INVALID shift, and go to state 16
+ ASSERT_UNLINKABLE shift, and go to state 17
+ ASSERT_RETURN shift, and go to state 18
+ ASSERT_RETURN_NAN shift, and go to state 19
+ ASSERT_TRAP shift, and go to state 20
+ ASSERT_EXHAUSTION shift, and go to state 21
+
+
+State 5
+
+ 147 module: raw_module .
+
+ $default reduce using rule 147 (module)
+
+
+State 6
+
+ 162 cmd: module .
+
+ $default reduce using rule 162 (cmd)
+
+
+State 7
+
+ 160 cmd: action .
+
+ $default reduce using rule 160 (cmd)
+
+
+State 8
+
+ 161 cmd: assertion .
+
+ $default reduce using rule 161 (cmd)
+
+
+State 9
+
+ 165 cmd_list: cmd_list cmd .
+
+ $default reduce using rule 165 (cmd_list)
+
+
+State 10
+
+ 0 $accept: script_start "EOF" .
+
+ $default accept
+
+
+State 11
+
+ 145 raw_module: "(" MODULE . bind_var_opt module_fields ")"
+ 146 | "(" MODULE . bind_var_opt non_empty_text_list ")"
+
+ VAR shift, and go to state 22
+
+ $default reduce using rule 29 (bind_var_opt)
+
+ bind_var_opt go to state 23
+ bind_var go to state 24
+
+
+State 12
+
+ 163 cmd: "(" REGISTER . quoted_text script_var_opt ")"
+
+ TEXT shift, and go to state 25
+
+ quoted_text go to state 26
+
+
+State 13
+
+ 150 action: "(" INVOKE . script_var_opt quoted_text const_list ")"
+
+ VAR shift, and go to state 27
+
+ $default reduce using rule 148 (script_var_opt)
+
+ script_var_opt go to state 28
+
+
+State 14
+
+ 151 action: "(" GET . script_var_opt quoted_text ")"
+
+ VAR shift, and go to state 27
+
+ $default reduce using rule 148 (script_var_opt)
+
+ script_var_opt go to state 29
+
+
+State 15
+
+ 152 assertion: "(" ASSERT_MALFORMED . raw_module quoted_text ")"
+
+ "(" shift, and go to state 30
+
+ raw_module go to state 31
+
+
+State 16
+
+ 153 assertion: "(" ASSERT_INVALID . raw_module quoted_text ")"
+
+ "(" shift, and go to state 30
+
+ raw_module go to state 32
+
+
+State 17
+
+ 154 assertion: "(" ASSERT_UNLINKABLE . raw_module quoted_text ")"
+
+ "(" shift, and go to state 30
+
+ raw_module go to state 33
+
+
+State 18
+
+ 156 assertion: "(" ASSERT_RETURN . action const_list ")"
+
+ "(" shift, and go to state 34
+
+ action go to state 35
+
+
+State 19
+
+ 157 assertion: "(" ASSERT_RETURN_NAN . action ")"
+
+ "(" shift, and go to state 34
+
+ action go to state 36
+
+
+State 20
+
+ 155 assertion: "(" ASSERT_TRAP . raw_module quoted_text ")"
+ 158 | "(" ASSERT_TRAP . action quoted_text ")"
+
+ "(" shift, and go to state 37
+
+ raw_module go to state 38
+ action go to state 39
+
+
+State 21
+
+ 159 assertion: "(" ASSERT_EXHAUSTION . action quoted_text ")"
+
+ "(" shift, and go to state 34
+
+ action go to state 40
+
+
+State 22
+
+ 31 bind_var: VAR .
+
+ $default reduce using rule 31 (bind_var)
+
+
+State 23
+
+ 145 raw_module: "(" MODULE bind_var_opt . module_fields ")"
+ 146 | "(" MODULE bind_var_opt . non_empty_text_list ")"
+
+ TEXT shift, and go to state 41
+
+ $default reduce using rule 134 (module_fields)
+
+ non_empty_text_list go to state 42
+ module_fields go to state 43
+
+
+State 24
+
+ 30 bind_var_opt: bind_var .
+
+ $default reduce using rule 30 (bind_var_opt)
+
+
+State 25
+
+ 5 quoted_text: TEXT .
+
+ $default reduce using rule 5 (quoted_text)
+
+
+State 26
+
+ 163 cmd: "(" REGISTER quoted_text . script_var_opt ")"
+
+ VAR shift, and go to state 27
+
+ $default reduce using rule 148 (script_var_opt)
+
+ script_var_opt go to state 44
+
+
+State 27
+
+ 149 script_var_opt: VAR .
+
+ $default reduce using rule 149 (script_var_opt)
+
+
+State 28
+
+ 150 action: "(" INVOKE script_var_opt . quoted_text const_list ")"
+
+ TEXT shift, and go to state 25
+
+ quoted_text go to state 45
+
+
+State 29
+
+ 151 action: "(" GET script_var_opt . quoted_text ")"
+
+ TEXT shift, and go to state 25
+
+ quoted_text go to state 46
+
+
+State 30
+
+ 145 raw_module: "(" . MODULE bind_var_opt module_fields ")"
+ 146 | "(" . MODULE bind_var_opt non_empty_text_list ")"
+
+ MODULE shift, and go to state 11
+
+
+State 31
+
+ 152 assertion: "(" ASSERT_MALFORMED raw_module . quoted_text ")"
+
+ TEXT shift, and go to state 25
+
+ quoted_text go to state 47
+
+
+State 32
+
+ 153 assertion: "(" ASSERT_INVALID raw_module . quoted_text ")"
+
+ TEXT shift, and go to state 25
+
+ quoted_text go to state 48
+
+
+State 33
+
+ 154 assertion: "(" ASSERT_UNLINKABLE raw_module . quoted_text ")"
+
+ TEXT shift, and go to state 25
+
+ quoted_text go to state 49
+
+
+State 34
+
+ 150 action: "(" . INVOKE script_var_opt quoted_text const_list ")"
+ 151 | "(" . GET script_var_opt quoted_text ")"
+
+ INVOKE shift, and go to state 13
+ GET shift, and go to state 14
+
+
+State 35
+
+ 156 assertion: "(" ASSERT_RETURN action . const_list ")"
+
+ $default reduce using rule 167 (const_list)
+
+ const_list go to state 50
+
+
+State 36
+
+ 157 assertion: "(" ASSERT_RETURN_NAN action . ")"
+
+ ")" shift, and go to state 51
+
+
+State 37
+
+ 145 raw_module: "(" . MODULE bind_var_opt module_fields ")"
+ 146 | "(" . MODULE bind_var_opt non_empty_text_list ")"
+ 150 action: "(" . INVOKE script_var_opt quoted_text const_list ")"
+ 151 | "(" . GET script_var_opt quoted_text ")"
+
+ MODULE shift, and go to state 11
+ INVOKE shift, and go to state 13
+ GET shift, and go to state 14
+
+
+State 38
+
+ 155 assertion: "(" ASSERT_TRAP raw_module . quoted_text ")"
+
+ TEXT shift, and go to state 25
+
+ quoted_text go to state 52
+
+
+State 39
+
+ 158 assertion: "(" ASSERT_TRAP action . quoted_text ")"
+
+ TEXT shift, and go to state 25
+
+ quoted_text go to state 53
+
+
+State 40
+
+ 159 assertion: "(" ASSERT_EXHAUSTION action . quoted_text ")"
+
+ TEXT shift, and go to state 25
+
+ quoted_text go to state 54
+
+
+State 41
+
+ 1 non_empty_text_list: TEXT .
+
+ $default reduce using rule 1 (non_empty_text_list)
+
+
+State 42
+
+ 2 non_empty_text_list: non_empty_text_list . TEXT
+ 146 raw_module: "(" MODULE bind_var_opt non_empty_text_list . ")"
+
+ ")" shift, and go to state 55
+ TEXT shift, and go to state 56
+
+
+State 43
+
+ 135 module_fields: module_fields . type_def
+ 136 | module_fields . global
+ 137 | module_fields . table
+ 138 | module_fields . memory
+ 139 | module_fields . func
+ 140 | module_fields . elem
+ 141 | module_fields . data
+ 142 | module_fields . start
+ 143 | module_fields . import
+ 144 | module_fields . export
+ 145 raw_module: "(" MODULE bind_var_opt module_fields . ")"
+
+ "(" shift, and go to state 57
+ ")" shift, and go to state 58
+
+ func go to state 59
+ elem go to state 60
+ table go to state 61
+ data go to state 62
+ memory go to state 63
+ global go to state 64
+ import go to state 65
+ export go to state 66
+ type_def go to state 67
+ start go to state 68
+
+
+State 44
+
+ 163 cmd: "(" REGISTER quoted_text script_var_opt . ")"
+
+ ")" shift, and go to state 69
+
+
+State 45
+
+ 150 action: "(" INVOKE script_var_opt quoted_text . const_list ")"
+
+ $default reduce using rule 167 (const_list)
+
+ const_list go to state 70
+
+
+State 46
+
+ 151 action: "(" GET script_var_opt quoted_text . ")"
+
+ ")" shift, and go to state 71
+
+
+State 47
+
+ 152 assertion: "(" ASSERT_MALFORMED raw_module quoted_text . ")"
+
+ ")" shift, and go to state 72
+
+
+State 48
+
+ 153 assertion: "(" ASSERT_INVALID raw_module quoted_text . ")"
+
+ ")" shift, and go to state 73
+
+
+State 49
+
+ 154 assertion: "(" ASSERT_UNLINKABLE raw_module quoted_text . ")"
+
+ ")" shift, and go to state 74
+
+
+State 50
+
+ 156 assertion: "(" ASSERT_RETURN action const_list . ")"
+ 168 const_list: const_list . const
+
+ "(" shift, and go to state 75
+ ")" shift, and go to state 76
+
+ const go to state 77
+
+
+State 51
+
+ 157 assertion: "(" ASSERT_RETURN_NAN action ")" .
+
+ $default reduce using rule 157 (assertion)
+
+
+State 52
+
+ 155 assertion: "(" ASSERT_TRAP raw_module quoted_text . ")"
+
+ ")" shift, and go to state 78
+
+
+State 53
+
+ 158 assertion: "(" ASSERT_TRAP action quoted_text . ")"
+
+ ")" shift, and go to state 79
+
+
+State 54
+
+ 159 assertion: "(" ASSERT_EXHAUSTION action quoted_text . ")"
+
+ ")" shift, and go to state 80
+
+
+State 55
+
+ 146 raw_module: "(" MODULE bind_var_opt non_empty_text_list ")" .
+
+ $default reduce using rule 146 (raw_module)
+
+
+State 56
+
+ 2 non_empty_text_list: non_empty_text_list TEXT .
+
+ $default reduce using rule 2 (non_empty_text_list)
+
+
+State 57
+
+ 94 func: "(" . FUNC bind_var_opt inline_export type_use func_info ")"
+ 95 | "(" . FUNC bind_var_opt type_use func_info ")"
+ 96 | "(" . FUNC bind_var_opt inline_export func_info ")"
+ 97 | "(" . FUNC bind_var_opt func_info ")"
+ 100 elem: "(" . ELEM var offset var_list ")"
+ 101 | "(" . ELEM offset var_list ")"
+ 102 table: "(" . TABLE bind_var_opt inline_export_opt table_sig ")"
+ 103 | "(" . TABLE bind_var_opt inline_export_opt elem_type "(" ELEM var_list ")" ")"
+ 104 data: "(" . DATA var offset text_list ")"
+ 105 | "(" . DATA offset text_list ")"
+ 106 memory: "(" . MEMORY bind_var_opt inline_export_opt memory_sig ")"
+ 107 | "(" . MEMORY bind_var_opt inline_export "(" DATA text_list ")" ")"
+ 108 | "(" . MEMORY bind_var_opt "(" DATA text_list ")" ")"
+ 109 global: "(" . GLOBAL bind_var_opt inline_export global_type const_expr ")"
+ 110 | "(" . GLOBAL bind_var_opt global_type const_expr ")"
+ 116 import: "(" . IMPORT quoted_text quoted_text import_kind ")"
+ 117 | "(" . FUNC bind_var_opt inline_import type_use ")"
+ 118 | "(" . FUNC bind_var_opt inline_import func_sig ")"
+ 119 | "(" . TABLE bind_var_opt inline_import table_sig ")"
+ 120 | "(" . MEMORY bind_var_opt inline_import memory_sig ")"
+ 121 | "(" . GLOBAL bind_var_opt inline_import global_type ")"
+ 127 export: "(" . EXPORT quoted_text export_kind ")"
+ 131 type_def: "(" . TYPE func_type ")"
+ 132 | "(" . TYPE bind_var func_type ")"
+ 133 start: "(" . START var ")"
+
+ FUNC shift, and go to state 81
+ START shift, and go to state 82
+ TYPE shift, and go to state 83
+ GLOBAL shift, and go to state 84
+ TABLE shift, and go to state 85
+ ELEM shift, and go to state 86
+ MEMORY shift, and go to state 87
+ DATA shift, and go to state 88
+ IMPORT shift, and go to state 89
+ EXPORT shift, and go to state 90
+
+
+State 58
+
+ 145 raw_module: "(" MODULE bind_var_opt module_fields ")" .
+
+ $default reduce using rule 145 (raw_module)
+
+
+State 59
+
+ 139 module_fields: module_fields func .
+
+ $default reduce using rule 139 (module_fields)
+
+
+State 60
+
+ 140 module_fields: module_fields elem .
+
+ $default reduce using rule 140 (module_fields)
+
+
+State 61
+
+ 137 module_fields: module_fields table .
+
+ $default reduce using rule 137 (module_fields)
+
+
+State 62
+
+ 141 module_fields: module_fields data .
+
+ $default reduce using rule 141 (module_fields)
+
+
+State 63
+
+ 138 module_fields: module_fields memory .
+
+ $default reduce using rule 138 (module_fields)
+
+
+State 64
+
+ 136 module_fields: module_fields global .
+
+ $default reduce using rule 136 (module_fields)
+
+
+State 65
+
+ 143 module_fields: module_fields import .
+
+ $default reduce using rule 143 (module_fields)
+
+
+State 66
+
+ 144 module_fields: module_fields export .
+
+ $default reduce using rule 144 (module_fields)
+
+
+State 67
+
+ 135 module_fields: module_fields type_def .
+
+ $default reduce using rule 135 (module_fields)
+
+
+State 68
+
+ 142 module_fields: module_fields start .
+
+ $default reduce using rule 142 (module_fields)
+
+
+State 69
+
+ 163 cmd: "(" REGISTER quoted_text script_var_opt ")" .
+
+ $default reduce using rule 163 (cmd)
+
+
+State 70
+
+ 150 action: "(" INVOKE script_var_opt quoted_text const_list . ")"
+ 168 const_list: const_list . const
+
+ "(" shift, and go to state 75
+ ")" shift, and go to state 91
+
+ const go to state 77
+
+
+State 71
+
+ 151 action: "(" GET script_var_opt quoted_text ")" .
+
+ $default reduce using rule 151 (action)
+
+
+State 72
+
+ 152 assertion: "(" ASSERT_MALFORMED raw_module quoted_text ")" .
+
+ $default reduce using rule 152 (assertion)
+
+
+State 73
+
+ 153 assertion: "(" ASSERT_INVALID raw_module quoted_text ")" .
+
+ $default reduce using rule 153 (assertion)
+
+
+State 74
+
+ 154 assertion: "(" ASSERT_UNLINKABLE raw_module quoted_text ")" .
+
+ $default reduce using rule 154 (assertion)
+
+
+State 75
+
+ 166 const: "(" . CONST literal ")"
+
+ CONST shift, and go to state 92
+
+
+State 76
+
+ 156 assertion: "(" ASSERT_RETURN action const_list ")" .
+
+ $default reduce using rule 156 (assertion)
+
+
+State 77
+
+ 168 const_list: const_list const .
+
+ $default reduce using rule 168 (const_list)
+
+
+State 78
+
+ 155 assertion: "(" ASSERT_TRAP raw_module quoted_text ")" .
+
+ $default reduce using rule 155 (assertion)
+
+
+State 79
+
+ 158 assertion: "(" ASSERT_TRAP action quoted_text ")" .
+
+ $default reduce using rule 158 (assertion)
+
+
+State 80
+
+ 159 assertion: "(" ASSERT_EXHAUSTION action quoted_text ")" .
+
+ $default reduce using rule 159 (assertion)
+
+
+State 81
+
+ 94 func: "(" FUNC . bind_var_opt inline_export type_use func_info ")"
+ 95 | "(" FUNC . bind_var_opt type_use func_info ")"
+ 96 | "(" FUNC . bind_var_opt inline_export func_info ")"
+ 97 | "(" FUNC . bind_var_opt func_info ")"
+ 117 import: "(" FUNC . bind_var_opt inline_import type_use ")"
+ 118 | "(" FUNC . bind_var_opt inline_import func_sig ")"
+
+ VAR shift, and go to state 22
+
+ $default reduce using rule 29 (bind_var_opt)
+
+ bind_var_opt go to state 93
+ bind_var go to state 24
+
+
+State 82
+
+ 133 start: "(" START . var ")"
+
+ NAT shift, and go to state 94
+ VAR shift, and go to state 95
+
+ nat go to state 96
+ var go to state 97
+
+
+State 83
+
+ 131 type_def: "(" TYPE . func_type ")"
+ 132 | "(" TYPE . bind_var func_type ")"
+
+ "(" shift, and go to state 98
+ VAR shift, and go to state 22
+
+ func_type go to state 99
+ bind_var go to state 100
+
+
+State 84
+
+ 109 global: "(" GLOBAL . bind_var_opt inline_export global_type const_expr ")"
+ 110 | "(" GLOBAL . bind_var_opt global_type const_expr ")"
+ 121 import: "(" GLOBAL . bind_var_opt inline_import global_type ")"
+
+ VAR shift, and go to state 22
+
+ $default reduce using rule 29 (bind_var_opt)
+
+ bind_var_opt go to state 101
+ bind_var go to state 24
+
+
+State 85
+
+ 102 table: "(" TABLE . bind_var_opt inline_export_opt table_sig ")"
+ 103 | "(" TABLE . bind_var_opt inline_export_opt elem_type "(" ELEM var_list ")" ")"
+ 119 import: "(" TABLE . bind_var_opt inline_import table_sig ")"
+
+ VAR shift, and go to state 22
+
+ $default reduce using rule 29 (bind_var_opt)
+
+ bind_var_opt go to state 102
+ bind_var go to state 24
+
+
+State 86
+
+ 100 elem: "(" ELEM . var offset var_list ")"
+ 101 | "(" ELEM . offset var_list ")"
+
+ "(" shift, and go to state 103
+ NAT shift, and go to state 94
+ VAR shift, and go to state 95
+
+ nat go to state 96
+ var go to state 104
+ expr go to state 105
+ offset go to state 106
+
+
+State 87
+
+ 106 memory: "(" MEMORY . bind_var_opt inline_export_opt memory_sig ")"
+ 107 | "(" MEMORY . bind_var_opt inline_export "(" DATA text_list ")" ")"
+ 108 | "(" MEMORY . bind_var_opt "(" DATA text_list ")" ")"
+ 120 import: "(" MEMORY . bind_var_opt inline_import memory_sig ")"
+
+ VAR shift, and go to state 22
+
+ $default reduce using rule 29 (bind_var_opt)
+
+ bind_var_opt go to state 107
+ bind_var go to state 24
+
+
+State 88
+
+ 104 data: "(" DATA . var offset text_list ")"
+ 105 | "(" DATA . offset text_list ")"
+
+ "(" shift, and go to state 103
+ NAT shift, and go to state 94
+ VAR shift, and go to state 95
+
+ nat go to state 96
+ var go to state 108
+ expr go to state 105
+ offset go to state 109
+
+
+State 89
+
+ 116 import: "(" IMPORT . quoted_text quoted_text import_kind ")"
+
+ TEXT shift, and go to state 25
+
+ quoted_text go to state 110
+
+
+State 90
+
+ 127 export: "(" EXPORT . quoted_text export_kind ")"
+
+ TEXT shift, and go to state 25
+
+ quoted_text go to state 111
+
+
+State 91
+
+ 150 action: "(" INVOKE script_var_opt quoted_text const_list ")" .
+
+ $default reduce using rule 150 (action)
+
+
+State 92
+
+ 166 const: "(" CONST . literal ")"
+
+ NAT shift, and go to state 112
+ INT shift, and go to state 113
+ FLOAT shift, and go to state 114
+
+ literal go to state 115
+
+
+State 93
+
+ 94 func: "(" FUNC bind_var_opt . inline_export type_use func_info ")"
+ 95 | "(" FUNC bind_var_opt . type_use func_info ")"
+ 96 | "(" FUNC bind_var_opt . inline_export func_info ")"
+ 97 | "(" FUNC bind_var_opt . func_info ")"
+ 117 import: "(" FUNC bind_var_opt . inline_import type_use ")"
+ 118 | "(" FUNC bind_var_opt . inline_import func_sig ")"
+
+ "(" shift, and go to state 116
+ NOP shift, and go to state 117
+ DROP shift, and go to state 118
+ BLOCK shift, and go to state 119
+ IF shift, and go to state 120
+ LOOP shift, and go to state 121
+ BR shift, and go to state 122
+ BR_IF shift, and go to state 123
+ BR_TABLE shift, and go to state 124
+ CALL shift, and go to state 125
+ CALL_INDIRECT shift, and go to state 126
+ RETURN shift, and go to state 127
+ GET_LOCAL shift, and go to state 128
+ SET_LOCAL shift, and go to state 129
+ TEE_LOCAL shift, and go to state 130
+ GET_GLOBAL shift, and go to state 131
+ SET_GLOBAL shift, and go to state 132
+ LOAD shift, and go to state 133
+ STORE shift, and go to state 134
+ CONST shift, and go to state 135
+ UNARY shift, and go to state 136
+ BINARY shift, and go to state 137
+ COMPARE shift, and go to state 138
+ CONVERT shift, and go to state 139
+ SELECT shift, and go to state 140
+ UNREACHABLE shift, and go to state 141
+ CURRENT_MEMORY shift, and go to state 142
+ GROW_MEMORY shift, and go to state 143
+
+ $default reduce using rule 81 (instr_list)
+
+ type_use go to state 144
+ instr go to state 145
+ plain_instr go to state 146
+ block_instr go to state 147
+ expr go to state 148
+ instr_list go to state 149
+ func_fields go to state 150
+ func_body go to state 151
+ func_info go to state 152
+ inline_import go to state 153
+ inline_export go to state 154
+
+
+State 94
+
+ 21 nat: NAT .
+
+ $default reduce using rule 21 (nat)
+
+
+State 95
+
+ 26 var: VAR .
+
+ $default reduce using rule 26 (var)
+
+
+State 96
+
+ 25 var: nat .
+
+ $default reduce using rule 25 (var)
+
+
+State 97
+
+ 133 start: "(" START var . ")"
+
+ ")" shift, and go to state 155
+
+
+State 98
+
+ 11 func_type: "(" . FUNC func_sig ")"
+
+ FUNC shift, and go to state 156
+
+
+State 99
+
+ 131 type_def: "(" TYPE func_type . ")"
+
+ ")" shift, and go to state 157
+
+
+State 100
+
+ 132 type_def: "(" TYPE bind_var . func_type ")"
+
+ "(" shift, and go to state 98
+
+ func_type go to state 158
+
+
+State 101
+
+ 109 global: "(" GLOBAL bind_var_opt . inline_export global_type const_expr ")"
+ 110 | "(" GLOBAL bind_var_opt . global_type const_expr ")"
+ 121 import: "(" GLOBAL bind_var_opt . inline_import global_type ")"
+
+ "(" shift, and go to state 159
+ VALUE_TYPE shift, and go to state 160
+
+ global_type go to state 161
+ inline_import go to state 162
+ inline_export go to state 163
+
+
+State 102
+
+ 102 table: "(" TABLE bind_var_opt . inline_export_opt table_sig ")"
+ 103 | "(" TABLE bind_var_opt . inline_export_opt elem_type "(" ELEM var_list ")" ")"
+ 119 import: "(" TABLE bind_var_opt . inline_import table_sig ")"
+
+ "(" shift, and go to state 164
+
+ $default reduce using rule 128 (inline_export_opt)
+
+ inline_import go to state 165
+ inline_export_opt go to state 166
+ inline_export go to state 167
+
+
+State 103
+
+ 70 expr: "(" . expr1 ")"
+ 98 offset: "(" . OFFSET const_expr ")"
+
+ NOP shift, and go to state 117
+ DROP shift, and go to state 118
+ BLOCK shift, and go to state 168
+ IF shift, and go to state 169
+ LOOP shift, and go to state 170
+ BR shift, and go to state 122
+ BR_IF shift, and go to state 123
+ BR_TABLE shift, and go to state 124
+ CALL shift, and go to state 125
+ CALL_INDIRECT shift, and go to state 126
+ RETURN shift, and go to state 127
+ GET_LOCAL shift, and go to state 128
+ SET_LOCAL shift, and go to state 129
+ TEE_LOCAL shift, and go to state 130
+ GET_GLOBAL shift, and go to state 131
+ SET_GLOBAL shift, and go to state 132
+ LOAD shift, and go to state 133
+ STORE shift, and go to state 134
+ CONST shift, and go to state 135
+ UNARY shift, and go to state 136
+ BINARY shift, and go to state 137
+ COMPARE shift, and go to state 138
+ CONVERT shift, and go to state 139
+ SELECT shift, and go to state 140
+ UNREACHABLE shift, and go to state 141
+ CURRENT_MEMORY shift, and go to state 142
+ GROW_MEMORY shift, and go to state 143
+ OFFSET shift, and go to state 171
+
+ plain_instr go to state 172
+ expr1 go to state 173
+
+
+State 104
+
+ 100 elem: "(" ELEM var . offset var_list ")"
+
+ "(" shift, and go to state 103
+
+ expr go to state 105
+ offset go to state 174
+
+
+State 105
+
+ 99 offset: expr .
+
+ $default reduce using rule 99 (offset)
+
+
+State 106
+
+ 101 elem: "(" ELEM offset . var_list ")"
+
+ $default reduce using rule 27 (var_list)
+
+ var_list go to state 175
+
+
+State 107
+
+ 106 memory: "(" MEMORY bind_var_opt . inline_export_opt memory_sig ")"
+ 107 | "(" MEMORY bind_var_opt . inline_export "(" DATA text_list ")" ")"
+ 108 | "(" MEMORY bind_var_opt . "(" DATA text_list ")" ")"
+ 120 import: "(" MEMORY bind_var_opt . inline_import memory_sig ")"
+
+ "(" shift, and go to state 176
+
+ $default reduce using rule 128 (inline_export_opt)
+
+ inline_import go to state 177
+ inline_export_opt go to state 178
+ inline_export go to state 179
+
+
+State 108
+
+ 104 data: "(" DATA var . offset text_list ")"
+
+ "(" shift, and go to state 103
+
+ expr go to state 105
+ offset go to state 180
+
+
+State 109
+
+ 105 data: "(" DATA offset . text_list ")"
+
+ TEXT shift, and go to state 41
+
+ $default reduce using rule 3 (text_list)
+
+ non_empty_text_list go to state 181
+ text_list go to state 182
+
+
+State 110
+
+ 116 import: "(" IMPORT quoted_text . quoted_text import_kind ")"
+
+ TEXT shift, and go to state 25
+
+ quoted_text go to state 183
+
+
+State 111
+
+ 127 export: "(" EXPORT quoted_text . export_kind ")"
+
+ "(" shift, and go to state 184
+
+ export_kind go to state 185
+
+
+State 112
+
+ 22 literal: NAT .
+
+ $default reduce using rule 22 (literal)
+
+
+State 113
+
+ 23 literal: INT .
+
+ $default reduce using rule 23 (literal)
+
+
+State 114
+
+ 24 literal: FLOAT .
+
+ $default reduce using rule 24 (literal)
+
+
+State 115
+
+ 166 const: "(" CONST literal . ")"
+
+ ")" shift, and go to state 186
+
+
+State 116
+
+ 20 type_use: "(" . TYPE var ")"
+ 70 expr: "(" . expr1 ")"
+ 87 func_fields: "(" . RESULT value_type_list ")" func_body
+ 88 | "(" . PARAM value_type_list ")" func_fields
+ 89 | "(" . PARAM bind_var VALUE_TYPE ")" func_fields
+ 91 func_body: "(" . LOCAL value_type_list ")" func_body
+ 92 | "(" . LOCAL bind_var VALUE_TYPE ")" func_body
+ 122 inline_import: "(" . IMPORT quoted_text quoted_text ")"
+ 130 inline_export: "(" . EXPORT quoted_text ")"
+
+ NOP shift, and go to state 117
+ DROP shift, and go to state 118
+ BLOCK shift, and go to state 168
+ IF shift, and go to state 169
+ LOOP shift, and go to state 170
+ BR shift, and go to state 122
+ BR_IF shift, and go to state 123
+ BR_TABLE shift, and go to state 124
+ CALL shift, and go to state 125
+ CALL_INDIRECT shift, and go to state 126
+ RETURN shift, and go to state 127
+ GET_LOCAL shift, and go to state 128
+ SET_LOCAL shift, and go to state 129
+ TEE_LOCAL shift, and go to state 130
+ GET_GLOBAL shift, and go to state 131
+ SET_GLOBAL shift, and go to state 132
+ LOAD shift, and go to state 133
+ STORE shift, and go to state 134
+ CONST shift, and go to state 135
+ UNARY shift, and go to state 136
+ BINARY shift, and go to state 137
+ COMPARE shift, and go to state 138
+ CONVERT shift, and go to state 139
+ SELECT shift, and go to state 140
+ UNREACHABLE shift, and go to state 141
+ CURRENT_MEMORY shift, and go to state 142
+ GROW_MEMORY shift, and go to state 143
+ TYPE shift, and go to state 187
+ PARAM shift, and go to state 188
+ RESULT shift, and go to state 189
+ LOCAL shift, and go to state 190
+ IMPORT shift, and go to state 191
+ EXPORT shift, and go to state 192
+
+ plain_instr go to state 172
+ expr1 go to state 173
+
+
+State 117
+
+ 42 plain_instr: NOP .
+
+ $default reduce using rule 42 (plain_instr)
+
+
+State 118
+
+ 43 plain_instr: DROP .
+
+ $default reduce using rule 43 (plain_instr)
+
+
+State 119
+
+ 65 block_instr: BLOCK . labeling_opt block END labeling_opt
+
+ VAR shift, and go to state 22
+
+ $default reduce using rule 32 (labeling_opt)
+
+ bind_var go to state 193
+ labeling_opt go to state 194
+
+
+State 120
+
+ 67 block_instr: IF . labeling_opt block END labeling_opt
+ 68 | IF . labeling_opt block ELSE labeling_opt instr_list END labeling_opt
+
+ VAR shift, and go to state 22
+
+ $default reduce using rule 32 (labeling_opt)
+
+ bind_var go to state 193
+ labeling_opt go to state 195
+
+
+State 121
+
+ 66 block_instr: LOOP . labeling_opt block END labeling_opt
+
+ VAR shift, and go to state 22
+
+ $default reduce using rule 32 (labeling_opt)
+
+ bind_var go to state 193
+ labeling_opt go to state 196
+
+
+State 122
+
+ 45 plain_instr: BR . var
+
+ NAT shift, and go to state 94
+ VAR shift, and go to state 95
+
+ nat go to state 96
+ var go to state 197
+
+
+State 123
+
+ 46 plain_instr: BR_IF . var
+
+ NAT shift, and go to state 94
+ VAR shift, and go to state 95
+
+ nat go to state 96
+ var go to state 198
+
+
+State 124
+
+ 47 plain_instr: BR_TABLE . var_list var
+
+ $default reduce using rule 27 (var_list)
+
+ var_list go to state 199
+
+
+State 125
+
+ 49 plain_instr: CALL . var
+
+ NAT shift, and go to state 94
+ VAR shift, and go to state 95
+
+ nat go to state 96
+ var go to state 200
+
+
+State 126
+
+ 50 plain_instr: CALL_INDIRECT . var
+
+ NAT shift, and go to state 94
+ VAR shift, and go to state 95
+
+ nat go to state 96
+ var go to state 201
+
+
+State 127
+
+ 48 plain_instr: RETURN .
+
+ $default reduce using rule 48 (plain_instr)
+
+
+State 128
+
+ 51 plain_instr: GET_LOCAL . var
+
+ NAT shift, and go to state 94
+ VAR shift, and go to state 95
+
+ nat go to state 96
+ var go to state 202
+
+
+State 129
+
+ 52 plain_instr: SET_LOCAL . var
+
+ NAT shift, and go to state 94
+ VAR shift, and go to state 95
+
+ nat go to state 96
+ var go to state 203
+
+
+State 130
+
+ 53 plain_instr: TEE_LOCAL . var
+
+ NAT shift, and go to state 94
+ VAR shift, and go to state 95
+
+ nat go to state 96
+ var go to state 204
+
+
+State 131
+
+ 54 plain_instr: GET_GLOBAL . var
+
+ NAT shift, and go to state 94
+ VAR shift, and go to state 95
+
+ nat go to state 96
+ var go to state 205
+
+
+State 132
+
+ 55 plain_instr: SET_GLOBAL . var
+
+ NAT shift, and go to state 94
+ VAR shift, and go to state 95
+
+ nat go to state 96
+ var go to state 206
+
+
+State 133
+
+ 56 plain_instr: LOAD . offset_opt align_opt
+
+ OFFSET_EQ_NAT shift, and go to state 207
+
+ $default reduce using rule 34 (offset_opt)
+
+ offset_opt go to state 208
+
+
+State 134
+
+ 57 plain_instr: STORE . offset_opt align_opt
+
+ OFFSET_EQ_NAT shift, and go to state 207
+
+ $default reduce using rule 34 (offset_opt)
+
+ offset_opt go to state 209
+
+
+State 135
+
+ 58 plain_instr: CONST . literal
+
+ NAT shift, and go to state 112
+ INT shift, and go to state 113
+ FLOAT shift, and go to state 114
+
+ literal go to state 210
+
+
+State 136
+
+ 59 plain_instr: UNARY .
+
+ $default reduce using rule 59 (plain_instr)
+
+
+State 137
+
+ 60 plain_instr: BINARY .
+
+ $default reduce using rule 60 (plain_instr)
+
+
+State 138
+
+ 61 plain_instr: COMPARE .
+
+ $default reduce using rule 61 (plain_instr)
+
+
+State 139
+
+ 62 plain_instr: CONVERT .
+
+ $default reduce using rule 62 (plain_instr)
+
+
+State 140
+
+ 44 plain_instr: SELECT .
+
+ $default reduce using rule 44 (plain_instr)
+
+
+State 141
+
+ 41 plain_instr: UNREACHABLE .
+
+ $default reduce using rule 41 (plain_instr)
+
+
+State 142
+
+ 63 plain_instr: CURRENT_MEMORY .
+
+ $default reduce using rule 63 (plain_instr)
+
+
+State 143
+
+ 64 plain_instr: GROW_MEMORY .
+
+ $default reduce using rule 64 (plain_instr)
+
+
+State 144
+
+ 95 func: "(" FUNC bind_var_opt type_use . func_info ")"
+
+ "(" shift, and go to state 211
+ NOP shift, and go to state 117
+ DROP shift, and go to state 118
+ BLOCK shift, and go to state 119
+ IF shift, and go to state 120
+ LOOP shift, and go to state 121
+ BR shift, and go to state 122
+ BR_IF shift, and go to state 123
+ BR_TABLE shift, and go to state 124
+ CALL shift, and go to state 125
+ CALL_INDIRECT shift, and go to state 126
+ RETURN shift, and go to state 127
+ GET_LOCAL shift, and go to state 128
+ SET_LOCAL shift, and go to state 129
+ TEE_LOCAL shift, and go to state 130
+ GET_GLOBAL shift, and go to state 131
+ SET_GLOBAL shift, and go to state 132
+ LOAD shift, and go to state 133
+ STORE shift, and go to state 134
+ CONST shift, and go to state 135
+ UNARY shift, and go to state 136
+ BINARY shift, and go to state 137
+ COMPARE shift, and go to state 138
+ CONVERT shift, and go to state 139
+ SELECT shift, and go to state 140
+ UNREACHABLE shift, and go to state 141
+ CURRENT_MEMORY shift, and go to state 142
+ GROW_MEMORY shift, and go to state 143
+
+ $default reduce using rule 81 (instr_list)
+
+ instr go to state 145
+ plain_instr go to state 146
+ block_instr go to state 147
+ expr go to state 148
+ instr_list go to state 149
+ func_fields go to state 150
+ func_body go to state 151
+ func_info go to state 212
+
+
+State 145
+
+ 82 instr_list: instr . instr_list
+
+ "(" shift, and go to state 213
+ NOP shift, and go to state 117
+ DROP shift, and go to state 118
+ BLOCK shift, and go to state 119
+ IF shift, and go to state 120
+ LOOP shift, and go to state 121
+ BR shift, and go to state 122
+ BR_IF shift, and go to state 123
+ BR_TABLE shift, and go to state 124
+ CALL shift, and go to state 125
+ CALL_INDIRECT shift, and go to state 126
+ RETURN shift, and go to state 127
+ GET_LOCAL shift, and go to state 128
+ SET_LOCAL shift, and go to state 129
+ TEE_LOCAL shift, and go to state 130
+ GET_GLOBAL shift, and go to state 131
+ SET_GLOBAL shift, and go to state 132
+ LOAD shift, and go to state 133
+ STORE shift, and go to state 134
+ CONST shift, and go to state 135
+ UNARY shift, and go to state 136
+ BINARY shift, and go to state 137
+ COMPARE shift, and go to state 138
+ CONVERT shift, and go to state 139
+ SELECT shift, and go to state 140
+ UNREACHABLE shift, and go to state 141
+ CURRENT_MEMORY shift, and go to state 142
+ GROW_MEMORY shift, and go to state 143
+
+ $default reduce using rule 81 (instr_list)
+
+ instr go to state 145
+ plain_instr go to state 146
+ block_instr go to state 147
+ expr go to state 148
+ instr_list go to state 214
+
+
+State 146
+
+ 38 instr: plain_instr .
+
+ $default reduce using rule 38 (instr)
+
+
+State 147
+
+ 39 instr: block_instr .
+
+ $default reduce using rule 39 (instr)
+
+
+State 148
+
+ 40 instr: expr .
+
+ $default reduce using rule 40 (instr)
+
+
+State 149
+
+ 90 func_body: instr_list .
+
+ $default reduce using rule 90 (func_body)
+
+
+State 150
+
+ 93 func_info: func_fields .
+
+ $default reduce using rule 93 (func_info)
+
+
+State 151
+
+ 86 func_fields: func_body .
+
+ $default reduce using rule 86 (func_fields)
+
+
+State 152
+
+ 97 func: "(" FUNC bind_var_opt func_info . ")"
+
+ ")" shift, and go to state 215
+
+
+State 153
+
+ 117 import: "(" FUNC bind_var_opt inline_import . type_use ")"
+ 118 | "(" FUNC bind_var_opt inline_import . func_sig ")"
+
+ "(" shift, and go to state 216
+
+ $default reduce using rule 12 (func_sig)
+
+ func_sig go to state 217
+ type_use go to state 218
+
+
+State 154
+
+ 94 func: "(" FUNC bind_var_opt inline_export . type_use func_info ")"
+ 96 | "(" FUNC bind_var_opt inline_export . func_info ")"
+
+ "(" shift, and go to state 219
+ NOP shift, and go to state 117
+ DROP shift, and go to state 118
+ BLOCK shift, and go to state 119
+ IF shift, and go to state 120
+ LOOP shift, and go to state 121
+ BR shift, and go to state 122
+ BR_IF shift, and go to state 123
+ BR_TABLE shift, and go to state 124
+ CALL shift, and go to state 125
+ CALL_INDIRECT shift, and go to state 126
+ RETURN shift, and go to state 127
+ GET_LOCAL shift, and go to state 128
+ SET_LOCAL shift, and go to state 129
+ TEE_LOCAL shift, and go to state 130
+ GET_GLOBAL shift, and go to state 131
+ SET_GLOBAL shift, and go to state 132
+ LOAD shift, and go to state 133
+ STORE shift, and go to state 134
+ CONST shift, and go to state 135
+ UNARY shift, and go to state 136
+ BINARY shift, and go to state 137
+ COMPARE shift, and go to state 138
+ CONVERT shift, and go to state 139
+ SELECT shift, and go to state 140
+ UNREACHABLE shift, and go to state 141
+ CURRENT_MEMORY shift, and go to state 142
+ GROW_MEMORY shift, and go to state 143
+
+ $default reduce using rule 81 (instr_list)
+
+ type_use go to state 220
+ instr go to state 145
+ plain_instr go to state 146
+ block_instr go to state 147
+ expr go to state 148
+ instr_list go to state 149
+ func_fields go to state 150
+ func_body go to state 151
+ func_info go to state 221
+
+
+State 155
+
+ 133 start: "(" START var ")" .
+
+ $default reduce using rule 133 (start)
+
+
+State 156
+
+ 11 func_type: "(" FUNC . func_sig ")"
+
+ "(" shift, and go to state 222
+
+ $default reduce using rule 12 (func_sig)
+
+ func_sig go to state 223
+
+
+State 157
+
+ 131 type_def: "(" TYPE func_type ")" .
+
+ $default reduce using rule 131 (type_def)
+
+
+State 158
+
+ 132 type_def: "(" TYPE bind_var func_type . ")"
+
+ ")" shift, and go to state 224
+
+
+State 159
+
+ 10 global_type: "(" . MUT VALUE_TYPE ")"
+ 122 inline_import: "(" . IMPORT quoted_text quoted_text ")"
+ 130 inline_export: "(" . EXPORT quoted_text ")"
+
+ MUT shift, and go to state 225
+ IMPORT shift, and go to state 191
+ EXPORT shift, and go to state 192
+
+
+State 160
+
+ 9 global_type: VALUE_TYPE .
+
+ $default reduce using rule 9 (global_type)
+
+
+State 161
+
+ 110 global: "(" GLOBAL bind_var_opt global_type . const_expr ")"
+
+ "(" shift, and go to state 213
+ NOP shift, and go to state 117
+ DROP shift, and go to state 118
+ BLOCK shift, and go to state 119
+ IF shift, and go to state 120
+ LOOP shift, and go to state 121
+ BR shift, and go to state 122
+ BR_IF shift, and go to state 123
+ BR_TABLE shift, and go to state 124
+ CALL shift, and go to state 125
+ CALL_INDIRECT shift, and go to state 126
+ RETURN shift, and go to state 127
+ GET_LOCAL shift, and go to state 128
+ SET_LOCAL shift, and go to state 129
+ TEE_LOCAL shift, and go to state 130
+ GET_GLOBAL shift, and go to state 131
+ SET_GLOBAL shift, and go to state 132
+ LOAD shift, and go to state 133
+ STORE shift, and go to state 134
+ CONST shift, and go to state 135
+ UNARY shift, and go to state 136
+ BINARY shift, and go to state 137
+ COMPARE shift, and go to state 138
+ CONVERT shift, and go to state 139
+ SELECT shift, and go to state 140
+ UNREACHABLE shift, and go to state 141
+ CURRENT_MEMORY shift, and go to state 142
+ GROW_MEMORY shift, and go to state 143
+
+ $default reduce using rule 81 (instr_list)
+
+ instr go to state 145
+ plain_instr go to state 146
+ block_instr go to state 147
+ expr go to state 148
+ instr_list go to state 226
+ const_expr go to state 227
+
+
+State 162
+
+ 121 import: "(" GLOBAL bind_var_opt inline_import . global_type ")"
+
+ "(" shift, and go to state 228
+ VALUE_TYPE shift, and go to state 160
+
+ global_type go to state 229
+
+
+State 163
+
+ 109 global: "(" GLOBAL bind_var_opt inline_export . global_type const_expr ")"
+
+ "(" shift, and go to state 228
+ VALUE_TYPE shift, and go to state 160
+
+ global_type go to state 230
+
+
+State 164
+
+ 122 inline_import: "(" . IMPORT quoted_text quoted_text ")"
+ 130 inline_export: "(" . EXPORT quoted_text ")"
+
+ IMPORT shift, and go to state 191
+ EXPORT shift, and go to state 192
+
+
+State 165
+
+ 119 import: "(" TABLE bind_var_opt inline_import . table_sig ")"
+
+ NAT shift, and go to state 94
+
+ table_sig go to state 231
+ limits go to state 232
+ nat go to state 233
+
+
+State 166
+
+ 102 table: "(" TABLE bind_var_opt inline_export_opt . table_sig ")"
+ 103 | "(" TABLE bind_var_opt inline_export_opt . elem_type "(" ELEM var_list ")" ")"
+
+ NAT shift, and go to state 94
+ ANYFUNC shift, and go to state 234
+
+ elem_type go to state 235
+ table_sig go to state 236
+ limits go to state 232
+ nat go to state 233
+
+
+State 167
+
+ 129 inline_export_opt: inline_export .
+
+ $default reduce using rule 129 (inline_export_opt)
+
+
+State 168
+
+ 72 expr1: BLOCK . labeling_opt block
+
+ VAR shift, and go to state 22
+
+ $default reduce using rule 32 (labeling_opt)
+
+ bind_var go to state 193
+ labeling_opt go to state 237
+
+
+State 169
+
+ 74 expr1: IF . labeling_opt value_type_list if_
+
+ VAR shift, and go to state 22
+
+ $default reduce using rule 32 (labeling_opt)
+
+ bind_var go to state 193
+ labeling_opt go to state 238
+
+
+State 170
+
+ 73 expr1: LOOP . labeling_opt block
+
+ VAR shift, and go to state 22
+
+ $default reduce using rule 32 (labeling_opt)
+
+ bind_var go to state 193
+ labeling_opt go to state 239
+
+
+State 171
+
+ 98 offset: "(" OFFSET . const_expr ")"
+
+ "(" shift, and go to state 213
+ NOP shift, and go to state 117
+ DROP shift, and go to state 118
+ BLOCK shift, and go to state 119
+ IF shift, and go to state 120
+ LOOP shift, and go to state 121
+ BR shift, and go to state 122
+ BR_IF shift, and go to state 123
+ BR_TABLE shift, and go to state 124
+ CALL shift, and go to state 125
+ CALL_INDIRECT shift, and go to state 126
+ RETURN shift, and go to state 127
+ GET_LOCAL shift, and go to state 128
+ SET_LOCAL shift, and go to state 129
+ TEE_LOCAL shift, and go to state 130
+ GET_GLOBAL shift, and go to state 131
+ SET_GLOBAL shift, and go to state 132
+ LOAD shift, and go to state 133
+ STORE shift, and go to state 134
+ CONST shift, and go to state 135
+ UNARY shift, and go to state 136
+ BINARY shift, and go to state 137
+ COMPARE shift, and go to state 138
+ CONVERT shift, and go to state 139
+ SELECT shift, and go to state 140
+ UNREACHABLE shift, and go to state 141
+ CURRENT_MEMORY shift, and go to state 142
+ GROW_MEMORY shift, and go to state 143
+
+ $default reduce using rule 81 (instr_list)
+
+ instr go to state 145
+ plain_instr go to state 146
+ block_instr go to state 147
+ expr go to state 148
+ instr_list go to state 226
+ const_expr go to state 240
+
+
+State 172
+
+ 71 expr1: plain_instr . expr_list
+
+ "(" shift, and go to state 213
+
+ $default reduce using rule 83 (expr_list)
+
+ expr go to state 241
+ expr_list go to state 242
+
+
+State 173
+
+ 70 expr: "(" expr1 . ")"
+
+ ")" shift, and go to state 243
+
+
+State 174
+
+ 100 elem: "(" ELEM var offset . var_list ")"
+
+ $default reduce using rule 27 (var_list)
+
+ var_list go to state 244
+
+
+State 175
+
+ 28 var_list: var_list . var
+ 101 elem: "(" ELEM offset var_list . ")"
+
+ ")" shift, and go to state 245
+ NAT shift, and go to state 94
+ VAR shift, and go to state 95
+
+ nat go to state 96
+ var go to state 246
+
+
+State 176
+
+ 108 memory: "(" MEMORY bind_var_opt "(" . DATA text_list ")" ")"
+ 122 inline_import: "(" . IMPORT quoted_text quoted_text ")"
+ 130 inline_export: "(" . EXPORT quoted_text ")"
+
+ DATA shift, and go to state 247
+ IMPORT shift, and go to state 191
+ EXPORT shift, and go to state 192
+
+
+State 177
+
+ 120 import: "(" MEMORY bind_var_opt inline_import . memory_sig ")"
+
+ NAT shift, and go to state 94
+
+ memory_sig go to state 248
+ limits go to state 249
+ nat go to state 233
+
+
+State 178
+
+ 106 memory: "(" MEMORY bind_var_opt inline_export_opt . memory_sig ")"
+
+ NAT shift, and go to state 94
+
+ memory_sig go to state 250
+ limits go to state 249
+ nat go to state 233
+
+
+State 179
+
+ 107 memory: "(" MEMORY bind_var_opt inline_export . "(" DATA text_list ")" ")"
+ 129 inline_export_opt: inline_export .
+
+ "(" shift, and go to state 251
+
+ $default reduce using rule 129 (inline_export_opt)
+
+
+State 180
+
+ 104 data: "(" DATA var offset . text_list ")"
+
+ TEXT shift, and go to state 41
+
+ $default reduce using rule 3 (text_list)
+
+ non_empty_text_list go to state 181
+ text_list go to state 252
+
+
+State 181
+
+ 2 non_empty_text_list: non_empty_text_list . TEXT
+ 4 text_list: non_empty_text_list .
+
+ TEXT shift, and go to state 56
+
+ $default reduce using rule 4 (text_list)
+
+
+State 182
+
+ 105 data: "(" DATA offset text_list . ")"
+
+ ")" shift, and go to state 253
+
+
+State 183
+
+ 116 import: "(" IMPORT quoted_text quoted_text . import_kind ")"
+
+ "(" shift, and go to state 254
+
+ import_kind go to state 255
+
+
+State 184
+
+ 123 export_kind: "(" . FUNC var ")"
+ 124 | "(" . TABLE var ")"
+ 125 | "(" . MEMORY var ")"
+ 126 | "(" . GLOBAL var ")"
+
+ FUNC shift, and go to state 256
+ GLOBAL shift, and go to state 257
+ TABLE shift, and go to state 258
+ MEMORY shift, and go to state 259
+
+
+State 185
+
+ 127 export: "(" EXPORT quoted_text export_kind . ")"
+
+ ")" shift, and go to state 260
+
+
+State 186
+
+ 166 const: "(" CONST literal ")" .
+
+ $default reduce using rule 166 (const)
+
+
+State 187
+
+ 20 type_use: "(" TYPE . var ")"
+
+ NAT shift, and go to state 94
+ VAR shift, and go to state 95
+
+ nat go to state 96
+ var go to state 261
+
+
+State 188
+
+ 88 func_fields: "(" PARAM . value_type_list ")" func_fields
+ 89 | "(" PARAM . bind_var VALUE_TYPE ")" func_fields
+
+ VAR shift, and go to state 22
+
+ $default reduce using rule 6 (value_type_list)
+
+ value_type_list go to state 262
+ bind_var go to state 263
+
+
+State 189
+
+ 87 func_fields: "(" RESULT . value_type_list ")" func_body
+
+ $default reduce using rule 6 (value_type_list)
+
+ value_type_list go to state 264
+
+
+State 190
+
+ 91 func_body: "(" LOCAL . value_type_list ")" func_body
+ 92 | "(" LOCAL . bind_var VALUE_TYPE ")" func_body
+
+ VAR shift, and go to state 22
+
+ $default reduce using rule 6 (value_type_list)
+
+ value_type_list go to state 265
+ bind_var go to state 266
+
+
+State 191
+
+ 122 inline_import: "(" IMPORT . quoted_text quoted_text ")"
+
+ TEXT shift, and go to state 25
+
+ quoted_text go to state 267
+
+
+State 192
+
+ 130 inline_export: "(" EXPORT . quoted_text ")"
+
+ TEXT shift, and go to state 25
+
+ quoted_text go to state 268
+
+
+State 193
+
+ 33 labeling_opt: bind_var .
+
+ $default reduce using rule 33 (labeling_opt)
+
+
+State 194
+
+ 65 block_instr: BLOCK labeling_opt . block END labeling_opt
+
+ $default reduce using rule 6 (value_type_list)
+
+ value_type_list go to state 269
+ block go to state 270
+
+
+State 195
+
+ 67 block_instr: IF labeling_opt . block END labeling_opt
+ 68 | IF labeling_opt . block ELSE labeling_opt instr_list END labeling_opt
+
+ $default reduce using rule 6 (value_type_list)
+
+ value_type_list go to state 269
+ block go to state 271
+
+
+State 196
+
+ 66 block_instr: LOOP labeling_opt . block END labeling_opt
+
+ $default reduce using rule 6 (value_type_list)
+
+ value_type_list go to state 269
+ block go to state 272
+
+
+State 197
+
+ 45 plain_instr: BR var .
+
+ $default reduce using rule 45 (plain_instr)
+
+
+State 198
+
+ 46 plain_instr: BR_IF var .
+
+ $default reduce using rule 46 (plain_instr)
+
+
+State 199
+
+ 28 var_list: var_list . var
+ 47 plain_instr: BR_TABLE var_list . var
+
+ NAT shift, and go to state 94
+ VAR shift, and go to state 95
+
+ nat go to state 96
+ var go to state 273
+
+
+State 200
+
+ 49 plain_instr: CALL var .
+
+ $default reduce using rule 49 (plain_instr)
+
+
+State 201
+
+ 50 plain_instr: CALL_INDIRECT var .
+
+ $default reduce using rule 50 (plain_instr)
+
+
+State 202
+
+ 51 plain_instr: GET_LOCAL var .
+
+ $default reduce using rule 51 (plain_instr)
+
+
+State 203
+
+ 52 plain_instr: SET_LOCAL var .
+
+ $default reduce using rule 52 (plain_instr)
+
+
+State 204
+
+ 53 plain_instr: TEE_LOCAL var .
+
+ $default reduce using rule 53 (plain_instr)
+
+
+State 205
+
+ 54 plain_instr: GET_GLOBAL var .
+
+ $default reduce using rule 54 (plain_instr)
+
+
+State 206
+
+ 55 plain_instr: SET_GLOBAL var .
+
+ $default reduce using rule 55 (plain_instr)
+
+
+State 207
+
+ 35 offset_opt: OFFSET_EQ_NAT .
+
+ $default reduce using rule 35 (offset_opt)
+
+
+State 208
+
+ 56 plain_instr: LOAD offset_opt . align_opt
+
+ ALIGN_EQ_NAT shift, and go to state 274
+
+ $default reduce using rule 36 (align_opt)
+
+ align_opt go to state 275
+
+
+State 209
+
+ 57 plain_instr: STORE offset_opt . align_opt
+
+ ALIGN_EQ_NAT shift, and go to state 274
+
+ $default reduce using rule 36 (align_opt)
+
+ align_opt go to state 276
+
+
+State 210
+
+ 58 plain_instr: CONST literal .
+
+ $default reduce using rule 58 (plain_instr)
+
+
+State 211
+
+ 70 expr: "(" . expr1 ")"
+ 87 func_fields: "(" . RESULT value_type_list ")" func_body
+ 88 | "(" . PARAM value_type_list ")" func_fields
+ 89 | "(" . PARAM bind_var VALUE_TYPE ")" func_fields
+ 91 func_body: "(" . LOCAL value_type_list ")" func_body
+ 92 | "(" . LOCAL bind_var VALUE_TYPE ")" func_body
+
+ NOP shift, and go to state 117
+ DROP shift, and go to state 118
+ BLOCK shift, and go to state 168
+ IF shift, and go to state 169
+ LOOP shift, and go to state 170
+ BR shift, and go to state 122
+ BR_IF shift, and go to state 123
+ BR_TABLE shift, and go to state 124
+ CALL shift, and go to state 125
+ CALL_INDIRECT shift, and go to state 126
+ RETURN shift, and go to state 127
+ GET_LOCAL shift, and go to state 128
+ SET_LOCAL shift, and go to state 129
+ TEE_LOCAL shift, and go to state 130
+ GET_GLOBAL shift, and go to state 131
+ SET_GLOBAL shift, and go to state 132
+ LOAD shift, and go to state 133
+ STORE shift, and go to state 134
+ CONST shift, and go to state 135
+ UNARY shift, and go to state 136
+ BINARY shift, and go to state 137
+ COMPARE shift, and go to state 138
+ CONVERT shift, and go to state 139
+ SELECT shift, and go to state 140
+ UNREACHABLE shift, and go to state 141
+ CURRENT_MEMORY shift, and go to state 142
+ GROW_MEMORY shift, and go to state 143
+ PARAM shift, and go to state 188
+ RESULT shift, and go to state 189
+ LOCAL shift, and go to state 190
+
+ plain_instr go to state 172
+ expr1 go to state 173
+
+
+State 212
+
+ 95 func: "(" FUNC bind_var_opt type_use func_info . ")"
+
+ ")" shift, and go to state 277
+
+
+State 213
+
+ 70 expr: "(" . expr1 ")"
+
+ NOP shift, and go to state 117
+ DROP shift, and go to state 118
+ BLOCK shift, and go to state 168
+ IF shift, and go to state 169
+ LOOP shift, and go to state 170
+ BR shift, and go to state 122
+ BR_IF shift, and go to state 123
+ BR_TABLE shift, and go to state 124
+ CALL shift, and go to state 125
+ CALL_INDIRECT shift, and go to state 126
+ RETURN shift, and go to state 127
+ GET_LOCAL shift, and go to state 128
+ SET_LOCAL shift, and go to state 129
+ TEE_LOCAL shift, and go to state 130
+ GET_GLOBAL shift, and go to state 131
+ SET_GLOBAL shift, and go to state 132
+ LOAD shift, and go to state 133
+ STORE shift, and go to state 134
+ CONST shift, and go to state 135
+ UNARY shift, and go to state 136
+ BINARY shift, and go to state 137
+ COMPARE shift, and go to state 138
+ CONVERT shift, and go to state 139
+ SELECT shift, and go to state 140
+ UNREACHABLE shift, and go to state 141
+ CURRENT_MEMORY shift, and go to state 142
+ GROW_MEMORY shift, and go to state 143
+
+ plain_instr go to state 172
+ expr1 go to state 173
+
+
+State 214
+
+ 82 instr_list: instr instr_list .
+
+ $default reduce using rule 82 (instr_list)
+
+
+State 215
+
+ 97 func: "(" FUNC bind_var_opt func_info ")" .
+
+ $default reduce using rule 97 (func)
+
+
+State 216
+
+ 13 func_sig: "(" . PARAM value_type_list ")"
+ 14 | "(" . PARAM value_type_list ")" "(" RESULT value_type_list ")"
+ 15 | "(" . RESULT value_type_list ")"
+ 20 type_use: "(" . TYPE var ")"
+
+ TYPE shift, and go to state 187
+ PARAM shift, and go to state 278
+ RESULT shift, and go to state 279
+
+
+State 217
+
+ 118 import: "(" FUNC bind_var_opt inline_import func_sig . ")"
+
+ ")" shift, and go to state 280
+
+
+State 218
+
+ 117 import: "(" FUNC bind_var_opt inline_import type_use . ")"
+
+ ")" shift, and go to state 281
+
+
+State 219
+
+ 20 type_use: "(" . TYPE var ")"
+ 70 expr: "(" . expr1 ")"
+ 87 func_fields: "(" . RESULT value_type_list ")" func_body
+ 88 | "(" . PARAM value_type_list ")" func_fields
+ 89 | "(" . PARAM bind_var VALUE_TYPE ")" func_fields
+ 91 func_body: "(" . LOCAL value_type_list ")" func_body
+ 92 | "(" . LOCAL bind_var VALUE_TYPE ")" func_body
+
+ NOP shift, and go to state 117
+ DROP shift, and go to state 118
+ BLOCK shift, and go to state 168
+ IF shift, and go to state 169
+ LOOP shift, and go to state 170
+ BR shift, and go to state 122
+ BR_IF shift, and go to state 123
+ BR_TABLE shift, and go to state 124
+ CALL shift, and go to state 125
+ CALL_INDIRECT shift, and go to state 126
+ RETURN shift, and go to state 127
+ GET_LOCAL shift, and go to state 128
+ SET_LOCAL shift, and go to state 129
+ TEE_LOCAL shift, and go to state 130
+ GET_GLOBAL shift, and go to state 131
+ SET_GLOBAL shift, and go to state 132
+ LOAD shift, and go to state 133
+ STORE shift, and go to state 134
+ CONST shift, and go to state 135
+ UNARY shift, and go to state 136
+ BINARY shift, and go to state 137
+ COMPARE shift, and go to state 138
+ CONVERT shift, and go to state 139
+ SELECT shift, and go to state 140
+ UNREACHABLE shift, and go to state 141
+ CURRENT_MEMORY shift, and go to state 142
+ GROW_MEMORY shift, and go to state 143
+ TYPE shift, and go to state 187
+ PARAM shift, and go to state 188
+ RESULT shift, and go to state 189
+ LOCAL shift, and go to state 190
+
+ plain_instr go to state 172
+ expr1 go to state 173
+
+
+State 220
+
+ 94 func: "(" FUNC bind_var_opt inline_export type_use . func_info ")"
+
+ "(" shift, and go to state 211
+ NOP shift, and go to state 117
+ DROP shift, and go to state 118
+ BLOCK shift, and go to state 119
+ IF shift, and go to state 120
+ LOOP shift, and go to state 121
+ BR shift, and go to state 122
+ BR_IF shift, and go to state 123
+ BR_TABLE shift, and go to state 124
+ CALL shift, and go to state 125
+ CALL_INDIRECT shift, and go to state 126
+ RETURN shift, and go to state 127
+ GET_LOCAL shift, and go to state 128
+ SET_LOCAL shift, and go to state 129
+ TEE_LOCAL shift, and go to state 130
+ GET_GLOBAL shift, and go to state 131
+ SET_GLOBAL shift, and go to state 132
+ LOAD shift, and go to state 133
+ STORE shift, and go to state 134
+ CONST shift, and go to state 135
+ UNARY shift, and go to state 136
+ BINARY shift, and go to state 137
+ COMPARE shift, and go to state 138
+ CONVERT shift, and go to state 139
+ SELECT shift, and go to state 140
+ UNREACHABLE shift, and go to state 141
+ CURRENT_MEMORY shift, and go to state 142
+ GROW_MEMORY shift, and go to state 143
+
+ $default reduce using rule 81 (instr_list)
+
+ instr go to state 145
+ plain_instr go to state 146
+ block_instr go to state 147
+ expr go to state 148
+ instr_list go to state 149
+ func_fields go to state 150
+ func_body go to state 151
+ func_info go to state 282
+
+
+State 221
+
+ 96 func: "(" FUNC bind_var_opt inline_export func_info . ")"
+
+ ")" shift, and go to state 283
+
+
+State 222
+
+ 13 func_sig: "(" . PARAM value_type_list ")"
+ 14 | "(" . PARAM value_type_list ")" "(" RESULT value_type_list ")"
+ 15 | "(" . RESULT value_type_list ")"
+
+ PARAM shift, and go to state 278
+ RESULT shift, and go to state 279
+
+
+State 223
+
+ 11 func_type: "(" FUNC func_sig . ")"
+
+ ")" shift, and go to state 284
+
+
+State 224
+
+ 132 type_def: "(" TYPE bind_var func_type ")" .
+
+ $default reduce using rule 132 (type_def)
+
+
+State 225
+
+ 10 global_type: "(" MUT . VALUE_TYPE ")"
+
+ VALUE_TYPE shift, and go to state 285
+
+
+State 226
+
+ 85 const_expr: instr_list .
+
+ $default reduce using rule 85 (const_expr)
+
+
+State 227
+
+ 110 global: "(" GLOBAL bind_var_opt global_type const_expr . ")"
+
+ ")" shift, and go to state 286
+
+
+State 228
+
+ 10 global_type: "(" . MUT VALUE_TYPE ")"
+
+ MUT shift, and go to state 225
+
+
+State 229
+
+ 121 import: "(" GLOBAL bind_var_opt inline_import global_type . ")"
+
+ ")" shift, and go to state 287
+
+
+State 230
+
+ 109 global: "(" GLOBAL bind_var_opt inline_export global_type . const_expr ")"
+
+ "(" shift, and go to state 213
+ NOP shift, and go to state 117
+ DROP shift, and go to state 118
+ BLOCK shift, and go to state 119
+ IF shift, and go to state 120
+ LOOP shift, and go to state 121
+ BR shift, and go to state 122
+ BR_IF shift, and go to state 123
+ BR_TABLE shift, and go to state 124
+ CALL shift, and go to state 125
+ CALL_INDIRECT shift, and go to state 126
+ RETURN shift, and go to state 127
+ GET_LOCAL shift, and go to state 128
+ SET_LOCAL shift, and go to state 129
+ TEE_LOCAL shift, and go to state 130
+ GET_GLOBAL shift, and go to state 131
+ SET_GLOBAL shift, and go to state 132
+ LOAD shift, and go to state 133
+ STORE shift, and go to state 134
+ CONST shift, and go to state 135
+ UNARY shift, and go to state 136
+ BINARY shift, and go to state 137
+ COMPARE shift, and go to state 138
+ CONVERT shift, and go to state 139
+ SELECT shift, and go to state 140
+ UNREACHABLE shift, and go to state 141
+ CURRENT_MEMORY shift, and go to state 142
+ GROW_MEMORY shift, and go to state 143
+
+ $default reduce using rule 81 (instr_list)
+
+ instr go to state 145
+ plain_instr go to state 146
+ block_instr go to state 147
+ expr go to state 148
+ instr_list go to state 226
+ const_expr go to state 288
+
+
+State 231
+
+ 119 import: "(" TABLE bind_var_opt inline_import table_sig . ")"
+
+ ")" shift, and go to state 289
+
+
+State 232
+
+ 16 table_sig: limits . elem_type
+
+ ANYFUNC shift, and go to state 234
+
+ elem_type go to state 290
+
+
+State 233
+
+ 18 limits: nat .
+ 19 | nat . nat
+
+ NAT shift, and go to state 94
+
+ $default reduce using rule 18 (limits)
+
+ nat go to state 291
+
+
+State 234
+
+ 8 elem_type: ANYFUNC .
+
+ $default reduce using rule 8 (elem_type)
+
+
+State 235
+
+ 103 table: "(" TABLE bind_var_opt inline_export_opt elem_type . "(" ELEM var_list ")" ")"
+
+ "(" shift, and go to state 292
+
+
+State 236
+
+ 102 table: "(" TABLE bind_var_opt inline_export_opt table_sig . ")"
+
+ ")" shift, and go to state 293
+
+
+State 237
+
+ 72 expr1: BLOCK labeling_opt . block
+
+ $default reduce using rule 6 (value_type_list)
+
+ value_type_list go to state 269
+ block go to state 294
+
+
+State 238
+
+ 74 expr1: IF labeling_opt . value_type_list if_
+
+ $default reduce using rule 6 (value_type_list)
+
+ value_type_list go to state 295
+
+
+State 239
+
+ 73 expr1: LOOP labeling_opt . block
+
+ $default reduce using rule 6 (value_type_list)
+
+ value_type_list go to state 269
+ block go to state 296
+
+
+State 240
+
+ 98 offset: "(" OFFSET const_expr . ")"
+
+ ")" shift, and go to state 297
+
+
+State 241
+
+ 84 expr_list: expr . expr_list
+
+ "(" shift, and go to state 213
+
+ $default reduce using rule 83 (expr_list)
+
+ expr go to state 241
+ expr_list go to state 298
+
+
+State 242
+
+ 71 expr1: plain_instr expr_list .
+
+ $default reduce using rule 71 (expr1)
+
+
+State 243
+
+ 70 expr: "(" expr1 ")" .
+
+ $default reduce using rule 70 (expr)
+
+
+State 244
+
+ 28 var_list: var_list . var
+ 100 elem: "(" ELEM var offset var_list . ")"
+
+ ")" shift, and go to state 299
+ NAT shift, and go to state 94
+ VAR shift, and go to state 95
+
+ nat go to state 96
+ var go to state 246
+
+
+State 245
+
+ 101 elem: "(" ELEM offset var_list ")" .
+
+ $default reduce using rule 101 (elem)
+
+
+State 246
+
+ 28 var_list: var_list var .
+
+ $default reduce using rule 28 (var_list)
+
+
+State 247
+
+ 108 memory: "(" MEMORY bind_var_opt "(" DATA . text_list ")" ")"
+
+ TEXT shift, and go to state 41
+
+ $default reduce using rule 3 (text_list)
+
+ non_empty_text_list go to state 181
+ text_list go to state 300
+
+
+State 248
+
+ 120 import: "(" MEMORY bind_var_opt inline_import memory_sig . ")"
+
+ ")" shift, and go to state 301
+
+
+State 249
+
+ 17 memory_sig: limits .
+
+ $default reduce using rule 17 (memory_sig)
+
+
+State 250
+
+ 106 memory: "(" MEMORY bind_var_opt inline_export_opt memory_sig . ")"
+
+ ")" shift, and go to state 302
+
+
+State 251
+
+ 107 memory: "(" MEMORY bind_var_opt inline_export "(" . DATA text_list ")" ")"
+
+ DATA shift, and go to state 303
+
+
+State 252
+
+ 104 data: "(" DATA var offset text_list . ")"
+
+ ")" shift, and go to state 304
+
+
+State 253
+
+ 105 data: "(" DATA offset text_list ")" .
+
+ $default reduce using rule 105 (data)
+
+
+State 254
+
+ 111 import_kind: "(" . FUNC bind_var_opt type_use ")"
+ 112 | "(" . FUNC bind_var_opt func_sig ")"
+ 113 | "(" . TABLE bind_var_opt table_sig ")"
+ 114 | "(" . MEMORY bind_var_opt memory_sig ")"
+ 115 | "(" . GLOBAL bind_var_opt global_type ")"
+
+ FUNC shift, and go to state 305
+ GLOBAL shift, and go to state 306
+ TABLE shift, and go to state 307
+ MEMORY shift, and go to state 308
+
+
+State 255
+
+ 116 import: "(" IMPORT quoted_text quoted_text import_kind . ")"
+
+ ")" shift, and go to state 309
+
+
+State 256
+
+ 123 export_kind: "(" FUNC . var ")"
+
+ NAT shift, and go to state 94
+ VAR shift, and go to state 95
+
+ nat go to state 96
+ var go to state 310
+
+
+State 257
+
+ 126 export_kind: "(" GLOBAL . var ")"
+
+ NAT shift, and go to state 94
+ VAR shift, and go to state 95
+
+ nat go to state 96
+ var go to state 311
+
+
+State 258
+
+ 124 export_kind: "(" TABLE . var ")"
+
+ NAT shift, and go to state 94
+ VAR shift, and go to state 95
+
+ nat go to state 96
+ var go to state 312
+
+
+State 259
+
+ 125 export_kind: "(" MEMORY . var ")"
+
+ NAT shift, and go to state 94
+ VAR shift, and go to state 95
+
+ nat go to state 96
+ var go to state 313
+
+
+State 260
+
+ 127 export: "(" EXPORT quoted_text export_kind ")" .
+
+ $default reduce using rule 127 (export)
+
+
+State 261
+
+ 20 type_use: "(" TYPE var . ")"
+
+ ")" shift, and go to state 314
+
+
+State 262
+
+ 7 value_type_list: value_type_list . VALUE_TYPE
+ 88 func_fields: "(" PARAM value_type_list . ")" func_fields
+
+ ")" shift, and go to state 315
+ VALUE_TYPE shift, and go to state 316
+
+
+State 263
+
+ 89 func_fields: "(" PARAM bind_var . VALUE_TYPE ")" func_fields
+
+ VALUE_TYPE shift, and go to state 317
+
+
+State 264
+
+ 7 value_type_list: value_type_list . VALUE_TYPE
+ 87 func_fields: "(" RESULT value_type_list . ")" func_body
+
+ ")" shift, and go to state 318
+ VALUE_TYPE shift, and go to state 316
+
+
+State 265
+
+ 7 value_type_list: value_type_list . VALUE_TYPE
+ 91 func_body: "(" LOCAL value_type_list . ")" func_body
+
+ ")" shift, and go to state 319
+ VALUE_TYPE shift, and go to state 316
+
+
+State 266
+
+ 92 func_body: "(" LOCAL bind_var . VALUE_TYPE ")" func_body
+
+ VALUE_TYPE shift, and go to state 320
+
+
+State 267
+
+ 122 inline_import: "(" IMPORT quoted_text . quoted_text ")"
+
+ TEXT shift, and go to state 25
+
+ quoted_text go to state 321
+
+
+State 268
+
+ 130 inline_export: "(" EXPORT quoted_text . ")"
+
+ ")" shift, and go to state 322
+
+
+State 269
+
+ 7 value_type_list: value_type_list . VALUE_TYPE
+ 69 block: value_type_list . instr_list
+
+ "(" shift, and go to state 213
+ VALUE_TYPE shift, and go to state 316
+ NOP shift, and go to state 117
+ DROP shift, and go to state 118
+ BLOCK shift, and go to state 119
+ IF shift, and go to state 120
+ LOOP shift, and go to state 121
+ BR shift, and go to state 122
+ BR_IF shift, and go to state 123
+ BR_TABLE shift, and go to state 124
+ CALL shift, and go to state 125
+ CALL_INDIRECT shift, and go to state 126
+ RETURN shift, and go to state 127
+ GET_LOCAL shift, and go to state 128
+ SET_LOCAL shift, and go to state 129
+ TEE_LOCAL shift, and go to state 130
+ GET_GLOBAL shift, and go to state 131
+ SET_GLOBAL shift, and go to state 132
+ LOAD shift, and go to state 133
+ STORE shift, and go to state 134
+ CONST shift, and go to state 135
+ UNARY shift, and go to state 136
+ BINARY shift, and go to state 137
+ COMPARE shift, and go to state 138
+ CONVERT shift, and go to state 139
+ SELECT shift, and go to state 140
+ UNREACHABLE shift, and go to state 141
+ CURRENT_MEMORY shift, and go to state 142
+ GROW_MEMORY shift, and go to state 143
+
+ $default reduce using rule 81 (instr_list)
+
+ instr go to state 145
+ plain_instr go to state 146
+ block_instr go to state 147
+ expr go to state 148
+ instr_list go to state 323
+
+
+State 270
+
+ 65 block_instr: BLOCK labeling_opt block . END labeling_opt
+
+ END shift, and go to state 324
+
+
+State 271
+
+ 67 block_instr: IF labeling_opt block . END labeling_opt
+ 68 | IF labeling_opt block . ELSE labeling_opt instr_list END labeling_opt
+
+ END shift, and go to state 325
+ ELSE shift, and go to state 326
+
+
+State 272
+
+ 66 block_instr: LOOP labeling_opt block . END labeling_opt
+
+ END shift, and go to state 327
+
+
+State 273
+
+ 28 var_list: var_list var .
+ 47 plain_instr: BR_TABLE var_list var .
+
+ NAT reduce using rule 28 (var_list)
+ VAR reduce using rule 28 (var_list)
+ $default reduce using rule 47 (plain_instr)
+
+
+State 274
+
+ 37 align_opt: ALIGN_EQ_NAT .
+
+ $default reduce using rule 37 (align_opt)
+
+
+State 275
+
+ 56 plain_instr: LOAD offset_opt align_opt .
+
+ $default reduce using rule 56 (plain_instr)
+
+
+State 276
+
+ 57 plain_instr: STORE offset_opt align_opt .
+
+ $default reduce using rule 57 (plain_instr)
+
+
+State 277
+
+ 95 func: "(" FUNC bind_var_opt type_use func_info ")" .
+
+ $default reduce using rule 95 (func)
+
+
+State 278
+
+ 13 func_sig: "(" PARAM . value_type_list ")"
+ 14 | "(" PARAM . value_type_list ")" "(" RESULT value_type_list ")"
+
+ $default reduce using rule 6 (value_type_list)
+
+ value_type_list go to state 328
+
+
+State 279
+
+ 15 func_sig: "(" RESULT . value_type_list ")"
+
+ $default reduce using rule 6 (value_type_list)
+
+ value_type_list go to state 329
+
+
+State 280
+
+ 118 import: "(" FUNC bind_var_opt inline_import func_sig ")" .
+
+ $default reduce using rule 118 (import)
+
+
+State 281
+
+ 117 import: "(" FUNC bind_var_opt inline_import type_use ")" .
+
+ $default reduce using rule 117 (import)
+
+
+State 282
+
+ 94 func: "(" FUNC bind_var_opt inline_export type_use func_info . ")"
+
+ ")" shift, and go to state 330
+
+
+State 283
+
+ 96 func: "(" FUNC bind_var_opt inline_export func_info ")" .
+
+ $default reduce using rule 96 (func)
+
+
+State 284
+
+ 11 func_type: "(" FUNC func_sig ")" .
+
+ $default reduce using rule 11 (func_type)
+
+
+State 285
+
+ 10 global_type: "(" MUT VALUE_TYPE . ")"
+
+ ")" shift, and go to state 331
+
+
+State 286
+
+ 110 global: "(" GLOBAL bind_var_opt global_type const_expr ")" .
+
+ $default reduce using rule 110 (global)
+
+
+State 287
+
+ 121 import: "(" GLOBAL bind_var_opt inline_import global_type ")" .
+
+ $default reduce using rule 121 (import)
+
+
+State 288
+
+ 109 global: "(" GLOBAL bind_var_opt inline_export global_type const_expr . ")"
+
+ ")" shift, and go to state 332
+
+
+State 289
+
+ 119 import: "(" TABLE bind_var_opt inline_import table_sig ")" .
+
+ $default reduce using rule 119 (import)
+
+
+State 290
+
+ 16 table_sig: limits elem_type .
+
+ $default reduce using rule 16 (table_sig)
+
+
+State 291
+
+ 19 limits: nat nat .
+
+ $default reduce using rule 19 (limits)
+
+
+State 292
+
+ 103 table: "(" TABLE bind_var_opt inline_export_opt elem_type "(" . ELEM var_list ")" ")"
+
+ ELEM shift, and go to state 333
+
+
+State 293
+
+ 102 table: "(" TABLE bind_var_opt inline_export_opt table_sig ")" .
+
+ $default reduce using rule 102 (table)
+
+
+State 294
+
+ 72 expr1: BLOCK labeling_opt block .
+
+ $default reduce using rule 72 (expr1)
+
+
+State 295
+
+ 7 value_type_list: value_type_list . VALUE_TYPE
+ 74 expr1: IF labeling_opt value_type_list . if_
+
+ "(" shift, and go to state 334
+ VALUE_TYPE shift, and go to state 316
+
+ expr go to state 335
+ if_ go to state 336
+
+
+State 296
+
+ 73 expr1: LOOP labeling_opt block .
+
+ $default reduce using rule 73 (expr1)
+
+
+State 297
+
+ 98 offset: "(" OFFSET const_expr ")" .
+
+ $default reduce using rule 98 (offset)
+
+
+State 298
+
+ 84 expr_list: expr expr_list .
+
+ $default reduce using rule 84 (expr_list)
+
+
+State 299
+
+ 100 elem: "(" ELEM var offset var_list ")" .
+
+ $default reduce using rule 100 (elem)
+
+
+State 300
+
+ 108 memory: "(" MEMORY bind_var_opt "(" DATA text_list . ")" ")"
+
+ ")" shift, and go to state 337
+
+
+State 301
+
+ 120 import: "(" MEMORY bind_var_opt inline_import memory_sig ")" .
+
+ $default reduce using rule 120 (import)
+
+
+State 302
+
+ 106 memory: "(" MEMORY bind_var_opt inline_export_opt memory_sig ")" .
+
+ $default reduce using rule 106 (memory)
+
+
+State 303
+
+ 107 memory: "(" MEMORY bind_var_opt inline_export "(" DATA . text_list ")" ")"
+
+ TEXT shift, and go to state 41
+
+ $default reduce using rule 3 (text_list)
+
+ non_empty_text_list go to state 181
+ text_list go to state 338
+
+
+State 304
+
+ 104 data: "(" DATA var offset text_list ")" .
+
+ $default reduce using rule 104 (data)
+
+
+State 305
+
+ 111 import_kind: "(" FUNC . bind_var_opt type_use ")"
+ 112 | "(" FUNC . bind_var_opt func_sig ")"
+
+ VAR shift, and go to state 22
+
+ $default reduce using rule 29 (bind_var_opt)
+
+ bind_var_opt go to state 339
+ bind_var go to state 24
+
+
+State 306
+
+ 115 import_kind: "(" GLOBAL . bind_var_opt global_type ")"
+
+ VAR shift, and go to state 22
+
+ $default reduce using rule 29 (bind_var_opt)
+
+ bind_var_opt go to state 340
+ bind_var go to state 24
+
+
+State 307
+
+ 113 import_kind: "(" TABLE . bind_var_opt table_sig ")"
+
+ VAR shift, and go to state 22
+
+ $default reduce using rule 29 (bind_var_opt)
+
+ bind_var_opt go to state 341
+ bind_var go to state 24
+
+
+State 308
+
+ 114 import_kind: "(" MEMORY . bind_var_opt memory_sig ")"
+
+ VAR shift, and go to state 22
+
+ $default reduce using rule 29 (bind_var_opt)
+
+ bind_var_opt go to state 342
+ bind_var go to state 24
+
+
+State 309
+
+ 116 import: "(" IMPORT quoted_text quoted_text import_kind ")" .
+
+ $default reduce using rule 116 (import)
+
+
+State 310
+
+ 123 export_kind: "(" FUNC var . ")"
+
+ ")" shift, and go to state 343
+
+
+State 311
+
+ 126 export_kind: "(" GLOBAL var . ")"
+
+ ")" shift, and go to state 344
+
+
+State 312
+
+ 124 export_kind: "(" TABLE var . ")"
+
+ ")" shift, and go to state 345
+
+
+State 313
+
+ 125 export_kind: "(" MEMORY var . ")"
+
+ ")" shift, and go to state 346
+
+
+State 314
+
+ 20 type_use: "(" TYPE var ")" .
+
+ $default reduce using rule 20 (type_use)
+
+
+State 315
+
+ 88 func_fields: "(" PARAM value_type_list ")" . func_fields
+
+ "(" shift, and go to state 211
+ NOP shift, and go to state 117
+ DROP shift, and go to state 118
+ BLOCK shift, and go to state 119
+ IF shift, and go to state 120
+ LOOP shift, and go to state 121
+ BR shift, and go to state 122
+ BR_IF shift, and go to state 123
+ BR_TABLE shift, and go to state 124
+ CALL shift, and go to state 125
+ CALL_INDIRECT shift, and go to state 126
+ RETURN shift, and go to state 127
+ GET_LOCAL shift, and go to state 128
+ SET_LOCAL shift, and go to state 129
+ TEE_LOCAL shift, and go to state 130
+ GET_GLOBAL shift, and go to state 131
+ SET_GLOBAL shift, and go to state 132
+ LOAD shift, and go to state 133
+ STORE shift, and go to state 134
+ CONST shift, and go to state 135
+ UNARY shift, and go to state 136
+ BINARY shift, and go to state 137
+ COMPARE shift, and go to state 138
+ CONVERT shift, and go to state 139
+ SELECT shift, and go to state 140
+ UNREACHABLE shift, and go to state 141
+ CURRENT_MEMORY shift, and go to state 142
+ GROW_MEMORY shift, and go to state 143
+
+ $default reduce using rule 81 (instr_list)
+
+ instr go to state 145
+ plain_instr go to state 146
+ block_instr go to state 147
+ expr go to state 148
+ instr_list go to state 149
+ func_fields go to state 347
+ func_body go to state 151
+
+
+State 316
+
+ 7 value_type_list: value_type_list VALUE_TYPE .
+
+ $default reduce using rule 7 (value_type_list)
+
+
+State 317
+
+ 89 func_fields: "(" PARAM bind_var VALUE_TYPE . ")" func_fields
+
+ ")" shift, and go to state 348
+
+
+State 318
+
+ 87 func_fields: "(" RESULT value_type_list ")" . func_body
+
+ "(" shift, and go to state 349
+ NOP shift, and go to state 117
+ DROP shift, and go to state 118
+ BLOCK shift, and go to state 119
+ IF shift, and go to state 120
+ LOOP shift, and go to state 121
+ BR shift, and go to state 122
+ BR_IF shift, and go to state 123
+ BR_TABLE shift, and go to state 124
+ CALL shift, and go to state 125
+ CALL_INDIRECT shift, and go to state 126
+ RETURN shift, and go to state 127
+ GET_LOCAL shift, and go to state 128
+ SET_LOCAL shift, and go to state 129
+ TEE_LOCAL shift, and go to state 130
+ GET_GLOBAL shift, and go to state 131
+ SET_GLOBAL shift, and go to state 132
+ LOAD shift, and go to state 133
+ STORE shift, and go to state 134
+ CONST shift, and go to state 135
+ UNARY shift, and go to state 136
+ BINARY shift, and go to state 137
+ COMPARE shift, and go to state 138
+ CONVERT shift, and go to state 139
+ SELECT shift, and go to state 140
+ UNREACHABLE shift, and go to state 141
+ CURRENT_MEMORY shift, and go to state 142
+ GROW_MEMORY shift, and go to state 143
+
+ $default reduce using rule 81 (instr_list)
+
+ instr go to state 145
+ plain_instr go to state 146
+ block_instr go to state 147
+ expr go to state 148
+ instr_list go to state 149
+ func_body go to state 350
+
+
+State 319
+
+ 91 func_body: "(" LOCAL value_type_list ")" . func_body
+
+ "(" shift, and go to state 349
+ NOP shift, and go to state 117
+ DROP shift, and go to state 118
+ BLOCK shift, and go to state 119
+ IF shift, and go to state 120
+ LOOP shift, and go to state 121
+ BR shift, and go to state 122
+ BR_IF shift, and go to state 123
+ BR_TABLE shift, and go to state 124
+ CALL shift, and go to state 125
+ CALL_INDIRECT shift, and go to state 126
+ RETURN shift, and go to state 127
+ GET_LOCAL shift, and go to state 128
+ SET_LOCAL shift, and go to state 129
+ TEE_LOCAL shift, and go to state 130
+ GET_GLOBAL shift, and go to state 131
+ SET_GLOBAL shift, and go to state 132
+ LOAD shift, and go to state 133
+ STORE shift, and go to state 134
+ CONST shift, and go to state 135
+ UNARY shift, and go to state 136
+ BINARY shift, and go to state 137
+ COMPARE shift, and go to state 138
+ CONVERT shift, and go to state 139
+ SELECT shift, and go to state 140
+ UNREACHABLE shift, and go to state 141
+ CURRENT_MEMORY shift, and go to state 142
+ GROW_MEMORY shift, and go to state 143
+
+ $default reduce using rule 81 (instr_list)
+
+ instr go to state 145
+ plain_instr go to state 146
+ block_instr go to state 147
+ expr go to state 148
+ instr_list go to state 149
+ func_body go to state 351
+
+
+State 320
+
+ 92 func_body: "(" LOCAL bind_var VALUE_TYPE . ")" func_body
+
+ ")" shift, and go to state 352
+
+
+State 321
+
+ 122 inline_import: "(" IMPORT quoted_text quoted_text . ")"
+
+ ")" shift, and go to state 353
+
+
+State 322
+
+ 130 inline_export: "(" EXPORT quoted_text ")" .
+
+ $default reduce using rule 130 (inline_export)
+
+
+State 323
+
+ 69 block: value_type_list instr_list .
+
+ $default reduce using rule 69 (block)
+
+
+State 324
+
+ 65 block_instr: BLOCK labeling_opt block END . labeling_opt
+
+ VAR shift, and go to state 22
+
+ $default reduce using rule 32 (labeling_opt)
+
+ bind_var go to state 193
+ labeling_opt go to state 354
+
+
+State 325
+
+ 67 block_instr: IF labeling_opt block END . labeling_opt
+
+ VAR shift, and go to state 22
+
+ $default reduce using rule 32 (labeling_opt)
+
+ bind_var go to state 193
+ labeling_opt go to state 355
+
+
+State 326
+
+ 68 block_instr: IF labeling_opt block ELSE . labeling_opt instr_list END labeling_opt
+
+ VAR shift, and go to state 22
+
+ $default reduce using rule 32 (labeling_opt)
+
+ bind_var go to state 193
+ labeling_opt go to state 356
+
+
+State 327
+
+ 66 block_instr: LOOP labeling_opt block END . labeling_opt
+
+ VAR shift, and go to state 22
+
+ $default reduce using rule 32 (labeling_opt)
+
+ bind_var go to state 193
+ labeling_opt go to state 357
+
+
+State 328
+
+ 7 value_type_list: value_type_list . VALUE_TYPE
+ 13 func_sig: "(" PARAM value_type_list . ")"
+ 14 | "(" PARAM value_type_list . ")" "(" RESULT value_type_list ")"
+
+ ")" shift, and go to state 358
+ VALUE_TYPE shift, and go to state 316
+
+
+State 329
+
+ 7 value_type_list: value_type_list . VALUE_TYPE
+ 15 func_sig: "(" RESULT value_type_list . ")"
+
+ ")" shift, and go to state 359
+ VALUE_TYPE shift, and go to state 316
+
+
+State 330
+
+ 94 func: "(" FUNC bind_var_opt inline_export type_use func_info ")" .
+
+ $default reduce using rule 94 (func)
+
+
+State 331
+
+ 10 global_type: "(" MUT VALUE_TYPE ")" .
+
+ $default reduce using rule 10 (global_type)
+
+
+State 332
+
+ 109 global: "(" GLOBAL bind_var_opt inline_export global_type const_expr ")" .
+
+ $default reduce using rule 109 (global)
+
+
+State 333
+
+ 103 table: "(" TABLE bind_var_opt inline_export_opt elem_type "(" ELEM . var_list ")" ")"
+
+ $default reduce using rule 27 (var_list)
+
+ var_list go to state 360
+
+
+State 334
+
+ 70 expr: "(" . expr1 ")"
+ 75 if_: "(" . THEN instr_list ")" "(" ELSE instr_list ")"
+ 76 | "(" . THEN instr_list ")"
+
+ NOP shift, and go to state 117
+ DROP shift, and go to state 118
+ BLOCK shift, and go to state 168
+ IF shift, and go to state 169
+ THEN shift, and go to state 361
+ LOOP shift, and go to state 170
+ BR shift, and go to state 122
+ BR_IF shift, and go to state 123
+ BR_TABLE shift, and go to state 124
+ CALL shift, and go to state 125
+ CALL_INDIRECT shift, and go to state 126
+ RETURN shift, and go to state 127
+ GET_LOCAL shift, and go to state 128
+ SET_LOCAL shift, and go to state 129
+ TEE_LOCAL shift, and go to state 130
+ GET_GLOBAL shift, and go to state 131
+ SET_GLOBAL shift, and go to state 132
+ LOAD shift, and go to state 133
+ STORE shift, and go to state 134
+ CONST shift, and go to state 135
+ UNARY shift, and go to state 136
+ BINARY shift, and go to state 137
+ COMPARE shift, and go to state 138
+ CONVERT shift, and go to state 139
+ SELECT shift, and go to state 140
+ UNREACHABLE shift, and go to state 141
+ CURRENT_MEMORY shift, and go to state 142
+ GROW_MEMORY shift, and go to state 143
+
+ plain_instr go to state 172
+ expr1 go to state 173
+
+
+State 335
+
+ 77 if_: expr . "(" THEN instr_list ")" "(" ELSE instr_list ")"
+ 78 | expr . "(" THEN instr_list ")"
+ 79 | expr . expr expr
+ 80 | expr . expr
+
+ "(" shift, and go to state 362
+
+ expr go to state 363
+
+
+State 336
+
+ 74 expr1: IF labeling_opt value_type_list if_ .
+
+ $default reduce using rule 74 (expr1)
+
+
+State 337
+
+ 108 memory: "(" MEMORY bind_var_opt "(" DATA text_list ")" . ")"
+
+ ")" shift, and go to state 364
+
+
+State 338
+
+ 107 memory: "(" MEMORY bind_var_opt inline_export "(" DATA text_list . ")" ")"
+
+ ")" shift, and go to state 365
+
+
+State 339
+
+ 111 import_kind: "(" FUNC bind_var_opt . type_use ")"
+ 112 | "(" FUNC bind_var_opt . func_sig ")"
+
+ "(" shift, and go to state 216
+
+ $default reduce using rule 12 (func_sig)
+
+ func_sig go to state 366
+ type_use go to state 367
+
+
+State 340
+
+ 115 import_kind: "(" GLOBAL bind_var_opt . global_type ")"
+
+ "(" shift, and go to state 228
+ VALUE_TYPE shift, and go to state 160
+
+ global_type go to state 368
+
+
+State 341
+
+ 113 import_kind: "(" TABLE bind_var_opt . table_sig ")"
+
+ NAT shift, and go to state 94
+
+ table_sig go to state 369
+ limits go to state 232
+ nat go to state 233
+
+
+State 342
+
+ 114 import_kind: "(" MEMORY bind_var_opt . memory_sig ")"
+
+ NAT shift, and go to state 94
+
+ memory_sig go to state 370
+ limits go to state 249
+ nat go to state 233
+
+
+State 343
+
+ 123 export_kind: "(" FUNC var ")" .
+
+ $default reduce using rule 123 (export_kind)
+
+
+State 344
+
+ 126 export_kind: "(" GLOBAL var ")" .
+
+ $default reduce using rule 126 (export_kind)
+
+
+State 345
+
+ 124 export_kind: "(" TABLE var ")" .
+
+ $default reduce using rule 124 (export_kind)
+
+
+State 346
+
+ 125 export_kind: "(" MEMORY var ")" .
+
+ $default reduce using rule 125 (export_kind)
+
+
+State 347
+
+ 88 func_fields: "(" PARAM value_type_list ")" func_fields .
+
+ $default reduce using rule 88 (func_fields)
+
+
+State 348
+
+ 89 func_fields: "(" PARAM bind_var VALUE_TYPE ")" . func_fields
+
+ "(" shift, and go to state 211
+ NOP shift, and go to state 117
+ DROP shift, and go to state 118
+ BLOCK shift, and go to state 119
+ IF shift, and go to state 120
+ LOOP shift, and go to state 121
+ BR shift, and go to state 122
+ BR_IF shift, and go to state 123
+ BR_TABLE shift, and go to state 124
+ CALL shift, and go to state 125
+ CALL_INDIRECT shift, and go to state 126
+ RETURN shift, and go to state 127
+ GET_LOCAL shift, and go to state 128
+ SET_LOCAL shift, and go to state 129
+ TEE_LOCAL shift, and go to state 130
+ GET_GLOBAL shift, and go to state 131
+ SET_GLOBAL shift, and go to state 132
+ LOAD shift, and go to state 133
+ STORE shift, and go to state 134
+ CONST shift, and go to state 135
+ UNARY shift, and go to state 136
+ BINARY shift, and go to state 137
+ COMPARE shift, and go to state 138
+ CONVERT shift, and go to state 139
+ SELECT shift, and go to state 140
+ UNREACHABLE shift, and go to state 141
+ CURRENT_MEMORY shift, and go to state 142
+ GROW_MEMORY shift, and go to state 143
+
+ $default reduce using rule 81 (instr_list)
+
+ instr go to state 145
+ plain_instr go to state 146
+ block_instr go to state 147
+ expr go to state 148
+ instr_list go to state 149
+ func_fields go to state 371
+ func_body go to state 151
+
+
+State 349
+
+ 70 expr: "(" . expr1 ")"
+ 91 func_body: "(" . LOCAL value_type_list ")" func_body
+ 92 | "(" . LOCAL bind_var VALUE_TYPE ")" func_body
+
+ NOP shift, and go to state 117
+ DROP shift, and go to state 118
+ BLOCK shift, and go to state 168
+ IF shift, and go to state 169
+ LOOP shift, and go to state 170
+ BR shift, and go to state 122
+ BR_IF shift, and go to state 123
+ BR_TABLE shift, and go to state 124
+ CALL shift, and go to state 125
+ CALL_INDIRECT shift, and go to state 126
+ RETURN shift, and go to state 127
+ GET_LOCAL shift, and go to state 128
+ SET_LOCAL shift, and go to state 129
+ TEE_LOCAL shift, and go to state 130
+ GET_GLOBAL shift, and go to state 131
+ SET_GLOBAL shift, and go to state 132
+ LOAD shift, and go to state 133
+ STORE shift, and go to state 134
+ CONST shift, and go to state 135
+ UNARY shift, and go to state 136
+ BINARY shift, and go to state 137
+ COMPARE shift, and go to state 138
+ CONVERT shift, and go to state 139
+ SELECT shift, and go to state 140
+ UNREACHABLE shift, and go to state 141
+ CURRENT_MEMORY shift, and go to state 142
+ GROW_MEMORY shift, and go to state 143
+ LOCAL shift, and go to state 190
+
+ plain_instr go to state 172
+ expr1 go to state 173
+
+
+State 350
+
+ 87 func_fields: "(" RESULT value_type_list ")" func_body .
+
+ $default reduce using rule 87 (func_fields)
+
+
+State 351
+
+ 91 func_body: "(" LOCAL value_type_list ")" func_body .
+
+ $default reduce using rule 91 (func_body)
+
+
+State 352
+
+ 92 func_body: "(" LOCAL bind_var VALUE_TYPE ")" . func_body
+
+ "(" shift, and go to state 349
+ NOP shift, and go to state 117
+ DROP shift, and go to state 118
+ BLOCK shift, and go to state 119
+ IF shift, and go to state 120
+ LOOP shift, and go to state 121
+ BR shift, and go to state 122
+ BR_IF shift, and go to state 123
+ BR_TABLE shift, and go to state 124
+ CALL shift, and go to state 125
+ CALL_INDIRECT shift, and go to state 126
+ RETURN shift, and go to state 127
+ GET_LOCAL shift, and go to state 128
+ SET_LOCAL shift, and go to state 129
+ TEE_LOCAL shift, and go to state 130
+ GET_GLOBAL shift, and go to state 131
+ SET_GLOBAL shift, and go to state 132
+ LOAD shift, and go to state 133
+ STORE shift, and go to state 134
+ CONST shift, and go to state 135
+ UNARY shift, and go to state 136
+ BINARY shift, and go to state 137
+ COMPARE shift, and go to state 138
+ CONVERT shift, and go to state 139
+ SELECT shift, and go to state 140
+ UNREACHABLE shift, and go to state 141
+ CURRENT_MEMORY shift, and go to state 142
+ GROW_MEMORY shift, and go to state 143
+
+ $default reduce using rule 81 (instr_list)
+
+ instr go to state 145
+ plain_instr go to state 146
+ block_instr go to state 147
+ expr go to state 148
+ instr_list go to state 149
+ func_body go to state 372
+
+
+State 353
+
+ 122 inline_import: "(" IMPORT quoted_text quoted_text ")" .
+
+ $default reduce using rule 122 (inline_import)
+
+
+State 354
+
+ 65 block_instr: BLOCK labeling_opt block END labeling_opt .
+
+ $default reduce using rule 65 (block_instr)
+
+
+State 355
+
+ 67 block_instr: IF labeling_opt block END labeling_opt .
+
+ $default reduce using rule 67 (block_instr)
+
+
+State 356
+
+ 68 block_instr: IF labeling_opt block ELSE labeling_opt . instr_list END labeling_opt
+
+ "(" shift, and go to state 213
+ NOP shift, and go to state 117
+ DROP shift, and go to state 118
+ BLOCK shift, and go to state 119
+ IF shift, and go to state 120
+ LOOP shift, and go to state 121
+ BR shift, and go to state 122
+ BR_IF shift, and go to state 123
+ BR_TABLE shift, and go to state 124
+ CALL shift, and go to state 125
+ CALL_INDIRECT shift, and go to state 126
+ RETURN shift, and go to state 127
+ GET_LOCAL shift, and go to state 128
+ SET_LOCAL shift, and go to state 129
+ TEE_LOCAL shift, and go to state 130
+ GET_GLOBAL shift, and go to state 131
+ SET_GLOBAL shift, and go to state 132
+ LOAD shift, and go to state 133
+ STORE shift, and go to state 134
+ CONST shift, and go to state 135
+ UNARY shift, and go to state 136
+ BINARY shift, and go to state 137
+ COMPARE shift, and go to state 138
+ CONVERT shift, and go to state 139
+ SELECT shift, and go to state 140
+ UNREACHABLE shift, and go to state 141
+ CURRENT_MEMORY shift, and go to state 142
+ GROW_MEMORY shift, and go to state 143
+
+ $default reduce using rule 81 (instr_list)
+
+ instr go to state 145
+ plain_instr go to state 146
+ block_instr go to state 147
+ expr go to state 148
+ instr_list go to state 373
+
+
+State 357
+
+ 66 block_instr: LOOP labeling_opt block END labeling_opt .
+
+ $default reduce using rule 66 (block_instr)
+
+
+State 358
+
+ 13 func_sig: "(" PARAM value_type_list ")" .
+ 14 | "(" PARAM value_type_list ")" . "(" RESULT value_type_list ")"
+
+ "(" shift, and go to state 374
+
+ $default reduce using rule 13 (func_sig)
+
+
+State 359
+
+ 15 func_sig: "(" RESULT value_type_list ")" .
+
+ $default reduce using rule 15 (func_sig)
+
+
+State 360
+
+ 28 var_list: var_list . var
+ 103 table: "(" TABLE bind_var_opt inline_export_opt elem_type "(" ELEM var_list . ")" ")"
+
+ ")" shift, and go to state 375
+ NAT shift, and go to state 94
+ VAR shift, and go to state 95
+
+ nat go to state 96
+ var go to state 246
+
+
+State 361
+
+ 75 if_: "(" THEN . instr_list ")" "(" ELSE instr_list ")"
+ 76 | "(" THEN . instr_list ")"
+
+ "(" shift, and go to state 213
+ NOP shift, and go to state 117
+ DROP shift, and go to state 118
+ BLOCK shift, and go to state 119
+ IF shift, and go to state 120
+ LOOP shift, and go to state 121
+ BR shift, and go to state 122
+ BR_IF shift, and go to state 123
+ BR_TABLE shift, and go to state 124
+ CALL shift, and go to state 125
+ CALL_INDIRECT shift, and go to state 126
+ RETURN shift, and go to state 127
+ GET_LOCAL shift, and go to state 128
+ SET_LOCAL shift, and go to state 129
+ TEE_LOCAL shift, and go to state 130
+ GET_GLOBAL shift, and go to state 131
+ SET_GLOBAL shift, and go to state 132
+ LOAD shift, and go to state 133
+ STORE shift, and go to state 134
+ CONST shift, and go to state 135
+ UNARY shift, and go to state 136
+ BINARY shift, and go to state 137
+ COMPARE shift, and go to state 138
+ CONVERT shift, and go to state 139
+ SELECT shift, and go to state 140
+ UNREACHABLE shift, and go to state 141
+ CURRENT_MEMORY shift, and go to state 142
+ GROW_MEMORY shift, and go to state 143
+
+ $default reduce using rule 81 (instr_list)
+
+ instr go to state 145
+ plain_instr go to state 146
+ block_instr go to state 147
+ expr go to state 148
+ instr_list go to state 376
+
+
+State 362
+
+ 70 expr: "(" . expr1 ")"
+ 77 if_: expr "(" . THEN instr_list ")" "(" ELSE instr_list ")"
+ 78 | expr "(" . THEN instr_list ")"
+
+ NOP shift, and go to state 117
+ DROP shift, and go to state 118
+ BLOCK shift, and go to state 168
+ IF shift, and go to state 169
+ THEN shift, and go to state 377
+ LOOP shift, and go to state 170
+ BR shift, and go to state 122
+ BR_IF shift, and go to state 123
+ BR_TABLE shift, and go to state 124
+ CALL shift, and go to state 125
+ CALL_INDIRECT shift, and go to state 126
+ RETURN shift, and go to state 127
+ GET_LOCAL shift, and go to state 128
+ SET_LOCAL shift, and go to state 129
+ TEE_LOCAL shift, and go to state 130
+ GET_GLOBAL shift, and go to state 131
+ SET_GLOBAL shift, and go to state 132
+ LOAD shift, and go to state 133
+ STORE shift, and go to state 134
+ CONST shift, and go to state 135
+ UNARY shift, and go to state 136
+ BINARY shift, and go to state 137
+ COMPARE shift, and go to state 138
+ CONVERT shift, and go to state 139
+ SELECT shift, and go to state 140
+ UNREACHABLE shift, and go to state 141
+ CURRENT_MEMORY shift, and go to state 142
+ GROW_MEMORY shift, and go to state 143
+
+ plain_instr go to state 172
+ expr1 go to state 173
+
+
+State 363
+
+ 79 if_: expr expr . expr
+ 80 | expr expr .
+
+ "(" shift, and go to state 213
+
+ $default reduce using rule 80 (if_)
+
+ expr go to state 378
+
+
+State 364
+
+ 108 memory: "(" MEMORY bind_var_opt "(" DATA text_list ")" ")" .
+
+ $default reduce using rule 108 (memory)
+
+
+State 365
+
+ 107 memory: "(" MEMORY bind_var_opt inline_export "(" DATA text_list ")" . ")"
+
+ ")" shift, and go to state 379
+
+
+State 366
+
+ 112 import_kind: "(" FUNC bind_var_opt func_sig . ")"
+
+ ")" shift, and go to state 380
+
+
+State 367
+
+ 111 import_kind: "(" FUNC bind_var_opt type_use . ")"
+
+ ")" shift, and go to state 381
+
+
+State 368
+
+ 115 import_kind: "(" GLOBAL bind_var_opt global_type . ")"
+
+ ")" shift, and go to state 382
+
+
+State 369
+
+ 113 import_kind: "(" TABLE bind_var_opt table_sig . ")"
+
+ ")" shift, and go to state 383
+
+
+State 370
+
+ 114 import_kind: "(" MEMORY bind_var_opt memory_sig . ")"
+
+ ")" shift, and go to state 384
+
+
+State 371
+
+ 89 func_fields: "(" PARAM bind_var VALUE_TYPE ")" func_fields .
+
+ $default reduce using rule 89 (func_fields)
+
+
+State 372
+
+ 92 func_body: "(" LOCAL bind_var VALUE_TYPE ")" func_body .
+
+ $default reduce using rule 92 (func_body)
+
+
+State 373
+
+ 68 block_instr: IF labeling_opt block ELSE labeling_opt instr_list . END labeling_opt
+
+ END shift, and go to state 385
+
+
+State 374
+
+ 14 func_sig: "(" PARAM value_type_list ")" "(" . RESULT value_type_list ")"
+
+ RESULT shift, and go to state 386
+
+
+State 375
+
+ 103 table: "(" TABLE bind_var_opt inline_export_opt elem_type "(" ELEM var_list ")" . ")"
+
+ ")" shift, and go to state 387
+
+
+State 376
+
+ 75 if_: "(" THEN instr_list . ")" "(" ELSE instr_list ")"
+ 76 | "(" THEN instr_list . ")"
+
+ ")" shift, and go to state 388
+
+
+State 377
+
+ 77 if_: expr "(" THEN . instr_list ")" "(" ELSE instr_list ")"
+ 78 | expr "(" THEN . instr_list ")"
+
+ "(" shift, and go to state 213
+ NOP shift, and go to state 117
+ DROP shift, and go to state 118
+ BLOCK shift, and go to state 119
+ IF shift, and go to state 120
+ LOOP shift, and go to state 121
+ BR shift, and go to state 122
+ BR_IF shift, and go to state 123
+ BR_TABLE shift, and go to state 124
+ CALL shift, and go to state 125
+ CALL_INDIRECT shift, and go to state 126
+ RETURN shift, and go to state 127
+ GET_LOCAL shift, and go to state 128
+ SET_LOCAL shift, and go to state 129
+ TEE_LOCAL shift, and go to state 130
+ GET_GLOBAL shift, and go to state 131
+ SET_GLOBAL shift, and go to state 132
+ LOAD shift, and go to state 133
+ STORE shift, and go to state 134
+ CONST shift, and go to state 135
+ UNARY shift, and go to state 136
+ BINARY shift, and go to state 137
+ COMPARE shift, and go to state 138
+ CONVERT shift, and go to state 139
+ SELECT shift, and go to state 140
+ UNREACHABLE shift, and go to state 141
+ CURRENT_MEMORY shift, and go to state 142
+ GROW_MEMORY shift, and go to state 143
+
+ $default reduce using rule 81 (instr_list)
+
+ instr go to state 145
+ plain_instr go to state 146
+ block_instr go to state 147
+ expr go to state 148
+ instr_list go to state 389
+
+
+State 378
+
+ 79 if_: expr expr expr .
+
+ $default reduce using rule 79 (if_)
+
+
+State 379
+
+ 107 memory: "(" MEMORY bind_var_opt inline_export "(" DATA text_list ")" ")" .
+
+ $default reduce using rule 107 (memory)
+
+
+State 380
+
+ 112 import_kind: "(" FUNC bind_var_opt func_sig ")" .
+
+ $default reduce using rule 112 (import_kind)
+
+
+State 381
+
+ 111 import_kind: "(" FUNC bind_var_opt type_use ")" .
+
+ $default reduce using rule 111 (import_kind)
+
+
+State 382
+
+ 115 import_kind: "(" GLOBAL bind_var_opt global_type ")" .
+
+ $default reduce using rule 115 (import_kind)
+
+
+State 383
+
+ 113 import_kind: "(" TABLE bind_var_opt table_sig ")" .
+
+ $default reduce using rule 113 (import_kind)
+
+
+State 384
+
+ 114 import_kind: "(" MEMORY bind_var_opt memory_sig ")" .
+
+ $default reduce using rule 114 (import_kind)
+
+
+State 385
+
+ 68 block_instr: IF labeling_opt block ELSE labeling_opt instr_list END . labeling_opt
+
+ VAR shift, and go to state 22
+
+ $default reduce using rule 32 (labeling_opt)
+
+ bind_var go to state 193
+ labeling_opt go to state 390
+
+
+State 386
+
+ 14 func_sig: "(" PARAM value_type_list ")" "(" RESULT . value_type_list ")"
+
+ $default reduce using rule 6 (value_type_list)
+
+ value_type_list go to state 391
+
+
+State 387
+
+ 103 table: "(" TABLE bind_var_opt inline_export_opt elem_type "(" ELEM var_list ")" ")" .
+
+ $default reduce using rule 103 (table)
+
+
+State 388
+
+ 75 if_: "(" THEN instr_list ")" . "(" ELSE instr_list ")"
+ 76 | "(" THEN instr_list ")" .
+
+ "(" shift, and go to state 392
+
+ $default reduce using rule 76 (if_)
+
+
+State 389
+
+ 77 if_: expr "(" THEN instr_list . ")" "(" ELSE instr_list ")"
+ 78 | expr "(" THEN instr_list . ")"
+
+ ")" shift, and go to state 393
+
+
+State 390
+
+ 68 block_instr: IF labeling_opt block ELSE labeling_opt instr_list END labeling_opt .
+
+ $default reduce using rule 68 (block_instr)
+
+
+State 391
+
+ 7 value_type_list: value_type_list . VALUE_TYPE
+ 14 func_sig: "(" PARAM value_type_list ")" "(" RESULT value_type_list . ")"
+
+ ")" shift, and go to state 394
+ VALUE_TYPE shift, and go to state 316
+
+
+State 392
+
+ 75 if_: "(" THEN instr_list ")" "(" . ELSE instr_list ")"
+
+ ELSE shift, and go to state 395
+
+
+State 393
+
+ 77 if_: expr "(" THEN instr_list ")" . "(" ELSE instr_list ")"
+ 78 | expr "(" THEN instr_list ")" .
+
+ "(" shift, and go to state 396
+
+ $default reduce using rule 78 (if_)
+
+
+State 394
+
+ 14 func_sig: "(" PARAM value_type_list ")" "(" RESULT value_type_list ")" .
+
+ $default reduce using rule 14 (func_sig)
+
+
+State 395
+
+ 75 if_: "(" THEN instr_list ")" "(" ELSE . instr_list ")"
+
+ "(" shift, and go to state 213
+ NOP shift, and go to state 117
+ DROP shift, and go to state 118
+ BLOCK shift, and go to state 119
+ IF shift, and go to state 120
+ LOOP shift, and go to state 121
+ BR shift, and go to state 122
+ BR_IF shift, and go to state 123
+ BR_TABLE shift, and go to state 124
+ CALL shift, and go to state 125
+ CALL_INDIRECT shift, and go to state 126
+ RETURN shift, and go to state 127
+ GET_LOCAL shift, and go to state 128
+ SET_LOCAL shift, and go to state 129
+ TEE_LOCAL shift, and go to state 130
+ GET_GLOBAL shift, and go to state 131
+ SET_GLOBAL shift, and go to state 132
+ LOAD shift, and go to state 133
+ STORE shift, and go to state 134
+ CONST shift, and go to state 135
+ UNARY shift, and go to state 136
+ BINARY shift, and go to state 137
+ COMPARE shift, and go to state 138
+ CONVERT shift, and go to state 139
+ SELECT shift, and go to state 140
+ UNREACHABLE shift, and go to state 141
+ CURRENT_MEMORY shift, and go to state 142
+ GROW_MEMORY shift, and go to state 143
+
+ $default reduce using rule 81 (instr_list)
+
+ instr go to state 145
+ plain_instr go to state 146
+ block_instr go to state 147
+ expr go to state 148
+ instr_list go to state 397
+
+
+State 396
+
+ 77 if_: expr "(" THEN instr_list ")" "(" . ELSE instr_list ")"
+
+ ELSE shift, and go to state 398
+
+
+State 397
+
+ 75 if_: "(" THEN instr_list ")" "(" ELSE instr_list . ")"
+
+ ")" shift, and go to state 399
+
+
+State 398
+
+ 77 if_: expr "(" THEN instr_list ")" "(" ELSE . instr_list ")"
+
+ "(" shift, and go to state 213
+ NOP shift, and go to state 117
+ DROP shift, and go to state 118
+ BLOCK shift, and go to state 119
+ IF shift, and go to state 120
+ LOOP shift, and go to state 121
+ BR shift, and go to state 122
+ BR_IF shift, and go to state 123
+ BR_TABLE shift, and go to state 124
+ CALL shift, and go to state 125
+ CALL_INDIRECT shift, and go to state 126
+ RETURN shift, and go to state 127
+ GET_LOCAL shift, and go to state 128
+ SET_LOCAL shift, and go to state 129
+ TEE_LOCAL shift, and go to state 130
+ GET_GLOBAL shift, and go to state 131
+ SET_GLOBAL shift, and go to state 132
+ LOAD shift, and go to state 133
+ STORE shift, and go to state 134
+ CONST shift, and go to state 135
+ UNARY shift, and go to state 136
+ BINARY shift, and go to state 137
+ COMPARE shift, and go to state 138
+ CONVERT shift, and go to state 139
+ SELECT shift, and go to state 140
+ UNREACHABLE shift, and go to state 141
+ CURRENT_MEMORY shift, and go to state 142
+ GROW_MEMORY shift, and go to state 143
+
+ $default reduce using rule 81 (instr_list)
+
+ instr go to state 145
+ plain_instr go to state 146
+ block_instr go to state 147
+ expr go to state 148
+ instr_list go to state 400
+
+
+State 399
+
+ 75 if_: "(" THEN instr_list ")" "(" ELSE instr_list ")" .
+
+ $default reduce using rule 75 (if_)
+
+
+State 400
+
+ 77 if_: expr "(" THEN instr_list ")" "(" ELSE instr_list . ")"
+
+ ")" shift, and go to state 401
+
+
+State 401
+
+ 77 if_: expr "(" THEN instr_list ")" "(" ELSE instr_list ")" .
+
+ $default reduce using rule 77 (if_)
diff --git a/src/resolve-names.c b/src/resolve-names.c
index 88c1a0f2..7277831d 100644
--- a/src/resolve-names.c
+++ b/src/resolve-names.c
@@ -23,32 +23,32 @@
#include "ast.h"
#include "ast-parser-lexer-shared.h"
-typedef WasmLabel* LabelPtr;
-WASM_DEFINE_VECTOR(label_ptr, LabelPtr);
+typedef WabtLabel* LabelPtr;
+WABT_DEFINE_VECTOR(label_ptr, LabelPtr);
typedef struct Context {
- WasmAllocator* allocator;
- WasmSourceErrorHandler* error_handler;
- WasmAstLexer* lexer;
- WasmScript* script;
- WasmModule* current_module;
- WasmFunc* current_func;
- WasmExprVisitor visitor;
+ WabtAllocator* allocator;
+ WabtSourceErrorHandler* error_handler;
+ WabtAstLexer* lexer;
+ WabtScript* script;
+ WabtModule* current_module;
+ WabtFunc* current_func;
+ WabtExprVisitor visitor;
LabelPtrVector labels;
- WasmResult result;
+ WabtResult result;
} Context;
-static void WASM_PRINTF_FORMAT(3, 4)
- print_error(Context* ctx, const WasmLocation* loc, const char* fmt, ...) {
- ctx->result = WASM_ERROR;
+static void WABT_PRINTF_FORMAT(3, 4)
+ print_error(Context* ctx, const WabtLocation* loc, const char* fmt, ...) {
+ ctx->result = WABT_ERROR;
va_list args;
va_start(args, fmt);
- wasm_ast_format_error(ctx->error_handler, loc, ctx->lexer, fmt, args);
+ wabt_ast_format_error(ctx->error_handler, loc, ctx->lexer, fmt, args);
va_end(args);
}
-static void push_label(Context* ctx, WasmLabel* label) {
- wasm_append_label_ptr_value(ctx->allocator, &ctx->labels, &label);
+static void push_label(Context* ctx, WabtLabel* label) {
+ wabt_append_label_ptr_value(ctx->allocator, &ctx->labels, &label);
}
static void pop_label(Context* ctx) {
@@ -61,258 +61,258 @@ typedef struct FindDuplicateBindingContext {
const char* desc;
} FindDuplicateBindingContext;
-static void on_duplicate_binding(WasmBindingHashEntry* a,
- WasmBindingHashEntry* b,
+static void on_duplicate_binding(WabtBindingHashEntry* a,
+ WabtBindingHashEntry* b,
void* user_data) {
FindDuplicateBindingContext* fdbc = user_data;
/* choose the location that is later in the file */
- WasmLocation* a_loc = &a->binding.loc;
- WasmLocation* b_loc = &b->binding.loc;
- WasmLocation* loc = a_loc->line > b_loc->line ? a_loc : b_loc;
+ WabtLocation* a_loc = &a->binding.loc;
+ WabtLocation* b_loc = &b->binding.loc;
+ WabtLocation* loc = a_loc->line > b_loc->line ? a_loc : b_loc;
print_error(fdbc->ctx, loc, "redefinition of %s \"" PRIstringslice "\"",
- fdbc->desc, WASM_PRINTF_STRING_SLICE_ARG(a->binding.name));
+ fdbc->desc, WABT_PRINTF_STRING_SLICE_ARG(a->binding.name));
}
static void check_duplicate_bindings(Context* ctx,
- const WasmBindingHash* bindings,
+ const WabtBindingHash* bindings,
const char* desc) {
FindDuplicateBindingContext fdbc;
fdbc.ctx = ctx;
fdbc.desc = desc;
- wasm_find_duplicate_bindings(bindings, on_duplicate_binding, &fdbc);
+ wabt_find_duplicate_bindings(bindings, on_duplicate_binding, &fdbc);
}
-static void resolve_label_var(Context* ctx, WasmVar* var) {
- if (var->type == WASM_VAR_TYPE_NAME) {
+static void resolve_label_var(Context* ctx, WabtVar* var) {
+ if (var->type == WABT_VAR_TYPE_NAME) {
int i;
for (i = ctx->labels.size - 1; i >= 0; --i) {
- WasmLabel* label = ctx->labels.data[i];
- if (wasm_string_slices_are_equal(label, &var->name)) {
- wasm_destroy_string_slice(ctx->allocator, &var->name);
- var->type = WASM_VAR_TYPE_INDEX;
+ WabtLabel* label = ctx->labels.data[i];
+ if (wabt_string_slices_are_equal(label, &var->name)) {
+ wabt_destroy_string_slice(ctx->allocator, &var->name);
+ var->type = WABT_VAR_TYPE_INDEX;
var->index = ctx->labels.size - i - 1;
return;
}
}
print_error(ctx, &var->loc,
"undefined label variable \"" PRIstringslice "\"",
- WASM_PRINTF_STRING_SLICE_ARG(var->name));
+ WABT_PRINTF_STRING_SLICE_ARG(var->name));
}
}
static void resolve_var(Context* ctx,
- const WasmBindingHash* bindings,
- WasmVar* var,
+ const WabtBindingHash* bindings,
+ WabtVar* var,
const char* desc) {
- if (var->type == WASM_VAR_TYPE_NAME) {
- int index = wasm_get_index_from_var(bindings, var);
+ if (var->type == WABT_VAR_TYPE_NAME) {
+ int index = wabt_get_index_from_var(bindings, var);
if (index == -1) {
print_error(ctx, &var->loc,
"undefined %s variable \"" PRIstringslice "\"", desc,
- WASM_PRINTF_STRING_SLICE_ARG(var->name));
+ WABT_PRINTF_STRING_SLICE_ARG(var->name));
return;
}
- wasm_destroy_string_slice(ctx->allocator, &var->name);
+ wabt_destroy_string_slice(ctx->allocator, &var->name);
var->index = index;
- var->type = WASM_VAR_TYPE_INDEX;
+ var->type = WABT_VAR_TYPE_INDEX;
}
}
-static void resolve_func_var(Context* ctx, WasmVar* var) {
+static void resolve_func_var(Context* ctx, WabtVar* var) {
resolve_var(ctx, &ctx->current_module->func_bindings, var, "function");
}
-static void resolve_global_var(Context* ctx, WasmVar* var) {
+static void resolve_global_var(Context* ctx, WabtVar* var) {
resolve_var(ctx, &ctx->current_module->global_bindings, var, "global");
}
-static void resolve_func_type_var(Context* ctx, WasmVar* var) {
+static void resolve_func_type_var(Context* ctx, WabtVar* var) {
resolve_var(ctx, &ctx->current_module->func_type_bindings, var,
"function type");
}
-static void resolve_table_var(Context* ctx, WasmVar* var) {
+static void resolve_table_var(Context* ctx, WabtVar* var) {
resolve_var(ctx, &ctx->current_module->table_bindings, var, "table");
}
-static void resolve_memory_var(Context* ctx, WasmVar* var) {
+static void resolve_memory_var(Context* ctx, WabtVar* var) {
resolve_var(ctx, &ctx->current_module->memory_bindings, var, "memory");
}
-static void resolve_local_var(Context* ctx, WasmVar* var) {
- if (var->type == WASM_VAR_TYPE_NAME) {
- int index = wasm_get_local_index_by_var(ctx->current_func, var);
+static void resolve_local_var(Context* ctx, WabtVar* var) {
+ if (var->type == WABT_VAR_TYPE_NAME) {
+ int index = wabt_get_local_index_by_var(ctx->current_func, var);
if (index == -1) {
print_error(ctx, &var->loc,
"undefined local variable \"" PRIstringslice "\"",
- WASM_PRINTF_STRING_SLICE_ARG(var->name));
+ WABT_PRINTF_STRING_SLICE_ARG(var->name));
return;
}
- wasm_destroy_string_slice(ctx->allocator, &var->name);
+ wabt_destroy_string_slice(ctx->allocator, &var->name);
var->index = index;
- var->type = WASM_VAR_TYPE_INDEX;
+ var->type = WABT_VAR_TYPE_INDEX;
}
}
-static WasmResult begin_block_expr(WasmExpr* expr, void* user_data) {
+static WabtResult begin_block_expr(WabtExpr* expr, void* user_data) {
Context* ctx = user_data;
push_label(ctx, &expr->block.label);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult end_block_expr(WasmExpr* expr, void* user_data) {
+static WabtResult end_block_expr(WabtExpr* expr, void* user_data) {
Context* ctx = user_data;
pop_label(ctx);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult begin_loop_expr(WasmExpr* expr, void* user_data) {
+static WabtResult begin_loop_expr(WabtExpr* expr, void* user_data) {
Context* ctx = user_data;
push_label(ctx, &expr->loop.label);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult end_loop_expr(WasmExpr* expr, void* user_data) {
+static WabtResult end_loop_expr(WabtExpr* expr, void* user_data) {
Context* ctx = user_data;
pop_label(ctx);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_br_expr(WasmExpr* expr, void* user_data) {
+static WabtResult on_br_expr(WabtExpr* expr, void* user_data) {
Context* ctx = user_data;
resolve_label_var(ctx, &expr->br.var);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_br_if_expr(WasmExpr* expr, void* user_data) {
+static WabtResult on_br_if_expr(WabtExpr* expr, void* user_data) {
Context* ctx = user_data;
resolve_label_var(ctx, &expr->br_if.var);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_br_table_expr(WasmExpr* expr, void* user_data) {
+static WabtResult on_br_table_expr(WabtExpr* expr, void* user_data) {
Context* ctx = user_data;
size_t i;
- WasmVarVector* targets = &expr->br_table.targets;
+ WabtVarVector* targets = &expr->br_table.targets;
for (i = 0; i < targets->size; ++i) {
- WasmVar* target = &targets->data[i];
+ WabtVar* target = &targets->data[i];
resolve_label_var(ctx, target);
}
resolve_label_var(ctx, &expr->br_table.default_target);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_call_expr(WasmExpr* expr, void* user_data) {
+static WabtResult on_call_expr(WabtExpr* expr, void* user_data) {
Context* ctx = user_data;
resolve_func_var(ctx, &expr->call.var);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_call_indirect_expr(WasmExpr* expr, void* user_data) {
+static WabtResult on_call_indirect_expr(WabtExpr* expr, void* user_data) {
Context* ctx = user_data;
resolve_func_type_var(ctx, &expr->call_indirect.var);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_get_global_expr(WasmExpr* expr, void* user_data) {
+static WabtResult on_get_global_expr(WabtExpr* expr, void* user_data) {
Context* ctx = user_data;
resolve_global_var(ctx, &expr->get_global.var);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_get_local_expr(WasmExpr* expr, void* user_data) {
+static WabtResult on_get_local_expr(WabtExpr* expr, void* user_data) {
Context* ctx = user_data;
resolve_local_var(ctx, &expr->get_local.var);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult begin_if_expr(WasmExpr* expr, void* user_data) {
+static WabtResult begin_if_expr(WabtExpr* expr, void* user_data) {
Context* ctx = user_data;
push_label(ctx, &expr->if_.true_.label);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult end_if_expr(WasmExpr* expr, void* user_data) {
+static WabtResult end_if_expr(WabtExpr* expr, void* user_data) {
Context* ctx = user_data;
pop_label(ctx);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_set_global_expr(WasmExpr* expr, void* user_data) {
+static WabtResult on_set_global_expr(WabtExpr* expr, void* user_data) {
Context* ctx = user_data;
resolve_global_var(ctx, &expr->set_global.var);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_set_local_expr(WasmExpr* expr, void* user_data) {
+static WabtResult on_set_local_expr(WabtExpr* expr, void* user_data) {
Context* ctx = user_data;
resolve_local_var(ctx, &expr->set_local.var);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_tee_local_expr(WasmExpr* expr, void* user_data) {
+static WabtResult on_tee_local_expr(WabtExpr* expr, void* user_data) {
Context* ctx = user_data;
resolve_local_var(ctx, &expr->tee_local.var);
- return WASM_OK;
+ return WABT_OK;
}
-static void visit_func(Context* ctx, WasmFunc* func) {
+static void visit_func(Context* ctx, WabtFunc* func) {
ctx->current_func = func;
- if (wasm_decl_has_func_type(&func->decl))
+ if (wabt_decl_has_func_type(&func->decl))
resolve_func_type_var(ctx, &func->decl.type_var);
check_duplicate_bindings(ctx, &func->param_bindings, "parameter");
check_duplicate_bindings(ctx, &func->local_bindings, "local");
- wasm_visit_func(func, &ctx->visitor);
+ wabt_visit_func(func, &ctx->visitor);
ctx->current_func = NULL;
}
-static void visit_export(Context* ctx, WasmExport* export) {
+static void visit_export(Context* ctx, WabtExport* export) {
switch (export->kind) {
- case WASM_EXTERNAL_KIND_FUNC:
+ case WABT_EXTERNAL_KIND_FUNC:
resolve_func_var(ctx, &export->var);
break;
- case WASM_EXTERNAL_KIND_TABLE:
+ case WABT_EXTERNAL_KIND_TABLE:
resolve_table_var(ctx, &export->var);
break;
- case WASM_EXTERNAL_KIND_MEMORY:
+ case WABT_EXTERNAL_KIND_MEMORY:
resolve_memory_var(ctx, &export->var);
break;
- case WASM_EXTERNAL_KIND_GLOBAL:
+ case WABT_EXTERNAL_KIND_GLOBAL:
resolve_global_var(ctx, &export->var);
break;
- case WASM_NUM_EXTERNAL_KINDS:
+ case WABT_NUM_EXTERNAL_KINDS:
assert(0);
break;
}
}
-static void visit_global(Context* ctx, WasmGlobal* global) {
- wasm_visit_expr_list(global->init_expr, &ctx->visitor);
+static void visit_global(Context* ctx, WabtGlobal* global) {
+ wabt_visit_expr_list(global->init_expr, &ctx->visitor);
}
-static void visit_elem_segment(Context* ctx, WasmElemSegment* segment) {
+static void visit_elem_segment(Context* ctx, WabtElemSegment* segment) {
size_t i;
resolve_table_var(ctx, &segment->table_var);
- wasm_visit_expr_list(segment->offset, &ctx->visitor);
+ wabt_visit_expr_list(segment->offset, &ctx->visitor);
for (i = 0; i < segment->vars.size; ++i)
resolve_func_var(ctx, &segment->vars.data[i]);
}
-static void visit_data_segment(Context* ctx, WasmDataSegment* segment) {
+static void visit_data_segment(Context* ctx, WabtDataSegment* segment) {
resolve_memory_var(ctx, &segment->memory_var);
- wasm_visit_expr_list(segment->offset, &ctx->visitor);
+ wabt_visit_expr_list(segment->offset, &ctx->visitor);
}
-static void visit_module(Context* ctx, WasmModule* module) {
+static void visit_module(Context* ctx, WabtModule* module) {
ctx->current_module = module;
check_duplicate_bindings(ctx, &module->func_bindings, "function");
check_duplicate_bindings(ctx, &module->global_bindings, "global");
@@ -336,101 +336,101 @@ static void visit_module(Context* ctx, WasmModule* module) {
ctx->current_module = NULL;
}
-static void visit_raw_module(Context* ctx, WasmRawModule* raw_module) {
- if (raw_module->type == WASM_RAW_MODULE_TYPE_TEXT)
+static void visit_raw_module(Context* ctx, WabtRawModule* raw_module) {
+ if (raw_module->type == WABT_RAW_MODULE_TYPE_TEXT)
visit_module(ctx, raw_module->text);
}
-void dummy_source_error_callback(const WasmLocation* loc,
+void dummy_source_error_callback(const WabtLocation* loc,
const char* error,
const char* source_line,
size_t source_line_length,
size_t source_line_column_offset,
void* user_data) {}
-static void visit_command(Context* ctx, WasmCommand* command) {
+static void visit_command(Context* ctx, WabtCommand* command) {
switch (command->type) {
- case WASM_COMMAND_TYPE_MODULE:
+ case WABT_COMMAND_TYPE_MODULE:
visit_module(ctx, &command->module);
break;
- case WASM_COMMAND_TYPE_ACTION:
- case WASM_COMMAND_TYPE_ASSERT_RETURN:
- case WASM_COMMAND_TYPE_ASSERT_RETURN_NAN:
- case WASM_COMMAND_TYPE_ASSERT_TRAP:
- case WASM_COMMAND_TYPE_ASSERT_EXHAUSTION:
- case WASM_COMMAND_TYPE_REGISTER:
+ case WABT_COMMAND_TYPE_ACTION:
+ case WABT_COMMAND_TYPE_ASSERT_RETURN:
+ case WABT_COMMAND_TYPE_ASSERT_RETURN_NAN:
+ case WABT_COMMAND_TYPE_ASSERT_TRAP:
+ case WABT_COMMAND_TYPE_ASSERT_EXHAUSTION:
+ case WABT_COMMAND_TYPE_REGISTER:
/* Don't resolve a module_var, since it doesn't really behave like other
* vars. You can't reference a module by index. */
break;
- case WASM_COMMAND_TYPE_ASSERT_MALFORMED:
+ case WABT_COMMAND_TYPE_ASSERT_MALFORMED:
/* Malformed modules should not be text; the whole point of this
* assertion is to test for malformed binary modules. */
break;
- case WASM_COMMAND_TYPE_ASSERT_INVALID: {
+ case WABT_COMMAND_TYPE_ASSERT_INVALID: {
/* The module may be invalid because the names cannot be resolved; we
* don't want to print errors or fail if that's the case, but we still
* should try to resolve names when possible. */
- WasmSourceErrorHandler new_error_handler;
+ WabtSourceErrorHandler new_error_handler;
new_error_handler.on_error = dummy_source_error_callback;
new_error_handler.source_line_max_length =
ctx->error_handler->source_line_max_length;
Context new_ctx;
- WASM_ZERO_MEMORY(new_ctx);
+ WABT_ZERO_MEMORY(new_ctx);
new_ctx.allocator = ctx->allocator;
new_ctx.error_handler = &new_error_handler;
new_ctx.lexer = ctx->lexer;
new_ctx.visitor = ctx->visitor;
new_ctx.visitor.user_data = &new_ctx;
- new_ctx.result = WASM_OK;
+ new_ctx.result = WABT_OK;
visit_raw_module(&new_ctx, &command->assert_invalid.module);
- wasm_destroy_label_ptr_vector(new_ctx.allocator, &new_ctx.labels);
- if (WASM_FAILED(new_ctx.result)) {
- command->type = WASM_COMMAND_TYPE_ASSERT_INVALID_NON_BINARY;
+ wabt_destroy_label_ptr_vector(new_ctx.allocator, &new_ctx.labels);
+ if (WABT_FAILED(new_ctx.result)) {
+ command->type = WABT_COMMAND_TYPE_ASSERT_INVALID_NON_BINARY;
}
break;
}
- case WASM_COMMAND_TYPE_ASSERT_INVALID_NON_BINARY:
+ case WABT_COMMAND_TYPE_ASSERT_INVALID_NON_BINARY:
/* The only reason a module would be "non-binary" is if the names cannot
* be resolved. So we assume name resolution has already been tried and
* failed, so skip it. */
break;
- case WASM_COMMAND_TYPE_ASSERT_UNLINKABLE:
+ case WABT_COMMAND_TYPE_ASSERT_UNLINKABLE:
visit_raw_module(ctx, &command->assert_unlinkable.module);
break;
- case WASM_COMMAND_TYPE_ASSERT_UNINSTANTIABLE:
+ case WABT_COMMAND_TYPE_ASSERT_UNINSTANTIABLE:
visit_raw_module(ctx, &command->assert_uninstantiable.module);
break;
- case WASM_NUM_COMMAND_TYPES:
+ case WABT_NUM_COMMAND_TYPES:
assert(0);
break;
}
}
-static void visit_script(Context* ctx, WasmScript* script) {
+static void visit_script(Context* ctx, WabtScript* script) {
size_t i;
for (i = 0; i < script->commands.size; ++i)
visit_command(ctx, &script->commands.data[i]);
}
static void init_context(Context* ctx,
- WasmAllocator* allocator,
- WasmAstLexer* lexer,
- WasmScript* script,
- WasmSourceErrorHandler* error_handler) {
- WASM_ZERO_MEMORY(*ctx);
+ WabtAllocator* allocator,
+ WabtAstLexer* lexer,
+ WabtScript* script,
+ WabtSourceErrorHandler* error_handler) {
+ WABT_ZERO_MEMORY(*ctx);
ctx->allocator = allocator;
ctx->lexer = lexer;
ctx->error_handler = error_handler;
- ctx->result = WASM_OK;
+ ctx->result = WABT_OK;
ctx->script = script;
ctx->visitor.user_data = ctx;
ctx->visitor.begin_block_expr = begin_block_expr;
@@ -451,24 +451,24 @@ static void init_context(Context* ctx,
ctx->visitor.on_tee_local_expr = on_tee_local_expr;
}
-WasmResult wasm_resolve_names_module(WasmAllocator* allocator,
- WasmAstLexer* lexer,
- WasmModule* module,
- WasmSourceErrorHandler* error_handler) {
+WabtResult wabt_resolve_names_module(WabtAllocator* allocator,
+ WabtAstLexer* lexer,
+ WabtModule* module,
+ WabtSourceErrorHandler* error_handler) {
Context ctx;
init_context(&ctx, allocator, lexer, NULL, error_handler);
visit_module(&ctx, module);
- wasm_destroy_label_ptr_vector(allocator, &ctx.labels);
+ wabt_destroy_label_ptr_vector(allocator, &ctx.labels);
return ctx.result;
}
-WasmResult wasm_resolve_names_script(WasmAllocator* allocator,
- WasmAstLexer* lexer,
- WasmScript* script,
- WasmSourceErrorHandler* error_handler) {
+WabtResult wabt_resolve_names_script(WabtAllocator* allocator,
+ WabtAstLexer* lexer,
+ WabtScript* script,
+ WabtSourceErrorHandler* error_handler) {
Context ctx;
init_context(&ctx, allocator, lexer, script, error_handler);
visit_script(&ctx, script);
- wasm_destroy_label_ptr_vector(allocator, &ctx.labels);
+ wabt_destroy_label_ptr_vector(allocator, &ctx.labels);
return ctx.result;
}
diff --git a/src/resolve-names.h b/src/resolve-names.h
index f248792d..781454c6 100644
--- a/src/resolve-names.h
+++ b/src/resolve-names.h
@@ -14,27 +14,27 @@
* limitations under the License.
*/
-#ifndef WASM_RESOLVE_NAMES_H_
-#define WASM_RESOLVE_NAMES_H_
+#ifndef WABT_RESOLVE_NAMES_H_
+#define WABT_RESOLVE_NAMES_H_
#include "common.h"
-struct WasmAllocator;
-struct WasmAstLexer;
-struct WasmModule;
-struct WasmScript;
-struct WasmSourceErrorHandler;
+struct WabtAllocator;
+struct WabtAstLexer;
+struct WabtModule;
+struct WabtScript;
+struct WabtSourceErrorHandler;
-WASM_EXTERN_C_BEGIN
-WasmResult wasm_resolve_names_module(struct WasmAllocator*,
- struct WasmAstLexer*,
- struct WasmModule*,
- struct WasmSourceErrorHandler*);
+WABT_EXTERN_C_BEGIN
+WabtResult wabt_resolve_names_module(struct WabtAllocator*,
+ struct WabtAstLexer*,
+ struct WabtModule*,
+ struct WabtSourceErrorHandler*);
-WasmResult wasm_resolve_names_script(struct WasmAllocator*,
- struct WasmAstLexer*,
- struct WasmScript*,
- struct WasmSourceErrorHandler*);
-WASM_EXTERN_C_END
+WabtResult wabt_resolve_names_script(struct WabtAllocator*,
+ struct WabtAstLexer*,
+ struct WabtScript*,
+ struct WabtSourceErrorHandler*);
+WABT_EXTERN_C_END
-#endif /* WASM_RESOLVE_NAMES_H_ */
+#endif /* WABT_RESOLVE_NAMES_H_ */
diff --git a/src/stack-allocator.c b/src/stack-allocator.c
index 1710e329..55aeda9a 100644
--- a/src/stack-allocator.c
+++ b/src/stack-allocator.c
@@ -29,22 +29,22 @@
#define TRACEF(...)
#endif
-#if WASM_STACK_ALLOCATOR_STATS
+#if WABT_STACK_ALLOCATOR_STATS
#include <stdio.h>
-#endif /* WASM_STACK_ALLOCATOR_STATS */
+#endif /* WABT_STACK_ALLOCATOR_STATS */
#define CHUNK_ALIGN 8
#define CHUNK_SIZE (1024 * 1024)
-#define CHUNK_MAX_AVAIL (CHUNK_SIZE - sizeof(WasmStackAllocatorChunk))
+#define CHUNK_MAX_AVAIL (CHUNK_SIZE - sizeof(WabtStackAllocatorChunk))
typedef struct StackAllocatorMark {
- WasmStackAllocatorChunk* chunk;
+ WabtStackAllocatorChunk* chunk;
void* chunk_current;
void* last_allocation;
} StackAllocatorMark;
#ifndef NDEBUG
-static WasmBool is_power_of_two(uint32_t x) {
+static WabtBool is_power_of_two(uint32_t x) {
return x && ((x & (x - 1)) == 0);
}
#endif /* NDEBUG */
@@ -53,54 +53,54 @@ static void* align_up(void* p, size_t align) {
return (void*)(((intptr_t)p + align - 1) & ~(align - 1));
}
-static WasmBool allocation_in_chunk(WasmStackAllocatorChunk* chunk, void* p) {
+static WabtBool allocation_in_chunk(WabtStackAllocatorChunk* chunk, void* p) {
return p >= (void*)chunk && p < chunk->end;
}
-static WasmStackAllocatorChunk* allocate_chunk(
- WasmStackAllocator* stack_allocator,
+static WabtStackAllocatorChunk* allocate_chunk(
+ WabtStackAllocator* stack_allocator,
size_t max_avail,
const char* file,
int line) {
- assert(max_avail < SIZE_MAX - sizeof(WasmStackAllocatorChunk));
- size_t real_size = max_avail + sizeof(WasmStackAllocatorChunk);
+ assert(max_avail < SIZE_MAX - sizeof(WabtStackAllocatorChunk));
+ size_t real_size = max_avail + sizeof(WabtStackAllocatorChunk);
/* common case of allocating a chunk of exactly CHUNK_SIZE */
if (real_size == CHUNK_SIZE) {
if (stack_allocator->next_free) {
- WasmStackAllocatorChunk* chunk = stack_allocator->next_free;
+ WabtStackAllocatorChunk* chunk = stack_allocator->next_free;
stack_allocator->next_free = stack_allocator->next_free->next_free;
return chunk;
}
}
- WasmStackAllocatorChunk* chunk =
- wasm_alloc(stack_allocator->fallback, real_size, CHUNK_ALIGN);
+ WabtStackAllocatorChunk* chunk =
+ wabt_alloc(stack_allocator->fallback, real_size, CHUNK_ALIGN);
if (!chunk) {
if (stack_allocator->has_jmpbuf)
longjmp(stack_allocator->jmpbuf, 1);
- WASM_FATAL("%s:%d: memory allocation failed\n", file, line);
+ WABT_FATAL("%s:%d: memory allocation failed\n", file, line);
}
- /* use the same allocation for the WasmStackAllocatorChunk and its data. + 1
- * skips over the WasmStackAllocatorChunk */
+ /* use the same allocation for the WabtStackAllocatorChunk and its data. + 1
+ * skips over the WabtStackAllocatorChunk */
chunk->start = chunk + 1;
chunk->current = chunk->start;
chunk->end = (void*)((intptr_t)chunk->start + max_avail);
chunk->prev = NULL;
-#if WASM_STACK_ALLOCATOR_STATS
+#if WABT_STACK_ALLOCATOR_STATS
stack_allocator->chunk_alloc_count++;
stack_allocator->total_chunk_bytes += CHUNK_SIZE;
-#endif /* WASM_STACK_ALLOCATOR_STATS */
+#endif /* WABT_STACK_ALLOCATOR_STATS */
return chunk;
}
-static void* stack_alloc(WasmAllocator* allocator,
+static void* stack_alloc(WabtAllocator* allocator,
size_t size,
size_t align,
const char* file,
int line) {
- WasmStackAllocator* stack_allocator = (WasmStackAllocator*)allocator;
+ WabtStackAllocator* stack_allocator = (WabtStackAllocator*)allocator;
assert(is_power_of_two(align));
- WasmStackAllocatorChunk* chunk = stack_allocator->last;
+ WabtStackAllocatorChunk* chunk = stack_allocator->last;
assert(size < SIZE_MAX - align + 1);
size_t alloc_size = size + align - 1;
void* result;
@@ -141,14 +141,14 @@ static void* stack_alloc(WasmAllocator* allocator,
}
#endif /* TRACE_ALLOCATOR */
-#if WASM_STACK_ALLOCATOR_STATS
+#if WABT_STACK_ALLOCATOR_STATS
stack_allocator->alloc_count++;
stack_allocator->total_alloc_bytes += size;
-#endif /* WASM_STACK_ALLOCATOR_STATS */
+#endif /* WABT_STACK_ALLOCATOR_STATS */
return result;
}
-static void* stack_realloc(WasmAllocator* allocator,
+static void* stack_realloc(WabtAllocator* allocator,
void* p,
size_t size,
size_t align,
@@ -157,9 +157,9 @@ static void* stack_realloc(WasmAllocator* allocator,
if (!p)
return stack_alloc(allocator, size, align, file, line);
- WasmStackAllocator* stack_allocator = (WasmStackAllocator*)allocator;
+ WabtStackAllocator* stack_allocator = (WabtStackAllocator*)allocator;
/* TODO(binji): optimize */
- WasmStackAllocatorChunk* chunk = stack_allocator->last;
+ WabtStackAllocatorChunk* chunk = stack_allocator->last;
while (chunk) {
if (allocation_in_chunk(chunk, p))
break;
@@ -183,17 +183,17 @@ static void* stack_realloc(WasmAllocator* allocator,
size_t old_max_size = (size_t)chunk->end - (size_t)p;
size_t copy_size = size > old_max_size ? old_max_size : size;
memmove(result, p, copy_size);
-#if WASM_STACK_ALLOCATOR_STATS
+#if WABT_STACK_ALLOCATOR_STATS
/* count this is as a realloc, not an alloc */
stack_allocator->alloc_count--;
stack_allocator->realloc_count++;
stack_allocator->total_alloc_bytes -= size;
stack_allocator->total_realloc_bytes += size;
-#endif /* WASM_STACK_ALLOCATOR_STATS */
+#endif /* WABT_STACK_ALLOCATOR_STATS */
return result;
}
-static void stack_free(WasmAllocator* allocator,
+static void stack_free(WabtAllocator* allocator,
void* p,
const char* file,
int line) {
@@ -201,41 +201,41 @@ static void stack_free(WasmAllocator* allocator,
return;
TRACEF("%s:%d: stack_free(%p)\n", file, line, p);
- WasmStackAllocator* stack_allocator = (WasmStackAllocator*)allocator;
+ WabtStackAllocator* stack_allocator = (WabtStackAllocator*)allocator;
-#if WASM_STACK_ALLOCATOR_STATS
+#if WABT_STACK_ALLOCATOR_STATS
stack_allocator->free_count++;
-#endif /* WASM_STACK_ALLOCATOR_STATS */
+#endif /* WABT_STACK_ALLOCATOR_STATS */
if (p != stack_allocator->last_allocation)
return;
- WasmStackAllocatorChunk* chunk = stack_allocator->last;
+ WabtStackAllocatorChunk* chunk = stack_allocator->last;
assert(allocation_in_chunk(chunk, p));
chunk->current = p;
}
-static void stack_destroy(WasmAllocator* allocator) {
- WasmStackAllocator* stack_allocator = (WasmStackAllocator*)allocator;
+static void stack_destroy(WabtAllocator* allocator) {
+ WabtStackAllocator* stack_allocator = (WabtStackAllocator*)allocator;
/* destroy the free chunks */
- WasmStackAllocatorChunk* chunk = stack_allocator->next_free;
+ WabtStackAllocatorChunk* chunk = stack_allocator->next_free;
while (chunk) {
- WasmStackAllocatorChunk* next_free = chunk->next_free;
- wasm_free(stack_allocator->fallback, chunk);
+ WabtStackAllocatorChunk* next_free = chunk->next_free;
+ wabt_free(stack_allocator->fallback, chunk);
chunk = next_free;
}
/* destroy the used chunks */
chunk = stack_allocator->last;
while (chunk) {
- WasmStackAllocatorChunk* prev = chunk->prev;
- wasm_free(stack_allocator->fallback, chunk);
+ WabtStackAllocatorChunk* prev = chunk->prev;
+ wabt_free(stack_allocator->fallback, chunk);
chunk = prev;
}
}
-static WasmAllocatorMark stack_mark(WasmAllocator* allocator) {
- WasmStackAllocator* stack_allocator = (WasmStackAllocator*)allocator;
+static WabtAllocatorMark stack_mark(WabtAllocator* allocator) {
+ WabtStackAllocator* stack_allocator = (WabtStackAllocator*)allocator;
/* allocate the space for the mark, but copy the current stack state now, so
* when we reset we reset before the mark was allocated */
@@ -245,24 +245,24 @@ static WasmAllocatorMark stack_mark(WasmAllocator* allocator) {
mark.last_allocation = stack_allocator->last_allocation;
StackAllocatorMark* allocated_mark = stack_alloc(
- allocator, sizeof(StackAllocatorMark), WASM_DEFAULT_ALIGN, NULL, 0);
-#if WASM_STACK_ALLOCATOR_STATS
+ allocator, sizeof(StackAllocatorMark), WABT_DEFAULT_ALIGN, NULL, 0);
+#if WABT_STACK_ALLOCATOR_STATS
/* don't count this allocation */
stack_allocator->alloc_count--;
stack_allocator->total_alloc_bytes -= sizeof(StackAllocatorMark);
-#endif /* WASM_STACK_ALLOCATOR_STATS */
+#endif /* WABT_STACK_ALLOCATOR_STATS */
*allocated_mark = mark;
return allocated_mark;
}
-static void stack_reset_to_mark(WasmAllocator* allocator,
- WasmAllocatorMark mark) {
- WasmStackAllocator* stack_allocator = (WasmStackAllocator*)allocator;
+static void stack_reset_to_mark(WabtAllocator* allocator,
+ WabtAllocatorMark mark) {
+ WabtStackAllocator* stack_allocator = (WabtStackAllocator*)allocator;
StackAllocatorMark* stack_mark = (StackAllocatorMark*)mark;
- WasmStackAllocatorChunk* chunk = stack_allocator->last;
+ WabtStackAllocatorChunk* chunk = stack_allocator->last;
while (chunk && chunk != stack_mark->chunk) {
- WasmStackAllocatorChunk* prev = chunk->prev;
+ WabtStackAllocatorChunk* prev = chunk->prev;
/* reset this chunk for future use, and thread it into the free list */
chunk->current = chunk->start;
chunk->next_free = stack_allocator->next_free;
@@ -276,7 +276,7 @@ static void stack_reset_to_mark(WasmAllocator* allocator,
stack_allocator->last_allocation = stack_mark->last_allocation;
}
-#if WASM_STACK_ALLOCATOR_STATS
+#if WABT_STACK_ALLOCATOR_STATS
static const char* human_readable(size_t count) {
/* printing a size_t in decimal requires ceil(sizeof(size_t) * 8 / log2(10))
* characters. We want to add one comma for each group of three digits, so
@@ -304,12 +304,12 @@ static const char* human_readable(size_t count) {
}
return buffer;
}
-#endif /* WASM_STACK_ALLOCATOR_STATS */
+#endif /* WABT_STACK_ALLOCATOR_STATS */
-static void stack_print_stats(WasmAllocator* allocator) {
-#if WASM_STACK_ALLOCATOR_STATS
+static void stack_print_stats(WabtAllocator* allocator) {
+#if WABT_STACK_ALLOCATOR_STATS
#define VALUE(name) human_readable(stack_allocator->name)
- WasmStackAllocator* stack_allocator = (WasmStackAllocator*)allocator;
+ WabtStackAllocator* stack_allocator = (WabtStackAllocator*)allocator;
printf("STACK ALLOCATOR STATS:\n");
printf("===============================================\n");
printf("chunk_alloc_count: %s\n", VALUE(chunk_alloc_count));
@@ -320,18 +320,18 @@ static void stack_print_stats(WasmAllocator* allocator) {
printf("total_alloc_bytes: %s\n", VALUE(total_alloc_bytes));
printf("total_realloc_bytes: %s\n", VALUE(total_realloc_bytes));
#undef VALUE
-#endif /* WASM_STACK_ALLOCATOR_STATS */
+#endif /* WABT_STACK_ALLOCATOR_STATS */
}
-static int stack_setjmp_handler(WasmAllocator* allocator) {
- WasmStackAllocator* stack_allocator = (WasmStackAllocator*)allocator;
- stack_allocator->has_jmpbuf = WASM_TRUE;
+static int stack_setjmp_handler(WabtAllocator* allocator) {
+ WabtStackAllocator* stack_allocator = (WabtStackAllocator*)allocator;
+ stack_allocator->has_jmpbuf = WABT_TRUE;
return setjmp(stack_allocator->jmpbuf);
}
-WasmResult wasm_init_stack_allocator(WasmStackAllocator* stack_allocator,
- WasmAllocator* fallback) {
- WASM_ZERO_MEMORY(*stack_allocator);
+WabtResult wabt_init_stack_allocator(WabtStackAllocator* stack_allocator,
+ WabtAllocator* fallback) {
+ WABT_ZERO_MEMORY(*stack_allocator);
stack_allocator->allocator.alloc = stack_alloc;
stack_allocator->allocator.realloc = stack_realloc;
stack_allocator->allocator.free = stack_free;
@@ -342,13 +342,13 @@ WasmResult wasm_init_stack_allocator(WasmStackAllocator* stack_allocator,
stack_allocator->allocator.setjmp_handler = stack_setjmp_handler;
stack_allocator->fallback = fallback;
- WasmStackAllocatorChunk* chunk =
+ WabtStackAllocatorChunk* chunk =
allocate_chunk(stack_allocator, CHUNK_MAX_AVAIL, __FILE__, __LINE__);
chunk->prev = NULL;
stack_allocator->first = stack_allocator->last = chunk;
- return WASM_OK;
+ return WABT_OK;
}
-void wasm_destroy_stack_allocator(WasmStackAllocator* stack_allocator) {
- stack_destroy((WasmAllocator*)stack_allocator);
+void wabt_destroy_stack_allocator(WabtStackAllocator* stack_allocator) {
+ stack_destroy((WabtAllocator*)stack_allocator);
}
diff --git a/src/stack-allocator.h b/src/stack-allocator.h
index c65f6519..1da8de4e 100644
--- a/src/stack-allocator.h
+++ b/src/stack-allocator.h
@@ -14,37 +14,37 @@
* limitations under the License.
*/
-#ifndef WASM_STACK_ALLOCATOR_H_
-#define WASM_STACK_ALLOCATOR_H_
+#ifndef WABT_STACK_ALLOCATOR_H_
+#define WABT_STACK_ALLOCATOR_H_
#include "allocator.h"
#include "common.h"
#include <setjmp.h>
-#define WASM_STACK_ALLOCATOR_STATS 0
+#define WABT_STACK_ALLOCATOR_STATS 0
-typedef struct WasmStackAllocatorChunk {
+typedef struct WabtStackAllocatorChunk {
void* start;
void* current;
void* end;
union {
- struct WasmStackAllocatorChunk* prev;
- struct WasmStackAllocatorChunk* next_free;
+ struct WabtStackAllocatorChunk* prev;
+ struct WabtStackAllocatorChunk* next_free;
};
-} WasmStackAllocatorChunk;
+} WabtStackAllocatorChunk;
-typedef struct WasmStackAllocator {
- WasmAllocator allocator;
- WasmStackAllocatorChunk* first;
- WasmStackAllocatorChunk* last;
- WasmAllocator* fallback;
+typedef struct WabtStackAllocator {
+ WabtAllocator allocator;
+ WabtStackAllocatorChunk* first;
+ WabtStackAllocatorChunk* last;
+ WabtAllocator* fallback;
void* last_allocation;
- WasmStackAllocatorChunk* next_free;
- WasmBool has_jmpbuf;
+ WabtStackAllocatorChunk* next_free;
+ WabtBool has_jmpbuf;
jmp_buf jmpbuf;
-#if WASM_STACK_ALLOCATOR_STATS
+#if WABT_STACK_ALLOCATOR_STATS
/* some random stats */
size_t chunk_alloc_count;
size_t alloc_count;
@@ -53,13 +53,13 @@ typedef struct WasmStackAllocator {
size_t total_chunk_bytes;
size_t total_alloc_bytes;
size_t total_realloc_bytes;
-#endif /* WASM_STACK_ALLOCATOR_STATS */
-} WasmStackAllocator;
+#endif /* WABT_STACK_ALLOCATOR_STATS */
+} WabtStackAllocator;
-WASM_EXTERN_C_BEGIN
-WasmResult wasm_init_stack_allocator(WasmStackAllocator*,
- WasmAllocator* fallback);
-void wasm_destroy_stack_allocator(WasmStackAllocator*);
-WASM_EXTERN_C_END
+WABT_EXTERN_C_BEGIN
+WabtResult wabt_init_stack_allocator(WabtStackAllocator*,
+ WabtAllocator* fallback);
+void wabt_destroy_stack_allocator(WabtStackAllocator*);
+WABT_EXTERN_C_END
-#endif /* WASM_STACK_ALLOCATOR_H_ */
+#endif /* WABT_STACK_ALLOCATOR_H_ */
diff --git a/src/stream.c b/src/stream.c
index bf56b0bb..2bb3a6ac 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -22,43 +22,43 @@
#define DUMP_OCTETS_PER_LINE 16
#define DUMP_OCTETS_PER_GROUP 2
-static WasmFileStream s_stdout_stream;
-static WasmFileStream s_stderr_stream;
+static WabtFileStream s_stdout_stream;
+static WabtFileStream s_stderr_stream;
-void wasm_init_stream(WasmStream* stream,
- WasmWriter* writer,
- WasmStream* log_stream) {
+void wabt_init_stream(WabtStream* stream,
+ WabtWriter* writer,
+ WabtStream* log_stream) {
stream->writer = writer;
stream->offset = 0;
- stream->result = WASM_OK;
+ stream->result = WABT_OK;
stream->log_stream = log_stream;
}
-void wasm_init_file_stream_from_existing(WasmFileStream* stream, FILE* file) {
- wasm_init_file_writer_existing(&stream->writer, file);
- wasm_init_stream(&stream->base, &stream->writer.base, NULL);
+void wabt_init_file_stream_from_existing(WabtFileStream* stream, FILE* file) {
+ wabt_init_file_writer_existing(&stream->writer, file);
+ wabt_init_stream(&stream->base, &stream->writer.base, NULL);
}
-WasmStream* wasm_init_stdout_stream(void) {
- wasm_init_file_stream_from_existing(&s_stdout_stream, stdout);
+WabtStream* wabt_init_stdout_stream(void) {
+ wabt_init_file_stream_from_existing(&s_stdout_stream, stdout);
return &s_stdout_stream.base;
}
-WasmStream* wasm_init_stderr_stream(void) {
- wasm_init_file_stream_from_existing(&s_stderr_stream, stderr);
+WabtStream* wabt_init_stderr_stream(void) {
+ wabt_init_file_stream_from_existing(&s_stderr_stream, stderr);
return &s_stderr_stream.base;
}
-void wasm_write_data_at(WasmStream* stream,
+void wabt_write_data_at(WabtStream* stream,
size_t offset,
const void* src,
size_t size,
- WasmPrintChars print_chars,
+ WabtPrintChars print_chars,
const char* desc) {
- if (WASM_FAILED(stream->result))
+ if (WABT_FAILED(stream->result))
return;
if (stream->log_stream) {
- wasm_write_memory_dump(stream->log_stream, src, size, offset, print_chars,
+ wabt_write_memory_dump(stream->log_stream, src, size, offset, print_chars,
NULL, desc);
}
if (stream->writer->write_data) {
@@ -67,23 +67,23 @@ void wasm_write_data_at(WasmStream* stream,
}
}
-void wasm_write_data(WasmStream* stream,
+void wabt_write_data(WabtStream* stream,
const void* src,
size_t size,
const char* desc) {
- wasm_write_data_at(stream, stream->offset, src, size, WASM_DONT_PRINT_CHARS,
+ wabt_write_data_at(stream, stream->offset, src, size, WABT_DONT_PRINT_CHARS,
desc);
stream->offset += size;
}
-void wasm_move_data(WasmStream* stream,
+void wabt_move_data(WabtStream* stream,
size_t dst_offset,
size_t src_offset,
size_t size) {
- if (WASM_FAILED(stream->result))
+ if (WABT_FAILED(stream->result))
return;
if (stream->log_stream) {
- wasm_writef(stream->log_stream, "; move data: [%" PRIzx ", %" PRIzx
+ wabt_writef(stream->log_stream, "; move data: [%" PRIzx ", %" PRIzx
") -> [%" PRIzx ", %" PRIzx ")\n",
src_offset, src_offset + size, dst_offset, dst_offset + size);
}
@@ -93,36 +93,36 @@ void wasm_move_data(WasmStream* stream,
}
}
-void wasm_writef(WasmStream* stream, const char* format, ...) {
- WASM_SNPRINTF_ALLOCA(buffer, length, format);
- wasm_write_data(stream, buffer, length, NULL);
+void wabt_writef(WabtStream* stream, const char* format, ...) {
+ WABT_SNPRINTF_ALLOCA(buffer, length, format);
+ wabt_write_data(stream, buffer, length, NULL);
}
-void wasm_write_u8(WasmStream* stream, uint32_t value, const char* desc) {
+void wabt_write_u8(WabtStream* stream, uint32_t value, const char* desc) {
assert(value <= UINT8_MAX);
uint8_t value8 = value;
- wasm_write_data_at(stream, stream->offset, &value8, sizeof(value8),
- WASM_DONT_PRINT_CHARS, desc);
+ wabt_write_data_at(stream, stream->offset, &value8, sizeof(value8),
+ WABT_DONT_PRINT_CHARS, desc);
stream->offset += sizeof(value8);
}
-void wasm_write_u32(WasmStream* stream, uint32_t value, const char* desc) {
- wasm_write_data_at(stream, stream->offset, &value, sizeof(value),
- WASM_DONT_PRINT_CHARS, desc);
+void wabt_write_u32(WabtStream* stream, uint32_t value, const char* desc) {
+ wabt_write_data_at(stream, stream->offset, &value, sizeof(value),
+ WABT_DONT_PRINT_CHARS, desc);
stream->offset += sizeof(value);
}
-void wasm_write_u64(WasmStream* stream, uint64_t value, const char* desc) {
- wasm_write_data_at(stream, stream->offset, &value, sizeof(value),
- WASM_DONT_PRINT_CHARS, desc);
+void wabt_write_u64(WabtStream* stream, uint64_t value, const char* desc) {
+ wabt_write_data_at(stream, stream->offset, &value, sizeof(value),
+ WABT_DONT_PRINT_CHARS, desc);
stream->offset += sizeof(value);
}
-void wasm_write_memory_dump(WasmStream* stream,
+void wabt_write_memory_dump(WabtStream* stream,
const void* start,
size_t size,
size_t offset,
- WasmPrintChars print_chars,
+ WabtPrintChars print_chars,
const char* prefix,
const char* desc) {
const uint8_t* p = start;
@@ -131,32 +131,32 @@ void wasm_write_memory_dump(WasmStream* stream,
const uint8_t* line = p;
const uint8_t* line_end = p + DUMP_OCTETS_PER_LINE;
if (prefix)
- wasm_writef(stream, "%s", prefix);
- wasm_writef(stream, "%07" PRIzx ": ", (size_t)p - (size_t)start + offset);
+ wabt_writef(stream, "%s", prefix);
+ wabt_writef(stream, "%07" PRIzx ": ", (size_t)p - (size_t)start + offset);
while (p < line_end) {
int i;
for (i = 0; i < DUMP_OCTETS_PER_GROUP; ++i, ++p) {
if (p < end) {
- wasm_writef(stream, "%02x", *p);
+ wabt_writef(stream, "%02x", *p);
} else {
- wasm_write_char(stream, ' ');
- wasm_write_char(stream, ' ');
+ wabt_write_char(stream, ' ');
+ wabt_write_char(stream, ' ');
}
}
- wasm_write_char(stream, ' ');
+ wabt_write_char(stream, ' ');
}
- if (print_chars == WASM_PRINT_CHARS) {
- wasm_write_char(stream, ' ');
+ if (print_chars == WABT_PRINT_CHARS) {
+ wabt_write_char(stream, ' ');
p = line;
int i;
for (i = 0; i < DUMP_OCTETS_PER_LINE && p < end; ++i, ++p)
- wasm_write_char(stream, isprint(*p) ? *p : '.');
+ wabt_write_char(stream, isprint(*p) ? *p : '.');
}
/* if there are multiple lines, only print the desc on the last one */
if (p >= end && desc)
- wasm_writef(stream, " ; %s", desc);
- wasm_write_char(stream, '\n');
+ wabt_writef(stream, " ; %s", desc);
+ wabt_write_char(stream, '\n');
}
}
diff --git a/src/stream.h b/src/stream.h
index 8fc9af41..11e51407 100644
--- a/src/stream.h
+++ b/src/stream.h
@@ -14,88 +14,88 @@
* limitations under the License.
*/
-#ifndef WASM_STREAM_H_
-#define WASM_STREAM_H_
+#ifndef WABT_STREAM_H_
+#define WABT_STREAM_H_
#include <stdio.h>
#include "common.h"
#include "writer.h"
-typedef struct WasmStream {
- WasmWriter* writer;
+typedef struct WabtStream {
+ WabtWriter* writer;
size_t offset;
- WasmResult result;
+ WabtResult result;
/* if non-NULL, log all writes to this stream */
- struct WasmStream* log_stream;
-} WasmStream;
+ struct WabtStream* log_stream;
+} WabtStream;
-typedef struct WasmFileStream {
- WasmStream base;
- WasmFileWriter writer;
-} WasmFileStream;
+typedef struct WabtFileStream {
+ WabtStream base;
+ WabtFileWriter writer;
+} WabtFileStream;
/* whether to display the ASCII characters in the debug output for
- * wasm_write_memory */
-typedef enum WasmPrintChars {
- WASM_DONT_PRINT_CHARS,
- WASM_PRINT_CHARS,
-} WasmPrintChars;
+ * wabt_write_memory */
+typedef enum WabtPrintChars {
+ WABT_DONT_PRINT_CHARS,
+ WABT_PRINT_CHARS,
+} WabtPrintChars;
-WASM_EXTERN_C_BEGIN
+WABT_EXTERN_C_BEGIN
-void wasm_init_stream(WasmStream* stream,
- WasmWriter* writer,
- WasmStream* log_stream);
-void wasm_init_file_stream_from_existing(WasmFileStream* stream, FILE* file);
-WasmStream* wasm_init_stdout_stream(void);
-WasmStream* wasm_init_stderr_stream(void);
+void wabt_init_stream(WabtStream* stream,
+ WabtWriter* writer,
+ WabtStream* log_stream);
+void wabt_init_file_stream_from_existing(WabtFileStream* stream, FILE* file);
+WabtStream* wabt_init_stdout_stream(void);
+WabtStream* wabt_init_stderr_stream(void);
-/* helper functions for writing to a WasmStream. the |desc| parameter is
+/* helper functions for writing to a WabtStream. the |desc| parameter is
* optional, and will be appended to the log stream if |stream.log_stream| is
* non-NULL. */
-void wasm_write_data_at(WasmStream*,
+void wabt_write_data_at(WabtStream*,
size_t offset,
const void* src,
size_t size,
- WasmPrintChars print_chars,
+ WabtPrintChars print_chars,
const char* desc);
-void wasm_write_data(WasmStream*,
+void wabt_write_data(WabtStream*,
const void* src,
size_t size,
const char* desc);
-void wasm_move_data(WasmStream*,
+void wabt_move_data(WabtStream*,
size_t dst_offset,
size_t src_offset,
size_t size);
-void WASM_PRINTF_FORMAT(2, 3) wasm_writef(WasmStream*, const char* format, ...);
+void WABT_PRINTF_FORMAT(2, 3) wabt_writef(WabtStream*, const char* format, ...);
/* specified as uint32_t instead of uint8_t so we can check if the value given
* is in range before wrapping */
-void wasm_write_u8(WasmStream*, uint32_t value, const char* desc);
-void wasm_write_u32(WasmStream*, uint32_t value, const char* desc);
-void wasm_write_u64(WasmStream*, uint64_t value, const char* desc);
+void wabt_write_u8(WabtStream*, uint32_t value, const char* desc);
+void wabt_write_u32(WabtStream*, uint32_t value, const char* desc);
+void wabt_write_u64(WabtStream*, uint64_t value, const char* desc);
-static WASM_INLINE void wasm_write_char(WasmStream* stream, char c) {
- wasm_write_u8(stream, c, NULL);
+static WABT_INLINE void wabt_write_char(WabtStream* stream, char c) {
+ wabt_write_u8(stream, c, NULL);
}
/* dump memory as text, similar to the xxd format */
-void wasm_write_memory_dump(WasmStream*,
+void wabt_write_memory_dump(WabtStream*,
const void* start,
size_t size,
size_t offset,
- WasmPrintChars print_chars,
+ WabtPrintChars print_chars,
const char* prefix,
const char* desc);
-static WASM_INLINE void wasm_write_output_buffer_memory_dump(
- WasmStream* stream,
- struct WasmOutputBuffer* buf) {
- wasm_write_memory_dump(stream, buf->start, buf->size, 0,
- WASM_DONT_PRINT_CHARS, NULL, NULL);
+static WABT_INLINE void wabt_write_output_buffer_memory_dump(
+ WabtStream* stream,
+ struct WabtOutputBuffer* buf) {
+ wabt_write_memory_dump(stream, buf->start, buf->size, 0,
+ WABT_DONT_PRINT_CHARS, NULL, NULL);
}
-WASM_EXTERN_C_END
+WABT_EXTERN_C_END
-#endif /* WASM_STREAM_H_ */
+#endif /* WABT_STREAM_H_ */
diff --git a/src/tools/wasm-interp.c b/src/tools/wasm-interp.c
index 4a8a9c58..aadea1d3 100644
--- a/src/tools/wasm-interp.c
+++ b/src/tools/wasm-interp.c
@@ -35,26 +35,26 @@
static const char* s_trap_strings[] = {FOREACH_INTERPRETER_RESULT(V)};
#undef V
-static WasmBool s_verbose;
+static WabtBool s_verbose;
static const char* s_infile;
-static WasmReadBinaryOptions s_read_binary_options =
- WASM_READ_BINARY_OPTIONS_DEFAULT;
-static WasmInterpreterThreadOptions s_thread_options =
- WASM_INTERPRETER_THREAD_OPTIONS_DEFAULT;
-static WasmBool s_trace;
-static WasmBool s_spec;
-static WasmBool s_run_all_exports;
-static WasmBool s_use_libc_allocator;
-static WasmStream* s_stdout_stream;
+static WabtReadBinaryOptions s_read_binary_options =
+ WABT_READ_BINARY_OPTIONS_DEFAULT;
+static WabtInterpreterThreadOptions s_thread_options =
+ WABT_INTERPRETER_THREAD_OPTIONS_DEFAULT;
+static WabtBool s_trace;
+static WabtBool s_spec;
+static WabtBool s_run_all_exports;
+static WabtBool s_use_libc_allocator;
+static WabtStream* s_stdout_stream;
-static WasmBinaryErrorHandler s_error_handler =
- WASM_BINARY_ERROR_HANDLER_DEFAULT;
+static WabtBinaryErrorHandler s_error_handler =
+ WABT_BINARY_ERROR_HANDLER_DEFAULT;
-static WasmFileWriter s_log_stream_writer;
-static WasmStream s_log_stream;
+static WabtFileWriter s_log_stream_writer;
+static WabtStream s_log_stream;
-#define NOPE WASM_OPTION_NO_ARGUMENT
-#define YEP WASM_OPTION_HAS_ARGUMENT
+#define NOPE WABT_OPTION_NO_ARGUMENT
+#define YEP WABT_OPTION_HAS_ARGUMENT
typedef enum RunVerbosity {
RUN_QUIET = 0,
@@ -94,7 +94,7 @@ static const char s_description[] =
" # value stack size to 100 elements\n"
" $ wasm-interp test.wasm -V 100 --run-all-exports\n";
-static WasmOption s_options[] = {
+static WabtOption s_options[] = {
{FLAG_VERBOSE, 'v', "verbose", NULL, NOPE,
"use multiple times for more info"},
{FLAG_HELP, 'h', "help", NULL, NOPE, "print this help message"},
@@ -110,21 +110,21 @@ static WasmOption s_options[] = {
{FLAG_USE_LIBC_ALLOCATOR, 0, "use-libc-allocator", NULL, NOPE,
"use malloc, free, etc. instead of stack allocator"},
};
-WASM_STATIC_ASSERT(NUM_FLAGS == WASM_ARRAY_SIZE(s_options));
+WABT_STATIC_ASSERT(NUM_FLAGS == WABT_ARRAY_SIZE(s_options));
-static void on_option(struct WasmOptionParser* parser,
- struct WasmOption* option,
+static void on_option(struct WabtOptionParser* parser,
+ struct WabtOption* option,
const char* argument) {
switch (option->id) {
case FLAG_VERBOSE:
s_verbose++;
- wasm_init_file_writer_existing(&s_log_stream_writer, stdout);
- wasm_init_stream(&s_log_stream, &s_log_stream_writer.base, NULL);
+ wabt_init_file_writer_existing(&s_log_stream_writer, stdout);
+ wabt_init_stream(&s_log_stream, &s_log_stream_writer.base, NULL);
s_read_binary_options.log_stream = &s_log_stream;
break;
case FLAG_HELP:
- wasm_print_help(parser, PROGRAM_NAME);
+ wabt_print_help(parser, PROGRAM_NAME);
exit(0);
break;
@@ -139,53 +139,53 @@ static void on_option(struct WasmOptionParser* parser,
break;
case FLAG_TRACE:
- s_trace = WASM_TRUE;
+ s_trace = WABT_TRUE;
break;
case FLAG_SPEC:
- s_spec = WASM_TRUE;
+ s_spec = WABT_TRUE;
break;
case FLAG_RUN_ALL_EXPORTS:
- s_run_all_exports = WASM_TRUE;
+ s_run_all_exports = WABT_TRUE;
break;
case FLAG_USE_LIBC_ALLOCATOR:
- s_use_libc_allocator = WASM_TRUE;
+ s_use_libc_allocator = WABT_TRUE;
break;
}
}
-static void on_argument(struct WasmOptionParser* parser, const char* argument) {
+static void on_argument(struct WabtOptionParser* parser, const char* argument) {
s_infile = argument;
}
-static void on_option_error(struct WasmOptionParser* parser,
+static void on_option_error(struct WabtOptionParser* parser,
const char* message) {
- WASM_FATAL("%s\n", message);
+ WABT_FATAL("%s\n", message);
}
static void parse_options(int argc, char** argv) {
- WasmOptionParser parser;
- WASM_ZERO_MEMORY(parser);
+ WabtOptionParser parser;
+ WABT_ZERO_MEMORY(parser);
parser.description = s_description;
parser.options = s_options;
- parser.num_options = WASM_ARRAY_SIZE(s_options);
+ parser.num_options = WABT_ARRAY_SIZE(s_options);
parser.on_option = on_option;
parser.on_argument = on_argument;
parser.on_error = on_option_error;
- wasm_parse_options(&parser, argc, argv);
+ wabt_parse_options(&parser, argc, argv);
if (s_spec && s_run_all_exports)
- WASM_FATAL("--spec and --run-all-exports are incompatible.\n");
+ WABT_FATAL("--spec and --run-all-exports are incompatible.\n");
if (!s_infile) {
- wasm_print_help(&parser, PROGRAM_NAME);
- WASM_FATAL("No filename given.\n");
+ wabt_print_help(&parser, PROGRAM_NAME);
+ WABT_FATAL("No filename given.\n");
}
}
-static WasmStringSlice get_dirname(const char* s) {
+static WabtStringSlice get_dirname(const char* s) {
/* strip everything after and including the last slash, e.g.:
*
* s = "foo/bar/baz", => "foo/bar"
@@ -196,7 +196,7 @@ static WasmStringSlice get_dirname(const char* s) {
if (last_slash == NULL)
last_slash = s;
- WasmStringSlice result;
+ WabtStringSlice result;
result.start = s;
result.length = last_slash - s;
return result;
@@ -207,27 +207,27 @@ static WasmStringSlice get_dirname(const char* s) {
static void sprint_typed_value(char* buffer,
size_t size,
- const WasmInterpreterTypedValue* tv) {
+ const WabtInterpreterTypedValue* tv) {
switch (tv->type) {
- case WASM_TYPE_I32:
- wasm_snprintf(buffer, size, "i32:%u", tv->value.i32);
+ case WABT_TYPE_I32:
+ wabt_snprintf(buffer, size, "i32:%u", tv->value.i32);
break;
- case WASM_TYPE_I64:
- wasm_snprintf(buffer, size, "i64:%" PRIu64, tv->value.i64);
+ case WABT_TYPE_I64:
+ wabt_snprintf(buffer, size, "i64:%" PRIu64, tv->value.i64);
break;
- case WASM_TYPE_F32: {
+ case WABT_TYPE_F32: {
float value;
memcpy(&value, &tv->value.f32_bits, sizeof(float));
- wasm_snprintf(buffer, size, "f32:%g", value);
+ wabt_snprintf(buffer, size, "f32:%g", value);
break;
}
- case WASM_TYPE_F64: {
+ case WABT_TYPE_F64: {
double value;
memcpy(&value, &tv->value.f64_bits, sizeof(double));
- wasm_snprintf(buffer, size, "f64:%g", value);
+ wabt_snprintf(buffer, size, "f64:%g", value);
break;
}
@@ -237,13 +237,13 @@ static void sprint_typed_value(char* buffer,
}
}
-static void print_typed_value(const WasmInterpreterTypedValue* tv) {
+static void print_typed_value(const WabtInterpreterTypedValue* tv) {
char buffer[MAX_TYPED_VALUE_CHARS];
sprint_typed_value(buffer, sizeof(buffer), tv);
printf("%s", buffer);
}
-static void print_typed_values(const WasmInterpreterTypedValue* values,
+static void print_typed_values(const WabtInterpreterTypedValue* values,
size_t num_values) {
size_t i;
for (i = 0; i < num_values; ++i) {
@@ -254,26 +254,26 @@ static void print_typed_values(const WasmInterpreterTypedValue* values,
}
static void print_typed_value_vector(
- const WasmInterpreterTypedValueVector* values) {
+ const WabtInterpreterTypedValueVector* values) {
print_typed_values(&values->data[0], values->size);
}
static void print_interpreter_result(const char* desc,
- WasmInterpreterResult iresult) {
+ WabtInterpreterResult iresult) {
printf("%s: %s\n", desc, s_trap_strings[iresult]);
}
-static void print_call(WasmStringSlice module_name,
- WasmStringSlice func_name,
- const WasmInterpreterTypedValueVector* args,
- const WasmInterpreterTypedValueVector* results,
- WasmInterpreterResult iresult) {
+static void print_call(WabtStringSlice module_name,
+ WabtStringSlice func_name,
+ const WabtInterpreterTypedValueVector* args,
+ const WabtInterpreterTypedValueVector* results,
+ WabtInterpreterResult iresult) {
if (module_name.length)
- printf(PRIstringslice ".", WASM_PRINTF_STRING_SLICE_ARG(module_name));
- printf(PRIstringslice "(", WASM_PRINTF_STRING_SLICE_ARG(func_name));
+ printf(PRIstringslice ".", WABT_PRINTF_STRING_SLICE_ARG(module_name));
+ printf(PRIstringslice "(", WABT_PRINTF_STRING_SLICE_ARG(func_name));
print_typed_value_vector(args);
printf(") =>");
- if (iresult == WASM_INTERPRETER_OK) {
+ if (iresult == WABT_INTERPRETER_OK) {
if (results->size > 0) {
printf(" ");
print_typed_value_vector(results);
@@ -284,58 +284,58 @@ static void print_call(WasmStringSlice module_name,
}
}
-static WasmInterpreterResult run_defined_function(WasmInterpreterThread* thread,
+static WabtInterpreterResult run_defined_function(WabtInterpreterThread* thread,
uint32_t offset) {
thread->pc = offset;
- WasmInterpreterResult iresult = WASM_INTERPRETER_OK;
+ WabtInterpreterResult iresult = WABT_INTERPRETER_OK;
uint32_t quantum = s_trace ? 1 : INSTRUCTION_QUANTUM;
uint32_t* call_stack_return_top = thread->call_stack_top;
- while (iresult == WASM_INTERPRETER_OK) {
+ while (iresult == WABT_INTERPRETER_OK) {
if (s_trace)
- wasm_trace_pc(thread, s_stdout_stream);
- iresult = wasm_run_interpreter(thread, quantum, call_stack_return_top);
+ wabt_trace_pc(thread, s_stdout_stream);
+ iresult = wabt_run_interpreter(thread, quantum, call_stack_return_top);
}
- if (iresult != WASM_INTERPRETER_RETURNED)
+ if (iresult != WABT_INTERPRETER_RETURNED)
return iresult;
/* use OK instead of RETURNED for consistency */
- return WASM_INTERPRETER_OK;
+ return WABT_INTERPRETER_OK;
}
-static WasmInterpreterResult push_args(
- WasmInterpreterThread* thread,
- const WasmInterpreterFuncSignature* sig,
- const WasmInterpreterTypedValueVector* args) {
+static WabtInterpreterResult push_args(
+ WabtInterpreterThread* thread,
+ const WabtInterpreterFuncSignature* sig,
+ const WabtInterpreterTypedValueVector* args) {
if (sig->param_types.size != args->size)
- return WASM_INTERPRETER_ARGUMENT_TYPE_MISMATCH;
+ return WABT_INTERPRETER_ARGUMENT_TYPE_MISMATCH;
size_t i;
for (i = 0; i < sig->param_types.size; ++i) {
if (sig->param_types.data[i] != args->data[i].type)
- return WASM_INTERPRETER_ARGUMENT_TYPE_MISMATCH;
+ return WABT_INTERPRETER_ARGUMENT_TYPE_MISMATCH;
- WasmInterpreterResult iresult =
- wasm_push_thread_value(thread, args->data[i].value);
- if (iresult != WASM_INTERPRETER_OK) {
+ WabtInterpreterResult iresult =
+ wabt_push_thread_value(thread, args->data[i].value);
+ if (iresult != WABT_INTERPRETER_OK) {
thread->value_stack_top = thread->value_stack.data;
return iresult;
}
}
- return WASM_INTERPRETER_OK;
+ return WABT_INTERPRETER_OK;
}
-static void copy_results(WasmAllocator* allocator,
- WasmInterpreterThread* thread,
- const WasmInterpreterFuncSignature* sig,
- WasmInterpreterTypedValueVector* out_results) {
+static void copy_results(WabtAllocator* allocator,
+ WabtInterpreterThread* thread,
+ const WabtInterpreterFuncSignature* sig,
+ WabtInterpreterTypedValueVector* out_results) {
size_t expected_results = sig->result_types.size;
size_t value_stack_depth = thread->value_stack_top - thread->value_stack.data;
- WASM_USE(value_stack_depth);
+ WABT_USE(value_stack_depth);
assert(expected_results == value_stack_depth);
/* Don't clear out the vector, in case it is being reused. Just reset the
* size to zero. */
out_results->size = 0;
- wasm_resize_interpreter_typed_value_vector(allocator, out_results,
+ wabt_resize_interpreter_typed_value_vector(allocator, out_results,
expected_results);
size_t i;
for (i = 0; i < expected_results; ++i) {
@@ -344,24 +344,24 @@ static void copy_results(WasmAllocator* allocator,
}
}
-static WasmInterpreterResult run_function(
- WasmAllocator* allocator,
- WasmInterpreterThread* thread,
+static WabtInterpreterResult run_function(
+ WabtAllocator* allocator,
+ WabtInterpreterThread* thread,
uint32_t func_index,
- const WasmInterpreterTypedValueVector* args,
- WasmInterpreterTypedValueVector* out_results) {
+ const WabtInterpreterTypedValueVector* args,
+ WabtInterpreterTypedValueVector* out_results) {
assert(func_index < thread->env->funcs.size);
- WasmInterpreterFunc* func = &thread->env->funcs.data[func_index];
+ WabtInterpreterFunc* func = &thread->env->funcs.data[func_index];
uint32_t sig_index = func->sig_index;
assert(sig_index < thread->env->sigs.size);
- WasmInterpreterFuncSignature* sig = &thread->env->sigs.data[sig_index];
+ WabtInterpreterFuncSignature* sig = &thread->env->sigs.data[sig_index];
- WasmInterpreterResult iresult = push_args(thread, sig, args);
- if (iresult == WASM_INTERPRETER_OK) {
+ WabtInterpreterResult iresult = push_args(thread, sig, args);
+ if (iresult == WABT_INTERPRETER_OK) {
iresult = func->is_host
- ? wasm_call_host(thread, func)
+ ? wabt_call_host(thread, func)
: run_defined_function(thread, func->defined.offset);
- if (iresult == WASM_INTERPRETER_OK)
+ if (iresult == WABT_INTERPRETER_OK)
copy_results(allocator, thread, sig, out_results);
}
@@ -371,238 +371,238 @@ static WasmInterpreterResult run_function(
return iresult;
}
-static WasmInterpreterResult run_start_function(WasmAllocator* allocator,
- WasmInterpreterThread* thread,
- WasmInterpreterModule* module) {
- if (module->defined.start_func_index == WASM_INVALID_INDEX)
- return WASM_INTERPRETER_OK;
+static WabtInterpreterResult run_start_function(WabtAllocator* allocator,
+ WabtInterpreterThread* thread,
+ WabtInterpreterModule* module) {
+ if (module->defined.start_func_index == WABT_INVALID_INDEX)
+ return WABT_INTERPRETER_OK;
if (s_trace)
printf(">>> running start function:\n");
- WasmInterpreterTypedValueVector args;
- WasmInterpreterTypedValueVector results;
- WASM_ZERO_MEMORY(args);
- WASM_ZERO_MEMORY(results);
+ WabtInterpreterTypedValueVector args;
+ WabtInterpreterTypedValueVector results;
+ WABT_ZERO_MEMORY(args);
+ WABT_ZERO_MEMORY(results);
- WasmInterpreterResult iresult = run_function(
+ WabtInterpreterResult iresult = run_function(
allocator, thread, module->defined.start_func_index, &args, &results);
assert(results.size == 0);
return iresult;
}
-static WasmInterpreterResult run_export(
- WasmAllocator* allocator,
- WasmInterpreterThread* thread,
- const WasmInterpreterExport* export,
- const WasmInterpreterTypedValueVector* args,
- WasmInterpreterTypedValueVector* out_results) {
+static WabtInterpreterResult run_export(
+ WabtAllocator* allocator,
+ WabtInterpreterThread* thread,
+ const WabtInterpreterExport* export,
+ const WabtInterpreterTypedValueVector* args,
+ WabtInterpreterTypedValueVector* out_results) {
if (s_trace) {
printf(">>> running export \"" PRIstringslice "\":\n",
- WASM_PRINTF_STRING_SLICE_ARG(export->name));
+ WABT_PRINTF_STRING_SLICE_ARG(export->name));
}
- assert(export->kind == WASM_EXTERNAL_KIND_FUNC);
+ assert(export->kind == WABT_EXTERNAL_KIND_FUNC);
return run_function(allocator, thread, export->index, args, out_results);
}
-static WasmInterpreterResult run_export_by_name(
- WasmAllocator* allocator,
- WasmInterpreterThread* thread,
- WasmInterpreterModule* module,
- const WasmStringSlice* name,
- const WasmInterpreterTypedValueVector* args,
- WasmInterpreterTypedValueVector* out_results,
+static WabtInterpreterResult run_export_by_name(
+ WabtAllocator* allocator,
+ WabtInterpreterThread* thread,
+ WabtInterpreterModule* module,
+ const WabtStringSlice* name,
+ const WabtInterpreterTypedValueVector* args,
+ WabtInterpreterTypedValueVector* out_results,
RunVerbosity verbose) {
- WasmInterpreterExport* export =
- wasm_get_interpreter_export_by_name(module, name);
+ WabtInterpreterExport* export =
+ wabt_get_interpreter_export_by_name(module, name);
if (!export)
- return WASM_INTERPRETER_UNKNOWN_EXPORT;
- if (export->kind != WASM_EXTERNAL_KIND_FUNC)
- return WASM_INTERPRETER_EXPORT_KIND_MISMATCH;
+ return WABT_INTERPRETER_UNKNOWN_EXPORT;
+ if (export->kind != WABT_EXTERNAL_KIND_FUNC)
+ return WABT_INTERPRETER_EXPORT_KIND_MISMATCH;
return run_export(allocator, thread, export, args, out_results);
}
-static WasmInterpreterResult get_global_export_by_name(
- WasmAllocator* allocator,
- WasmInterpreterThread* thread,
- WasmInterpreterModule* module,
- const WasmStringSlice* name,
- WasmInterpreterTypedValueVector* out_results) {
- WasmInterpreterExport* export =
- wasm_get_interpreter_export_by_name(module, name);
+static WabtInterpreterResult get_global_export_by_name(
+ WabtAllocator* allocator,
+ WabtInterpreterThread* thread,
+ WabtInterpreterModule* module,
+ const WabtStringSlice* name,
+ WabtInterpreterTypedValueVector* out_results) {
+ WabtInterpreterExport* export =
+ wabt_get_interpreter_export_by_name(module, name);
if (!export)
- return WASM_INTERPRETER_UNKNOWN_EXPORT;
- if (export->kind != WASM_EXTERNAL_KIND_GLOBAL)
- return WASM_INTERPRETER_EXPORT_KIND_MISMATCH;
+ return WABT_INTERPRETER_UNKNOWN_EXPORT;
+ if (export->kind != WABT_EXTERNAL_KIND_GLOBAL)
+ return WABT_INTERPRETER_EXPORT_KIND_MISMATCH;
assert(export->index < thread->env->globals.size);
- WasmInterpreterGlobal* global = &thread->env->globals.data[export->index];
+ WabtInterpreterGlobal* global = &thread->env->globals.data[export->index];
/* Don't clear out the vector, in case it is being reused. Just reset the
* size to zero. */
out_results->size = 0;
- wasm_append_interpreter_typed_value_value(allocator, out_results,
+ wabt_append_interpreter_typed_value_value(allocator, out_results,
&global->typed_value);
- return WASM_INTERPRETER_OK;
+ return WABT_INTERPRETER_OK;
}
-static void run_all_exports(WasmAllocator* allocator,
- WasmInterpreterModule* module,
- WasmInterpreterThread* thread,
+static void run_all_exports(WabtAllocator* allocator,
+ WabtInterpreterModule* module,
+ WabtInterpreterThread* thread,
RunVerbosity verbose) {
- WasmInterpreterTypedValueVector args;
- WasmInterpreterTypedValueVector results;
- WASM_ZERO_MEMORY(args);
- WASM_ZERO_MEMORY(results);
+ WabtInterpreterTypedValueVector args;
+ WabtInterpreterTypedValueVector results;
+ WABT_ZERO_MEMORY(args);
+ WABT_ZERO_MEMORY(results);
uint32_t i;
for (i = 0; i < module->exports.size; ++i) {
- WasmInterpreterExport* export = &module->exports.data[i];
- WasmInterpreterResult iresult =
+ WabtInterpreterExport* export = &module->exports.data[i];
+ WabtInterpreterResult iresult =
run_export(allocator, thread, export, &args, &results);
if (verbose) {
- print_call(wasm_empty_string_slice(), export->name, &args, &results,
+ print_call(wabt_empty_string_slice(), export->name, &args, &results,
iresult);
}
}
- wasm_destroy_interpreter_typed_value_vector(allocator, &args);
- wasm_destroy_interpreter_typed_value_vector(allocator, &results);
+ wabt_destroy_interpreter_typed_value_vector(allocator, &args);
+ wabt_destroy_interpreter_typed_value_vector(allocator, &results);
}
-static WasmResult read_module(WasmAllocator* allocator,
+static WabtResult read_module(WabtAllocator* allocator,
const char* module_filename,
- WasmInterpreterEnvironment* env,
- WasmBinaryErrorHandler* error_handler,
- WasmInterpreterModule** out_module) {
- WasmResult result;
+ WabtInterpreterEnvironment* env,
+ WabtBinaryErrorHandler* error_handler,
+ WabtInterpreterModule** out_module) {
+ WabtResult result;
void* data;
size_t size;
*out_module = NULL;
- result = wasm_read_file(allocator, module_filename, &data, &size);
- if (WASM_SUCCEEDED(result)) {
- WasmAllocator* memory_allocator = &g_wasm_libc_allocator;
- result = wasm_read_binary_interpreter(allocator, memory_allocator, env,
+ result = wabt_read_file(allocator, module_filename, &data, &size);
+ if (WABT_SUCCEEDED(result)) {
+ WabtAllocator* memory_allocator = &g_wabt_libc_allocator;
+ result = wabt_read_binary_interpreter(allocator, memory_allocator, env,
data, size, &s_read_binary_options,
error_handler, out_module);
- if (WASM_SUCCEEDED(result)) {
+ if (WABT_SUCCEEDED(result)) {
if (s_verbose)
- wasm_disassemble_module(env, s_stdout_stream, *out_module);
+ wabt_disassemble_module(env, s_stdout_stream, *out_module);
}
- wasm_free(allocator, data);
+ wabt_free(allocator, data);
}
return result;
}
-static WasmResult default_host_callback(const WasmInterpreterFunc* func,
- const WasmInterpreterFuncSignature* sig,
+static WabtResult default_host_callback(const WabtInterpreterFunc* func,
+ const WabtInterpreterFuncSignature* sig,
uint32_t num_args,
- WasmInterpreterTypedValue* args,
+ WabtInterpreterTypedValue* args,
uint32_t num_results,
- WasmInterpreterTypedValue* out_results,
+ WabtInterpreterTypedValue* out_results,
void* user_data) {
- memset(out_results, 0, sizeof(WasmInterpreterTypedValue) * num_results);
+ memset(out_results, 0, sizeof(WabtInterpreterTypedValue) * num_results);
uint32_t i;
for (i = 0; i < num_results; ++i)
out_results[i].type = sig->result_types.data[i];
- WasmInterpreterTypedValueVector vec_args;
+ WabtInterpreterTypedValueVector vec_args;
vec_args.size = num_args;
vec_args.data = args;
- WasmInterpreterTypedValueVector vec_results;
+ WabtInterpreterTypedValueVector vec_results;
vec_results.size = num_results;
vec_results.data = out_results;
printf("called host ");
print_call(func->host.module_name, func->host.field_name, &vec_args,
- &vec_results, WASM_INTERPRETER_OK);
- return WASM_OK;
+ &vec_results, WABT_INTERPRETER_OK);
+ return WABT_OK;
}
#define PRIimport "\"" PRIstringslice "." PRIstringslice "\""
#define PRINTF_IMPORT_ARG(x) \
- WASM_PRINTF_STRING_SLICE_ARG((x).module_name) \
- , WASM_PRINTF_STRING_SLICE_ARG((x).field_name)
+ WABT_PRINTF_STRING_SLICE_ARG((x).module_name) \
+ , WABT_PRINTF_STRING_SLICE_ARG((x).field_name)
-static void WASM_PRINTF_FORMAT(2, 3)
- print_error(WasmPrintErrorCallback callback, const char* format, ...) {
- WASM_SNPRINTF_ALLOCA(buffer, length, format);
+static void WABT_PRINTF_FORMAT(2, 3)
+ print_error(WabtPrintErrorCallback callback, const char* format, ...) {
+ WABT_SNPRINTF_ALLOCA(buffer, length, format);
callback.print_error(buffer, callback.user_data);
}
-static WasmResult spectest_import_func(WasmInterpreterImport* import,
- WasmInterpreterFunc* func,
- WasmInterpreterFuncSignature* sig,
- WasmPrintErrorCallback callback,
+static WabtResult spectest_import_func(WabtInterpreterImport* import,
+ WabtInterpreterFunc* func,
+ WabtInterpreterFuncSignature* sig,
+ WabtPrintErrorCallback callback,
void* user_data) {
- if (wasm_string_slice_eq_cstr(&import->field_name, "print")) {
+ if (wabt_string_slice_eq_cstr(&import->field_name, "print")) {
func->host.callback = default_host_callback;
- return WASM_OK;
+ return WABT_OK;
} else {
print_error(callback, "unknown host function import " PRIimport,
PRINTF_IMPORT_ARG(*import));
- return WASM_ERROR;
+ return WABT_ERROR;
}
}
-static WasmResult spectest_import_table(WasmInterpreterImport* import,
- WasmInterpreterTable* table,
- WasmPrintErrorCallback callback,
+static WabtResult spectest_import_table(WabtInterpreterImport* import,
+ WabtInterpreterTable* table,
+ WabtPrintErrorCallback callback,
void* user_data) {
- if (wasm_string_slice_eq_cstr(&import->field_name, "table")) {
- table->limits.has_max = WASM_TRUE;
+ if (wabt_string_slice_eq_cstr(&import->field_name, "table")) {
+ table->limits.has_max = WABT_TRUE;
table->limits.initial = 10;
table->limits.max = 20;
- return WASM_OK;
+ return WABT_OK;
} else {
print_error(callback, "unknown host table import " PRIimport,
PRINTF_IMPORT_ARG(*import));
- return WASM_ERROR;
+ return WABT_ERROR;
}
}
-static WasmResult spectest_import_memory(WasmInterpreterImport* import,
- WasmInterpreterMemory* memory,
- WasmPrintErrorCallback callback,
+static WabtResult spectest_import_memory(WabtInterpreterImport* import,
+ WabtInterpreterMemory* memory,
+ WabtPrintErrorCallback callback,
void* user_data) {
- if (wasm_string_slice_eq_cstr(&import->field_name, "memory")) {
- memory->page_limits.has_max = WASM_TRUE;
+ if (wabt_string_slice_eq_cstr(&import->field_name, "memory")) {
+ memory->page_limits.has_max = WABT_TRUE;
memory->page_limits.initial = 1;
memory->page_limits.max = 2;
- memory->byte_size = memory->page_limits.initial * WASM_MAX_PAGES;
- memory->data = wasm_alloc_zero(memory->allocator, memory->byte_size,
- WASM_DEFAULT_ALIGN);
- return WASM_OK;
+ memory->byte_size = memory->page_limits.initial * WABT_MAX_PAGES;
+ memory->data = wabt_alloc_zero(memory->allocator, memory->byte_size,
+ WABT_DEFAULT_ALIGN);
+ return WABT_OK;
} else {
print_error(callback, "unknown host memory import " PRIimport,
PRINTF_IMPORT_ARG(*import));
- return WASM_ERROR;
+ return WABT_ERROR;
}
}
-static WasmResult spectest_import_global(WasmInterpreterImport* import,
- WasmInterpreterGlobal* global,
- WasmPrintErrorCallback callback,
+static WabtResult spectest_import_global(WabtInterpreterImport* import,
+ WabtInterpreterGlobal* global,
+ WabtPrintErrorCallback callback,
void* user_data) {
- if (wasm_string_slice_eq_cstr(&import->field_name, "global")) {
+ if (wabt_string_slice_eq_cstr(&import->field_name, "global")) {
switch (global->typed_value.type) {
- case WASM_TYPE_I32:
+ case WABT_TYPE_I32:
global->typed_value.value.i32 = 666;
break;
- case WASM_TYPE_F32: {
+ case WABT_TYPE_F32: {
float value = 666.6f;
memcpy(&global->typed_value.value.f32_bits, &value, sizeof(value));
break;
}
- case WASM_TYPE_I64:
+ case WABT_TYPE_I64:
global->typed_value.value.i64 = 666;
break;
- case WASM_TYPE_F64: {
+ case WABT_TYPE_F64: {
double value = 666.6;
memcpy(&global->typed_value.value.f64_bits, &value, sizeof(value));
break;
@@ -611,72 +611,72 @@ static WasmResult spectest_import_global(WasmInterpreterImport* import,
default:
print_error(callback, "bad type for host global import " PRIimport,
PRINTF_IMPORT_ARG(*import));
- return WASM_ERROR;
+ return WABT_ERROR;
}
- return WASM_OK;
+ return WABT_OK;
} else {
print_error(callback, "unknown host global import " PRIimport,
PRINTF_IMPORT_ARG(*import));
- return WASM_ERROR;
+ return WABT_ERROR;
}
}
-static void init_environment(WasmAllocator* allocator,
- WasmInterpreterEnvironment* env) {
- wasm_init_interpreter_environment(allocator, env);
- WasmInterpreterModule* host_module = wasm_append_host_module(
- allocator, env, wasm_string_slice_from_cstr("spectest"));
+static void init_environment(WabtAllocator* allocator,
+ WabtInterpreterEnvironment* env) {
+ wabt_init_interpreter_environment(allocator, env);
+ WabtInterpreterModule* host_module = wabt_append_host_module(
+ allocator, env, wabt_string_slice_from_cstr("spectest"));
host_module->host.import_delegate.import_func = spectest_import_func;
host_module->host.import_delegate.import_table = spectest_import_table;
host_module->host.import_delegate.import_memory = spectest_import_memory;
host_module->host.import_delegate.import_global = spectest_import_global;
}
-static WasmResult read_and_run_module(WasmAllocator* allocator,
+static WabtResult read_and_run_module(WabtAllocator* allocator,
const char* module_filename) {
- WasmResult result;
- WasmInterpreterEnvironment env;
- WasmInterpreterModule* module = NULL;
- WasmInterpreterThread thread;
+ WabtResult result;
+ WabtInterpreterEnvironment env;
+ WabtInterpreterModule* module = NULL;
+ WabtInterpreterThread thread;
init_environment(allocator, &env);
- wasm_init_interpreter_thread(allocator, &env, &thread, &s_thread_options);
+ wabt_init_interpreter_thread(allocator, &env, &thread, &s_thread_options);
result =
read_module(allocator, module_filename, &env, &s_error_handler, &module);
- if (WASM_SUCCEEDED(result)) {
- WasmInterpreterResult iresult =
+ if (WABT_SUCCEEDED(result)) {
+ WabtInterpreterResult iresult =
run_start_function(allocator, &thread, module);
- if (iresult == WASM_INTERPRETER_OK) {
+ if (iresult == WABT_INTERPRETER_OK) {
if (s_run_all_exports)
run_all_exports(allocator, module, &thread, RUN_VERBOSE);
} else {
print_interpreter_result("error running start function", iresult);
}
}
- wasm_destroy_interpreter_thread(allocator, &thread);
- wasm_destroy_interpreter_environment(allocator, &env);
+ wabt_destroy_interpreter_thread(allocator, &thread);
+ wabt_destroy_interpreter_environment(allocator, &env);
return result;
}
-WASM_DEFINE_VECTOR(interpreter_thread, WasmInterpreterThread);
+WABT_DEFINE_VECTOR(interpreter_thread, WabtInterpreterThread);
/* An extremely simple JSON parser that only knows how to parse the expected
- * format from wast2wasm. */
+ * format from wast2wabt. */
typedef struct Context {
- WasmAllocator* allocator;
- WasmInterpreterEnvironment env;
- WasmInterpreterThread thread;
- WasmInterpreterModule* last_module;
+ WabtAllocator* allocator;
+ WabtInterpreterEnvironment env;
+ WabtInterpreterThread thread;
+ WabtInterpreterModule* last_module;
/* Parsing info */
char* json_data;
size_t json_data_size;
- WasmStringSlice source_filename;
+ WabtStringSlice source_filename;
size_t json_offset;
- WasmLocation loc;
- WasmLocation prev_loc;
- WasmBool has_prev_loc;
+ WabtLocation loc;
+ WabtLocation prev_loc;
+ WabtBool has_prev_loc;
uint32_t command_line_number;
/* Test info */
@@ -691,15 +691,15 @@ typedef enum ActionType {
typedef struct Action {
ActionType type;
- WasmStringSlice module_name;
- WasmStringSlice field_name;
- WasmInterpreterTypedValueVector args;
+ WabtStringSlice module_name;
+ WabtStringSlice field_name;
+ WabtInterpreterTypedValueVector args;
} Action;
#define CHECK_RESULT(x) \
do { \
- if (WASM_FAILED(x)) \
- return WASM_ERROR; \
+ if (WABT_FAILED(x)) \
+ return WABT_ERROR; \
} while (0)
#define EXPECT(x) CHECK_RESULT(expect(ctx, x))
@@ -707,18 +707,18 @@ typedef struct Action {
#define PARSE_KEY_STRING_VALUE(key, value) \
CHECK_RESULT(parse_key_string_value(ctx, key, value))
-static void WASM_PRINTF_FORMAT(2, 3)
+static void WABT_PRINTF_FORMAT(2, 3)
print_parse_error(Context* ctx, const char* format, ...) {
- WASM_SNPRINTF_ALLOCA(buffer, length, format);
+ WABT_SNPRINTF_ALLOCA(buffer, length, format);
fprintf(stderr, "%s:%d:%d: %s\n", ctx->loc.filename, ctx->loc.line,
ctx->loc.first_column, buffer);
}
-static void WASM_PRINTF_FORMAT(2, 3)
+static void WABT_PRINTF_FORMAT(2, 3)
print_command_error(Context* ctx, const char* format, ...) {
- WASM_SNPRINTF_ALLOCA(buffer, length, format);
+ WABT_SNPRINTF_ALLOCA(buffer, length, format);
printf(PRIstringslice ":%u: %s\n",
- WASM_PRINTF_STRING_SLICE_ARG(ctx->source_filename),
+ WABT_PRINTF_STRING_SLICE_ARG(ctx->source_filename),
ctx->command_line_number, buffer);
}
@@ -726,7 +726,7 @@ static void putback_char(Context* ctx) {
assert(ctx->has_prev_loc);
ctx->json_offset--;
ctx->loc = ctx->prev_loc;
- ctx->has_prev_loc = WASM_FALSE;
+ ctx->has_prev_loc = WABT_FALSE;
}
static int read_char(Context* ctx) {
@@ -740,7 +740,7 @@ static int read_char(Context* ctx) {
} else {
ctx->loc.first_column++;
}
- ctx->has_prev_loc = WASM_TRUE;
+ ctx->has_prev_loc = WABT_TRUE;
return c;
}
@@ -763,42 +763,42 @@ static void skip_whitespace(Context* ctx) {
}
}
-static WasmBool match(Context* ctx, const char* s) {
+static WabtBool match(Context* ctx, const char* s) {
skip_whitespace(ctx);
- WasmLocation start_loc = ctx->loc;
+ WabtLocation start_loc = ctx->loc;
size_t start_offset = ctx->json_offset;
while (*s && *s == read_char(ctx))
s++;
if (*s == 0) {
- return WASM_TRUE;
+ return WABT_TRUE;
} else {
ctx->json_offset = start_offset;
ctx->loc = start_loc;
- return WASM_FALSE;
+ return WABT_FALSE;
}
}
-static WasmResult expect(Context* ctx, const char* s) {
+static WabtResult expect(Context* ctx, const char* s) {
if (match(ctx, s)) {
- return WASM_OK;
+ return WABT_OK;
} else {
print_parse_error(ctx, "expected %s", s);
- return WASM_ERROR;
+ return WABT_ERROR;
}
}
-static WasmResult expect_key(Context* ctx, const char* key) {
+static WabtResult expect_key(Context* ctx, const char* key) {
size_t keylen = strlen(key);
size_t quoted_len = keylen + 2 + 1;
char* quoted = alloca(quoted_len);
- wasm_snprintf(quoted, quoted_len, "\"%s\"", key);
+ wabt_snprintf(quoted, quoted_len, "\"%s\"", key);
EXPECT(quoted);
EXPECT(":");
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult parse_uint32(Context* ctx, uint32_t* out_int) {
+static WabtResult parse_uint32(Context* ctx, uint32_t* out_int) {
uint32_t result = 0;
skip_whitespace(ctx);
while (1) {
@@ -808,7 +808,7 @@ static WasmResult parse_uint32(Context* ctx, uint32_t* out_int) {
result = result * 10 + (uint32_t)(c - '0');
if (result < last_result) {
print_parse_error(ctx, "uint32 overflow");
- return WASM_ERROR;
+ return WABT_ERROR;
}
} else {
putback_char(ctx);
@@ -816,18 +816,18 @@ static WasmResult parse_uint32(Context* ctx, uint32_t* out_int) {
}
}
*out_int = result;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult parse_string(Context* ctx, WasmStringSlice* out_string) {
- WASM_ZERO_MEMORY(*out_string);
+static WabtResult parse_string(Context* ctx, WabtStringSlice* out_string) {
+ WABT_ZERO_MEMORY(*out_string);
skip_whitespace(ctx);
if (read_char(ctx) != '"') {
print_parse_error(ctx, "expected string");
- return WASM_ERROR;
+ return WABT_ERROR;
}
- /* Modify json_data in-place so we can use the WasmStringSlice directly
+ /* Modify json_data in-place so we can use the WabtStringSlice directly
* without having to allocate additional memory; this is only necessary when
* the string contains an escape, but we do it always because the code is
* simpler. */
@@ -843,7 +843,7 @@ static WasmResult parse_string(Context* ctx, WasmStringSlice* out_string) {
c = read_char(ctx);
if (c != 'u') {
print_parse_error(ctx, "expected escape: \\uxxxx");
- return WASM_ERROR;
+ return WABT_ERROR;
}
int i;
uint16_t code = 0;
@@ -858,7 +858,7 @@ static WasmResult parse_string(Context* ctx, WasmStringSlice* out_string) {
cval = c - 'A' + 10;
} else {
print_parse_error(ctx, "expected hex char");
- return WASM_ERROR;
+ return WABT_ERROR;
}
code = (code << 4) + cval;
}
@@ -874,78 +874,78 @@ static WasmResult parse_string(Context* ctx, WasmStringSlice* out_string) {
}
}
out_string->length = p - start;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult parse_key_string_value(Context* ctx,
+static WabtResult parse_key_string_value(Context* ctx,
const char* key,
- WasmStringSlice* out_string) {
- WASM_ZERO_MEMORY(*out_string);
+ WabtStringSlice* out_string) {
+ WABT_ZERO_MEMORY(*out_string);
EXPECT_KEY(key);
return parse_string(ctx, out_string);
}
-static WasmResult parse_opt_name_string_value(Context* ctx,
- WasmStringSlice* out_string) {
- WASM_ZERO_MEMORY(*out_string);
+static WabtResult parse_opt_name_string_value(Context* ctx,
+ WabtStringSlice* out_string) {
+ WABT_ZERO_MEMORY(*out_string);
if (match(ctx, "\"name\"")) {
EXPECT(":");
CHECK_RESULT(parse_string(ctx, out_string));
EXPECT(",");
}
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult parse_line(Context* ctx) {
+static WabtResult parse_line(Context* ctx) {
EXPECT_KEY("line");
CHECK_RESULT(parse_uint32(ctx, &ctx->command_line_number));
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult parse_type_object(Context* ctx, WasmType* out_type) {
- WasmStringSlice type_str;
+static WabtResult parse_type_object(Context* ctx, WabtType* out_type) {
+ WabtStringSlice type_str;
EXPECT("{");
PARSE_KEY_STRING_VALUE("type", &type_str);
EXPECT("}");
- if (wasm_string_slice_eq_cstr(&type_str, "i32")) {
- *out_type = WASM_TYPE_I32;
- return WASM_OK;
- } else if (wasm_string_slice_eq_cstr(&type_str, "f32")) {
- *out_type = WASM_TYPE_F32;
- return WASM_OK;
- } else if (wasm_string_slice_eq_cstr(&type_str, "i64")) {
- *out_type = WASM_TYPE_I64;
- return WASM_OK;
- } else if (wasm_string_slice_eq_cstr(&type_str, "f64")) {
- *out_type = WASM_TYPE_F64;
- return WASM_OK;
+ if (wabt_string_slice_eq_cstr(&type_str, "i32")) {
+ *out_type = WABT_TYPE_I32;
+ return WABT_OK;
+ } else if (wabt_string_slice_eq_cstr(&type_str, "f32")) {
+ *out_type = WABT_TYPE_F32;
+ return WABT_OK;
+ } else if (wabt_string_slice_eq_cstr(&type_str, "i64")) {
+ *out_type = WABT_TYPE_I64;
+ return WABT_OK;
+ } else if (wabt_string_slice_eq_cstr(&type_str, "f64")) {
+ *out_type = WABT_TYPE_F64;
+ return WABT_OK;
} else {
print_parse_error(ctx, "unknown type: \"" PRIstringslice "\"",
- WASM_PRINTF_STRING_SLICE_ARG(type_str));
- return WASM_ERROR;
+ WABT_PRINTF_STRING_SLICE_ARG(type_str));
+ return WABT_ERROR;
}
}
-static WasmResult parse_type_vector(Context* ctx, WasmTypeVector* out_types) {
- WASM_ZERO_MEMORY(*out_types);
+static WabtResult parse_type_vector(Context* ctx, WabtTypeVector* out_types) {
+ WABT_ZERO_MEMORY(*out_types);
EXPECT("[");
- WasmBool first = WASM_TRUE;
+ WabtBool first = WABT_TRUE;
while (!match(ctx, "]")) {
if (!first)
EXPECT(",");
- WasmType type;
+ WabtType type;
CHECK_RESULT(parse_type_object(ctx, &type));
- first = WASM_FALSE;
- wasm_append_type_value(ctx->allocator, out_types, &type);
+ first = WABT_FALSE;
+ wabt_append_type_value(ctx->allocator, out_types, &type);
}
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult parse_const(Context* ctx,
- WasmInterpreterTypedValue* out_value) {
- WasmStringSlice type_str;
- WasmStringSlice value_str;
+static WabtResult parse_const(Context* ctx,
+ WabtInterpreterTypedValue* out_value) {
+ WabtStringSlice type_str;
+ WabtStringSlice value_str;
EXPECT("{");
PARSE_KEY_STRING_VALUE("type", &type_str);
EXPECT(",");
@@ -955,61 +955,61 @@ static WasmResult parse_const(Context* ctx,
const char* value_start = value_str.start;
const char* value_end = value_str.start + value_str.length;
- if (wasm_string_slice_eq_cstr(&type_str, "i32")) {
+ if (wabt_string_slice_eq_cstr(&type_str, "i32")) {
uint32_t value;
- CHECK_RESULT(wasm_parse_int32(value_start, value_end, &value,
- WASM_PARSE_UNSIGNED_ONLY));
- out_value->type = WASM_TYPE_I32;
+ CHECK_RESULT(wabt_parse_int32(value_start, value_end, &value,
+ WABT_PARSE_UNSIGNED_ONLY));
+ out_value->type = WABT_TYPE_I32;
out_value->value.i32 = value;
- return WASM_OK;
- } else if (wasm_string_slice_eq_cstr(&type_str, "f32")) {
+ return WABT_OK;
+ } else if (wabt_string_slice_eq_cstr(&type_str, "f32")) {
uint32_t value_bits;
- CHECK_RESULT(wasm_parse_int32(value_start, value_end, &value_bits,
- WASM_PARSE_UNSIGNED_ONLY));
- out_value->type = WASM_TYPE_F32;
+ CHECK_RESULT(wabt_parse_int32(value_start, value_end, &value_bits,
+ WABT_PARSE_UNSIGNED_ONLY));
+ out_value->type = WABT_TYPE_F32;
out_value->value.f32_bits = value_bits;
- return WASM_OK;
- } else if (wasm_string_slice_eq_cstr(&type_str, "i64")) {
+ return WABT_OK;
+ } else if (wabt_string_slice_eq_cstr(&type_str, "i64")) {
uint64_t value;
- CHECK_RESULT(wasm_parse_int64(value_start, value_end, &value,
- WASM_PARSE_UNSIGNED_ONLY));
- out_value->type = WASM_TYPE_I64;
+ CHECK_RESULT(wabt_parse_int64(value_start, value_end, &value,
+ WABT_PARSE_UNSIGNED_ONLY));
+ out_value->type = WABT_TYPE_I64;
out_value->value.i64 = value;
- return WASM_OK;
- } else if (wasm_string_slice_eq_cstr(&type_str, "f64")) {
+ return WABT_OK;
+ } else if (wabt_string_slice_eq_cstr(&type_str, "f64")) {
uint64_t value_bits;
- CHECK_RESULT(wasm_parse_int64(value_start, value_end, &value_bits,
- WASM_PARSE_UNSIGNED_ONLY));
- out_value->type = WASM_TYPE_F64;
+ CHECK_RESULT(wabt_parse_int64(value_start, value_end, &value_bits,
+ WABT_PARSE_UNSIGNED_ONLY));
+ out_value->type = WABT_TYPE_F64;
out_value->value.f64_bits = value_bits;
- return WASM_OK;
+ return WABT_OK;
} else {
print_parse_error(ctx, "unknown type: \"" PRIstringslice "\"",
- WASM_PRINTF_STRING_SLICE_ARG(type_str));
- return WASM_ERROR;
+ WABT_PRINTF_STRING_SLICE_ARG(type_str));
+ return WABT_ERROR;
}
}
-static WasmResult parse_const_vector(
+static WabtResult parse_const_vector(
Context* ctx,
- WasmInterpreterTypedValueVector* out_values) {
- WASM_ZERO_MEMORY(*out_values);
+ WabtInterpreterTypedValueVector* out_values) {
+ WABT_ZERO_MEMORY(*out_values);
EXPECT("[");
- WasmBool first = WASM_TRUE;
+ WabtBool first = WABT_TRUE;
while (!match(ctx, "]")) {
if (!first)
EXPECT(",");
- WasmInterpreterTypedValue value;
+ WabtInterpreterTypedValue value;
CHECK_RESULT(parse_const(ctx, &value));
- wasm_append_interpreter_typed_value_value(ctx->allocator, out_values,
+ wabt_append_interpreter_typed_value_value(ctx->allocator, out_values,
&value);
- first = WASM_FALSE;
+ first = WABT_FALSE;
}
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult parse_action(Context* ctx, Action* out_action) {
- WASM_ZERO_MEMORY(*out_action);
+static WabtResult parse_action(Context* ctx, Action* out_action) {
+ WABT_ZERO_MEMORY(*out_action);
EXPECT_KEY("action");
EXPECT("{");
EXPECT_KEY("type");
@@ -1032,82 +1032,82 @@ static WasmResult parse_action(Context* ctx, Action* out_action) {
CHECK_RESULT(parse_const_vector(ctx, &out_action->args));
}
EXPECT("}");
- return WASM_OK;
+ return WABT_OK;
}
-static char* create_module_path(Context* ctx, WasmStringSlice filename) {
+static char* create_module_path(Context* ctx, WabtStringSlice filename) {
const char* spec_json_filename = ctx->loc.filename;
- WasmStringSlice dirname = get_dirname(spec_json_filename);
+ WabtStringSlice dirname = get_dirname(spec_json_filename);
size_t path_len = dirname.length + 1 + filename.length + 1;
- char* path = wasm_alloc(ctx->allocator, path_len, 1);
+ char* path = wabt_alloc(ctx->allocator, path_len, 1);
if (dirname.length == 0) {
- wasm_snprintf(path, path_len, PRIstringslice,
- WASM_PRINTF_STRING_SLICE_ARG(filename));
+ wabt_snprintf(path, path_len, PRIstringslice,
+ WABT_PRINTF_STRING_SLICE_ARG(filename));
} else {
- wasm_snprintf(path, path_len, PRIstringslice "/" PRIstringslice,
- WASM_PRINTF_STRING_SLICE_ARG(dirname),
- WASM_PRINTF_STRING_SLICE_ARG(filename));
+ wabt_snprintf(path, path_len, PRIstringslice "/" PRIstringslice,
+ WABT_PRINTF_STRING_SLICE_ARG(dirname),
+ WABT_PRINTF_STRING_SLICE_ARG(filename));
}
return path;
}
-static WasmResult on_module_command(Context* ctx,
- WasmStringSlice filename,
- WasmStringSlice name) {
+static WabtResult on_module_command(Context* ctx,
+ WabtStringSlice filename,
+ WabtStringSlice name) {
char* path = create_module_path(ctx, filename);
- WasmInterpreterEnvironmentMark mark =
- wasm_mark_interpreter_environment(&ctx->env);
- WasmResult result = read_module(ctx->allocator, path, &ctx->env,
+ WabtInterpreterEnvironmentMark mark =
+ wabt_mark_interpreter_environment(&ctx->env);
+ WabtResult result = read_module(ctx->allocator, path, &ctx->env,
&s_error_handler, &ctx->last_module);
- if (WASM_FAILED(result)) {
- wasm_reset_interpreter_environment_to_mark(ctx->allocator, &ctx->env, mark);
+ if (WABT_FAILED(result)) {
+ wabt_reset_interpreter_environment_to_mark(ctx->allocator, &ctx->env, mark);
print_command_error(ctx, "error reading module: \"%s\"", path);
- wasm_free(ctx->allocator, path);
- return WASM_ERROR;
+ wabt_free(ctx->allocator, path);
+ return WABT_ERROR;
}
- wasm_free(ctx->allocator, path);
+ wabt_free(ctx->allocator, path);
- WasmInterpreterResult iresult =
+ WabtInterpreterResult iresult =
run_start_function(ctx->allocator, &ctx->thread, ctx->last_module);
- if (iresult != WASM_INTERPRETER_OK) {
- wasm_reset_interpreter_environment_to_mark(ctx->allocator, &ctx->env, mark);
+ if (iresult != WABT_INTERPRETER_OK) {
+ wabt_reset_interpreter_environment_to_mark(ctx->allocator, &ctx->env, mark);
print_interpreter_result("error running start function", iresult);
- return WASM_ERROR;
+ return WABT_ERROR;
}
- if (!wasm_string_slice_is_empty(&name)) {
- ctx->last_module->name = wasm_dup_string_slice(ctx->allocator, name);
+ if (!wabt_string_slice_is_empty(&name)) {
+ ctx->last_module->name = wabt_dup_string_slice(ctx->allocator, name);
/* The binding also needs its own copy of the name. */
- WasmStringSlice binding_name = wasm_dup_string_slice(ctx->allocator, name);
- WasmBinding* binding = wasm_insert_binding(
+ WabtStringSlice binding_name = wabt_dup_string_slice(ctx->allocator, name);
+ WabtBinding* binding = wabt_insert_binding(
ctx->allocator, &ctx->env.module_bindings, &binding_name);
binding->index = ctx->env.modules.size - 1;
}
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult run_action(Context* ctx,
+static WabtResult run_action(Context* ctx,
Action* action,
- WasmInterpreterResult* out_iresult,
- WasmInterpreterTypedValueVector* out_results,
+ WabtInterpreterResult* out_iresult,
+ WabtInterpreterTypedValueVector* out_results,
RunVerbosity verbose) {
- WASM_ZERO_MEMORY(*out_results);
+ WABT_ZERO_MEMORY(*out_results);
int module_index;
- if (!wasm_string_slice_is_empty(&action->module_name)) {
- module_index = wasm_find_binding_index_by_name(&ctx->env.module_bindings,
+ if (!wabt_string_slice_is_empty(&action->module_name)) {
+ module_index = wabt_find_binding_index_by_name(&ctx->env.module_bindings,
&action->module_name);
} else {
module_index = (int)ctx->env.modules.size - 1;
}
assert(module_index < (int)ctx->env.modules.size);
- WasmInterpreterModule* module = &ctx->env.modules.data[module_index];
+ WabtInterpreterModule* module = &ctx->env.modules.data[module_index];
switch (action->type) {
case ACTION_TYPE_INVOKE:
@@ -1115,115 +1115,115 @@ static WasmResult run_action(Context* ctx,
&action->field_name, &action->args,
out_results, verbose);
if (verbose) {
- print_call(wasm_empty_string_slice(), action->field_name, &action->args,
+ print_call(wabt_empty_string_slice(), action->field_name, &action->args,
out_results, *out_iresult);
}
- return WASM_OK;
+ return WABT_OK;
case ACTION_TYPE_GET: {
*out_iresult =
get_global_export_by_name(ctx->allocator, &ctx->thread, module,
&action->field_name, out_results);
- return WASM_OK;
+ return WABT_OK;
}
default:
print_command_error(ctx, "invalid action type %d", action->type);
- return WASM_ERROR;
+ return WABT_ERROR;
}
}
-static WasmResult on_action_command(Context* ctx, Action* action) {
- WasmInterpreterTypedValueVector results;
- WasmInterpreterResult iresult;
+static WabtResult on_action_command(Context* ctx, Action* action) {
+ WabtInterpreterTypedValueVector results;
+ WabtInterpreterResult iresult;
ctx->total++;
- WasmResult result = run_action(ctx, action, &iresult, &results, RUN_VERBOSE);
- if (WASM_SUCCEEDED(result)) {
- if (iresult == WASM_INTERPRETER_OK) {
+ WabtResult result = run_action(ctx, action, &iresult, &results, RUN_VERBOSE);
+ if (WABT_SUCCEEDED(result)) {
+ if (iresult == WABT_INTERPRETER_OK) {
ctx->passed++;
} else {
print_command_error(ctx, "unexpected trap: %s", s_trap_strings[iresult]);
- result = WASM_ERROR;
+ result = WABT_ERROR;
}
}
- wasm_destroy_interpreter_typed_value_vector(ctx->allocator, &results);
+ wabt_destroy_interpreter_typed_value_vector(ctx->allocator, &results);
return result;
}
-static WasmBinaryErrorHandler* new_custom_error_handler(Context* ctx,
+static WabtBinaryErrorHandler* new_custom_error_handler(Context* ctx,
const char* desc) {
size_t header_size = ctx->source_filename.length + strlen(desc) + 100;
- char* header = wasm_alloc(ctx->allocator, header_size, 1);
- wasm_snprintf(header, header_size, PRIstringslice ":%d: %s passed",
- WASM_PRINTF_STRING_SLICE_ARG(ctx->source_filename),
+ char* header = wabt_alloc(ctx->allocator, header_size, 1);
+ wabt_snprintf(header, header_size, PRIstringslice ":%d: %s passed",
+ WABT_PRINTF_STRING_SLICE_ARG(ctx->source_filename),
ctx->command_line_number, desc);
- WasmDefaultErrorHandlerInfo* info = wasm_alloc_zero(
- ctx->allocator, sizeof(WasmDefaultErrorHandlerInfo), WASM_DEFAULT_ALIGN);
+ WabtDefaultErrorHandlerInfo* info = wabt_alloc_zero(
+ ctx->allocator, sizeof(WabtDefaultErrorHandlerInfo), WABT_DEFAULT_ALIGN);
info->header = header;
info->out_file = stdout;
- info->print_header = WASM_PRINT_ERROR_HEADER_ONCE;
+ info->print_header = WABT_PRINT_ERROR_HEADER_ONCE;
- WasmBinaryErrorHandler* error_handler = wasm_alloc_zero(
- ctx->allocator, sizeof(WasmBinaryErrorHandler), WASM_DEFAULT_ALIGN);
- error_handler->on_error = wasm_default_binary_error_callback;
+ WabtBinaryErrorHandler* error_handler = wabt_alloc_zero(
+ ctx->allocator, sizeof(WabtBinaryErrorHandler), WABT_DEFAULT_ALIGN);
+ error_handler->on_error = wabt_default_binary_error_callback;
error_handler->user_data = info;
return error_handler;
}
static void destroy_custom_error_handler(
- WasmAllocator* allocator,
- WasmBinaryErrorHandler* error_handler) {
- WasmDefaultErrorHandlerInfo* info = error_handler->user_data;
- wasm_free(allocator, (void*)info->header);
- wasm_free(allocator, info);
- wasm_free(allocator, error_handler);
-}
-
-static WasmResult on_assert_malformed_command(Context* ctx,
- WasmStringSlice filename,
- WasmStringSlice text) {
- WasmBinaryErrorHandler* error_handler =
+ WabtAllocator* allocator,
+ WabtBinaryErrorHandler* error_handler) {
+ WabtDefaultErrorHandlerInfo* info = error_handler->user_data;
+ wabt_free(allocator, (void*)info->header);
+ wabt_free(allocator, info);
+ wabt_free(allocator, error_handler);
+}
+
+static WabtResult on_assert_malformed_command(Context* ctx,
+ WabtStringSlice filename,
+ WabtStringSlice text) {
+ WabtBinaryErrorHandler* error_handler =
new_custom_error_handler(ctx, "assert_malformed");
- WasmInterpreterEnvironment env;
- WASM_ZERO_MEMORY(env);
+ WabtInterpreterEnvironment env;
+ WABT_ZERO_MEMORY(env);
init_environment(ctx->allocator, &env);
ctx->total++;
char* path = create_module_path(ctx, filename);
- WasmInterpreterModule* module;
- WasmResult result =
+ WabtInterpreterModule* module;
+ WabtResult result =
read_module(ctx->allocator, path, &env, error_handler, &module);
- if (WASM_FAILED(result)) {
+ if (WABT_FAILED(result)) {
ctx->passed++;
- result = WASM_OK;
+ result = WABT_OK;
} else {
print_command_error(ctx, "expected module to be malformed: \"%s\"", path);
- result = WASM_ERROR;
+ result = WABT_ERROR;
}
- wasm_free(ctx->allocator, path);
- wasm_destroy_interpreter_environment(ctx->allocator, &env);
+ wabt_free(ctx->allocator, path);
+ wabt_destroy_interpreter_environment(ctx->allocator, &env);
destroy_custom_error_handler(ctx->allocator, error_handler);
return result;
}
-static WasmResult on_register_command(Context* ctx,
- WasmStringSlice name,
- WasmStringSlice as) {
+static WabtResult on_register_command(Context* ctx,
+ WabtStringSlice name,
+ WabtStringSlice as) {
int module_index;
- if (!wasm_string_slice_is_empty(&name)) {
+ if (!wabt_string_slice_is_empty(&name)) {
/* The module names can be different than their registered names. We don't
* keep a hash for the module names (just the registered names), so we'll
* just iterate over all the modules to find it. */
size_t i;
module_index = -1;
for (i = 0; i < ctx->env.modules.size; ++i) {
- const WasmStringSlice* module_name = &ctx->env.modules.data[i].name;
- if (!wasm_string_slice_is_empty(module_name) &&
- wasm_string_slices_are_equal(&name, module_name)) {
+ const WabtStringSlice* module_name = &ctx->env.modules.data[i].name;
+ if (!wabt_string_slice_is_empty(module_name) &&
+ wabt_string_slices_are_equal(&name, module_name)) {
module_index = (int)i;
break;
}
@@ -1234,135 +1234,135 @@ static WasmResult on_register_command(Context* ctx,
if (module_index < 0 || module_index >= (int)ctx->env.modules.size) {
print_command_error(ctx, "unknown module in register");
- return WASM_ERROR;
+ return WABT_ERROR;
}
- WasmStringSlice dup_as = wasm_dup_string_slice(ctx->allocator, as);
- WasmBinding* binding = wasm_insert_binding(
+ WabtStringSlice dup_as = wabt_dup_string_slice(ctx->allocator, as);
+ WabtBinding* binding = wabt_insert_binding(
ctx->allocator, &ctx->env.registered_module_bindings, &dup_as);
binding->index = module_index;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_assert_unlinkable_command(Context* ctx,
- WasmStringSlice filename,
- WasmStringSlice text) {
- WasmBinaryErrorHandler* error_handler =
+static WabtResult on_assert_unlinkable_command(Context* ctx,
+ WabtStringSlice filename,
+ WabtStringSlice text) {
+ WabtBinaryErrorHandler* error_handler =
new_custom_error_handler(ctx, "assert_unlinkable");
ctx->total++;
char* path = create_module_path(ctx, filename);
- WasmInterpreterModule* module;
- WasmInterpreterEnvironmentMark mark =
- wasm_mark_interpreter_environment(&ctx->env);
- WasmResult result =
+ WabtInterpreterModule* module;
+ WabtInterpreterEnvironmentMark mark =
+ wabt_mark_interpreter_environment(&ctx->env);
+ WabtResult result =
read_module(ctx->allocator, path, &ctx->env, error_handler, &module);
- wasm_reset_interpreter_environment_to_mark(ctx->allocator, &ctx->env, mark);
+ wabt_reset_interpreter_environment_to_mark(ctx->allocator, &ctx->env, mark);
- if (WASM_FAILED(result)) {
+ if (WABT_FAILED(result)) {
ctx->passed++;
- result = WASM_OK;
+ result = WABT_OK;
} else {
print_command_error(ctx, "expected module to be unlinkable: \"%s\"", path);
- result = WASM_ERROR;
+ result = WABT_ERROR;
}
- wasm_free(ctx->allocator, path);
+ wabt_free(ctx->allocator, path);
destroy_custom_error_handler(ctx->allocator, error_handler);
return result;
}
-static WasmResult on_assert_invalid_command(Context* ctx,
- WasmStringSlice filename,
- WasmStringSlice text) {
- WasmBinaryErrorHandler* error_handler =
+static WabtResult on_assert_invalid_command(Context* ctx,
+ WabtStringSlice filename,
+ WabtStringSlice text) {
+ WabtBinaryErrorHandler* error_handler =
new_custom_error_handler(ctx, "assert_invalid");
- WasmInterpreterEnvironment env;
- WASM_ZERO_MEMORY(env);
+ WabtInterpreterEnvironment env;
+ WABT_ZERO_MEMORY(env);
init_environment(ctx->allocator, &env);
ctx->total++;
char* path = create_module_path(ctx, filename);
- WasmInterpreterModule* module;
- WasmResult result =
+ WabtInterpreterModule* module;
+ WabtResult result =
read_module(ctx->allocator, path, &env, error_handler, &module);
- if (WASM_FAILED(result)) {
+ if (WABT_FAILED(result)) {
ctx->passed++;
- result = WASM_OK;
+ result = WABT_OK;
} else {
print_command_error(ctx, "expected module to be invalid: \"%s\"", path);
- result = WASM_ERROR;
+ result = WABT_ERROR;
}
- wasm_free(ctx->allocator, path);
- wasm_destroy_interpreter_environment(ctx->allocator, &env);
+ wabt_free(ctx->allocator, path);
+ wabt_destroy_interpreter_environment(ctx->allocator, &env);
destroy_custom_error_handler(ctx->allocator, error_handler);
return result;
}
-static WasmResult on_assert_uninstantiable_command(Context* ctx,
- WasmStringSlice filename,
- WasmStringSlice text) {
+static WabtResult on_assert_uninstantiable_command(Context* ctx,
+ WabtStringSlice filename,
+ WabtStringSlice text) {
ctx->total++;
char* path = create_module_path(ctx, filename);
- WasmInterpreterModule* module;
- WasmInterpreterEnvironmentMark mark =
- wasm_mark_interpreter_environment(&ctx->env);
- WasmResult result =
+ WabtInterpreterModule* module;
+ WabtInterpreterEnvironmentMark mark =
+ wabt_mark_interpreter_environment(&ctx->env);
+ WabtResult result =
read_module(ctx->allocator, path, &ctx->env, &s_error_handler, &module);
- if (WASM_SUCCEEDED(result)) {
- WasmInterpreterResult iresult =
+ if (WABT_SUCCEEDED(result)) {
+ WabtInterpreterResult iresult =
run_start_function(ctx->allocator, &ctx->thread, module);
- if (iresult == WASM_INTERPRETER_OK) {
+ if (iresult == WABT_INTERPRETER_OK) {
print_command_error(ctx, "expected error running start function: \"%s\"",
path);
- result = WASM_ERROR;
+ result = WABT_ERROR;
} else {
ctx->passed++;
- result = WASM_OK;
+ result = WABT_OK;
}
} else {
print_command_error(ctx, "error reading module: \"%s\"", path);
- result = WASM_ERROR;
+ result = WABT_ERROR;
}
- wasm_reset_interpreter_environment_to_mark(ctx->allocator, &ctx->env, mark);
- wasm_free(ctx->allocator, path);
+ wabt_reset_interpreter_environment_to_mark(ctx->allocator, &ctx->env, mark);
+ wabt_free(ctx->allocator, path);
return result;
}
-static WasmBool typed_values_are_equal(const WasmInterpreterTypedValue* tv1,
- const WasmInterpreterTypedValue* tv2) {
+static WabtBool typed_values_are_equal(const WabtInterpreterTypedValue* tv1,
+ const WabtInterpreterTypedValue* tv2) {
if (tv1->type != tv2->type)
- return WASM_FALSE;
+ return WABT_FALSE;
switch (tv1->type) {
- case WASM_TYPE_I32: return tv1->value.i32 == tv2->value.i32;
- case WASM_TYPE_F32: return tv1->value.f32_bits == tv2->value.f32_bits;
- case WASM_TYPE_I64: return tv1->value.i64 == tv2->value.i64;
- case WASM_TYPE_F64: return tv1->value.f64_bits == tv2->value.f64_bits;
- default: assert(0); return WASM_FALSE;
+ case WABT_TYPE_I32: return tv1->value.i32 == tv2->value.i32;
+ case WABT_TYPE_F32: return tv1->value.f32_bits == tv2->value.f32_bits;
+ case WABT_TYPE_I64: return tv1->value.i64 == tv2->value.i64;
+ case WABT_TYPE_F64: return tv1->value.f64_bits == tv2->value.f64_bits;
+ default: assert(0); return WABT_FALSE;
}
}
-static WasmResult on_assert_return_command(
+static WabtResult on_assert_return_command(
Context* ctx,
Action* action,
- WasmInterpreterTypedValueVector* expected) {
- WasmInterpreterTypedValueVector results;
- WasmInterpreterResult iresult;
+ WabtInterpreterTypedValueVector* expected) {
+ WabtInterpreterTypedValueVector results;
+ WabtInterpreterResult iresult;
ctx->total++;
- WasmResult result = run_action(ctx, action, &iresult, &results, RUN_QUIET);
+ WabtResult result = run_action(ctx, action, &iresult, &results, RUN_QUIET);
- if (WASM_SUCCEEDED(result)) {
- if (iresult == WASM_INTERPRETER_OK) {
+ if (WABT_SUCCEEDED(result)) {
+ if (iresult == WABT_INTERPRETER_OK) {
if (results.size == expected->size) {
size_t i;
for (i = 0; i < results.size; ++i) {
- const WasmInterpreterTypedValue* expected_tv = &expected->data[i];
- const WasmInterpreterTypedValue* actual_tv = &results.data[i];
+ const WabtInterpreterTypedValue* expected_tv = &expected->data[i];
+ const WabtInterpreterTypedValue* actual_tv = &results.data[i];
if (!typed_values_are_equal(expected_tv, actual_tv)) {
char expected_str[MAX_TYPED_VALUE_CHARS];
char actual_str[MAX_TYPED_VALUE_CHARS];
@@ -1371,7 +1371,7 @@ static WasmResult on_assert_return_command(
print_command_error(ctx, "mismatch in result %" PRIzd
" of assert_return: expected %s, got %s",
i, expected_str, actual_str);
- result = WASM_ERROR;
+ result = WABT_ERROR;
}
}
} else {
@@ -1379,132 +1379,132 @@ static WasmResult on_assert_return_command(
ctx, "result length mismatch in assert_return: expected %" PRIzd
", got %" PRIzd,
expected->size, results.size);
- result = WASM_ERROR;
+ result = WABT_ERROR;
}
} else {
print_command_error(ctx, "unexpected trap: %s", s_trap_strings[iresult]);
- result = WASM_ERROR;
+ result = WABT_ERROR;
}
}
- if (WASM_SUCCEEDED(result))
+ if (WABT_SUCCEEDED(result))
ctx->passed++;
- wasm_destroy_interpreter_typed_value_vector(ctx->allocator, &results);
+ wabt_destroy_interpreter_typed_value_vector(ctx->allocator, &results);
return result;
}
-static WasmResult on_assert_return_nan_command(Context* ctx, Action* action) {
- WasmInterpreterTypedValueVector results;
- WasmInterpreterResult iresult;
+static WabtResult on_assert_return_nan_command(Context* ctx, Action* action) {
+ WabtInterpreterTypedValueVector results;
+ WabtInterpreterResult iresult;
ctx->total++;
- WasmResult result = run_action(ctx, action, &iresult, &results, RUN_QUIET);
- if (WASM_SUCCEEDED(result)) {
- if (iresult == WASM_INTERPRETER_OK) {
+ WabtResult result = run_action(ctx, action, &iresult, &results, RUN_QUIET);
+ if (WABT_SUCCEEDED(result)) {
+ if (iresult == WABT_INTERPRETER_OK) {
if (results.size != 1) {
print_command_error(ctx, "expected one result, got %" PRIzd,
results.size);
- result = WASM_ERROR;
+ result = WABT_ERROR;
}
- const WasmInterpreterTypedValue* actual = &results.data[0];
+ const WabtInterpreterTypedValue* actual = &results.data[0];
switch (actual->type) {
- case WASM_TYPE_F32:
- if (!is_nan_f32(actual->value.f32_bits)) {
+ case WABT_TYPE_F32:
+ if (!wabt_is_nan_f32(actual->value.f32_bits)) {
char actual_str[MAX_TYPED_VALUE_CHARS];
sprint_typed_value(actual_str, sizeof(actual_str), actual);
print_command_error(ctx, "expected result to be nan, got %s",
actual_str);
- result = WASM_ERROR;
+ result = WABT_ERROR;
}
break;
- case WASM_TYPE_F64:
- if (!is_nan_f64(actual->value.f64_bits)) {
+ case WABT_TYPE_F64:
+ if (!wabt_is_nan_f64(actual->value.f64_bits)) {
char actual_str[MAX_TYPED_VALUE_CHARS];
sprint_typed_value(actual_str, sizeof(actual_str), actual);
print_command_error(ctx, "expected result to be nan, got %s",
actual_str);
- result = WASM_ERROR;
+ result = WABT_ERROR;
}
break;
default:
print_command_error(ctx,
"expected result type to be f32 or f64, got %s",
- wasm_get_type_name(actual->type));
- result = WASM_ERROR;
+ wabt_get_type_name(actual->type));
+ result = WABT_ERROR;
break;
}
} else {
print_command_error(ctx, "unexpected trap: %s", s_trap_strings[iresult]);
- result = WASM_ERROR;
+ result = WABT_ERROR;
}
}
- if (WASM_SUCCEEDED(result))
+ if (WABT_SUCCEEDED(result))
ctx->passed++;
- wasm_destroy_interpreter_typed_value_vector(ctx->allocator, &results);
- return WASM_OK;
+ wabt_destroy_interpreter_typed_value_vector(ctx->allocator, &results);
+ return WABT_OK;
}
-static WasmResult on_assert_trap_command(Context* ctx,
+static WabtResult on_assert_trap_command(Context* ctx,
Action* action,
- WasmStringSlice text) {
- WasmInterpreterTypedValueVector results;
- WasmInterpreterResult iresult;
+ WabtStringSlice text) {
+ WabtInterpreterTypedValueVector results;
+ WabtInterpreterResult iresult;
ctx->total++;
- WasmResult result = run_action(ctx, action, &iresult, &results, RUN_QUIET);
- if (WASM_SUCCEEDED(result)) {
- if (iresult != WASM_INTERPRETER_OK) {
+ WabtResult result = run_action(ctx, action, &iresult, &results, RUN_QUIET);
+ if (WABT_SUCCEEDED(result)) {
+ if (iresult != WABT_INTERPRETER_OK) {
ctx->passed++;
} else {
print_command_error(ctx, "expected trap: \"" PRIstringslice "\"",
- WASM_PRINTF_STRING_SLICE_ARG(text));
- result = WASM_ERROR;
+ WABT_PRINTF_STRING_SLICE_ARG(text));
+ result = WABT_ERROR;
}
}
- wasm_destroy_interpreter_typed_value_vector(ctx->allocator, &results);
+ wabt_destroy_interpreter_typed_value_vector(ctx->allocator, &results);
return result;
}
-static WasmResult on_assert_exhaustion_command(Context* ctx,
+static WabtResult on_assert_exhaustion_command(Context* ctx,
Action* action) {
- WasmInterpreterTypedValueVector results;
- WasmInterpreterResult iresult;
+ WabtInterpreterTypedValueVector results;
+ WabtInterpreterResult iresult;
ctx->total++;
- WasmResult result = run_action(ctx, action, &iresult, &results, RUN_QUIET);
- if (WASM_SUCCEEDED(result)) {
- if (iresult == WASM_INTERPRETER_TRAP_CALL_STACK_EXHAUSTED ||
- iresult == WASM_INTERPRETER_TRAP_VALUE_STACK_EXHAUSTED) {
+ WabtResult result = run_action(ctx, action, &iresult, &results, RUN_QUIET);
+ if (WABT_SUCCEEDED(result)) {
+ if (iresult == WABT_INTERPRETER_TRAP_CALL_STACK_EXHAUSTED ||
+ iresult == WABT_INTERPRETER_TRAP_VALUE_STACK_EXHAUSTED) {
ctx->passed++;
} else {
print_command_error(ctx, "expected call stack exhaustion");
- result = WASM_ERROR;
+ result = WABT_ERROR;
}
}
- wasm_destroy_interpreter_typed_value_vector(ctx->allocator, &results);
+ wabt_destroy_interpreter_typed_value_vector(ctx->allocator, &results);
return result;
}
-static void destroy_action(WasmAllocator* allocator, Action* action) {
- wasm_destroy_interpreter_typed_value_vector(allocator, &action->args);
+static void destroy_action(WabtAllocator* allocator, Action* action) {
+ wabt_destroy_interpreter_typed_value_vector(allocator, &action->args);
}
-static WasmResult parse_command(Context* ctx) {
+static WabtResult parse_command(Context* ctx) {
EXPECT("{");
EXPECT_KEY("type");
if (match(ctx, "\"module\"")) {
- WasmStringSlice name;
- WasmStringSlice filename;
- WASM_ZERO_MEMORY(name);
- WASM_ZERO_MEMORY(filename);
+ WabtStringSlice name;
+ WabtStringSlice filename;
+ WABT_ZERO_MEMORY(name);
+ WABT_ZERO_MEMORY(filename);
EXPECT(",");
CHECK_RESULT(parse_line(ctx));
@@ -1514,7 +1514,7 @@ static WasmResult parse_command(Context* ctx) {
on_module_command(ctx, filename, name);
} else if (match(ctx, "\"action\"")) {
Action action;
- WASM_ZERO_MEMORY(action);
+ WABT_ZERO_MEMORY(action);
EXPECT(",");
CHECK_RESULT(parse_line(ctx));
@@ -1523,10 +1523,10 @@ static WasmResult parse_command(Context* ctx) {
on_action_command(ctx, &action);
destroy_action(ctx->allocator, &action);
} else if (match(ctx, "\"register\"")) {
- WasmStringSlice as;
- WasmStringSlice name;
- WASM_ZERO_MEMORY(as);
- WASM_ZERO_MEMORY(name);
+ WabtStringSlice as;
+ WabtStringSlice name;
+ WABT_ZERO_MEMORY(as);
+ WABT_ZERO_MEMORY(name);
EXPECT(",");
CHECK_RESULT(parse_line(ctx));
@@ -1535,10 +1535,10 @@ static WasmResult parse_command(Context* ctx) {
PARSE_KEY_STRING_VALUE("as", &as);
on_register_command(ctx, name, as);
} else if (match(ctx, "\"assert_malformed\"")) {
- WasmStringSlice filename;
- WasmStringSlice text;
- WASM_ZERO_MEMORY(filename);
- WASM_ZERO_MEMORY(text);
+ WabtStringSlice filename;
+ WabtStringSlice text;
+ WABT_ZERO_MEMORY(filename);
+ WABT_ZERO_MEMORY(text);
EXPECT(",");
CHECK_RESULT(parse_line(ctx));
@@ -1548,8 +1548,8 @@ static WasmResult parse_command(Context* ctx) {
PARSE_KEY_STRING_VALUE("text", &text);
on_assert_malformed_command(ctx, filename, text);
} else if (match(ctx, "\"assert_invalid\"")) {
- WasmStringSlice filename;
- WasmStringSlice text;
+ WabtStringSlice filename;
+ WabtStringSlice text;
EXPECT(",");
CHECK_RESULT(parse_line(ctx));
EXPECT(",");
@@ -1558,10 +1558,10 @@ static WasmResult parse_command(Context* ctx) {
PARSE_KEY_STRING_VALUE("text", &text);
on_assert_invalid_command(ctx, filename, text);
} else if (match(ctx, "\"assert_unlinkable\"")) {
- WasmStringSlice filename;
- WasmStringSlice text;
- WASM_ZERO_MEMORY(filename);
- WASM_ZERO_MEMORY(text);
+ WabtStringSlice filename;
+ WabtStringSlice text;
+ WABT_ZERO_MEMORY(filename);
+ WABT_ZERO_MEMORY(text);
EXPECT(",");
CHECK_RESULT(parse_line(ctx));
@@ -1571,10 +1571,10 @@ static WasmResult parse_command(Context* ctx) {
PARSE_KEY_STRING_VALUE("text", &text);
on_assert_unlinkable_command(ctx, filename, text);
} else if (match(ctx, "\"assert_uninstantiable\"")) {
- WasmStringSlice filename;
- WasmStringSlice text;
- WASM_ZERO_MEMORY(filename);
- WASM_ZERO_MEMORY(text);
+ WabtStringSlice filename;
+ WabtStringSlice text;
+ WABT_ZERO_MEMORY(filename);
+ WABT_ZERO_MEMORY(text);
EXPECT(",");
CHECK_RESULT(parse_line(ctx));
@@ -1585,9 +1585,9 @@ static WasmResult parse_command(Context* ctx) {
on_assert_uninstantiable_command(ctx, filename, text);
} else if (match(ctx, "\"assert_return\"")) {
Action action;
- WasmInterpreterTypedValueVector expected;
- WASM_ZERO_MEMORY(action);
- WASM_ZERO_MEMORY(expected);
+ WabtInterpreterTypedValueVector expected;
+ WABT_ZERO_MEMORY(action);
+ WABT_ZERO_MEMORY(expected);
EXPECT(",");
CHECK_RESULT(parse_line(ctx));
@@ -1597,29 +1597,29 @@ static WasmResult parse_command(Context* ctx) {
EXPECT_KEY("expected");
CHECK_RESULT(parse_const_vector(ctx, &expected));
on_assert_return_command(ctx, &action, &expected);
- wasm_destroy_interpreter_typed_value_vector(ctx->allocator, &expected);
+ wabt_destroy_interpreter_typed_value_vector(ctx->allocator, &expected);
destroy_action(ctx->allocator, &action);
} else if (match(ctx, "\"assert_return_nan\"")) {
Action action;
- WasmTypeVector expected;
- WASM_ZERO_MEMORY(action);
+ WabtTypeVector expected;
+ WABT_ZERO_MEMORY(action);
EXPECT(",");
CHECK_RESULT(parse_line(ctx));
EXPECT(",");
CHECK_RESULT(parse_action(ctx, &action));
EXPECT(",");
- /* Not needed for wasm-interp, but useful for other parsers. */
+ /* Not needed for wabt-interp, but useful for other parsers. */
EXPECT_KEY("expected");
CHECK_RESULT(parse_type_vector(ctx, &expected));
on_assert_return_nan_command(ctx, &action);
- wasm_destroy_type_vector(ctx->allocator, &expected);
+ wabt_destroy_type_vector(ctx->allocator, &expected);
destroy_action(ctx->allocator, &action);
} else if (match(ctx, "\"assert_trap\"")) {
Action action;
- WasmStringSlice text;
- WASM_ZERO_MEMORY(action);
- WASM_ZERO_MEMORY(text);
+ WabtStringSlice text;
+ WABT_ZERO_MEMORY(action);
+ WABT_ZERO_MEMORY(text);
EXPECT(",");
CHECK_RESULT(parse_line(ctx));
@@ -1631,9 +1631,9 @@ static WasmResult parse_command(Context* ctx) {
destroy_action(ctx->allocator, &action);
} else if (match(ctx, "\"assert_exhaustion\"")) {
Action action;
- WasmStringSlice text;
- WASM_ZERO_MEMORY(action);
- WASM_ZERO_MEMORY(text);
+ WabtStringSlice text;
+ WABT_ZERO_MEMORY(action);
+ WABT_ZERO_MEMORY(text);
EXPECT(",");
CHECK_RESULT(parse_line(ctx));
@@ -1643,53 +1643,53 @@ static WasmResult parse_command(Context* ctx) {
destroy_action(ctx->allocator, &action);
} else {
print_command_error(ctx, "unknown command type");
- return WASM_ERROR;
+ return WABT_ERROR;
}
EXPECT("}");
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult parse_commands(Context* ctx) {
+static WabtResult parse_commands(Context* ctx) {
EXPECT("{");
PARSE_KEY_STRING_VALUE("source_filename", &ctx->source_filename);
EXPECT(",");
EXPECT_KEY("commands");
EXPECT("[");
- WasmBool first = WASM_TRUE;
+ WabtBool first = WABT_TRUE;
while (!match(ctx, "]")) {
if (!first)
EXPECT(",");
CHECK_RESULT(parse_command(ctx));
- first = WASM_FALSE;
+ first = WABT_FALSE;
}
EXPECT("}");
- return WASM_OK;
+ return WABT_OK;
}
static void destroy_context(Context* ctx) {
- wasm_destroy_interpreter_thread(ctx->allocator, &ctx->thread);
- wasm_destroy_interpreter_environment(ctx->allocator, &ctx->env);
- wasm_free(ctx->allocator, ctx->json_data);
+ wabt_destroy_interpreter_thread(ctx->allocator, &ctx->thread);
+ wabt_destroy_interpreter_environment(ctx->allocator, &ctx->env);
+ wabt_free(ctx->allocator, ctx->json_data);
}
-static WasmResult read_and_run_spec_json(WasmAllocator* allocator,
+static WabtResult read_and_run_spec_json(WabtAllocator* allocator,
const char* spec_json_filename) {
Context ctx;
- WASM_ZERO_MEMORY(ctx);
+ WABT_ZERO_MEMORY(ctx);
ctx.allocator = allocator;
ctx.loc.filename = spec_json_filename;
ctx.loc.line = 1;
ctx.loc.first_column = 1;
init_environment(allocator, &ctx.env);
- wasm_init_interpreter_thread(allocator, &ctx.env, &ctx.thread,
+ wabt_init_interpreter_thread(allocator, &ctx.env, &ctx.thread,
&s_thread_options);
void* data;
size_t size;
- WasmResult result =
- wasm_read_file(allocator, spec_json_filename, &data, &size);
- if (WASM_FAILED(result))
- return WASM_ERROR;
+ WabtResult result =
+ wabt_read_file(allocator, spec_json_filename, &data, &size);
+ if (WABT_FAILED(result))
+ return WABT_ERROR;
ctx.json_data = data;
ctx.json_data_size = size;
@@ -1701,28 +1701,28 @@ static WasmResult read_and_run_spec_json(WasmAllocator* allocator,
}
int main(int argc, char** argv) {
- WasmStackAllocator stack_allocator;
- WasmAllocator* allocator;
+ WabtStackAllocator stack_allocator;
+ WabtAllocator* allocator;
- wasm_init_stdio();
+ wabt_init_stdio();
parse_options(argc, argv);
- s_stdout_stream = wasm_init_stdout_stream();
+ s_stdout_stream = wabt_init_stdout_stream();
if (s_use_libc_allocator) {
- allocator = &g_wasm_libc_allocator;
+ allocator = &g_wabt_libc_allocator;
} else {
- wasm_init_stack_allocator(&stack_allocator, &g_wasm_libc_allocator);
+ wabt_init_stack_allocator(&stack_allocator, &g_wabt_libc_allocator);
allocator = &stack_allocator.allocator;
}
- WasmResult result;
+ WabtResult result;
if (s_spec) {
result = read_and_run_spec_json(allocator, s_infile);
} else {
result = read_and_run_module(allocator, s_infile);
}
- wasm_print_allocator_stats(allocator);
- wasm_destroy_allocator(allocator);
+ wabt_print_allocator_stats(allocator);
+ wabt_destroy_allocator(allocator);
return result;
}
diff --git a/src/tools/wasm-link.c b/src/tools/wasm-link.c
index 5f8ced18..07bd20c8 100644
--- a/src/tools/wasm-link.c
+++ b/src/tools/wasm-link.c
@@ -27,9 +27,9 @@
#include "binary-reader-linker.h"
#define PROGRAM_NAME "wasm-link"
-#define NOPE WASM_OPTION_NO_ARGUMENT
-#define YEP WASM_OPTION_HAS_ARGUMENT
-#define FIRST_KNOWN_SECTION WASM_BINARY_SECTION_TYPE
+#define NOPE WABT_OPTION_NO_ARGUMENT
+#define YEP WABT_OPTION_HAS_ARGUMENT
+#define FIRST_KNOWN_SECTION WABT_BINARY_SECTION_TYPE
enum { FLAG_VERBOSE, FLAG_OUTPUT, FLAG_RELOCATABLE, FLAG_HELP, NUM_FLAGS };
@@ -38,7 +38,7 @@ static const char s_description[] =
"\n"
" $ wasm-link m1.wasm m2.wasm -o out.wasm\n";
-static WasmOption s_options[] = {
+static WabtOption s_options[] = {
{FLAG_VERBOSE, 'v', "verbose", NULL, NOPE,
"use multiple times for more info"},
{FLAG_OUTPUT, 'o', "output", "FILE", YEP, "output wasm binary file"},
@@ -46,33 +46,33 @@ static WasmOption s_options[] = {
"output a relocatable object file"},
{FLAG_HELP, 'h', "help", NULL, NOPE, "print this help message"},
};
-WASM_STATIC_ASSERT(NUM_FLAGS == WASM_ARRAY_SIZE(s_options));
+WABT_STATIC_ASSERT(NUM_FLAGS == WABT_ARRAY_SIZE(s_options));
typedef const char* String;
-WASM_DEFINE_VECTOR(string, String);
+WABT_DEFINE_VECTOR(string, String);
-static WasmBool s_verbose;
-static WasmBool s_relocatable;
+static WabtBool s_verbose;
+static WabtBool s_relocatable;
static const char* s_outfile = "a.wasm";
static StringVector s_infiles;
-static WasmFileWriter s_log_stream_writer;
-static WasmStream s_log_stream;
+static WabtFileWriter s_log_stream_writer;
+static WabtStream s_log_stream;
typedef struct Context {
- WasmStream stream;
- WasmLinkerInputBinaryVector inputs;
+ WabtStream stream;
+ WabtLinkerInputBinaryVector inputs;
ssize_t current_section_payload_offset;
- WasmAllocator* allocator;
+ WabtAllocator* allocator;
} Context;
-static void on_option(struct WasmOptionParser* parser,
- struct WasmOption* option,
+static void on_option(struct WabtOptionParser* parser,
+ struct WabtOption* option,
const char* argument) {
switch (option->id) {
case FLAG_VERBOSE:
s_verbose++;
- wasm_init_file_writer_existing(&s_log_stream_writer, stdout);
- wasm_init_stream(&s_log_stream, &s_log_stream_writer.base, NULL);
+ wabt_init_file_writer_existing(&s_log_stream_writer, stdout);
+ wabt_init_stream(&s_log_stream, &s_log_stream_writer.base, NULL);
break;
case FLAG_OUTPUT:
@@ -80,83 +80,83 @@ static void on_option(struct WasmOptionParser* parser,
break;
case FLAG_RELOCATABLE:
- s_relocatable = WASM_TRUE;
+ s_relocatable = WABT_TRUE;
break;
case FLAG_HELP:
- wasm_print_help(parser, PROGRAM_NAME);
+ wabt_print_help(parser, PROGRAM_NAME);
exit(0);
break;
}
}
-static void on_argument(struct WasmOptionParser* parser, const char* argument) {
- WasmAllocator* allocator = parser->user_data;
- wasm_append_string_value(allocator, &s_infiles, &argument);
+static void on_argument(struct WabtOptionParser* parser, const char* argument) {
+ WabtAllocator* allocator = parser->user_data;
+ wabt_append_string_value(allocator, &s_infiles, &argument);
}
-static void on_option_error(struct WasmOptionParser* parser,
+static void on_option_error(struct WabtOptionParser* parser,
const char* message) {
- WASM_FATAL("%s\n", message);
+ WABT_FATAL("%s\n", message);
}
-static void parse_options(WasmAllocator* allocator, int argc, char** argv) {
- WasmOptionParser parser;
- WASM_ZERO_MEMORY(parser);
+static void parse_options(WabtAllocator* allocator, int argc, char** argv) {
+ WabtOptionParser parser;
+ WABT_ZERO_MEMORY(parser);
parser.description = s_description;
parser.options = s_options;
- parser.num_options = WASM_ARRAY_SIZE(s_options);
+ parser.num_options = WABT_ARRAY_SIZE(s_options);
parser.on_option = on_option;
parser.on_argument = on_argument;
parser.on_error = on_option_error;
parser.user_data = allocator;
- wasm_parse_options(&parser, argc, argv);
+ wabt_parse_options(&parser, argc, argv);
if (!s_infiles.size) {
- wasm_print_help(&parser, PROGRAM_NAME);
- WASM_FATAL("No inputs files specified.\n");
+ wabt_print_help(&parser, PROGRAM_NAME);
+ WABT_FATAL("No inputs files specified.\n");
}
}
-void wasm_destroy_section(WasmAllocator* allocator, WasmSection* section) {
- wasm_destroy_reloc_vector(allocator, &section->relocations);
+void wabt_destroy_section(WabtAllocator* allocator, WabtSection* section) {
+ wabt_destroy_reloc_vector(allocator, &section->relocations);
switch (section->section_code) {
- case WASM_BINARY_SECTION_DATA:
- wasm_destroy_data_segment_vector(allocator, &section->data_segments);
+ case WABT_BINARY_SECTION_DATA:
+ wabt_destroy_data_segment_vector(allocator, &section->data_segments);
break;
default:
break;
}
}
-void wasm_destroy_binary(WasmAllocator* allocator,
- WasmLinkerInputBinary* binary) {
- WASM_DESTROY_VECTOR_AND_ELEMENTS(allocator, binary->sections, section);
- wasm_destroy_function_import_vector(allocator, &binary->function_imports);
- wasm_destroy_global_import_vector(allocator, &binary->global_imports);
- wasm_destroy_string_slice_vector(allocator, &binary->debug_names);
- wasm_destroy_export_vector(allocator, &binary->exports);
- wasm_free(allocator, binary->data);
+void wabt_destroy_binary(WabtAllocator* allocator,
+ WabtLinkerInputBinary* binary) {
+ WABT_DESTROY_VECTOR_AND_ELEMENTS(allocator, binary->sections, section);
+ wabt_destroy_function_import_vector(allocator, &binary->function_imports);
+ wabt_destroy_global_import_vector(allocator, &binary->global_imports);
+ wabt_destroy_string_slice_vector(allocator, &binary->debug_names);
+ wabt_destroy_export_vector(allocator, &binary->exports);
+ wabt_free(allocator, binary->data);
}
-static uint32_t relocate_func_index(WasmLinkerInputBinary* binary,
+static uint32_t relocate_func_index(WabtLinkerInputBinary* binary,
uint32_t function_index) {
uint32_t offset;
if (function_index >= binary->function_imports.size) {
/* locally declared function call */
offset = binary->function_index_offset;
if (s_verbose)
- wasm_writef(&s_log_stream, "func reloc %d + %d\n", function_index,
+ wabt_writef(&s_log_stream, "func reloc %d + %d\n", function_index,
offset);
} else {
/* imported function call */
- WasmFunctionImport* import = &binary->function_imports.data[function_index];
+ WabtFunctionImport* import = &binary->function_imports.data[function_index];
offset = binary->imported_function_index_offset;
if (!import->active) {
function_index = import->foreign_index;
offset = import->foreign_binary->function_index_offset;
if (s_verbose)
- wasm_writef(&s_log_stream,
+ wabt_writef(&s_log_stream,
"reloc for disabled import. new index = %d + %d\n",
function_index, offset);
}
@@ -164,27 +164,27 @@ static uint32_t relocate_func_index(WasmLinkerInputBinary* binary,
return function_index + offset;
}
-static void apply_relocation(WasmSection* section, WasmReloc* r) {
- WasmLinkerInputBinary* binary = section->binary;
+static void apply_relocation(WabtSection* section, WabtReloc* r) {
+ WabtLinkerInputBinary* binary = section->binary;
uint8_t* section_data = &binary->data[section->offset];
size_t section_size = section->size;
uint32_t cur_value = 0, new_value = 0;
- wasm_read_u32_leb128(section_data + r->offset, section_data + section_size,
+ wabt_read_u32_leb128(section_data + r->offset, section_data + section_size,
&cur_value);
uint32_t offset = 0;
switch (r->type) {
- case WASM_RELOC_FUNC_INDEX_LEB:
+ case WABT_RELOC_FUNC_INDEX_LEB:
new_value = relocate_func_index(binary, cur_value);
break;
- case WASM_RELOC_TABLE_INDEX_SLEB:
+ case WABT_RELOC_TABLE_INDEX_SLEB:
printf("%s: table index reloc: %d offset=%d\n", binary->filename,
cur_value, binary->table_index_offset);
offset = binary->table_index_offset;
new_value = cur_value + offset;
break;
- case WASM_RELOC_GLOBAL_INDEX_LEB:
+ case WABT_RELOC_GLOBAL_INDEX_LEB:
if (cur_value >= binary->global_imports.size) {
offset = binary->global_index_offset;
} else {
@@ -193,82 +193,82 @@ static void apply_relocation(WasmSection* section, WasmReloc* r) {
new_value = cur_value + offset;
break;
default:
- WASM_FATAL("unhandled relocation type: %s\n",
- wasm_get_reloc_type_name(r->type));
+ WABT_FATAL("unhandled relocation type: %s\n",
+ wabt_get_reloc_type_name(r->type));
break;
}
- wasm_write_fixed_u32_leb128_raw(section_data + r->offset,
+ wabt_write_fixed_u32_leb128_raw(section_data + r->offset,
section_data + section_size, new_value);
}
-static void apply_relocations(WasmSection* section) {
+static void apply_relocations(WabtSection* section) {
if (!section->relocations.size)
return;
if (s_verbose)
- wasm_writef(&s_log_stream, "apply_relocations: %s\n",
- wasm_get_section_name(section->section_code));
+ wabt_writef(&s_log_stream, "apply_relocations: %s\n",
+ wabt_get_section_name(section->section_code));
/* Perform relocations in-place */
size_t i;
for (i = 0; i < section->relocations.size; i++) {
- WasmReloc* reloc = &section->relocations.data[i];
+ WabtReloc* reloc = &section->relocations.data[i];
apply_relocation(section, reloc);
}
}
-static void write_section_payload(Context* ctx, WasmSection* sec) {
+static void write_section_payload(Context* ctx, WabtSection* sec) {
assert(ctx->current_section_payload_offset != -1);
sec->output_payload_offset =
ctx->stream.offset - ctx->current_section_payload_offset;
uint8_t* payload = &sec->binary->data[sec->payload_offset];
- wasm_write_data(&ctx->stream, payload, sec->payload_size, "section content");
+ wabt_write_data(&ctx->stream, payload, sec->payload_size, "section content");
}
-static void write_c_str(WasmStream* stream, const char* str, const char* desc) {
- wasm_write_str(stream, str, strlen(str), WASM_PRINT_CHARS, desc);
+static void write_c_str(WabtStream* stream, const char* str, const char* desc) {
+ wabt_write_str(stream, str, strlen(str), WABT_PRINT_CHARS, desc);
}
-static void write_slice(WasmStream* stream,
- WasmStringSlice str,
+static void write_slice(WabtStream* stream,
+ WabtStringSlice str,
const char* desc) {
- wasm_write_str(stream, str.start, str.length, WASM_PRINT_CHARS, desc);
+ wabt_write_str(stream, str.start, str.length, WABT_PRINT_CHARS, desc);
}
#define WRITE_UNKNOWN_SIZE(STREAM) \
uint32_t fixup_offset = (STREAM)->offset; \
- wasm_write_fixed_u32_leb128(STREAM, 0, "unknown size"); \
+ wabt_write_fixed_u32_leb128(STREAM, 0, "unknown size"); \
ctx->current_section_payload_offset = (STREAM)->offset; \
uint32_t start = (STREAM)->offset;
#define FIXUP_SIZE(STREAM) \
- wasm_write_fixed_u32_leb128_at(STREAM, fixup_offset, \
+ wabt_write_fixed_u32_leb128_at(STREAM, fixup_offset, \
(STREAM)->offset - start, "fixup size");
static void write_table_section(Context* ctx,
- const WasmSectionPtrVector* sections) {
+ const WabtSectionPtrVector* sections) {
/* Total section size includes the element count leb128 which is
* always 1 in the current spec */
uint32_t table_count = 1;
- uint32_t flags = WASM_BINARY_LIMITS_HAS_MAX_FLAG;
+ uint32_t flags = WABT_BINARY_LIMITS_HAS_MAX_FLAG;
uint32_t elem_count = 0;
size_t i;
for (i = 0; i < sections->size; i++) {
- WasmSection* sec = sections->data[i];
+ WabtSection* sec = sections->data[i];
elem_count += sec->binary->table_elem_count;
}
- WasmStream* stream = &ctx->stream;
+ WabtStream* stream = &ctx->stream;
WRITE_UNKNOWN_SIZE(stream);
- wasm_write_u32_leb128(stream, table_count, "table count");
- wasm_write_type(stream, WASM_TYPE_ANYFUNC);
- wasm_write_u32_leb128(stream, flags, "table elem flags");
- wasm_write_u32_leb128(stream, elem_count, "table initial length");
- wasm_write_u32_leb128(stream, elem_count, "table max length");
+ wabt_write_u32_leb128(stream, table_count, "table count");
+ wabt_write_type(stream, WABT_TYPE_ANYFUNC);
+ wabt_write_u32_leb128(stream, flags, "table elem flags");
+ wabt_write_u32_leb128(stream, elem_count, "table initial length");
+ wabt_write_u32_leb128(stream, elem_count, "table max length");
FIXUP_SIZE(stream);
}
@@ -276,58 +276,58 @@ static void write_export_section(Context* ctx) {
size_t i, j;
uint32_t total_exports = 0;
for (i = 0; i < ctx->inputs.size; i++) {
- WasmLinkerInputBinary* binary = &ctx->inputs.data[i];
+ WabtLinkerInputBinary* binary = &ctx->inputs.data[i];
total_exports += binary->exports.size;
}
- WasmStream* stream = &ctx->stream;
+ WabtStream* stream = &ctx->stream;
WRITE_UNKNOWN_SIZE(stream);
- wasm_write_u32_leb128(stream, total_exports, "export count");
+ wabt_write_u32_leb128(stream, total_exports, "export count");
for (i = 0; i < ctx->inputs.size; i++) {
- WasmLinkerInputBinary* binary = &ctx->inputs.data[i];
+ WabtLinkerInputBinary* binary = &ctx->inputs.data[i];
for (j = 0; j < binary->exports.size; j++) {
- WasmExport* export = &binary->exports.data[j];
+ WabtExport* export = &binary->exports.data[j];
write_slice(stream, export->name, "export name");
- wasm_write_u8(stream, export->kind, "export kind");
+ wabt_write_u8(stream, export->kind, "export kind");
uint32_t index = export->index;
switch (export->kind) {
- case WASM_EXTERNAL_KIND_FUNC:
+ case WABT_EXTERNAL_KIND_FUNC:
index = relocate_func_index(binary, index);
break;
default:
- WASM_FATAL("unsupport export type: %d\n", export->kind);
+ WABT_FATAL("unsupport export type: %d\n", export->kind);
break;
}
- wasm_write_u32_leb128(stream, index, "export index");
+ wabt_write_u32_leb128(stream, index, "export index");
}
}
FIXUP_SIZE(stream);
}
static void write_elem_section(Context* ctx,
- const WasmSectionPtrVector* sections) {
- WasmStream* stream = &ctx->stream;
+ const WabtSectionPtrVector* sections) {
+ WabtStream* stream = &ctx->stream;
WRITE_UNKNOWN_SIZE(stream);
size_t i;
uint32_t total_elem_count = 0;
for (i = 0; i < sections->size; i++) {
- WasmSection* sec = sections->data[i];
+ WabtSection* sec = sections->data[i];
total_elem_count += sec->binary->table_elem_count;
}
- wasm_write_u32_leb128(stream, 1, "segment count");
- wasm_write_u32_leb128(stream, 0, "table index");
- wasm_write_opcode(&ctx->stream, WASM_OPCODE_I32_CONST);
- wasm_write_i32_leb128(&ctx->stream, 0, "elem init literal");
- wasm_write_opcode(&ctx->stream, WASM_OPCODE_END);
- wasm_write_u32_leb128(stream, total_elem_count, "num elements");
+ wabt_write_u32_leb128(stream, 1, "segment count");
+ wabt_write_u32_leb128(stream, 0, "table index");
+ wabt_write_opcode(&ctx->stream, WABT_OPCODE_I32_CONST);
+ wabt_write_i32_leb128(&ctx->stream, 0, "elem init literal");
+ wabt_write_opcode(&ctx->stream, WABT_OPCODE_END);
+ wabt_write_u32_leb128(stream, total_elem_count, "num elements");
ctx->current_section_payload_offset = stream->offset;
for (i = 0; i < sections->size; i++) {
- WasmSection* sec = sections->data[i];
+ WabtSection* sec = sections->data[i];
apply_relocations(sec);
write_section_payload(ctx, sec);
}
@@ -336,52 +336,52 @@ static void write_elem_section(Context* ctx,
}
static void write_memory_section(Context* ctx,
- const WasmSectionPtrVector* sections) {
- WasmStream* stream = &ctx->stream;
+ const WabtSectionPtrVector* sections) {
+ WabtStream* stream = &ctx->stream;
WRITE_UNKNOWN_SIZE(stream);
- wasm_write_u32_leb128(stream, 1, "memory count");
+ wabt_write_u32_leb128(stream, 1, "memory count");
- WasmLimits limits;
- WASM_ZERO_MEMORY(limits);
- limits.has_max = WASM_TRUE;
+ WabtLimits limits;
+ WABT_ZERO_MEMORY(limits);
+ limits.has_max = WABT_TRUE;
size_t i;
for (i = 0; i < sections->size; i++) {
- WasmSection* sec = sections->data[i];
+ WabtSection* sec = sections->data[i];
limits.initial += sec->memory_limits.initial;
}
limits.max = limits.initial;
- wasm_write_limits(stream, &limits);
+ wabt_write_limits(stream, &limits);
FIXUP_SIZE(stream);
}
static void write_function_import(Context* ctx,
- WasmFunctionImport* import,
+ WabtFunctionImport* import,
uint32_t offset) {
- write_c_str(&ctx->stream, WASM_LINK_MODULE_NAME, "import module name");
+ write_c_str(&ctx->stream, WABT_LINK_MODULE_NAME, "import module name");
write_slice(&ctx->stream, import->name, "import field name");
- wasm_write_u8(&ctx->stream, WASM_EXTERNAL_KIND_FUNC, "import kind");
- wasm_write_u32_leb128(&ctx->stream, import->sig_index + offset,
+ wabt_write_u8(&ctx->stream, WABT_EXTERNAL_KIND_FUNC, "import kind");
+ wabt_write_u32_leb128(&ctx->stream, import->sig_index + offset,
"import signature index");
}
-static void write_global_import(Context* ctx, WasmGlobalImport* import) {
- write_c_str(&ctx->stream, WASM_LINK_MODULE_NAME, "import module name");
+static void write_global_import(Context* ctx, WabtGlobalImport* import) {
+ write_c_str(&ctx->stream, WABT_LINK_MODULE_NAME, "import module name");
write_slice(&ctx->stream, import->name, "import field name");
- wasm_write_u8(&ctx->stream, WASM_EXTERNAL_KIND_GLOBAL, "import kind");
- wasm_write_type(&ctx->stream, import->type);
- wasm_write_u8(&ctx->stream, import->mutable, "global mutability");
+ wabt_write_u8(&ctx->stream, WABT_EXTERNAL_KIND_GLOBAL, "import kind");
+ wabt_write_type(&ctx->stream, import->type);
+ wabt_write_u8(&ctx->stream, import->mutable, "global mutability");
}
static void write_import_section(Context* ctx) {
uint32_t num_imports = 0;
size_t i, j;
for (i = 0; i < ctx->inputs.size; i++) {
- WasmLinkerInputBinary* binary = &ctx->inputs.data[i];
- WasmFunctionImportVector* imports = &binary->function_imports;
+ WabtLinkerInputBinary* binary = &ctx->inputs.data[i];
+ WabtFunctionImportVector* imports = &binary->function_imports;
for (j = 0; j < imports->size; j++) {
- WasmFunctionImport* import = &imports->data[j];
+ WabtFunctionImport* import = &imports->data[j];
if (import->active)
num_imports++;
}
@@ -389,18 +389,18 @@ static void write_import_section(Context* ctx) {
}
WRITE_UNKNOWN_SIZE(&ctx->stream);
- wasm_write_u32_leb128(&ctx->stream, num_imports, "num imports");
+ wabt_write_u32_leb128(&ctx->stream, num_imports, "num imports");
for (i = 0; i < ctx->inputs.size; i++) {
- WasmLinkerInputBinary* binary = &ctx->inputs.data[i];
- WasmFunctionImportVector* imports = &binary->function_imports;
+ WabtLinkerInputBinary* binary = &ctx->inputs.data[i];
+ WabtFunctionImportVector* imports = &binary->function_imports;
for (j = 0; j < imports->size; j++) {
- WasmFunctionImport* import = &imports->data[j];
+ WabtFunctionImport* import = &imports->data[j];
if (import->active)
write_function_import(ctx, import, binary->type_index_offset);
}
- WasmGlobalImportVector* globals = &binary->global_imports;
+ WabtGlobalImportVector* globals = &binary->global_imports;
for (j = 0; j < globals->size; j++) {
write_global_import(ctx, &globals->data[j]);
}
@@ -410,16 +410,16 @@ static void write_import_section(Context* ctx) {
}
static void write_function_section(Context* ctx,
- const WasmSectionPtrVector* sections,
+ const WabtSectionPtrVector* sections,
uint32_t total_count) {
- WasmStream* stream = &ctx->stream;
+ WabtStream* stream = &ctx->stream;
WRITE_UNKNOWN_SIZE(stream);
- wasm_write_u32_leb128(stream, total_count, "function count");
+ wabt_write_u32_leb128(stream, total_count, "function count");
size_t i;
for (i = 0; i < sections->size; i++) {
- WasmSection* sec = sections->data[i];
+ WabtSection* sec = sections->data[i];
uint32_t count = sec->count;
uint32_t input_offset = 0;
uint32_t sig_index = 0;
@@ -428,41 +428,41 @@ static void write_function_section(Context* ctx,
&sec->binary->data[sec->payload_offset + sec->payload_size];
while (count--) {
input_offset +=
- wasm_read_u32_leb128(start + input_offset, end, &sig_index);
+ wabt_read_u32_leb128(start + input_offset, end, &sig_index);
sig_index += sec->binary->type_index_offset;
- wasm_write_u32_leb128(stream, sig_index, "sig");
+ wabt_write_u32_leb128(stream, sig_index, "sig");
}
}
FIXUP_SIZE(stream);
}
-static void write_data_segment(WasmStream* stream,
- WasmDataSegment* segment,
+static void write_data_segment(WabtStream* stream,
+ WabtDataSegment* segment,
uint32_t offset) {
assert(segment->memory_index == 0);
- wasm_write_u32_leb128(stream, segment->memory_index, "memory index");
- wasm_write_opcode(stream, WASM_OPCODE_I32_CONST);
- wasm_write_u32_leb128(stream, segment->offset + offset, "offset");
- wasm_write_opcode(stream, WASM_OPCODE_END);
- wasm_write_u32_leb128(stream, segment->size, "segment size");
- wasm_write_data(stream, segment->data, segment->size, "segment data");
+ wabt_write_u32_leb128(stream, segment->memory_index, "memory index");
+ wabt_write_opcode(stream, WABT_OPCODE_I32_CONST);
+ wabt_write_u32_leb128(stream, segment->offset + offset, "offset");
+ wabt_write_opcode(stream, WABT_OPCODE_END);
+ wabt_write_u32_leb128(stream, segment->size, "segment size");
+ wabt_write_data(stream, segment->data, segment->size, "segment data");
}
static void write_data_section(Context* ctx,
- WasmSectionPtrVector* sections,
+ WabtSectionPtrVector* sections,
uint32_t total_count) {
- WasmStream* stream = &ctx->stream;
+ WabtStream* stream = &ctx->stream;
WRITE_UNKNOWN_SIZE(stream);
- wasm_write_u32_leb128(stream, total_count, "data segment count");
+ wabt_write_u32_leb128(stream, total_count, "data segment count");
size_t i, j;
for (i = 0; i < sections->size; i++) {
- WasmSection* sec = sections->data[i];
+ WabtSection* sec = sections->data[i];
for (j = 0; j < sec->data_segments.size; j++) {
- WasmDataSegment* segment = &sec->data_segments.data[j];
+ WabtDataSegment* segment = &sec->data_segments.data[j];
write_data_segment(stream, segment,
- sec->binary->memory_page_offset * WASM_PAGE_SIZE);
+ sec->binary->memory_page_offset * WABT_PAGE_SIZE);
}
}
@@ -473,7 +473,7 @@ static void write_names_section(Context* ctx) {
uint32_t total_count = 0;
size_t i, j;
for (i = 0; i < ctx->inputs.size; i++) {
- WasmLinkerInputBinary* binary = &ctx->inputs.data[i];
+ WabtLinkerInputBinary* binary = &ctx->inputs.data[i];
for (j = 0; j < binary->debug_names.size; j++) {
if (j < binary->function_imports.size) {
if (!binary->function_imports.data[j].active)
@@ -486,21 +486,21 @@ static void write_names_section(Context* ctx) {
if (!total_count)
return;
- WasmStream* stream = &ctx->stream;
- wasm_write_u8(stream, WASM_BINARY_SECTION_CUSTOM, "section code");
+ WabtStream* stream = &ctx->stream;
+ wabt_write_u8(stream, WABT_BINARY_SECTION_CUSTOM, "section code");
WRITE_UNKNOWN_SIZE(stream);
write_c_str(stream, "name", "custom section name");
- wasm_write_u32_leb128(stream, total_count, "element count");
+ wabt_write_u32_leb128(stream, total_count, "element count");
for (i = 0; i < ctx->inputs.size; i++) {
- WasmLinkerInputBinary* binary = &ctx->inputs.data[i];
+ WabtLinkerInputBinary* binary = &ctx->inputs.data[i];
for (j = 0; j < binary->debug_names.size; j++) {
if (j < binary->function_imports.size) {
if (!binary->function_imports.data[j].active)
continue;
}
write_slice(stream, binary->debug_names.data[j], "function name");
- wasm_write_u32_leb128(stream, 0, "local name count");
+ wabt_write_u32_leb128(stream, 0, "local name count");
}
}
@@ -508,14 +508,14 @@ static void write_names_section(Context* ctx) {
}
static void write_reloc_section(Context* ctx,
- WasmBinarySection section_code,
- WasmSectionPtrVector* sections) {
+ WabtBinarySection section_code,
+ WabtSectionPtrVector* sections) {
size_t i, j;
uint32_t total_relocs = 0;
/* First pass to know total reloc count */
for (i = 0; i < sections->size; i++) {
- WasmSection* sec = sections->data[i];
+ WabtSection* sec = sections->data[i];
total_relocs += sec->relocations.size;
}
@@ -523,38 +523,38 @@ static void write_reloc_section(Context* ctx,
return;
char section_name[128];
- wasm_snprintf(section_name, sizeof(section_name), "%s.%s",
- WASM_BINARY_SECTION_RELOC, wasm_get_section_name(section_code));
+ wabt_snprintf(section_name, sizeof(section_name), "%s.%s",
+ WABT_BINARY_SECTION_RELOC, wabt_get_section_name(section_code));
- WasmStream* stream = &ctx->stream;
- wasm_write_u8(stream, WASM_BINARY_SECTION_CUSTOM, "section code");
+ WabtStream* stream = &ctx->stream;
+ wabt_write_u8(stream, WABT_BINARY_SECTION_CUSTOM, "section code");
WRITE_UNKNOWN_SIZE(stream);
write_c_str(stream, section_name, "reloc section name");
- wasm_write_u32_leb128(&ctx->stream, section_code, "reloc section");
- wasm_write_u32_leb128(&ctx->stream, total_relocs, "num relocs");
+ wabt_write_u32_leb128(&ctx->stream, section_code, "reloc section");
+ wabt_write_u32_leb128(&ctx->stream, total_relocs, "num relocs");
for (i = 0; i < sections->size; i++) {
- WasmSection* sec = sections->data[i];
- WasmRelocVector* relocs = &sec->relocations;
+ WabtSection* sec = sections->data[i];
+ WabtRelocVector* relocs = &sec->relocations;
for (j = 0; j < relocs->size; j++) {
- wasm_write_u32_leb128(&ctx->stream, relocs->data[j].type, "reloc type");
+ wabt_write_u32_leb128(&ctx->stream, relocs->data[j].type, "reloc type");
uint32_t new_offset = relocs->data[j].offset + sec->output_payload_offset;
- wasm_write_u32_leb128(&ctx->stream, new_offset, "reloc offset");
+ wabt_write_u32_leb128(&ctx->stream, new_offset, "reloc offset");
}
}
FIXUP_SIZE(stream);
}
-static WasmBool write_combined_section(Context* ctx,
- WasmBinarySection section_code,
- WasmSectionPtrVector* sections) {
+static WabtBool write_combined_section(Context* ctx,
+ WabtBinarySection section_code,
+ WabtSectionPtrVector* sections) {
if (!sections->size)
- return WASM_FALSE;
+ return WABT_FALSE;
- if (section_code == WASM_BINARY_SECTION_START && sections->size > 1) {
- WASM_FATAL("Don't know how to combine sections of type: %s\n",
- wasm_get_section_name(section_code));
+ if (section_code == WABT_BINARY_SECTION_START && sections->size > 1) {
+ WABT_FATAL("Don't know how to combine sections of type: %s\n",
+ wabt_get_section_name(section_code));
}
size_t i;
@@ -563,83 +563,83 @@ static WasmBool write_combined_section(Context* ctx,
/* Sum section size and element count */
for (i = 0; i < sections->size; i++) {
- WasmSection* sec = sections->data[i];
+ WabtSection* sec = sections->data[i];
total_size += sec->payload_size;
total_count += sec->count;
}
- wasm_write_u8(&ctx->stream, section_code, "section code");
+ wabt_write_u8(&ctx->stream, section_code, "section code");
ctx->current_section_payload_offset = -1;
switch (section_code) {
- case WASM_BINARY_SECTION_IMPORT:
+ case WABT_BINARY_SECTION_IMPORT:
write_import_section(ctx);
break;
- case WASM_BINARY_SECTION_FUNCTION:
+ case WABT_BINARY_SECTION_FUNCTION:
write_function_section(ctx, sections, total_count);
break;
- case WASM_BINARY_SECTION_TABLE:
+ case WABT_BINARY_SECTION_TABLE:
write_table_section(ctx, sections);
break;
- case WASM_BINARY_SECTION_EXPORT:
+ case WABT_BINARY_SECTION_EXPORT:
write_export_section(ctx);
break;
- case WASM_BINARY_SECTION_ELEM:
+ case WABT_BINARY_SECTION_ELEM:
write_elem_section(ctx, sections);
break;
- case WASM_BINARY_SECTION_MEMORY:
+ case WABT_BINARY_SECTION_MEMORY:
write_memory_section(ctx, sections);
break;
- case WASM_BINARY_SECTION_DATA:
+ case WABT_BINARY_SECTION_DATA:
write_data_section(ctx, sections, total_count);
break;
default: {
/* Total section size includes the element count leb128. */
- total_size += wasm_u32_leb128_length(total_count);
+ total_size += wabt_u32_leb128_length(total_count);
/* Write section to stream */
- WasmStream* stream = &ctx->stream;
- wasm_write_u32_leb128(stream, total_size, "section size");
- wasm_write_u32_leb128(stream, total_count, "element count");
+ WabtStream* stream = &ctx->stream;
+ wabt_write_u32_leb128(stream, total_size, "section size");
+ wabt_write_u32_leb128(stream, total_count, "element count");
ctx->current_section_payload_offset = ctx->stream.offset;
for (i = 0; i < sections->size; i++) {
- WasmSection* sec = sections->data[i];
+ WabtSection* sec = sections->data[i];
apply_relocations(sec);
write_section_payload(ctx, sec);
}
}
}
- return WASM_TRUE;
+ return WABT_TRUE;
}
typedef struct ExportInfo {
- WasmExport* export;
- WasmLinkerInputBinary* binary;
+ WabtExport* export;
+ WabtLinkerInputBinary* binary;
} ExportInfo;
-WASM_DEFINE_VECTOR(export_info, ExportInfo);
+WABT_DEFINE_VECTOR(export_info, ExportInfo);
static void resolve_symbols(Context* ctx) {
/* Create hashmap of all exported symbols from all inputs */
- WasmBindingHash export_map;
- WASM_ZERO_MEMORY(export_map);
+ WabtBindingHash export_map;
+ WABT_ZERO_MEMORY(export_map);
ExportInfoVector export_list;
- WASM_ZERO_MEMORY(export_list);
+ WABT_ZERO_MEMORY(export_list);
size_t i, j;
for (i = 0; i < ctx->inputs.size; i++) {
- WasmLinkerInputBinary* binary = &ctx->inputs.data[i];
+ WabtLinkerInputBinary* binary = &ctx->inputs.data[i];
for (j = 0; j < binary->exports.size; j++) {
- WasmExport* export = &binary->exports.data[j];
- ExportInfo* info = wasm_append_export_info(ctx->allocator, &export_list);
+ WabtExport* export = &binary->exports.data[j];
+ ExportInfo* info = wabt_append_export_info(ctx->allocator, &export_list);
info->export = export;
info->binary = binary;
/* TODO(sbc): Handle duplicate names */
- WasmStringSlice name =
- wasm_dup_string_slice(ctx->allocator, export->name);
- WasmBinding* binding =
- wasm_insert_binding(ctx->allocator, &export_map, &name);
+ WabtStringSlice name =
+ wabt_dup_string_slice(ctx->allocator, export->name);
+ WabtBinding* binding =
+ wabt_insert_binding(ctx->allocator, &export_map, &name);
binding->index = export_list.size - 1;
}
}
@@ -649,15 +649,15 @@ static void resolve_symbols(Context* ctx) {
* ones.
*/
for (i = 0; i < ctx->inputs.size; i++) {
- WasmLinkerInputBinary* binary = &ctx->inputs.data[i];
+ WabtLinkerInputBinary* binary = &ctx->inputs.data[i];
for (j = 0; j < binary->function_imports.size; j++) {
- WasmFunctionImport* import = &binary->function_imports.data[j];
+ WabtFunctionImport* import = &binary->function_imports.data[j];
int export_index =
- wasm_find_binding_index_by_name(&export_map, &import->name);
+ wabt_find_binding_index_by_name(&export_map, &import->name);
if (export_index == -1) {
if (!s_relocatable)
- WASM_FATAL("undefined symbol: " PRIstringslice "\n",
- WASM_PRINTF_STRING_SLICE_ARG(import->name));
+ WABT_FATAL("undefined symbol: " PRIstringslice "\n",
+ WABT_PRINTF_STRING_SLICE_ARG(import->name));
continue;
}
@@ -665,15 +665,15 @@ static void resolve_symbols(Context* ctx) {
ExportInfo* export_info = &export_list.data[export_index];
/* TODO(sbc): verify the foriegn function has the correct signature */
- import->active = WASM_FALSE;
+ import->active = WABT_FALSE;
import->foreign_binary = export_info->binary;
import->foreign_index = export_info->export->index;
binary->active_function_imports--;
}
}
- wasm_destroy_export_info_vector(ctx->allocator, &export_list);
- wasm_destroy_binding_hash(ctx->allocator, &export_map);
+ wabt_destroy_export_info_vector(ctx->allocator, &export_list);
+ wabt_destroy_binding_hash(ctx->allocator, &export_map);
}
static void calculate_reloc_offsets(Context* ctx) {
@@ -686,7 +686,7 @@ static void calculate_reloc_offsets(Context* ctx) {
uint32_t total_function_imports = 0;
uint32_t total_global_imports = 0;
for (i = 0; i < ctx->inputs.size; i++) {
- WasmLinkerInputBinary* binary = &ctx->inputs.data[i];
+ WabtLinkerInputBinary* binary = &ctx->inputs.data[i];
/* The imported_function_index_offset is the sum of all the function
* imports from objects that precede this one. i.e. the current running
* total */
@@ -699,23 +699,23 @@ static void calculate_reloc_offsets(Context* ctx) {
}
for (i = 0; i < ctx->inputs.size; i++) {
- WasmLinkerInputBinary* binary = &ctx->inputs.data[i];
+ WabtLinkerInputBinary* binary = &ctx->inputs.data[i];
binary->table_index_offset = table_elem_count;
table_elem_count += binary->table_elem_count;
for (j = 0; j < binary->sections.size; j++) {
- WasmSection* sec = &binary->sections.data[j];
+ WabtSection* sec = &binary->sections.data[j];
switch (sec->section_code) {
- case WASM_BINARY_SECTION_TYPE:
+ case WABT_BINARY_SECTION_TYPE:
binary->type_index_offset = type_count;
type_count += sec->count;
break;
- case WASM_BINARY_SECTION_GLOBAL:
+ case WABT_BINARY_SECTION_GLOBAL:
binary->global_index_offset = total_global_imports -
sec->binary->global_imports.size +
global_count;
global_count += sec->count;
break;
- case WASM_BINARY_SECTION_FUNCTION:
+ case WABT_BINARY_SECTION_FUNCTION:
binary->function_index_offset = total_function_imports -
sec->binary->function_imports.size +
function_count;
@@ -730,37 +730,37 @@ static void calculate_reloc_offsets(Context* ctx) {
static void write_binary(Context* ctx) {
/* Find all the sections of each type */
- WasmSectionPtrVector sections[WASM_NUM_BINARY_SECTIONS];
- WASM_ZERO_MEMORY(sections);
+ WabtSectionPtrVector sections[WABT_NUM_BINARY_SECTIONS];
+ WABT_ZERO_MEMORY(sections);
size_t i, j;
for (j = 0; j < ctx->inputs.size; j++) {
- WasmLinkerInputBinary* binary = &ctx->inputs.data[j];
+ WabtLinkerInputBinary* binary = &ctx->inputs.data[j];
for (i = 0; i < binary->sections.size; i++) {
- WasmSection* s = &binary->sections.data[i];
- WasmSectionPtrVector* sec_list = &sections[s->section_code];
- wasm_append_section_ptr_value(ctx->allocator, sec_list, &s);
+ WabtSection* s = &binary->sections.data[i];
+ WabtSectionPtrVector* sec_list = &sections[s->section_code];
+ wabt_append_section_ptr_value(ctx->allocator, sec_list, &s);
}
}
/* Write the final binary */
- wasm_write_u32(&ctx->stream, WASM_BINARY_MAGIC, "WASM_BINARY_MAGIC");
- wasm_write_u32(&ctx->stream, WASM_BINARY_VERSION, "WASM_BINARY_VERSION");
+ wabt_write_u32(&ctx->stream, WABT_BINARY_MAGIC, "WABT_BINARY_MAGIC");
+ wabt_write_u32(&ctx->stream, WABT_BINARY_VERSION, "WABT_BINARY_VERSION");
/* Write known sections first */
- for (i = FIRST_KNOWN_SECTION; i < WASM_NUM_BINARY_SECTIONS; i++) {
+ for (i = FIRST_KNOWN_SECTION; i < WABT_NUM_BINARY_SECTIONS; i++) {
write_combined_section(ctx, i, &sections[i]);
}
write_names_section(ctx);
/* Generate a new set of reloction sections */
- for (i = FIRST_KNOWN_SECTION; i < WASM_NUM_BINARY_SECTIONS; i++) {
+ for (i = FIRST_KNOWN_SECTION; i < WABT_NUM_BINARY_SECTIONS; i++) {
write_reloc_section(ctx, i, &sections[i]);
}
- for (i = 0; i < WASM_NUM_BINARY_SECTIONS; i++) {
- wasm_destroy_section_ptr_vector(ctx->allocator, &sections[i]);
+ for (i = 0; i < WABT_NUM_BINARY_SECTIONS; i++) {
+ wabt_destroy_section_ptr_vector(ctx->allocator, &sections[i]);
}
}
@@ -768,90 +768,90 @@ static void dump_reloc_offsets(Context* ctx) {
if (s_verbose) {
uint32_t i;
for (i = 0; i < ctx->inputs.size; i++) {
- WasmLinkerInputBinary* binary = &ctx->inputs.data[i];
- wasm_writef(&s_log_stream, "Relocation info for: %s\n", binary->filename);
- wasm_writef(&s_log_stream, " - type index offset : %d\n",
+ WabtLinkerInputBinary* binary = &ctx->inputs.data[i];
+ wabt_writef(&s_log_stream, "Relocation info for: %s\n", binary->filename);
+ wabt_writef(&s_log_stream, " - type index offset : %d\n",
binary->type_index_offset);
- wasm_writef(&s_log_stream, " - mem page offset : %d\n",
+ wabt_writef(&s_log_stream, " - mem page offset : %d\n",
binary->memory_page_offset);
- wasm_writef(&s_log_stream, " - function index offset : %d\n",
+ wabt_writef(&s_log_stream, " - function index offset : %d\n",
binary->function_index_offset);
- wasm_writef(&s_log_stream, " - global index offset : %d\n",
+ wabt_writef(&s_log_stream, " - global index offset : %d\n",
binary->global_index_offset);
- wasm_writef(&s_log_stream, " - imported function offset: %d\n",
+ wabt_writef(&s_log_stream, " - imported function offset: %d\n",
binary->imported_function_index_offset);
- wasm_writef(&s_log_stream, " - imported global offset : %d\n",
+ wabt_writef(&s_log_stream, " - imported global offset : %d\n",
binary->imported_global_index_offset);
}
}
}
-static WasmResult perform_link(Context* ctx) {
- WasmMemoryWriter writer;
- WASM_ZERO_MEMORY(writer);
- if (WASM_FAILED(wasm_init_mem_writer(ctx->allocator, &writer)))
- WASM_FATAL("unable to open memory writer for writing\n");
+static WabtResult perform_link(Context* ctx) {
+ WabtMemoryWriter writer;
+ WABT_ZERO_MEMORY(writer);
+ if (WABT_FAILED(wabt_init_mem_writer(ctx->allocator, &writer)))
+ WABT_FATAL("unable to open memory writer for writing\n");
- WasmStream* log_stream = NULL;
+ WabtStream* log_stream = NULL;
if (s_verbose)
log_stream = &s_log_stream;
if (s_verbose)
- wasm_writef(&s_log_stream, "writing file: %s\n", s_outfile);
+ wabt_writef(&s_log_stream, "writing file: %s\n", s_outfile);
calculate_reloc_offsets(ctx);
resolve_symbols(ctx);
calculate_reloc_offsets(ctx);
dump_reloc_offsets(ctx);
- wasm_init_stream(&ctx->stream, &writer.base, log_stream);
+ wabt_init_stream(&ctx->stream, &writer.base, log_stream);
write_binary(ctx);
- if (WASM_FAILED(wasm_write_output_buffer_to_file(&writer.buf, s_outfile)))
- WASM_FATAL("error writing linked output to file\n");
+ if (WABT_FAILED(wabt_write_output_buffer_to_file(&writer.buf, s_outfile)))
+ WABT_FATAL("error writing linked output to file\n");
- wasm_close_mem_writer(&writer);
- return WASM_OK;
+ wabt_close_mem_writer(&writer);
+ return WABT_OK;
}
int main(int argc, char** argv) {
- wasm_init_stdio();
+ wabt_init_stdio();
Context context;
- WASM_ZERO_MEMORY(context);
- context.allocator = &g_wasm_libc_allocator;
+ WABT_ZERO_MEMORY(context);
+ context.allocator = &g_wabt_libc_allocator;
parse_options(context.allocator, argc, argv);
- WasmResult result = WASM_OK;
+ WabtResult result = WABT_OK;
size_t i;
for (i = 0; i < s_infiles.size; i++) {
const char* input_filename = s_infiles.data[i];
if (s_verbose)
- wasm_writef(&s_log_stream, "reading file: %s\n", input_filename);
+ wabt_writef(&s_log_stream, "reading file: %s\n", input_filename);
void* data;
size_t size;
- result = wasm_read_file(context.allocator, input_filename, &data, &size);
- if (WASM_FAILED(result))
+ result = wabt_read_file(context.allocator, input_filename, &data, &size);
+ if (WABT_FAILED(result))
return result;
- WasmLinkerInputBinary* b =
- wasm_append_binary(context.allocator, &context.inputs);
+ WabtLinkerInputBinary* b =
+ wabt_append_binary(context.allocator, &context.inputs);
b->data = data;
b->size = size;
b->filename = input_filename;
- result = wasm_read_binary_linker(context.allocator, b);
- if (WASM_FAILED(result))
- WASM_FATAL("error parsing file: %s\n", input_filename);
+ result = wabt_read_binary_linker(context.allocator, b);
+ if (WABT_FAILED(result))
+ WABT_FATAL("error parsing file: %s\n", input_filename);
}
result = perform_link(&context);
- if (WASM_FAILED(result))
+ if (WABT_FAILED(result))
return result;
/* Cleanup */
- WASM_DESTROY_VECTOR_AND_ELEMENTS(context.allocator, context.inputs, binary);
- wasm_destroy_string_vector(context.allocator, &s_infiles);
+ WABT_DESTROY_VECTOR_AND_ELEMENTS(context.allocator, context.inputs, binary);
+ wabt_destroy_string_vector(context.allocator, &s_infiles);
- wasm_print_allocator_stats(context.allocator);
- wasm_destroy_allocator(context.allocator);
+ wabt_print_allocator_stats(context.allocator);
+ wabt_destroy_allocator(context.allocator);
return result;
}
diff --git a/src/tools/wasm2wast.c b/src/tools/wasm2wast.c
index 228b75bd..1800b3bb 100644
--- a/src/tools/wasm2wast.c
+++ b/src/tools/wasm2wast.c
@@ -36,18 +36,18 @@
static int s_verbose;
static const char* s_infile;
static const char* s_outfile;
-static WasmReadBinaryOptions s_read_binary_options = {NULL, WASM_TRUE};
-static WasmBool s_use_libc_allocator;
-static WasmBool s_generate_names;
+static WabtReadBinaryOptions s_read_binary_options = {NULL, WABT_TRUE};
+static WabtBool s_use_libc_allocator;
+static WabtBool s_generate_names;
-static WasmBinaryErrorHandler s_error_handler =
- WASM_BINARY_ERROR_HANDLER_DEFAULT;
+static WabtBinaryErrorHandler s_error_handler =
+ WABT_BINARY_ERROR_HANDLER_DEFAULT;
-static WasmFileWriter s_log_stream_writer;
-static WasmStream s_log_stream;
+static WabtFileWriter s_log_stream_writer;
+static WabtStream s_log_stream;
-#define NOPE WASM_OPTION_NO_ARGUMENT
-#define YEP WASM_OPTION_HAS_ARGUMENT
+#define NOPE WABT_OPTION_NO_ARGUMENT
+#define YEP WABT_OPTION_HAS_ARGUMENT
enum {
FLAG_VERBOSE,
@@ -70,7 +70,7 @@ static const char s_description[] =
" # parse test.wasm, write test.wast, but ignore the debug names, if any\n"
" $ wasm2wast test.wasm --no-debug-names -o test.wast\n";
-static WasmOption s_options[] = {
+static WabtOption s_options[] = {
{FLAG_VERBOSE, 'v', "verbose", NULL, NOPE,
"use multiple times for more info"},
{FLAG_HELP, 'h', "help", NULL, NOPE, "print this help message"},
@@ -83,21 +83,21 @@ static WasmOption s_options[] = {
{FLAG_GENERATE_NAMES, 0, "generate-names", NULL, NOPE,
"Give auto-generated names to non-named functions, types, etc."},
};
-WASM_STATIC_ASSERT(NUM_FLAGS == WASM_ARRAY_SIZE(s_options));
+WABT_STATIC_ASSERT(NUM_FLAGS == WABT_ARRAY_SIZE(s_options));
-static void on_option(struct WasmOptionParser* parser,
- struct WasmOption* option,
+static void on_option(struct WabtOptionParser* parser,
+ struct WabtOption* option,
const char* argument) {
switch (option->id) {
case FLAG_VERBOSE:
s_verbose++;
- wasm_init_file_writer_existing(&s_log_stream_writer, stdout);
- wasm_init_stream(&s_log_stream, &s_log_stream_writer.base, NULL);
+ wabt_init_file_writer_existing(&s_log_stream_writer, stdout);
+ wabt_init_stream(&s_log_stream, &s_log_stream_writer.base, NULL);
s_read_binary_options.log_stream = &s_log_stream;
break;
case FLAG_HELP:
- wasm_print_help(parser, PROGRAM_NAME);
+ wabt_print_help(parser, PROGRAM_NAME);
exit(0);
break;
@@ -106,100 +106,100 @@ static void on_option(struct WasmOptionParser* parser,
break;
case FLAG_USE_LIBC_ALLOCATOR:
- s_use_libc_allocator = WASM_TRUE;
+ s_use_libc_allocator = WABT_TRUE;
break;
case FLAG_NO_DEBUG_NAMES:
- s_read_binary_options.read_debug_names = WASM_FALSE;
+ s_read_binary_options.read_debug_names = WABT_FALSE;
break;
case FLAG_GENERATE_NAMES:
- s_generate_names = WASM_TRUE;
+ s_generate_names = WABT_TRUE;
break;
}
}
-static void on_argument(struct WasmOptionParser* parser, const char* argument) {
+static void on_argument(struct WabtOptionParser* parser, const char* argument) {
s_infile = argument;
}
-static void on_option_error(struct WasmOptionParser* parser,
+static void on_option_error(struct WabtOptionParser* parser,
const char* message) {
- WASM_FATAL("%s\n", message);
+ WABT_FATAL("%s\n", message);
}
static void parse_options(int argc, char** argv) {
- WasmOptionParser parser;
- WASM_ZERO_MEMORY(parser);
+ WabtOptionParser parser;
+ WABT_ZERO_MEMORY(parser);
parser.description = s_description;
parser.options = s_options;
- parser.num_options = WASM_ARRAY_SIZE(s_options);
+ parser.num_options = WABT_ARRAY_SIZE(s_options);
parser.on_option = on_option;
parser.on_argument = on_argument;
parser.on_error = on_option_error;
- wasm_parse_options(&parser, argc, argv);
+ wabt_parse_options(&parser, argc, argv);
if (!s_infile) {
- wasm_print_help(&parser, PROGRAM_NAME);
- WASM_FATAL("No filename given.\n");
+ wabt_print_help(&parser, PROGRAM_NAME);
+ WABT_FATAL("No filename given.\n");
}
}
int main(int argc, char** argv) {
- WasmResult result;
- WasmStackAllocator stack_allocator;
- WasmAllocator* allocator;
+ WabtResult result;
+ WabtStackAllocator stack_allocator;
+ WabtAllocator* allocator;
- wasm_init_stdio();
+ wabt_init_stdio();
parse_options(argc, argv);
if (s_use_libc_allocator) {
- allocator = &g_wasm_libc_allocator;
+ allocator = &g_wabt_libc_allocator;
} else {
- wasm_init_stack_allocator(&stack_allocator, &g_wasm_libc_allocator);
+ wabt_init_stack_allocator(&stack_allocator, &g_wabt_libc_allocator);
allocator = &stack_allocator.allocator;
}
void* data;
size_t size;
- result = wasm_read_file(allocator, s_infile, &data, &size);
- if (WASM_SUCCEEDED(result)) {
- WasmModule module;
- WASM_ZERO_MEMORY(module);
- result = wasm_read_binary_ast(allocator, data, size, &s_read_binary_options,
+ result = wabt_read_file(allocator, s_infile, &data, &size);
+ if (WABT_SUCCEEDED(result)) {
+ WabtModule module;
+ WABT_ZERO_MEMORY(module);
+ result = wabt_read_binary_ast(allocator, data, size, &s_read_binary_options,
&s_error_handler, &module);
- if (WASM_SUCCEEDED(result)) {
+ if (WABT_SUCCEEDED(result)) {
if (s_generate_names)
- result = wasm_generate_names(allocator, &module);
+ result = wabt_generate_names(allocator, &module);
- if (WASM_SUCCEEDED(result)) {
+ if (WABT_SUCCEEDED(result)) {
/* TODO(binji): This shouldn't fail; if a name can't be applied
* (because the index is invalid, say) it should just be skipped. */
- WasmResult dummy_result = wasm_apply_names(allocator, &module);
- WASM_USE(dummy_result);
+ WabtResult dummy_result = wabt_apply_names(allocator, &module);
+ WABT_USE(dummy_result);
}
- if (WASM_SUCCEEDED(result)) {
- WasmFileWriter file_writer;
+ if (WABT_SUCCEEDED(result)) {
+ WabtFileWriter file_writer;
if (s_outfile) {
- result = wasm_init_file_writer(&file_writer, s_outfile);
+ result = wabt_init_file_writer(&file_writer, s_outfile);
} else {
- wasm_init_file_writer_existing(&file_writer, stdout);
+ wabt_init_file_writer_existing(&file_writer, stdout);
}
- if (WASM_SUCCEEDED(result)) {
- result = wasm_write_ast(allocator, &file_writer.base, &module);
- wasm_close_file_writer(&file_writer);
+ if (WABT_SUCCEEDED(result)) {
+ result = wabt_write_ast(allocator, &file_writer.base, &module);
+ wabt_close_file_writer(&file_writer);
}
}
if (s_use_libc_allocator)
- wasm_destroy_module(allocator, &module);
+ wabt_destroy_module(allocator, &module);
}
- wasm_free(allocator, data);
- wasm_print_allocator_stats(allocator);
- wasm_destroy_allocator(allocator);
+ wabt_free(allocator, data);
+ wabt_print_allocator_stats(allocator);
+ wabt_destroy_allocator(allocator);
}
return result;
}
diff --git a/src/tools/wasmdump.c b/src/tools/wasmdump.c
index 9ee96828..564fc00c 100644
--- a/src/tools/wasmdump.c
+++ b/src/tools/wasmdump.c
@@ -28,8 +28,8 @@
#define PROGRAM_NAME "wasmdump"
-#define NOPE WASM_OPTION_NO_ARGUMENT
-#define YEP WASM_OPTION_HAS_ARGUMENT
+#define NOPE WABT_OPTION_NO_ARGUMENT
+#define YEP WABT_OPTION_HAS_ARGUMENT
enum {
FLAG_HEADERS,
@@ -49,7 +49,7 @@ static const char s_description[] =
"examples:\n"
" $ wasmdump test.wasm\n";
-static WasmOption s_options[] = {
+static WabtOption s_options[] = {
{FLAG_HEADERS, 'h', "headers", NULL, NOPE, "print headers"},
{FLAG_SECTION, 'j', "section", NULL, YEP, "select just one section"},
{FLAG_RAW, 's', "full-contents", NULL, NOPE, "print raw section contents"},
@@ -62,39 +62,39 @@ static WasmOption s_options[] = {
{FLAG_HELP, 'h', "help", NULL, NOPE, "print this help message"},
};
-WASM_STATIC_ASSERT(NUM_FLAGS == WASM_ARRAY_SIZE(s_options));
+WABT_STATIC_ASSERT(NUM_FLAGS == WABT_ARRAY_SIZE(s_options));
-static WasmObjdumpOptions s_objdump_options;
+static WabtObjdumpOptions s_objdump_options;
-static void on_argument(struct WasmOptionParser* parser, const char* argument) {
+static void on_argument(struct WabtOptionParser* parser, const char* argument) {
s_objdump_options.infile = argument;
}
-static void on_option(struct WasmOptionParser* parser,
- struct WasmOption* option,
+static void on_option(struct WabtOptionParser* parser,
+ struct WabtOption* option,
const char* argument) {
switch (option->id) {
case FLAG_HEADERS:
- s_objdump_options.headers = WASM_TRUE;
+ s_objdump_options.headers = WABT_TRUE;
break;
case FLAG_RAW:
- s_objdump_options.raw = WASM_TRUE;
+ s_objdump_options.raw = WABT_TRUE;
break;
case FLAG_DEBUG:
- s_objdump_options.debug = WASM_TRUE;
+ s_objdump_options.debug = WABT_TRUE;
case FLAG_DISASSEMBLE:
- s_objdump_options.disassemble = WASM_TRUE;
+ s_objdump_options.disassemble = WABT_TRUE;
break;
case FLAG_DETAILS:
- s_objdump_options.details = WASM_TRUE;
+ s_objdump_options.details = WABT_TRUE;
break;
case FLAG_RELOCS:
- s_objdump_options.relocs = WASM_TRUE;
+ s_objdump_options.relocs = WABT_TRUE;
break;
case FLAG_SECTION:
@@ -102,36 +102,36 @@ static void on_option(struct WasmOptionParser* parser,
break;
case FLAG_HELP:
- wasm_print_help(parser, PROGRAM_NAME);
+ wabt_print_help(parser, PROGRAM_NAME);
exit(0);
break;
}
}
-static void on_option_error(struct WasmOptionParser* parser,
+static void on_option_error(struct WabtOptionParser* parser,
const char* message) {
- WASM_FATAL("%s\n", message);
+ WABT_FATAL("%s\n", message);
}
static void parse_options(int argc, char** argv) {
- WasmOptionParser parser;
- WASM_ZERO_MEMORY(parser);
+ WabtOptionParser parser;
+ WABT_ZERO_MEMORY(parser);
parser.description = s_description;
parser.options = s_options;
- parser.num_options = WASM_ARRAY_SIZE(s_options);
+ parser.num_options = WABT_ARRAY_SIZE(s_options);
parser.on_option = on_option;
parser.on_argument = on_argument;
parser.on_error = on_option_error;
- wasm_parse_options(&parser, argc, argv);
+ wabt_parse_options(&parser, argc, argv);
if (!s_objdump_options.infile) {
- wasm_print_help(&parser, PROGRAM_NAME);
- WASM_FATAL("No filename given.\n");
+ wabt_print_help(&parser, PROGRAM_NAME);
+ WABT_FATAL("No filename given.\n");
}
}
int main(int argc, char** argv) {
- wasm_init_stdio();
+ wabt_init_stdio();
parse_options(argc, argv);
if (!s_objdump_options.headers && !s_objdump_options.details && !s_objdump_options.disassemble && !s_objdump_options.raw) {
@@ -143,12 +143,12 @@ int main(int argc, char** argv) {
return 1;
}
- WasmAllocator* allocator = &g_wasm_libc_allocator;
+ WabtAllocator* allocator = &g_wabt_libc_allocator;
void* data;
size_t size;
- WasmResult result = wasm_read_file(allocator, s_objdump_options.infile, &data, &size);
- if (WASM_FAILED(result))
+ WabtResult result = wabt_read_file(allocator, s_objdump_options.infile, &data, &size);
+ if (WABT_FAILED(result))
return result;
// Perform serveral passed over the binary in order to print out different
@@ -164,41 +164,41 @@ int main(int argc, char** argv) {
return 1;
}
- s_objdump_options.mode = WASM_DUMP_PREPASS;
- result = wasm_read_binary_objdump(allocator, data, size, &s_objdump_options);
- if (WASM_FAILED(result))
+ s_objdump_options.mode = WABT_DUMP_PREPASS;
+ result = wabt_read_binary_objdump(allocator, data, size, &s_objdump_options);
+ if (WABT_FAILED(result))
goto done;
// Pass 1: Print the section headers
if (s_objdump_options.headers) {
- s_objdump_options.mode = WASM_DUMP_HEADERS;
- result = wasm_read_binary_objdump(allocator, data, size, &s_objdump_options);
- if (WASM_FAILED(result))
+ s_objdump_options.mode = WABT_DUMP_HEADERS;
+ result = wabt_read_binary_objdump(allocator, data, size, &s_objdump_options);
+ if (WABT_FAILED(result))
goto done;
s_objdump_options.print_header = 0;
}
// Pass 2: Print extra information based on section type
if (s_objdump_options.details) {
- s_objdump_options.mode = WASM_DUMP_DETAILS;
- result = wasm_read_binary_objdump(allocator, data, size, &s_objdump_options);
- if (WASM_FAILED(result))
+ s_objdump_options.mode = WABT_DUMP_DETAILS;
+ result = wabt_read_binary_objdump(allocator, data, size, &s_objdump_options);
+ if (WABT_FAILED(result))
goto done;
s_objdump_options.print_header = 0;
}
if (s_objdump_options.disassemble) {
- s_objdump_options.mode = WASM_DUMP_DISASSEMBLE;
- result = wasm_read_binary_objdump(allocator, data, size, &s_objdump_options);
- if (WASM_FAILED(result))
+ s_objdump_options.mode = WABT_DUMP_DISASSEMBLE;
+ result = wabt_read_binary_objdump(allocator, data, size, &s_objdump_options);
+ if (WABT_FAILED(result))
goto done;
s_objdump_options.print_header = 0;
}
// Pass 3: Dump to raw contents of the sections
if (s_objdump_options.raw) {
- s_objdump_options.mode = WASM_DUMP_RAW_DATA;
- result = wasm_read_binary_objdump(allocator, data, size, &s_objdump_options);
+ s_objdump_options.mode = WABT_DUMP_RAW_DATA;
+ result = wabt_read_binary_objdump(allocator, data, size, &s_objdump_options);
}
done:
- wasm_free(allocator, data);
+ wabt_free(allocator, data);
return result;
}
diff --git a/src/tools/wasmopcodecnt.c b/src/tools/wasmopcodecnt.c
index d17d8ab7..a6dacb89 100644
--- a/src/tools/wasmopcodecnt.c
+++ b/src/tools/wasmopcodecnt.c
@@ -39,16 +39,16 @@ static const char* s_outfile;
static size_t s_cutoff = 0;
static const char* s_separator = ": ";
-static WasmReadBinaryOptions s_read_binary_options =
- WASM_READ_BINARY_OPTIONS_DEFAULT;
+static WabtReadBinaryOptions s_read_binary_options =
+ WABT_READ_BINARY_OPTIONS_DEFAULT;
-static WasmBool s_use_libc_allocator;
+static WabtBool s_use_libc_allocator;
-static WasmFileWriter s_log_stream_writer;
-static WasmStream s_log_stream;
+static WabtFileWriter s_log_stream_writer;
+static WabtStream s_log_stream;
-#define NOPE WASM_OPTION_NO_ARGUMENT
-#define YEP WASM_OPTION_HAS_ARGUMENT
+#define NOPE WABT_OPTION_NO_ARGUMENT
+#define YEP WABT_OPTION_HAS_ARGUMENT
enum {
FLAG_VERBOSE,
@@ -68,7 +68,7 @@ static const char s_description[] =
" # parse binary file test.wasm and write pcode dist file test.dist\n"
" $ wasmopcodecnt test.wasm -o test.dist\n";
-static WasmOption s_options[] = {
+static WabtOption s_options[] = {
{FLAG_VERBOSE,
'v',
"verbose",
@@ -102,21 +102,21 @@ static WasmOption s_options[] = {
"Separator text between element and count when reporting counts"}
};
-WASM_STATIC_ASSERT(NUM_FLAGS == WASM_ARRAY_SIZE(s_options));
+WABT_STATIC_ASSERT(NUM_FLAGS == WABT_ARRAY_SIZE(s_options));
-static void on_option(struct WasmOptionParser* parser,
- struct WasmOption* option,
+static void on_option(struct WabtOptionParser* parser,
+ struct WabtOption* option,
const char* argument) {
switch (option->id) {
case FLAG_VERBOSE:
s_verbose++;
- wasm_init_file_writer_existing(&s_log_stream_writer, stdout);
- wasm_init_stream(&s_log_stream, &s_log_stream_writer.base, NULL);
+ wabt_init_file_writer_existing(&s_log_stream_writer, stdout);
+ wabt_init_stream(&s_log_stream, &s_log_stream_writer.base, NULL);
s_read_binary_options.log_stream = &s_log_stream;
break;
case FLAG_HELP:
- wasm_print_help(parser, PROGRAM_NAME);
+ wabt_print_help(parser, PROGRAM_NAME);
exit(0);
break;
@@ -125,7 +125,7 @@ static void on_option(struct WasmOptionParser* parser,
break;
case FLAG_USE_LIBC_ALLOCATOR:
- s_use_libc_allocator = WASM_TRUE;
+ s_use_libc_allocator = WABT_TRUE;
break;
case FLAG_CUTOFF:
@@ -138,45 +138,45 @@ static void on_option(struct WasmOptionParser* parser,
}
}
-static void on_argument(struct WasmOptionParser* parser, const char* argument) {
+static void on_argument(struct WabtOptionParser* parser, const char* argument) {
s_infile = argument;
}
-static void on_option_error(struct WasmOptionParser* parser,
+static void on_option_error(struct WabtOptionParser* parser,
const char* message) {
- WASM_FATAL("%s\n", message);
+ WABT_FATAL("%s\n", message);
}
static void parse_options(int argc, char** argv) {
- WasmOptionParser parser;
- WASM_ZERO_MEMORY(parser);
+ WabtOptionParser parser;
+ WABT_ZERO_MEMORY(parser);
parser.description = s_description;
parser.options = s_options;
- parser.num_options = WASM_ARRAY_SIZE(s_options);
+ parser.num_options = WABT_ARRAY_SIZE(s_options);
parser.on_option = on_option;
parser.on_argument = on_argument;
parser.on_error = on_option_error;
- wasm_parse_options(&parser, argc, argv);
+ wabt_parse_options(&parser, argc, argv);
if (!s_infile) {
- wasm_print_help(&parser, PROGRAM_NAME);
- WASM_FATAL("No filename given.\n");
+ wabt_print_help(&parser, PROGRAM_NAME);
+ WABT_FATAL("No filename given.\n");
}
}
-WASM_DEFINE_VECTOR_SORT(int_counter, WasmIntCounter);
+WABT_DEFINE_VECTOR_SORT(int_counter, WabtIntCounter);
-typedef int (int_counter_lt_fcn)(WasmIntCounter*, WasmIntCounter*);
+typedef int (int_counter_lt_fcn)(WabtIntCounter*, WabtIntCounter*);
-WASM_DEFINE_VECTOR_SORT(int_pair_counter, WasmIntPairCounter);
+WABT_DEFINE_VECTOR_SORT(int_pair_counter, WabtIntPairCounter);
-typedef int (int_pair_counter_lt_fcn)(WasmIntPairCounter*, WasmIntPairCounter*);
+typedef int (int_pair_counter_lt_fcn)(WabtIntPairCounter*, WabtIntPairCounter*);
typedef void (*display_name_fcn)(FILE* out, intmax_t value);
static void display_opcode_name(FILE* out, intmax_t opcode) {
- if (opcode >= 0 && opcode < WASM_NUM_OPCODES)
- fprintf(out, "%s", wasm_get_opcode_name(opcode));
+ if (opcode >= 0 && opcode < WABT_NUM_OPCODES)
+ fprintf(out, "%s", wabt_get_opcode_name(opcode));
else
fprintf(out, "?(%" PRIdMAX ")", opcode);
}
@@ -186,7 +186,7 @@ static void display_intmax(FILE* out, intmax_t value) {
}
static void display_int_counter_vector(
- FILE* out, WasmIntCounterVector* vec, display_name_fcn display_fcn,
+ FILE* out, WabtIntCounterVector* vec, display_name_fcn display_fcn,
const char* opcode_name) {
size_t i;
for (i = 0; i < vec->size; ++i) {
@@ -202,7 +202,7 @@ static void display_int_counter_vector(
}
static void display_int_pair_counter_vector(
- FILE* out, WasmIntPairCounterVector* vec,
+ FILE* out, WabtIntPairCounterVector* vec,
display_name_fcn display_first_fcn, display_name_fcn display_second_fcn,
const char* opcode_name) {
size_t i;
@@ -220,8 +220,8 @@ static void display_int_pair_counter_vector(
}
}
-static void swap_int_counters(WasmIntCounter* v1, WasmIntCounter* v2) {
- WasmIntCounter tmp;
+static void swap_int_counters(WabtIntCounter* v1, WabtIntCounter* v2) {
+ WabtIntCounter tmp;
tmp.value = v1->value;
tmp.count = v1->count;
@@ -232,21 +232,21 @@ static void swap_int_counters(WasmIntCounter* v1, WasmIntCounter* v2) {
v2->count = tmp.count;
}
-static int opcode_counter_gt(WasmIntCounter* counter_1,
- WasmIntCounter* counter_2) {
+static int opcode_counter_gt(WabtIntCounter* counter_1,
+ WabtIntCounter* counter_2) {
if (counter_1->count > counter_2->count)
return 1;
if (counter_1->count < counter_2->count)
return 0;
const char* name_1 = "?1";
const char* name_2 = "?2";
- if (counter_1->value < WASM_NUM_OPCODES) {
- const char* opcode_name = wasm_get_opcode_name(counter_1->value);
+ if (counter_1->value < WABT_NUM_OPCODES) {
+ const char* opcode_name = wabt_get_opcode_name(counter_1->value);
if (opcode_name)
name_1 = opcode_name;
}
- if (counter_2->value < WASM_NUM_OPCODES) {
- const char* opcode_name = wasm_get_opcode_name(counter_2->value);
+ if (counter_2->value < WABT_NUM_OPCODES) {
+ const char* opcode_name = wabt_get_opcode_name(counter_2->value);
if (opcode_name)
name_2 = opcode_name;
}
@@ -256,8 +256,8 @@ static int opcode_counter_gt(WasmIntCounter* counter_1,
return 0;
}
-static int int_counter_gt(WasmIntCounter* counter_1,
- WasmIntCounter* counter_2) {
+static int int_counter_gt(WabtIntCounter* counter_1,
+ WabtIntCounter* counter_2) {
if (counter_1->count < counter_2->count)
return 0;
if (counter_1->count > counter_2->count)
@@ -269,9 +269,9 @@ static int int_counter_gt(WasmIntCounter* counter_1,
return 0;
}
-static void swap_int_pair_counters(WasmIntPairCounter* v1,
- WasmIntPairCounter* v2) {
- WasmIntPairCounter tmp;
+static void swap_int_pair_counters(WabtIntPairCounter* v1,
+ WabtIntPairCounter* v2) {
+ WabtIntPairCounter tmp;
tmp.first = v1->first;
tmp.second = v1->second;
tmp.count = v1->count;
@@ -285,8 +285,8 @@ static void swap_int_pair_counters(WasmIntPairCounter* v1,
v2->count = tmp.count;
}
-static int int_pair_counter_gt(WasmIntPairCounter* counter_1,
- WasmIntPairCounter* counter_2) {
+static int int_pair_counter_gt(WabtIntPairCounter* counter_1,
+ WabtIntPairCounter* counter_2) {
if (counter_1->count < counter_2->count)
return 0;
if (counter_1->count > counter_2->count)
@@ -303,128 +303,128 @@ static int int_pair_counter_gt(WasmIntPairCounter* counter_1,
}
static void display_sorted_int_counter_vector(
- FILE* out, const char* title, struct WasmAllocator* allocator,
- WasmIntCounterVector* vec, int_counter_lt_fcn lt_fcn,
+ FILE* out, const char* title, struct WabtAllocator* allocator,
+ WabtIntCounterVector* vec, int_counter_lt_fcn lt_fcn,
display_name_fcn display_fcn, const char* opcode_name) {
if (vec->size == 0)
return;
/* First filter out values less than cutoff. This speeds up sorting. */
- WasmIntCounterVector filtered_vec;
- WASM_ZERO_MEMORY(filtered_vec);
+ WabtIntCounterVector filtered_vec;
+ WABT_ZERO_MEMORY(filtered_vec);
size_t i;
for (i = 0; i < vec->size; ++i) {
if (vec->data[i].count < s_cutoff)
continue;
- wasm_append_int_counter_value(allocator, &filtered_vec, &vec->data[i]);
+ wabt_append_int_counter_value(allocator, &filtered_vec, &vec->data[i]);
}
- WasmIntCounterVector sorted_vec;
- WASM_ZERO_MEMORY(sorted_vec);
- wasm_sort_int_counter_vector(allocator, &filtered_vec, &sorted_vec,
+ WabtIntCounterVector sorted_vec;
+ WABT_ZERO_MEMORY(sorted_vec);
+ wabt_sort_int_counter_vector(allocator, &filtered_vec, &sorted_vec,
swap_int_counters, lt_fcn);
fprintf(out, "%s\n", title);
display_int_counter_vector(out, &sorted_vec, display_fcn, opcode_name);
- wasm_destroy_int_counter_vector(allocator, &filtered_vec);
- wasm_destroy_int_counter_vector(allocator, &sorted_vec);
+ wabt_destroy_int_counter_vector(allocator, &filtered_vec);
+ wabt_destroy_int_counter_vector(allocator, &sorted_vec);
}
static void display_sorted_int_pair_counter_vector(
- FILE* out, const char* title, struct WasmAllocator* allocator,
- WasmIntPairCounterVector* vec, int_pair_counter_lt_fcn lt_fcn,
+ FILE* out, const char* title, struct WabtAllocator* allocator,
+ WabtIntPairCounterVector* vec, int_pair_counter_lt_fcn lt_fcn,
display_name_fcn display_first_fcn, display_name_fcn display_second_fcn,
const char* opcode_name) {
if (vec->size == 0)
return;
- WasmIntPairCounterVector filtered_vec;
- WASM_ZERO_MEMORY(filtered_vec);
- WasmIntPairCounterVector sorted_vec;
+ WabtIntPairCounterVector filtered_vec;
+ WABT_ZERO_MEMORY(filtered_vec);
+ WabtIntPairCounterVector sorted_vec;
size_t i;
for (i = 0; i < vec->size; ++i) {
if (vec->data[i].count < s_cutoff)
continue;
- wasm_append_int_pair_counter_value(allocator, &filtered_vec, &vec->data[i]);
+ wabt_append_int_pair_counter_value(allocator, &filtered_vec, &vec->data[i]);
}
- WASM_ZERO_MEMORY(sorted_vec);
- wasm_sort_int_pair_counter_vector(allocator, &filtered_vec, &sorted_vec,
+ WABT_ZERO_MEMORY(sorted_vec);
+ wabt_sort_int_pair_counter_vector(allocator, &filtered_vec, &sorted_vec,
swap_int_pair_counters, lt_fcn);
fprintf(out, "%s\n", title);
display_int_pair_counter_vector(out, &sorted_vec, display_first_fcn,
display_second_fcn, opcode_name);
- wasm_destroy_int_pair_counter_vector(allocator, &filtered_vec);
- wasm_destroy_int_pair_counter_vector(allocator, &sorted_vec);
+ wabt_destroy_int_pair_counter_vector(allocator, &filtered_vec);
+ wabt_destroy_int_pair_counter_vector(allocator, &sorted_vec);
}
int main(int argc, char** argv) {
- wasm_init_stdio();
+ wabt_init_stdio();
parse_options(argc, argv);
- WasmStackAllocator stack_allocator;
- WasmAllocator *allocator;
+ WabtStackAllocator stack_allocator;
+ WabtAllocator *allocator;
if (s_use_libc_allocator) {
- allocator = &g_wasm_libc_allocator;
+ allocator = &g_wabt_libc_allocator;
} else {
- wasm_init_stack_allocator(&stack_allocator, &g_wasm_libc_allocator);
+ wabt_init_stack_allocator(&stack_allocator, &g_wabt_libc_allocator);
allocator = &stack_allocator.allocator;
}
void* data;
size_t size;
- WasmResult result = wasm_read_file(allocator, s_infile, &data, &size);
- if (WASM_FAILED(result)) {
+ WabtResult result = wabt_read_file(allocator, s_infile, &data, &size);
+ if (WABT_FAILED(result)) {
const char* input_name = s_infile ? s_infile : "stdin";
ERROR("Unable to parse: %s", input_name);
- wasm_free(allocator, data);
- wasm_print_allocator_stats(allocator);
- wasm_destroy_allocator(allocator);
+ wabt_free(allocator, data);
+ wabt_print_allocator_stats(allocator);
+ wabt_destroy_allocator(allocator);
}
FILE* out = stdout;
if (s_outfile) {
out = fopen(s_outfile, "w");
if (!out)
ERROR("fopen \"%s\" failed, errno=%d\n", s_outfile, errno);
- result = WASM_ERROR;
+ result = WABT_ERROR;
}
- if (WASM_SUCCEEDED(result)) {
- WasmOpcntData opcnt_data;
- wasm_init_opcnt_data(allocator, &opcnt_data);
- result = wasm_read_binary_opcnt(
+ if (WABT_SUCCEEDED(result)) {
+ WabtOpcntData opcnt_data;
+ wabt_init_opcnt_data(allocator, &opcnt_data);
+ result = wabt_read_binary_opcnt(
allocator, data, size, &s_read_binary_options, &opcnt_data);
- if (WASM_SUCCEEDED(result)) {
+ if (WABT_SUCCEEDED(result)) {
display_sorted_int_counter_vector(
out, "Opcode counts:", allocator, &opcnt_data.opcode_vec,
opcode_counter_gt, display_opcode_name, NULL);
display_sorted_int_counter_vector(
out, "\ni32.const:", allocator, &opcnt_data.i32_const_vec,
int_counter_gt, display_intmax,
- wasm_get_opcode_name(WASM_OPCODE_I32_CONST));
+ wabt_get_opcode_name(WABT_OPCODE_I32_CONST));
display_sorted_int_counter_vector(
out, "\nget_local:", allocator, &opcnt_data.get_local_vec,
int_counter_gt, display_intmax,
- wasm_get_opcode_name(WASM_OPCODE_GET_LOCAL));
+ wabt_get_opcode_name(WABT_OPCODE_GET_LOCAL));
display_sorted_int_counter_vector(
out, "\nset_local:", allocator, &opcnt_data.set_local_vec,
int_counter_gt, display_intmax,
- wasm_get_opcode_name(WASM_OPCODE_SET_LOCAL));
+ wabt_get_opcode_name(WABT_OPCODE_SET_LOCAL));
display_sorted_int_counter_vector(
out, "\ntee_local:", allocator, &opcnt_data.tee_local_vec,
int_counter_gt, display_intmax,
- wasm_get_opcode_name(WASM_OPCODE_TEE_LOCAL));
+ wabt_get_opcode_name(WABT_OPCODE_TEE_LOCAL));
display_sorted_int_pair_counter_vector(
out, "\ni32.load:", allocator, &opcnt_data.i32_load_vec,
int_pair_counter_gt, display_intmax, display_intmax,
- wasm_get_opcode_name(WASM_OPCODE_I32_LOAD));
+ wabt_get_opcode_name(WABT_OPCODE_I32_LOAD));
display_sorted_int_pair_counter_vector(
out, "\ni32.store:", allocator, &opcnt_data.i32_store_vec,
int_pair_counter_gt, display_intmax, display_intmax,
- wasm_get_opcode_name(WASM_OPCODE_I32_STORE));
+ wabt_get_opcode_name(WABT_OPCODE_I32_STORE));
}
- wasm_destroy_opcnt_data(allocator, &opcnt_data);
+ wabt_destroy_opcnt_data(allocator, &opcnt_data);
}
- wasm_free(allocator, data);
- wasm_print_allocator_stats(allocator);
- wasm_destroy_allocator(allocator);
+ wabt_free(allocator, data);
+ wabt_print_allocator_stats(allocator);
+ wabt_destroy_allocator(allocator);
return result;
}
diff --git a/src/tools/wast-desugar.c b/src/tools/wast-desugar.c
index 6cbd6518..4eaa6d2c 100644
--- a/src/tools/wast-desugar.c
+++ b/src/tools/wast-desugar.c
@@ -36,11 +36,11 @@
static const char* s_infile;
static const char* s_outfile;
-static WasmBool s_use_libc_allocator;
-static WasmBool s_generate_names;
+static WabtBool s_use_libc_allocator;
+static WabtBool s_generate_names;
-static WasmSourceErrorHandler s_error_handler =
- WASM_SOURCE_ERROR_HANDLER_DEFAULT;
+static WabtSourceErrorHandler s_error_handler =
+ WABT_SOURCE_ERROR_HANDLER_DEFAULT;
enum {
FLAG_HELP,
@@ -63,25 +63,25 @@ static const char s_description[] =
" # generate names for indexed variables\n"
" $ wast-desugar --generate-names test.wast\n";
-static WasmOption s_options[] = {
- {FLAG_HELP, 'h', "help", NULL, WASM_OPTION_NO_ARGUMENT,
+static WabtOption s_options[] = {
+ {FLAG_HELP, 'h', "help", NULL, WABT_OPTION_NO_ARGUMENT,
"print this help message"},
- {FLAG_OUTPUT, 'o', "output", "FILE", WASM_OPTION_HAS_ARGUMENT,
+ {FLAG_OUTPUT, 'o', "output", "FILE", WABT_OPTION_HAS_ARGUMENT,
"output file for the formatted file"},
{FLAG_USE_LIBC_ALLOCATOR, 0, "use-libc-allocator", NULL,
- WASM_OPTION_NO_ARGUMENT,
+ WABT_OPTION_NO_ARGUMENT,
"use malloc, free, etc. instead of stack allocator"},
- {FLAG_GENERATE_NAMES, 0, "generate-names", NULL, WASM_OPTION_NO_ARGUMENT,
+ {FLAG_GENERATE_NAMES, 0, "generate-names", NULL, WABT_OPTION_NO_ARGUMENT,
"Give auto-generated names to non-named functions, types, etc."},
};
-WASM_STATIC_ASSERT(NUM_FLAGS == WASM_ARRAY_SIZE(s_options));
+WABT_STATIC_ASSERT(NUM_FLAGS == WABT_ARRAY_SIZE(s_options));
-static void on_option(struct WasmOptionParser* parser,
- struct WasmOption* option,
+static void on_option(struct WabtOptionParser* parser,
+ struct WabtOption* option,
const char* argument) {
switch (option->id) {
case FLAG_HELP:
- wasm_print_help(parser, PROGRAM_NAME);
+ wabt_print_help(parser, PROGRAM_NAME);
exit(0);
break;
@@ -90,104 +90,104 @@ static void on_option(struct WasmOptionParser* parser,
break;
case FLAG_USE_LIBC_ALLOCATOR:
- s_use_libc_allocator = WASM_TRUE;
+ s_use_libc_allocator = WABT_TRUE;
break;
case FLAG_GENERATE_NAMES:
- s_generate_names = WASM_TRUE;
+ s_generate_names = WABT_TRUE;
break;
}
}
-static void on_argument(struct WasmOptionParser* parser, const char* argument) {
+static void on_argument(struct WabtOptionParser* parser, const char* argument) {
s_infile = argument;
}
-static void on_option_error(struct WasmOptionParser* parser,
+static void on_option_error(struct WabtOptionParser* parser,
const char* message) {
- WASM_FATAL("%s\n", message);
+ WABT_FATAL("%s\n", message);
}
static void parse_options(int argc, char** argv) {
- WasmOptionParser parser;
- WASM_ZERO_MEMORY(parser);
+ WabtOptionParser parser;
+ WABT_ZERO_MEMORY(parser);
parser.description = s_description;
parser.options = s_options;
- parser.num_options = WASM_ARRAY_SIZE(s_options);
+ parser.num_options = WABT_ARRAY_SIZE(s_options);
parser.on_option = on_option;
parser.on_argument = on_argument;
parser.on_error = on_option_error;
- wasm_parse_options(&parser, argc, argv);
+ wabt_parse_options(&parser, argc, argv);
if (!s_infile) {
- wasm_print_help(&parser, PROGRAM_NAME);
- WASM_FATAL("No filename given.\n");
+ wabt_print_help(&parser, PROGRAM_NAME);
+ WABT_FATAL("No filename given.\n");
}
}
typedef struct Context {
- WasmAllocator* allocator;
- WasmMemoryWriter json_writer;
- WasmMemoryWriter module_writer;
- WasmStream json_stream;
- WasmStringSlice output_filename_noext;
+ WabtAllocator* allocator;
+ WabtMemoryWriter json_writer;
+ WabtMemoryWriter module_writer;
+ WabtStream json_stream;
+ WabtStringSlice output_filename_noext;
char* module_filename;
- WasmResult result;
+ WabtResult result;
} Context;
int main(int argc, char** argv) {
- WasmStackAllocator stack_allocator;
- WasmAllocator* allocator;
+ WabtStackAllocator stack_allocator;
+ WabtAllocator* allocator;
- wasm_init_stdio();
+ wabt_init_stdio();
parse_options(argc, argv);
if (s_use_libc_allocator) {
- allocator = &g_wasm_libc_allocator;
+ allocator = &g_wabt_libc_allocator;
} else {
- wasm_init_stack_allocator(&stack_allocator, &g_wasm_libc_allocator);
+ wabt_init_stack_allocator(&stack_allocator, &g_wabt_libc_allocator);
allocator = &stack_allocator.allocator;
}
- WasmAstLexer* lexer = wasm_new_ast_file_lexer(allocator, s_infile);
+ WabtAstLexer* lexer = wabt_new_ast_file_lexer(allocator, s_infile);
if (!lexer)
- WASM_FATAL("unable to read %s\n", s_infile);
+ WABT_FATAL("unable to read %s\n", s_infile);
- WasmScript script;
- WasmResult result = wasm_parse_ast(lexer, &script, &s_error_handler);
+ WabtScript script;
+ WabtResult result = wabt_parse_ast(lexer, &script, &s_error_handler);
- if (WASM_SUCCEEDED(result)) {
- WasmModule* module = wasm_get_first_module(&script);
+ if (WABT_SUCCEEDED(result)) {
+ WabtModule* module = wabt_get_first_module(&script);
if (!module)
- WASM_FATAL("no module in file.\n");
+ WABT_FATAL("no module in file.\n");
if (s_generate_names)
- result = wasm_generate_names(allocator, module);
+ result = wabt_generate_names(allocator, module);
- if (WASM_SUCCEEDED(result))
- result = wasm_apply_names(allocator, module);
+ if (WABT_SUCCEEDED(result))
+ result = wabt_apply_names(allocator, module);
- if (WASM_SUCCEEDED(result)) {
- WasmFileWriter file_writer;
+ if (WABT_SUCCEEDED(result)) {
+ WabtFileWriter file_writer;
if (s_outfile) {
- result = wasm_init_file_writer(&file_writer, s_outfile);
+ result = wabt_init_file_writer(&file_writer, s_outfile);
} else {
- wasm_init_file_writer_existing(&file_writer, stdout);
+ wabt_init_file_writer_existing(&file_writer, stdout);
}
- if (WASM_SUCCEEDED(result)) {
- result = wasm_write_ast(allocator, &file_writer.base, module);
- wasm_close_file_writer(&file_writer);
+ if (WABT_SUCCEEDED(result)) {
+ result = wabt_write_ast(allocator, &file_writer.base, module);
+ wabt_close_file_writer(&file_writer);
}
}
}
- wasm_destroy_ast_lexer(lexer);
+ wabt_destroy_ast_lexer(lexer);
if (s_use_libc_allocator)
- wasm_destroy_script(&script);
- wasm_print_allocator_stats(allocator);
- wasm_destroy_allocator(allocator);
+ wabt_destroy_script(&script);
+ wabt_print_allocator_stats(allocator);
+ wabt_destroy_allocator(allocator);
return result;
}
diff --git a/src/tools/wast2wasm.c b/src/tools/wast2wasm.c
index e0c8c1de..2fc85d37 100644
--- a/src/tools/wast2wasm.c
+++ b/src/tools/wast2wasm.c
@@ -37,23 +37,23 @@
static const char* s_infile;
static const char* s_outfile;
-static WasmBool s_dump_module;
-static WasmBool s_verbose;
-static WasmWriteBinaryOptions s_write_binary_options =
- WASM_WRITE_BINARY_OPTIONS_DEFAULT;
-static WasmWriteBinarySpecOptions s_write_binary_spec_options =
- WASM_WRITE_BINARY_SPEC_OPTIONS_DEFAULT;
-static WasmBool s_spec;
-static WasmBool s_use_libc_allocator;
-static WasmBool s_validate = WASM_TRUE;
+static WabtBool s_dump_module;
+static WabtBool s_verbose;
+static WabtWriteBinaryOptions s_write_binary_options =
+ WABT_WRITE_BINARY_OPTIONS_DEFAULT;
+static WabtWriteBinarySpecOptions s_write_binary_spec_options =
+ WABT_WRITE_BINARY_SPEC_OPTIONS_DEFAULT;
+static WabtBool s_spec;
+static WabtBool s_use_libc_allocator;
+static WabtBool s_validate = WABT_TRUE;
-static WasmSourceErrorHandler s_error_handler =
- WASM_SOURCE_ERROR_HANDLER_DEFAULT;
+static WabtSourceErrorHandler s_error_handler =
+ WABT_SOURCE_ERROR_HANDLER_DEFAULT;
-static WasmFileStream s_log_stream;
+static WabtFileStream s_log_stream;
-#define NOPE WASM_OPTION_NO_ARGUMENT
-#define YEP WASM_OPTION_HAS_ARGUMENT
+#define NOPE WABT_OPTION_NO_ARGUMENT
+#define YEP WABT_OPTION_HAS_ARGUMENT
enum {
FLAG_VERBOSE,
@@ -88,7 +88,7 @@ static const char s_description[] =
" # written to spec-test.0.wasm, spec-test.1.wasm, etc.\n"
" $ wast2wasm spec-test.wast --spec -o spec-test.json\n";
-static WasmOption s_options[] = {
+static WabtOption s_options[] = {
{FLAG_VERBOSE, 'v', "verbose", NULL, NOPE,
"use multiple times for more info"},
{FLAG_HELP, 'h', "help", NULL, NOPE, "print this help message"},
@@ -109,10 +109,10 @@ static WasmOption s_options[] = {
{FLAG_NO_CHECK, 0, "no-check", NULL, NOPE,
"Don't check for invalid modules"},
};
-WASM_STATIC_ASSERT(NUM_FLAGS == WASM_ARRAY_SIZE(s_options));
+WABT_STATIC_ASSERT(NUM_FLAGS == WABT_ARRAY_SIZE(s_options));
-static void on_option(struct WasmOptionParser* parser,
- struct WasmOption* option,
+static void on_option(struct WabtOptionParser* parser,
+ struct WabtOption* option,
const char* argument) {
switch (option->id) {
case FLAG_VERBOSE:
@@ -121,12 +121,12 @@ static void on_option(struct WasmOptionParser* parser,
break;
case FLAG_HELP:
- wasm_print_help(parser, PROGRAM_NAME);
+ wabt_print_help(parser, PROGRAM_NAME);
exit(0);
break;
case FLAG_DUMP_MODULE:
- s_dump_module = WASM_TRUE;
+ s_dump_module = WABT_TRUE;
break;
case FLAG_OUTPUT:
@@ -134,145 +134,145 @@ static void on_option(struct WasmOptionParser* parser,
break;
case FLAG_RELOCATABLE:
- s_write_binary_options.relocatable = WASM_TRUE;
+ s_write_binary_options.relocatable = WABT_TRUE;
break;
case FLAG_SPEC:
- s_spec = WASM_TRUE;
+ s_spec = WABT_TRUE;
break;
case FLAG_USE_LIBC_ALLOCATOR:
- s_use_libc_allocator = WASM_TRUE;
+ s_use_libc_allocator = WABT_TRUE;
break;
case FLAG_NO_CANONICALIZE_LEB128S:
- s_write_binary_options.canonicalize_lebs = WASM_FALSE;
+ s_write_binary_options.canonicalize_lebs = WABT_FALSE;
break;
case FLAG_DEBUG_NAMES:
- s_write_binary_options.write_debug_names = WASM_TRUE;
+ s_write_binary_options.write_debug_names = WABT_TRUE;
break;
case FLAG_NO_CHECK:
- s_validate = WASM_FALSE;
+ s_validate = WABT_FALSE;
break;
}
}
-static void on_argument(struct WasmOptionParser* parser, const char* argument) {
+static void on_argument(struct WabtOptionParser* parser, const char* argument) {
s_infile = argument;
}
-static void on_option_error(struct WasmOptionParser* parser,
+static void on_option_error(struct WabtOptionParser* parser,
const char* message) {
- WASM_FATAL("%s\n", message);
+ WABT_FATAL("%s\n", message);
}
static void parse_options(int argc, char** argv) {
- WasmOptionParser parser;
- WASM_ZERO_MEMORY(parser);
+ WabtOptionParser parser;
+ WABT_ZERO_MEMORY(parser);
parser.description = s_description;
parser.options = s_options;
- parser.num_options = WASM_ARRAY_SIZE(s_options);
+ parser.num_options = WABT_ARRAY_SIZE(s_options);
parser.on_option = on_option;
parser.on_argument = on_argument;
parser.on_error = on_option_error;
- wasm_parse_options(&parser, argc, argv);
+ wabt_parse_options(&parser, argc, argv);
if (!s_infile) {
- wasm_print_help(&parser, PROGRAM_NAME);
- WASM_FATAL("No filename given.\n");
+ wabt_print_help(&parser, PROGRAM_NAME);
+ WABT_FATAL("No filename given.\n");
}
}
static void write_buffer_to_file(const char* filename,
- WasmOutputBuffer* buffer) {
+ WabtOutputBuffer* buffer) {
if (s_dump_module) {
if (s_verbose)
- wasm_writef(&s_log_stream.base, ";; dump\n");
- wasm_write_output_buffer_memory_dump(&s_log_stream.base, buffer);
+ wabt_writef(&s_log_stream.base, ";; dump\n");
+ wabt_write_output_buffer_memory_dump(&s_log_stream.base, buffer);
}
if (filename) {
- wasm_write_output_buffer_to_file(buffer, filename);
+ wabt_write_output_buffer_to_file(buffer, filename);
}
}
int main(int argc, char** argv) {
- WasmStackAllocator stack_allocator;
- WasmAllocator* allocator;
+ WabtStackAllocator stack_allocator;
+ WabtAllocator* allocator;
- wasm_init_stdio();
+ wabt_init_stdio();
- wasm_init_file_stream_from_existing(&s_log_stream, stdout);
+ wabt_init_file_stream_from_existing(&s_log_stream, stdout);
parse_options(argc, argv);
if (s_use_libc_allocator) {
- allocator = &g_wasm_libc_allocator;
+ allocator = &g_wabt_libc_allocator;
} else {
- wasm_init_stack_allocator(&stack_allocator, &g_wasm_libc_allocator);
+ wabt_init_stack_allocator(&stack_allocator, &g_wabt_libc_allocator);
allocator = &stack_allocator.allocator;
}
- WasmAstLexer* lexer = wasm_new_ast_file_lexer(allocator, s_infile);
+ WabtAstLexer* lexer = wabt_new_ast_file_lexer(allocator, s_infile);
if (!lexer)
- WASM_FATAL("unable to read file: %s\n", s_infile);
+ WABT_FATAL("unable to read file: %s\n", s_infile);
- WasmScript script;
- WasmResult result = wasm_parse_ast(lexer, &script, &s_error_handler);
+ WabtScript script;
+ WabtResult result = wabt_parse_ast(lexer, &script, &s_error_handler);
- if (WASM_SUCCEEDED(result)) {
+ if (WABT_SUCCEEDED(result)) {
result =
- wasm_resolve_names_script(allocator, lexer, &script, &s_error_handler);
+ wabt_resolve_names_script(allocator, lexer, &script, &s_error_handler);
- if (WASM_SUCCEEDED(result) && s_validate) {
+ if (WABT_SUCCEEDED(result) && s_validate) {
result =
- wasm_validate_script(allocator, lexer, &script, &s_error_handler);
+ wabt_validate_script(allocator, lexer, &script, &s_error_handler);
}
- if (WASM_SUCCEEDED(result)) {
+ if (WABT_SUCCEEDED(result)) {
if (s_spec) {
s_write_binary_spec_options.json_filename = s_outfile;
s_write_binary_spec_options.write_binary_options =
s_write_binary_options;
- result = wasm_write_binary_spec_script(allocator, &script, s_infile,
+ result = wabt_write_binary_spec_script(allocator, &script, s_infile,
&s_write_binary_spec_options);
} else {
- WasmMemoryWriter writer;
- WASM_ZERO_MEMORY(writer);
- if (WASM_FAILED(wasm_init_mem_writer(allocator, &writer)))
- WASM_FATAL("unable to open memory writer for writing\n");
+ WabtMemoryWriter writer;
+ WABT_ZERO_MEMORY(writer);
+ if (WABT_FAILED(wabt_init_mem_writer(allocator, &writer)))
+ WABT_FATAL("unable to open memory writer for writing\n");
/* Write the first module, if any. */
- const WasmModule* module = NULL;
+ const WabtModule* module = NULL;
size_t i;
for (i = 0; i < script.commands.size; ++i) {
- const WasmCommand* command = &script.commands.data[i];
- if (command->type != WASM_COMMAND_TYPE_MODULE)
+ const WabtCommand* command = &script.commands.data[i];
+ if (command->type != WABT_COMMAND_TYPE_MODULE)
continue;
module = &command->module;
break;
}
if (module) {
- result = wasm_write_binary_module(allocator, &writer.base, module,
+ result = wabt_write_binary_module(allocator, &writer.base, module,
&s_write_binary_options);
} else {
- WASM_FATAL("no module found\n");
+ WABT_FATAL("no module found\n");
}
- if (WASM_SUCCEEDED(result))
+ if (WABT_SUCCEEDED(result))
write_buffer_to_file(s_outfile, &writer.buf);
- wasm_close_mem_writer(&writer);
+ wabt_close_mem_writer(&writer);
}
}
}
- wasm_destroy_ast_lexer(lexer);
+ wabt_destroy_ast_lexer(lexer);
if (s_use_libc_allocator)
- wasm_destroy_script(&script);
- wasm_print_allocator_stats(allocator);
- wasm_destroy_allocator(allocator);
+ wabt_destroy_script(&script);
+ wabt_print_allocator_stats(allocator);
+ wabt_destroy_allocator(allocator);
return result;
}
diff --git a/src/type-vector.h b/src/type-vector.h
index 29bbfe43..94b822cf 100644
--- a/src/type-vector.h
+++ b/src/type-vector.h
@@ -14,29 +14,29 @@
* limitations under the License.
*/
-#ifndef WASM_TYPE_VECTOR_H_
-#define WASM_TYPE_VECTOR_H_
+#ifndef WABT_TYPE_VECTOR_H_
+#define WABT_TYPE_VECTOR_H_
#include "common.h"
#include "vector.h"
-WASM_DEFINE_VECTOR(type, WasmType)
+WABT_DEFINE_VECTOR(type, WabtType)
-WASM_EXTERN_C_BEGIN
+WABT_EXTERN_C_BEGIN
-static WASM_INLINE WasmBool
-wasm_type_vectors_are_equal(const WasmTypeVector* types1,
- const WasmTypeVector* types2) {
+static WABT_INLINE WabtBool
+wabt_type_vectors_are_equal(const WabtTypeVector* types1,
+ const WabtTypeVector* types2) {
if (types1->size != types2->size)
- return WASM_FALSE;
+ return WABT_FALSE;
size_t i;
for (i = 0; i < types1->size; ++i) {
if (types1->data[i] != types2->data[i])
- return WASM_FALSE;
+ return WABT_FALSE;
}
- return WASM_TRUE;
+ return WABT_TRUE;
}
-WASM_EXTERN_C_END
+WABT_EXTERN_C_END
-#endif /* WASM_TYPE_VECTOR_H_ */
+#endif /* WABT_TYPE_VECTOR_H_ */
diff --git a/src/validator.c b/src/validator.c
index ba49296a..0f154548 100644
--- a/src/validator.c
+++ b/src/validator.c
@@ -38,7 +38,7 @@ typedef enum LabelType {
typedef struct LabelNode {
LabelType label_type;
- const WasmTypeVector* sig;
+ const WabtTypeVector* sig;
struct LabelNode* next;
size_t type_stack_limit;
} LabelNode;
@@ -52,170 +52,170 @@ typedef enum ActionResultKind {
typedef struct ActionResult {
ActionResultKind kind;
union {
- const WasmTypeVector* types;
- WasmType type;
+ const WabtTypeVector* types;
+ WabtType type;
};
} ActionResult;
typedef struct Context {
- WasmSourceErrorHandler* error_handler;
- WasmAllocator* allocator;
- WasmAstLexer* lexer;
- const WasmScript* script;
- const WasmModule* current_module;
- const WasmFunc* current_func;
+ WabtSourceErrorHandler* error_handler;
+ WabtAllocator* allocator;
+ WabtAstLexer* lexer;
+ const WabtScript* script;
+ const WabtModule* current_module;
+ const WabtFunc* current_func;
int current_table_index;
int current_memory_index;
int current_global_index;
int num_imported_globals;
- WasmTypeVector type_stack;
+ WabtTypeVector type_stack;
LabelNode* top_label;
int max_depth;
- WasmResult result;
+ WabtResult result;
} Context;
-static void WASM_PRINTF_FORMAT(3, 4)
- print_error(Context* ctx, const WasmLocation* loc, const char* fmt, ...) {
- ctx->result = WASM_ERROR;
+static void WABT_PRINTF_FORMAT(3, 4)
+ print_error(Context* ctx, const WabtLocation* loc, const char* fmt, ...) {
+ ctx->result = WABT_ERROR;
va_list args;
va_start(args, fmt);
- wasm_ast_format_error(ctx->error_handler, loc, ctx->lexer, fmt, args);
+ wabt_ast_format_error(ctx->error_handler, loc, ctx->lexer, fmt, args);
va_end(args);
}
-static WasmBool is_power_of_two(uint32_t x) {
+static WabtBool is_power_of_two(uint32_t x) {
return x && ((x & (x - 1)) == 0);
}
-static uint32_t get_opcode_natural_alignment(WasmOpcode opcode) {
- uint32_t memory_size = wasm_get_opcode_memory_size(opcode);
+static uint32_t get_opcode_natural_alignment(WabtOpcode opcode) {
+ uint32_t memory_size = wabt_get_opcode_memory_size(opcode);
assert(memory_size != 0);
return memory_size;
}
-static WasmResult check_var(Context* ctx,
+static WabtResult check_var(Context* ctx,
int max_index,
- const WasmVar* var,
+ const WabtVar* var,
const char* desc,
int* out_index) {
- assert(var->type == WASM_VAR_TYPE_INDEX);
+ assert(var->type == WABT_VAR_TYPE_INDEX);
if (var->index >= 0 && var->index < max_index) {
if (out_index)
*out_index = var->index;
- return WASM_OK;
+ return WABT_OK;
}
print_error(ctx, &var->loc, "%s variable out of range (max %d)", desc,
max_index);
- return WASM_ERROR;
+ return WABT_ERROR;
}
-static WasmResult check_func_var(Context* ctx,
- const WasmVar* var,
- const WasmFunc** out_func) {
+static WabtResult check_func_var(Context* ctx,
+ const WabtVar* var,
+ const WabtFunc** out_func) {
int index;
- if (WASM_FAILED(check_var(ctx, ctx->current_module->funcs.size, var,
+ if (WABT_FAILED(check_var(ctx, ctx->current_module->funcs.size, var,
"function", &index))) {
- return WASM_ERROR;
+ return WABT_ERROR;
}
if (out_func)
*out_func = ctx->current_module->funcs.data[index];
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult check_global_var(Context* ctx,
- const WasmVar* var,
- const WasmGlobal** out_global,
+static WabtResult check_global_var(Context* ctx,
+ const WabtVar* var,
+ const WabtGlobal** out_global,
int* out_global_index) {
int index;
- if (WASM_FAILED(check_var(ctx, ctx->current_module->globals.size, var,
+ if (WABT_FAILED(check_var(ctx, ctx->current_module->globals.size, var,
"global", &index))) {
- return WASM_ERROR;
+ return WABT_ERROR;
}
if (out_global)
*out_global = ctx->current_module->globals.data[index];
if (out_global_index)
*out_global_index = index;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult check_func_type_var(Context* ctx,
- const WasmVar* var,
- const WasmFuncType** out_func_type) {
+static WabtResult check_func_type_var(Context* ctx,
+ const WabtVar* var,
+ const WabtFuncType** out_func_type) {
int index;
- if (WASM_FAILED(check_var(ctx, ctx->current_module->func_types.size, var,
+ if (WABT_FAILED(check_var(ctx, ctx->current_module->func_types.size, var,
"function type", &index))) {
- return WASM_ERROR;
+ return WABT_ERROR;
}
if (out_func_type)
*out_func_type = ctx->current_module->func_types.data[index];
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult check_table_var(Context* ctx,
- const WasmVar* var,
- const WasmTable** out_table) {
+static WabtResult check_table_var(Context* ctx,
+ const WabtVar* var,
+ const WabtTable** out_table) {
int index;
- if (WASM_FAILED(check_var(ctx, ctx->current_module->tables.size, var, "table",
+ if (WABT_FAILED(check_var(ctx, ctx->current_module->tables.size, var, "table",
&index))) {
- return WASM_ERROR;
+ return WABT_ERROR;
}
if (out_table)
*out_table = ctx->current_module->tables.data[index];
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult check_memory_var(Context* ctx,
- const WasmVar* var,
- const WasmMemory** out_memory) {
+static WabtResult check_memory_var(Context* ctx,
+ const WabtVar* var,
+ const WabtMemory** out_memory) {
int index;
- if (WASM_FAILED(check_var(ctx, ctx->current_module->memories.size, var,
+ if (WABT_FAILED(check_var(ctx, ctx->current_module->memories.size, var,
"memory", &index))) {
- return WASM_ERROR;
+ return WABT_ERROR;
}
if (out_memory)
*out_memory = ctx->current_module->memories.data[index];
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult check_local_var(Context* ctx,
- const WasmVar* var,
- WasmType* out_type) {
- const WasmFunc* func = ctx->current_func;
- int max_index = wasm_get_num_params_and_locals(func);
- int index = wasm_get_local_index_by_var(func, var);
+static WabtResult check_local_var(Context* ctx,
+ const WabtVar* var,
+ WabtType* out_type) {
+ const WabtFunc* func = ctx->current_func;
+ int max_index = wabt_get_num_params_and_locals(func);
+ int index = wabt_get_local_index_by_var(func, var);
if (index >= 0 && index < max_index) {
if (out_type) {
- int num_params = wasm_get_num_params(func);
+ int num_params = wabt_get_num_params(func);
if (index < num_params) {
- *out_type = wasm_get_param_type(func, index);
+ *out_type = wabt_get_param_type(func, index);
} else {
*out_type = ctx->current_func->local_types.data[index - num_params];
}
}
- return WASM_OK;
+ return WABT_OK;
}
- if (var->type == WASM_VAR_TYPE_NAME) {
+ if (var->type == WABT_VAR_TYPE_NAME) {
print_error(ctx, &var->loc,
"undefined local variable \"" PRIstringslice "\"",
- WASM_PRINTF_STRING_SLICE_ARG(var->name));
+ WABT_PRINTF_STRING_SLICE_ARG(var->name));
} else {
print_error(ctx, &var->loc, "local variable out of range (max %d)",
max_index);
}
- return WASM_ERROR;
+ return WABT_ERROR;
}
static void check_align(Context* ctx,
- const WasmLocation* loc,
+ const WabtLocation* loc,
uint32_t alignment,
uint32_t natural_alignment) {
- if (alignment != WASM_USE_NATURAL_ALIGNMENT) {
+ if (alignment != WABT_USE_NATURAL_ALIGNMENT) {
if (!is_power_of_two(alignment))
print_error(ctx, loc, "alignment must be power-of-two");
if (alignment > natural_alignment) {
@@ -227,15 +227,15 @@ static void check_align(Context* ctx,
}
static void check_offset(Context* ctx,
- const WasmLocation* loc,
+ const WabtLocation* loc,
uint64_t offset) {
if (offset > UINT32_MAX) {
print_error(ctx, loc, "offset must be less than or equal to 0xffffffff");
}
}
-static LabelNode* find_label_by_var(LabelNode* top_label, const WasmVar* var) {
- assert(var->type == WASM_VAR_TYPE_INDEX);
+static LabelNode* find_label_by_var(LabelNode* top_label, const WabtVar* var) {
+ assert(var->type == WABT_VAR_TYPE_INDEX);
LabelNode* node = top_label;
int i = 0;
while (node && i != var->index) {
@@ -245,27 +245,27 @@ static LabelNode* find_label_by_var(LabelNode* top_label, const WasmVar* var) {
return node;
}
-static WasmResult check_label_var(Context* ctx,
+static WabtResult check_label_var(Context* ctx,
LabelNode* top_label,
- const WasmVar* var,
+ const WabtVar* var,
LabelNode** out_node) {
LabelNode* node = find_label_by_var(top_label, var);
if (node) {
if (out_node)
*out_node = node;
- return WASM_OK;
+ return WABT_OK;
}
print_error(ctx, &var->loc, "label variable out of range (max %d)",
ctx->max_depth);
- return WASM_ERROR;
+ return WABT_ERROR;
}
static void push_label(Context* ctx,
- const WasmLocation* loc,
+ const WabtLocation* loc,
LabelNode* node,
LabelType label_type,
- const WasmTypeVector* sig) {
+ const WabtTypeVector* sig) {
node->label_type = label_type;
node->next = ctx->top_label;
node->sig = sig;
@@ -284,8 +284,8 @@ static size_t type_stack_limit(Context* ctx) {
return ctx->top_label->type_stack_limit;
}
-static WasmResult check_type_stack_limit(Context* ctx,
- const WasmLocation* loc,
+static WabtResult check_type_stack_limit(Context* ctx,
+ const WabtLocation* loc,
size_t expected,
const char* desc) {
size_t limit = type_stack_limit(ctx);
@@ -294,13 +294,13 @@ static WasmResult check_type_stack_limit(Context* ctx,
print_error(ctx, loc, "type stack size too small at %s. got %" PRIzd
", expected at least %" PRIzd,
desc, avail, expected);
- return WASM_ERROR;
+ return WABT_ERROR;
}
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult check_type_stack_limit_exact(Context* ctx,
- const WasmLocation* loc,
+static WabtResult check_type_stack_limit_exact(Context* ctx,
+ const WabtLocation* loc,
size_t expected,
const char* desc) {
size_t limit = type_stack_limit(ctx);
@@ -309,80 +309,80 @@ static WasmResult check_type_stack_limit_exact(Context* ctx,
print_error(ctx, loc,
"type stack at end of %s is %" PRIzd ". expected %" PRIzd, desc,
avail, expected);
- return WASM_ERROR;
+ return WABT_ERROR;
}
- return WASM_OK;
+ return WABT_OK;
}
static void reset_type_stack_to_limit(Context* ctx) {
ctx->type_stack.size = type_stack_limit(ctx);
}
-static void push_type(Context* ctx, WasmType type) {
- if (type != WASM_TYPE_VOID)
- wasm_append_type_value(ctx->allocator, &ctx->type_stack, &type);
+static void push_type(Context* ctx, WabtType type) {
+ if (type != WABT_TYPE_VOID)
+ wabt_append_type_value(ctx->allocator, &ctx->type_stack, &type);
}
-static void push_types(Context* ctx, const WasmTypeVector* types) {
+static void push_types(Context* ctx, const WabtTypeVector* types) {
size_t i;
for (i = 0; i < types->size; ++i)
push_type(ctx, types->data[i]);
}
-static WasmType peek_type(Context* ctx, size_t depth, int arity) {
+static WabtType peek_type(Context* ctx, size_t depth, int arity) {
if (arity > 0) {
if (depth < ctx->type_stack.size - type_stack_limit(ctx)) {
return ctx->type_stack.data[ctx->type_stack.size - depth - 1];
} else {
/* return any type to allow type-checking to continue; the caller should
* have already raised an error about the stack underflow. */
- return WASM_TYPE_I32;
+ return WABT_TYPE_I32;
}
} else {
- return WASM_TYPE_VOID;
+ return WABT_TYPE_VOID;
}
}
-static WasmType top_type(Context* ctx) {
+static WabtType top_type(Context* ctx) {
return peek_type(ctx, 0, 1);
}
-static WasmType pop_type(Context* ctx) {
- WasmType result = top_type(ctx);
+static WabtType pop_type(Context* ctx) {
+ WabtType result = top_type(ctx);
if (ctx->type_stack.size > type_stack_limit(ctx))
ctx->type_stack.size--;
return result;
}
static void check_type(Context* ctx,
- const WasmLocation* loc,
- WasmType actual,
- WasmType expected,
+ const WabtLocation* loc,
+ WabtType actual,
+ WabtType expected,
const char* desc) {
if (actual != expected) {
print_error(ctx, loc, "type mismatch at %s. got %s, expected %s", desc,
- wasm_get_type_name(actual), wasm_get_type_name(expected));
+ wabt_get_type_name(actual), wabt_get_type_name(expected));
}
}
static void check_type_index(Context* ctx,
- const WasmLocation* loc,
- WasmType actual,
- WasmType expected,
+ const WabtLocation* loc,
+ WabtType actual,
+ WabtType expected,
const char* desc,
int index,
const char* index_kind) {
if (actual != expected) {
print_error(ctx, loc, "type mismatch for %s %d of %s. got %s, expected %s",
- index_kind, index, desc, wasm_get_type_name(actual),
- wasm_get_type_name(expected));
+ index_kind, index, desc, wabt_get_type_name(actual),
+ wabt_get_type_name(expected));
}
}
static void check_types(Context* ctx,
- const WasmLocation* loc,
- const WasmTypeVector* actual,
- const WasmTypeVector* expected,
+ const WabtLocation* loc,
+ const WabtTypeVector* actual,
+ const WabtTypeVector* expected,
const char* desc,
const char* index_kind) {
if (actual->size == expected->size) {
@@ -398,9 +398,9 @@ static void check_types(Context* ctx,
}
static void check_const_types(Context* ctx,
- const WasmLocation* loc,
- const WasmTypeVector* actual,
- const WasmConstVector* expected,
+ const WabtLocation* loc,
+ const WabtTypeVector* actual,
+ const WabtConstVector* expected,
const char* desc) {
if (actual->size == expected->size) {
size_t i;
@@ -415,67 +415,67 @@ static void check_const_types(Context* ctx,
}
static void check_const_type(Context* ctx,
- const WasmLocation* loc,
- WasmType actual,
- const WasmConstVector* expected,
+ const WabtLocation* loc,
+ WabtType actual,
+ const WabtConstVector* expected,
const char* desc) {
- assert(actual != WASM_TYPE_ANY);
- WasmTypeVector actual_types;
+ assert(actual != WABT_TYPE_ANY);
+ WabtTypeVector actual_types;
- WASM_ZERO_MEMORY(actual_types);
- actual_types.size = actual == WASM_TYPE_VOID ? 0 : 1;
+ WABT_ZERO_MEMORY(actual_types);
+ actual_types.size = actual == WABT_TYPE_VOID ? 0 : 1;
actual_types.data = &actual;
check_const_types(ctx, loc, &actual_types, expected, desc);
}
static void pop_and_check_1_type(Context* ctx,
- const WasmLocation* loc,
- WasmType expected,
+ const WabtLocation* loc,
+ WabtType expected,
const char* desc) {
- if (WASM_SUCCEEDED(check_type_stack_limit(ctx, loc, 1, desc))) {
- WasmType actual = pop_type(ctx);
+ if (WABT_SUCCEEDED(check_type_stack_limit(ctx, loc, 1, desc))) {
+ WabtType actual = pop_type(ctx);
check_type(ctx, loc, actual, expected, desc);
}
}
static void pop_and_check_2_types(Context* ctx,
- const WasmLocation* loc,
- WasmType expected1,
- WasmType expected2,
+ const WabtLocation* loc,
+ WabtType expected1,
+ WabtType expected2,
const char* desc) {
- if (WASM_SUCCEEDED(check_type_stack_limit(ctx, loc, 2, desc))) {
- WasmType actual2 = pop_type(ctx);
- WasmType actual1 = pop_type(ctx);
+ if (WABT_SUCCEEDED(check_type_stack_limit(ctx, loc, 2, desc))) {
+ WabtType actual2 = pop_type(ctx);
+ WabtType actual1 = pop_type(ctx);
check_type(ctx, loc, actual1, expected1, desc);
check_type(ctx, loc, actual2, expected2, desc);
}
}
static void check_opcode1(Context* ctx,
- const WasmLocation* loc,
- WasmOpcode opcode) {
- pop_and_check_1_type(ctx, loc, wasm_get_opcode_param_type_1(opcode),
- wasm_get_opcode_name(opcode));
- push_type(ctx, wasm_get_opcode_result_type(opcode));
+ const WabtLocation* loc,
+ WabtOpcode opcode) {
+ pop_and_check_1_type(ctx, loc, wabt_get_opcode_param_type_1(opcode),
+ wabt_get_opcode_name(opcode));
+ push_type(ctx, wabt_get_opcode_result_type(opcode));
}
static void check_opcode2(Context* ctx,
- const WasmLocation* loc,
- WasmOpcode opcode) {
- pop_and_check_2_types(ctx, loc, wasm_get_opcode_param_type_1(opcode),
- wasm_get_opcode_param_type_2(opcode),
- wasm_get_opcode_name(opcode));
- push_type(ctx, wasm_get_opcode_result_type(opcode));
+ const WabtLocation* loc,
+ WabtOpcode opcode) {
+ pop_and_check_2_types(ctx, loc, wabt_get_opcode_param_type_1(opcode),
+ wabt_get_opcode_param_type_2(opcode),
+ wabt_get_opcode_name(opcode));
+ push_type(ctx, wabt_get_opcode_result_type(opcode));
}
static void check_n_types(Context* ctx,
- const WasmLocation* loc,
- const WasmTypeVector* expected,
+ const WabtLocation* loc,
+ const WabtTypeVector* expected,
const char* desc) {
- if (WASM_SUCCEEDED(check_type_stack_limit(ctx, loc, expected->size, desc))) {
+ if (WABT_SUCCEEDED(check_type_stack_limit(ctx, loc, expected->size, desc))) {
size_t i;
for (i = 0; i < expected->size; ++i) {
- WasmType actual =
+ WabtType actual =
ctx->type_stack.data[ctx->type_stack.size - expected->size + i];
check_type(ctx, loc, actual, expected->data[i], desc);
}
@@ -483,25 +483,25 @@ static void check_n_types(Context* ctx,
}
static void check_assert_return_nan_type(Context* ctx,
- const WasmLocation* loc,
- WasmType actual,
+ const WabtLocation* loc,
+ WabtType actual,
const char* desc) {
/* when using assert_return_nan, the result can be either a f32 or f64 type
* so we special case it here. */
- if (actual != WASM_TYPE_F32 && actual != WASM_TYPE_F64) {
+ if (actual != WABT_TYPE_F32 && actual != WABT_TYPE_F64) {
print_error(ctx, loc, "type mismatch at %s. got %s, expected f32 or f64",
- desc, wasm_get_type_name(actual));
+ desc, wabt_get_type_name(actual));
}
}
-static WasmResult check_br(Context* ctx,
- const WasmLocation* loc,
- const WasmVar* var,
- const WasmBlockSignature** out_sig,
+static WabtResult check_br(Context* ctx,
+ const WabtLocation* loc,
+ const WabtVar* var,
+ const WabtBlockSignature** out_sig,
const char* desc) {
LabelNode* node;
- WasmResult result = check_label_var(ctx, ctx->top_label, var, &node);
- if (WASM_SUCCEEDED(result)) {
+ WabtResult result = check_label_var(ctx, ctx->top_label, var, &node);
+ if (WABT_SUCCEEDED(result)) {
if (node->label_type != LABEL_TYPE_LOOP) {
check_n_types(ctx, loc, node->sig, desc);
}
@@ -513,9 +513,9 @@ static WasmResult check_br(Context* ctx,
}
static void check_call(Context* ctx,
- const WasmLocation* loc,
- const WasmStringSlice* callee_name,
- const WasmFuncSignature* sig,
+ const WabtLocation* loc,
+ const WabtStringSlice* callee_name,
+ const WabtFuncSignature* sig,
const char* desc) {
size_t expected_args = sig->param_types.size;
size_t limit = type_stack_limit(ctx);
@@ -523,9 +523,9 @@ static void check_call(Context* ctx,
size_t i;
if (expected_args <= avail) {
for (i = 0; i < sig->param_types.size; ++i) {
- WasmType actual =
+ WabtType actual =
ctx->type_stack.data[ctx->type_stack.size - expected_args + i];
- WasmType expected = sig->param_types.data[i];
+ WabtType expected = sig->param_types.data[i];
check_type_index(ctx, loc, actual, expected, desc, i, "argument");
}
ctx->type_stack.size -= expected_args;
@@ -539,20 +539,20 @@ static void check_call(Context* ctx,
push_type(ctx, sig->result_types.data[i]);
}
-static void check_expr(Context* ctx, const WasmExpr* expr);
+static void check_expr(Context* ctx, const WabtExpr* expr);
static void check_block(Context* ctx,
- const WasmLocation* loc,
- const WasmExpr* first,
+ const WabtLocation* loc,
+ const WabtExpr* first,
const char* desc) {
- WasmBool check_result = WASM_TRUE;
+ WabtBool check_result = WABT_TRUE;
if (first) {
- const WasmExpr* expr;
+ const WabtExpr* expr;
for (expr = first; expr; expr = expr->next) {
check_expr(ctx, expr);
/* stop typechecking if we hit unreachable code */
- if (top_type(ctx) == WASM_TYPE_ANY) {
- check_result = WASM_FALSE;
+ if (top_type(ctx) == WABT_TYPE_ANY) {
+ check_result = WABT_FALSE;
break;
}
}
@@ -566,21 +566,21 @@ static void check_block(Context* ctx,
}
static void check_has_memory(Context* ctx,
- const WasmLocation* loc,
- WasmOpcode opcode) {
+ const WabtLocation* loc,
+ WabtOpcode opcode) {
if (ctx->current_module->memories.size == 0) {
print_error(ctx, loc, "%s requires an imported or defined memory.",
- wasm_get_opcode_name(opcode));
+ wabt_get_opcode_name(opcode));
}
}
-static void check_expr(Context* ctx, const WasmExpr* expr) {
+static void check_expr(Context* ctx, const WabtExpr* expr) {
switch (expr->type) {
- case WASM_EXPR_TYPE_BINARY:
+ case WABT_EXPR_TYPE_BINARY:
check_opcode2(ctx, &expr->loc, expr->binary.opcode);
break;
- case WASM_EXPR_TYPE_BLOCK: {
+ case WABT_EXPR_TYPE_BLOCK: {
LabelNode node;
push_label(ctx, &expr->loc, &node, LABEL_TYPE_BLOCK, &expr->block.sig);
check_block(ctx, &expr->loc, expr->block.first, "block");
@@ -589,21 +589,21 @@ static void check_expr(Context* ctx, const WasmExpr* expr) {
break;
}
- case WASM_EXPR_TYPE_BR:
+ case WABT_EXPR_TYPE_BR:
check_br(ctx, &expr->loc, &expr->br.var, NULL, "br value");
reset_type_stack_to_limit(ctx);
- push_type(ctx, WASM_TYPE_ANY);
+ push_type(ctx, WABT_TYPE_ANY);
break;
- case WASM_EXPR_TYPE_BR_IF: {
- const WasmBlockSignature* sig;
- pop_and_check_1_type(ctx, &expr->loc, WASM_TYPE_I32, "br_if condition");
+ case WABT_EXPR_TYPE_BR_IF: {
+ const WabtBlockSignature* sig;
+ pop_and_check_1_type(ctx, &expr->loc, WABT_TYPE_I32, "br_if condition");
check_br(ctx, &expr->loc, &expr->br_if.var, &sig, "br_if value");
break;
}
- case WASM_EXPR_TYPE_BR_TABLE: {
- pop_and_check_1_type(ctx, &expr->loc, WASM_TYPE_I32, "br_table key");
+ case WABT_EXPR_TYPE_BR_TABLE: {
+ pop_and_check_1_type(ctx, &expr->loc, WABT_TYPE_I32, "br_table key");
size_t i;
for (i = 0; i < expr->br_table.targets.size; ++i) {
check_br(ctx, &expr->loc, &expr->br_table.targets.data[i], NULL,
@@ -612,73 +612,73 @@ static void check_expr(Context* ctx, const WasmExpr* expr) {
check_br(ctx, &expr->loc, &expr->br_table.default_target, NULL,
"br_table default target");
reset_type_stack_to_limit(ctx);
- push_type(ctx, WASM_TYPE_ANY);
+ push_type(ctx, WABT_TYPE_ANY);
break;
}
- case WASM_EXPR_TYPE_CALL: {
- const WasmFunc* callee;
- if (WASM_SUCCEEDED(check_func_var(ctx, &expr->call.var, &callee)))
+ case WABT_EXPR_TYPE_CALL: {
+ const WabtFunc* callee;
+ if (WABT_SUCCEEDED(check_func_var(ctx, &expr->call.var, &callee)))
check_call(ctx, &expr->loc, &callee->name, &callee->decl.sig, "call");
break;
}
- case WASM_EXPR_TYPE_CALL_INDIRECT: {
- const WasmFuncType* func_type;
+ case WABT_EXPR_TYPE_CALL_INDIRECT: {
+ const WabtFuncType* func_type;
if (ctx->current_module->tables.size == 0) {
print_error(ctx, &expr->loc,
"found call_indirect operator, but no table");
}
- if (WASM_SUCCEEDED(
+ if (WABT_SUCCEEDED(
check_func_type_var(ctx, &expr->call_indirect.var, &func_type))) {
- WasmType type = pop_type(ctx);
- check_type(ctx, &expr->loc, type, WASM_TYPE_I32,
+ WabtType type = pop_type(ctx);
+ check_type(ctx, &expr->loc, type, WABT_TYPE_I32,
"call_indirect function index");
check_call(ctx, &expr->loc, NULL, &func_type->sig, "call_indirect");
}
break;
}
- case WASM_EXPR_TYPE_COMPARE:
+ case WABT_EXPR_TYPE_COMPARE:
check_opcode2(ctx, &expr->loc, expr->compare.opcode);
break;
- case WASM_EXPR_TYPE_CONST:
+ case WABT_EXPR_TYPE_CONST:
push_type(ctx, expr->const_.type);
break;
- case WASM_EXPR_TYPE_CONVERT:
+ case WABT_EXPR_TYPE_CONVERT:
check_opcode1(ctx, &expr->loc, expr->convert.opcode);
break;
- case WASM_EXPR_TYPE_DROP:
- if (WASM_SUCCEEDED(check_type_stack_limit(ctx, &expr->loc, 1, "drop")))
+ case WABT_EXPR_TYPE_DROP:
+ if (WABT_SUCCEEDED(check_type_stack_limit(ctx, &expr->loc, 1, "drop")))
pop_type(ctx);
break;
- case WASM_EXPR_TYPE_GET_GLOBAL: {
- const WasmGlobal* global;
- if (WASM_SUCCEEDED(
+ case WABT_EXPR_TYPE_GET_GLOBAL: {
+ const WabtGlobal* global;
+ if (WABT_SUCCEEDED(
check_global_var(ctx, &expr->get_global.var, &global, NULL)))
push_type(ctx, global->type);
break;
}
- case WASM_EXPR_TYPE_GET_LOCAL: {
- WasmType type;
- if (WASM_SUCCEEDED(check_local_var(ctx, &expr->get_local.var, &type)))
+ case WABT_EXPR_TYPE_GET_LOCAL: {
+ WabtType type;
+ if (WABT_SUCCEEDED(check_local_var(ctx, &expr->get_local.var, &type)))
push_type(ctx, type);
break;
}
- case WASM_EXPR_TYPE_GROW_MEMORY:
- check_has_memory(ctx, &expr->loc, WASM_OPCODE_GROW_MEMORY);
- check_opcode1(ctx, &expr->loc, WASM_OPCODE_GROW_MEMORY);
+ case WABT_EXPR_TYPE_GROW_MEMORY:
+ check_has_memory(ctx, &expr->loc, WABT_OPCODE_GROW_MEMORY);
+ check_opcode1(ctx, &expr->loc, WABT_OPCODE_GROW_MEMORY);
break;
- case WASM_EXPR_TYPE_IF: {
+ case WABT_EXPR_TYPE_IF: {
LabelNode node;
- pop_and_check_1_type(ctx, &expr->loc, WASM_TYPE_I32, "if condition");
+ pop_and_check_1_type(ctx, &expr->loc, WABT_TYPE_I32, "if condition");
push_label(ctx, &expr->loc, &node, LABEL_TYPE_IF, &expr->if_.true_.sig);
check_block(ctx, &expr->loc, expr->if_.true_.first, "if true branch");
check_block(ctx, &expr->loc, expr->if_.false_, "if false branch");
@@ -687,7 +687,7 @@ static void check_expr(Context* ctx, const WasmExpr* expr) {
break;
}
- case WASM_EXPR_TYPE_LOAD:
+ case WABT_EXPR_TYPE_LOAD:
check_has_memory(ctx, &expr->loc, expr->load.opcode);
check_align(ctx, &expr->loc, expr->load.align,
get_opcode_natural_alignment(expr->load.opcode));
@@ -695,7 +695,7 @@ static void check_expr(Context* ctx, const WasmExpr* expr) {
check_opcode1(ctx, &expr->loc, expr->load.opcode);
break;
- case WASM_EXPR_TYPE_LOOP: {
+ case WABT_EXPR_TYPE_LOOP: {
LabelNode node;
push_label(ctx, &expr->loc, &node, LABEL_TYPE_LOOP, &expr->loop.sig);
check_block(ctx, &expr->loc, expr->loop.first, "loop");
@@ -704,38 +704,38 @@ static void check_expr(Context* ctx, const WasmExpr* expr) {
break;
}
- case WASM_EXPR_TYPE_CURRENT_MEMORY:
- check_has_memory(ctx, &expr->loc, WASM_OPCODE_CURRENT_MEMORY);
- push_type(ctx, WASM_TYPE_I32);
+ case WABT_EXPR_TYPE_CURRENT_MEMORY:
+ check_has_memory(ctx, &expr->loc, WABT_OPCODE_CURRENT_MEMORY);
+ push_type(ctx, WABT_TYPE_I32);
break;
- case WASM_EXPR_TYPE_NOP:
+ case WABT_EXPR_TYPE_NOP:
break;
- case WASM_EXPR_TYPE_RETURN: {
+ case WABT_EXPR_TYPE_RETURN: {
check_n_types(ctx, &expr->loc, &ctx->current_func->decl.sig.result_types,
"return");
reset_type_stack_to_limit(ctx);
- push_type(ctx, WASM_TYPE_ANY);
+ push_type(ctx, WABT_TYPE_ANY);
break;
}
- case WASM_EXPR_TYPE_SELECT: {
- pop_and_check_1_type(ctx, &expr->loc, WASM_TYPE_I32, "select");
- if (WASM_SUCCEEDED(
+ case WABT_EXPR_TYPE_SELECT: {
+ pop_and_check_1_type(ctx, &expr->loc, WABT_TYPE_I32, "select");
+ if (WABT_SUCCEEDED(
check_type_stack_limit(ctx, &expr->loc, 2, "select"))) {
- WasmType type1 = pop_type(ctx);
- WasmType type2 = pop_type(ctx);
+ WabtType type1 = pop_type(ctx);
+ WabtType type2 = pop_type(ctx);
check_type(ctx, &expr->loc, type2, type1, "select");
push_type(ctx, type1);
}
break;
}
- case WASM_EXPR_TYPE_SET_GLOBAL: {
- WasmType type = WASM_TYPE_I32;
- const WasmGlobal* global;
- if (WASM_SUCCEEDED(
+ case WABT_EXPR_TYPE_SET_GLOBAL: {
+ WabtType type = WABT_TYPE_I32;
+ const WabtGlobal* global;
+ if (WABT_SUCCEEDED(
check_global_var(ctx, &expr->set_global.var, &global, NULL))) {
type = global->type;
}
@@ -743,14 +743,14 @@ static void check_expr(Context* ctx, const WasmExpr* expr) {
break;
}
- case WASM_EXPR_TYPE_SET_LOCAL: {
- WasmType type = WASM_TYPE_I32;
+ case WABT_EXPR_TYPE_SET_LOCAL: {
+ WabtType type = WABT_TYPE_I32;
check_local_var(ctx, &expr->set_local.var, &type);
pop_and_check_1_type(ctx, &expr->loc, type, "set_local");
break;
}
- case WASM_EXPR_TYPE_STORE:
+ case WABT_EXPR_TYPE_STORE:
check_has_memory(ctx, &expr->loc, expr->store.opcode);
check_align(ctx, &expr->loc, expr->store.align,
get_opcode_natural_alignment(expr->store.opcode));
@@ -758,30 +758,30 @@ static void check_expr(Context* ctx, const WasmExpr* expr) {
check_opcode2(ctx, &expr->loc, expr->store.opcode);
break;
- case WASM_EXPR_TYPE_TEE_LOCAL: {
- WasmType local_type = WASM_TYPE_I32;
+ case WABT_EXPR_TYPE_TEE_LOCAL: {
+ WabtType local_type = WABT_TYPE_I32;
check_local_var(ctx, &expr->tee_local.var, &local_type);
if (check_type_stack_limit(ctx, &expr->loc, 1, "tee_local"))
check_type(ctx, &expr->loc, top_type(ctx), local_type, "tee_local");
break;
}
- case WASM_EXPR_TYPE_UNARY:
+ case WABT_EXPR_TYPE_UNARY:
check_opcode1(ctx, &expr->loc, expr->unary.opcode);
break;
- case WASM_EXPR_TYPE_UNREACHABLE:
+ case WABT_EXPR_TYPE_UNREACHABLE:
reset_type_stack_to_limit(ctx);
- push_type(ctx, WASM_TYPE_ANY);
+ push_type(ctx, WABT_TYPE_ANY);
break;
}
}
static void check_func_signature_matches_func_type(
Context* ctx,
- const WasmLocation* loc,
- const WasmFuncSignature* sig,
- const WasmFuncType* func_type) {
+ const WabtLocation* loc,
+ const WabtFuncSignature* sig,
+ const WabtFuncType* func_type) {
check_types(ctx, loc, &sig->result_types, &func_type->sig.result_types,
"function", "result");
check_types(ctx, loc, &sig->param_types, &func_type->sig.param_types,
@@ -789,17 +789,17 @@ static void check_func_signature_matches_func_type(
}
static void check_func(Context* ctx,
- const WasmLocation* loc,
- const WasmFunc* func) {
+ const WabtLocation* loc,
+ const WabtFunc* func) {
ctx->current_func = func;
- if (wasm_get_num_results(func) > 1) {
+ if (wabt_get_num_results(func) > 1) {
print_error(ctx, loc, "multiple result values not currently supported.");
/* don't run any other checks, the won't test the result_type properly */
return;
}
- if (wasm_decl_has_func_type(&func->decl)) {
- const WasmFuncType* func_type;
- if (WASM_SUCCEEDED(
+ if (wabt_decl_has_func_type(&func->decl)) {
+ const WabtFuncType* func_type;
+ if (WABT_SUCCEEDED(
check_func_type_var(ctx, &func->decl.type_var, &func_type))) {
check_func_signature_matches_func_type(ctx, loc, &func->decl.sig,
func_type);
@@ -816,7 +816,7 @@ static void check_func(Context* ctx,
}
static void print_const_expr_error(Context* ctx,
- const WasmLocation* loc,
+ const WabtLocation* loc,
const char* desc) {
print_error(ctx, loc,
"invalid %s, must be a constant expression; either *.const or "
@@ -825,11 +825,11 @@ static void print_const_expr_error(Context* ctx,
}
static void check_const_init_expr(Context* ctx,
- const WasmLocation* loc,
- const WasmExpr* expr,
- WasmType expected_type,
+ const WabtLocation* loc,
+ const WabtExpr* expr,
+ WabtType expected_type,
const char* desc) {
- WasmType type = WASM_TYPE_VOID;
+ WabtType type = WABT_TYPE_VOID;
if (expr) {
if (expr->next != NULL) {
print_const_expr_error(ctx, loc, desc);
@@ -837,14 +837,14 @@ static void check_const_init_expr(Context* ctx,
}
switch (expr->type) {
- case WASM_EXPR_TYPE_CONST:
+ case WABT_EXPR_TYPE_CONST:
type = expr->const_.type;
break;
- case WASM_EXPR_TYPE_GET_GLOBAL: {
- const WasmGlobal* ref_global = NULL;
+ case WABT_EXPR_TYPE_GET_GLOBAL: {
+ const WabtGlobal* ref_global = NULL;
int ref_global_index;
- if (WASM_FAILED(check_global_var(ctx, &expr->get_global.var,
+ if (WABT_FAILED(check_global_var(ctx, &expr->get_global.var,
&ref_global, &ref_global_index))) {
return;
}
@@ -879,15 +879,15 @@ static void check_const_init_expr(Context* ctx,
}
static void check_global(Context* ctx,
- const WasmLocation* loc,
- const WasmGlobal* global) {
+ const WabtLocation* loc,
+ const WabtGlobal* global) {
check_const_init_expr(ctx, loc, global->init_expr, global->type,
"global initializer expression");
}
static void check_limits(Context* ctx,
- const WasmLocation* loc,
- const WasmLimits* limits,
+ const WabtLocation* loc,
+ const WabtLimits* limits,
uint64_t absolute_max,
const char* desc) {
if (limits->initial > absolute_max) {
@@ -910,105 +910,105 @@ static void check_limits(Context* ctx,
}
static void check_table(Context* ctx,
- const WasmLocation* loc,
- const WasmTable* table) {
+ const WabtLocation* loc,
+ const WabtTable* table) {
if (ctx->current_table_index == 1)
print_error(ctx, loc, "only one table allowed");
check_limits(ctx, loc, &table->elem_limits, UINT32_MAX, "elems");
}
-static void check_elem_segments(Context* ctx, const WasmModule* module) {
- WasmModuleField* field;
+static void check_elem_segments(Context* ctx, const WabtModule* module) {
+ WabtModuleField* field;
for (field = module->first_field; field; field = field->next) {
- if (field->type != WASM_MODULE_FIELD_TYPE_ELEM_SEGMENT)
+ if (field->type != WABT_MODULE_FIELD_TYPE_ELEM_SEGMENT)
continue;
- WasmElemSegment* elem_segment = &field->elem_segment;
- const WasmTable* table;
- if (!WASM_SUCCEEDED(
+ WabtElemSegment* elem_segment = &field->elem_segment;
+ const WabtTable* table;
+ if (!WABT_SUCCEEDED(
check_table_var(ctx, &elem_segment->table_var, &table)))
continue;
size_t i;
for (i = 0; i < elem_segment->vars.size; ++i) {
- if (!WASM_SUCCEEDED(
+ if (!WABT_SUCCEEDED(
check_func_var(ctx, &elem_segment->vars.data[i], NULL)))
continue;
}
- check_const_init_expr(ctx, &field->loc, elem_segment->offset, WASM_TYPE_I32,
+ check_const_init_expr(ctx, &field->loc, elem_segment->offset, WABT_TYPE_I32,
"elem segment offset");
}
}
static void check_memory(Context* ctx,
- const WasmLocation* loc,
- const WasmMemory* memory) {
+ const WabtLocation* loc,
+ const WabtMemory* memory) {
if (ctx->current_memory_index == 1)
print_error(ctx, loc, "only one memory block allowed");
- check_limits(ctx, loc, &memory->page_limits, WASM_MAX_PAGES, "pages");
+ check_limits(ctx, loc, &memory->page_limits, WABT_MAX_PAGES, "pages");
}
-static void check_data_segments(Context* ctx, const WasmModule* module) {
- WasmModuleField* field;
+static void check_data_segments(Context* ctx, const WabtModule* module) {
+ WabtModuleField* field;
for (field = module->first_field; field; field = field->next) {
- if (field->type != WASM_MODULE_FIELD_TYPE_DATA_SEGMENT)
+ if (field->type != WABT_MODULE_FIELD_TYPE_DATA_SEGMENT)
continue;
- WasmDataSegment* data_segment = &field->data_segment;
- const WasmMemory* memory;
- if (!WASM_SUCCEEDED(
+ WabtDataSegment* data_segment = &field->data_segment;
+ const WabtMemory* memory;
+ if (!WABT_SUCCEEDED(
check_memory_var(ctx, &data_segment->memory_var, &memory)))
continue;
- check_const_init_expr(ctx, &field->loc, data_segment->offset, WASM_TYPE_I32,
+ check_const_init_expr(ctx, &field->loc, data_segment->offset, WABT_TYPE_I32,
"data segment offset");
}
}
static void check_import(Context* ctx,
- const WasmLocation* loc,
- const WasmImport* import) {
+ const WabtLocation* loc,
+ const WabtImport* import) {
switch (import->kind) {
- case WASM_EXTERNAL_KIND_FUNC:
- if (wasm_decl_has_func_type(&import->func.decl))
+ case WABT_EXTERNAL_KIND_FUNC:
+ if (wabt_decl_has_func_type(&import->func.decl))
check_func_type_var(ctx, &import->func.decl.type_var, NULL);
break;
- case WASM_EXTERNAL_KIND_TABLE:
+ case WABT_EXTERNAL_KIND_TABLE:
check_table(ctx, loc, &import->table);
ctx->current_table_index++;
break;
- case WASM_EXTERNAL_KIND_MEMORY:
+ case WABT_EXTERNAL_KIND_MEMORY:
check_memory(ctx, loc, &import->memory);
ctx->current_memory_index++;
break;
- case WASM_EXTERNAL_KIND_GLOBAL:
+ case WABT_EXTERNAL_KIND_GLOBAL:
if (import->global.mutable_) {
print_error(ctx, loc, "mutable globals cannot be imported");
}
ctx->num_imported_globals++;
ctx->current_global_index++;
break;
- case WASM_NUM_EXTERNAL_KINDS:
+ case WABT_NUM_EXTERNAL_KINDS:
assert(0);
break;
}
}
-static void check_export(Context* ctx, const WasmExport* export_) {
+static void check_export(Context* ctx, const WabtExport* export_) {
switch (export_->kind) {
- case WASM_EXTERNAL_KIND_FUNC:
+ case WABT_EXTERNAL_KIND_FUNC:
check_func_var(ctx, &export_->var, NULL);
break;
- case WASM_EXTERNAL_KIND_TABLE:
+ case WABT_EXTERNAL_KIND_TABLE:
check_table_var(ctx, &export_->var, NULL);
break;
- case WASM_EXTERNAL_KIND_MEMORY:
+ case WABT_EXTERNAL_KIND_MEMORY:
check_memory_var(ctx, &export_->var, NULL);
break;
- case WASM_EXTERNAL_KIND_GLOBAL: {
- const WasmGlobal* global;
- if (WASM_SUCCEEDED(check_global_var(ctx, &export_->var, &global, NULL))) {
+ case WABT_EXTERNAL_KIND_GLOBAL: {
+ const WabtGlobal* global;
+ if (WABT_SUCCEEDED(check_global_var(ctx, &export_->var, &global, NULL))) {
if (global->mutable_) {
print_error(ctx, &export_->var.loc,
"mutable globals cannot be exported");
@@ -1016,32 +1016,32 @@ static void check_export(Context* ctx, const WasmExport* export_) {
}
break;
}
- case WASM_NUM_EXTERNAL_KINDS:
+ case WABT_NUM_EXTERNAL_KINDS:
assert(0);
break;
}
}
-static void on_duplicate_binding(WasmBindingHashEntry* a,
- WasmBindingHashEntry* b,
+static void on_duplicate_binding(WabtBindingHashEntry* a,
+ WabtBindingHashEntry* b,
void* user_data) {
Context* ctx = user_data;
/* choose the location that is later in the file */
- WasmLocation* a_loc = &a->binding.loc;
- WasmLocation* b_loc = &b->binding.loc;
- WasmLocation* loc = a_loc->line > b_loc->line ? a_loc : b_loc;
+ WabtLocation* a_loc = &a->binding.loc;
+ WabtLocation* b_loc = &b->binding.loc;
+ WabtLocation* loc = a_loc->line > b_loc->line ? a_loc : b_loc;
print_error(ctx, loc, "redefinition of export \"" PRIstringslice "\"",
- WASM_PRINTF_STRING_SLICE_ARG(a->binding.name));
+ WABT_PRINTF_STRING_SLICE_ARG(a->binding.name));
}
static void check_duplicate_export_bindings(Context* ctx,
- const WasmModule* module) {
- wasm_find_duplicate_bindings(&module->export_bindings, on_duplicate_binding,
+ const WabtModule* module) {
+ wabt_find_duplicate_bindings(&module->export_bindings, on_duplicate_binding,
ctx);
}
-static void check_module(Context* ctx, const WasmModule* module) {
- WasmBool seen_start = WASM_FALSE;
+static void check_module(Context* ctx, const WabtModule* module) {
+ WabtBool seen_start = WABT_FALSE;
ctx->current_module = module;
ctx->current_table_index = 0;
@@ -1049,65 +1049,65 @@ static void check_module(Context* ctx, const WasmModule* module) {
ctx->current_global_index = 0;
ctx->num_imported_globals = 0;
- WasmModuleField* field;
+ WabtModuleField* field;
for (field = module->first_field; field != NULL; field = field->next) {
switch (field->type) {
- case WASM_MODULE_FIELD_TYPE_FUNC:
+ case WABT_MODULE_FIELD_TYPE_FUNC:
check_func(ctx, &field->loc, &field->func);
break;
- case WASM_MODULE_FIELD_TYPE_GLOBAL:
+ case WABT_MODULE_FIELD_TYPE_GLOBAL:
check_global(ctx, &field->loc, &field->global);
ctx->current_global_index++;
break;
- case WASM_MODULE_FIELD_TYPE_IMPORT:
+ case WABT_MODULE_FIELD_TYPE_IMPORT:
check_import(ctx, &field->loc, &field->import);
break;
- case WASM_MODULE_FIELD_TYPE_EXPORT:
+ case WABT_MODULE_FIELD_TYPE_EXPORT:
check_export(ctx, &field->export_);
break;
- case WASM_MODULE_FIELD_TYPE_TABLE:
+ case WABT_MODULE_FIELD_TYPE_TABLE:
check_table(ctx, &field->loc, &field->table);
ctx->current_table_index++;
break;
- case WASM_MODULE_FIELD_TYPE_ELEM_SEGMENT:
+ case WABT_MODULE_FIELD_TYPE_ELEM_SEGMENT:
/* checked below */
break;
- case WASM_MODULE_FIELD_TYPE_MEMORY:
+ case WABT_MODULE_FIELD_TYPE_MEMORY:
check_memory(ctx, &field->loc, &field->memory);
ctx->current_memory_index++;
break;
- case WASM_MODULE_FIELD_TYPE_DATA_SEGMENT:
+ case WABT_MODULE_FIELD_TYPE_DATA_SEGMENT:
/* checked below */
break;
- case WASM_MODULE_FIELD_TYPE_FUNC_TYPE:
+ case WABT_MODULE_FIELD_TYPE_FUNC_TYPE:
break;
- case WASM_MODULE_FIELD_TYPE_START: {
+ case WABT_MODULE_FIELD_TYPE_START: {
if (seen_start) {
print_error(ctx, &field->loc, "only one start function allowed");
}
- const WasmFunc* start_func = NULL;
+ const WabtFunc* start_func = NULL;
check_func_var(ctx, &field->start, &start_func);
if (start_func) {
- if (wasm_get_num_params(start_func) != 0) {
+ if (wabt_get_num_params(start_func) != 0) {
print_error(ctx, &field->loc, "start function must be nullary");
}
- if (wasm_get_num_results(start_func) != 0) {
+ if (wabt_get_num_results(start_func) != 0) {
print_error(ctx, &field->loc,
"start function must not return anything");
}
}
- seen_start = WASM_TRUE;
+ seen_start = WABT_TRUE;
break;
}
}
@@ -1121,32 +1121,32 @@ static void check_module(Context* ctx, const WasmModule* module) {
/* returns the result type of the invoked function, checked by the caller;
* returning NULL means that another error occured first, so the result type
* should be ignored. */
-static const WasmTypeVector* check_invoke(Context* ctx,
- const WasmAction* action) {
- const WasmActionInvoke* invoke = &action->invoke;
- const WasmModule* module =
- wasm_get_module_by_var(ctx->script, &action->module_var);
+static const WabtTypeVector* check_invoke(Context* ctx,
+ const WabtAction* action) {
+ const WabtActionInvoke* invoke = &action->invoke;
+ const WabtModule* module =
+ wabt_get_module_by_var(ctx->script, &action->module_var);
if (!module) {
print_error(ctx, &action->loc, "unknown module");
return NULL;
}
- WasmExport* export = wasm_get_export_by_name(module, &invoke->name);
+ WabtExport* export = wabt_get_export_by_name(module, &invoke->name);
if (!export) {
print_error(ctx, &action->loc,
"unknown function export \"" PRIstringslice "\"",
- WASM_PRINTF_STRING_SLICE_ARG(invoke->name));
+ WABT_PRINTF_STRING_SLICE_ARG(invoke->name));
return NULL;
}
- WasmFunc* func = wasm_get_func_by_var(module, &export->var);
+ WabtFunc* func = wabt_get_func_by_var(module, &export->var);
if (!func) {
/* this error will have already been reported, just skip it */
return NULL;
}
size_t actual_args = invoke->args.size;
- size_t expected_args = wasm_get_num_params(func);
+ size_t expected_args = wabt_get_num_params(func);
if (expected_args != actual_args) {
print_error(ctx, &action->loc, "too %s parameters to function. got %" PRIzd
", expected %" PRIzd,
@@ -1156,56 +1156,56 @@ static const WasmTypeVector* check_invoke(Context* ctx,
}
size_t i;
for (i = 0; i < actual_args; ++i) {
- WasmConst* const_ = &invoke->args.data[i];
+ WabtConst* const_ = &invoke->args.data[i];
check_type_index(ctx, &const_->loc, const_->type,
- wasm_get_param_type(func, i), "invoke", i, "argument");
+ wabt_get_param_type(func, i), "invoke", i, "argument");
}
return &func->decl.sig.result_types;
}
-static WasmResult check_get(Context* ctx,
- const WasmAction* action,
- WasmType* out_type) {
- const WasmActionGet* get = &action->get;
- const WasmModule* module =
- wasm_get_module_by_var(ctx->script, &action->module_var);
+static WabtResult check_get(Context* ctx,
+ const WabtAction* action,
+ WabtType* out_type) {
+ const WabtActionGet* get = &action->get;
+ const WabtModule* module =
+ wabt_get_module_by_var(ctx->script, &action->module_var);
if (!module) {
print_error(ctx, &action->loc, "unknown module");
- return WASM_ERROR;
+ return WABT_ERROR;
}
- WasmExport* export = wasm_get_export_by_name(module, &get->name);
+ WabtExport* export = wabt_get_export_by_name(module, &get->name);
if (!export) {
print_error(ctx, &action->loc,
"unknown global export \"" PRIstringslice "\"",
- WASM_PRINTF_STRING_SLICE_ARG(get->name));
- return WASM_ERROR;
+ WABT_PRINTF_STRING_SLICE_ARG(get->name));
+ return WABT_ERROR;
}
- WasmGlobal* global = wasm_get_global_by_var(module, &export->var);
+ WabtGlobal* global = wabt_get_global_by_var(module, &export->var);
if (!global) {
/* this error will have already been reported, just skip it */
- return WASM_ERROR;
+ return WABT_ERROR;
}
*out_type = global->type;
- return WASM_OK;
+ return WABT_OK;
}
-static ActionResult check_action(Context* ctx, const WasmAction* action) {
+static ActionResult check_action(Context* ctx, const WabtAction* action) {
ActionResult result;
- WASM_ZERO_MEMORY(result);
+ WABT_ZERO_MEMORY(result);
switch (action->type) {
- case WASM_ACTION_TYPE_INVOKE:
+ case WABT_ACTION_TYPE_INVOKE:
result.types = check_invoke(ctx, action);
result.kind =
result.types ? ACTION_RESULT_KIND_TYPES : ACTION_RESULT_KIND_ERROR;
break;
- case WASM_ACTION_TYPE_GET:
- if (WASM_SUCCEEDED(check_get(ctx, action, &result.type)))
+ case WABT_ACTION_TYPE_GET:
+ if (WABT_SUCCEEDED(check_get(ctx, action, &result.type)))
result.kind = ACTION_RESULT_KIND_TYPE;
else
result.kind = ACTION_RESULT_KIND_ERROR;
@@ -1215,28 +1215,28 @@ static ActionResult check_action(Context* ctx, const WasmAction* action) {
return result;
}
-static void check_command(Context* ctx, const WasmCommand* command) {
+static void check_command(Context* ctx, const WabtCommand* command) {
switch (command->type) {
- case WASM_COMMAND_TYPE_MODULE:
+ case WABT_COMMAND_TYPE_MODULE:
check_module(ctx, &command->module);
break;
- case WASM_COMMAND_TYPE_ACTION:
+ case WABT_COMMAND_TYPE_ACTION:
/* ignore result type */
check_action(ctx, &command->action);
break;
- case WASM_COMMAND_TYPE_REGISTER:
- case WASM_COMMAND_TYPE_ASSERT_MALFORMED:
- case WASM_COMMAND_TYPE_ASSERT_INVALID:
- case WASM_COMMAND_TYPE_ASSERT_INVALID_NON_BINARY:
- case WASM_COMMAND_TYPE_ASSERT_UNLINKABLE:
- case WASM_COMMAND_TYPE_ASSERT_UNINSTANTIABLE:
+ case WABT_COMMAND_TYPE_REGISTER:
+ case WABT_COMMAND_TYPE_ASSERT_MALFORMED:
+ case WABT_COMMAND_TYPE_ASSERT_INVALID:
+ case WABT_COMMAND_TYPE_ASSERT_INVALID_NON_BINARY:
+ case WABT_COMMAND_TYPE_ASSERT_UNLINKABLE:
+ case WABT_COMMAND_TYPE_ASSERT_UNINSTANTIABLE:
/* ignore */
break;
- case WASM_COMMAND_TYPE_ASSERT_RETURN: {
- const WasmAction* action = &command->assert_return.action;
+ case WABT_COMMAND_TYPE_ASSERT_RETURN: {
+ const WabtAction* action = &command->assert_return.action;
ActionResult result = check_action(ctx, action);
switch (result.kind) {
case ACTION_RESULT_KIND_TYPES:
@@ -1256,12 +1256,12 @@ static void check_command(Context* ctx, const WasmCommand* command) {
break;
}
- case WASM_COMMAND_TYPE_ASSERT_RETURN_NAN: {
- const WasmAction* action = &command->assert_return_nan.action;
+ case WABT_COMMAND_TYPE_ASSERT_RETURN_NAN: {
+ const WabtAction* action = &command->assert_return_nan.action;
ActionResult result = check_action(ctx, action);
/* a valid result type will either be f32 or f64; convert a TYPES result
- * into a TYPE result, so it is easier to check below. WASM_TYPE_ANY is
+ * into a TYPE result, so it is easier to check below. WABT_TYPE_ANY is
* used to specify a type that should not be checked (because an earlier
* error occurred). */
if (result.kind == ACTION_RESULT_KIND_TYPES) {
@@ -1271,46 +1271,46 @@ static void check_command(Context* ctx, const WasmCommand* command) {
} else {
print_error(ctx, &action->loc, "expected 1 result, got %" PRIzd,
result.types->size);
- result.type = WASM_TYPE_ANY;
+ result.type = WABT_TYPE_ANY;
}
}
if (result.kind == ACTION_RESULT_KIND_TYPE &&
- result.type != WASM_TYPE_ANY)
+ result.type != WABT_TYPE_ANY)
check_assert_return_nan_type(ctx, &action->loc, result.type, "action");
break;
}
- case WASM_COMMAND_TYPE_ASSERT_TRAP:
- case WASM_COMMAND_TYPE_ASSERT_EXHAUSTION:
+ case WABT_COMMAND_TYPE_ASSERT_TRAP:
+ case WABT_COMMAND_TYPE_ASSERT_EXHAUSTION:
/* ignore result type */
check_action(ctx, &command->assert_trap.action);
break;
- case WASM_NUM_COMMAND_TYPES:
+ case WABT_NUM_COMMAND_TYPES:
assert(0);
break;
}
}
-static void wasm_destroy_context(Context* ctx) {
- wasm_destroy_type_vector(ctx->allocator, &ctx->type_stack);
+static void wabt_destroy_context(Context* ctx) {
+ wabt_destroy_type_vector(ctx->allocator, &ctx->type_stack);
}
-WasmResult wasm_validate_script(WasmAllocator* allocator,
- WasmAstLexer* lexer,
- const struct WasmScript* script,
- WasmSourceErrorHandler* error_handler) {
+WabtResult wabt_validate_script(WabtAllocator* allocator,
+ WabtAstLexer* lexer,
+ const struct WabtScript* script,
+ WabtSourceErrorHandler* error_handler) {
Context ctx;
- WASM_ZERO_MEMORY(ctx);
+ WABT_ZERO_MEMORY(ctx);
ctx.allocator = allocator;
ctx.lexer = lexer;
ctx.error_handler = error_handler;
- ctx.result = WASM_OK;
+ ctx.result = WABT_OK;
ctx.script = script;
size_t i;
for (i = 0; i < script->commands.size; ++i)
check_command(&ctx, &script->commands.data[i]);
- wasm_destroy_context(&ctx);
+ wabt_destroy_context(&ctx);
return ctx.result;
}
diff --git a/src/validator.h b/src/validator.h
index d6f29d27..47cf7a00 100644
--- a/src/validator.h
+++ b/src/validator.h
@@ -14,22 +14,22 @@
* limitations under the License.
*/
-#ifndef WASM_VALIDATOR_H_
-#define WASM_VALIDATOR_H_
+#ifndef WABT_VALIDATOR_H_
+#define WABT_VALIDATOR_H_
#include "ast-lexer.h"
#include "common.h"
-struct WasmAllocator;
-struct WasmModule;
-struct WasmScript;
+struct WabtAllocator;
+struct WabtModule;
+struct WabtScript;
-WASM_EXTERN_C_BEGIN
+WABT_EXTERN_C_BEGIN
/* perform all checks on the AST; the module is valid if and only if this
* function succeeds. */
-WasmResult wasm_validate_script(struct WasmAllocator*,
- WasmAstLexer*,
- const struct WasmScript*,
- WasmSourceErrorHandler*);
+WabtResult wabt_validate_script(struct WabtAllocator*,
+ WabtAstLexer*,
+ const struct WabtScript*,
+ WabtSourceErrorHandler*);
-#endif /* WASM_VALIDATOR_H_ */
+#endif /* WABT_VALIDATOR_H_ */
diff --git a/src/vector-sort.h b/src/vector-sort.h
index 9a5a93d9..78ca5f13 100644
--- a/src/vector-sort.h
+++ b/src/vector-sort.h
@@ -14,19 +14,19 @@
* limitations under the License.
*/
-#ifndef WASM_VECTOR_SORT_H_
-#define WASM_VECTOR_SORT_H_
+#ifndef WABT_VECTOR_SORT_H_
+#define WABT_VECTOR_SORT_H_
#include "vector.h"
/*
- * Define algorithm to sort wasm vectors (defined by macro WASM_VECTOR).
+ * Define algorithm to sort wabt vectors (defined by macro WABT_VECTOR).
*
*/
-#define WASM_DEFINE_VECTOR_SORT(name, type) \
- static void wasm_sort_##name##_vector( \
- struct WasmAllocator* allocator, \
+#define WABT_DEFINE_VECTOR_SORT(name, type) \
+ static void wabt_sort_##name##_vector( \
+ struct WabtAllocator* allocator, \
type##Vector* in_vec, \
type##Vector* out_vec, \
void (*swap_fcn)(type* v1, type*v2), \
@@ -37,7 +37,7 @@
if (in_vec->size == 0) \
return; \
for (i = 0; i < in_vec->size; ++i) { \
- wasm_append_##name##_value(allocator, out_vec, &in_vec->data[i]); \
+ wabt_append_##name##_value(allocator, out_vec, &in_vec->data[i]); \
if (out_vec->size < 2) \
continue; \
for (j = out_vec->size; j >= 2; --j) { \
@@ -49,4 +49,4 @@
} \
}
-#endif // WASM_VECTOR_SORT_H_
+#endif // WABT_VECTOR_SORT_H_
diff --git a/src/vector.c b/src/vector.c
index b35a4295..82dba65a 100644
--- a/src/vector.c
+++ b/src/vector.c
@@ -20,7 +20,7 @@
#define INITIAL_VECTOR_CAPACITY 8
-void wasm_ensure_capacity(WasmAllocator* allocator,
+void wabt_ensure_capacity(WabtAllocator* allocator,
void** data,
size_t* capacity,
size_t desired_size,
@@ -30,19 +30,19 @@ void wasm_ensure_capacity(WasmAllocator* allocator,
while (new_capacity < desired_size)
new_capacity *= 2;
size_t new_byte_size = new_capacity * elt_byte_size;
- *data = wasm_realloc(allocator, *data, new_byte_size, WASM_DEFAULT_ALIGN);
+ *data = wabt_realloc(allocator, *data, new_byte_size, WABT_DEFAULT_ALIGN);
*capacity = new_capacity;
}
}
-void wasm_resize_vector(struct WasmAllocator* allocator,
+void wabt_resize_vector(struct WabtAllocator* allocator,
void** data,
size_t* size,
size_t* capacity,
size_t desired_size,
size_t elt_byte_size) {
size_t old_size = *size;
- wasm_ensure_capacity(allocator, data, capacity, desired_size, elt_byte_size);
+ wabt_ensure_capacity(allocator, data, capacity, desired_size, elt_byte_size);
if (desired_size > old_size) {
memset((void*)((size_t)*data + old_size * elt_byte_size), 0,
(desired_size - old_size) * elt_byte_size);
@@ -50,25 +50,25 @@ void wasm_resize_vector(struct WasmAllocator* allocator,
*size = desired_size;
}
-void* wasm_append_element(WasmAllocator* allocator,
+void* wabt_append_element(WabtAllocator* allocator,
void** data,
size_t* size,
size_t* capacity,
size_t elt_byte_size) {
- wasm_ensure_capacity(allocator, data, capacity, *size + 1, elt_byte_size);
+ wabt_ensure_capacity(allocator, data, capacity, *size + 1, elt_byte_size);
void* p = (void*)((size_t)*data + (*size)++ * elt_byte_size);
memset(p, 0, elt_byte_size);
return p;
}
-void wasm_extend_elements(WasmAllocator* allocator,
+void wabt_extend_elements(WabtAllocator* allocator,
void** dst,
size_t* dst_size,
size_t* dst_capacity,
const void** src,
size_t src_size,
size_t elt_byte_size) {
- wasm_ensure_capacity(allocator, dst, dst_capacity, *dst_size + src_size,
+ wabt_ensure_capacity(allocator, dst, dst_capacity, *dst_size + src_size,
elt_byte_size);
memcpy((void*)((size_t)*dst + (*dst_size * elt_byte_size)), *src,
src_size * elt_byte_size);
diff --git a/src/vector.h b/src/vector.h
index a40b7a42..2b58d946 100644
--- a/src/vector.h
+++ b/src/vector.h
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#ifndef WASM_VECTOR_H_
-#define WASM_VECTOR_H_
+#ifndef WABT_VECTOR_H_
+#define WABT_VECTOR_H_
#include <stddef.h>
@@ -24,123 +24,123 @@
#include "config.h"
/*
- * WASM_DEFINE_VECTOR(widget, WasmWidget) defines struct and functions like the
+ * WABT_DEFINE_VECTOR(widget, WabtWidget) defines struct and functions like the
* following:
*
- * typedef struct WasmWidgetVector {
- * WasmWidget* data;
+ * typedef struct WabtWidgetVector {
+ * WabtWidget* data;
* size_t size;
* size_t capacity;
- * } WasmWidgetVector;
+ * } WabtWidgetVector;
*
- * void wasm_destroy_widget_vector(WasmAllocator*, WasmWidgetVector* vec);
- * WasmWidget* wasm_append_widget(WasmAllocator*, WasmWidgetVector* vec);
- * void wasm_resize_widget_vector(WasmAllocator*, WasmWidgetVector* vec,
+ * void wabt_destroy_widget_vector(WabtAllocator*, WabtWidgetVector* vec);
+ * WabtWidget* wabt_append_widget(WabtAllocator*, WabtWidgetVector* vec);
+ * void wabt_resize_widget_vector(WabtAllocator*, WabtWidgetVector* vec,
* size_t size);
- * void wasm_reserve_widgets(WasmAllocator*, WasmWidgetVector* vec,
+ * void wabt_reserve_widgets(WabtAllocator*, WabtWidgetVector* vec,
* size_t desired);
- * void wasm_append_widget_value(WasmAllocator*, WasmWidgetVector* vec,
- * const WasmWidget* value);
- * void wasm_extend_widgets(WasmAllocator*, WasmWidgetVector* dst,
- * const WasmWidgetVector* src);
+ * void wabt_append_widget_value(WabtAllocator*, WabtWidgetVector* vec,
+ * const WabtWidget* value);
+ * void wabt_extend_widgets(WabtAllocator*, WabtWidgetVector* dst,
+ * const WabtWidgetVector* src);
*/
-#define WASM_DEFINE_VECTOR(name, type) \
+#define WABT_DEFINE_VECTOR(name, type) \
typedef struct type##Vector { \
type* data; \
size_t size; \
size_t capacity; \
} type##Vector; \
\
- WASM_EXTERN_C_BEGIN \
- static WASM_INLINE void wasm_destroy_##name##_vector( \
- struct WasmAllocator* allocator, type##Vector* vec) WASM_UNUSED; \
- static WASM_INLINE void wasm_resize_##name##_vector( \
- struct WasmAllocator* allocator, type##Vector* vec, size_t desired) \
- WASM_UNUSED; \
- static WASM_INLINE void wasm_reserve_##name##s( \
- struct WasmAllocator* allocator, type##Vector* vec, size_t desired) \
- WASM_UNUSED; \
- static WASM_INLINE type* wasm_append_##name(struct WasmAllocator* allocator, \
- type##Vector* vec) WASM_UNUSED; \
- static WASM_INLINE void wasm_append_##name##_value( \
- struct WasmAllocator* allocator, type##Vector* vec, const type* value) \
- WASM_UNUSED; \
- static WASM_INLINE void wasm_extend_##name##s( \
- struct WasmAllocator* allocator, type##Vector* dst, \
- const type##Vector* src) WASM_UNUSED; \
- WASM_EXTERN_C_END \
+ WABT_EXTERN_C_BEGIN \
+ static WABT_INLINE void wabt_destroy_##name##_vector( \
+ struct WabtAllocator* allocator, type##Vector* vec) WABT_UNUSED; \
+ static WABT_INLINE void wabt_resize_##name##_vector( \
+ struct WabtAllocator* allocator, type##Vector* vec, size_t desired) \
+ WABT_UNUSED; \
+ static WABT_INLINE void wabt_reserve_##name##s( \
+ struct WabtAllocator* allocator, type##Vector* vec, size_t desired) \
+ WABT_UNUSED; \
+ static WABT_INLINE type* wabt_append_##name(struct WabtAllocator* allocator, \
+ type##Vector* vec) WABT_UNUSED; \
+ static WABT_INLINE void wabt_append_##name##_value( \
+ struct WabtAllocator* allocator, type##Vector* vec, const type* value) \
+ WABT_UNUSED; \
+ static WABT_INLINE void wabt_extend_##name##s( \
+ struct WabtAllocator* allocator, type##Vector* dst, \
+ const type##Vector* src) WABT_UNUSED; \
+ WABT_EXTERN_C_END \
\
- void wasm_destroy_##name##_vector(struct WasmAllocator* allocator, \
+ void wabt_destroy_##name##_vector(struct WabtAllocator* allocator, \
type##Vector* vec) { \
- wasm_free(allocator, vec->data); \
+ wabt_free(allocator, vec->data); \
vec->data = NULL; \
vec->size = 0; \
vec->capacity = 0; \
} \
- void wasm_resize_##name##_vector(struct WasmAllocator* allocator, \
+ void wabt_resize_##name##_vector(struct WabtAllocator* allocator, \
type##Vector* vec, size_t size) { \
- wasm_resize_vector(allocator, (void**)&vec->data, &vec->size, \
+ wabt_resize_vector(allocator, (void**)&vec->data, &vec->size, \
&vec->capacity, size, sizeof(type)); \
} \
- void wasm_reserve_##name##s(struct WasmAllocator* allocator, \
+ void wabt_reserve_##name##s(struct WabtAllocator* allocator, \
type##Vector* vec, size_t desired) { \
- wasm_ensure_capacity(allocator, (void**)&vec->data, &vec->capacity, \
+ wabt_ensure_capacity(allocator, (void**)&vec->data, &vec->capacity, \
desired, sizeof(type)); \
} \
- type* wasm_append_##name(struct WasmAllocator* allocator, \
+ type* wabt_append_##name(struct WabtAllocator* allocator, \
type##Vector* vec) { \
- return (type*)wasm_append_element(allocator, (void**)&vec->data, \
+ return (type*)wabt_append_element(allocator, (void**)&vec->data, \
&vec->size, &vec->capacity, \
sizeof(type)); \
} \
- void wasm_append_##name##_value(struct WasmAllocator* allocator, \
+ void wabt_append_##name##_value(struct WabtAllocator* allocator, \
type##Vector* vec, const type* value) { \
- type* slot = wasm_append_##name(allocator, vec); \
+ type* slot = wabt_append_##name(allocator, vec); \
*slot = *value; \
} \
- void wasm_extend_##name##s(struct WasmAllocator* allocator, \
+ void wabt_extend_##name##s(struct WabtAllocator* allocator, \
type##Vector* dst, const type##Vector* src) { \
- wasm_extend_elements(allocator, (void**)&dst->data, &dst->size, \
+ wabt_extend_elements(allocator, (void**)&dst->data, &dst->size, \
&dst->capacity, (const void**)&src->data, src->size, \
sizeof(type)); \
}
-#define WASM_DESTROY_VECTOR_AND_ELEMENTS(allocator, v, name) \
+#define WABT_DESTROY_VECTOR_AND_ELEMENTS(allocator, v, name) \
{ \
size_t i; \
for (i = 0; i < (v).size; ++i) \
- wasm_destroy_##name(allocator, &((v).data[i])); \
- wasm_destroy_##name##_vector(allocator, &(v)); \
+ wabt_destroy_##name(allocator, &((v).data[i])); \
+ wabt_destroy_##name##_vector(allocator, &(v)); \
}
-WASM_EXTERN_C_BEGIN
-void wasm_ensure_capacity(struct WasmAllocator*,
+WABT_EXTERN_C_BEGIN
+void wabt_ensure_capacity(struct WabtAllocator*,
void** data,
size_t* capacity,
size_t desired_size,
size_t elt_byte_size);
-void wasm_resize_vector(struct WasmAllocator*,
+void wabt_resize_vector(struct WabtAllocator*,
void** data,
size_t* size,
size_t* capacity,
size_t desired_size,
size_t elt_byte_size);
-void* wasm_append_element(struct WasmAllocator*,
+void* wabt_append_element(struct WabtAllocator*,
void** data,
size_t* size,
size_t* capacity,
size_t elt_byte_size);
-void wasm_extend_elements(struct WasmAllocator*,
+void wabt_extend_elements(struct WabtAllocator*,
void** dst,
size_t* dst_size,
size_t* dst_capacity,
const void** src,
size_t src_size,
size_t elt_byte_size);
-WASM_EXTERN_C_END
+WABT_EXTERN_C_END
-#endif /* WASM_VECTOR_H_ */
+#endif /* WABT_VECTOR_H_ */
diff --git a/src/wasm.js b/src/wabt.js
index d77dd3bf..5412713b 100644
--- a/src/wasm.js
+++ b/src/wabt.js
@@ -14,11 +14,11 @@
* limitations under the License.
*/
-var wasm = {};
+var wabt = {};
-wasm.ready = new Promise(function(resolve, reject) {
- wasm.$resolve = resolve;
- wasm.$reject = reject;
+wabt.ready = new Promise(function(resolve, reject) {
+ wabt.$resolve = resolve;
+ wabt.$reject = reject;
});
var Module = {};
@@ -49,9 +49,9 @@ function loadbuffer(addr, len) {
return new Uint8Array(HEAPU8.buffer, addr, len);
}
-function sizeof(structName) { return Module['_wasm_sizeof_' + structName](); }
+function sizeof(structName) { return Module['_wabt_sizeof_' + structName](); }
function offsetof(structName, fieldName) {
- return Module['_wasm_offsetof_' + structName + '_' + fieldName]();
+ return Module['_wabt_offsetof_' + structName + '_' + fieldName]();
}
function malloc(size) {
@@ -531,13 +531,13 @@ BufferValue.prototype.toString = function() {
return '<Buffer>@' + this.$addr + ', ' + this.size + ' bytes';
};
-// Wasm enums //////////////////////////////////////////////////////////////////
+// Wabt enums //////////////////////////////////////////////////////////////////
-// WasmResult
+// WabtResult
var OK = 0;
var ERROR = 1;
-// Wasm low-level types ////////////////////////////////////////////////////////
+// Wabt low-level types ////////////////////////////////////////////////////////
var I = (function() {
@@ -633,23 +633,23 @@ Writer.define('writer', {
move_data: Fn(I32, [U32, U32, U32, UserData]),
});
-// Wasm low-level functions ////////////////////////////////////////////////////
-
-var checkAst = Fn(I32, [Ptr(Allocator), Ptr(AstLexer), Ptr(Script), Ptr(SourceErrorHandler)]).define('_wasm_check_ast');
-var closeMemWriter = Fn(Void, [Ptr(MemoryWriter)]).define('_wasm_close_mem_writer');
-var defaultBinaryErrorCallback = BinaryErrorHandlerCallback.define('_wasm_default_binary_error_callback');
-var defaultSourceErrorCallback = SourceErrorHandlerCallback.define('_wasm_default_source_error_callback');
-var destroyAstLexer = Fn(Void, [Ptr(AstLexer)]).define('_wasm_destroy_ast_lexer');
-var destroyOutputBuffer = Fn(Void, [Ptr(OutputBuffer)]).define('_wasm_destroy_output_buffer');
-var destroyScript = Fn(Void, [Ptr(Script)]).define('_wasm_destroy_script');
-var destroyStackAllocator = Fn(Void, [Ptr(StackAllocator)]).define('_wasm_destroy_stack_allocator');
-var getLibcAllocator = Fn(Ptr(Allocator), []).define('_wasm_get_libc_allocator');
-var initMemWriter = Fn(I32, [Ptr(Allocator), Ptr(MemoryWriter)]).define('_wasm_init_mem_writer');
-var initStackAllocator = Fn(Void, [Ptr(StackAllocator), Ptr(Allocator)]).define('_wasm_init_stack_allocator');
-var initStream = Fn(Void, [Ptr(Stream), Ptr(Writer), Ptr(Stream)]).define('_wasm_init_stream');
-var newAstBufferLexer = Fn(Ptr(AstLexer), [Ptr(Allocator), Str, BufPtr, BufLen]).define('_wasm_new_ast_buffer_lexer');
-var parseAst = Fn(I32, [Ptr(AstLexer), Ptr(Script), Ptr(SourceErrorHandler)]).define('_wasm_parse_ast');
-var writeBinaryScript = Fn(I32, [Ptr(Allocator), Ptr(Writer), Ptr(Script), Ptr(WriteBinaryOptions)]).define('_wasm_write_binary_script');
+// Wabt low-level functions ////////////////////////////////////////////////////
+
+var checkAst = Fn(I32, [Ptr(Allocator), Ptr(AstLexer), Ptr(Script), Ptr(SourceErrorHandler)]).define('_wabt_check_ast');
+var closeMemWriter = Fn(Void, [Ptr(MemoryWriter)]).define('_wabt_close_mem_writer');
+var defaultBinaryErrorCallback = BinaryErrorHandlerCallback.define('_wabt_default_binary_error_callback');
+var defaultSourceErrorCallback = SourceErrorHandlerCallback.define('_wabt_default_source_error_callback');
+var destroyAstLexer = Fn(Void, [Ptr(AstLexer)]).define('_wabt_destroy_ast_lexer');
+var destroyOutputBuffer = Fn(Void, [Ptr(OutputBuffer)]).define('_wabt_destroy_output_buffer');
+var destroyScript = Fn(Void, [Ptr(Script)]).define('_wabt_destroy_script');
+var destroyStackAllocator = Fn(Void, [Ptr(StackAllocator)]).define('_wabt_destroy_stack_allocator');
+var getLibcAllocator = Fn(Ptr(Allocator), []).define('_wabt_get_libc_allocator');
+var initMemWriter = Fn(I32, [Ptr(Allocator), Ptr(MemoryWriter)]).define('_wabt_init_mem_writer');
+var initStackAllocator = Fn(Void, [Ptr(StackAllocator), Ptr(Allocator)]).define('_wabt_init_stack_allocator');
+var initStream = Fn(Void, [Ptr(Stream), Ptr(Writer), Ptr(Stream)]).define('_wabt_init_stream');
+var newAstBufferLexer = Fn(Ptr(AstLexer), [Ptr(Allocator), Str, BufPtr, BufLen]).define('_wabt_new_ast_buffer_lexer');
+var parseAst = Fn(I32, [Ptr(AstLexer), Ptr(Script), Ptr(SourceErrorHandler)]).define('_wabt_parse_ast');
+var writeBinaryScript = Fn(I32, [Ptr(Allocator), Ptr(Writer), Ptr(Script), Ptr(WriteBinaryOptions)]).define('_wabt_write_binary_script');
return {
// Types
@@ -1033,10 +1033,10 @@ ReadBinaryOptions.prototype.$destroy = function() {
////////////////////////////////////////////////////////////////////////////////
-var resolve = wasm.$resolve;
+var resolve = wabt.$resolve;
-wasm = {
- ready: wasm.ready,
+wabt = {
+ ready: wabt.ready,
// Types
LibcAllocator: LibcAllocator,
@@ -1051,13 +1051,13 @@ resolve();
};
/*
-wasm.ready.then(function() {
+wabt.ready.then(function() {
if (false) {
try {
- var sa = new wasm.StackAllocator(wasm.LibcAllocator);
+ var sa = new wabt.StackAllocator(wabt.LibcAllocator);
var a = sa.allocator;
var data = '(module\n (func (result i32)\n (i32.const 1)))';
- var s = wasm.parseAst(a, 'foo.wast', data);
+ var s = wabt.parseAst(a, 'foo.wast', data);
s.check();
var output = s.toBinary({log: true});
print('log output:\n' + output.log);
@@ -1071,8 +1071,8 @@ wasm.ready.then(function() {
if (false) {
try {
- var a = new wasm.StackAllocator(wasm.LibcAllocator);
- var ma = wasm.LibcAllocator;
+ var a = new wabt.StackAllocator(wabt.LibcAllocator);
+ var ma = wabt.LibcAllocator;
var buf = new Uint8Array([
0, 97, 115, 109, 11, 0, 0, 0, 4, 116, 121, 112, 101, 8, 2, 64,
1, 1, 0, 64, 0, 0, 6, 105, 109, 112, 111, 114, 116, 12, 1, 0,
@@ -1080,8 +1080,8 @@ wasm.ready.then(function() {
105, 111, 110, 2, 1, 1, 6, 101, 120, 112, 111, 114, 116, 4, 1, 0,
1, 102, 4, 99, 111, 100, 101, 8, 1, 6, 0, 16, 42, 24, 1, 0,
]);
- var im = wasm.readInterpreterModule(a.allocator, ma, buf, {});
- var it = new wasm.InterpreterThread(a.allocator, im);
+ var im = wabt.readInterpreterModule(a.allocator, ma, buf, {});
+ var it = new wabt.InterpreterThread(a.allocator, im);
im.run(it, 1000, 0);
} catch(e) {
print('ERROR:' + (e.stack ? e.stack : e));
@@ -1093,7 +1093,7 @@ wasm.ready.then(function() {
if (true) {
try {
- var sa = new wasm.StackAllocator(wasm.LibcAllocator);
+ var sa = new wabt.StackAllocator(wabt.LibcAllocator);
var a = sa.allocator;
var source = `
(module
@@ -1115,15 +1115,15 @@ wasm.ready.then(function() {
(return (get_local $b)))
(export "test" $test))
`;
- var s = wasm.parseAst(a, 'foo.wast', source);
+ var s = wabt.parseAst(a, 'foo.wast', source);
s.check();
var output = s.toBinary();
- var im = wasm.readInterpreterModule(a, wasm.LibcAllocator, output.buffer);
+ var im = wabt.readInterpreterModule(a, wabt.LibcAllocator, output.buffer);
if (true) {
print('disassemble:\n' + im.disassemble(0, 1000));
}
if (true) {
- var it = new wasm.InterpreterThread(a, im);
+ var it = new wabt.InterpreterThread(a, im);
print('running');
do {
print(im.tracePC(it).trimRight());
diff --git a/src/wasm-link.h b/src/wasm-link.h
index bee00614..90d0fc34 100644
--- a/src/wasm-link.h
+++ b/src/wasm-link.h
@@ -14,65 +14,65 @@
* limitations under the License.
*/
-#ifndef WASM_LINK_H_
-#define WASM_LINK_H_
+#ifndef WABT_LINK_H_
+#define WABT_LINK_H_
#include "binary.h"
#include "common.h"
#include "vector.h"
-#define WASM_LINK_MODULE_NAME "__extern"
+#define WABT_LINK_MODULE_NAME "__extern"
-struct WasmLinkerInputBinary;
+struct WabtLinkerInputBinary;
-typedef struct WasmFunctionImport {
- WasmStringSlice name;
+typedef struct WabtFunctionImport {
+ WabtStringSlice name;
uint32_t sig_index;
- WasmBool active; /* Is this import present in the linked binary */
- struct WasmLinkerInputBinary* foreign_binary;
+ WabtBool active; /* Is this import present in the linked binary */
+ struct WabtLinkerInputBinary* foreign_binary;
uint32_t foreign_index;
-} WasmFunctionImport;
-WASM_DEFINE_VECTOR(function_import, WasmFunctionImport);
+} WabtFunctionImport;
+WABT_DEFINE_VECTOR(function_import, WabtFunctionImport);
-typedef struct WasmGlobalImport {
- WasmStringSlice name;
- WasmType type;
- WasmBool mutable;
-} WasmGlobalImport;
-WASM_DEFINE_VECTOR(global_import, WasmGlobalImport);
+typedef struct WabtGlobalImport {
+ WabtStringSlice name;
+ WabtType type;
+ WabtBool mutable;
+} WabtGlobalImport;
+WABT_DEFINE_VECTOR(global_import, WabtGlobalImport);
-typedef struct WasmDataSegment {
+typedef struct WabtDataSegment {
uint32_t memory_index;
uint32_t offset;
const uint8_t* data;
size_t size;
-} WasmDataSegment;
-WASM_DEFINE_VECTOR(data_segment, WasmDataSegment);
+} WabtDataSegment;
+WABT_DEFINE_VECTOR(data_segment, WabtDataSegment);
-typedef struct WasmReloc {
- WasmRelocType type;
+typedef struct WabtReloc {
+ WabtRelocType type;
size_t offset;
-} WasmReloc;
-WASM_DEFINE_VECTOR(reloc, WasmReloc);
+} WabtReloc;
+WABT_DEFINE_VECTOR(reloc, WabtReloc);
-typedef struct WasmExport {
- WasmExternalKind kind;
- WasmStringSlice name;
+typedef struct WabtExport {
+ WabtExternalKind kind;
+ WabtStringSlice name;
uint32_t index;
-} WasmExport;
-WASM_DEFINE_VECTOR(export, WasmExport);
+} WabtExport;
+WABT_DEFINE_VECTOR(export, WabtExport);
-typedef struct WasmSectionDataCustom {
+typedef struct WabtSectionDataCustom {
/* Reference to string data stored in the containing InputBinary */
- WasmStringSlice name;
-} WasmSectionDataCustom;
+ WabtStringSlice name;
+} WabtSectionDataCustom;
-typedef struct WasmSection {
+typedef struct WabtSection {
/* The binary to which this section belongs */
- struct WasmLinkerInputBinary* binary;
- WasmRelocVector relocations; /* The relocations for this section */
+ struct WabtLinkerInputBinary* binary;
+ WabtRelocVector relocations; /* The relocations for this section */
- WasmBinarySection section_code;
+ WabtBinarySection section_code;
size_t size;
size_t offset;
@@ -84,35 +84,35 @@ typedef struct WasmSection {
union {
/* CUSTOM section data */
- WasmSectionDataCustom data_custom;
+ WabtSectionDataCustom data_custom;
/* DATA section data */
- WasmDataSegmentVector data_segments;
+ WabtDataSegmentVector data_segments;
/* MEMORY section data */
- WasmLimits memory_limits;
+ WabtLimits memory_limits;
};
/* The offset at which this section appears within the combined output
* section. */
size_t output_payload_offset;
-} WasmSection;
-WASM_DEFINE_VECTOR(section, WasmSection);
+} WabtSection;
+WABT_DEFINE_VECTOR(section, WabtSection);
-typedef WasmSection* WasmSectionPtr;
-WASM_DEFINE_VECTOR(section_ptr, WasmSectionPtr);
+typedef WabtSection* WabtSectionPtr;
+WABT_DEFINE_VECTOR(section_ptr, WabtSectionPtr);
-WASM_DEFINE_VECTOR(string_slice, WasmStringSlice);
+WABT_DEFINE_VECTOR(string_slice, WabtStringSlice);
-typedef struct WasmLinkerInputBinary {
+typedef struct WabtLinkerInputBinary {
const char* filename;
uint8_t* data;
size_t size;
- WasmSectionVector sections;
+ WabtSectionVector sections;
- WasmExportVector exports;
+ WabtExportVector exports;
- WasmFunctionImportVector function_imports;
+ WabtFunctionImportVector function_imports;
uint32_t active_function_imports;
- WasmGlobalImportVector global_imports;
+ WabtGlobalImportVector global_imports;
uint32_t active_global_imports;
uint32_t type_index_offset;
@@ -126,8 +126,8 @@ typedef struct WasmLinkerInputBinary {
uint32_t table_elem_count;
- WasmStringSliceVector debug_names;
-} WasmLinkerInputBinary;
-WASM_DEFINE_VECTOR(binary, WasmLinkerInputBinary);
+ WabtStringSliceVector debug_names;
+} WabtLinkerInputBinary;
+WABT_DEFINE_VECTOR(binary, WabtLinkerInputBinary);
-#endif /* WASM_LINK_H_ */
+#endif /* WABT_LINK_H_ */
diff --git a/src/writer.c b/src/writer.c
index 4aae2c1d..b76f6768 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -28,41 +28,41 @@
#define INITIAL_OUTPUT_BUFFER_CAPACITY (64 * 1024)
-static WasmResult write_data_to_file(size_t offset,
+static WabtResult write_data_to_file(size_t offset,
const void* data,
size_t size,
void* user_data) {
if (size == 0)
- return WASM_OK;
- WasmFileWriter* writer = user_data;
+ return WABT_OK;
+ WabtFileWriter* writer = user_data;
if (offset != writer->offset) {
if (fseek(writer->file, offset, SEEK_SET) != 0) {
ERROR("fseek offset=%" PRIzd " failed, errno=%d\n", size, errno);
- return WASM_ERROR;
+ return WABT_ERROR;
}
writer->offset = offset;
}
if (fwrite(data, size, 1, writer->file) != 1) {
ERROR("fwrite size=%" PRIzd " failed, errno=%d\n", size, errno);
- return WASM_ERROR;
+ return WABT_ERROR;
}
writer->offset += size;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult move_data_in_file(size_t dst_offset,
+static WabtResult move_data_in_file(size_t dst_offset,
size_t src_offset,
size_t size,
void* user_data) {
if (size == 0)
- return WASM_OK;
+ return WABT_OK;
/* TODO(binji): implement if needed. */
ERROR0("move_data_in_file not implemented!\n");
- return WASM_ERROR;
+ return WABT_ERROR;
}
-void wasm_init_file_writer_existing(WasmFileWriter* writer, FILE* file) {
- WASM_ZERO_MEMORY(*writer);
+void wabt_init_file_writer_existing(WabtFileWriter* writer, FILE* file) {
+ WABT_ZERO_MEMORY(*writer);
writer->file = file;
writer->offset = 0;
writer->base.user_data = writer;
@@ -70,62 +70,62 @@ void wasm_init_file_writer_existing(WasmFileWriter* writer, FILE* file) {
writer->base.move_data = move_data_in_file;
}
-WasmResult wasm_init_file_writer(WasmFileWriter* writer, const char* filename) {
+WabtResult wabt_init_file_writer(WabtFileWriter* writer, const char* filename) {
FILE* file = fopen(filename, "wb");
if (!file) {
ERROR("fopen name=\"%s\" failed, errno=%d\n", filename, errno);
- return WASM_ERROR;
+ return WABT_ERROR;
}
- wasm_init_file_writer_existing(writer, file);
- return WASM_OK;
+ wabt_init_file_writer_existing(writer, file);
+ return WABT_OK;
}
-void wasm_close_file_writer(WasmFileWriter* writer) {
+void wabt_close_file_writer(WabtFileWriter* writer) {
fclose(writer->file);
}
-void wasm_init_output_buffer(WasmAllocator* allocator,
- WasmOutputBuffer* buf,
+void wabt_init_output_buffer(WabtAllocator* allocator,
+ WabtOutputBuffer* buf,
size_t initial_capacity) {
assert(initial_capacity != 0);
buf->allocator = allocator;
- buf->start = wasm_alloc(allocator, initial_capacity, WASM_DEFAULT_ALIGN);
+ buf->start = wabt_alloc(allocator, initial_capacity, WABT_DEFAULT_ALIGN);
buf->size = 0;
buf->capacity = initial_capacity;
}
-static void ensure_output_buffer_capacity(WasmOutputBuffer* buf,
+static void ensure_output_buffer_capacity(WabtOutputBuffer* buf,
size_t ensure_capacity) {
if (ensure_capacity > buf->capacity) {
assert(buf->capacity != 0);
size_t new_capacity = buf->capacity * 2;
while (new_capacity < ensure_capacity)
new_capacity *= 2;
- buf->start = wasm_realloc(buf->allocator, buf->start, new_capacity,
- WASM_DEFAULT_ALIGN);
+ buf->start = wabt_realloc(buf->allocator, buf->start, new_capacity,
+ WABT_DEFAULT_ALIGN);
buf->capacity = new_capacity;
}
}
-static WasmResult write_data_to_output_buffer(size_t offset,
+static WabtResult write_data_to_output_buffer(size_t offset,
const void* data,
size_t size,
void* user_data) {
- WasmMemoryWriter* writer = user_data;
+ WabtMemoryWriter* writer = user_data;
size_t end = offset + size;
ensure_output_buffer_capacity(&writer->buf, end);
memcpy((void*)((size_t)writer->buf.start + offset), data, size);
if (end > writer->buf.size)
writer->buf.size = end;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult move_data_in_output_buffer(size_t dst_offset,
+static WabtResult move_data_in_output_buffer(size_t dst_offset,
size_t src_offset,
size_t size,
void* user_data) {
- WasmMemoryWriter* writer = user_data;
+ WabtMemoryWriter* writer = user_data;
size_t src_end = src_offset + size;
size_t dst_end = dst_offset + size;
size_t end = src_end > dst_end ? src_end : dst_end;
@@ -135,63 +135,63 @@ static WasmResult move_data_in_output_buffer(size_t dst_offset,
memmove(dst, src, size);
if (end > writer->buf.size)
writer->buf.size = end;
- return WASM_OK;
+ return WABT_OK;
}
-WasmResult wasm_init_mem_writer(WasmAllocator* allocator,
- WasmMemoryWriter* writer) {
- WASM_ZERO_MEMORY(*writer);
+WabtResult wabt_init_mem_writer(WabtAllocator* allocator,
+ WabtMemoryWriter* writer) {
+ WABT_ZERO_MEMORY(*writer);
writer->base.user_data = writer;
writer->base.write_data = write_data_to_output_buffer;
writer->base.move_data = move_data_in_output_buffer;
- wasm_init_output_buffer(allocator, &writer->buf,
+ wabt_init_output_buffer(allocator, &writer->buf,
INITIAL_OUTPUT_BUFFER_CAPACITY);
- return WASM_OK;
+ return WABT_OK;
}
-WasmResult wasm_init_mem_writer_existing(WasmMemoryWriter* writer,
- WasmOutputBuffer* buf) {
- WASM_ZERO_MEMORY(*writer);
+WabtResult wabt_init_mem_writer_existing(WabtMemoryWriter* writer,
+ WabtOutputBuffer* buf) {
+ WABT_ZERO_MEMORY(*writer);
writer->base.user_data = writer;
writer->base.write_data = write_data_to_output_buffer;
writer->base.move_data = move_data_in_output_buffer;
writer->buf = *buf;
/* Clear buffer, since ownership has passed to the writer. */
- WASM_ZERO_MEMORY(*buf);
- return WASM_OK;
+ WABT_ZERO_MEMORY(*buf);
+ return WABT_OK;
}
-void wasm_steal_mem_writer_output_buffer(WasmMemoryWriter* writer,
- WasmOutputBuffer* out_buf) {
+void wabt_steal_mem_writer_output_buffer(WabtMemoryWriter* writer,
+ WabtOutputBuffer* out_buf) {
*out_buf= writer->buf;
writer->buf.start = NULL;
writer->buf.size = 0;
writer->buf.capacity = 0;
}
-void wasm_close_mem_writer(WasmMemoryWriter* writer) {
- wasm_destroy_output_buffer(&writer->buf);
+void wabt_close_mem_writer(WabtMemoryWriter* writer) {
+ wabt_destroy_output_buffer(&writer->buf);
}
-WasmResult wasm_write_output_buffer_to_file(WasmOutputBuffer* buf,
+WabtResult wabt_write_output_buffer_to_file(WabtOutputBuffer* buf,
const char* filename) {
FILE* file = fopen(filename, "wb");
if (!file) {
ERROR("unable to open %s for writing\n", filename);
- return WASM_ERROR;
+ return WABT_ERROR;
}
ssize_t bytes = fwrite(buf->start, 1, buf->size, file);
if (bytes < 0 || (size_t)bytes != buf->size) {
ERROR("failed to write %" PRIzd " bytes to %s\n", buf->size, filename);
- return WASM_ERROR;
+ return WABT_ERROR;
}
fclose(file);
- return WASM_OK;
+ return WABT_OK;
}
-void wasm_destroy_output_buffer(WasmOutputBuffer* buf) {
+void wabt_destroy_output_buffer(WabtOutputBuffer* buf) {
if (buf->allocator)
- wasm_free(buf->allocator, buf->start);
+ wabt_free(buf->allocator, buf->start);
}
diff --git a/src/writer.h b/src/writer.h
index ff6efde4..42e4e37d 100644
--- a/src/writer.h
+++ b/src/writer.h
@@ -14,69 +14,69 @@
* limitations under the License.
*/
-#ifndef WASM_WRITER_H_
-#define WASM_WRITER_H_
+#ifndef WABT_WRITER_H_
+#define WABT_WRITER_H_
#include <stdio.h>
#include "allocator.h"
#include "common.h"
-typedef struct WasmWriter {
+typedef struct WabtWriter {
void* user_data;
- WasmResult (*write_data)(size_t offset,
+ WabtResult (*write_data)(size_t offset,
const void* data,
size_t size,
void* user_data);
- WasmResult (*move_data)(size_t dst_offset,
+ WabtResult (*move_data)(size_t dst_offset,
size_t src_offset,
size_t size,
void* user_data);
-} WasmWriter;
+} WabtWriter;
-typedef struct WasmOutputBuffer {
- WasmAllocator* allocator;
+typedef struct WabtOutputBuffer {
+ WabtAllocator* allocator;
void* start;
size_t size;
size_t capacity;
-} WasmOutputBuffer;
+} WabtOutputBuffer;
-typedef struct WasmMemoryWriter {
- WasmWriter base;
- WasmOutputBuffer buf;
-} WasmMemoryWriter;
+typedef struct WabtMemoryWriter {
+ WabtWriter base;
+ WabtOutputBuffer buf;
+} WabtMemoryWriter;
-typedef struct WasmFileWriter {
- WasmWriter base;
+typedef struct WabtFileWriter {
+ WabtWriter base;
FILE* file;
size_t offset;
-} WasmFileWriter;
+} WabtFileWriter;
-WASM_EXTERN_C_BEGIN
+WABT_EXTERN_C_BEGIN
-/* WasmFileWriter */
-WasmResult wasm_init_file_writer(WasmFileWriter* writer, const char* filename);
-void wasm_init_file_writer_existing(WasmFileWriter* writer, FILE* file);
-void wasm_close_file_writer(WasmFileWriter* writer);
+/* WabtFileWriter */
+WabtResult wabt_init_file_writer(WabtFileWriter* writer, const char* filename);
+void wabt_init_file_writer_existing(WabtFileWriter* writer, FILE* file);
+void wabt_close_file_writer(WabtFileWriter* writer);
-/* WasmMemoryWriter */
-WasmResult wasm_init_mem_writer(WasmAllocator* allocator,
- WasmMemoryWriter* writer);
+/* WabtMemoryWriter */
+WabtResult wabt_init_mem_writer(WabtAllocator* allocator,
+ WabtMemoryWriter* writer);
/* Passes ownership of the buffer to writer */
-WasmResult wasm_init_mem_writer_existing(WasmMemoryWriter* writer,
- WasmOutputBuffer* buf);
-void wasm_steal_mem_writer_output_buffer(WasmMemoryWriter* writer,
- WasmOutputBuffer* out_buf);
-void wasm_close_mem_writer(WasmMemoryWriter* writer);
+WabtResult wabt_init_mem_writer_existing(WabtMemoryWriter* writer,
+ WabtOutputBuffer* buf);
+void wabt_steal_mem_writer_output_buffer(WabtMemoryWriter* writer,
+ WabtOutputBuffer* out_buf);
+void wabt_close_mem_writer(WabtMemoryWriter* writer);
-/* WasmOutputBuffer */
-void wasm_init_output_buffer(WasmAllocator* allocator,
- WasmOutputBuffer* buf,
+/* WabtOutputBuffer */
+void wabt_init_output_buffer(WabtAllocator* allocator,
+ WabtOutputBuffer* buf,
size_t initial_capacity);
-WasmResult wasm_write_output_buffer_to_file(WasmOutputBuffer* buf,
+WabtResult wabt_write_output_buffer_to_file(WabtOutputBuffer* buf,
const char* filename);
-void wasm_destroy_output_buffer(WasmOutputBuffer* buf);
+void wabt_destroy_output_buffer(WabtOutputBuffer* buf);
-WASM_EXTERN_C_END
+WABT_EXTERN_C_END
-#endif /* WASM_WRITER_H_ */
+#endif /* WABT_WRITER_H_ */