public class IntegerBoundsChecker extends polyglot.visit.DataFlow<IntegerBoundsChecker.DataFlowItem>
Modifier and Type | Class and Description |
---|---|
protected static class |
IntegerBoundsChecker.ArrayLengthBound |
protected static class |
IntegerBoundsChecker.Bound |
protected static class |
IntegerBoundsChecker.Bounds |
protected static class |
IntegerBoundsChecker.DataFlowItem
The items that this dataflow analysis operates on is essetially a set
of integer constraints.
|
static class |
IntegerBoundsChecker.Interval
A closed interval over the integers.
|
protected static class |
IntegerBoundsChecker.LocalBound |
polyglot.visit.DataFlow.BoolItem<FlowItem extends polyglot.visit.DataFlow.Item>, polyglot.visit.DataFlow.ConditionNavigator<FlowItem extends polyglot.visit.DataFlow.Item>, polyglot.visit.DataFlow.FlowGraphSource<FlowItem extends polyglot.visit.DataFlow.Item>, polyglot.visit.DataFlow.Frame<FlowItem extends polyglot.visit.DataFlow.Item>, polyglot.visit.DataFlow.Item
Modifier and Type | Field and Description |
---|---|
protected static java.util.Set<polyglot.ast.Binary.Operator> |
INTERESTING_BINARY_OPERATORS |
Constructor and Description |
---|
IntegerBoundsChecker(polyglot.frontend.Job job) |
IntegerBoundsChecker(polyglot.frontend.Job job,
polyglot.types.TypeSystem ts,
polyglot.ast.NodeFactory nf) |
Modifier and Type | Method and Description |
---|---|
protected void |
addBounds(java.util.Map<polyglot.types.LocalInstance,IntegerBoundsChecker.Bounds> updates,
polyglot.ast.Expr left,
boolean strict,
polyglot.ast.Expr right)
Add bounds to updates given left < right or left <= right, depending on
whether strict is set.
|
protected int |
addBoundsAssign(java.util.Map<polyglot.types.LocalInstance,IntegerBoundsChecker.Bounds> updates,
polyglot.types.LocalInstance li,
polyglot.ast.Expr right,
IntegerBoundsChecker.DataFlowItem df,
IntegerBoundsChecker.Interval existingNumericBounds)
Add the bounds for an assignment li = right.
|
void |
check(polyglot.visit.FlowGraph<IntegerBoundsChecker.DataFlowItem> graph,
polyglot.ast.Term n,
boolean entry,
IntegerBoundsChecker.DataFlowItem inItem,
java.util.Map<polyglot.visit.FlowGraph.EdgeKey,IntegerBoundsChecker.DataFlowItem> outItems)
Record the bounds information.
|
protected IntegerBoundsChecker.DataFlowItem |
confluence(java.util.List<IntegerBoundsChecker.DataFlowItem> items,
polyglot.visit.FlowGraph.Peer<IntegerBoundsChecker.DataFlowItem> peer,
polyglot.visit.FlowGraph<IntegerBoundsChecker.DataFlowItem> graph)
The confluence of a list of items.
|
protected IntegerBoundsChecker.DataFlowItem |
createInitialItem(polyglot.visit.FlowGraph<IntegerBoundsChecker.DataFlowItem> graph,
polyglot.ast.Term node,
boolean entry)
Create an initial Item for the dataflow analysis.
|
protected java.util.Set<polyglot.types.LocalInstance> |
findArrayLengthBounds(polyglot.ast.Expr expr,
boolean strict,
IntegerBoundsChecker.DataFlowItem df)
Finds the local instances that are arrays, and whose length
is a (strict or non-strict) upper bound on the expression expr.
|
protected java.util.Set<polyglot.types.LocalInstance> |
findArrayLengthBounds(polyglot.ast.Expr expr,
IntegerBoundsChecker.Bound.Type type)
Returns the set of LocalInstances of locals that are arrays, and whose lengths
are (non-strict) lower or upper bounds on the expression
|
protected java.util.Set<polyglot.types.LocalInstance> |
findArrayLengthBounds(polyglot.types.LocalInstance li,
boolean strict,
IntegerBoundsChecker.DataFlowItem df) |
protected java.util.Set<polyglot.types.LocalInstance> |
findArrayLengthBounds(polyglot.types.LocalInstance li,
boolean strict,
IntegerBoundsChecker.DataFlowItem df,
java.util.Set<polyglot.types.LocalInstance> seen)
Finds the local instances that are arrays, and whose length
is a strict upper bound on the value of the local variable li.
|
protected java.util.Set<polyglot.types.LocalInstance> |
findLocalInstanceBounds(polyglot.ast.Expr expr,
IntegerBoundsChecker.Bound.Type type)
Returns the set of LocalInstances that are (non-strict) lower or upper
bounds on the expression
|
protected java.lang.Long |
findNumericBound(polyglot.types.LocalInstance li,
IntegerBoundsChecker.DataFlowItem df,
IntegerBoundsChecker.Bound.Type type)
Finds the tightest numeric bound possible for li.
|
protected java.lang.Long |
findNumericBound(polyglot.types.LocalInstance li,
IntegerBoundsChecker.DataFlowItem df,
IntegerBoundsChecker.Bound.Type type,
java.util.Set<polyglot.types.LocalInstance> seen)
Finds the tightest numeric bound possible for li.
|
protected IntegerBoundsChecker.Interval |
findNumericRange(polyglot.ast.Expr expr,
IntegerBoundsChecker.DataFlowItem df)
Finds the tightest numeric range for expr, given dataflow information
available immediately before evaluation of this expression (but after any
sub-expressions).
|
java.util.Map<polyglot.visit.FlowGraph.EdgeKey,IntegerBoundsChecker.DataFlowItem> |
flow(IntegerBoundsChecker.DataFlowItem trueItem,
IntegerBoundsChecker.DataFlowItem falseItem,
IntegerBoundsChecker.DataFlowItem otherItem,
polyglot.visit.FlowGraph<IntegerBoundsChecker.DataFlowItem> graph,
polyglot.visit.FlowGraph.Peer<IntegerBoundsChecker.DataFlowItem> peer) |
protected java.util.Map<polyglot.visit.FlowGraph.EdgeKey,IntegerBoundsChecker.DataFlowItem> |
flow(java.util.List<IntegerBoundsChecker.DataFlowItem> inItems,
java.util.List<polyglot.visit.FlowGraph.EdgeKey> inItemKeys,
polyglot.visit.FlowGraph<IntegerBoundsChecker.DataFlowItem> graph,
polyglot.visit.FlowGraph.Peer<IntegerBoundsChecker.DataFlowItem> peer)
We use boolean flows for this dataflow analysis, i.e., we want to track
different information on the true and false branches.
|
protected IntegerBoundsChecker.Interval |
getExprBounds(polyglot.ast.Expr e) |
protected static java.lang.Long |
max(java.lang.Long a,
java.lang.Long b) |
protected static java.lang.Long |
min(java.lang.Long a,
java.lang.Long b) |
protected void |
notifyAllNodes(polyglot.ast.Node n) |
protected static boolean |
nullableEquals(java.lang.Object o1,
java.lang.Object o2)
Checks two reference for object equality.
|
protected static int |
nullableHashCode(java.lang.Object o)
Gets the hash code for a given object, dealing with null pointers.
|
protected void |
post(polyglot.visit.FlowGraph<IntegerBoundsChecker.DataFlowItem> graph,
polyglot.ast.Term root) |
protected void |
setExprBounds(polyglot.ast.Expr e,
IntegerBoundsChecker.Interval bounds) |
check, confluence, constructItemsFromCondition, createCFGBuilder, createFrame, createInitialItem, currentFlowGraph, dataflow, dataflow, dataflow, dumpFlowGraph, enterCall, filterItems, filterItemsExceptionSubclass, filterItemsNonError, filterItemsNonException, findSCCs, flow, flow, flow, flowBooleanConditions, flowToBooleanFlow, hasTrueFalseBranches, initGraph, initGraph, itemsToMap, itemToMap, lang, leave, leaveCall, safeConfluence, safeConfluence, safeConfluence
begin, catchErrors, enter, enterCall, enterError, errorQueue, hasErrors, job, leaveCall, leaveCall, nodeFactory, typeSystem
bypass, bypass, bypassChildren, override, visitChildren
protected static final java.util.Set<polyglot.ast.Binary.Operator> INTERESTING_BINARY_OPERATORS
public IntegerBoundsChecker(polyglot.frontend.Job job)
public IntegerBoundsChecker(polyglot.frontend.Job job, polyglot.types.TypeSystem ts, polyglot.ast.NodeFactory nf)
protected IntegerBoundsChecker.DataFlowItem createInitialItem(polyglot.visit.FlowGraph<IntegerBoundsChecker.DataFlowItem> graph, polyglot.ast.Term node, boolean entry)
createInitialItem
in class polyglot.visit.DataFlow<IntegerBoundsChecker.DataFlowItem>
protected java.util.Map<polyglot.visit.FlowGraph.EdgeKey,IntegerBoundsChecker.DataFlowItem> flow(java.util.List<IntegerBoundsChecker.DataFlowItem> inItems, java.util.List<polyglot.visit.FlowGraph.EdgeKey> inItemKeys, polyglot.visit.FlowGraph<IntegerBoundsChecker.DataFlowItem> graph, polyglot.visit.FlowGraph.Peer<IntegerBoundsChecker.DataFlowItem> peer)
flow
in class polyglot.visit.DataFlow<IntegerBoundsChecker.DataFlowItem>
public java.util.Map<polyglot.visit.FlowGraph.EdgeKey,IntegerBoundsChecker.DataFlowItem> flow(IntegerBoundsChecker.DataFlowItem trueItem, IntegerBoundsChecker.DataFlowItem falseItem, IntegerBoundsChecker.DataFlowItem otherItem, polyglot.visit.FlowGraph<IntegerBoundsChecker.DataFlowItem> graph, polyglot.visit.FlowGraph.Peer<IntegerBoundsChecker.DataFlowItem> peer)
flow
in class polyglot.visit.DataFlow<IntegerBoundsChecker.DataFlowItem>
protected void post(polyglot.visit.FlowGraph<IntegerBoundsChecker.DataFlowItem> graph, polyglot.ast.Term root) throws polyglot.types.SemanticException
post
in class polyglot.visit.DataFlow<IntegerBoundsChecker.DataFlowItem>
polyglot.types.SemanticException
public void check(polyglot.visit.FlowGraph<IntegerBoundsChecker.DataFlowItem> graph, polyglot.ast.Term n, boolean entry, IntegerBoundsChecker.DataFlowItem inItem, java.util.Map<polyglot.visit.FlowGraph.EdgeKey,IntegerBoundsChecker.DataFlowItem> outItems)
check
in class polyglot.visit.DataFlow<IntegerBoundsChecker.DataFlowItem>
protected void notifyAllNodes(polyglot.ast.Node n)
protected IntegerBoundsChecker.DataFlowItem confluence(java.util.List<IntegerBoundsChecker.DataFlowItem> items, polyglot.visit.FlowGraph.Peer<IntegerBoundsChecker.DataFlowItem> peer, polyglot.visit.FlowGraph<IntegerBoundsChecker.DataFlowItem> graph)
confluence
in class polyglot.visit.DataFlow<IntegerBoundsChecker.DataFlowItem>
protected void setExprBounds(polyglot.ast.Expr e, IntegerBoundsChecker.Interval bounds)
protected IntegerBoundsChecker.Interval getExprBounds(polyglot.ast.Expr e)
protected void addBounds(java.util.Map<polyglot.types.LocalInstance,IntegerBoundsChecker.Bounds> updates, polyglot.ast.Expr left, boolean strict, polyglot.ast.Expr right)
protected int addBoundsAssign(java.util.Map<polyglot.types.LocalInstance,IntegerBoundsChecker.Bounds> updates, polyglot.types.LocalInstance li, polyglot.ast.Expr right, IntegerBoundsChecker.DataFlowItem df, IntegerBoundsChecker.Interval existingNumericBounds)
protected java.util.Set<polyglot.types.LocalInstance> findLocalInstanceBounds(polyglot.ast.Expr expr, IntegerBoundsChecker.Bound.Type type)
protected java.util.Set<polyglot.types.LocalInstance> findArrayLengthBounds(polyglot.ast.Expr expr, IntegerBoundsChecker.Bound.Type type)
protected java.util.Set<polyglot.types.LocalInstance> findArrayLengthBounds(polyglot.ast.Expr expr, boolean strict, IntegerBoundsChecker.DataFlowItem df)
protected java.util.Set<polyglot.types.LocalInstance> findArrayLengthBounds(polyglot.types.LocalInstance li, boolean strict, IntegerBoundsChecker.DataFlowItem df)
protected java.util.Set<polyglot.types.LocalInstance> findArrayLengthBounds(polyglot.types.LocalInstance li, boolean strict, IntegerBoundsChecker.DataFlowItem df, java.util.Set<polyglot.types.LocalInstance> seen)
protected java.lang.Long findNumericBound(polyglot.types.LocalInstance li, IntegerBoundsChecker.DataFlowItem df, IntegerBoundsChecker.Bound.Type type)
protected java.lang.Long findNumericBound(polyglot.types.LocalInstance li, IntegerBoundsChecker.DataFlowItem df, IntegerBoundsChecker.Bound.Type type, java.util.Set<polyglot.types.LocalInstance> seen)
protected IntegerBoundsChecker.Interval findNumericRange(polyglot.ast.Expr expr, IntegerBoundsChecker.DataFlowItem df)
protected static java.lang.Long max(java.lang.Long a, java.lang.Long b)
protected static java.lang.Long min(java.lang.Long a, java.lang.Long b)
protected static boolean nullableEquals(java.lang.Object o1, java.lang.Object o2)
protected static int nullableHashCode(java.lang.Object o)