mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 20:12:21 +02:00
Fixed Linux interop issue
This commit is contained in:
parent
3c40f80f6d
commit
0e6a001091
4 changed files with 24 additions and 14 deletions
|
@ -17179,8 +17179,7 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup)
|
|||
UpdateSrcPos(methodDef->mBody);
|
||||
else if (mCurTypeInstance->mTypeDef->mTypeDeclaration != NULL)
|
||||
UpdateSrcPos(mCurTypeInstance->mTypeDef->mTypeDeclaration);
|
||||
|
||||
int declArgIdx = 0;
|
||||
|
||||
localIdx = 0;
|
||||
argIdx = 0;
|
||||
|
||||
|
@ -17201,6 +17200,9 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup)
|
|||
if ((isThis) && (thisType->IsValuelessType()))
|
||||
isThis = false;
|
||||
|
||||
if (paramVar->mValue.IsArg())
|
||||
BF_ASSERT(paramVar->mValue.mId == argIdx);
|
||||
|
||||
BfIRMDNode diVariable;
|
||||
if (wantsDIData)
|
||||
{
|
||||
|
@ -17293,12 +17295,10 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup)
|
|||
auto primType = mBfIRBuilder->GetPrimitiveType(loweredTypeCode);
|
||||
auto primPtrType = mBfIRBuilder->GetPointerTo(primType);
|
||||
auto primPtrVal = mBfIRBuilder->CreateBitCast(paramVar->mAddr, primPtrType);
|
||||
mBfIRBuilder->CreateStore(paramVar->mValue, primPtrVal);
|
||||
|
||||
mBfIRBuilder->CreateStore(paramVar->mValue, primPtrVal);
|
||||
|
||||
if (loweredTypeCode2 != BfTypeCode_None)
|
||||
{
|
||||
declArgIdx++;
|
||||
|
||||
auto primType2 = mBfIRBuilder->GetPrimitiveType(loweredTypeCode2);
|
||||
auto primPtrType2 = mBfIRBuilder->GetPointerTo(primType2);
|
||||
BfIRValue primPtrVal2;
|
||||
|
@ -17324,9 +17324,6 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup)
|
|||
}
|
||||
}
|
||||
|
||||
if (!isThis)
|
||||
declArgIdx++;
|
||||
|
||||
if (methodDef->mBody != NULL)
|
||||
UpdateSrcPos(methodDef->mBody);
|
||||
else if (methodDef->mDeclaringType->mTypeDeclaration != NULL)
|
||||
|
@ -17490,7 +17487,7 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup)
|
|||
BfTypeCode loweredTypeCode = BfTypeCode_None;
|
||||
BfTypeCode loweredTypeCode2 = BfTypeCode_None;
|
||||
paramVar->mResolvedType->GetLoweredType(BfTypeUsage_Parameter, &loweredTypeCode, &loweredTypeCode2);
|
||||
if (loweredTypeCode != BfTypeCode_None)
|
||||
if (loweredTypeCode2 != BfTypeCode_None)
|
||||
argIdx++;
|
||||
}
|
||||
else if (!paramVar->mResolvedType->IsValuelessType())
|
||||
|
|
|
@ -10148,7 +10148,7 @@ BfIRValue BfModule::CastToValue(BfAstNode* srcNode, BfTypedValue typedVal, BfTyp
|
|||
|
||||
if (methodInst->GetParamCount() != 1)
|
||||
{
|
||||
BF_ASSERT(mCompiler->mPassInstance->HasFailed());
|
||||
AssertErrorState();
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -362,6 +362,11 @@ extern "C" int Func0W(int a, Interop::StructW b)
|
|||
return a + (int)b.mX * 100;
|
||||
}
|
||||
|
||||
extern "C" int Func0KM(Interop::StructK a, Interop::StructM b, Interop::StructK c)
|
||||
{
|
||||
return (int)a.mX + (int)b.mX * 100 + (int)c.mX * 1000;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
extern "C" int Func1A(Interop::StructA arg0, Interop::StructA arg1, int arg2)
|
||||
|
|
|
@ -258,6 +258,8 @@ namespace Tests
|
|||
public static extern int32 Func0V(int32 a, StructV b);
|
||||
[LinkName(.C)]
|
||||
public static extern int32 Func0W(int32 a, StructW b);
|
||||
[LinkName(.C)]
|
||||
public static extern int32 Func0KM(StructK a, StructM b, StructK c);
|
||||
|
||||
[LinkName(.C)]
|
||||
public static extern int32 Func1A(StructA arg0, StructA arg1, int32 arg2);
|
||||
|
@ -313,6 +315,7 @@ namespace Tests
|
|||
static int32 LocalFunc0U(int32 a, StructU b) => a + (int32)b.mK.mX * 100 + (int32)b.mK.mY * 10000;
|
||||
static int32 LocalFunc0V(int32 a, StructV b) => a + (int32)b.mX * 100 + (int32)b.mY * 10000;
|
||||
static int32 LocalFunc0W(int32 a, StructW b) => a + (int32)b.mX * 100;
|
||||
static int32 LocalFunc0KM(StructK a, StructM b, StructK c) => (int32)a.mX + (int32)b.mX * 100 + (int32)c.mX * 1000;
|
||||
|
||||
[Test]
|
||||
public static void TestBasics()
|
||||
|
@ -365,8 +368,9 @@ namespace Tests
|
|||
si1.mA = 91;
|
||||
|
||||
StructK sk = .() { mX = 3, mY = 4};
|
||||
StructK sk2 = .() { mX = 11, mY = 12 };
|
||||
StructL sl = .() { mX = 3, mY = 4};
|
||||
StructM sm = .() { mX = 3, mY = 4};
|
||||
StructM sm = .() { mX = 5, mY = 6, mZ = 7, mW = 8 };
|
||||
StructN sn = .() { mX = 3, mY = 4};
|
||||
StructO so = .() { mX = 3, mY = 4};
|
||||
StructP sp = .() { mX = 3, mY = 4};
|
||||
|
@ -390,7 +394,7 @@ namespace Tests
|
|||
StartTest("Func0L");
|
||||
Test.Assert(Func0L(12, sl) == 40312);
|
||||
StartTest("Func0M");
|
||||
Test.Assert(Func0M(12, sm) == 40312);
|
||||
Test.Assert(Func0M(12, sm) == 60512);
|
||||
StartTest("Func0N");
|
||||
Test.Assert(Func0N(12, sn) == 40312);
|
||||
StartTest("Func0O");
|
||||
|
@ -411,13 +415,15 @@ namespace Tests
|
|||
Test.Assert(Func0V(12, sv) == 40312);
|
||||
StartTest("Func0W");
|
||||
Test.Assert(Func0W(12, sw) == 312);
|
||||
StartTest("Func0KM");
|
||||
Test.Assert(Func0KM(sk, sm, sk2) == 11503);
|
||||
|
||||
StartTest("LocalFunc0K");
|
||||
Test.Assert(LocalFunc0K(12, sk) == 40312);
|
||||
StartTest("LocalFunc0L");
|
||||
Test.Assert(LocalFunc0L(12, sl) == 40312);
|
||||
StartTest("LocalFunc0M");
|
||||
Test.Assert(LocalFunc0M(12, sm) == 40312);
|
||||
Test.Assert(LocalFunc0M(12, sm) == 60512);
|
||||
StartTest("LocalFunc0N");
|
||||
Test.Assert(LocalFunc0N(12, sn) == 40312);
|
||||
StartTest("LocalFunc0O");
|
||||
|
@ -438,6 +444,8 @@ namespace Tests
|
|||
Test.Assert(LocalFunc0V(12, sv) == 40312);
|
||||
StartTest("LocalFunc0W");
|
||||
Test.Assert(LocalFunc0W(12, sw) == 312);
|
||||
StartTest("Func0KM");
|
||||
Test.Assert(LocalFunc0KM(sk, sm, sk2) == 11503);
|
||||
|
||||
StartTest("Func1A");
|
||||
Test.Assert(Func1A(sa0, sa1, 12) == 121110);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue