@Override
  public Object executeFunction() {
    Matcher conc_matcher = (Matcher) this.getConcReceiver();
    NonNullReference symb_matcher = (NonNullReference) this.getSymbReceiver();
    boolean res = this.getConcBooleanRetVal();

    String conc_regex = conc_matcher.pattern().pattern();
    StringValue symb_input =
        (StringValue)
            env.heap.getField(
                Types.JAVA_UTIL_REGEX_MATCHER,
                SymbolicHeap.$MATCHER_INPUT,
                conc_matcher,
                symb_matcher);

    if (symb_input != null && symb_input.containsSymbolicVariable()) {
      int concrete_value = res ? 1 : 0;
      StringConstant symb_regex = ExpressionFactory.buildNewStringConstant(conc_regex);
      StringBinaryComparison strComp =
          new StringBinaryComparison(
              symb_regex, Operator.PATTERNMATCHES, symb_input, (long) concrete_value);

      return strComp;
    } else {
      return this.getSymbIntegerRetVal();
    }
  }
  @Override
  public Object executeFunction() {
    String conc_string = (String) this.getConcArgument(0);
    NonNullReference str_ref = (NonNullReference) this.getSymbArgument(0);

    StringValue symb_string =
        this.env.heap.getField(
            Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_string, str_ref, conc_string);

    if (symb_string.containsSymbolicVariable()) {

      NonNullReference symb_big_integer = (NonNullReference) env.topFrame().operandStack.peekRef();

      BigInteger bigInteger = new BigInteger(conc_string);
      long concVal = bigInteger.longValue();

      StringToIntegerCast big_integer_value = new StringToIntegerCast(symb_string, concVal);

      env.heap.putField(
          Types.JAVA_MATH_BIG_INTEGER,
          SymbolicHeap.$BIG_INTEGER_CONTENTS,
          null /* conc_big_integer */,
          symb_big_integer,
          big_integer_value);
    }

    // return void
    return null;
  }
  @Override
  public Object executeFunction() {

    ReferenceConstant symb_receiver = (ReferenceConstant) this.getSymbReceiver();
    String conc_receiver = (String) this.getConcReceiver();
    StringValue stringReceiverExpr =
        env.heap.getField(
            Types.JAVA_LANG_STRING,
            SymbolicHeap.$STRING_VALUE,
            conc_receiver,
            symb_receiver,
            conc_receiver);

    IntegerValue ignoreCaseExpr = new IntegerConstant(0);
    IntegerValue toffsetExpr = this.getSymbIntegerArgument(0);

    ReferenceConstant symb_other = (ReferenceConstant) this.getSymbArgument(1);
    String conc_other = (String) this.getConcArgument(1);
    StringValue otherExpr =
        env.heap.getField(
            Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_other, symb_other, conc_other);
    IntegerValue ooffsetExpr = this.getSymbIntegerArgument(2);
    IntegerValue lenExpr = this.getSymbIntegerArgument(3);

    boolean res = this.getConcBooleanRetVal();
    if (stringReceiverExpr.containsSymbolicVariable()
        || ignoreCaseExpr.containsSymbolicVariable()
        || toffsetExpr.containsSymbolicVariable()
        || otherExpr.containsSymbolicVariable()
        || ooffsetExpr.containsSymbolicVariable()
        || lenExpr.containsSymbolicVariable()) {

      ArrayList<Expression<?>> other = new ArrayList<Expression<?>>();
      other.add(toffsetExpr);
      other.add(ooffsetExpr);
      other.add(lenExpr);
      other.add(ignoreCaseExpr);
      int conV = res ? 1 : 0;

      StringMultipleComparison strComp =
          new StringMultipleComparison(
              stringReceiverExpr, Operator.REGIONMATCHES, otherExpr, other, (long) conV);

      return strComp;
    }

    return this.getSymbIntegerRetVal();
  }
  @Override
  public Object executeFunction() {

    NonNullReference symb_str_reader = this.getSymbReceiver();
    StringReader conc_str_reader = (StringReader) this.getConcReceiver();

    StringReaderExpr stringReaderExpr =
        (StringReaderExpr)
            env.heap.getField(
                Types.JAVA_IO_STRING_READER,
                SymbolicHeap.$STRING_READER_VALUE,
                conc_str_reader,
                symb_str_reader);

    if (stringReaderExpr != null && stringReaderExpr.containsSymbolicVariable()) {

      StringValue symb_string = stringReaderExpr.getString();
      String conc_string = symb_string.getConcreteValue();

      int currPosition = stringReaderExpr.getReaderPosition();

      if (currPosition < conc_string.length()) {
        // update symbolic string reader
        currPosition++;

        int conc_string_reader_value;
        if (currPosition >= conc_string.length()) {
          conc_string_reader_value = -1;
        } else {
          conc_string_reader_value = conc_string.charAt(currPosition);
        }

        StringReaderExpr newStringReaderExpr =
            new StringReaderExpr((long) conc_string_reader_value, symb_string, currPosition);
        env.heap.putField(
            Types.JAVA_IO_STRING_READER,
            SymbolicHeap.$STRING_READER_VALUE,
            conc_str_reader,
            symb_str_reader,
            newStringReaderExpr);
      }

      // returns STRING_READER(string,currPosition)
      return stringReaderExpr;
    }
    return this.getSymbIntegerRetVal();
  }
Exemple #5
0
  @Override
  public Object executeFunction() {

    String conc_str = (String) this.getConcReceiver();
    NonNullReference symb_str = this.getSymbReceiver();
    StringValue string_expr =
        env.heap.getField(
            Types.JAVA_LANG_STRING, SymbolicHeap.$STRING_VALUE, conc_str, symb_str, conc_str);

    IntegerValue index_expr = this.getSymbIntegerArgument(0);
    char res = this.getConcCharRetVal();

    if (string_expr.containsSymbolicVariable() || index_expr.containsSymbolicVariable()) {

      StringBinaryToIntegerExpression strBExpr =
          new StringBinaryToIntegerExpression(string_expr, Operator.CHARAT, index_expr, (long) res);

      return strBExpr;

    } else {
      return this.getSymbIntegerRetVal();
    }
  }