|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--de.fub.bytecode.generic.FindPattern
This class is an utility to search for given patterns, i.e., regular expressions in an instruction list. This can be used in order to implement a peep hole optimizer that looks for code patterns and replaces them with faster equivalents. This class internally uses the package gnu.regexp to search for regular expressions.
Instruction
,
InstructionList
,
CodeConstraint
Constructor Summary | |
FindPattern(InstructionList il)
|
Method Summary | |
InstructionList |
getInstructionList()
|
InstructionHandle[] |
getMatch()
|
int |
getMatchLength()
|
void |
reread()
Rereads the instruction list, e.g., after you've altered the list upon a match. |
InstructionHandle |
search(java.lang.String pattern)
Start search beginning from the start of the given instruction list. |
InstructionHandle |
search(java.lang.String pattern,
CodeConstraint constraint)
Start search beginning from the start of the given instruction list. |
InstructionHandle |
search(java.lang.String pattern,
InstructionHandle from)
Start search beginning from `from'. |
InstructionHandle |
search(java.lang.String pattern,
InstructionHandle from,
CodeConstraint constraint)
Search for the given pattern in the InstructionList. |
void |
setInstructionList(InstructionList il)
Defines a new instruction list. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public FindPattern(InstructionList il)
il
- instruction list to search for given patternsMethod Detail |
public final void reread()
public final InstructionHandle search(java.lang.String pattern, InstructionHandle from, CodeConstraint constraint)
Example pattern:
search("(`BranchInstruction')`NOP'((`IF_ICMP__'|`GOTO')+`ISTORE__'`Instruction')*");
pattern
- the instruction pattern to search for, case is ignoredfrom
- where to start the search in the instruction listconstraint
- optional CodeConstraint to check the found code pattern for
given constraintspublic final InstructionHandle search(java.lang.String pattern)
pattern
- the instruction pattern to search for, case is ignoredpublic final InstructionHandle search(java.lang.String pattern, InstructionHandle from)
pattern
- the instruction pattern to search for, case is ignoredfrom
- where to start the search in the instruction listpublic final InstructionHandle search(java.lang.String pattern, CodeConstraint constraint)
pattern
- the instruction pattern to search for, case is ignoredconstraint
- constraints to be checked on matching codepublic final int getMatchLength()
public final InstructionHandle[] getMatch()
public final void setInstructionList(InstructionList il)
il
- the new instuction listpublic final InstructionList getInstructionList()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |