mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
Value lifetime fix for chained conditionals
This commit is contained in:
parent
21798e20f9
commit
e8de8cd7be
2 changed files with 34 additions and 1 deletions
|
@ -7857,7 +7857,7 @@ BF_NOINLINE void BfModule::EvaluateWithNewScope(BfExprEvaluator& exprEvaluator,
|
||||||
newScope.mOuterIsConditional = true;
|
newScope.mOuterIsConditional = true;
|
||||||
newScope.mAllowTargeting = false;
|
newScope.mAllowTargeting = false;
|
||||||
mCurMethodState->AddScope(&newScope);
|
mCurMethodState->AddScope(&newScope);
|
||||||
NewScopeState();
|
NewScopeState(true, false);
|
||||||
exprEvaluator.mBfEvalExprFlags = (BfEvalExprFlags)(exprEvaluator.mBfEvalExprFlags | flags);
|
exprEvaluator.mBfEvalExprFlags = (BfEvalExprFlags)(exprEvaluator.mBfEvalExprFlags | flags);
|
||||||
exprEvaluator.Evaluate(expr, (flags & BfEvalExprFlags_PropogateNullConditional) != 0, (flags & BfEvalExprFlags_IgnoreNullConditional) != 0, (flags & BfEvalExprFlags_AllowSplat) != 0);
|
exprEvaluator.Evaluate(expr, (flags & BfEvalExprFlags_PropogateNullConditional) != 0, (flags & BfEvalExprFlags_IgnoreNullConditional) != 0, (flags & BfEvalExprFlags_AllowSplat) != 0);
|
||||||
RestoreScopeState();
|
RestoreScopeState();
|
||||||
|
|
|
@ -6,6 +6,36 @@ namespace Tests
|
||||||
{
|
{
|
||||||
class Operators
|
class Operators
|
||||||
{
|
{
|
||||||
|
struct FlagsRegister
|
||||||
|
{
|
||||||
|
public bool zero;
|
||||||
|
public bool subtract;
|
||||||
|
public bool half_carry;
|
||||||
|
public bool carry;
|
||||||
|
|
||||||
|
const uint8 ZERO_FLAG_BYTE_POSITION = 7;
|
||||||
|
const uint8 SUBTRACT_FLAG_BYTE_POSITION = 6;
|
||||||
|
const uint8 HALF_CARRY_FLAG_BYTE_POSITION = 5;
|
||||||
|
const uint8 CARRY_FLAG_BYTE_POSITION = 4;
|
||||||
|
|
||||||
|
public this(bool z, bool s, bool hc, bool c)
|
||||||
|
{
|
||||||
|
zero = z;
|
||||||
|
subtract = s;
|
||||||
|
half_carry = hc;
|
||||||
|
carry = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Convert flag register to a uint8
|
||||||
|
public static implicit operator uint8 (FlagsRegister flag)
|
||||||
|
{
|
||||||
|
return (flag.zero ? 1 : 0) << ZERO_FLAG_BYTE_POSITION |
|
||||||
|
(flag.subtract ? 1 : 0) << SUBTRACT_FLAG_BYTE_POSITION |
|
||||||
|
(flag.half_carry ? 1 : 0) << HALF_CARRY_FLAG_BYTE_POSITION |
|
||||||
|
(flag.carry ? 1 : 0) << CARRY_FLAG_BYTE_POSITION;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
struct StructA
|
struct StructA
|
||||||
{
|
{
|
||||||
public int mA;
|
public int mA;
|
||||||
|
@ -284,6 +314,9 @@ namespace Tests
|
||||||
float f = so3.Use(1, 2);
|
float f = so3.Use(1, 2);
|
||||||
Test.Assert(f == 3);
|
Test.Assert(f == 3);
|
||||||
|
|
||||||
|
FlagsRegister fr = .(true, false, true, true);
|
||||||
|
Test.Assert(fr == (uint8)0b10110000);
|
||||||
|
|
||||||
/*let oai = OuterOp<float>.InnerOp<int>.Op(1.0f, 100);
|
/*let oai = OuterOp<float>.InnerOp<int>.Op(1.0f, 100);
|
||||||
Test.Assert(oai == 101.0f);
|
Test.Assert(oai == 101.0f);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue