mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 03:52:19 +02:00
Fixed reification issues, mut-vs-imut method mangling
This commit is contained in:
parent
425284f023
commit
9a857cceb3
8 changed files with 31 additions and 18 deletions
|
@ -210,8 +210,6 @@ namespace System.IO
|
|||
|
||||
public this(StreamReader streamReader)
|
||||
{
|
||||
Debug.WriteLine("ReadLineTask this {0}", this);
|
||||
|
||||
mStreamReader = streamReader;
|
||||
ThreadPool.QueueUserWorkItem(new => Proc);
|
||||
}
|
||||
|
|
|
@ -447,7 +447,7 @@ bool BfContext::ProcessWorkList(bool onlyReifiedTypes, bool onlyReifiedMethods)
|
|||
|
||||
auto typeInst = methodSpecializationRequest.mType->ToTypeInstance();
|
||||
module->GetMethodInstance(methodSpecializationRequest.mType->ToTypeInstance(), methodSpecializationRequest.mMethodDef, methodSpecializationRequest.mMethodGenericArguments,
|
||||
(BfGetMethodInstanceFlags)(methodSpecializationRequest.mFlags | BfGetMethodInstanceFlag_ResultNotUsed));
|
||||
(BfGetMethodInstanceFlags)(methodSpecializationRequest.mFlags | BfGetMethodInstanceFlag_ResultNotUsed), methodSpecializationRequest.mForeignType);
|
||||
didWork = true;
|
||||
}
|
||||
}
|
||||
|
@ -505,8 +505,12 @@ bool BfContext::ProcessWorkList(bool onlyReifiedTypes, bool onlyReifiedMethods)
|
|||
module->PopulateType(owner, BfPopulateType_Full);
|
||||
|
||||
if (methodInstance->mDeclModule != NULL)
|
||||
{
|
||||
if (!mCompiler->mIsResolveOnly)
|
||||
BF_ASSERT(!methodInstance->mIsReified || methodInstance->mDeclModule->mIsModuleMutable);
|
||||
ProcessMethod(methodInstance);
|
||||
}
|
||||
}
|
||||
|
||||
workIdx = mMethodWorkList.RemoveAt(workIdx);
|
||||
|
||||
|
|
|
@ -47,12 +47,14 @@ public:
|
|||
BfMethodDef* mMethodDef;
|
||||
BfTypeVector mMethodGenericArguments;
|
||||
BfGetMethodInstanceFlags mFlags;
|
||||
BfTypeInstance* mForeignType;
|
||||
|
||||
public:
|
||||
BfMethodSpecializationRequest()
|
||||
{
|
||||
mMethodDef = NULL;
|
||||
mFlags = BfGetMethodInstanceFlag_None;
|
||||
mForeignType = NULL;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -2011,6 +2011,9 @@ void BfMSMangler::Mangle(StringImpl& name, bool is64Bit, BfMethodInstance* metho
|
|||
}
|
||||
else
|
||||
{
|
||||
if ((!mangleContext.mCPPMangle) && (!methodDef->mIsMutating) && (!methodDef->mIsStatic) && (methodInst->GetOwner()->IsValueType()))
|
||||
AddStr(mangleContext, name, methodDef->mName + "__im");
|
||||
else
|
||||
AddStr(mangleContext, name, methodDef->mName);
|
||||
}
|
||||
|
||||
|
@ -2044,12 +2047,15 @@ void BfMSMangler::Mangle(StringImpl& name, bool is64Bit, BfMethodInstance* metho
|
|||
name += StrFormat("%d$", declType->mPartialIdx);
|
||||
}
|
||||
|
||||
if (!mangleContext.mCPPMangle)
|
||||
{
|
||||
if (methodInst->mMangleWithIdx)
|
||||
name += StrFormat("i%d$", methodInst->mMethodDef->mIdx);
|
||||
if (methodDef->mCheckedKind == BfCheckedKind_Checked)
|
||||
name += "CHK$";
|
||||
else if (methodDef->mCheckedKind == BfCheckedKind_Unchecked)
|
||||
name += "UCHK$";
|
||||
}
|
||||
|
||||
/*if ((methodInst->mMethodInstanceGroup->mOwner->mTypeDef->IsGlobalsContainer()) && (methodInst->mMethodDef->mMethodDeclaration == NULL))
|
||||
{
|
||||
|
|
|
@ -1180,7 +1180,7 @@ void BfModule::StartNewRevision(RebuildKind rebuildKind, bool force)
|
|||
mExtensionCount = 0;
|
||||
mRevision = mCompiler->mRevision;
|
||||
mRebuildIdx++;
|
||||
ClearModuleData();
|
||||
ClearModuleData(!force);
|
||||
|
||||
// Clear this here, not in ClearModuleData, so we preserve those references even after writing out module
|
||||
if (rebuildKind != BfModule::RebuildKind_None) // Leave string pool refs for when we need to use things like [LinkName("")] methods bofore re-reification
|
||||
|
@ -12170,6 +12170,7 @@ BfModuleMethodInstance BfModule::GetMethodInstance(BfTypeInstance* typeInst, BfM
|
|||
specializationRequest->mMethodGenericArguments = methodGenericArguments;
|
||||
specializationRequest->mType = typeInst;
|
||||
specializationRequest->mFlags = flags;
|
||||
specializationRequest->mForeignType = foreignType;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22770,7 +22771,7 @@ void BfModule::ReportMemory(MemReporter* memReporter)
|
|||
|
||||
// ClearModuleData is called immediately after the module is compiled, so don't clear out any data that needs to
|
||||
// be transient through the next compile
|
||||
void BfModule::ClearModuleData()
|
||||
void BfModule::ClearModuleData(bool clearTransientData)
|
||||
{
|
||||
BfLogSysM("ClearModuleData %p\n", this);
|
||||
|
||||
|
@ -22782,6 +22783,7 @@ void BfModule::ClearModuleData()
|
|||
|
||||
mDICompileUnit = BfIRMDNode();
|
||||
mIsModuleMutable = false;
|
||||
if (clearTransientData)
|
||||
mIncompleteMethodCount = 0;
|
||||
mHasGenericMethods = false;
|
||||
|
||||
|
|
|
@ -1883,7 +1883,7 @@ public:
|
|||
void EnsureIRBuilder(bool dbgVerifyCodeGen = false);
|
||||
void DbgFinish();
|
||||
BfIRValue CreateForceLinkMarker(BfModule* module, String* outName);
|
||||
void ClearModuleData();
|
||||
void ClearModuleData(bool clearTransientData = true);
|
||||
void DisownMethods();
|
||||
void ClearModule();
|
||||
void StartExtension(); // For new method specializations
|
||||
|
|
|
@ -102,7 +102,7 @@ class LibClassA
|
|||
|
||||
public this()
|
||||
{
|
||||
Debug.WriteLine("LibA.LibClassA()\n");
|
||||
//Debug.WriteLine("LibA.LibClassA()\n");
|
||||
mA += 100;
|
||||
}
|
||||
|
||||
|
@ -118,7 +118,7 @@ class LibClassA
|
|||
|
||||
public static int32 GetVal(int32 val, int32 magic, String str)
|
||||
{
|
||||
Debug.WriteLine("GetVal: {}", str);
|
||||
//Debug.WriteLine("GetVal: {}", str);
|
||||
sMagic += magic;
|
||||
return val;
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace Tests
|
|||
}
|
||||
|
||||
[Test]
|
||||
public static void Hey()
|
||||
public static void TestBasics()
|
||||
{
|
||||
ClassB cc = scope ClassC();
|
||||
ClassB cb = cc;
|
||||
|
@ -64,6 +64,7 @@ namespace Tests
|
|||
|
||||
StructA sa = default;
|
||||
let sa2 = sa;
|
||||
|
||||
Test.Assert(sa[0] == 2);
|
||||
Test.Assert(sa2[0] == 1);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue