| 8338 | } |
| 8339 | |
| 8340 | void BfReducer::InitAnonymousType(BfTypeDeclaration* typeDecl) |
| 8341 | { |
| 8342 | int blockId = 0; |
| 8343 | if (auto block = BfNodeDynCast<BfBlock>(typeDecl->mDefineNode)) |
| 8344 | { |
| 8345 | blockId = block->mParserBlockId; |
| 8346 | } |
| 8347 | else |
| 8348 | { |
| 8349 | auto parser = mSource->ToParser(); |
| 8350 | if (parser != NULL) |
| 8351 | blockId = parser->mCurBlockId + typeDecl->mSrcStart; |
| 8352 | } |
| 8353 | |
| 8354 | String name; |
| 8355 | auto parserData = typeDecl->GetParserData(); |
| 8356 | name = "_Anon_"; |
| 8357 | |
| 8358 | auto parseFileData = parserData->mParseFileData; |
| 8359 | int uniqueId = parseFileData->GetUniqueId(blockId); |
| 8360 | name += StrFormat("%d", uniqueId); |
| 8361 | |
| 8362 | int len = (int)name.length() + 1; |
| 8363 | typeDecl->mAnonymousName = (char*)mAlloc->AllocBytes(len); |
| 8364 | memcpy(typeDecl->mAnonymousName, name.c_str(), len); |
| 8365 | |
| 8366 | auto parser = typeDecl->GetParser(); |
| 8367 | if ((parser != NULL) && (parser->mIsEmitted)) |
| 8368 | { |
| 8369 | Fail("Type declarations are not allowed in emitted code", typeDecl); |
| 8370 | } |
| 8371 | else if (mCurTypeState != NULL) |
| 8372 | { |
| 8373 | mCurTypeState->mAnonymousTypeDecls.Add(typeDecl); |
| 8374 | } |
| 8375 | else |
| 8376 | { |
| 8377 | Fail("Invalid use of anonymous type declaration", typeDecl); |
| 8378 | } |
| 8379 | } |
| 8380 | |
| 8381 | bool BfReducer::CheckInlineTypeRefAttribute(BfAstNode* typeRef, BfAttributeDirective* attributes) |
| 8382 | { |
nothing calls this directly
no test coverage detected