Fixing dynamic initializer. · kevcadieux/ChakraCore@9e6cb62 (original) (raw)
`@@ -14,6 +14,12 @@
`
14
14
` * limitations under the License.
`
15
15
`*/
`
16
16
``
``
17
`+
/**************************************************************************
`
``
18
`+
- MODIFICATION NOTICE:
`
``
19
`+
- This file has been modified by Kevin Cadieux (Microsoft) for educational
`
``
20
`+
- purposes and is different from the original version.
`
``
21
`+
- ***********************************************************************/
`
``
22
+
17
23
`#ifndef WABT_OPCODE_H_
`
18
24
`#define WABT_OPCODE_H_
`
19
25
``
`@@ -27,6 +33,12 @@ namespace wabt {
`
27
33
``
28
34
`class Features;
`
29
35
``
``
36
`+
constexpr uint32_t PrefixCode(uint8_t prefix, uint32_t code) {
`
``
37
`+
// For now, 8 bits is enough for all codes.
`
``
38
`+
assert(code < 0x100);
`
``
39
`+
return (prefix << 8) | code;
`
``
40
`+
}
`
``
41
+
30
42
`struct Opcode {
`
31
43
`// Opcode enumerations.
`
32
44
`//
`
`@@ -103,12 +115,6 @@ struct Opcode {
`
103
115
`uint32_t prefix_code; // See PrefixCode below. Used for fast lookup.
`
104
116
` };
`
105
117
``
106
``
`-
static uint32_t PrefixCode(uint8_t prefix, uint32_t code) {
`
107
``
`-
// For now, 8 bits is enough for all codes.
`
108
``
`-
assert(code < 0x100);
`
109
``
`-
return (prefix << 8) | code;
`
110
``
`-
}
`
111
``
-
112
118
`// The Opcode struct only stores an enumeration (Opcode::Enum) of all valid
`
113
119
`// opcodes, densely packed. We want to be able to store invalid opcodes as
`
114
120
`// well, for display to the user. To encode these, we use PrefixCode() to
`
`@@ -136,7 +142,17 @@ struct Opcode {
`
136
142
` }
`
137
143
``
138
144
` Info GetInfo() const;
`
139
``
`-
static Info infos_[];
`
``
145
`+
static constexpr Info infos_[] = {
`
``
146
`+
#define WABT_OPCODE(rtype, type1, type2, type3, mem_size, prefix, code, Name, \
`
``
147
`+
text) \
`
``
148
`+
{text, Type::rtype, Type::type1, \
`
``
149
`+
Type::type2, Type::type3, mem_size, \
`
``
150
`+
prefix, code, PrefixCode(prefix, code)},
`
``
151
`+
#include "src/opcode.def"
`
``
152
`+
#undef WABT_OPCODE
`
``
153
+
``
154
`+
{"", Type::Void, Type::Void, Type::Void, Type::Void, 0, 0, 0, 0},
`
``
155
`+
};
`
140
156
``
141
157
` Enum enum_;
`
142
158
`};
`