-SpirVModule::SpirVModule(const SpirVModule &other):
- code(other.code),
- entry_points(other.entry_points),
- structs(other.structs),
- variables(other.variables)
-{
- remap_pointers_from(other);
-}
-
-SpirVModule &SpirVModule::operator=(const SpirVModule &other)
-{
- code = other.code;
- entry_points = other.entry_points;
- structs = other.structs;
- variables = other.variables;
- remap_pointers_from(other);
- return *this;
-}
-
-void SpirVModule::remap_pointers_from(const SpirVModule &other)
-{
- for(EntryPoint &e: entry_points)
- for(const Variable *&v: e.globals)
- v = &variables[v-&other.variables.front()];
-
- for(Variable &v: variables)
- if(v.struct_type)
- v.struct_type = &structs[v.struct_type-&other.structs.front()];
-
- for(Structure &s: structs)
- for(StructMember &m: s.members)
- if(m.struct_type)
- m.struct_type = &structs[m.struct_type-&other.structs.front()];
-}
-