1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 04:22:20 +02:00

Fixed Linux interop issue

This commit is contained in:
Brian Fiete 2020-07-15 06:28:41 -07:00
parent 3c40f80f6d
commit 0e6a001091
4 changed files with 24 additions and 14 deletions

View file

@ -17180,7 +17180,6 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup)
else if (mCurTypeInstance->mTypeDef->mTypeDeclaration != NULL) else if (mCurTypeInstance->mTypeDef->mTypeDeclaration != NULL)
UpdateSrcPos(mCurTypeInstance->mTypeDef->mTypeDeclaration); UpdateSrcPos(mCurTypeInstance->mTypeDef->mTypeDeclaration);
int declArgIdx = 0;
localIdx = 0; localIdx = 0;
argIdx = 0; argIdx = 0;
@ -17201,6 +17200,9 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup)
if ((isThis) && (thisType->IsValuelessType())) if ((isThis) && (thisType->IsValuelessType()))
isThis = false; isThis = false;
if (paramVar->mValue.IsArg())
BF_ASSERT(paramVar->mValue.mId == argIdx);
BfIRMDNode diVariable; BfIRMDNode diVariable;
if (wantsDIData) if (wantsDIData)
{ {
@ -17297,8 +17299,6 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup)
if (loweredTypeCode2 != BfTypeCode_None) if (loweredTypeCode2 != BfTypeCode_None)
{ {
declArgIdx++;
auto primType2 = mBfIRBuilder->GetPrimitiveType(loweredTypeCode2); auto primType2 = mBfIRBuilder->GetPrimitiveType(loweredTypeCode2);
auto primPtrType2 = mBfIRBuilder->GetPointerTo(primType2); auto primPtrType2 = mBfIRBuilder->GetPointerTo(primType2);
BfIRValue primPtrVal2; BfIRValue primPtrVal2;
@ -17324,9 +17324,6 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup)
} }
} }
if (!isThis)
declArgIdx++;
if (methodDef->mBody != NULL) if (methodDef->mBody != NULL)
UpdateSrcPos(methodDef->mBody); UpdateSrcPos(methodDef->mBody);
else if (methodDef->mDeclaringType->mTypeDeclaration != NULL) else if (methodDef->mDeclaringType->mTypeDeclaration != NULL)
@ -17490,7 +17487,7 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup)
BfTypeCode loweredTypeCode = BfTypeCode_None; BfTypeCode loweredTypeCode = BfTypeCode_None;
BfTypeCode loweredTypeCode2 = BfTypeCode_None; BfTypeCode loweredTypeCode2 = BfTypeCode_None;
paramVar->mResolvedType->GetLoweredType(BfTypeUsage_Parameter, &loweredTypeCode, &loweredTypeCode2); paramVar->mResolvedType->GetLoweredType(BfTypeUsage_Parameter, &loweredTypeCode, &loweredTypeCode2);
if (loweredTypeCode != BfTypeCode_None) if (loweredTypeCode2 != BfTypeCode_None)
argIdx++; argIdx++;
} }
else if (!paramVar->mResolvedType->IsValuelessType()) else if (!paramVar->mResolvedType->IsValuelessType())

View file

@ -10148,7 +10148,7 @@ BfIRValue BfModule::CastToValue(BfAstNode* srcNode, BfTypedValue typedVal, BfTyp
if (methodInst->GetParamCount() != 1) if (methodInst->GetParamCount() != 1)
{ {
BF_ASSERT(mCompiler->mPassInstance->HasFailed()); AssertErrorState();
continue; continue;
} }

View file

@ -362,6 +362,11 @@ extern "C" int Func0W(int a, Interop::StructW b)
return a + (int)b.mX * 100; 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) extern "C" int Func1A(Interop::StructA arg0, Interop::StructA arg1, int arg2)

View file

@ -258,6 +258,8 @@ namespace Tests
public static extern int32 Func0V(int32 a, StructV b); public static extern int32 Func0V(int32 a, StructV b);
[LinkName(.C)] [LinkName(.C)]
public static extern int32 Func0W(int32 a, StructW b); public static extern int32 Func0W(int32 a, StructW b);
[LinkName(.C)]
public static extern int32 Func0KM(StructK a, StructM b, StructK c);
[LinkName(.C)] [LinkName(.C)]
public static extern int32 Func1A(StructA arg0, StructA arg1, int32 arg2); 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 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 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 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] [Test]
public static void TestBasics() public static void TestBasics()
@ -365,8 +368,9 @@ namespace Tests
si1.mA = 91; si1.mA = 91;
StructK sk = .() { mX = 3, mY = 4}; StructK sk = .() { mX = 3, mY = 4};
StructK sk2 = .() { mX = 11, mY = 12 };
StructL sl = .() { mX = 3, mY = 4}; 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}; StructN sn = .() { mX = 3, mY = 4};
StructO so = .() { mX = 3, mY = 4}; StructO so = .() { mX = 3, mY = 4};
StructP sp = .() { mX = 3, mY = 4}; StructP sp = .() { mX = 3, mY = 4};
@ -390,7 +394,7 @@ namespace Tests
StartTest("Func0L"); StartTest("Func0L");
Test.Assert(Func0L(12, sl) == 40312); Test.Assert(Func0L(12, sl) == 40312);
StartTest("Func0M"); StartTest("Func0M");
Test.Assert(Func0M(12, sm) == 40312); Test.Assert(Func0M(12, sm) == 60512);
StartTest("Func0N"); StartTest("Func0N");
Test.Assert(Func0N(12, sn) == 40312); Test.Assert(Func0N(12, sn) == 40312);
StartTest("Func0O"); StartTest("Func0O");
@ -411,13 +415,15 @@ namespace Tests
Test.Assert(Func0V(12, sv) == 40312); Test.Assert(Func0V(12, sv) == 40312);
StartTest("Func0W"); StartTest("Func0W");
Test.Assert(Func0W(12, sw) == 312); Test.Assert(Func0W(12, sw) == 312);
StartTest("Func0KM");
Test.Assert(Func0KM(sk, sm, sk2) == 11503);
StartTest("LocalFunc0K"); StartTest("LocalFunc0K");
Test.Assert(LocalFunc0K(12, sk) == 40312); Test.Assert(LocalFunc0K(12, sk) == 40312);
StartTest("LocalFunc0L"); StartTest("LocalFunc0L");
Test.Assert(LocalFunc0L(12, sl) == 40312); Test.Assert(LocalFunc0L(12, sl) == 40312);
StartTest("LocalFunc0M"); StartTest("LocalFunc0M");
Test.Assert(LocalFunc0M(12, sm) == 40312); Test.Assert(LocalFunc0M(12, sm) == 60512);
StartTest("LocalFunc0N"); StartTest("LocalFunc0N");
Test.Assert(LocalFunc0N(12, sn) == 40312); Test.Assert(LocalFunc0N(12, sn) == 40312);
StartTest("LocalFunc0O"); StartTest("LocalFunc0O");
@ -438,6 +444,8 @@ namespace Tests
Test.Assert(LocalFunc0V(12, sv) == 40312); Test.Assert(LocalFunc0V(12, sv) == 40312);
StartTest("LocalFunc0W"); StartTest("LocalFunc0W");
Test.Assert(LocalFunc0W(12, sw) == 312); Test.Assert(LocalFunc0W(12, sw) == 312);
StartTest("Func0KM");
Test.Assert(LocalFunc0KM(sk, sm, sk2) == 11503);
StartTest("Func1A"); StartTest("Func1A");
Test.Assert(Func1A(sa0, sa1, 12) == 121110); Test.Assert(Func1A(sa0, sa1, 12) == 121110);