1.1 --- a/vm/src/main/java/org/apidesign/vm4brwsr/GenJS.java Tue Sep 25 17:30:13 2012 +0200
1.2 +++ b/vm/src/main/java/org/apidesign/vm4brwsr/GenJS.java Fri Sep 28 07:27:34 2012 +0200
1.3 @@ -49,6 +49,54 @@
1.4 ) {
1.5 continue;
1.6 }
1.7 + InputStream emul = GenJS.class.getResourceAsStream("emulation/" + name.replace('/', '_') + ".js");
1.8 + if (emul != null) {
1.9 + try {
1.10 + int state = 0;
1.11 + for (;;) {
1.12 + int ch = emul.read();
1.13 + if (ch == -1) {
1.14 + break;
1.15 + }
1.16 + if (ch < 0 || ch > 255) {
1.17 + throw new IOException("Invalid char in emulation " + ch);
1.18 + }
1.19 + switch (state) {
1.20 + case 0:
1.21 + if (ch == '/') {
1.22 + state = 1;
1.23 + } else {
1.24 + out.append((char)ch);
1.25 + }
1.26 + break;
1.27 + case 1:
1.28 + if (ch == '*') {
1.29 + state = 2;
1.30 + } else {
1.31 + out.append('/').append((char)ch);
1.32 + state = 0;
1.33 + }
1.34 + break;
1.35 + case 2:
1.36 + if (ch == '*') {
1.37 + state = 3;
1.38 + }
1.39 + break;
1.40 + case 3:
1.41 + if (ch == '/') {
1.42 + state = 0;
1.43 + } else {
1.44 + state = 2;
1.45 + }
1.46 + break;
1.47 + }
1.48 + }
1.49 + } finally {
1.50 + emul.close();
1.51 + }
1.52 + continue;
1.53 + }
1.54 +
1.55 InputStream is = GenJS.class.getClassLoader().getResourceAsStream(name + ".class");
1.56 if (is == null) {
1.57 throw new IOException("Can't find class " + name);