Package dk.brics.string.flow

Examples of dk.brics.string.flow.Node


                    s.visitBy(this); // visit each defined variable (including aliases) for each statement
                    if (dv.defines(s, v)) {
                        trans_map.put(s, map.get(s).get(v));
                    }
                    if (vi.isTaint()) {
                        Node n = map.get(s).get(v);
                        if (n != null) {
                            n.setTaint(true);
                        }
                    }
                }
            }
        }

        for (Map<Variable, Node> vmap : map.values()) {
            for (Variable v : vmap.keySet()) { // TODO: inefficient, use entrySet iterator instead
                Node n = vmap.get(v);
                n.setTaint(v.isTaint());
            }
        }
       
        // create field nodes
        for (Field field : app.getFields()) {
View Full Code Here


        }
        log.info("Simplifying flow graph...");
        Map<Node, Node> m3 = g.simplify();
        Set<Node> nodes = new HashSet<Node>();
        for (Statement ss : hotspot_statements) {
            Node beforeSimplifyNode = m2.get(ss);
            Node n = m3.get(beforeSimplifyNode);
            if (n != null) {
                nodes.add(n);
            }
        }
        for (StringStatement ss : jt.getToStringHotspotMap().values()) {
            Node n = m3.get(m2.get(ss));
            if (n != null) {
                nodes.add(n);
            }
        }
        for (Node n : m3.keySet()) { // TODO: inefficient, use entrySet iterator instead
            Node n2 = m3.get(n);
            if (n.isTaint() && n2 != null) {
                n2.setTaint(true);
            }
        }
        if (log.isDebugEnabled()) {
            log.debug(g.toDot(nodes));
        }
        log.info("Transforming into grammar...");
        FlowGraph2Grammar f2g = new FlowGraph2Grammar(g);
        Grammar r = f2g.convert();
        Set<Nonterminal> hs_nt = new HashSet<Nonterminal>();
        for (Node hn : nodes) {
            hs_nt.add(f2g.getNonterminal(hn));
        }
        if (log.isDebugEnabled()) {
            log.debug(r.toString() + "Hotspots: " + hs_nt);
        }

        // Approximate grammar
        log.info("Cutting operation cycles...");
        r.approximateOperationCycles();
        log.info("Performing regular approximation...");
        r.approximateNonLinear(hs_nt);
        if (log.isDebugEnabled()) {
            log.debug(r.toString() + "Hotspots: " + hs_nt);
        }
        log.info("Converting to MLFA...");

        Grammar2MLFA gm = new Grammar2MLFA(r);
        MLFA mlfa = gm.convert();

        propagateTaint(r);

        for (Node n : nodes) {
            Nonterminal nt = f2g.getNonterminal(n);
            MLFAStatePair sp = gm.getMLFAStatePair(nt);
            if (nt.isTaint()) {
                sp.setTaint(true);
            }
        }
        log.debug(mlfa.toString());

        // Make map
        map = new HashMap<ValueBox, MLFAStatePair>();
        for (ValueBox box : hotspots) {
            Node n = m3.get(m2.get(m1.get(box)));
            if (n != null) {
                Nonterminal nt = f2g.getNonterminal(n);
                MLFAStatePair sp = gm.getMLFAStatePair(nt);
                map.put(box, sp);
            }
        }
        tostring_map = new HashMap<SootClass, MLFAStatePair>();
        Map<SootClass, StringStatement> tostring_hotspot_map = jt.getToStringHotspotMap();
        for (Map.Entry<SootClass, StringStatement> tse : tostring_hotspot_map.entrySet()) {
            SootClass tsc = tse.getKey();
            StringStatement ss = tse.getValue();
            Node n = m3.get(m2.get(ss));
            if (n != null) {
                Nonterminal nt = f2g.getNonterminal(n);
                MLFAStatePair sp = gm.getMLFAStatePair(nt);
                tostring_map.put(tsc, sp);
            }
View Full Code Here

TOP

Related Classes of dk.brics.string.flow.Node

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.