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

Method SetSource

IDEHelper/Compiler/BfParser.cpp:623–703  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

621}
622
623void BfParser::SetSource(const char* data, int length)
624{
625 const int EXTRA_BUFFER_SIZE = 80; // Extra chars for a bit of AllocChars room
626
627 //TODO: Check cache
628 // Don't cache if we have a Cursorid set,
629 // if mDataId != -1
630 // if BfParerFlag != 0
631
632 bool canCache = true;
633 if (mDataId != -1)
634 canCache = false;
635 if (mParserFlags != 0)
636 canCache = false;
637 if (mCursorIdx != -1)
638 canCache = false;
639 if (mCompatMode)
640 canCache = false;
641 if (mQuickCompatMode)
642 canCache = false;
643 if (mFileName.IsEmpty())
644 canCache = false;
645 if (mProject == NULL)
646 canCache = false;
647 if (mIsEmitted)
648 canCache = false;
649
650 uint64 cacheHash = 0;
651 if (canCache)
652 {
653 AutoCrit autoCrit(gBfParserCache->mCritSect);
654
655 HashContext hashCtx;
656 hashCtx.MixinStr(mFileName);
657 hashCtx.Mixin(data, length);
658 cacheHash = hashCtx.Finish64();
659
660 BfParserCache::LookupEntry lookupEntry;
661 lookupEntry.mFileName = mFileName;
662 lookupEntry.mSrc = data;
663 lookupEntry.mSrcLength = length;
664 lookupEntry.mHash = cacheHash;
665 lookupEntry.mProject = mProject;
666
667 BfParserCache::DataEntry* dataEntryP;
668 if (gBfParserCache->mEntries.TryGetWith(lookupEntry, &dataEntryP))
669 {
670 mUsingCache = true;
671
672 mParserData = dataEntryP->mParserData;
673 BF_ASSERT(mParserData->mDidReduce);
674
675 BfLogSysM("Using cached parserData %p for %p %s\n", mParserData, this, mFileName.c_str());
676
677 mParserData->mRefCount++;
678 mSourceData = mParserData;
679
680 mSrc = mParserData->mSrc;

Callers 13

InitMethod · 0.45
EvaluateMethod · 0.45
EvaluateToAddressMethod · 0.45
CEEmitParseMethod · 0.45
GetTypeMethod · 0.45
GetReflectTypeMethod · 0.45
BfParser_SetSourceFunction · 0.45
InitMethod · 0.45
EvaluateMethod · 0.45

Calls 7

MixinStrMethod · 0.80
Finish64Method · 0.80
TryGetWithMethod · 0.80
InitFunction · 0.70
IsEmptyMethod · 0.45
MixinMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected