MCPcopy Create free account
hub / github.com/beefytech/Beef / InitAnonymousType

Method InitAnonymousType

IDEHelper/Compiler/BfReducer.cpp:8340–8379  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8338}
8339
8340void 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
8381bool BfReducer::CheckInlineTypeRefAttribute(BfAstNode* typeRef, BfAttributeDirective* attributes)
8382{

Callers

nothing calls this directly

Calls 9

FailFunction · 0.85
GetParserDataMethod · 0.80
GetUniqueIdMethod · 0.80
GetParserMethod · 0.80
ToParserMethod · 0.45
lengthMethod · 0.45
AllocBytesMethod · 0.45
c_strMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected