public class ExpressionList extends Object
Constructor and Description |
---|
ExpressionList(MethodModel _methodModel) |
Modifier and Type | Method and Description |
---|---|
Instruction |
add(Instruction _instruction)
Add this instruction to the end of the list.
|
Instruction |
createList(Instruction _newTail)
[1] [2] [3] [4]
Note that passing null here essentially deletes the existing expression list and returns the expression
|
boolean |
doesNotContainCompositeOrBranch(Instruction _start,
Instruction _exclusiveEnd) |
boolean |
doesNotContainContinueOrBreak(Instruction _start,
Instruction _extent)
Determine whether the sequence of instructions from _start to _extent is free of branches which extend beyond _extent.
|
String |
dumpDiagram(Instruction _instruction)
Aids debugging.
|
boolean |
foldComposite(Instruction _instruction)
Fold headTail.tail into valid composites
|
Instruction |
getHead() |
Instruction |
getTail() |
void |
insertBetween(Instruction _prev,
Instruction _next,
Instruction _newOne)
Insert the given instruction (_newone) between the existing entries (_prev and _next).
|
void |
replaceInclusive(Instruction _head,
Instruction _tail,
Instruction _newOne)
Inclusive replace between _head and _tail with _newOne.
|
void |
unwind() |
public ExpressionList(MethodModel _methodModel)
public boolean doesNotContainContinueOrBreak(Instruction _start, Instruction _extent)
_start
- _extent
- public boolean doesNotContainCompositeOrBranch(Instruction _start, Instruction _exclusiveEnd)
public void unwind()
public Instruction createList(Instruction _newTail)
_newTail
- public Instruction add(Instruction _instruction)
_instruction
- public void insertBetween(Instruction _prev, Instruction _next, Instruction _newOne)
_prev
- _next
- _newOne
- public void replaceInclusive(Instruction _head, Instruction _tail, Instruction _newOne)
| | --> | | ---> ... ---> | | ---> | | | prev | | _head | | _tail | | next | | | <-- | | <--- ... <----| | <--- | |To
| | --> | | ---> | | | prev | | _newOne | | next | | | <-- | | <--- | |
public boolean foldComposite(Instruction _instruction) throws ClassParseException
if(??){then}... ?? ?> [THEN] ... --------> if (??){THEN}else{ELSE}... ?? ?> [THEN] >> [ELSE] ... ------------> --------> sun for (INIT,??,DELTA){BODY} ... [INIT] ?? ?> [BODY] [DELTA] << ... ------------------> <------------------- sun for (,??,DELTA){BODY} ... ?? ?> [BODY] [DELTA] << ... ------------------> <------------------- sun while (?){l} ... ?? ?> [BODY] << ... -----------> <------------ eclipse for (INIT,??,DELTA){BODY} ... [INIT] >> [BODY] [DELTA] ?? ?< ... ----------------> <----------------- eclipse for (,??,DELTA){BODY} ... >> [BODY] [DELTA] ?? ?< ... ---------------> <----------------- eclipse while (??){BODY} ... >> [BODY] ?? ?< ... --------> <---------- eclipe if (?1) { while (?2) {BODY} } else {ELSE} ... ?1 ?> >> [BODY] ?2 ?< >> [ELSE] ... ---------> <--------- ---------------------> --------> sun for (,?1,DELTA){ if (?2) { THEN break; } BODY} ... ?1 ?> ?2 ?> [THEN] >> [BODY] [DELTA] << ... -----------> ----------------------------------> ------------------> <------------------------------------ sun for (,?1,DELTA){ if (?2) { THEN continue; } BODY} ... ?1 ?> ?2 ?> THEN >> [BODY] [DELTA] << ... ---------> --------> --------------------------------> <---------------------------------- Some exceptions based on sun javac optimizations if (?1){ if (?2){THEN} }else{ ELSE } ... One might expect ?1 ?> ?2 ?> [THEN] >> [ELSE] ... -----------------> -------->! -------------> However the conditional branch to the unconditional (!) is optimized away and instead the unconditional inverted and extended ?1 ?> ?2 ?> [THEN] >> [ELSE] ... -----------------> --------*---------> sun if (?1) { while (?2) {l} } else {e} ... One might expect ?1 ?> ?2 ?> [BODY] << >> [ELSE] ... -------------------> ----------->! <---------- --------> However as above the conditional branch to the unconditional (!) can be optimized away and the conditional inverted and extended ?1 ?> ?2 ?> [BODY] << >> [ELSE] ... --------------------> -----------*---------> <----------- However we can also now remove the forward unconditional completely as it is unreachable ?1 ?> ?2 ?> [BODY] << [ELSE] ... -----------------> ------------------> <----------- sun while(?1){if (?2) {THEN} else {ELSE} } ... One might expect ?1 ?> ?2 ?> [BODY] >> [ELSE] << ... --------------------------> <--------------------- ----------> ------->! However the unconditional branch to the unconditional backbranch (!) can be optimized away and the unconditional wrapped back directly to the loop control head ?1 ?> ?2 ?> [BODY] << [ELSE] << ... --------------------------> <--------------------- ----------> <-----------
_instruction
- ClassParseException
public String dumpDiagram(Instruction _instruction)
I I I C C I U I U[I]I |---------->1 |---->1 |------>2 |-->2
_cursor
- The instruction we are looking at_instruction
- The instruction we are considering adding (may be null)public Instruction getTail()
public Instruction getHead()
Copyright © 2016 Syncleus. All rights reserved.