|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpolyglot.visit.NodeVisitor
polyglot.visit.HaltingVisitor
polyglot.visit.ErrorHandlingVisitor
polyglot.visit.DataFlow
jif.visit.IntegerBoundsChecker
public class IntegerBoundsChecker
This class finds integral bounds on expressions. It uses that information to determine whether it is impossible for certain exceptions to be thrown.
Nested Class Summary | |
---|---|
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
|
Nested classes/interfaces inherited from class polyglot.visit.DataFlow |
---|
polyglot.visit.DataFlow.BoolItem, polyglot.visit.DataFlow.ConditionNavigator, polyglot.visit.DataFlow.FlowGraphSource, polyglot.visit.DataFlow.Item |
Field Summary | |
---|---|
protected static java.util.Set<polyglot.ast.Binary.Operator> |
INTERESTING_BINARY_OPERATORS
|
Fields inherited from class polyglot.visit.DataFlow |
---|
dataflowOnEntry, flowCounter, flowgraphStack, forward |
Fields inherited from class polyglot.visit.ErrorHandlingVisitor |
---|
error, job, nf, ts |
Fields inherited from class polyglot.visit.HaltingVisitor |
---|
bypass, bypassParent |
Constructor Summary | |
---|---|
IntegerBoundsChecker(polyglot.frontend.Job job)
|
|
IntegerBoundsChecker(polyglot.frontend.Job job,
polyglot.types.TypeSystem ts,
polyglot.ast.NodeFactory nf)
|
Method Summary | |
---|---|
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 graph,
polyglot.ast.Term n,
boolean entry,
polyglot.visit.DataFlow.Item inItem,
java.util.Map outItems)
Record the bounds information. |
protected polyglot.visit.DataFlow.Item |
confluence(java.util.List items,
polyglot.ast.Term node,
boolean entry,
polyglot.visit.FlowGraph graph)
The confluence of a list of items. |
protected polyglot.visit.DataFlow.Item |
createInitialItem(polyglot.visit.FlowGraph 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 |
flow(polyglot.visit.DataFlow.Item trueItem,
polyglot.visit.DataFlow.Item falseItem,
polyglot.visit.DataFlow.Item otherItem,
polyglot.visit.FlowGraph graph,
polyglot.ast.Term n,
boolean entry,
java.util.Set succEdgeKeys)
|
protected java.util.Map |
flow(java.util.List inItems,
java.util.List inItemKeys,
polyglot.visit.FlowGraph graph,
polyglot.ast.Term n,
boolean entry,
java.util.Set edgeKeys)
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 graph,
polyglot.ast.Term root)
|
protected void |
setExprBounds(polyglot.ast.Expr e,
IntegerBoundsChecker.Interval bounds)
|
Methods inherited from class polyglot.visit.DataFlow |
---|
confluence, constructItemsFromCondition, createCFGBuilder, currentFlowGraph, dataflow, dataflow, dataflow, dumpFlowGraph, enterCall, filterItems, filterItemsExceptionSubclass, filterItemsNonError, filterItemsNonException, findSCCs, flow, flowBooleanConditions, flowToBooleanFlow, hasTrueFalseBranches, initGraph, initGraph, itemsToMap, itemToMap, leave, leaveCall, safeConfluence, safeConfluence, safeConfluence |
Methods inherited from class polyglot.visit.ErrorHandlingVisitor |
---|
begin, catchErrors, enter, enterCall, enterError, errorQueue, hasErrors, job, leaveCall, leaveCall, nodeFactory, typeSystem |
Methods inherited from class polyglot.visit.HaltingVisitor |
---|
bypass, bypass, bypassChildren, override, visitChildren |
Methods inherited from class polyglot.visit.NodeVisitor |
---|
copy, enter, finish, finish, leave, override, toString, visitEdge, visitEdgeNoOverride |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final java.util.Set<polyglot.ast.Binary.Operator> INTERESTING_BINARY_OPERATORS
Constructor Detail |
---|
public IntegerBoundsChecker(polyglot.frontend.Job job)
public IntegerBoundsChecker(polyglot.frontend.Job job, polyglot.types.TypeSystem ts, polyglot.ast.NodeFactory nf)
Method Detail |
---|
protected polyglot.visit.DataFlow.Item createInitialItem(polyglot.visit.FlowGraph graph, polyglot.ast.Term node, boolean entry)
createInitialItem
in class polyglot.visit.DataFlow
protected java.util.Map flow(java.util.List inItems, java.util.List inItemKeys, polyglot.visit.FlowGraph graph, polyglot.ast.Term n, boolean entry, java.util.Set edgeKeys)
flow
in class polyglot.visit.DataFlow
public java.util.Map flow(polyglot.visit.DataFlow.Item trueItem, polyglot.visit.DataFlow.Item falseItem, polyglot.visit.DataFlow.Item otherItem, polyglot.visit.FlowGraph graph, polyglot.ast.Term n, boolean entry, java.util.Set succEdgeKeys)
flow
in class polyglot.visit.DataFlow
protected void post(polyglot.visit.FlowGraph graph, polyglot.ast.Term root) throws polyglot.types.SemanticException
post
in class polyglot.visit.DataFlow
polyglot.types.SemanticException
public void check(polyglot.visit.FlowGraph graph, polyglot.ast.Term n, boolean entry, polyglot.visit.DataFlow.Item inItem, java.util.Map outItems) throws polyglot.types.SemanticException
check
in class polyglot.visit.DataFlow
polyglot.types.SemanticException
protected void notifyAllNodes(polyglot.ast.Node n)
protected polyglot.visit.DataFlow.Item confluence(java.util.List items, polyglot.ast.Term node, boolean entry, polyglot.visit.FlowGraph graph)
confluence
in class polyglot.visit.DataFlow
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)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |