mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-14 08:30:50 +00:00
Remove IsUnary() and IsBinary()
- This information is already stored in the node's NodeType field, so there's no reason to go do a table lookup for it elsewhere. Must have been a brain fart when I wrote them in the first place.
This commit is contained in:
parent
16fc9be411
commit
b66de4116d
4 changed files with 47 additions and 60 deletions
|
@ -226,11 +226,11 @@ PSymbolConst *ZCCCompiler::CompileConstant(ZCC_ConstantDef *def)
|
||||||
|
|
||||||
ZCC_Expression *ZCCCompiler::Simplify(ZCC_Expression *root)
|
ZCC_Expression *ZCCCompiler::Simplify(ZCC_Expression *root)
|
||||||
{
|
{
|
||||||
if (IsUnaryOp(root->Operation))
|
if (root->NodeType == AST_ExprUnary)
|
||||||
{
|
{
|
||||||
return SimplifyUnary(static_cast<ZCC_ExprUnary *>(root));
|
return SimplifyUnary(static_cast<ZCC_ExprUnary *>(root));
|
||||||
}
|
}
|
||||||
else if (IsBinaryOp(root->Operation))
|
else if (root->NodeType == AST_ExprBinary)
|
||||||
{
|
{
|
||||||
return SimplifyBinary(static_cast<ZCC_ExprBinary *>(root));
|
return SimplifyBinary(static_cast<ZCC_ExprBinary *>(root));
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
ZCC_OpInfoType ZCC_OpInfo[PEX_COUNT_OF] =
|
ZCC_OpInfoType ZCC_OpInfo[PEX_COUNT_OF] =
|
||||||
{
|
{
|
||||||
#define xx(a,n) { n, #a, NULL },
|
#define xx(a,z) { #a, NULL },
|
||||||
#include "zcc_exprlist.h"
|
#include "zcc_exprlist.h"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,57 +1,57 @@
|
||||||
// Name n-ary
|
// Name n-ary
|
||||||
xx(Nil, 0)
|
xx(Nil, )
|
||||||
|
|
||||||
xx(ID, 0)
|
xx(ID, )
|
||||||
xx(Super, 0)
|
xx(Super, )
|
||||||
xx(Self, 0)
|
xx(Self, )
|
||||||
xx(ConstValue, 0)
|
xx(ConstValue, )
|
||||||
xx(FuncCall, 0)
|
xx(FuncCall, )
|
||||||
xx(ArrayAccess, 0)
|
xx(ArrayAccess, )
|
||||||
xx(MemberAccess, 0)
|
xx(MemberAccess, )
|
||||||
xx(TypeRef, 0)
|
xx(TypeRef, )
|
||||||
|
|
||||||
xx(PostInc, 1)
|
xx(PostInc, )
|
||||||
xx(PostDec, 1)
|
xx(PostDec, )
|
||||||
|
|
||||||
xx(PreInc, 1)
|
xx(PreInc, )
|
||||||
xx(PreDec, 1)
|
xx(PreDec, )
|
||||||
xx(Negate, 1)
|
xx(Negate, )
|
||||||
xx(AntiNegate, 1)
|
xx(AntiNegate, )
|
||||||
xx(BitNot, 1)
|
xx(BitNot, )
|
||||||
xx(BoolNot, 1)
|
xx(BoolNot, )
|
||||||
xx(SizeOf, 1)
|
xx(SizeOf, )
|
||||||
xx(AlignOf, 1)
|
xx(AlignOf, )
|
||||||
|
|
||||||
xx(Add, 2)
|
xx(Add, )
|
||||||
xx(Sub, 2)
|
xx(Sub, )
|
||||||
xx(Mul, 2)
|
xx(Mul, )
|
||||||
xx(Div, 2)
|
xx(Div, )
|
||||||
xx(Mod, 2)
|
xx(Mod, )
|
||||||
xx(Pow, 2)
|
xx(Pow, )
|
||||||
xx(CrossProduct, 2)
|
xx(CrossProduct, )
|
||||||
xx(DotProduct, 2)
|
xx(DotProduct, )
|
||||||
xx(LeftShift, 2)
|
xx(LeftShift, )
|
||||||
xx(RightShift, 2)
|
xx(RightShift, )
|
||||||
xx(Concat, 2)
|
xx(Concat, )
|
||||||
|
|
||||||
xx(LT, 2)
|
xx(LT, )
|
||||||
xx(LTEQ, 2)
|
xx(LTEQ, )
|
||||||
xx(LTGTEQ, 2)
|
xx(LTGTEQ, )
|
||||||
xx(Is, 2)
|
xx(Is, )
|
||||||
|
|
||||||
xx(EQEQ, 2)
|
xx(EQEQ, )
|
||||||
xx(APREQ, 2)
|
xx(APREQ, )
|
||||||
|
|
||||||
xx(BitAnd, 2)
|
xx(BitAnd, )
|
||||||
xx(BitOr, 2)
|
xx(BitOr, )
|
||||||
xx(BitXor, 2)
|
xx(BitXor, )
|
||||||
xx(BoolAnd, 2)
|
xx(BoolAnd, )
|
||||||
xx(BoolOr, 2)
|
xx(BoolOr, )
|
||||||
|
|
||||||
xx(Scope, 0)
|
xx(Scope, )
|
||||||
|
|
||||||
xx(Trinary, 2)
|
xx(Trinary, )
|
||||||
|
|
||||||
xx(Cast, 1)
|
xx(Cast, )
|
||||||
|
|
||||||
#undef xx
|
#undef xx
|
||||||
|
|
|
@ -476,8 +476,6 @@ struct ZCC_OpProto
|
||||||
|
|
||||||
struct ZCC_OpInfoType
|
struct ZCC_OpInfoType
|
||||||
{
|
{
|
||||||
BYTE Nary:2; // n-ary-ness of operator
|
|
||||||
|
|
||||||
const char *OpName;
|
const char *OpName;
|
||||||
ZCC_OpProto *Protos;
|
ZCC_OpProto *Protos;
|
||||||
|
|
||||||
|
@ -497,17 +495,6 @@ void ZCC_InitOperators();
|
||||||
|
|
||||||
extern ZCC_OpInfoType ZCC_OpInfo[PEX_COUNT_OF];
|
extern ZCC_OpInfoType ZCC_OpInfo[PEX_COUNT_OF];
|
||||||
|
|
||||||
static inline bool IsUnaryOp(EZCCExprType op)
|
|
||||||
{
|
|
||||||
assert((unsigned)op < (unsigned)PEX_COUNT_OF);
|
|
||||||
return ZCC_OpInfo[op].Nary == 1;
|
|
||||||
}
|
|
||||||
static inline bool IsBinaryOp(EZCCExprType op)
|
|
||||||
{
|
|
||||||
assert((unsigned)op < (unsigned)PEX_COUNT_OF);
|
|
||||||
return ZCC_OpInfo[op].Nary == 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ZCC_AST
|
struct ZCC_AST
|
||||||
{
|
{
|
||||||
ZCC_AST() : TopNode(NULL) {}
|
ZCC_AST() : TopNode(NULL) {}
|
||||||
|
|
Loading…
Reference in a new issue