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

Fixed varargs and tuple building

This commit is contained in:
Brian Fiete 2020-02-11 08:37:52 -08:00
parent 7741344fd2
commit 8171c842f0
5 changed files with 42 additions and 25 deletions

View file

@ -2893,11 +2893,6 @@ BeMCOperand BeMCContext::CreateCall(const BeMCOperand& func, const SizedArrayImp
int argCount = (int)args.size() + argOfs; int argCount = (int)args.size() + argOfs;
int dynStackSize = 0; int dynStackSize = 0;
// if (mUseBP)
// {
// dynStackSize = BF_MAX(4, argCount) * 8;
// dynStackSize = BF_ALIGN(dynStackSize, 16);
// }
if (dynStackSize > 0) if (dynStackSize > 0)
AllocInst(BeMCInstKind_Sub, BeMCOperand::FromReg(X64Reg_RSP), BeMCOperand::FromImmediate(dynStackSize)); AllocInst(BeMCInstKind_Sub, BeMCOperand::FromReg(X64Reg_RSP), BeMCOperand::FromImmediate(dynStackSize));
@ -16268,9 +16263,7 @@ void BeMCContext::Generate(BeFunction* function)
} }
else else
{ {
if (auto func = BeValueDynCast<BeFunction>(castedInst->mFunc)) auto funcPtrType = castedInst->mFunc->GetType();
{
auto funcPtrType = func->mType;
if (funcPtrType->IsPointer()) if (funcPtrType->IsPointer())
{ {
auto elementType = ((BePointerType*)funcPtrType)->mElementType; auto elementType = ((BePointerType*)funcPtrType)->mElementType;
@ -16279,7 +16272,6 @@ void BeMCContext::Generate(BeFunction* function)
isVarArg = ((BeFunctionType*)elementType)->mIsVarArg; isVarArg = ((BeFunctionType*)elementType)->mIsVarArg;
} }
} }
}
returnType = castedInst->GetType(); returnType = castedInst->GetType();
mcFunc = GetOperand(castedInst->mFunc); mcFunc = GetOperand(castedInst->mFunc);

View file

@ -13825,6 +13825,11 @@ void BfExprEvaluator::CheckPropFail(BfMethodDef* propMethodDef, BfMethodInstance
} }
} }
bool BfExprEvaluator::HasResult()
{
return (mResult) || (mPropDef != NULL);
}
BfTypedValue BfExprEvaluator::GetResult(bool clearResult, bool resolveGenericType) BfTypedValue BfExprEvaluator::GetResult(bool clearResult, bool resolveGenericType)
{ {
if ((!mResult) && (mPropDef != NULL)) if ((!mResult) && (mPropDef != NULL))
@ -14550,7 +14555,7 @@ void BfExprEvaluator::AssignDeferrredTupleAssignData(BfAssignmentExpression* ass
} }
else else
{ {
if (child.mExprEvaluator->mResult) if (child.mExprEvaluator->HasResult())
{ {
child.mExprEvaluator->mBfEvalExprFlags = (BfEvalExprFlags)(child.mExprEvaluator->mBfEvalExprFlags | BfEvalExprFlags_NoAutoComplete); child.mExprEvaluator->mBfEvalExprFlags = (BfEvalExprFlags)(child.mExprEvaluator->mBfEvalExprFlags | BfEvalExprFlags_NoAutoComplete);
child.mExprEvaluator->PerformAssignment(assignExpr, true, elementValue); child.mExprEvaluator->PerformAssignment(assignExpr, true, elementValue);

View file

@ -329,6 +329,7 @@ public:
BfMethodDef* GetPropertyMethodDef(BfPropertyDef* propDef, BfMethodType methodType, BfCheckedKind checkedKind); BfMethodDef* GetPropertyMethodDef(BfPropertyDef* propDef, BfMethodType methodType, BfCheckedKind checkedKind);
BfModuleMethodInstance GetPropertyMethodInstance(BfMethodDef* methodDef); BfModuleMethodInstance GetPropertyMethodInstance(BfMethodDef* methodDef);
void CheckPropFail(BfMethodDef* propMethodDef, BfMethodInstance* methodInstance); void CheckPropFail(BfMethodDef* propMethodDef, BfMethodInstance* methodInstance);
bool HasResult();
BfTypedValue GetResult(bool clearResult = false, bool resolveGenericType = false); BfTypedValue GetResult(bool clearResult = false, bool resolveGenericType = false);
void CheckResultForReading(BfTypedValue& typedValue); void CheckResultForReading(BfTypedValue& typedValue);
void MarkResultUsed(); void MarkResultUsed();

View file

@ -8794,11 +8794,6 @@ BfIRValue BfModule::CreateFunctionFrom(BfMethodInstance* methodInstance, bool tr
if (mCompiler->IsSkippingExtraResolveChecks()) if (mCompiler->IsSkippingExtraResolveChecks())
return BfIRValue(); return BfIRValue();
if (methodInstance->mMethodDef->mName == "Check")
{
NOP;
}
if (methodInstance->mMethodInstanceGroup->mOwner->IsInterface()) if (methodInstance->mMethodInstanceGroup->mOwner->IsInterface())
{ {
//BF_ASSERT(!methodInstance->mIRFunction); //BF_ASSERT(!methodInstance->mIRFunction);

View file

@ -0,0 +1,24 @@
using System;
namespace Tests
{
class VarArgs
{
#if BF_PLATFORM_WINDOWS
[CLink, Import("msvcrt.dll")]
#else
[CLink]
#endif
public static extern int32 sprintf(char8* dest, char8* fmt, ...);
[Test]
public static void TestBasics()
{
char8[256] cStr;
sprintf(&cStr, "Test %d %0.1f %0.1f", 123, 1.2f, 2.3f);
String str = scope .(&cStr);
Test.Assert(str == "Test 123 1.2 2.3");
}
}
}