From b66de4116d8ca22b31f05b20c28f131798fb0225 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Fri, 1 Nov 2013 21:28:00 -0500 Subject: [PATCH] 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. --- src/zscript/zcc_compile.cpp | 4 +- src/zscript/zcc_expr.cpp | 2 +- src/zscript/zcc_exprlist.h | 88 ++++++++++++++++++------------------- src/zscript/zcc_parser.h | 13 ------ 4 files changed, 47 insertions(+), 60 deletions(-) diff --git a/src/zscript/zcc_compile.cpp b/src/zscript/zcc_compile.cpp index b95bc33b7f..5a3276a071 100644 --- a/src/zscript/zcc_compile.cpp +++ b/src/zscript/zcc_compile.cpp @@ -226,11 +226,11 @@ PSymbolConst *ZCCCompiler::CompileConstant(ZCC_ConstantDef *def) ZCC_Expression *ZCCCompiler::Simplify(ZCC_Expression *root) { - if (IsUnaryOp(root->Operation)) + if (root->NodeType == AST_ExprUnary) { return SimplifyUnary(static_cast(root)); } - else if (IsBinaryOp(root->Operation)) + else if (root->NodeType == AST_ExprBinary) { return SimplifyBinary(static_cast(root)); } diff --git a/src/zscript/zcc_expr.cpp b/src/zscript/zcc_expr.cpp index 3f5aec2987..da9063fc97 100644 --- a/src/zscript/zcc_expr.cpp +++ b/src/zscript/zcc_expr.cpp @@ -12,7 +12,7 @@ ZCC_OpInfoType ZCC_OpInfo[PEX_COUNT_OF] = { -#define xx(a,n) { n, #a, NULL }, +#define xx(a,z) { #a, NULL }, #include "zcc_exprlist.h" }; diff --git a/src/zscript/zcc_exprlist.h b/src/zscript/zcc_exprlist.h index cbe78ef094..e36aedea63 100644 --- a/src/zscript/zcc_exprlist.h +++ b/src/zscript/zcc_exprlist.h @@ -1,57 +1,57 @@ // Name n-ary -xx(Nil, 0) +xx(Nil, ) -xx(ID, 0) -xx(Super, 0) -xx(Self, 0) -xx(ConstValue, 0) -xx(FuncCall, 0) -xx(ArrayAccess, 0) -xx(MemberAccess, 0) -xx(TypeRef, 0) +xx(ID, ) +xx(Super, ) +xx(Self, ) +xx(ConstValue, ) +xx(FuncCall, ) +xx(ArrayAccess, ) +xx(MemberAccess, ) +xx(TypeRef, ) -xx(PostInc, 1) -xx(PostDec, 1) +xx(PostInc, ) +xx(PostDec, ) -xx(PreInc, 1) -xx(PreDec, 1) -xx(Negate, 1) -xx(AntiNegate, 1) -xx(BitNot, 1) -xx(BoolNot, 1) -xx(SizeOf, 1) -xx(AlignOf, 1) +xx(PreInc, ) +xx(PreDec, ) +xx(Negate, ) +xx(AntiNegate, ) +xx(BitNot, ) +xx(BoolNot, ) +xx(SizeOf, ) +xx(AlignOf, ) -xx(Add, 2) -xx(Sub, 2) -xx(Mul, 2) -xx(Div, 2) -xx(Mod, 2) -xx(Pow, 2) -xx(CrossProduct, 2) -xx(DotProduct, 2) -xx(LeftShift, 2) -xx(RightShift, 2) -xx(Concat, 2) +xx(Add, ) +xx(Sub, ) +xx(Mul, ) +xx(Div, ) +xx(Mod, ) +xx(Pow, ) +xx(CrossProduct, ) +xx(DotProduct, ) +xx(LeftShift, ) +xx(RightShift, ) +xx(Concat, ) -xx(LT, 2) -xx(LTEQ, 2) -xx(LTGTEQ, 2) -xx(Is, 2) +xx(LT, ) +xx(LTEQ, ) +xx(LTGTEQ, ) +xx(Is, ) -xx(EQEQ, 2) -xx(APREQ, 2) +xx(EQEQ, ) +xx(APREQ, ) -xx(BitAnd, 2) -xx(BitOr, 2) -xx(BitXor, 2) -xx(BoolAnd, 2) -xx(BoolOr, 2) +xx(BitAnd, ) +xx(BitOr, ) +xx(BitXor, ) +xx(BoolAnd, ) +xx(BoolOr, ) -xx(Scope, 0) +xx(Scope, ) -xx(Trinary, 2) +xx(Trinary, ) -xx(Cast, 1) +xx(Cast, ) #undef xx diff --git a/src/zscript/zcc_parser.h b/src/zscript/zcc_parser.h index 5dae12e780..6512ee0f77 100644 --- a/src/zscript/zcc_parser.h +++ b/src/zscript/zcc_parser.h @@ -476,8 +476,6 @@ struct ZCC_OpProto struct ZCC_OpInfoType { - BYTE Nary:2; // n-ary-ness of operator - const char *OpName; ZCC_OpProto *Protos; @@ -497,17 +495,6 @@ void ZCC_InitOperators(); 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 { ZCC_AST() : TopNode(NULL) {}