Exemplo n.º 1
0
  /**
   * Generate a default assignment with 'local' as left-hand-side value.
   *
   * @param local
   * @return
   */
  private Unit createCorrectDummyAssignment(Local local) {
    Unit dummyAssignemnt = null;
    if (local.getType() instanceof PrimType) {
      if (local.getType() instanceof IntType) {
        StaticInvokeExpr sie =
            Instrumentation.createJimpleStaticInvokeExpr(Settings.SANITIZER, "dummyInteger", null);
        dummyAssignemnt = Jimple.v().newAssignStmt(local, sie);
      } else if (local.getType() instanceof BooleanType) {
        StaticInvokeExpr sie =
            Instrumentation.createJimpleStaticInvokeExpr(Settings.SANITIZER, "dummyBoolean", null);
        dummyAssignemnt = Jimple.v().newAssignStmt(local, sie);
      } else if (local.getType() instanceof ByteType) {
        StaticInvokeExpr sie =
            Instrumentation.createJimpleStaticInvokeExpr(Settings.SANITIZER, "dummyByte", null);
        dummyAssignemnt = Jimple.v().newAssignStmt(local, sie);
      } else if (local.getType() instanceof CharType) {
        StaticInvokeExpr sie =
            Instrumentation.createJimpleStaticInvokeExpr(
                Settings.SANITIZER, "dummyCharacter", null);
        dummyAssignemnt = Jimple.v().newAssignStmt(local, sie);
      } else if (local.getType() instanceof DoubleType) {
        StaticInvokeExpr sie =
            Instrumentation.createJimpleStaticInvokeExpr(Settings.SANITIZER, "dummyDouble", null);
        dummyAssignemnt = Jimple.v().newAssignStmt(local, sie);
      } else if (local.getType() instanceof FloatType) {
        StaticInvokeExpr sie =
            Instrumentation.createJimpleStaticInvokeExpr(Settings.SANITIZER, "dummyFloat", null);
        dummyAssignemnt = Jimple.v().newAssignStmt(local, sie);
      } else if (local.getType() instanceof LongType) {
        StaticInvokeExpr sie =
            Instrumentation.createJimpleStaticInvokeExpr(Settings.SANITIZER, "dummyLong", null);
        dummyAssignemnt = Jimple.v().newAssignStmt(local, sie);
      } else if (local.getType() instanceof ShortType) {
        StaticInvokeExpr sie =
            Instrumentation.createJimpleStaticInvokeExpr(Settings.SANITIZER, "dummyShort", null);
        dummyAssignemnt = Jimple.v().newAssignStmt(local, sie);
      } else throw new RuntimeException("Oops, the primitive type is not correct");
    } else {
      if (local.getType().equals(RefType.v("java.lang.String")))
        dummyAssignemnt = Jimple.v().newAssignStmt(local, StringConstant.v(""));
      else dummyAssignemnt = Jimple.v().newAssignStmt(local, NullConstant.v());
    }

    return dummyAssignemnt;
  }
Exemplo n.º 2
0
 public void outANullConstant(ANullConstant node) {
   mProductions.addLast(NullConstant.v());
 }