@@ -8,9 +8,7 @@ import scala.tools.asm.Opcodes._
8
8
class ArrayApplyOptTest extends DottyBytecodeTest {
9
9
import ASMConverters ._
10
10
11
- // FIXME: Re-enable IArray bytecode tests (requires updated reference compiler)
12
- // Also change: library/src/scala/IArray.scala
13
- @ Test def testArrayEmptyGenericApply = {
11
+ @ Test def testArrayEmptyGenericApply = {
14
12
test(" Array[String]()" , List (Op (ICONST_0 ), TypeOp (ANEWARRAY , " java/lang/String" ), Op (POP ), Op (RETURN )))
15
13
test(" Array[Unit]()" , List (Op (ICONST_0 ), TypeOp (ANEWARRAY , " scala/runtime/BoxedUnit" ), Op (POP ), Op (RETURN )))
16
14
test(" Array[Object]()" , List (Op (ICONST_0 ), TypeOp (ANEWARRAY , " java/lang/Object" ), Op (POP ), Op (RETURN )))
@@ -24,91 +22,91 @@ class ArrayApplyOptTest extends DottyBytecodeTest {
24
22
test(" Array[Char]()" , newArray0Opcodes(T_CHAR ))
25
23
test(" Array[T]()" , newArray0Opcodes(T_INT ))
26
24
27
- // test("IArray[String]()", List(Op(ICONST_0), TypeOp(ANEWARRAY, "java/lang/String"), TypeOp(CHECKCAST, "[Ljava/lang/String;"), Op(POP), Op(RETURN)))
28
- // test("IArray[Unit]()", List(Op(ICONST_0), TypeOp(ANEWARRAY, "scala/runtime/BoxedUnit"), TypeOp(CHECKCAST, "[Lscala/runtime/BoxedUnit;"), Op(POP), Op(RETURN)))
29
- // test("IArray[Object]()", List(Op(ICONST_0), TypeOp(ANEWARRAY, "java/lang/Object"), TypeOp(CHECKCAST, "[Ljava/lang/Object;"), Op(POP), Op(RETURN)))
30
- // test("IArray[Boolean]()", newArray0Opcodes(T_BOOLEAN, TypeOp(CHECKCAST, "[Z") :: Nil))
31
- // test("IArray[Byte]()", newArray0Opcodes(T_BYTE, TypeOp(CHECKCAST, "[B") :: Nil))
32
- // test("IArray[Short]()", newArray0Opcodes(T_SHORT, TypeOp(CHECKCAST, "[S") :: Nil))
33
- // test("IArray[Int]()", newArray0Opcodes(T_INT, TypeOp(CHECKCAST, "[I") :: Nil))
34
- // test("IArray[Long]()", newArray0Opcodes(T_LONG, TypeOp(CHECKCAST, "[J") :: Nil))
35
- // test("IArray[Float]()", newArray0Opcodes(T_FLOAT, TypeOp(CHECKCAST, "[F") :: Nil))
36
- // test("IArray[Double]()", newArray0Opcodes(T_DOUBLE, TypeOp(CHECKCAST, "[D") :: Nil))
37
- // test("IArray[Char]()", newArray0Opcodes(T_CHAR, TypeOp(CHECKCAST, "[C") :: Nil))
38
- // test("IArray[T]()", newArray0Opcodes(T_INT, TypeOp(CHECKCAST, "[I") :: Nil))
25
+ test(" IArray[String]()" , List (Op (ICONST_0 ), TypeOp (ANEWARRAY , " java/lang/String" ), TypeOp (CHECKCAST , " [Ljava/lang/String;" ), Op (POP ), Op (RETURN )))
26
+ test(" IArray[Unit]()" , List (Op (ICONST_0 ), TypeOp (ANEWARRAY , " scala/runtime/BoxedUnit" ), TypeOp (CHECKCAST , " [Lscala/runtime/BoxedUnit;" ), Op (POP ), Op (RETURN )))
27
+ test(" IArray[Object]()" , List (Op (ICONST_0 ), TypeOp (ANEWARRAY , " java/lang/Object" ), TypeOp (CHECKCAST , " [Ljava/lang/Object;" ), Op (POP ), Op (RETURN )))
28
+ test(" IArray[Boolean]()" , newArray0Opcodes(T_BOOLEAN , TypeOp (CHECKCAST , " [Z" ) :: Nil ))
29
+ test(" IArray[Byte]()" , newArray0Opcodes(T_BYTE , TypeOp (CHECKCAST , " [B" ) :: Nil ))
30
+ test(" IArray[Short]()" , newArray0Opcodes(T_SHORT , TypeOp (CHECKCAST , " [S" ) :: Nil ))
31
+ test(" IArray[Int]()" , newArray0Opcodes(T_INT , TypeOp (CHECKCAST , " [I" ) :: Nil ))
32
+ test(" IArray[Long]()" , newArray0Opcodes(T_LONG , TypeOp (CHECKCAST , " [J" ) :: Nil ))
33
+ test(" IArray[Float]()" , newArray0Opcodes(T_FLOAT , TypeOp (CHECKCAST , " [F" ) :: Nil ))
34
+ test(" IArray[Double]()" , newArray0Opcodes(T_DOUBLE , TypeOp (CHECKCAST , " [D" ) :: Nil ))
35
+ test(" IArray[Char]()" , newArray0Opcodes(T_CHAR , TypeOp (CHECKCAST , " [C" ) :: Nil ))
36
+ test(" IArray[T]()" , newArray0Opcodes(T_INT , TypeOp (CHECKCAST , " [I" ) :: Nil ))
39
37
}
40
38
41
- @ Test def testArrayGenericApply = {
39
+ @ Test def testArrayGenericApply = {
42
40
def opCodes (tpe : String ) =
43
41
List (Op (ICONST_2 ), TypeOp (ANEWARRAY , tpe), Op (DUP ), Op (ICONST_0 ), Ldc (LDC , " a" ), Op (AASTORE ), Op (DUP ), Op (ICONST_1 ), Ldc (LDC , " b" ), Op (AASTORE ), Op (POP ), Op (RETURN ))
44
42
test(""" Array("a", "b")""" , opCodes(" java/lang/String" ))
45
43
test(""" Array[Object]("a", "b")""" , opCodes(" java/lang/Object" ))
46
44
47
45
def opCodes2 (tpe : String ) =
48
46
List (Op (ICONST_2 ), TypeOp (ANEWARRAY , tpe), Op (DUP ), Op (ICONST_0 ), Ldc (LDC , " a" ), Op (AASTORE ), Op (DUP ), Op (ICONST_1 ), Ldc (LDC , " b" ), Op (AASTORE ), TypeOp (CHECKCAST , s " [L $tpe; " ), Op (POP ), Op (RETURN ))
49
- // test("""IArray("a", "b")""", opCodes2("java/lang/String"))
50
- // test("""IArray[Object]("a", "b")""", opCodes2("java/lang/Object"))
47
+ test(""" IArray("a", "b")""" , opCodes2(" java/lang/String" ))
48
+ test(""" IArray[Object]("a", "b")""" , opCodes2(" java/lang/Object" ))
51
49
}
52
50
53
51
@ Test def testArrayApplyBoolean = {
54
52
val init = List (Op (DUP ), Op (ICONST_0 ), Op (ICONST_1 ), Op (BASTORE ), Op (DUP ), Op (ICONST_1 ), Op (ICONST_0 ), Op (BASTORE ))
55
53
test(" Array(true, false)" , newArray2Opcodes(T_BOOLEAN , init))
56
- // test("IArray(true, false)", newArray2Opcodes(T_BOOLEAN, init :+ TypeOp(CHECKCAST, "[Z")))
54
+ test(" IArray(true, false)" , newArray2Opcodes(T_BOOLEAN , init :+ TypeOp (CHECKCAST , " [Z" )))
57
55
}
58
56
59
57
@ Test def testArrayApplyByte = {
60
58
val init = List (Op (DUP ), Op (ICONST_0 ), Op (ICONST_1 ), Op (BASTORE ), Op (DUP ), Op (ICONST_1 ), Op (ICONST_2 ), Op (BASTORE ))
61
59
test(" Array[Byte](1, 2)" , newArray2Opcodes(T_BYTE , init))
62
- // test("IArray[Byte](1, 2)", newArray2Opcodes(T_BYTE, init :+ TypeOp(CHECKCAST, "[B")))
60
+ test(" IArray[Byte](1, 2)" , newArray2Opcodes(T_BYTE , init :+ TypeOp (CHECKCAST , " [B" )))
63
61
}
64
62
65
63
@ Test def testArrayApplyShort = {
66
64
val init = List (Op (DUP ), Op (ICONST_0 ), Op (ICONST_1 ), Op (SASTORE ), Op (DUP ), Op (ICONST_1 ), Op (ICONST_2 ), Op (SASTORE ))
67
65
test(" Array[Short](1, 2)" , newArray2Opcodes(T_SHORT , init))
68
- // test("IArray[Short](1, 2)", newArray2Opcodes(T_SHORT, init :+ TypeOp(CHECKCAST, "[S")))
66
+ test(" IArray[Short](1, 2)" , newArray2Opcodes(T_SHORT , init :+ TypeOp (CHECKCAST , " [S" )))
69
67
}
70
68
71
69
@ Test def testArrayApplyInt = {
72
70
val init = List (Op (DUP ), Op (ICONST_0 ), Op (ICONST_1 ), Op (IASTORE ), Op (DUP ), Op (ICONST_1 ), Op (ICONST_2 ), Op (IASTORE ))
73
71
test(" Array(1, 2)" , newArray2Opcodes(T_INT , init))
74
- // test("IArray(1, 2)", newArray2Opcodes(T_INT, init :+ TypeOp(CHECKCAST, "[I")))
72
+ test(" IArray(1, 2)" , newArray2Opcodes(T_INT , init :+ TypeOp (CHECKCAST , " [I" )))
75
73
76
74
val init2 = List (Op (DUP ), Op (ICONST_0 ), Field (GETSTATIC , " Foo$" , " MODULE$" , " LFoo$;" ), Invoke (INVOKEVIRTUAL , " Foo$" , " t" , " ()I" , false ), Op (IASTORE ), Op (DUP ), Op (ICONST_1 ), Field (GETSTATIC , " Foo$" , " MODULE$" , " LFoo$;" ), Invoke (INVOKEVIRTUAL , " Foo$" , " t" , " ()I" , false ), Op (IASTORE ))
77
75
test(""" Array[T](t, t)""" , newArray2Opcodes(T_INT , init2))
78
- // test("""IArray[T](t, t)""", newArray2Opcodes(T_INT, init2 :+ TypeOp(CHECKCAST, "[I")))
76
+ test(""" IArray[T](t, t)""" , newArray2Opcodes(T_INT , init2 :+ TypeOp (CHECKCAST , " [I" )))
79
77
}
80
78
81
79
@ Test def testArrayApplyLong = {
82
80
val init = List (Op (DUP ), Op (ICONST_0 ), Ldc (LDC , 2 ), Op (LASTORE ), Op (DUP ), Op (ICONST_1 ), Ldc (LDC , 3 ), Op (LASTORE ))
83
81
test(" Array(2L, 3L)" , newArray2Opcodes(T_LONG , init))
84
- // test("IArray(2L, 3L)", newArray2Opcodes(T_LONG, init :+ TypeOp(CHECKCAST, "[J")))
82
+ test(" IArray(2L, 3L)" , newArray2Opcodes(T_LONG , init :+ TypeOp (CHECKCAST , " [J" )))
85
83
}
86
84
87
85
@ Test def testArrayApplyFloat = {
88
86
val init = List (Op (DUP ), Op (ICONST_0 ), Ldc (LDC , 2.1f ), Op (FASTORE ), Op (DUP ), Op (ICONST_1 ), Ldc (LDC , 3.1f ), Op (FASTORE ))
89
87
test(" Array(2.1f, 3.1f)" , newArray2Opcodes(T_FLOAT , init))
90
- // test("IArray(2.1f, 3.1f)", newArray2Opcodes(T_FLOAT, init :+ TypeOp(CHECKCAST, "[F")))
88
+ test(" IArray(2.1f, 3.1f)" , newArray2Opcodes(T_FLOAT , init :+ TypeOp (CHECKCAST , " [F" )))
91
89
}
92
90
93
91
@ Test def testArrayApplyDouble = {
94
92
val init = List (Op (DUP ), Op (ICONST_0 ), Ldc (LDC , 2.2d ), Op (DASTORE ), Op (DUP ), Op (ICONST_1 ), Ldc (LDC , 3.2d ), Op (DASTORE ))
95
93
test(" Array(2.2d, 3.2d)" , newArray2Opcodes(T_DOUBLE , init))
96
- // test("IArray(2.2d, 3.2d)", newArray2Opcodes(T_DOUBLE, init :+ TypeOp(CHECKCAST, "[D")))
94
+ test(" IArray(2.2d, 3.2d)" , newArray2Opcodes(T_DOUBLE , init :+ TypeOp (CHECKCAST , " [D" )))
97
95
}
98
96
99
97
@ Test def testArrayApplyChar = {
100
98
val init = List (Op (DUP ), Op (ICONST_0 ), IntOp (BIPUSH , 120 ), Op (CASTORE ), Op (DUP ), Op (ICONST_1 ), IntOp (BIPUSH , 121 ), Op (CASTORE ))
101
99
test(" Array('x', 'y')" , newArray2Opcodes(T_CHAR , init))
102
- // test("IArray('x', 'y')", newArray2Opcodes(T_CHAR, init :+ TypeOp(CHECKCAST, "[C")))
100
+ test(" IArray('x', 'y')" , newArray2Opcodes(T_CHAR , init :+ TypeOp (CHECKCAST , " [C" )))
103
101
}
104
102
105
103
@ Test def testArrayApplyUnit = {
106
104
test(" Array[Unit]((), ())" , List (Op (ICONST_2 ), TypeOp (ANEWARRAY , " scala/runtime/BoxedUnit" ), Op (DUP ),
107
105
Op (ICONST_0 ), Field (GETSTATIC , " scala/runtime/BoxedUnit" , " UNIT" , " Lscala/runtime/BoxedUnit;" ), Op (AASTORE ), Op (DUP ),
108
106
Op (ICONST_1 ), Field (GETSTATIC , " scala/runtime/BoxedUnit" , " UNIT" , " Lscala/runtime/BoxedUnit;" ), Op (AASTORE ), Op (POP ), Op (RETURN )))
109
- // test("IArray[Unit]((), ())", List(Op(ICONST_2), TypeOp(ANEWARRAY, "scala/runtime/BoxedUnit"), Op(DUP),
110
- // Op(ICONST_0), Field(GETSTATIC, "scala/runtime/BoxedUnit", "UNIT", "Lscala/runtime/BoxedUnit;"), Op(AASTORE), Op(DUP),
111
- // Op(ICONST_1), Field(GETSTATIC, "scala/runtime/BoxedUnit", "UNIT", "Lscala/runtime/BoxedUnit;"), Op(AASTORE), TypeOp(CHECKCAST, "[Lscala/runtime/BoxedUnit;"), Op(POP), Op(RETURN)))
107
+ test(" IArray[Unit]((), ())" , List (Op (ICONST_2 ), TypeOp (ANEWARRAY , " scala/runtime/BoxedUnit" ), Op (DUP ),
108
+ Op (ICONST_0 ), Field (GETSTATIC , " scala/runtime/BoxedUnit" , " UNIT" , " Lscala/runtime/BoxedUnit;" ), Op (AASTORE ), Op (DUP ),
109
+ Op (ICONST_1 ), Field (GETSTATIC , " scala/runtime/BoxedUnit" , " UNIT" , " Lscala/runtime/BoxedUnit;" ), Op (AASTORE ), TypeOp (CHECKCAST , " [Lscala/runtime/BoxedUnit;" ), Op (POP ), Op (RETURN )))
112
110
}
113
111
114
112
@ Test def testArrayInlined = test(
0 commit comments