use of org.eclipse.n4js.flowgraphs.dataflow.symbols.Symbol in project n4js by eclipse.
the class AssignmentRelationFactory method findInVariableDeclaration.
private void findInVariableDeclaration(Multimap<Symbol, Object> assgns, VariableDeclaration vd) {
EObject parent = vd.eContainer();
if (parent instanceof ForStatement) {
ForStatement fs = (ForStatement) parent;
if (!fs.isForPlain()) {
findInForStatementInOf(assgns, vd, (ForStatement) parent);
return;
}
}
Expression rhs = vd.getExpression();
if (rhs == null) {
Symbol undefinedSymbol = symbolFactory.getUndefined();
createRelation(assgns, vd, undefinedSymbol, null);
} else {
handleSubexpressions(assgns, vd, rhs);
}
}
use of org.eclipse.n4js.flowgraphs.dataflow.symbols.Symbol in project n4js by eclipse.
the class AssignmentRelationFactory method createRelation.
private void createRelation(Multimap<Symbol, Object> assgns, ControlFlowElement lhs, Expression rhs) {
Symbol rSymbol = symbolFactory.create(rhs);
createRelation(assgns, lhs, rSymbol, rhs);
}
use of org.eclipse.n4js.flowgraphs.dataflow.symbols.Symbol in project n4js by eclipse.
the class Assumption method callHoldsOnDataflow.
/**
* Called from {@link DataFlowBranchWalker}.
* <p>
* Method transforms multiple right hand sides into separate calls to
* {@link #callHoldsOnDataflow(Symbol, Collection)}. Multiple right hand sides occur when either using
* {@link ConditionalExpression}s <br/>
* {@code let v = 1 ? null : undefined;} <br/>
* or when using nested {@link AssignmentExpression}s <br/>
* {@code let v = a = null;}.
*/
final void callHoldsOnDataflow(Symbol lhs, Collection<Object> rhss) {
checkState(isOpen());
Set<PartialResult.Type> resultSet = new HashSet<>();
for (Object rhs : rhss) {
Symbol rSymbol = null;
PartialResult result = null;
if (rhs instanceof Symbol) {
rSymbol = (Symbol) rhs;
result = holdsOnDataflow(lhs, rSymbol, null);
aliases.remove(lhs);
if (rSymbol.isVariableSymbol() && followAliases()) {
aliases.add(rSymbol);
}
} else if (rhs instanceof Expression) {
Expression rValue = (Expression) rhs;
result = holdsOnDataflow(lhs, null, rValue);
}
if (result != null) {
resultSet.add(result.type);
handleHoldResult(result, lhs);
}
}
if (resultSet.size() > 1 && resultSet.contains(PartialResult.Type.Unclear)) {
openBranch = true;
}
}
use of org.eclipse.n4js.flowgraphs.dataflow.symbols.Symbol in project n4js by eclipse.
the class NullDereferenceResult method getFailedSymbol.
private Symbol getFailedSymbol(IsNotNull inn) {
if (inn.failedBranches.isEmpty()) {
return null;
}
Set<Symbol> failedSymbols = new HashSet<>();
for (PartialResult result : inn.failedBranches) {
NullDerefernceFailed ndFailed = (NullDerefernceFailed) result;
failedSymbols.add(ndFailed.symbol);
}
if (failedSymbols.size() == 1) {
return failedSymbols.iterator().next();
}
return null;
}
Aggregations