1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#ifndef WASM_INTERNAL_H
#define WASM_INTERNAL_H
#include "wasm.h"
#define FATAL(...) fprintf(stderr, __VA_ARGS__), exit(1)
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
#define STATIC_ASSERT__(x, c) typedef char static_assert_##c[x ? 1 : -1]
#define STATIC_ASSERT_(x, c) STATIC_ASSERT__(x, c)
#define STATIC_ASSERT(x) STATIC_ASSERT_(x, __COUNTER__)
typedef union WasmToken {
/* terminals */
WasmStringSlice text;
WasmType type;
WasmUnaryOp unary;
WasmBinaryOp binary;
WasmCompareOp compare;
WasmConvertOp convert;
WasmCastOp cast;
WasmMemOp mem;
/* non-terminals */
uint32_t u32;
uint64_t u64;
WasmTypeVector types;
WasmVar var;
WasmVarVector vars;
WasmExprPtr expr;
WasmExprPtrVector exprs;
WasmTarget target;
WasmTargetVector targets;
WasmCase case_;
WasmCaseVector cases;
WasmTypeBindings type_bindings;
WasmFunc func;
WasmSegment segment;
WasmSegmentVector segments;
WasmMemory memory;
WasmFuncSignature func_sig;
WasmFuncType func_type;
WasmImport import;
WasmExport export;
WasmModuleFieldVector module_fields;
WasmModule module;
WasmConst const_;
WasmConstVector consts;
WasmCommand command;
WasmCommandVector commands;
WasmScript script;
} WasmToken;
#define WASM_STYPE WasmToken
#define WASM_LTYPE WasmLocation
#define YYSTYPE WASM_STYPE
#define YYLTYPE WASM_LTYPE
int wasm_lex(WasmToken*, WasmLocation*, WasmScanner, WasmParser*);
void wasm_print_memory(const void* start,
size_t size,
size_t offset,
int print_chars,
const char* desc);
#endif /* WASM_INTERNAL_H */
|