Package dk.brics.string.intermediate

Examples of dk.brics.string.intermediate.Variable


    assignAnyValue(result);
    corruptIfMutable(result);
  }
 
  private Variable handlePhantomInvocation(InvokeExpr exp, List<Variable> arguments) {
      Variable result = makeVariable(getType(exp.getType()));
      for (Variable arg : arguments) {
          corruptIfMutable(arg);
      }
        assignAnyValue(result);
        corruptIfMutable(result);
View Full Code Here


   * <p/>
   * Cannot currently be handled by method call translators, because it is
   * really <tt>Object.clone()</tt> being called, followed by a typecast (which is invisible in Java).
   */
  private Variable handleArrayClone(Variable callee) {
    Variable result = factory.createVariable(VariableType.ARRAY);
    factory.addStatement(new ArrayAddAll(result, callee));
    return result;
  }
View Full Code Here

        Type elementType = type;
        while (elementType instanceof ArrayType) {
            elementType = ((ArrayType)elementType).getElementType();
        }
       
        Variable var = makeVariable(VariableType.ARRAY);
        if (elementType instanceof RefType) {
            // object arrays are filled with null initially
            addStatement(new ArrayWriteElement(var, makeConstantStringVariable("null")));
        } else {
            // primitive arrays are filled zeros initially
View Full Code Here

    return factory.getParameter(v);
  }
 
  @Override
  public Variable caseStaticInvokeExpr(StaticInvokeExpr v, ValueBox box) {
      Variable result = null;
     
      // find the static string return type, if it has one
      Automaton staticReturn = factory.getMethodReturnType(v.getMethod());
      if (staticReturn != null) {
          result = makeAutomatonVariable(staticReturn);
      }
     
    // evaluate all arguments
    List<Variable> arguments = new ArrayList<Variable>();
    for (int i=0; i<v.getArgCount(); i++) {
      arguments.add(translateExpression(v.getArgBox(i)));
    }
       
    // translate the method call (if possible)
    Variable goodResult = methodCallTranslator.translateStaticMethodCall(v, arguments, factory);
    if (result == null) {
        result = goodResult;
    }
    if (goodResult != null) {
      return result;
View Full Code Here

    return makeConstantStringVariable(v.value);
  }
 
  @Override
  public Variable caseIntConstant(IntConstant v, ValueBox question) {
      Variable result = makeVariable(VariableType.PRIMITIVE);
      if (v.value >= Character.MIN_VALUE && v.value <= Character.MAX_VALUE) {
          addStatement(new PrimitiveInit(result, Automaton.makeChar((char)v.value)));
      } else {
          addStatement(new PrimitiveInit(result, Automaton.makeAnyChar()));
      }
View Full Code Here

      }
      return result;
  }
  @Override
  public Variable caseLongConstant(LongConstant v, ValueBox question) {
    Variable result = makeVariable(VariableType.PRIMITIVE);
      if (v.value >= Character.MIN_VALUE && v.value <= Character.MAX_VALUE) {
          addStatement(new PrimitiveInit(result, Automaton.makeChar((char)v.value)));
      } else {
          addStatement(new PrimitiveInit(result, Automaton.makeAnyChar()));
      }
View Full Code Here

            if (staticType != null) {
                return makeAutomatonVariable(staticType);
            }
        }
       
        Variable result = fieldReferenceTranslator.translateFieldRef(v, box, factory);
        if (result != null) {
            return result;
        }
       
        result = getAnyValueOf(type);
View Full Code Here

  }
  public void caseIdentityStmt(IdentityStmt stmt) {
    assignment(stmt);
  }
  public void assignment(DefinitionStmt stmt) {
    Variable result = translateExpression(stmt.getRightOpBox());
   
    if (result.getType() == VariableType.NONE) {
      return; // no need to track this object
    }
   
    // assign to a local variable?
    if (stmt.getLeftOp() instanceof Local) {
      Variable lefthandSide = factory.getLocal((Local)stmt.getLeftOp());
      assignValue(lefthandSide, result);
   
    // assign to a field?
    } else if (stmt.getLeftOp() instanceof FieldRef) {
      FieldRef ref = (FieldRef)stmt.getLeftOp();
     
      // delegate the translation
      fieldReferenceTranslator.translateFieldAssignment(ref, result, factory);
   
    // assign into an array slot?
    } else if (stmt.getLeftOp() instanceof ArrayRef) {
      ArrayRef left = (ArrayRef)stmt.getLeftOp();
      Value array = left.getBase();
      if (array instanceof Local) {
        Local arrayLocal = (Local)array;
        Variable arrayVariable = factory.getLocal(arrayLocal);
       
        switch (result.getType()) {
        case STRING:
        case PRIMITIVE:
          addStatement(new ArrayWriteElement(arrayVariable, result));
View Full Code Here

 
  public void caseInvokeStmt(InvokeStmt stmt) {
    translateExpression(stmt.getInvokeExprBox());
  }
  public void caseReturnStmt(ReturnStmt stmt) {
    Variable returnValue = translateExpression(stmt.getOpBox());
    addStatement(new Return(returnValue));
  }
View Full Code Here

 
  public Variable translateAbstractMethodCall(InstanceInvokeExpr expr,
      SootMethod target, Variable callee, List<Variable> arguments,
      IntermediateFactory factory) {
    for (MethodCallTranslator child : children) {
      Variable r = child.translateAbstractMethodCall(expr, target, callee, arguments, factory);
      if (r != null)
        return r;
    }
    return null;
  }
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.