@@ -43,6 +43,7 @@ struct ValidateOptions {
43
43
class SharedValidator {
44
44
public:
45
45
WABT_DISALLOW_COPY_AND_ASSIGN (SharedValidator);
46
+ using FuncType = TypeChecker::FuncType;
46
47
SharedValidator (Errors*, const ValidateOptions& options);
47
48
48
49
// TODO: Move into SharedValidator?
@@ -72,7 +73,6 @@ class SharedValidator {
72
73
Index type_index);
73
74
Result OnStructType (const Location&, Index field_count, TypeMut* fields);
74
75
Result OnArrayType (const Location&, TypeMut field);
75
- Result EndTypeSection ();
76
76
77
77
Result OnFunction (const Location&, Var sig_var);
78
78
Result OnTable (const Location&, Type elem_type, const Limits&);
@@ -141,7 +141,7 @@ class SharedValidator {
141
141
Result EndBrTable (const Location&);
142
142
Result OnCall (const Location&, Var func_var);
143
143
Result OnCallIndirect (const Location&, Var sig_var, Var table_var);
144
- Result OnCallRef (const Location&, Index* function_type_index );
144
+ Result OnCallRef (const Location&, Var function_type_var );
145
145
Result OnCatch (const Location&, Var tag_var, bool is_catch_all);
146
146
Result OnCompare (const Location&, Opcode);
147
147
Result OnConst (const Location&, Type);
@@ -178,7 +178,7 @@ class SharedValidator {
178
178
Result OnNop (const Location&);
179
179
Result OnRefFunc (const Location&, Var func_var);
180
180
Result OnRefIsNull (const Location&);
181
- Result OnRefNull (const Location&, Type type );
181
+ Result OnRefNull (const Location&, Var func_type_var );
182
182
Result OnRethrow (const Location&, Var depth);
183
183
Result OnReturnCall (const Location&, Var func_var);
184
184
Result OnReturnCallIndirect (const Location&, Var sig_var, Var table_var);
@@ -221,18 +221,6 @@ class SharedValidator {
221
221
Result OnUnreachable (const Location&);
222
222
223
223
private:
224
- struct FuncType {
225
- FuncType () = default ;
226
- FuncType (const TypeVector& params,
227
- const TypeVector& results,
228
- Index type_index)
229
- : params(params), results(results), type_index(type_index) {}
230
-
231
- TypeVector params;
232
- TypeVector results;
233
- Index type_index;
234
- };
235
-
236
224
struct StructType {
237
225
StructType () = default ;
238
226
StructType (const TypeMutVector& fields) : fields(fields) {}
@@ -289,6 +277,11 @@ class SharedValidator {
289
277
Index end;
290
278
};
291
279
280
+ struct LocalReferenceMap {
281
+ Type type;
282
+ Index bit_index;
283
+ };
284
+
292
285
bool ValidInitOpcode (Opcode opcode) const ;
293
286
Result CheckInstr (Opcode opcode, const Location& loc);
294
287
Result CheckType (const Location&,
@@ -336,6 +329,10 @@ class SharedValidator {
336
329
337
330
TypeVector ToTypeVector (Index count, const Type* types);
338
331
332
+ void SaveLocalRefs ();
333
+ void RestoreLocalRefs (Result result);
334
+ void IgnoreLocalRefs ();
335
+
339
336
ValidateOptions options_;
340
337
Errors* errors_;
341
338
TypeChecker typechecker_; // TODO: Move into SharedValidator.
@@ -361,6 +358,8 @@ class SharedValidator {
361
358
// Includes parameters, since this is only used for validating
362
359
// local.{get,set,tee} instructions.
363
360
std::vector<LocalDecl> locals_;
361
+ std::map<Index, LocalReferenceMap> local_refs_map_;
362
+ std::vector<bool > local_ref_is_set_;
364
363
365
364
std::set<std::string> export_names_; // Used to check for duplicates.
366
365
std::set<Index> declared_funcs_; // TODO: optimize?
0 commit comments