Exemplo n.º 1
0
  public Object visitStmtFor(StmtFor stmt) {

    Statement newInit = null;
    if (stmt.getInit() != null) {
      newInit = (Statement) stmt.getInit().accept(this);
    }
    if (stmt.getCond() != null) {
      stmt.getCond().accept(new UpgradeStarToInt(this, TypePrimitive.bittype, nres));
    }
    Expression newCond = stmt.getCond();
    Statement newIncr = null;
    if (stmt.getIncr() != null) {
      newIncr = (Statement) stmt.getIncr().accept(this);
    }
    Statement tmp = stmt.getBody();
    Statement newBody = StmtEmpty.EMPTY;
    if (tmp != null) {
      newBody = (Statement) tmp.accept(this);
    }

    if (newInit == stmt.getInit()
        && newCond == stmt.getCond()
        && newIncr == stmt.getIncr()
        && newBody == stmt.getBody()) return stmt;
    return new StmtFor(stmt, newInit, newCond, newIncr, newBody, stmt.isCanonical());
  }
Exemplo n.º 2
0
 private Type matchTypes(Statement stmt, String lhsn, Type lt, Type rt) {
   //    	if((lt != null && rt != null && !rt.promotesTo(lt)))
   //    	{
   //        	if((lt != null && rt != null && !rt.promotesTo(lt)))
   //        		System.out.println("CRAP");
   //    	}
   stmt.assertTrue(lt != null && rt != null, "internal error: " + lt + "   " + rt);
   stmt.assertTrue(rt.promotesTo(lt, nres), "Type mismatch " + lt + " !>= " + rt);
   return lt;
 }