mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-15 23:04:09 +02:00
Fixed invalid const binop resolution for non-simple consts
This commit is contained in:
parent
c0d6db0824
commit
8280cdba56
1 changed files with 109 additions and 95 deletions
|
@ -48,6 +48,8 @@ USING_NS_BF;
|
|||
auto constRHS = GetConstantById(rhs.mId); \
|
||||
if (constLHS->mConstType == BfConstType_Undef) return lhs; \
|
||||
if (constRHS->mConstType == BfConstType_Undef) return rhs; \
|
||||
if ((constLHS->mTypeCode < BfTypeCode_Length) && (constRHS->mTypeCode < BfTypeCode_Length)) \
|
||||
{ \
|
||||
BF_ASSERT(constLHS->mTypeCode == constRHS->mTypeCode); \
|
||||
uint64 val = 0; \
|
||||
switch (constLHS->mTypeCode) \
|
||||
|
@ -69,13 +71,16 @@ USING_NS_BF;
|
|||
return CreateConst(constLHS->mTypeCode, OP(constLHS->mDouble, constRHS->mDouble)); break; \
|
||||
default: break; \
|
||||
} \
|
||||
return CreateConst(constLHS->mTypeCode, val);
|
||||
return CreateConst(constLHS->mTypeCode, val); \
|
||||
}
|
||||
|
||||
#define INT_BINOPFUNC_APPLY(lhs, rhs, OP) \
|
||||
auto constLHS = GetConstantById(lhs.mId); \
|
||||
auto constRHS = GetConstantById(rhs.mId); \
|
||||
if (constLHS->mConstType == BfConstType_Undef) return lhs; \
|
||||
if (constRHS->mConstType == BfConstType_Undef) return rhs; \
|
||||
if ((constLHS->mTypeCode < BfTypeCode_Length) && (constRHS->mTypeCode < BfTypeCode_Length)) \
|
||||
{ \
|
||||
BF_ASSERT(constLHS->mTypeCode == constRHS->mTypeCode); \
|
||||
uint64 val = 0; \
|
||||
switch (constLHS->mTypeCode) \
|
||||
|
@ -94,14 +99,16 @@ USING_NS_BF;
|
|||
case BfTypeCode_UInt64: val = OP(constLHS->mUInt64, constRHS->mUInt64); break; \
|
||||
default: break; \
|
||||
} \
|
||||
return CreateConst(constLHS->mTypeCode, val);
|
||||
|
||||
return CreateConst(constLHS->mTypeCode, val); \
|
||||
}
|
||||
|
||||
#define BINOP_APPLY(lhs, rhs, OP) \
|
||||
auto constLHS = GetConstantById(lhs.mId); \
|
||||
auto constRHS = GetConstantById(rhs.mId); \
|
||||
if (constLHS->mConstType == BfConstType_Undef) return lhs; \
|
||||
if (constRHS->mConstType == BfConstType_Undef) return rhs; \
|
||||
if ((constLHS->mTypeCode < BfTypeCode_Length) && (constRHS->mTypeCode < BfTypeCode_Length)) \
|
||||
{ \
|
||||
BF_ASSERT(constLHS->mTypeCode == constRHS->mTypeCode); \
|
||||
uint64 val = 0; \
|
||||
switch (constLHS->mTypeCode) \
|
||||
|
@ -123,11 +130,14 @@ USING_NS_BF;
|
|||
return CreateConst(constLHS->mTypeCode, constLHS->mDouble OP constRHS->mDouble); break; \
|
||||
default: break; \
|
||||
} \
|
||||
return CreateConst(constLHS->mTypeCode, val);
|
||||
return CreateConst(constLHS->mTypeCode, val); \
|
||||
}
|
||||
|
||||
#define INT_BINOP_APPLY(constLHS, constRHS, OP) \
|
||||
if (constLHS->mConstType == BfConstType_Undef) return lhs; \
|
||||
if (constRHS->mConstType == BfConstType_Undef) return rhs; \
|
||||
if ((constLHS->mTypeCode < BfTypeCode_Length) && (constRHS->mTypeCode < BfTypeCode_Length)) \
|
||||
{ \
|
||||
BF_ASSERT(constLHS->mTypeCode == constRHS->mTypeCode); \
|
||||
uint64 val = 0; \
|
||||
switch (constLHS->mTypeCode) \
|
||||
|
@ -144,11 +154,14 @@ USING_NS_BF;
|
|||
case BfTypeCode_Int64: return CreateConst(constLHS->mTypeCode, (uint64)(constLHS->mInt64 OP constRHS->mInt64)); \
|
||||
case BfTypeCode_UInt64: return CreateConst(constLHS->mTypeCode, constLHS->mUInt64 OP constRHS->mUInt64); \
|
||||
default: break; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define UNARYOP_APPLY(val, OP) \
|
||||
auto constVal = GetConstantById(val.mId); \
|
||||
if (constVal->mConstType == BfConstType_Undef) return val; \
|
||||
if (constVal->mTypeCode < BfTypeCode_Length) \
|
||||
{ \
|
||||
uint64 val = 0; \
|
||||
switch (constVal->mTypeCode) \
|
||||
{ \
|
||||
|
@ -168,7 +181,8 @@ USING_NS_BF;
|
|||
return CreateConst(constVal->mTypeCode, OP constVal->mDouble); break; \
|
||||
default: break; \
|
||||
} \
|
||||
return CreateConst(constVal->mTypeCode, val);
|
||||
return CreateConst(constVal->mTypeCode, val); \
|
||||
}
|
||||
|
||||
#define CMP_APPLY(lhs, rhs, OP) \
|
||||
auto constLHS = GetConstantById(lhs.mId); \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue