1.1 --- a/rt/vm/src/main/java/org/apidesign/vm4brwsr/Bck2Brwsr.java Thu Mar 12 10:32:13 2015 +0100
1.2 +++ b/rt/vm/src/main/java/org/apidesign/vm4brwsr/Bck2Brwsr.java Fri Mar 13 11:41:04 2015 +0100
1.3 @@ -422,8 +422,10 @@
1.4 */
1.5 public static final class Flow {
1.6 private final MethodData m;
1.7 + private byte[] ops;
1.8 Flow(MethodData m) {
1.9 this.m = m;
1.10 + ops = new byte[m.getCode().length];
1.11 }
1.12
1.13 /** Access to bytecode of the method to analyse.
1.14 @@ -441,10 +443,46 @@
1.15 return m.getName();
1.16 }
1.17
1.18 - public void registerCycle(int offset) {
1.19 + public void beginLoopAt(int bci) {
1.20 + ops[bci] |= 0x10;
1.21 }
1.22
1.23 - public void registerIf(int offset) {
1.24 + public void beginIfAt(int bci) {
1.25 + ops[bci] |= 0x20;
1.26 + }
1.27 +
1.28 +
1.29 + public void breakAt(int bci) {
1.30 + ops[bci] |= 0x40;
1.31 + }
1.32 +
1.33 + public void beginElseAt(int bci) {
1.34 + ops[bci] |= 0x80;
1.35 + }
1.36 +
1.37 + public void endAt(int bci) {
1.38 + int cnt = (ops[bci] & 0x0f) + 1;
1.39 + int rest = ops[bci] & 0xf0;
1.40 + ops[bci] = (byte)(rest | cnt);
1.41 + }
1.42 +
1.43 + boolean isFlow(int at) {
1.44 + return ops[at] != 0;
1.45 + }
1.46 + boolean isLoop(int at) {
1.47 + return (ops[at] & 0x10) != 0;
1.48 + }
1.49 + boolean isIf(int at) {
1.50 + return (ops[at] & 0x20) != 0;
1.51 + }
1.52 + boolean isBreak(int at) {
1.53 + return (ops[at] & 0x40) != 0;
1.54 + }
1.55 + boolean isElse(int at) {
1.56 + return (ops[at] & 0x80) != 0;
1.57 + }
1.58 + int isEnd(int at) {
1.59 + return (ops[at] & 0x0f);
1.60 }
1.61
1.62 /** Provider of advanced analysis of the code flow inside of