public Object visitStmtVarDecl(StmtVarDecl stmt) { // Make sure the variable declaration stays first. This will // have no initializers, except for where there is an array // initializer. ArrayList newInits = new ArrayList(stmt.getNumVars()); for (int i = 0; i < stmt.getNumVars(); i++) { // if (stmt.getInit(i) instanceof ExprArrayInit) { // newInits.add(stmt.getInit(i)); // } else { newInits.add(null); // } } Statement newDecl = new StmtVarDecl(stmt, stmt.getTypes(), stmt.getNames(), newInits); addStatement(newDecl); // Now go through the original statement; if there are // any initializers, create a new assignment statement. for (int i = 0; i < stmt.getNumVars(); i++) { String name = stmt.getName(i); Expression init = stmt.getInit(i); // don't separate array initializations, because it become // illegal syntax if (init != null) // && !(init instanceof ExprArrayInit)) { Statement assign = new StmtAssign(new ExprVar(stmt, name), init); addStatement(assign); } } // Already added the base statement. return null; }
public Object visitStmtVarDecl(StmtVarDecl stmt) { Object result = super.visitStmtVarDecl(stmt); for (int i = 0; i < stmt.getNumVars(); i++) { Expression ie = stmt.getInit(i); if (ie != null) { Type rt = getType(ie); Type ftype = matchTypes(stmt, stmt.getName(i), (stmt.getType(i)), rt); upgradeStarToInt(ie, ftype); } } return result; }