| 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()) { |
no test coverage detected