From 47ba6bf1100fe1da8d80607053d88cfd2abe25ff Mon Sep 17 00:00:00 2001 From: Tuowen Zhao Date: Sat, 24 Sep 2016 10:39:43 -0600 Subject: added precedence to operators --- src/chillASTs.cc | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'src/chillASTs.cc') diff --git a/src/chillASTs.cc b/src/chillASTs.cc index 170e481..3665571 100644 --- a/src/chillASTs.cc +++ b/src/chillASTs.cc @@ -3660,13 +3660,11 @@ void chillAST_CStyleCastExpr::print(int indent, FILE *fp) { subexpr->print(0, fp); fprintf(fp, "f"); } else { // general case - fprintf(fp, "((%s) ", towhat); - //fprintf(fp, "\ntowhat '%s'\n", towhat ); - + fprintf(fp, "(%s) ", towhat); + if (subexpr->getPrec()isVarDecl()) fprintf(fp, "%s", ((chillAST_VarDecl *) subexpr)->varname); else subexpr->print(indent, fp); - //fprintf(fp, "subexpr '%s' ", subexpr->getTypeString()); - fprintf(fp, ")"); + if (subexpr->getPrec()=0;--i) + if (opInSet(unaryPrec[i],op)) return INT8_MAX+i+1; + else + for (int i = 0;i<3;--i) + if (opInSet(unaryPrec[i],op)) return INT8_MAX+i+1; + return INT8_MAX; +} -- cgit v1.2.3-70-g09d2