Package dk.brics.xact.analysis.flowgraph

Examples of dk.brics.xact.analysis.flowgraph.Method


        calls.add((CallStm)stm);
    }
    ControlFlowBuilder cfg = new ControlFlowBuilder(graph, null);
    // transform!
    for (CallStm call : calls) {
      Method target = call.getMethod();
      cfg.setOrigin(call.getOrigin());
      Statement start = cfg.currentStatement();
      Variable[] params = target.getParameters();
      Variable[] args = call.getArguments();
      VariableFilter paramsOnly = new VariableFilter(false, VariableFilter.Kind.CALL);
      VariableFilter argsOnly = new VariableFilter(false);
      VariableFilter notArgs = new VariableFilter(true);
      VariableFilter resultFilter = new VariableFilter(call.getResult(), VariableFilter.Kind.RETURN);
      VariableFilter returnFilter = new VariableFilter(target.getReturnVar());
      for (int i=0; i<args.length; i++) {
        paramsOnly.addVariable(params[i]);
        argsOnly.addVariable(args[i]);
        notArgs.removeVariable(args[i]);
        if (call.isArgumentMutable(i)) {
          resultFilter.addVariable(call.getArgument(i));
          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


          if (context.isAnnotatableType(m.getParameterType(i))) {
            paramTypes[i] = context.parseSchemaType(config.getMethodParameterType(m, i, context.getTypeAnnotationForParameter(m, i)), origin);
          }
        }
        // make the method
        Method method = new Method(m.getName(), methodentry, methodexit, parameters, returnVar, returnType, paramTypes);
        context.setMethod(m, method);
      }
      for (SootField f : c.getFields()) {
        // parse annotations
        if (context.isAnnotatableType(f.getType())) {
          Origin origin = new Origin(c.getName() + "." + f.getName(), 0, 0);
          context.setFieldSchemaType(f, context.parseSchemaType(config.getFieldType(f, context.getTypeAnnotation(f)), origin));
        }
      }
    }
    // translate!
    for (SootClass c : Scene.v().getApplicationClasses()) {
      context.setCurrentClass(c);
      for (SootMethod m : c.getMethods()) {
        if (!m.isConcrete())
          continue;
        context.setCurrentSootMethod(m);
        CompleteUnitGraph unitgraph = new CompleteUnitGraph(m.retrieveActiveBody());
        context.setNullness(new NullnessAnalysis(unitgraph));
        context.setStringConstants(new StringConstantAnalysis(unitgraph));
        context.setArrayConstants(new ArrayConstantAnalysis(unitgraph));
        Method method = context.getMethod(m);
        Map<Unit,StatementPair> translated = new HashMap<Unit,StatementPair>();
        for (Unit stmt : m.getActiveBody().getUnits()) {
          context.setCurrentUnit(stmt);
          context.setCurrentLine(getLineNumber(stmt));
          translated.put(stmt, translator.translateStmt((Stmt)stmt));
        }
        for (Map.Entry<Unit, StatementPair> entry : translated.entrySet()) {
          Unit stmt = entry.getKey();
          StatementPair translation = entry.getValue();
          // add successors
          for (Unit next : unitgraph.getSuccsOf(stmt)) {
            StatementPair nextt = translated.get(next);
            graph.addEdge(translation.last, nextt.first, new VariableFilter());
          }
          // add (exceptional) return edge
          graph.addEdge(translation.last, method.getExit(), new VariableFilter());
        }
        // add entry edges
        for (Unit head : unitgraph.getHeads()) {
          graph.addEdge(method.getEntry(), translated.get(head).first, new VariableFilter(true, VariableFilter.Kind.ENTRY));
        }
      }
    }
   
    // run string analysis
View Full Code Here

  public Variable caseLocal(Local v, Object question) {
    return context.getLocal(v.getName());
  }
  @Override
  public Variable caseParameterRef(ParameterRef v, Object question) {
    Method method = context.getCurrentMethod();
    return assumeTypeAnnotation(method.getParameterType(v.getIndex()), method.getParameter(v.getIndex()));
  }
View Full Code Here

    for (SootMethod target : getTargets(v)) {
      // non-application classes are handled as extern calls below, so ignore them here
      if (!target.getDeclaringClass().isApplicationClass())
        continue; // XXX will resolveAbstractDispatch actually return non-concrete targets?
      // handle call to application method
      Method method = context.getMethod(target);
      cfg.addStatement(new CallStm(var, method, arguments, context.getCurrentOrigin()));
      cfg.useBranch();
    }
    if (config.canCallExtern(v)) {
      for (int i=0; i<arguments.length; i++) {
View Full Code Here

TOP

Related Classes of dk.brics.xact.analysis.flowgraph.Method

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.