diff --git a/compiler-lib/src/firm/method_body_generator.rs b/compiler-lib/src/firm/method_body_generator.rs index 49f2552a4..3b4c85c7a 100644 --- a/compiler-lib/src/firm/method_body_generator.rs +++ b/compiler-lib/src/firm/method_body_generator.rs @@ -269,13 +269,13 @@ impl<'a, 'ir, 'src, 'ast> MethodBodyGenerator<'ir, 'src, 'ast> { &mut self, res_expr: &Option>>>, ) -> LastBlockJumps { - let mem = self.graph.cur_store(); let res = res_expr.as_ref().map(|res_expr| { self.gen_expr(&*res_expr) .enforce_value(self.graph) .mature_entry() }); + let mem = self.graph.cur_store(); let ret = self.graph.cur_block().new_return(mem, res); self.graph.end_block().add_pred(&ret); diff --git a/integration-tests/binary/eval_order.mj b/integration-tests/binary/eval_order.mj new file mode 100644 index 000000000..1d2e668aa --- /dev/null +++ b/integration-tests/binary/eval_order.mj @@ -0,0 +1,13 @@ +class EvalOrder { + public int n; + public static void main(String[] args) { + EvalOrder a = new EvalOrder(); + int x = a.u(); + System.out.println(x); + System.out.println(a.n); + } + + public int u() { + return n = 42; + } +} diff --git a/integration-tests/binary/eval_order.mj.exitcode b/integration-tests/binary/eval_order.mj.exitcode new file mode 100644 index 000000000..c22708346 --- /dev/null +++ b/integration-tests/binary/eval_order.mj.exitcode @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/integration-tests/binary/eval_order.mj.stderr b/integration-tests/binary/eval_order.mj.stderr new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/binary/eval_order.mj.stdout b/integration-tests/binary/eval_order.mj.stdout new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/binary/eval_order.out.exitcode b/integration-tests/binary/eval_order.out.exitcode new file mode 100644 index 000000000..c22708346 --- /dev/null +++ b/integration-tests/binary/eval_order.out.exitcode @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/integration-tests/binary/eval_order.out.stderr b/integration-tests/binary/eval_order.out.stderr new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/binary/eval_order.out.stdout b/integration-tests/binary/eval_order.out.stdout new file mode 100644 index 000000000..daaac9e30 --- /dev/null +++ b/integration-tests/binary/eval_order.out.stdout @@ -0,0 +1,2 @@ +42 +42 diff --git a/integration-tests/binary/jls_15_12_4.mj b/integration-tests/binary/jls_15_12_4.mj new file mode 100644 index 000000000..f95e1c2cd --- /dev/null +++ b/integration-tests/binary/jls_15_12_4.mj @@ -0,0 +1,11 @@ +class Test { + public static void main(String[] args) { + Test t = new Test(); + t.test(1).test(2); + } + + public Test test(int i) { + System.out.println(i); + return this; + } +} diff --git a/integration-tests/binary/jls_15_12_4.mj.exitcode b/integration-tests/binary/jls_15_12_4.mj.exitcode new file mode 100644 index 000000000..c22708346 --- /dev/null +++ b/integration-tests/binary/jls_15_12_4.mj.exitcode @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/integration-tests/binary/jls_15_12_4.mj.stderr b/integration-tests/binary/jls_15_12_4.mj.stderr new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/binary/jls_15_12_4.mj.stdout b/integration-tests/binary/jls_15_12_4.mj.stdout new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/binary/jls_15_12_4.out.exitcode b/integration-tests/binary/jls_15_12_4.out.exitcode new file mode 100644 index 000000000..c22708346 --- /dev/null +++ b/integration-tests/binary/jls_15_12_4.out.exitcode @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/integration-tests/binary/jls_15_12_4.out.stderr b/integration-tests/binary/jls_15_12_4.out.stderr new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/binary/jls_15_12_4.out.stdout b/integration-tests/binary/jls_15_12_4.out.stdout new file mode 100644 index 000000000..1191247b6 --- /dev/null +++ b/integration-tests/binary/jls_15_12_4.out.stdout @@ -0,0 +1,2 @@ +1 +2 diff --git a/integration-tests/binary/jls_15_13_1_1.mj b/integration-tests/binary/jls_15_13_1_1.mj new file mode 100644 index 000000000..5eaafdafd --- /dev/null +++ b/integration-tests/binary/jls_15_13_1_1.mj @@ -0,0 +1,13 @@ +class Test1 { + public static void main(String[] args) { + int[] a = new int[2]; + a[0] = 10; + a[1] = 11; + int[] b = new int[3]; + b[0] = 2; + b[1] = 1; + b[2] = 0; + + System.out.println(a[(a=b)[2]]); + } +} diff --git a/integration-tests/binary/jls_15_13_1_1.mj.exitcode b/integration-tests/binary/jls_15_13_1_1.mj.exitcode new file mode 100644 index 000000000..c22708346 --- /dev/null +++ b/integration-tests/binary/jls_15_13_1_1.mj.exitcode @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/integration-tests/binary/jls_15_13_1_1.mj.stderr b/integration-tests/binary/jls_15_13_1_1.mj.stderr new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/binary/jls_15_13_1_1.mj.stdout b/integration-tests/binary/jls_15_13_1_1.mj.stdout new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/binary/jls_15_13_1_1.out.exitcode b/integration-tests/binary/jls_15_13_1_1.out.exitcode new file mode 100644 index 000000000..c22708346 --- /dev/null +++ b/integration-tests/binary/jls_15_13_1_1.out.exitcode @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/integration-tests/binary/jls_15_13_1_1.out.stderr b/integration-tests/binary/jls_15_13_1_1.out.stderr new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/binary/jls_15_13_1_1.out.stdout b/integration-tests/binary/jls_15_13_1_1.out.stdout new file mode 100644 index 000000000..f599e28b8 --- /dev/null +++ b/integration-tests/binary/jls_15_13_1_1.out.stdout @@ -0,0 +1 @@ +10 diff --git a/integration-tests/binary/jls_15_13_1_2.mj b/integration-tests/binary/jls_15_13_1_2.mj new file mode 100644 index 000000000..dde2ae4ec --- /dev/null +++ b/integration-tests/binary/jls_15_13_1_2.mj @@ -0,0 +1,21 @@ +class Test2 { + public static void main(String[] args) { + Test2 t = new Test2(); + System.out.println(t.array()[t.test()]); + } + + public int[] array() { + System.out.println(5); + int[] ret = new int[3]; + ret[0] = 5; + ret[1] = 5; + ret[2] = 5; + int x = 1 / 0; + return ret; + } + + public int test() { + System.out.println(10); + return 0; + } +} diff --git a/integration-tests/binary/jls_15_13_1_2.mj.exitcode b/integration-tests/binary/jls_15_13_1_2.mj.exitcode new file mode 100644 index 000000000..c22708346 --- /dev/null +++ b/integration-tests/binary/jls_15_13_1_2.mj.exitcode @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/integration-tests/binary/jls_15_13_1_2.mj.stderr b/integration-tests/binary/jls_15_13_1_2.mj.stderr new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/binary/jls_15_13_1_2.mj.stdout b/integration-tests/binary/jls_15_13_1_2.mj.stdout new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/binary/jls_15_13_1_2.out.exitcode b/integration-tests/binary/jls_15_13_1_2.out.exitcode new file mode 100644 index 000000000..54e138953 --- /dev/null +++ b/integration-tests/binary/jls_15_13_1_2.out.exitcode @@ -0,0 +1 @@ +terminated by signal or crashed. \ No newline at end of file diff --git a/integration-tests/binary/jls_15_13_1_2.out.stderr b/integration-tests/binary/jls_15_13_1_2.out.stderr new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/binary/jls_15_13_1_2.out.stdout b/integration-tests/binary/jls_15_13_1_2.out.stdout new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/binary/jls_15_13_1_3.mj b/integration-tests/binary/jls_15_13_1_3.mj new file mode 100644 index 000000000..353b3ef6f --- /dev/null +++ b/integration-tests/binary/jls_15_13_1_3.mj @@ -0,0 +1,19 @@ +class Test3 { + public static void main(String[] args) { + Test3 t = new Test3(); + int[][] arr = new int[3][]; + int i = 0; + while (i < 3) { + arr[i] = new int[1]; + arr[i][0] = 5; + i = i + 1; + } + System.out.println(arr[t.test(1)][t.test(2)]); + } + + public int test(int i) { + System.out.println(i); + int x = 1 / 0; + return 0; + } +} diff --git a/integration-tests/binary/jls_15_13_1_3.mj.exitcode b/integration-tests/binary/jls_15_13_1_3.mj.exitcode new file mode 100644 index 000000000..c22708346 --- /dev/null +++ b/integration-tests/binary/jls_15_13_1_3.mj.exitcode @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/integration-tests/binary/jls_15_13_1_3.mj.stderr b/integration-tests/binary/jls_15_13_1_3.mj.stderr new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/binary/jls_15_13_1_3.mj.stdout b/integration-tests/binary/jls_15_13_1_3.mj.stdout new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/binary/jls_15_13_1_3.out.exitcode b/integration-tests/binary/jls_15_13_1_3.out.exitcode new file mode 100644 index 000000000..54e138953 --- /dev/null +++ b/integration-tests/binary/jls_15_13_1_3.out.exitcode @@ -0,0 +1 @@ +terminated by signal or crashed. \ No newline at end of file diff --git a/integration-tests/binary/jls_15_13_1_3.out.stderr b/integration-tests/binary/jls_15_13_1_3.out.stderr new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/binary/jls_15_13_1_3.out.stdout b/integration-tests/binary/jls_15_13_1_3.out.stdout new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/binary/jls_15_26.mj b/integration-tests/binary/jls_15_26.mj new file mode 100644 index 000000000..fb34a5d86 --- /dev/null +++ b/integration-tests/binary/jls_15_26.mj @@ -0,0 +1,17 @@ +class Test { + public int i; + public static void main(String[] args) { + Test t = new Test(); + t.getTest().i = t.test(); + } + + public int test() { + System.out.println(10); + return 10; + } + + public Test getTest() { + this.i = 1 / 0; + return this; + } +} diff --git a/integration-tests/binary/jls_15_26.mj.exitcode b/integration-tests/binary/jls_15_26.mj.exitcode new file mode 100644 index 000000000..c22708346 --- /dev/null +++ b/integration-tests/binary/jls_15_26.mj.exitcode @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/integration-tests/binary/jls_15_26.mj.stderr b/integration-tests/binary/jls_15_26.mj.stderr new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/binary/jls_15_26.mj.stdout b/integration-tests/binary/jls_15_26.mj.stdout new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/binary/jls_15_26.out.exitcode b/integration-tests/binary/jls_15_26.out.exitcode new file mode 100644 index 000000000..54e138953 --- /dev/null +++ b/integration-tests/binary/jls_15_26.out.exitcode @@ -0,0 +1 @@ +terminated by signal or crashed. \ No newline at end of file diff --git a/integration-tests/binary/jls_15_26.out.stderr b/integration-tests/binary/jls_15_26.out.stderr new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/binary/jls_15_26.out.stdout b/integration-tests/binary/jls_15_26.out.stdout new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/binary/jls_15_7_1_1.mj b/integration-tests/binary/jls_15_7_1_1.mj new file mode 100644 index 000000000..06cfbfd79 --- /dev/null +++ b/integration-tests/binary/jls_15_7_1_1.mj @@ -0,0 +1,7 @@ +class Test1 { + public static void main(String[] args) { + int i = 2; + int j = (i=3) * i; + System.out.println(j); + } +} diff --git a/integration-tests/binary/jls_15_7_1_1.mj.exitcode b/integration-tests/binary/jls_15_7_1_1.mj.exitcode new file mode 100644 index 000000000..c22708346 --- /dev/null +++ b/integration-tests/binary/jls_15_7_1_1.mj.exitcode @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/integration-tests/binary/jls_15_7_1_1.mj.stderr b/integration-tests/binary/jls_15_7_1_1.mj.stderr new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/binary/jls_15_7_1_1.mj.stdout b/integration-tests/binary/jls_15_7_1_1.mj.stdout new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/binary/jls_15_7_1_1.out.exitcode b/integration-tests/binary/jls_15_7_1_1.out.exitcode new file mode 100644 index 000000000..c22708346 --- /dev/null +++ b/integration-tests/binary/jls_15_7_1_1.out.exitcode @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/integration-tests/binary/jls_15_7_1_1.out.stderr b/integration-tests/binary/jls_15_7_1_1.out.stderr new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/binary/jls_15_7_1_1.out.stdout b/integration-tests/binary/jls_15_7_1_1.out.stdout new file mode 100644 index 000000000..ec635144f --- /dev/null +++ b/integration-tests/binary/jls_15_7_1_1.out.stdout @@ -0,0 +1 @@ +9 diff --git a/integration-tests/binary/jls_15_7_1_2.mj b/integration-tests/binary/jls_15_7_1_2.mj new file mode 100644 index 000000000..015cbb5de --- /dev/null +++ b/integration-tests/binary/jls_15_7_1_2.mj @@ -0,0 +1,7 @@ +class Test2 { + public static void main(String[] args) { + int a = 9; + a = a + (a = 3); + System.out.println(a); + } +} diff --git a/integration-tests/binary/jls_15_7_1_2.mj.exitcode b/integration-tests/binary/jls_15_7_1_2.mj.exitcode new file mode 100644 index 000000000..c22708346 --- /dev/null +++ b/integration-tests/binary/jls_15_7_1_2.mj.exitcode @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/integration-tests/binary/jls_15_7_1_2.mj.stderr b/integration-tests/binary/jls_15_7_1_2.mj.stderr new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/binary/jls_15_7_1_2.mj.stdout b/integration-tests/binary/jls_15_7_1_2.mj.stdout new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/binary/jls_15_7_1_2.out.exitcode b/integration-tests/binary/jls_15_7_1_2.out.exitcode new file mode 100644 index 000000000..c22708346 --- /dev/null +++ b/integration-tests/binary/jls_15_7_1_2.out.exitcode @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/integration-tests/binary/jls_15_7_1_2.out.stderr b/integration-tests/binary/jls_15_7_1_2.out.stderr new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/binary/jls_15_7_1_2.out.stdout b/integration-tests/binary/jls_15_7_1_2.out.stdout new file mode 100644 index 000000000..48082f72f --- /dev/null +++ b/integration-tests/binary/jls_15_7_1_2.out.stdout @@ -0,0 +1 @@ +12 diff --git a/integration-tests/binary/jls_15_7_1_3.mj b/integration-tests/binary/jls_15_7_1_3.mj new file mode 100644 index 000000000..d4eaa53e8 --- /dev/null +++ b/integration-tests/binary/jls_15_7_1_3.mj @@ -0,0 +1,16 @@ +class Test3 { + public static void main(String[] args) { + Test3 t = new Test3(); + int i = t.forgetIt() / t.test(); + } + + public int forgetIt() { + System.out.println(1); + return 1 / 0; + } + + public int test() { + System.out.println(2); + return 1; + } +} diff --git a/integration-tests/binary/jls_15_7_1_3.mj.exitcode b/integration-tests/binary/jls_15_7_1_3.mj.exitcode new file mode 100644 index 000000000..c22708346 --- /dev/null +++ b/integration-tests/binary/jls_15_7_1_3.mj.exitcode @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/integration-tests/binary/jls_15_7_1_3.mj.stderr b/integration-tests/binary/jls_15_7_1_3.mj.stderr new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/binary/jls_15_7_1_3.mj.stdout b/integration-tests/binary/jls_15_7_1_3.mj.stdout new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/binary/jls_15_7_1_3.out.exitcode b/integration-tests/binary/jls_15_7_1_3.out.exitcode new file mode 100644 index 000000000..54e138953 --- /dev/null +++ b/integration-tests/binary/jls_15_7_1_3.out.exitcode @@ -0,0 +1 @@ +terminated by signal or crashed. \ No newline at end of file diff --git a/integration-tests/binary/jls_15_7_1_3.out.stderr b/integration-tests/binary/jls_15_7_1_3.out.stderr new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/binary/jls_15_7_1_3.out.stdout b/integration-tests/binary/jls_15_7_1_3.out.stdout new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/binary/jls_15_7_2.mj b/integration-tests/binary/jls_15_7_2.mj new file mode 100644 index 000000000..fb7185d49 --- /dev/null +++ b/integration-tests/binary/jls_15_7_2.mj @@ -0,0 +1,13 @@ +class Test { + public static void main(String[] args) { + Test t = new Test(); + int divisor = 0; + int i = 1 / (divisor * t.loseBig()); + } + + public int loseBig() { + System.out.println(42); + System.out.flush(); + return 42; + } +} diff --git a/integration-tests/binary/jls_15_7_2.mj.exitcode b/integration-tests/binary/jls_15_7_2.mj.exitcode new file mode 100644 index 000000000..c22708346 --- /dev/null +++ b/integration-tests/binary/jls_15_7_2.mj.exitcode @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/integration-tests/binary/jls_15_7_2.mj.stderr b/integration-tests/binary/jls_15_7_2.mj.stderr new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/binary/jls_15_7_2.mj.stdout b/integration-tests/binary/jls_15_7_2.mj.stdout new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/binary/jls_15_7_2.out.exitcode b/integration-tests/binary/jls_15_7_2.out.exitcode new file mode 100644 index 000000000..54e138953 --- /dev/null +++ b/integration-tests/binary/jls_15_7_2.out.exitcode @@ -0,0 +1 @@ +terminated by signal or crashed. \ No newline at end of file diff --git a/integration-tests/binary/jls_15_7_2.out.stderr b/integration-tests/binary/jls_15_7_2.out.stderr new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/binary/jls_15_7_2.out.stdout b/integration-tests/binary/jls_15_7_2.out.stdout new file mode 100644 index 000000000..d81cc0710 --- /dev/null +++ b/integration-tests/binary/jls_15_7_2.out.stdout @@ -0,0 +1 @@ +42 diff --git a/integration-tests/binary/jls_15_7_3.mj b/integration-tests/binary/jls_15_7_3.mj new file mode 100644 index 000000000..8b72b4d56 --- /dev/null +++ b/integration-tests/binary/jls_15_7_3.mj @@ -0,0 +1,12 @@ +class Test { + public static void main(String[] args) { + Test t = new Test(); + int x = t.test(1) + t.test(2) * t.test(3) + (t.test(4) + t.test(5)) * t.test(6); + System.out.println(x); + } + + public int test(int i) { + System.out.println(i); + return i; + } +} diff --git a/integration-tests/binary/jls_15_7_3.mj.exitcode b/integration-tests/binary/jls_15_7_3.mj.exitcode new file mode 100644 index 000000000..c22708346 --- /dev/null +++ b/integration-tests/binary/jls_15_7_3.mj.exitcode @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/integration-tests/binary/jls_15_7_3.mj.stderr b/integration-tests/binary/jls_15_7_3.mj.stderr new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/binary/jls_15_7_3.mj.stdout b/integration-tests/binary/jls_15_7_3.mj.stdout new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/binary/jls_15_7_3.out.exitcode b/integration-tests/binary/jls_15_7_3.out.exitcode new file mode 100644 index 000000000..c22708346 --- /dev/null +++ b/integration-tests/binary/jls_15_7_3.out.exitcode @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/integration-tests/binary/jls_15_7_3.out.stderr b/integration-tests/binary/jls_15_7_3.out.stderr new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/binary/jls_15_7_3.out.stdout b/integration-tests/binary/jls_15_7_3.out.stdout new file mode 100644 index 000000000..9d9f5c7a9 --- /dev/null +++ b/integration-tests/binary/jls_15_7_3.out.stdout @@ -0,0 +1,7 @@ +1 +2 +3 +4 +5 +6 +61 diff --git a/integration-tests/binary/jls_15_7_4.mj b/integration-tests/binary/jls_15_7_4.mj new file mode 100644 index 000000000..93933cf0f --- /dev/null +++ b/integration-tests/binary/jls_15_7_4.mj @@ -0,0 +1,12 @@ +class Test1 { + public static void main(String[] args) { + Test1 t = new Test1(); + int s = 1; + t.print3(s, s, s = 2); + } + public void print3(int a, int b, int c) { + System.out.println(a); + System.out.println(b); + System.out.println(c); + } +} diff --git a/integration-tests/binary/jls_15_7_4.mj.exitcode b/integration-tests/binary/jls_15_7_4.mj.exitcode new file mode 100644 index 000000000..c22708346 --- /dev/null +++ b/integration-tests/binary/jls_15_7_4.mj.exitcode @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/integration-tests/binary/jls_15_7_4.mj.stderr b/integration-tests/binary/jls_15_7_4.mj.stderr new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/binary/jls_15_7_4.mj.stdout b/integration-tests/binary/jls_15_7_4.mj.stdout new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/binary/jls_15_7_4.out.exitcode b/integration-tests/binary/jls_15_7_4.out.exitcode new file mode 100644 index 000000000..c22708346 --- /dev/null +++ b/integration-tests/binary/jls_15_7_4.out.exitcode @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/integration-tests/binary/jls_15_7_4.out.stderr b/integration-tests/binary/jls_15_7_4.out.stderr new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/binary/jls_15_7_4.out.stdout b/integration-tests/binary/jls_15_7_4.out.stdout new file mode 100644 index 000000000..33280629d --- /dev/null +++ b/integration-tests/binary/jls_15_7_4.out.stdout @@ -0,0 +1,3 @@ +1 +1 +2 diff --git a/integration-tests/binary/side_effects.mj b/integration-tests/binary/side_effects.mj new file mode 100644 index 000000000..0ecafad89 --- /dev/null +++ b/integration-tests/binary/side_effects.mj @@ -0,0 +1,66 @@ +class Main { + public int i; + public static void main(String[] args) { + Main m = new Main(); + int x = m.ret_side(); /* prints 0 */ + + System.out.write(10); + + m.i = 1; + m.getSelf().i = 10; /* prints 1 */ + if (m.getSelfChangeI(2).i == 2) { + System.out.println(2); + m.getSelfChangeI(2).i = 10; + if (m.i == 10) { + System.out.println(3); + } + } + + System.out.write(10); + + int[] arr = new int[10]; + x = 0; + int y = 1; + if (arr[arr[x] = y] == 0 && arr[x] == 1) { + System.out.println(2); + } + + System.out.write(10); + + y = 3; + arr[(x = y)] = x; + System.out.println(x); /* prints 3 */ + System.out.println(y); /* prints 3 */ + System.out.println(arr[x]); /* prints 3 */ + System.out.println(arr[y]); /* prints 3 */ + + System.out.write(10); + + m.side_effect(0, m.side_effect(1, m.side_effect(2, 0))); /* prints 210 */ + } + + public int side_int() { + System.out.println(0); + return 0; + } + + public int ret_side() { + return side_int(); + } + + public Main getSelf() { + System.out.println(this.i); + return this; + } + + public Main getSelfChangeI(int i) { + this.i = i; + return this; + } + + public int side_effect(int print, int fn) { + System.out.println(print); + return fn; + } +} + diff --git a/integration-tests/binary/side_effects.mj.exitcode b/integration-tests/binary/side_effects.mj.exitcode new file mode 100644 index 000000000..c22708346 --- /dev/null +++ b/integration-tests/binary/side_effects.mj.exitcode @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/integration-tests/binary/side_effects.mj.stderr b/integration-tests/binary/side_effects.mj.stderr new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/binary/side_effects.mj.stdout b/integration-tests/binary/side_effects.mj.stdout new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/binary/side_effects.out.exitcode b/integration-tests/binary/side_effects.out.exitcode new file mode 100644 index 000000000..c22708346 --- /dev/null +++ b/integration-tests/binary/side_effects.out.exitcode @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/integration-tests/binary/side_effects.out.stderr b/integration-tests/binary/side_effects.out.stderr new file mode 100644 index 000000000..e69de29bb diff --git a/integration-tests/binary/side_effects.out.stdout b/integration-tests/binary/side_effects.out.stdout new file mode 100644 index 000000000..92bcbf998 --- /dev/null +++ b/integration-tests/binary/side_effects.out.stdout @@ -0,0 +1,16 @@ +0 + +1 +2 +3 + +2 + +3 +3 +3 +3 + +2 +1 +0