forked from wader/fq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmappers.go
97 lines (89 loc) · 2.27 KB
/
mappers.go
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package wasm
import (
"github.com/wader/fq/pkg/scalar"
)
var sectionIDToSym = scalar.UintMapSymStr{
sectionIDCustom: "custom_section",
sectionIDType: "type_section",
sectionIDImport: "import_section",
sectionIDFunction: "function_section",
sectionIDTable: "table_section",
sectionIDMemory: "memory_section",
sectionIDGlobal: "global_section",
sectionIDExport: "export_section",
sectionIDStart: "start_section",
sectionIDElement: "element_section",
sectionIDCode: "code_section",
sectionIDData: "data_section",
sectionIDDataCount: "data_count_section",
}
// A map to convert valtypes to symbols.
//
// valtype ::= t:numtype => t
// | t:vectype => t
// | t:reftype => t
//
// numtype ::= 0x7F => i32
// | 0x7E => i64
// | 0x7D => f32
// | 0x7C => f64
//
// vectype ::= 0x7B => v128
//
// reftype ::= 0x70 => funcref
// | 0x6F => externref
var valtypeToSymMapper = scalar.UintMapSymStr{
0x7f: "i32",
0x7e: "i64",
0x7d: "f32",
0x7c: "f64",
0x7b: "v128",
0x70: "funcref",
0x6f: "externref",
}
// A map to convert tags of importdesc to symbols.
//
// importdesc ::= 0x00 x:typeidx => func x
// | 0x01 tt:tabletype => table tt
// | 0x02 mt:memtype => mem mt
// | 0x03 gt:globaltype => global gt
var importdescTagToSym = scalar.UintMapSymStr{
0x00: "func",
0x01: "table",
0x02: "mem",
0x03: "global",
}
// A map to convert tags of exportdesc to symbols.
//
// exportdesc ::= 0x00 x:funcidx => func x
// | 0x01 x:tableidx => table x
// | 0x02 x:memidx => mem x
// | 0x03 x:globalidx => global x
var exportdescTagToSym = scalar.UintMapSymStr{
0x00: "funcidx",
0x01: "tableidx",
0x02: "memidx",
0x03: "globalidx",
}
// A map to convert reftypes to symbols.
//
// reftype ::= 0x70 => funcref
// | 0x6F => externref
var reftypeTagToSym = scalar.UintMapSymStr{
0x70: "funcref",
0x6f: "externref",
}
// A map to convert mut to symbols.
//
// mut ::= 0x00 => const
// | 0x01 => var
var mutToSym = scalar.UintMapSymStr{
0x00: "const",
0x01: "var",
}
// A map to convert elemkind to symbols.
//
// elemkind ::= 0x00 => funcref
var elemkindTagToSym = scalar.UintMapSymStr{
0x00: "funcref",
}