Package dk.brics.string.intermediate

Examples of dk.brics.string.intermediate.Variable


    Variable v = makeVariable(VariableType.STRING);
    addStatement(new StringInit(v, Basic.makeAnyString()));
    return v;
  }
  private Variable makeConstantStringVariable(String value) {
    Variable v = makeVariable(VariableType.STRING);
    addStatement(new StringInit(v, Automaton.makeString(value)));
    return v;
  }
View Full Code Here


    Variable v = makeVariable(VariableType.STRING);
    addStatement(new StringInit(v, Automaton.makeString(value)));
    return v;
  }
    private Variable makeConstantCharVariable(char value) {
        Variable v = makeVariable(VariableType.STRING);
        addStatement(new StringInit(v, Automaton.makeChar(value)));
        return v;
    }
View Full Code Here

        Variable v = makeVariable(VariableType.STRING);
        addStatement(new StringInit(v, Automaton.makeChar(value)));
        return v;
    }
    private Variable makeAutomatonVariable(Automaton automaton) {
        Variable v = makeVariable(VariableType.STRING);
        addStatement(new StringInit(v, automaton));
        return v;
    }
View Full Code Here

   * Returns a variable that may contain any non-corrupt value of the specified type.
   */
  private Variable getAnyValueOf(VariableType type) {
    if (type == VariableType.NONE)
      return getNothing();
    Variable v = makeVariable(type);
    assignAnyValue(v);
    return v;
  }
View Full Code Here

   * directly, since this also takes care of creating hotspots.
   * @param box the jimple expression to translate
   * @return a variable holding the result
   */
  private Variable translateExpression(ValueBox box) {
    Variable result = applyTo(box.getValue(), box);
   
    if (factory.isHotspot(box)) {
        factory.addHotspot(result, box);
    }
   
View Full Code Here

  }
 
  @Override
  public Variable caseArrayRef(ArrayRef v, ValueBox box) {
    // read something from an array
    Variable arrayObject = translateExpression(v.getBaseBox());
    VariableType innerType = getType(v.getType());
   
    if (innerType == VariableType.NONE)
      return getNothing();
   
    Variable result = makeVariable(innerType);
    switch (innerType) {
    case STRINGBUFFER:
      addStatement(new StringBufferCorrupt(result));
      break;
     
View Full Code Here

    return result;
  }
 
  @Override
  public Variable caseCastExpr(CastExpr v, ValueBox box) {
    Variable operand = translateExpression(v.getOpBox());
    VariableType castTo = getType(v.getCastType());
   
    // whatever comes out of the cast must satisfy both the operand's type and the casted type
    VariableType resultType = operand.getType().greatestLowerBound(castTo);
    if (resultType == VariableType.NONE) {
      return getNothing();
    }
   
    // if a primitive cast is performed, assume nothing about the result
//    if (castTo == VariableType.PRIMITIVE) {
//      if (v.getOp().getType().equals(v.getCastType())) {
//        return operand;
//      } else {
//        return getAnyValueOf(VariableType.PRIMITIVE);
//      }
//    }
   
    // upgrade the result to the casted type
    // other parts of the translation can use the additional information
    Variable result;
    if (resultType == operand.getType()) {
      result = operand;
    } else {
      result = factory.createVariable(resultType);
      assignValue(result, operand);
View Full Code Here

    return invokeExpr(v, box);
  }
 
  @Override
  public Variable caseSpecialInvokeExpr(SpecialInvokeExpr v, ValueBox box) {
    Variable callee = translateExpression(v.getBaseBox());

    // evaluate all arguments
    List<Variable> arguments = new ArrayList<Variable>();
    for (int i=0; i<v.getArgCount(); i++) {
      arguments.add(translateExpression(v.getArgBox(i)));
    }
   
    // if the called class could not be found (ie a phantom class), treat it as a corrupt call
    if (v.getMethodRef().declaringClass().isPhantom()) {
        return handlePhantomInvocation(v, arguments);
    }
   
        SootMethod method = v.getMethod();
   
    // Is this a constructor call?
    if (method.getName().equals("<init>")) {
      return handleConstructor(v, callee, arguments);
    }
   
    // try to handle it as an abstract method call. even though we know the exact target,
    // this is the correct thing to do according to the MethodCallTranslator interface.
    Variable result = methodCallTranslator.translateAbstractMethodCall(v, method, callee, arguments, factory);
    if (result != null)
      return result;
   
    // Otherwise just handle it as a normal call with only one possible target
    result = makeVariable(getType(v.getMethod().getReturnType()));
View Full Code Here

      if (v.getMethodRef().declaringClass().isPhantom()) {
          return handlePhantomInvocation(v, arguments);
      }
   
      SootMethod method = v.getMethod();
    Variable callee = translateExpression(v.getBaseBox());
   
    // Special case: clone() on an array or collection
    if (method.getName().equals("clone") && method.getParameterCount() == 0 && callee.getType() == VariableType.ARRAY) {
      return handleArrayClone(callee);
    }
   
    // try to translate the abstract call
    Variable r2 = methodCallTranslator.translateAbstractMethodCall(v, v.getMethod(), callee, arguments, factory);
    if (r2 != null)
      return r2;
   
    // find the possible implementations that get called
    List<SootMethod> targets = factory.getTargetsOf(v);
   
    if (targets.size() == 0) {
        // try to translate the abstract method call. A resolver could know something useful.
        Variable result = methodCallTranslator.translateMethodCall(v, method, callee, arguments, factory);
       
        if (result != null)
            return result;
    }
       
        // create a variable with the result
        VariableType returnType = getType(method.getReturnType());
        Variable result = makeVariable(returnType);
       
        // split the control-flow graph for each possible target
    factory.startBranch();
   
    // if no targets can be seen, we will assume it is a corrupting call (externally implemented)
View Full Code Here

   * @param target method implementation being called; may differ from <tt>v.getMethod()</tt>.
   * @param callee variable holding the object being called on
   * @param arguments variables holding the method call's arguments
   */
  private void handleInvocationTarget(Variable result, InstanceInvokeExpr v, SootMethod target, Variable callee, List<Variable> arguments) {
    Variable goodResult = methodCallTranslator.translateMethodCall(v, target, callee, arguments, factory);
    if (goodResult != null) {
      assignValue(result, goodResult);
    } else {
      // if the method declaring the method might be an interesting mutable type,
      // corrupt the callee
View Full Code Here

TOP

Related Classes of dk.brics.string.intermediate.Variable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.