MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / patch

Method patch

src/builtin/module_builtin_ast_serialize.cpp:113–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111 }
112
113 void AstSerializer::patch () {
114 patchRefs(functionRefs, smartFunctionMap);
115 patchRefs(variableRefs, smartVariableMap);
116 patchRefs(structureRefs, smartStructureMap);
117 patchRefs(enumerationRefs, smartEnumerationMap);
118 // finally, patch block refs (differenct container)
119 for ( auto & p : blockRefs ) {
120 auto it = exprBlockMap.find(p.second);
121 if ( it == exprBlockMap.end() ) {
122 throw_formatted_error("ast serializer block ref not found");
123 } else {
124 *p.first = it->second;
125 }
126 }
127 blockRefs.clear();
128
129 for ( auto & [field, mod, name, fieldname] : fieldRefs ) {
130 auto struct_ = moduleLibrary->findStructure(name, mod);
131 if ( struct_.size() == 0 ) {
132 throw_formatted_error("expected to find structure '%s'", name.c_str());
133 } else if ( struct_.size() > 1 ) {
134 throw_formatted_error("too many candidates for structure '%s'", name.c_str());
135 }
136 // set the missing field field
137 *field = struct_.front()->findFieldRef(fieldname);
138 }
139 fieldRefs.clear();
140 }
141
142 void AstSerializer::write ( const void * data, size_t size ) {
143 buffer->write(data, size);

Callers 2

patchAnnotationsMethod · 0.45
serializeMethod · 0.45

Calls 9

patchRefsFunction · 0.85
throw_formatted_errorFunction · 0.85
findFieldRefMethod · 0.80
findMethod · 0.45
endMethod · 0.45
clearMethod · 0.45
findStructureMethod · 0.45
sizeMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected