public class Monitoring<BlockStateType extends BlockState<BlockStateType,CallContextType,CallEdgeType>,CallContextType extends ICallContext<CallContextType>,CallEdgeType extends CallEdge<BlockStateType>> extends Object implements IMonitoring<BlockStateType,CallContextType>
| Constructor and Description |
|---|
Monitoring()
Constructs a new monitoring object.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addMessage(AbstractNode n,
Message.Severity severity,
String msg)
Adds a message for the given node.
|
void |
addMessage(AbstractNode n,
Message.Severity severity,
String key,
String msg)
Adds a message for the given node.
|
void |
addMessageInfo(AbstractNode n,
Message.Severity severity,
String msg)
Adds a message for the given node.
|
void |
beginScanPhase(FlowGraph fg)
Initializes messages.
|
List<Message> |
endScanPhase(FlowGraph fg)
Finalizes messages by adding messages about unreachable code/functions,
unused variables and parameters, dead assignments, and shadowing declarations.
|
void |
generateUnreachableMap()
Produces output showing the parts of the code that is determined unreachable by the analysis.
|
Set<Message> |
getMessages()
Returns the collected messages.
|
Set<AbstractNode> |
getReachableNodes()
Returns the set of maybe reachable nodes.
|
int |
getTotalNumberOfNodeTransfers()
Returns the total number of node transfers.
|
Map<TypeCollector.VariableSummary,Value> |
getTypeInformation()
Returns the collected type information.
|
void |
presentTypeInformation()
Presents the collected type information.
|
void |
reportShadowing(FlowGraph fg)
Add messages about shadowing.
|
String |
toString()
Returns a string description of the results.
|
void |
visitBlockTransfer()
Registers a block transfer occurrence.
|
void |
visitCall(AbstractNode n,
boolean maybe_non_function,
boolean maybe_function)
Registers a potential call/construct to a non-function value.
|
void |
visitEvalCall(AbstractNode n,
Value v)
Registers a call to eval.
|
void |
visitFunction(Function f,
Collection<BlockStateType> entry_states)
Registers the function and checks whether it is unreachable.
|
void |
visitIf(IfNode n,
Value v)
Checks whether the branch condition is always true or always false.
|
void |
visitIn(AbstractNode n,
boolean maybe_v2_object,
boolean maybe_v2_nonobject)
Checks whether the 'in' operation may fail.
|
void |
visitInnerHTMLWrite(Node n,
Value v)
Registers a write to innerHTML.
|
void |
visitInstanceof(AbstractNode n,
boolean maybe_v2_non_function,
boolean maybe_v2_function,
boolean maybe_v2_prototype_primitive,
boolean maybe_v2_prototype_nonprimitive)
Checks whether the 'instanceof' operation may fail.
|
void |
visitJoin()
Registers a state join operation.
|
void |
visitNativeFunctionCall(AbstractNode n,
HostObject hostobject,
boolean num_actuals_unknown,
int num_actuals,
int min,
int max)
Checks the number of parameters for a call to a native function.
|
void |
visitNewFlow(BasicBlock b,
ICallContext<?> c,
IBlockState<?,?,?> s,
String diff,
String info)
Registers new dataflow being propagated.
|
void |
visitNodeTransfer(AbstractNode n)
Registers a node transfer occurrence.
|
void |
visitPropertyAccess(Node n,
Value baseval)
Checks whether the property access operation may dereference null or undefined.
|
void |
visitPropertyRead(Node n,
Set<ObjectLabel> objs,
Str propertystr,
BlockStateType state)
Warns about writes to unknown properties;
also registers a read operation on abstract objects.
|
void |
visitPropertyWrite(Node n,
Set<ObjectLabel> objs,
Str propertystr)
Warns about writes to unknown properties;
also registers a write operation on abstract objects.
|
void |
visitReachableNode(AbstractNode n)
Registers a maybe reachable node.
|
void |
visitRead(Node n,
ICallContext<?> c,
Value v)
Record type information about a var/prop read.
|
void |
visitReadNonThisVariable(ReadVariableNode n,
Value v)
Checks whether an absent variable is read.
|
void |
visitReadProperty(ReadPropertyNode n,
Set<ObjectLabel> objlabels,
Str propertystr,
boolean maybe,
BlockStateType state)
Checks whether the property read operation accesses an absent property and whether the operation returns null/undefined.
|
void |
visitReadThis(ReadVariableNode n,
Value v,
BlockStateType state,
ObjectLabel global_obj)
Checks whether the read of 'this' yields the global object.
|
void |
visitReadVariable(ReadVariableNode n,
Value v,
BlockStateType state)
Checks whether the variable read yields null/undefined.
|
void |
visitRecoveryGraph(int size)
Registers a property recovery graph size.
|
void |
visitUnknownValueResolve()
Registers a recovery of an unknown value.
|
void |
visitUserFunctionCall(Function f,
AbstractNode call,
boolean constructor)
Checks whether the function is invoked both as a constructor (with 'new') and as a function/method (without 'new').
|
void |
visitVariableAsRead(ReadVariableNode n,
Value v)
Registers that the given variable is read; also checks for suspicious type mixings.
|
void |
visitVariableOrProperty(String var,
SourceLocation loc,
Value value)
Registers the name, location, and value of a variable being read or written.
|
void |
visitWriteVariable(WriteVariableNode n,
Value v,
BlockStateType state)
Checks whether the assignment has no effect.
|
public void addMessage(AbstractNode n, Message.Severity severity, String msg)
public void addMessage(AbstractNode n, Message.Severity severity, String key, String msg)
public void addMessageInfo(AbstractNode n, Message.Severity severity, String msg)
public void beginScanPhase(FlowGraph fg)
IMonitoringbeginScanPhase in interface IMonitoring<BlockStateType extends BlockState<BlockStateType,CallContextType,CallEdgeType>,CallContextType extends ICallContext<CallContextType>>public List<Message> endScanPhase(FlowGraph fg)
endScanPhase in interface IMonitoring<BlockStateType extends BlockState<BlockStateType,CallContextType,CallEdgeType>,CallContextType extends ICallContext<CallContextType>>public void generateUnreachableMap()
public Set<AbstractNode> getReachableNodes()
public int getTotalNumberOfNodeTransfers()
IMonitoringgetTotalNumberOfNodeTransfers in interface IMonitoring<BlockStateType extends BlockState<BlockStateType,CallContextType,CallEdgeType>,CallContextType extends ICallContext<CallContextType>>public Map<TypeCollector.VariableSummary,Value> getTypeInformation()
public void presentTypeInformation()
public void reportShadowing(FlowGraph fg)
public String toString()
public void visitBlockTransfer()
visitBlockTransfer in interface IMonitoring<BlockStateType extends BlockState<BlockStateType,CallContextType,CallEdgeType>,CallContextType extends ICallContext<CallContextType>>public void visitCall(AbstractNode n, boolean maybe_non_function, boolean maybe_function)
n - node responsible for the callmaybe_non_function - if set, this call may involve a non-function valuemaybe_function - if set, this call may involve a function valuepublic void visitEvalCall(AbstractNode n, Value v)
n - node that may call evalv - value being eval'edpublic void visitFunction(Function f, Collection<BlockStateType> entry_states)
visitFunction in interface IMonitoring<BlockStateType extends BlockState<BlockStateType,CallContextType,CallEdgeType>,CallContextType extends ICallContext<CallContextType>>public void visitIf(IfNode n, Value v)
n - if nodev - the boolean valuepublic void visitIn(AbstractNode n, boolean maybe_v2_object, boolean maybe_v2_nonobject)
n - node performing the operationmaybe_v2_object - if the second parameter may be an object valuemaybe_v2_nonobject - if the second parameter may be a non-object valuepublic void visitInnerHTMLWrite(Node n, Value v)
n - node where the write occursv - value being writtenpublic void visitInstanceof(AbstractNode n, boolean maybe_v2_non_function, boolean maybe_v2_function, boolean maybe_v2_prototype_primitive, boolean maybe_v2_prototype_nonprimitive)
n - node performing the operationmaybe_v2_non_function - set if the second parameter may be a non-function valuemaybe_v2_function - set if the second parameter may be a function valuemaybe_v2_prototype_primitive - set if the prototype property of the second parameter may be a primitive valuemaybe_v2_prototype_nonprimitive - set if the prototype property of the second parameter may be an object valuepublic void visitJoin()
IMonitoringvisitJoin in interface IMonitoring<BlockStateType extends BlockState<BlockStateType,CallContextType,CallEdgeType>,CallContextType extends ICallContext<CallContextType>>public void visitNativeFunctionCall(AbstractNode n, HostObject hostobject, boolean num_actuals_unknown, int num_actuals, int min, int max)
n - node responsible for the callhostobject - the native function being callednum_actuals_unknown - if set, the number of actuals is unknownnum_actuals - number of actuals (if num_actuals_unknown is not set)min - minimum number of parameters expectedmax - maximum number of paramaters expected (-1 for any number)public void visitNewFlow(BasicBlock b, ICallContext<?> c, IBlockState<?,?,?> s, String diff, String info)
IMonitoringvisitNewFlow in interface IMonitoring<BlockStateType extends BlockState<BlockStateType,CallContextType,CallEdgeType>,CallContextType extends ICallContext<CallContextType>>public void visitNodeTransfer(AbstractNode n)
IMonitoringvisitNodeTransfer in interface IMonitoring<BlockStateType extends BlockState<BlockStateType,CallContextType,CallEdgeType>,CallContextType extends ICallContext<CallContextType>>public void visitPropertyAccess(Node n, Value baseval)
n - operation that accesses a propertybaseval - base value for the accesspublic void visitPropertyRead(Node n, Set<ObjectLabel> objs, Str propertystr, BlockStateType state)
n - the node responsible for the readobjs - the objects being read frompropertystr - description of the property namepublic void visitPropertyWrite(Node n, Set<ObjectLabel> objs, Str propertystr)
n - the node responsible for the writeobjs - the objects being written topropertystr - description of the property namepublic void visitReachableNode(AbstractNode n)
IMonitoringvisitReachableNode in interface IMonitoring<BlockStateType extends BlockState<BlockStateType,CallContextType,CallEdgeType>,CallContextType extends ICallContext<CallContextType>>public void visitRead(Node n, ICallContext<?> c, Value v)
public void visitReadNonThisVariable(ReadVariableNode n, Value v)
n - (non-this) read variable operationv - the value being readpublic void visitReadProperty(ReadPropertyNode n, Set<ObjectLabel> objlabels, Str propertystr, boolean maybe, BlockStateType state)
n - read property operationobjlabels - objects being read frompropertystr - description of the property namemaybe - if there may be more than one valuestate - current abstract statepublic void visitReadThis(ReadVariableNode n, Value v, BlockStateType state, ObjectLabel global_obj)
n - (this) read variable operationv - the value being readstate - public void visitReadVariable(ReadVariableNode n, Value v, BlockStateType state)
n - read variable operationv - the value being readpublic void visitRecoveryGraph(int size)
IMonitoringvisitRecoveryGraph in interface IMonitoring<BlockStateType extends BlockState<BlockStateType,CallContextType,CallEdgeType>,CallContextType extends ICallContext<CallContextType>>public void visitUnknownValueResolve()
IMonitoringvisitUnknownValueResolve in interface IMonitoring<BlockStateType extends BlockState<BlockStateType,CallContextType,CallEdgeType>,CallContextType extends ICallContext<CallContextType>>public void visitUserFunctionCall(Function f, AbstractNode call, boolean constructor)
f - function being calledcall - node responsible for the callconstructor - if set, the call uses 'new'public void visitVariableAsRead(ReadVariableNode n, Value v)
n - (non-this) read variable operationv - value being readpublic void visitVariableOrProperty(String var, SourceLocation loc, Value value)
public void visitWriteVariable(WriteVariableNode n, Value v, BlockStateType state)
n - write variable operationv - value being writtenstate - current abstract stateCopyright © 2012 Aarhus University