Search in sources :

Example 1 with Symbol

use of org.eclipse.n4js.flowgraphs.dataflow.symbols.Symbol in project n4js by eclipse.

the class DataFlowBranchWalker method visit.

@Override
protected void visit(Node lastVisitNodes, Node end, ControlFlowEdge edge) {
    GuardStructure guardStructure = GuardStructureFactory.create(edge);
    if (guardStructure == null) {
        return;
    }
    guardStructure.initSymbols(getSymbolFactory());
    for (Iterator<Assumption> assIter = assumptions.values().iterator(); assIter.hasNext(); ) {
        Assumption ass = assIter.next();
        if (ass.isOpen()) {
            for (Symbol alias : ass.aliases) {
                if (!guardStructure.hasGuards(alias)) {
                    continue;
                }
                Collection<Guard> guards = guardStructure.getGuards(alias);
                for (Guard guard : guards) {
                    ass.callHoldsOnGuards(guard);
                }
            }
        }
    }
    for (DataFlowVisitor dfv : getDataFlowVisitorHost().dfVisitors) {
        for (Guard guard : guardStructure.allGuards()) {
            dfv.visitGuard(guard);
        }
    }
}
Also used : GuardStructure(org.eclipse.n4js.flowgraphs.dataflow.guards.GuardStructure) Symbol(org.eclipse.n4js.flowgraphs.dataflow.symbols.Symbol) Guard(org.eclipse.n4js.flowgraphs.dataflow.guards.Guard)

Example 2 with Symbol

use of org.eclipse.n4js.flowgraphs.dataflow.symbols.Symbol in project n4js by eclipse.

the class DataFlowBranchWalker method visit.

@Override
protected void visit(Node node) {
    if (node.effectInfos.isEmpty()) {
        return;
    }
    ControlFlowElement cfe = node.getControlFlowElement();
    Multimap<Symbol, Object> assgns = getDataFlowVisitorHost().getAssignmentRelationFactory().findAssignments(cfe);
    Set<Symbol> handledDataFlowSymbols = new HashSet<>();
    for (Symbol lhs : assgns.keySet()) {
        Collection<Object> rhss = assgns.get(lhs);
        boolean handledDataFlow = handleDataflow(lhs, rhss);
        if (handledDataFlow) {
            handledDataFlowSymbols.add(lhs);
        }
    }
    for (EffectInfo effect : node.effectInfos) {
        handleVisitEffect(cfe, effect, handledDataFlowSymbols);
    }
}
Also used : Symbol(org.eclipse.n4js.flowgraphs.dataflow.symbols.Symbol) ControlFlowElement(org.eclipse.n4js.n4JS.ControlFlowElement) HashSet(java.util.HashSet)

Example 3 with Symbol

use of org.eclipse.n4js.flowgraphs.dataflow.symbols.Symbol in project n4js by eclipse.

the class GuardStructure method initSymbols.

/**
 * This will initialize the symbol of all guards, and delete guards where a {@link Symbol} cannot be found
 */
public void initSymbols(SymbolFactory symbolFactory) {
    for (Iterator<Guard> guardsIter = guardList.iterator(); guardsIter.hasNext(); ) {
        Guard guard = guardsIter.next();
        guard.initSymbol(symbolFactory);
        Symbol symbol = guard.getSymbol();
        if (symbol != null) {
            guards.put(symbol, guard);
        } else {
            guardsIter.remove();
        }
    }
}
Also used : Symbol(org.eclipse.n4js.flowgraphs.dataflow.symbols.Symbol)

Example 4 with Symbol

use of org.eclipse.n4js.flowgraphs.dataflow.symbols.Symbol in project n4js by eclipse.

the class NullDereferenceAnalyser method visitEffect.

@Override
public void visitEffect(EffectInfo effect, ControlFlowElement cfe) {
    if (isDereferencing(cfe)) {
        Symbol tgtSymbol = getSymbolFactory().create(cfe);
        if (tgtSymbol != null) {
            IsNotNull symbolNotNull = new IsNotNull(cfe, tgtSymbol);
            assume(symbolNotNull);
        }
    }
}
Also used : Symbol(org.eclipse.n4js.flowgraphs.dataflow.symbols.Symbol)

Example 5 with Symbol

use of org.eclipse.n4js.flowgraphs.dataflow.symbols.Symbol in project n4js by eclipse.

the class AssignmentRelationFactory method findInDestructNodes.

private void findInDestructNodes(Multimap<Symbol, Object> assgns, DestructNode dNode) {
    for (Iterator<DestructNode> dnIter = dNode.stream().iterator(); dnIter.hasNext(); ) {
        DestructNode dnChild = dnIter.next();
        ControlFlowElement lhs = dnChild.getVarRef() != null ? dnChild.getVarRef() : dnChild.getVarDecl();
        EObject rhs = DestructureUtilsForSymbols.getValueFromDestructuring(symbolFactory, dnChild);
        if (rhs == null) {
            Symbol undefinedSymbol = symbolFactory.getUndefined();
            createRelation(assgns, lhs, undefinedSymbol, null);
        } else {
            createRelation(assgns, lhs, (Expression) rhs);
        }
    }
}
Also used : Symbol(org.eclipse.n4js.flowgraphs.dataflow.symbols.Symbol) EObject(org.eclipse.emf.ecore.EObject) DestructNode(org.eclipse.n4js.n4JS.DestructNode) ControlFlowElement(org.eclipse.n4js.n4JS.ControlFlowElement)

Aggregations

Symbol (org.eclipse.n4js.flowgraphs.dataflow.symbols.Symbol)9 HashSet (java.util.HashSet)3 EObject (org.eclipse.emf.ecore.EObject)2 AssignmentExpression (org.eclipse.n4js.n4JS.AssignmentExpression)2 ConditionalExpression (org.eclipse.n4js.n4JS.ConditionalExpression)2 ControlFlowElement (org.eclipse.n4js.n4JS.ControlFlowElement)2 Expression (org.eclipse.n4js.n4JS.Expression)2 PartialResult (org.eclipse.n4js.flowgraphs.dataflow.PartialResult)1 Guard (org.eclipse.n4js.flowgraphs.dataflow.guards.Guard)1 GuardStructure (org.eclipse.n4js.flowgraphs.dataflow.guards.GuardStructure)1 GuardType (org.eclipse.n4js.flowgraphs.dataflow.guards.GuardType)1 BinaryLogicalExpression (org.eclipse.n4js.n4JS.BinaryLogicalExpression)1 DestructNode (org.eclipse.n4js.n4JS.DestructNode)1 ForStatement (org.eclipse.n4js.n4JS.ForStatement)1