rt/vm/src/main/java/org/apidesign/vm4brwsr/Bck2Brwsr.java
branchflow
changeset 1842 dd4dabfead82
parent 1816 6c1fa412c72d
     1.1 --- a/rt/vm/src/main/java/org/apidesign/vm4brwsr/Bck2Brwsr.java	Fri Mar 13 11:41:04 2015 +0100
     1.2 +++ b/rt/vm/src/main/java/org/apidesign/vm4brwsr/Bck2Brwsr.java	Fri Sep 11 14:51:09 2015 +0200
     1.3 @@ -422,10 +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 +        private final Appendable emit;
    1.10 +        Flow(MethodData m, Appendable emit) {
    1.11              this.m = m;
    1.12 -            ops = new byte[m.getCode().length];
    1.13 +            this.emit = emit;
    1.14          }
    1.15          
    1.16          /** Access to bytecode of the method to analyse.
    1.17 @@ -442,47 +442,12 @@
    1.18          public String getMethodName() {
    1.19              return m.getName();
    1.20          }
    1.21 -        
    1.22 -        public void beginLoopAt(int bci) {
    1.23 -            ops[bci] |= 0x10;
    1.24 -        }
    1.25 -        
    1.26 -        public void beginIfAt(int bci) {
    1.27 -            ops[bci] |= 0x20;
    1.28 -        }
    1.29  
    1.30 -
    1.31 -        public void breakAt(int bci) {
    1.32 -            ops[bci] |= 0x40;
    1.33 -        }
    1.34 -
    1.35 -        public void beginElseAt(int bci) {
    1.36 -            ops[bci] |= 0x80;
    1.37 -        }
    1.38 -
    1.39 -        public void endAt(int bci) {
    1.40 -            int cnt = (ops[bci] & 0x0f) + 1;
    1.41 -            int rest = ops[bci] & 0xf0;
    1.42 -            ops[bci] = (byte)(rest | cnt);
    1.43 -        }
    1.44 -        
    1.45 -        boolean isFlow(int at) {
    1.46 -            return ops[at] != 0;
    1.47 -        }
    1.48 -        boolean isLoop(int at) {
    1.49 -            return (ops[at] & 0x10) != 0;
    1.50 -        }
    1.51 -        boolean isIf(int at) {
    1.52 -            return (ops[at] & 0x20) != 0;
    1.53 -        }
    1.54 -        boolean isBreak(int at) {
    1.55 -            return (ops[at] & 0x40) != 0;
    1.56 -        }
    1.57 -        boolean isElse(int at) {
    1.58 -            return (ops[at] & 0x80) != 0;
    1.59 -        }
    1.60 -        int isEnd(int at) {
    1.61 -            return (ops[at] & 0x0f);
    1.62 +        /** Emits JavaScript to the final JavaScript output.
    1.63 +         * @param seq text to emit
    1.64 +         */
    1.65 +        public void emit(CharSequence seq) throws IOException {
    1.66 +            this.emit.append(seq);
    1.67          }
    1.68          
    1.69          /** Provider of advanced analysis of the code flow inside of
    1.70 @@ -500,7 +465,7 @@
    1.71               * @return <code>true</code> if the analysis was successful,
    1.72               *   <code>false</code> otherwise
    1.73               */
    1.74 -            public boolean analyze(Flow request);
    1.75 +            public boolean analyze(Flow request) throws IOException;
    1.76          }
    1.77      }
    1.78