mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
Fixed params expression with ref values
This commit is contained in:
parent
4fe6bcaa86
commit
e82daf74d4
9 changed files with 29 additions and 45 deletions
|
@ -301,11 +301,6 @@ void BfStructuralVisitor::Visit(BfParameterDeclaration* paramDecl)
|
|||
Visit(paramDecl->ToBase());
|
||||
}
|
||||
|
||||
void BfStructuralVisitor::Visit(BfParamsExpression* paramsExpr)
|
||||
{
|
||||
Visit(paramsExpr->ToBase());
|
||||
}
|
||||
|
||||
void BfStructuralVisitor::Visit(BfTypeAttrExpression* typeAttrExpr)
|
||||
{
|
||||
Visit(typeAttrExpr->ToBase());
|
||||
|
|
|
@ -268,7 +268,6 @@ class BfOperatorDeclaration;
|
|||
class BfFieldDeclaration;
|
||||
class BfEnumCaseDeclaration;
|
||||
class BfParameterDeclaration;
|
||||
class BfParamsExpression;
|
||||
class BfForStatement;
|
||||
class BfUsingStatement;
|
||||
class BfDoStatement;
|
||||
|
@ -455,7 +454,6 @@ public:
|
|||
virtual void Visit(BfVariableDeclaration* varDecl);
|
||||
virtual void Visit(BfLocalMethodDeclaration* methodDecl);
|
||||
virtual void Visit(BfParameterDeclaration* paramDecl);
|
||||
virtual void Visit(BfParamsExpression* paramsExpr);
|
||||
virtual void Visit(BfTypeAttrExpression* typeAttrExpr);
|
||||
virtual void Visit(BfTypeOfExpression* typeOfExpr);
|
||||
virtual void Visit(BfSizeOfExpression* sizeOfExpr);
|
||||
|
@ -2472,14 +2470,6 @@ public:
|
|||
BfTokenNode* mRefToken;
|
||||
}; BF_AST_DECL(BfRefTypeRef, BfElementedTypeRef);
|
||||
|
||||
class BfParamsExpression : public BfExpression
|
||||
{
|
||||
public:
|
||||
BF_AST_TYPE(BfParamsExpression, BfExpression);
|
||||
|
||||
BfTokenNode* mParamsToken;
|
||||
}; BF_AST_DECL(BfParamsExpression, BfExpression);
|
||||
|
||||
class BfTypeAttrExpression : public BfExpression
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -446,13 +446,6 @@ void BfElementVisitor::Visit(BfParameterDeclaration* paramDecl)
|
|||
VisitChild(paramDecl->mModToken); // 'Params'
|
||||
}
|
||||
|
||||
void BfElementVisitor::Visit(BfParamsExpression* paramsExpr)
|
||||
{
|
||||
Visit(paramsExpr->ToBase());
|
||||
|
||||
VisitChild(paramsExpr->mParamsToken);
|
||||
}
|
||||
|
||||
void BfElementVisitor::Visit(BfTypeAttrExpression* typeAttrExpr)
|
||||
{
|
||||
Visit(typeAttrExpr->ToBase());
|
||||
|
|
|
@ -65,7 +65,6 @@ public:
|
|||
virtual void Visit(BfVariableDeclaration* varDecl);
|
||||
virtual void Visit(BfLocalMethodDeclaration* methodDecl);
|
||||
virtual void Visit(BfParameterDeclaration* paramDecl);
|
||||
virtual void Visit(BfParamsExpression* paramsExpr);
|
||||
virtual void Visit(BfTypeAttrExpression* typeAttrExpr);
|
||||
virtual void Visit(BfDefaultExpression* defaultExpr);
|
||||
virtual void Visit(BfUninitializedExpression* uninitializedExpr);
|
||||
|
|
|
@ -4134,12 +4134,10 @@ void BfExprEvaluator::ResolveArgValues(BfResolvedArgs& resolvedArgs, BfResolveAr
|
|||
{
|
||||
BfResolvedArg compositeResolvedArg;
|
||||
auto compositeLocalVar = methodState->mLocals[localVar->mLocalVarIdx + compositeIdx + 1];
|
||||
auto argValue = exprEvaluator.LoadLocal(compositeLocalVar);
|
||||
auto argValue = exprEvaluator.LoadLocal(compositeLocalVar, true);
|
||||
if (argValue)
|
||||
{
|
||||
if (argValue.mType->IsRef())
|
||||
argValue.mKind = BfTypedValueKind_Value;
|
||||
else if (!argValue.mType->IsStruct())
|
||||
if (!argValue.mType->IsStruct())
|
||||
argValue = mModule->LoadValue(argValue, NULL, exprEvaluator.mIsVolatileReference);
|
||||
}
|
||||
resolvedArg.mTypedValue = argValue;
|
||||
|
@ -8052,11 +8050,6 @@ void BfExprEvaluator::Visit(BfCollectionInitializerExpression* arrayInitExpr)
|
|||
mModule->Fail("Collection initializer not usable here", arrayInitExpr);
|
||||
}
|
||||
|
||||
void BfExprEvaluator::Visit(BfParamsExpression* paramsExpr)
|
||||
{
|
||||
mModule->Fail("Params expression is only usable as a call parameter", paramsExpr);
|
||||
}
|
||||
|
||||
void BfExprEvaluator::Visit(BfTypeOfExpression* typeOfExpr)
|
||||
{
|
||||
auto typeType = mModule->ResolveTypeDef(mModule->mCompiler->mTypeTypeDef);
|
||||
|
|
|
@ -420,7 +420,6 @@ public:
|
|||
virtual void Visit(BfMixinExpression* mixinExpr) override;
|
||||
virtual void Visit(BfSizedArrayCreateExpression* createExpr) override;
|
||||
virtual void Visit(BfCollectionInitializerExpression* initExpr) override;
|
||||
virtual void Visit(BfParamsExpression* paramsExpr) override;
|
||||
virtual void Visit(BfTypeOfExpression* typeOfExpr) override;
|
||||
virtual void Visit(BfSizeOfExpression* sizeOfExpr) override;
|
||||
virtual void Visit(BfAlignOfExpression* alignOfExpr) override;
|
||||
|
|
|
@ -1462,13 +1462,6 @@ void BfPrinter::Visit(BfParameterDeclaration* paramDecl)
|
|||
Visit(paramDecl->ToBase());
|
||||
}
|
||||
|
||||
void BfPrinter::Visit(BfParamsExpression* paramsExpr)
|
||||
{
|
||||
Visit(paramsExpr->ToBase());
|
||||
|
||||
VisitChild(paramsExpr->mParamsToken);
|
||||
}
|
||||
|
||||
void BfPrinter::Visit(BfTypeOfExpression* typeOfExpr)
|
||||
{
|
||||
Visit(typeOfExpr->ToBase());
|
||||
|
|
|
@ -147,7 +147,6 @@ public:
|
|||
virtual void Visit(BfNullableTypeRef* typeRef) override;
|
||||
virtual void Visit(BfVariableDeclaration* varDecl) override;
|
||||
virtual void Visit(BfParameterDeclaration* paramDecl) override;
|
||||
virtual void Visit(BfParamsExpression* paramsExpr) override;
|
||||
virtual void Visit(BfTypeOfExpression* typeOfExpr) override;
|
||||
virtual void Visit(BfSizeOfExpression* sizeOfExpr) override;
|
||||
virtual void Visit(BfDefaultExpression* defaultExpr) override;
|
||||
|
|
|
@ -140,6 +140,29 @@ namespace Tests
|
|||
ca.TestLambda();
|
||||
}
|
||||
|
||||
public static void Modify(ref int a, ref Splattable b)
|
||||
{
|
||||
a += 1000;
|
||||
b.mA += 2000;
|
||||
b.mB += 3000;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public static void TestRefs()
|
||||
{
|
||||
delegate void(ref int a, ref Splattable b) dlg = scope => Modify;
|
||||
|
||||
int a = 123;
|
||||
Splattable splat = .();
|
||||
splat.mA = 234;
|
||||
splat.mB = 345;
|
||||
|
||||
dlg(ref a, ref splat);
|
||||
Test.Assert(a == 1123);
|
||||
Test.Assert(splat.mA == 2234);
|
||||
Test.Assert(splat.mB == 3345);
|
||||
}
|
||||
|
||||
public static void TestCasting()
|
||||
{
|
||||
delegate int(int, int) dlg0 = null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue