Package dk.brics.xact.analysis.flowgraph.statements

Examples of dk.brics.xact.analysis.flowgraph.statements.VarStm


        public void visitArrayReadStm(ArrayReadStm s) {
          // merge arrays if one array is stored in the other
          if (var_alias.getData(s.getDest()).array) {
            var_alias.merge(s.getSource(), s.getDest());
          }
          cfg.addStatement(new VarStm(s.getDest(), s.getSource(), s.getOrigin()));
          replace(s, cfg.finish());
        }
        @Override
        public void visitArrayWriteStm(ArrayWriteStm s) {
          // merge arrays if one array is stored in the other
          if (var_alias.getData(s.getSource()).array) {
            var_alias.merge(s.getSource(), s.getDest());
          }
          cfg.addStatement(new VarStm(s.getDest(), s.getSource(), s.getOrigin()));
          replace(s, cfg.finish());
        }
        @Override
        public void visitCallStm(CallStm s) {
          for (int i=0; i<s.getArguments().length; i++) {
View Full Code Here


    }

    // copy propagation
    for (Statement s : new LinkedHashSet<Statement>(graph.getNodes())) {
      if (s instanceof VarStm) {
        VarStm vs = (VarStm)s;
        if (graph.getInEdges(vs).size() == 1) {
          Assignment pred = (Assignment)(graph.getInEdges(vs).iterator().next()).getFrom();
          if (graph.getOutEdges(pred).size()==1) {
            // variable assignment with unique predecessor node that has no other successors - bypass this assignment
            pred.setDest(vs.getDest());
            for (Edge<Statement,VariableFilter> e : graph.getOutEdges(vs))
              graph.addEdge(pred, e.getTo(), e.getData()); // XXX: ok to lose some edge info?
            graph.removeNode(vs);
          }
        } else if (graph.getOutEdges(vs).size() == 1) {
          Statement succ = graph.getOutEdges(vs).iterator().next().getTo();
          if (graph.getInEdges(succ).size()==1) { // TODO: copy propagation could be improved by not requiring "no other predecessors"
            // variable assignment with unique successor node that has no other predecessors - bypass this assignment
            final Variable vsrc = vs.getSource();
            succ.visitBy(new StatementVisitor() {

              public void visitAnalyzeStm(AnalyzeStm s) {
                s.setBase(vsrc);
              }
View Full Code Here

          returnFilter.addVariable(target.getParameter(i));
        }
      }
      cfg.addFilter(argsOnly);
      for (int i=0; i<args.length; i++) {
        cfg.addStatement(new VarStm(params[i], args[i], call.getOrigin()));
      }
      graph.addEdge(cfg.currentStatement(), target.getEntry(), paramsOnly);
      cfg.moveToStatement(target.getExit());
      cfg.addStatement(new VarStm(call.getResult(), target.getReturnVar(), call.getOrigin()), returnFilter);
      /*for (int i=0; i<args.length; i++) {
        if (call.isArgumentMutable(i)) {
          cfg.addStatement(new VarStm(call.getArgument(i), target.getParameter(i), call.getOrigin()));
        }
      }*/
 
View Full Code Here

      // A.field = B
      SootField sootField = ((FieldRef)s.getLeftOp()).getField();
      Variable field = context.getField(sootField);
      checkTypeAnnotation(context.getFieldSchemaType(sootField), right);
      cfg.startBranch();
      cfg.addStatement(new VarStm(field, right, context.getCurrentOrigin()));
      cfg.useBranch();
      cfg.useBranch(); // <-- second branch is empty for weak update
      cfg.endBranch();

    } else if (s.getLeftOp() instanceof Local) {
      // var = B
      Variable left = context.getLocal(((Local)s.getLeftOp()).getName());
      cfg.addStatement(new VarStm(left, right, context.getCurrentOrigin()));

    } else {
      throw new RuntimeException("Unexpected assignment to " + s.getLeftOp().getClass());
    }
  }
View Full Code Here

  }

  public void caseReturnStmt(ReturnStmt s) {
    Variable result = translateExpr(s.getOp());
    checkTypeAnnotation(context.getCurrentMethod().getReturnType(), result);
    cfg.addStatement(new VarStm(context.getCurrentMethod().getReturnVar(), result, context.getCurrentOrigin()));
  }
View Full Code Here

    cfg.endBranch();
  }

  private void putCopyArray(Value base, Value arg) {
    hardcodeResult = context.getNothing();
    cfg.addStatement(new VarStm(context.getLocal(((Local)base).getName()), translateExpr(arg), context.getCurrentOrigin()));
  }
View Full Code Here

  }

  private void putSpecialToArray(Value base, Value arg) {
    hardcodeResult = makevar();
    cfg.startBranch();
    cfg.addStatement(new VarStm(hardcodeResult, translateExpr(base), context.getCurrentOrigin()));
    cfg.useBranch();
    cfg.addStatement(new VarStm(hardcodeResult, translateExpr(arg), context.getCurrentOrigin()));
    cfg.useBranch();
    cfg.endBranch();
  }
View Full Code Here

    hardcodeResult = context.getNothing();
    Variable array = translateExpr(dest);
    Variable src = translateExpr(source.getValue());
    cfg.startBranch();
    cfg.useBranch();
    cfg.addStatement(new VarStm(array, src, context.getCurrentOrigin()));
    cfg.useBranch();
    cfg.endBranch();
  }
View Full Code Here

      // this case covers when a text node is plugged in
      cfg.useBranch();
      // plug in as XML if it is an XML node
//      boolean xml = context.isSubtypeOf(t, "dk.brics.xact.XML");
//      if (t.equals(RefType.v("java.lang.Object")) || xml) {
        cfg.addStatement(new VarStm(var, translateExpr(b.getValue()), context.getCurrentOrigin()));
        cfg.useBranch();
//      }
      // if not XML, call appropriate toXML methods.
      // XXX a proper type analysis will upgrade both performance and precision here
//      if (!xml) {
View Full Code Here

TOP

Related Classes of dk.brics.xact.analysis.flowgraph.statements.VarStm

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.