summaryrefslogtreecommitdiff
path: root/src/printer/cfamily.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/printer/cfamily.cpp')
-rw-r--r--src/printer/cfamily.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/printer/cfamily.cpp b/src/printer/cfamily.cpp
index 488c884..c328c67 100644
--- a/src/printer/cfamily.cpp
+++ b/src/printer/cfamily.cpp
@@ -59,7 +59,7 @@ void CFamily::printS(std::string ident, chillAST_BinaryOperator *n, std::ostream
if (n->getLHS()) printPrec(ident, n->getLHS(), o, prec);
else o << "(NULL)";
o << " " << n->op << " ";
- if (n->getRHS()) printPrec(ident, n->getRHS(), o, prec);
+ if (n->getRHS()) printPrec(ident, n->getRHS(), o, prec-1);
else o << "(NULL)";
}
@@ -83,32 +83,32 @@ void CFamily::printS(std::string ident, chillAST_CallExpr *n, std::ostream &o) {
FD = (chillAST_FunctionDecl *) n->getCallee();
else if (n->getCallee()->isMacroDefinition())
MD = (chillAST_MacroDefinition *) n->getCallee();
- if (FD) {
- o << FD->functionName;
+ if (MD && n->getNumChildren()-1)
+ o << "(";
+ else {
+ print(ident,n->getCallee(),o);
if (n->grid && n->block)
o << "<<<" << n->grid->varname << "," << n->block->varname << ">>>";
o << "(";
}
- if (MD && n->getNumChildren()-1)
- o << "(";
for (int i = 1; i < n->getNumChildren(); ++i) {
- if (i != 0) o << ", ";
+ if (i != 1) o << ", ";
print(ident, n->getChild(i), o);
}
- if (FD || n->getNumChildren()-1)
+ if (!MD || n->getNumChildren()-1)
o << ")";
}
void CFamily::printS(std::string ident, chillAST_CompoundStmt *n, std::ostream &o) {
chillAST_NodeList *c = n->getChildren();
string nid = ident + identSpace;
- if (c->size() > 1) o << "{";
+ if (c->size() > 1 || n->getParent()->isFunctionDecl()) o << "{";
for (int i = 0; i < c->size(); ++i) {
o << "\n" << nid;
print(nid, c->at(i), o);
if (!ifSemicolonFree(c->at(i)->getType())) o << ";";
}
- if (c->size() > 1) o << "\n" << ident << "}";
+ if (c->size() > 1 || n->getParent()->isFunctionDecl()) o << "\n" << ident << "}";
}
int CFamily::getPrecS(chillAST_CStyleAddressOf *n) {