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);
}
}
}
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);
}
}
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();
}
}
}
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);
}
}
}
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);
}
}
}
Aggregations