1.1 --- a/emul/src/main/resources/org/apidesign/vm4brwsr/emul/java_lang_String.js Tue Jan 15 12:38:49 2013 +0100
1.2 +++ b/emul/src/main/resources/org/apidesign/vm4brwsr/emul/java_lang_String.js Tue Jan 15 12:44:33 2013 +0100
1.3 @@ -7,12 +7,15 @@
1.4 this.jvmName = sig;
1.5 return this;
1.6 };
1.7 -Array.prototype.at = function(indx) {
1.8 +Array.prototype.at = function(indx, value) {
1.9 if (indx < 0 || indx > this.length) {
1.10 var e = vm.java_lang_ArrayIndexOutOfBoundsException(true);
1.11 e.constructor.cons__VLjava_lang_String_2.call(e, indx.toString());
1.12 throw e;
1.13 }
1.14 + if (arguments.length === 2) {
1.15 + this[indx] = value;
1.16 + }
1.17 return this[indx];
1.18 };
1.19 Array.prototype.getClass__Ljava_lang_Class_2 = function() {
2.1 --- a/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java Tue Jan 15 12:38:49 2013 +0100
2.2 +++ b/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java Tue Jan 15 12:44:33 2013 +0100
2.3 @@ -973,26 +973,26 @@
2.4 emit(out, "@2 = @1.length;", smapper.popA(), smapper.pushI());
2.5 break;
2.6 case opc_lastore:
2.7 - emit(out, "@3[@2] = @1;",
2.8 + emit(out, "@3.at(@2, @1);",
2.9 smapper.popL(), smapper.popI(), smapper.popA());
2.10 break;
2.11 case opc_fastore:
2.12 - emit(out, "@3[@2] = @1;",
2.13 + emit(out, "@3.at(@2, @1);",
2.14 smapper.popF(), smapper.popI(), smapper.popA());
2.15 break;
2.16 case opc_dastore:
2.17 - emit(out, "@3[@2] = @1;",
2.18 + emit(out, "@3.at(@2, @1);",
2.19 smapper.popD(), smapper.popI(), smapper.popA());
2.20 break;
2.21 case opc_aastore:
2.22 - emit(out, "@3[@2] = @1;",
2.23 + emit(out, "@3.at(@2, @1);",
2.24 smapper.popA(), smapper.popI(), smapper.popA());
2.25 break;
2.26 case opc_iastore:
2.27 case opc_bastore:
2.28 case opc_castore:
2.29 case opc_sastore:
2.30 - emit(out, "@3[@2] = @1;",
2.31 + emit(out, "@3.at(@2, @1);",
2.32 smapper.popI(), smapper.popI(), smapper.popA());
2.33 break;
2.34 case opc_laload:
3.1 --- a/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/CompareByteArrayTest.java Tue Jan 15 12:38:49 2013 +0100
3.2 +++ b/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/CompareByteArrayTest.java Tue Jan 15 12:44:33 2013 +0100
3.3 @@ -61,10 +61,22 @@
3.4 return atIndex(-1);
3.5 }
3.6
3.7 + @Compare public String toOfBounds() {
3.8 + return toIndex(5);
3.9 + }
3.10 +
3.11 + @Compare public String toOfBoundsMinus() {
3.12 + return toIndex(-1);
3.13 + }
3.14 +
3.15 private static final int[] arr = { 0, 1, 2 };
3.16 public static String atIndex(int at) {
3.17 return "at@" + arr[at];
3.18 }
3.19 + public static String toIndex(int at) {
3.20 + arr[at] = 10;
3.21 + return "ok";
3.22 + }
3.23
3.24
3.25 @Factory