Package soot

Examples of soot.ValueBox


                    .hasNext();) {
                Unit unit = (Unit) units.next();
                Iterator boxes = unit.getUseBoxes().iterator();

                while (boxes.hasNext()) {
                    ValueBox box = (ValueBox) boxes.next();
                    Value value = box.getValue();

                    if (value instanceof SpecialInvokeExpr) {
                        SpecialInvokeExpr r = (SpecialInvokeExpr) value;

                        if (PtolemyUtilities.executableInterface
                                .declaresMethod(r.getMethod().getSubSignature())) {
                            if (r.getMethod().getName().equals("prefire")
                                    || r.getMethod().getName().equals(
                                            "postfire")) {
                                box.setValue(IntConstant.v(1));
                            } else {
                                body.getUnits().remove(unit);
                            }
                        } else if (!r.getMethod().getName().equals("<init>")) {
                            System.out.println("superCall:" + r);
View Full Code Here


                if (!unit.containsInvokeExpr()) {
                    continue;
                }

                ValueBox box = unit.getInvokeExprBox();
                Value value = box.getValue();

                if (value instanceof InstanceInvokeExpr) {
                    InstanceInvokeExpr r = (InstanceInvokeExpr) value;

                    if (r.getMethod().getSubSignature().equals(_getDirectorSig)) {
                        // Replace calls to getDirector with
                        // null.  FIXME: we should be able to
                        // do better than this?
                        if (unit instanceof InvokeStmt) {
                            body.getUnits().remove(unit);
                        } else {
                            box.setValue(NullConstant.v());
                        }
                    } else if (r.getMethod().getSubSignature().equals(
                            _getAttributeSig)) {
                        if (unit instanceof InvokeStmt) {
                            body.getUnits().remove(unit);
View Full Code Here

                    if (!unit.containsInvokeExpr()) {
                        continue;
                    }

                    ValueBox box = unit.getInvokeExprBox();
                    InvokeExpr r = (InvokeExpr) box.getValue();

                    if (r.getMethod().getSubSignature().equals(
                            PtolemyUtilities.invalidateResolvedTypesMethod
                                    .getSubSignature())) {
                        // Remove calls to invalidateResolvedTypes()
View Full Code Here

                if (!unit.containsInvokeExpr()) {
                    continue;
                }

                ValueBox box = unit.getInvokeExprBox();
                Value value = box.getValue();

                if (value instanceof InstanceInvokeExpr) {
                    InstanceInvokeExpr r = (InstanceInvokeExpr) value;

                    if (r.getMethod().getSubSignature().equals(
                            PtolemyUtilities.getPortMethod.getSubSignature())) {
                        if (_debug) {
                            System.out.println("replacing getPort in " + unit);
                        }

                        // Inline calls to getPort(arg) when
                        // arg is a string that can be
                        // statically evaluated.
                        Value nameValue = r.getArg(0);

                        if (Evaluator.isValueConstantValued(nameValue)) {
                            StringConstant nameConstant = (StringConstant) Evaluator
                                    .getConstantValueOf(nameValue);
                            String name = nameConstant.value;

                            // perform type analysis to determine what the
                            // type of the base is.
                            Local baseLocal = (Local) r.getBase();
                            Value newFieldRef = _createPortField(baseLocal,
                                    name, unit, localDefs);

                            if (unit instanceof AssignStmt) {
                                box.setValue(newFieldRef);
                            } else {
                                body.getUnits().remove(unit);
                            }
                        } else {
                            String string = "Port cannot be "
View Full Code Here

                if (!unit.containsInvokeExpr()) {
                    continue;
                }

                ValueBox box = unit.getInvokeExprBox();
                Value value = box.getValue();

                if (value instanceof InstanceInvokeExpr) {
                    InstanceInvokeExpr r = (InstanceInvokeExpr) value;

                    if (r.getMethod().getSubSignature().equals(
                            PtolemyUtilities.getContainerMethod
                                    .getSubSignature())) {
                        Value newFieldRef = _getContainerMethodReplacementFieldRef(
                                theClass, (Local) r.getBase(), body, unit,
                                localDefs);
                        box.setValue(newFieldRef);

                        if (_debug) {
                            System.out.println("replacing " + unit);
                        }
                    } else if (r.getMethod().equals(
                            PtolemyUtilities.toplevelMethod)) {
                        // Replace with reference to the toplevel
                        Value newFieldRef = getLocalReferenceForEntity(_model,
                                theClass, body.getThisLocal(), body, unit,
                                _options);
                        box.setValue(newFieldRef);

                        if (_debug) {
                            System.out.println("replacing " + unit);
                        }
                    } else if (r.getMethod().getSubSignature().equals(
                            PtolemyUtilities.getEntityMethod.getSubSignature())) {
                        Value nameValue = r.getArg(0);

                        if (Evaluator.isValueConstantValued(nameValue)) {
                            StringConstant nameConstant = (StringConstant) Evaluator
                                    .getConstantValueOf(nameValue);
                            String name = nameConstant.value;

                            if (_debug) {
                                System.out.println("replacing " + unit);
                            }

                            Value newFieldRef = _getEntityMethodReplacementValue(
                                    theClass, (Local) r.getBase(), name, body,
                                    unit, localDefs);
                            box.setValue(newFieldRef);

                            if (_debug) {
                                System.out.println("replacing " + unit);
                            }
                        } else {
View Full Code Here

                if (!stmt.containsInvokeExpr()) {
                    continue;
                }

                ValueBox box = stmt.getInvokeExprBox();
                Value value = box.getValue();

                if (value instanceof InstanceInvokeExpr) {
                    InstanceInvokeExpr expr = (InstanceInvokeExpr) value;

                    if (expr.getMethod().equals(mainStartRunMethod)) {
View Full Code Here

       
        long time2 = System.currentTimeMillis();
       
        // report results for runtime hotspots
        for (RuntimeHotspot rh : runtimeHotspots) {
            ValueBox e = rh.spot;
            String sf = sa.getSourceFile(e);
            int line = sa.getLineNumber(e);
            String kind = "";
            if (rh.kind == HotspotKind.ANALYZE) {
                kind = "Strings.analyze()";
View Full Code Here

            if (u instanceof Stmt) {
              Stmt stmt = (Stmt)u;
              List boxes = stmt.getUseAndDefBoxes();
              for (Object o : boxes) {
                if (o instanceof ValueBox) {
                  ValueBox box = (ValueBox)o;
                  boxStmtMap.put(box,stmt);
                }
              }
            }
          }
View Full Code Here

  }
 
  private void handleAnalyzeRuntimeHotspots(RuntimeResolver rr) {
    List<RuntimeHotspot> runtime_hotspots = rr.getHotspots();
    for (RuntimeHotspot rh : runtime_hotspots) {
      ValueBox e = rh.spot;
      String sf = sa.getSourceFile(e);
      int line = sa.getLineNumber(e);
      String kind = "";
      if (rh.kind==HotspotKind.ANALYZE)
        kind = "RegExp.analyze()";
View Full Code Here

  public void createHotspotsFromInvokeExpr(Stmt stmt) {
    InvokeExpr expr = stmt.getInvokeExpr();
    SootMethod target = expr.getMethod();
    for (int i=0; i<expr.getArgCount(); i++) {
      Value value = expr.getArg(i);
      ValueBox box = expr.getArgBox(i);
      if (isStringType(value.getType())) {
        Map<Integer,Automaton> pMap = parameterAutomatonMap.get(target);
        if (pMap != null && pMap.containsKey(i)) {
          Automaton automaton = pMap.get(i);
          createHotspot(stmt, box, automaton);
View Full Code Here

TOP

Related Classes of soot.ValueBox

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.