void operativeMachine::addAttrInNode (void) { /* NOTE : constant nodes and expression nodes (unary, binary, ternary, reference, others) haven't any attributes */ nast_code code = c_nnp->getCode (); // The code of the nast_node // What node class belong to ? // declaration nodes if (isDecl (code) || isOthrDecl (code)) addAttrInDecl (); // type nodes else if (isType (code) || isOthrType (code)) addAttrInType (); // statement nodes else if (isStmt (code) || isOthrStmt (code)) addAttrInStmt (); // other nodes else if (isOthr (code)) addAttrInOthr (); else printWarning ("operativeMachine", "The attribute doesn't belong to any node"); return; }
long stmtNumData::numStmt(nast_code code) throw (bad_data) { if ( (isStmt(code)) || (isOthrStmt(code)) || (code == CASE_LABEL) ) return counted[code]; else throw bad_data("stmtNumData", "Impossibile get the number of a stmt_n"); }
// --------------------------------------------------------------------------- // CLASS // --------------------------------------------------------------------------- void stmtNumData::addStmt(nast_code code) throw (bad_data) { if ( (isStmt(code)) || (isOthrStmt(code)) || (code == CASE_LABEL) ) counted[code]++; else throw bad_data("stmtNumData", "Impossibile add a new stmt_n"); return; }
bool Expr::isStmtExpr() const { bool retval = false; if (isStmt() == true) { retval = true; // NOAKES 2014/11/28 A WhileStmt is currently a BlockStmt // but needs special handling } else if (WhileStmt* parent = toWhileStmt(parentExpr)) { retval = (parent->condExprGet() != this) ? true : false; // NOAKES 2014/11/30 A ForLoop is currently a BlockStmt // but needs special handling } else if (ForLoop* parent = toForLoop(parentExpr)) { retval = (parent->indexGet() != this && parent->iteratorGet() != this) ? true : false; } else { retval = isDirectlyUnderBlockStmt(this); } return retval; }