mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 12:02:21 +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)
|
public this(StreamReader streamReader)
|
||||||
{
|
{
|
||||||
Debug.WriteLine("ReadLineTask this {0}", this);
|
|
||||||
|
|
||||||
mStreamReader = streamReader;
|
mStreamReader = streamReader;
|
||||||
ThreadPool.QueueUserWorkItem(new => Proc);
|
ThreadPool.QueueUserWorkItem(new => Proc);
|
||||||
}
|
}
|
||||||
|
|
|
@ -447,7 +447,7 @@ bool BfContext::ProcessWorkList(bool onlyReifiedTypes, bool onlyReifiedMethods)
|
||||||
|
|
||||||
auto typeInst = methodSpecializationRequest.mType->ToTypeInstance();
|
auto typeInst = methodSpecializationRequest.mType->ToTypeInstance();
|
||||||
module->GetMethodInstance(methodSpecializationRequest.mType->ToTypeInstance(), methodSpecializationRequest.mMethodDef, methodSpecializationRequest.mMethodGenericArguments,
|
module->GetMethodInstance(methodSpecializationRequest.mType->ToTypeInstance(), methodSpecializationRequest.mMethodDef, methodSpecializationRequest.mMethodGenericArguments,
|
||||||
(BfGetMethodInstanceFlags)(methodSpecializationRequest.mFlags | BfGetMethodInstanceFlag_ResultNotUsed));
|
(BfGetMethodInstanceFlags)(methodSpecializationRequest.mFlags | BfGetMethodInstanceFlag_ResultNotUsed), methodSpecializationRequest.mForeignType);
|
||||||
didWork = true;
|
didWork = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -505,8 +505,12 @@ bool BfContext::ProcessWorkList(bool onlyReifiedTypes, bool onlyReifiedMethods)
|
||||||
module->PopulateType(owner, BfPopulateType_Full);
|
module->PopulateType(owner, BfPopulateType_Full);
|
||||||
|
|
||||||
if (methodInstance->mDeclModule != NULL)
|
if (methodInstance->mDeclModule != NULL)
|
||||||
|
{
|
||||||
|
if (!mCompiler->mIsResolveOnly)
|
||||||
|
BF_ASSERT(!methodInstance->mIsReified || methodInstance->mDeclModule->mIsModuleMutable);
|
||||||
ProcessMethod(methodInstance);
|
ProcessMethod(methodInstance);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
workIdx = mMethodWorkList.RemoveAt(workIdx);
|
workIdx = mMethodWorkList.RemoveAt(workIdx);
|
||||||
|
|
||||||
|
|
|
@ -47,12 +47,14 @@ public:
|
||||||
BfMethodDef* mMethodDef;
|
BfMethodDef* mMethodDef;
|
||||||
BfTypeVector mMethodGenericArguments;
|
BfTypeVector mMethodGenericArguments;
|
||||||
BfGetMethodInstanceFlags mFlags;
|
BfGetMethodInstanceFlags mFlags;
|
||||||
|
BfTypeInstance* mForeignType;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BfMethodSpecializationRequest()
|
BfMethodSpecializationRequest()
|
||||||
{
|
{
|
||||||
mMethodDef = NULL;
|
mMethodDef = NULL;
|
||||||
mFlags = BfGetMethodInstanceFlag_None;
|
mFlags = BfGetMethodInstanceFlag_None;
|
||||||
|
mForeignType = NULL;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2011,6 +2011,9 @@ void BfMSMangler::Mangle(StringImpl& name, bool is64Bit, BfMethodInstance* metho
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if ((!mangleContext.mCPPMangle) && (!methodDef->mIsMutating) && (!methodDef->mIsStatic) && (methodInst->GetOwner()->IsValueType()))
|
||||||
|
AddStr(mangleContext, name, methodDef->mName + "__im");
|
||||||
|
else
|
||||||
AddStr(mangleContext, name, methodDef->mName);
|
AddStr(mangleContext, name, methodDef->mName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2044,12 +2047,15 @@ void BfMSMangler::Mangle(StringImpl& name, bool is64Bit, BfMethodInstance* metho
|
||||||
name += StrFormat("%d$", declType->mPartialIdx);
|
name += StrFormat("%d$", declType->mPartialIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!mangleContext.mCPPMangle)
|
||||||
|
{
|
||||||
if (methodInst->mMangleWithIdx)
|
if (methodInst->mMangleWithIdx)
|
||||||
name += StrFormat("i%d$", methodInst->mMethodDef->mIdx);
|
name += StrFormat("i%d$", methodInst->mMethodDef->mIdx);
|
||||||
if (methodDef->mCheckedKind == BfCheckedKind_Checked)
|
if (methodDef->mCheckedKind == BfCheckedKind_Checked)
|
||||||
name += "CHK$";
|
name += "CHK$";
|
||||||
else if (methodDef->mCheckedKind == BfCheckedKind_Unchecked)
|
else if (methodDef->mCheckedKind == BfCheckedKind_Unchecked)
|
||||||
name += "UCHK$";
|
name += "UCHK$";
|
||||||
|
}
|
||||||
|
|
||||||
/*if ((methodInst->mMethodInstanceGroup->mOwner->mTypeDef->IsGlobalsContainer()) && (methodInst->mMethodDef->mMethodDeclaration == NULL))
|
/*if ((methodInst->mMethodInstanceGroup->mOwner->mTypeDef->IsGlobalsContainer()) && (methodInst->mMethodDef->mMethodDeclaration == NULL))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1180,7 +1180,7 @@ void BfModule::StartNewRevision(RebuildKind rebuildKind, bool force)
|
||||||
mExtensionCount = 0;
|
mExtensionCount = 0;
|
||||||
mRevision = mCompiler->mRevision;
|
mRevision = mCompiler->mRevision;
|
||||||
mRebuildIdx++;
|
mRebuildIdx++;
|
||||||
ClearModuleData();
|
ClearModuleData(!force);
|
||||||
|
|
||||||
// Clear this here, not in ClearModuleData, so we preserve those references even after writing out module
|
// 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
|
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->mMethodGenericArguments = methodGenericArguments;
|
||||||
specializationRequest->mType = typeInst;
|
specializationRequest->mType = typeInst;
|
||||||
specializationRequest->mFlags = flags;
|
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
|
// 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
|
// be transient through the next compile
|
||||||
void BfModule::ClearModuleData()
|
void BfModule::ClearModuleData(bool clearTransientData)
|
||||||
{
|
{
|
||||||
BfLogSysM("ClearModuleData %p\n", this);
|
BfLogSysM("ClearModuleData %p\n", this);
|
||||||
|
|
||||||
|
@ -22782,6 +22783,7 @@ void BfModule::ClearModuleData()
|
||||||
|
|
||||||
mDICompileUnit = BfIRMDNode();
|
mDICompileUnit = BfIRMDNode();
|
||||||
mIsModuleMutable = false;
|
mIsModuleMutable = false;
|
||||||
|
if (clearTransientData)
|
||||||
mIncompleteMethodCount = 0;
|
mIncompleteMethodCount = 0;
|
||||||
mHasGenericMethods = false;
|
mHasGenericMethods = false;
|
||||||
|
|
||||||
|
|
|
@ -1883,7 +1883,7 @@ public:
|
||||||
void EnsureIRBuilder(bool dbgVerifyCodeGen = false);
|
void EnsureIRBuilder(bool dbgVerifyCodeGen = false);
|
||||||
void DbgFinish();
|
void DbgFinish();
|
||||||
BfIRValue CreateForceLinkMarker(BfModule* module, String* outName);
|
BfIRValue CreateForceLinkMarker(BfModule* module, String* outName);
|
||||||
void ClearModuleData();
|
void ClearModuleData(bool clearTransientData = true);
|
||||||
void DisownMethods();
|
void DisownMethods();
|
||||||
void ClearModule();
|
void ClearModule();
|
||||||
void StartExtension(); // For new method specializations
|
void StartExtension(); // For new method specializations
|
||||||
|
|
|
@ -102,7 +102,7 @@ class LibClassA
|
||||||
|
|
||||||
public this()
|
public this()
|
||||||
{
|
{
|
||||||
Debug.WriteLine("LibA.LibClassA()\n");
|
//Debug.WriteLine("LibA.LibClassA()\n");
|
||||||
mA += 100;
|
mA += 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ class LibClassA
|
||||||
|
|
||||||
public static int32 GetVal(int32 val, int32 magic, String str)
|
public static int32 GetVal(int32 val, int32 magic, String str)
|
||||||
{
|
{
|
||||||
Debug.WriteLine("GetVal: {}", str);
|
//Debug.WriteLine("GetVal: {}", str);
|
||||||
sMagic += magic;
|
sMagic += magic;
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ namespace Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public static void Hey()
|
public static void TestBasics()
|
||||||
{
|
{
|
||||||
ClassB cc = scope ClassC();
|
ClassB cc = scope ClassC();
|
||||||
ClassB cb = cc;
|
ClassB cb = cc;
|
||||||
|
@ -64,6 +64,7 @@ namespace Tests
|
||||||
|
|
||||||
StructA sa = default;
|
StructA sa = default;
|
||||||
let sa2 = sa;
|
let sa2 = sa;
|
||||||
|
|
||||||
Test.Assert(sa[0] == 2);
|
Test.Assert(sa[0] == 2);
|
||||||
Test.Assert(sa2[0] == 1);
|
Test.Assert(sa2[0] == 1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue