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

Method CEEmitParse

IDEHelper/Compiler/BfModuleTypeUtils.cpp:2217–2423  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2215}
2216
2217BfCEParseContext BfModule::CEEmitParse(BfTypeInstance* typeInstance, BfTypeDef* declaringType, const StringImpl& src, BfAstNode* refNode, BfCeTypeEmitSourceKind emitSourceKind)
2218{
2219 if (mCompiler->mResolvePassData != NULL)
2220 mCompiler->mResolvePassData->mHadEmits = true;
2221
2222 BfCEParseContext ceParseContext;
2223 ceParseContext.mFailIdx = mCompiler->mPassInstance->mFailedIdx;
2224 ceParseContext.mWarnIdx = mCompiler->mPassInstance->mWarnIdx;
2225
2226 if (typeInstance->mTypeDef->mEmitParent == NULL)
2227 {
2228 if (typeInstance->mTypeDef->mNextRevision != NULL)
2229 {
2230 InternalError("CEEmitParse preconditions failed");
2231 return ceParseContext;
2232 }
2233 }
2234
2235 bool createdParser = false;
2236 int startSrcIdx = 0;
2237
2238 BfParser* emitParser = NULL;
2239
2240 int64 emitSourceMapKey = ((int64)declaringType->mPartialIdx << 32) | refNode->mSrcStart;
2241 if (typeInstance->mCeTypeInfo == NULL)
2242 typeInstance->mCeTypeInfo = new BfCeTypeInfo();
2243 auto ceTypeInfo = typeInstance->mCeTypeInfo;
2244 if (ceTypeInfo->mNext != NULL)
2245 ceTypeInfo = ceTypeInfo->mNext;
2246 BfCeTypeEmitSource* ceEmitSource = NULL;
2247 if ((mCurMethodState != NULL) && (mCurMethodState->mClosureState != NULL) && (mCurMethodState->mClosureState->mCapturing))
2248 {
2249 // Don't create emit sources when we're in a capture phase
2250 }
2251 else
2252 {
2253 auto refParser = refNode->GetParser();
2254 if ((refParser != NULL) && (refParser->mIsEmitted))
2255 {
2256 // Default to type declaration
2257 emitSourceMapKey = mCurTypeInstance->mTypeDef->GetRefNode()->mSrcStart;
2258 for (auto& kv : ceTypeInfo->mEmitSourceMap)
2259 {
2260 if ((refNode->mSrcStart >= kv.mValue.mSrcStart) && (refNode->mSrcStart < kv.mValue.mSrcEnd))
2261 {
2262 // We found the initial emit source
2263 emitSourceMapKey = kv.mKey;
2264 break;
2265 }
2266 }
2267 }
2268
2269 if (ceTypeInfo->mEmitSourceMap.TryAdd(emitSourceMapKey, NULL, &ceEmitSource))
2270 {
2271 if (typeInstance->IsSpecializedType())
2272 {
2273 auto unspecializedType = GetUnspecializedTypeInstance(typeInstance);
2274 if ((unspecializedType->mCeTypeInfo == NULL) || (!unspecializedType->mCeTypeInfo->mEmitSourceMap.ContainsKey(emitSourceMapKey)))

Callers

nothing calls this directly

Calls 15

TypeToStringFunction · 0.85
GetParserMethod · 0.80
ContainsKeyMethod · 0.80
CopyTypeDefMethod · 0.80
TryGetValueMethod · 0.80
SetCursorIdxMethod · 0.80
SubstringMethod · 0.80
AllocCharsMethod · 0.80
GetParserDataMethod · 0.80
FinishSideNodesMethod · 0.80
GrowUninitializedMethod · 0.80
GetRefNodeMethod · 0.45

Tested by

no test coverage detected