@@ -48,6 +48,7 @@ Function* copyFunction(Function* func,
4848 std::optional<std::vector<Index>> fileIndexMap) {
4949 auto ret = std::make_unique<Function>();
5050 ret->name = newName.is () ? newName : func->name ;
51+ ret->hasExplicitName = func->hasExplicitName && !newName.is ();
5152 ret->type = func->type ;
5253 ret->vars = func->vars ;
5354 ret->localNames = func->localNames ;
@@ -77,6 +78,7 @@ Function* copyFunction(Function* func,
7778Global* copyGlobal (Global* global, Module& out) {
7879 auto * ret = new Global ();
7980 ret->name = global->name ;
81+ ret->hasExplicitName = global->hasExplicitName ;
8082 ret->type = global->type ;
8183 ret->mutable_ = global->mutable_ ;
8284 ret->module = global->module ;
@@ -93,6 +95,7 @@ Global* copyGlobal(Global* global, Module& out) {
9395Tag* copyTag (Tag* tag, Module& out) {
9496 auto * ret = new Tag ();
9597 ret->name = tag->name ;
98+ ret->hasExplicitName = tag->hasExplicitName ;
9699 ret->sig = tag->sig ;
97100 ret->module = tag->module ;
98101 ret->base = tag->base ;
@@ -209,6 +212,12 @@ void copyModuleItems(const Module& in, Module& out) {
209212 for (auto & curr : in.dataSegments ) {
210213 copyDataSegment (curr.get (), out);
211214 }
215+
216+ for (auto & [type, names] : in.typeNames ) {
217+ if (!out.typeNames .count (type)) {
218+ out.typeNames [type] = names;
219+ }
220+ }
212221}
213222
214223void copyModule (const Module& in, Module& out) {
@@ -222,7 +231,6 @@ void copyModule(const Module& in, Module& out) {
222231 out.customSections = in.customSections ;
223232 out.debugInfoFileNames = in.debugInfoFileNames ;
224233 out.features = in.features ;
225- out.typeNames = in.typeNames ;
226234}
227235
228236void clearModule (Module& wasm) {
0 commit comments