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

Function ast_structureName

src/parser/parser_impl.cpp:233–275  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

231 }
232
233 Structure * ast_structureName ( yyscan_t scanner, bool sealed, string * name, const LineInfo & atName,
234 string * parent, const LineInfo & atParent ) {
235 das_checkName(scanner,*name,atName);
236 StructurePtr pStruct = nullptr;
237 if ( parent ) {
238 auto structs = yyextra->g_Program->findStructure(*parent);
239 if ( structs.size()==1 ) {
240 pStruct = structs.back()->clone();
241 pStruct->name = *name;
242 pStruct->parent = structs.back();
243 if ( pStruct->parent->sealed ) {
244 das_yyerror(scanner,"can't derive from a sealed class or structure "+*parent,atParent,
245 CompilationError::cant_structure);
246 }
247 pStruct->annotations.clear();
248 pStruct->genCtor = false;
249 pStruct->macroInterface = pStruct->parent && pStruct->parent->macroInterface;
250
251 } else if ( structs.size()==0 ) {
252 das_yyerror(scanner,"parent structure not found " + *parent,atParent,
253 CompilationError::lookup_structure);
254 } else {
255 string candidates = yyextra->g_Program->describeCandidates(structs);
256 das_yyerror(scanner,"too many options for " + *parent + "\n" + candidates,atParent,
257 CompilationError::ambiguous_structure);
258 }
259 delete parent;
260 }
261 if ( !pStruct ) {
262 pStruct = new Structure(*name);
263 }
264 pStruct->sealed = sealed;
265 if ( !yyextra->g_Program->addStructure(pStruct) ) {
266 das_yyerror(scanner,"structure is already defined "+*name,atName,
267 CompilationError::already_declared_structure);
268 delete name;
269 return nullptr;
270 } else {
271 yyextra->g_thisStructure = pStruct;
272 delete name;
273 return pStruct;
274 }
275 }
276
277 bool ast_structureAlias ( yyscan_t scanner, string * name, TypeDecl * typeDecl, const LineInfo & atName ) {
278 if (!typeDecl->alias.empty()) {

Callers 3

yyparseFunction · 0.85
yyparseFunction · 0.85
yyparseFunction · 0.85

Calls 7

das_checkNameFunction · 0.85
das_yyerrorFunction · 0.70
findStructureMethod · 0.45
sizeMethod · 0.45
cloneMethod · 0.45
clearMethod · 0.45
addStructureMethod · 0.45

Tested by

no test coverage detected