sandmark.util.controlflowgraph
Class PositiveIntSynthesizer
java.lang.Object
|
+--sandmark.util.controlflowgraph.ControlFlowSynthesizer
|
+--sandmark.util.controlflowgraph.IntFuncSynthesizer
|
+--sandmark.util.controlflowgraph.PositiveIntSynthesizer
- public class PositiveIntSynthesizer
- extends IntFuncSynthesizer
A PositiveIntSyntheizer generates an integer function that works
by maintaining the "hidden" invariant: its one variable always has
a nonnegative value. The function argument is made non-negative
using a randomly chosen code fragment. Basic block code fragments
(also randomly chosen) preserve the invariant.
Code can be generated to force a positive, negative, zero, or
nonzero result, allowing use with an opaque predicate.
Method Summary |
MethodCFG |
generate(Graph graph,
de.fub.bytecode.generic.ConstantPoolGen cpg)
Generates an integer function corresponding to the given graph.
|
MethodCFG |
generate(Graph graph,
de.fub.bytecode.generic.ConstantPoolGen cpg,
short opcode)
Generates an integer function with a constraint on the returned result.
|
static void |
main(java.lang.String[] args)
Test driver; see ControlFlowSynthesizer.test. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PositiveIntSynthesizer
public PositiveIntSynthesizer()
generate
public MethodCFG generate(Graph graph,
de.fub.bytecode.generic.ConstantPoolGen cpg)
- Generates an integer function corresponding to the given graph.
All graphs are acceptable.
The generated code is guaranteed to return safely, without throwing
an exception, provided that the graph contains at least one leaf node.
(A leaf node produces a return. With no return, the code loops forever.)
- Specified by:
generate
in class ControlFlowSynthesizer
generate
public MethodCFG generate(Graph graph,
de.fub.bytecode.generic.ConstantPoolGen cpg,
short opcode)
- Generates an integer function with a constraint on the returned result.
The opcode argument is one of the de.fub.bytecode.Constants values
IFLT, IFLE, IFEQ, IFNE, IFGE, IFGT, or NOP. The generated code will
ensure, for any passed argument, that the result value passes the test
(takes the jump) indicated by the opcode. A NOP argument indicates a
don't-care situation where the result is unconstrained.
main
public static void main(java.lang.String[] args)
throws java.lang.Exception
- Test driver; see ControlFlowSynthesizer.test.
java.lang.Exception