-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(vector<EntryPoint>::iterator i=entry_points.begin(); i!=entry_points.end(); ++i)
- for(vector<const Variable *>::iterator j=i->globals.begin(); j!=i->globals.end(); ++j)
- *j = &variables[*j-&other.variables.front()];
-
- for(vector<Variable>::iterator i=variables.begin(); i!=variables.end(); ++i)
- if(i->struct_type)
- i->struct_type = &structs[i->struct_type-&other.structs.front()];
-
- for(vector<Structure>::iterator i=structs.begin(); i!=structs.end(); ++i)
- for(vector<StructMember>::iterator j=i->members.begin(); j!=i->members.end(); ++j)
- if(j->struct_type)
- j->struct_type = &structs[j->struct_type-&other.structs.front()];
-}
-