@@ -1096,6 +1096,8 @@ struct ParseDefsCtx : TypeParserCtx<ParseDefsCtx> {
1096
1096
1097
1097
const std::vector<HeapType>& types;
1098
1098
const std::unordered_map<Index, HeapType>& implicitTypes;
1099
+ const std::unordered_map<HeapType, std::unordered_map<Name, Index>>&
1100
+ typeNames;
1099
1101
const std::unordered_map<Index, Index>& implicitElemIndices;
1100
1102
1101
1103
// The index of the current module element.
@@ -1113,14 +1115,17 @@ struct ParseDefsCtx : TypeParserCtx<ParseDefsCtx> {
1113
1115
return Ok{};
1114
1116
}
1115
1117
1116
- ParseDefsCtx (std::string_view in,
1117
- Module& wasm,
1118
- const std::vector<HeapType>& types,
1119
- const std::unordered_map<Index, HeapType>& implicitTypes,
1120
- const std::unordered_map<Index, Index>& implicitElemIndices,
1121
- const IndexMap& typeIndices)
1118
+ ParseDefsCtx (
1119
+ std::string_view in,
1120
+ Module& wasm,
1121
+ const std::vector<HeapType>& types,
1122
+ const std::unordered_map<Index, HeapType>& implicitTypes,
1123
+ const std::unordered_map<HeapType, std::unordered_map<Name, Index>>&
1124
+ typeNames,
1125
+ const std::unordered_map<Index, Index>& implicitElemIndices,
1126
+ const IndexMap& typeIndices)
1122
1127
: TypeParserCtx(typeIndices), in(in), wasm(wasm), builder(wasm),
1123
- types (types), implicitTypes(implicitTypes),
1128
+ types (types), implicitTypes(implicitTypes), typeNames(typeNames),
1124
1129
implicitElemIndices(implicitElemIndices), irBuilder(wasm) {}
1125
1130
1126
1131
template <typename T> Result<T> withLoc (Index pos, Result<T> res) {
@@ -1192,8 +1197,13 @@ struct ParseDefsCtx : TypeParserCtx<ParseDefsCtx> {
1192
1197
}
1193
1198
1194
1199
Result<Index> getFieldFromName (HeapType type, Name name) {
1195
- // TODO: Field names
1196
- return in.err (" symbolic field names note yet supported" );
1200
+ if (auto typeIt = typeNames.find (type); typeIt != typeNames.end ()) {
1201
+ const auto & fieldIdxs = typeIt->second ;
1202
+ if (auto fieldIt = fieldIdxs.find (name); fieldIt != fieldIdxs.end ()) {
1203
+ return fieldIt->second ;
1204
+ }
1205
+ }
1206
+ return in.err (" unrecognized field name" );
1197
1207
}
1198
1208
1199
1209
Result<Index> getLocalFromIdx (uint32_t idx) {
0 commit comments