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

Method GetType

IDEHelper/Compiler/BfCompiler.cpp:9657–9710  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9655}
9656
9657BfType* BfCompiler::GetType(const StringImpl& fullTypeName)
9658{
9659 AutoCrit autoCrit(mSystem->mSystemLock);
9660
9661 BfPassInstance passInstance(mSystem);
9662
9663 BfProject* activeProject = NULL;
9664
9665 String typeName = fullTypeName;
9666 int colonPos = (int)typeName.LastIndexOf(':');
9667 if (colonPos != -1)
9668 {
9669 int startProjName = (int)typeName.LastIndexOf(':', colonPos - 1) + 1;
9670 activeProject = mSystem->GetProject(typeName.Substring(startProjName, colonPos - startProjName));
9671 typeName.Remove(0, colonPos + 1);
9672 }
9673
9674 BfTypeState typeState;
9675 typeState.mPrevState = mContext->mCurTypeState;
9676 typeState.mActiveProject = activeProject;
9677 SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
9678
9679 BfParser parser(mSystem);
9680 parser.SetSource(typeName.c_str(), (int)typeName.length());
9681 parser.Parse(&passInstance);
9682
9683 BfReducer reducer;
9684 reducer.mAlloc = parser.mAlloc;
9685 reducer.mPassInstance = &passInstance;
9686
9687 if (parser.mRootNode->mChildArr.mSize == 0)
9688 return NULL;
9689
9690 auto firstNode = parser.mRootNode->mChildArr[0];
9691 auto endIdx = parser.mRootNode->mSrcEnd;
9692 reducer.mVisitorPos = BfReducer::BfVisitorPos(parser.mRootNode);
9693
9694 reducer.mVisitorPos.MoveNext();
9695 auto typeRef = reducer.CreateTypeRef(firstNode);
9696 if (typeRef == NULL)
9697 return NULL;
9698
9699 BfResolvePassData resolvePass;
9700 SetAndRestoreValue<bool> prevIgnoreError(mContext->mScratchModule->mIgnoreErrors, true);
9701 SetAndRestoreValue<bool> prevIgnoreWarnings(mContext->mScratchModule->mIgnoreWarnings, true);
9702 SetAndRestoreValue<BfResolvePassData*> prevResolvePass(mResolvePassData, &resolvePass);
9703
9704 auto type = mContext->mScratchModule->ResolveTypeRef(typeRef, BfPopulateType_Identity, (BfResolveTypeRefFlags)(
9705 BfResolveTypeRefFlag_NoCreate | BfResolveTypeRefFlag_AllowUnboundGeneric | BfResolveTypeRefFlag_AllowGlobalContainer));
9706 if (type != NULL)
9707 return type;
9708
9709 return NULL;
9710}
9711
9712int BfCompiler::GetEmitSource(const StringImpl& fileName, StringImpl* outBuffer)
9713{

Callers 7

FixClassVDataMethod · 0.45
GetOperandMethod · 0.45
BuildMethod · 0.45
WriteConstantMethod · 0.45

Calls 12

BfVisitorPosClass · 0.85
GetProjectMethod · 0.80
SubstringMethod · 0.80
CreateTypeRefMethod · 0.80
LastIndexOfMethod · 0.45
RemoveMethod · 0.45
SetSourceMethod · 0.45
c_strMethod · 0.45
lengthMethod · 0.45
ParseMethod · 0.45
MoveNextMethod · 0.45
ResolveTypeRefMethod · 0.45

Tested by

no test coverage detected