1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 12:32:20 +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 dynStackSize = 0;
// if (mUseBP)
// {
// dynStackSize = BF_MAX(4, argCount) * 8;
// dynStackSize = BF_ALIGN(dynStackSize, 16);
// }
if (dynStackSize > 0)
AllocInst(BeMCInstKind_Sub, BeMCOperand::FromReg(X64Reg_RSP), BeMCOperand::FromImmediate(dynStackSize));
@ -16268,16 +16263,13 @@ void BeMCContext::Generate(BeFunction* function)
}
else
{
if (auto func = BeValueDynCast<BeFunction>(castedInst->mFunc))
auto funcPtrType = castedInst->mFunc->GetType();
if (funcPtrType->IsPointer())
{
auto funcPtrType = func->mType;
if (funcPtrType->IsPointer())
auto elementType = ((BePointerType*)funcPtrType)->mElementType;
if (elementType->mTypeCode == BeTypeCode_Function)
{
auto elementType = ((BePointerType*)funcPtrType)->mElementType;
if (elementType->mTypeCode == BeTypeCode_Function)
{
isVarArg = ((BeFunctionType*)elementType)->mIsVarArg;
}
isVarArg = ((BeFunctionType*)elementType)->mIsVarArg;
}
}

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)
{
if ((!mResult) && (mPropDef != NULL))
@ -14550,7 +14555,7 @@ void BfExprEvaluator::AssignDeferrredTupleAssignData(BfAssignmentExpression* ass
}
else
{
if (child.mExprEvaluator->mResult)
if (child.mExprEvaluator->HasResult())
{
child.mExprEvaluator->mBfEvalExprFlags = (BfEvalExprFlags)(child.mExprEvaluator->mBfEvalExprFlags | BfEvalExprFlags_NoAutoComplete);
child.mExprEvaluator->PerformAssignment(assignExpr, true, elementValue);

View file

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

View file

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