Skip to content

Commit 65bf728

Browse files
committed
changed test cases & added standard outputs for comparison
1 parent 3b3f152 commit 65bf728

16 files changed

+5334
-51
lines changed

test-bytecodegen/bcGen/Arrays/ArrayTestCases.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package bcGen.Arrays
22

33
import bcGen.Arrays.ArrayTestLib
44

5-
object testArray{
5+
object arrayTestCases{
66
val size = 1000
77
val maxInt = 10000
88
val rng = new scala.util.Random(1234)

test-bytecodegen/bcGen/Arrays/StdArrayTestCases.txt

Lines changed: 2501 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 241 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,241 @@
1+
Classfile /u0/j523xu/scala3/out/bcGen/Arrays/ArrayTestLib$.class
2+
Last modified Oct 16, 2025; size 1684 bytes
3+
SHA-256 checksum 675b7961ddde1554ead7dc81eb0080dcc77009bfb313b8c5da4d25074c04864c
4+
Compiled from "ArrayTestLib.scala"
5+
public final class bcGen.Arrays.ArrayTestLib$ implements java.io.Serializable
6+
minor version: 0
7+
major version: 52
8+
flags: (0x0031) ACC_PUBLIC, ACC_FINAL, ACC_SUPER
9+
this_class: #2 // bcGen/Arrays/ArrayTestLib$
10+
super_class: #4 // java/lang/Object
11+
interfaces: 1, fields: 1, methods: 5, attributes: 2
12+
Constant pool:
13+
#1 = Utf8 bcGen/Arrays/ArrayTestLib$
14+
#2 = Class #1 // bcGen/Arrays/ArrayTestLib$
15+
#3 = Utf8 java/lang/Object
16+
#4 = Class #3 // java/lang/Object
17+
#5 = Utf8 java/io/Serializable
18+
#6 = Class #5 // java/io/Serializable
19+
#7 = Utf8 ArrayTestLib.scala
20+
#8 = Utf8 MODULE$
21+
#9 = Utf8 LbcGen/Arrays/ArrayTestLib$;
22+
#10 = Utf8 <init>
23+
#11 = Utf8 ()V
24+
#12 = NameAndType #10:#11 // "<init>":()V
25+
#13 = Methodref #4.#12 // java/lang/Object."<init>":()V
26+
#14 = Utf8 this
27+
#15 = Utf8 <clinit>
28+
#16 = Methodref #2.#12 // bcGen/Arrays/ArrayTestLib$."<init>":()V
29+
#17 = NameAndType #8:#9 // MODULE$:LbcGen/Arrays/ArrayTestLib$;
30+
#18 = Fieldref #2.#17 // bcGen/Arrays/ArrayTestLib$.MODULE$:LbcGen/Arrays/ArrayTestLib$;
31+
#19 = Utf8 writeReplace
32+
#20 = Utf8 ()Ljava/lang/Object;
33+
#21 = Utf8 scala/runtime/ModuleSerializationProxy
34+
#22 = Class #21 // scala/runtime/ModuleSerializationProxy
35+
#23 = Utf8 (Ljava/lang/Class;)V
36+
#24 = NameAndType #10:#23 // "<init>":(Ljava/lang/Class;)V
37+
#25 = Methodref #22.#24 // scala/runtime/ModuleSerializationProxy."<init>":(Ljava/lang/Class;)V
38+
#26 = Utf8 copy
39+
#27 = Utf8 (Ljava/lang/Object;Ljava/lang/Object;)V
40+
#28 = Utf8 <T:Ljava/lang/Object;>(Ljava/lang/Object;Ljava/lang/Object;)V
41+
#29 = Utf8 src
42+
#30 = Utf8 dst
43+
#31 = Utf8 scala/runtime/ScalaRunTime$
44+
#32 = Class #31 // scala/runtime/ScalaRunTime$
45+
#33 = Utf8 Lscala/runtime/ScalaRunTime$;
46+
#34 = NameAndType #8:#33 // MODULE$:Lscala/runtime/ScalaRunTime$;
47+
#35 = Fieldref #32.#34 // scala/runtime/ScalaRunTime$.MODULE$:Lscala/runtime/ScalaRunTime$;
48+
#36 = Utf8 array_length
49+
#37 = Utf8 (Ljava/lang/Object;)I
50+
#38 = NameAndType #36:#37 // array_length:(Ljava/lang/Object;)I
51+
#39 = Methodref #32.#38 // scala/runtime/ScalaRunTime$.array_length:(Ljava/lang/Object;)I
52+
#40 = Utf8 array_apply
53+
#41 = Utf8 (Ljava/lang/Object;I)Ljava/lang/Object;
54+
#42 = NameAndType #40:#41 // array_apply:(Ljava/lang/Object;I)Ljava/lang/Object;
55+
#43 = Methodref #32.#42 // scala/runtime/ScalaRunTime$.array_apply:(Ljava/lang/Object;I)Ljava/lang/Object;
56+
#44 = Utf8 array_update
57+
#45 = Utf8 (Ljava/lang/Object;ILjava/lang/Object;)V
58+
#46 = NameAndType #44:#45 // array_update:(Ljava/lang/Object;ILjava/lang/Object;)V
59+
#47 = Methodref #32.#46 // scala/runtime/ScalaRunTime$.array_update:(Ljava/lang/Object;ILjava/lang/Object;)V
60+
#48 = Utf8 idx
61+
#49 = Utf8 I
62+
#50 = Utf8 Ljava/lang/Object;
63+
#51 = Utf8 checksum
64+
#52 = Utf8 <T:Ljava/lang/Object;>(Ljava/lang/Object;)I
65+
#53 = Utf8 array
66+
#54 = Utf8 scala/runtime/Statics
67+
#55 = Class #54 // scala/runtime/Statics
68+
#56 = Utf8 anyHash
69+
#57 = NameAndType #56:#37 // anyHash:(Ljava/lang/Object;)I
70+
#58 = Methodref #55.#57 // scala/runtime/Statics.anyHash:(Ljava/lang/Object;)I
71+
#59 = Utf8 sum
72+
#60 = Utf8 i
73+
#61 = Utf8 Code
74+
#62 = Utf8 LineNumberTable
75+
#63 = Utf8 LocalVariableTable
76+
#64 = Utf8 StackMapTable
77+
#65 = Utf8 Signature
78+
#66 = Utf8 MethodParameters
79+
#67 = Utf8 InvokeReturnType
80+
#68 = Utf8 MethodParameterType
81+
#69 = Utf8 MethodTypeParameterCount
82+
#70 = Utf8 SourceFile
83+
#71 = Utf8 Scala
84+
{
85+
public static final bcGen.Arrays.ArrayTestLib$ MODULE$;
86+
descriptor: LbcGen/Arrays/ArrayTestLib$;
87+
flags: (0x0019) ACC_PUBLIC, ACC_STATIC, ACC_FINAL
88+
89+
private bcGen.Arrays.ArrayTestLib$();
90+
descriptor: ()V
91+
flags: (0x0002) ACC_PRIVATE
92+
Code:
93+
stack=1, locals=1, args_size=1
94+
0: aload_0
95+
1: invokespecial #13 // Method java/lang/Object."<init>":()V
96+
4: return
97+
LineNumberTable:
98+
line 3: 0
99+
LocalVariableTable:
100+
Start Length Slot Name Signature
101+
0 5 0 this LbcGen/Arrays/ArrayTestLib$;
102+
103+
public static {};
104+
descriptor: ()V
105+
flags: (0x0009) ACC_PUBLIC, ACC_STATIC
106+
Code:
107+
stack=2, locals=0, args_size=0
108+
0: new #2 // class bcGen/Arrays/ArrayTestLib$
109+
3: dup
110+
4: invokespecial #16 // Method "<init>":()V
111+
7: putstatic #18 // Field MODULE$:LbcGen/Arrays/ArrayTestLib$;
112+
10: return
113+
LineNumberTable:
114+
line 4: 0
115+
116+
private java.lang.Object writeReplace();
117+
descriptor: ()Ljava/lang/Object;
118+
flags: (0x0002) ACC_PRIVATE
119+
Code:
120+
stack=3, locals=1, args_size=1
121+
0: new #22 // class scala/runtime/ModuleSerializationProxy
122+
3: dup
123+
4: ldc #2 // class bcGen/Arrays/ArrayTestLib$
124+
6: invokespecial #25 // Method scala/runtime/ModuleSerializationProxy."<init>":(Ljava/lang/Class;)V
125+
9: areturn
126+
LineNumberTable:
127+
line 3: 0
128+
LocalVariableTable:
129+
Start Length Slot Name Signature
130+
0 10 0 this LbcGen/Arrays/ArrayTestLib$;
131+
132+
public <T extends java.lang.Object> void copy(java.lang.Object, java.lang.Object);
133+
descriptor: (Ljava/lang/Object;Ljava/lang/Object;)V
134+
flags: (0x0001) ACC_PUBLIC
135+
Code:
136+
stack=6, locals=4, args_size=3
137+
0: iconst_0
138+
1: istore_3
139+
2: iload_3
140+
3: getstatic #35 // Field scala/runtime/ScalaRunTime$.MODULE$:Lscala/runtime/ScalaRunTime$;
141+
6: aload_1
142+
7: invokevirtual #39 // Method scala/runtime/ScalaRunTime$.array_length:(Ljava/lang/Object;)I
143+
10: if_icmpge 35
144+
13: getstatic #35 // Field scala/runtime/ScalaRunTime$.MODULE$:Lscala/runtime/ScalaRunTime$;
145+
16: aload_2
146+
17: iload_3
147+
18: getstatic #35 // Field scala/runtime/ScalaRunTime$.MODULE$:Lscala/runtime/ScalaRunTime$;
148+
21: aload_1
149+
22: iload_3
150+
23: invokevirtual #43 // Method scala/runtime/ScalaRunTime$.array_apply:(Ljava/lang/Object;I)Ljava/lang/Object;
151+
26: invokevirtual #47 // Method scala/runtime/ScalaRunTime$.array_update:(Ljava/lang/Object;ILjava/lang/Object;)V
152+
29: iinc 3, 1
153+
32: goto 2
154+
35: return
155+
StackMapTable: number_of_entries = 2
156+
frame_type = 252 /* append */
157+
offset_delta = 2
158+
locals = [ int ]
159+
frame_type = 32 /* same */
160+
LineNumberTable:
161+
line 5: 0
162+
line 6: 2
163+
line 7: 13
164+
line 8: 29
165+
line 10: 35
166+
LocalVariableTable:
167+
Start Length Slot Name Signature
168+
2 34 3 idx I
169+
0 36 0 this LbcGen/Arrays/ArrayTestLib$;
170+
0 36 1 src Ljava/lang/Object;
171+
0 36 2 dst Ljava/lang/Object;
172+
Signature: #28 // <T:Ljava/lang/Object;>(Ljava/lang/Object;Ljava/lang/Object;)V
173+
MethodParameters:
174+
Name Flags
175+
src final
176+
dst final
177+
InvokeReturnType: length = 0x9 (unknown attribute)
178+
00 01 00 17 4D 00 00 00 00
179+
MethodParameterType: length = 0xC (unknown attribute)
180+
00 02 6D 00 00 00 00 6D 00 00 00 00
181+
MethodTypeParameterCount: length = 0x2 (unknown attribute)
182+
00 01
183+
184+
public <T extends java.lang.Object> int checksum(java.lang.Object);
185+
descriptor: (Ljava/lang/Object;)I
186+
flags: (0x0001) ACC_PUBLIC
187+
Code:
188+
stack=4, locals=4, args_size=2
189+
0: iconst_0
190+
1: istore_2
191+
2: iconst_0
192+
3: istore_3
193+
4: iload_3
194+
5: getstatic #35 // Field scala/runtime/ScalaRunTime$.MODULE$:Lscala/runtime/ScalaRunTime$;
195+
8: aload_1
196+
9: invokevirtual #39 // Method scala/runtime/ScalaRunTime$.array_length:(Ljava/lang/Object;)I
197+
12: if_icmpge 35
198+
15: iload_2
199+
16: getstatic #35 // Field scala/runtime/ScalaRunTime$.MODULE$:Lscala/runtime/ScalaRunTime$;
200+
19: aload_1
201+
20: iload_3
202+
21: invokevirtual #43 // Method scala/runtime/ScalaRunTime$.array_apply:(Ljava/lang/Object;I)Ljava/lang/Object;
203+
24: invokestatic #58 // Method scala/runtime/Statics.anyHash:(Ljava/lang/Object;)I
204+
27: iadd
205+
28: istore_2
206+
29: iinc 3, 1
207+
32: goto 4
208+
35: iload_2
209+
36: ireturn
210+
StackMapTable: number_of_entries = 2
211+
frame_type = 253 /* append */
212+
offset_delta = 4
213+
locals = [ int, int ]
214+
frame_type = 30 /* same */
215+
LineNumberTable:
216+
line 14: 0
217+
line 15: 2
218+
line 16: 4
219+
line 17: 15
220+
line 18: 29
221+
line 20: 35
222+
LocalVariableTable:
223+
Start Length Slot Name Signature
224+
2 35 2 sum I
225+
4 33 3 i I
226+
0 37 0 this LbcGen/Arrays/ArrayTestLib$;
227+
0 37 1 array Ljava/lang/Object;
228+
Signature: #52 // <T:Ljava/lang/Object;>(Ljava/lang/Object;)I
229+
MethodParameters:
230+
Name Flags
231+
array final
232+
InvokeReturnType: length = 0x9 (unknown attribute)
233+
00 01 00 15 4D 00 00 00 00
234+
MethodParameterType: length = 0x7 (unknown attribute)
235+
00 01 6D 00 00 00 00
236+
MethodTypeParameterCount: length = 0x2 (unknown attribute)
237+
00 01
238+
}
239+
SourceFile: "ArrayTestLib.scala"
240+
Scala: length = 0x0 (unknown attribute)
241+

test-bytecodegen/bcGen/Classes/Outer1.scala renamed to test-bytecodegen/bcGen/Classes/Nested1.scala

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package bcGen.Classes
22

3-
class Outer1[T](initOuterT: T) {
4-
val outer1T : T = initOuterT
5-
class Inner1[U](initInner1U: U, initInner1T: T) {
6-
val inner1U : U = initInner1U
7-
val inner1T : T = initInner1T
8-
class Inner2_0[V](initInner2V: V) extends Pair[T, U](outer1T, inner1U) {
3+
class Nested1[T](val initOuterT: T) {
4+
val outer1T: T = initOuterT
5+
class Inner1[U](val initInner1U: U, val initInner1T: T) {
6+
val inner1U: U = initInner1U
7+
val inner1T: T = initInner1T
8+
class Inner2_0[V](val initInner2V: V) extends Pair[T, U](outer1T, inner1U) {
99
val inner2_0V : V = initInner2V
1010
def foo(x: T, y: U, z: V): String = s"Outer1: $x, Inner1: $y, Inner2: $z"
1111
def bar(): String = s"Outer1: $outer1T, Inner1: $inner1U, Inner2: $inner2_0V"
@@ -24,15 +24,15 @@ class Outer1[T](initOuterT: T) {
2424
}
2525
}
2626

27-
object testOuters {
28-
val intOuter1 = new Outer1[Int](42)
27+
object testNested {
28+
val intOuter1 = new Nested1[Int](42)
2929
val refInner1 = new intOuter1.Inner1[String]("Hello", intOuter1.outer1T)
3030
val doubleInner2_0 = new refInner1.Inner2_0[Double](3.14)
31-
@main def testOuter1(): Unit = {
31+
@main def testNested1(): Unit = {
3232
println(doubleInner2_0.foo(41, "World", 2.71))
3333
}
3434

35-
@main def testOuter2(): Unit = {
35+
@main def testNested2(): Unit = {
3636
println(doubleInner2_0.bar())
3737
}
3838
}

test-bytecodegen/bcGen/Classes/Pair.scala

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -15,53 +15,57 @@ object testPair {
1515
val intRefPair = new Pair[Int, String](1, "one")
1616
val doubleLongPair = new Pair[Double, Long](3.14, 42L)
1717
val anyAnyPair = new Pair[Any, Any]("key", 232)
18-
@main def testPair1(): Unit = {
19-
println(s"Key: ${intRefPair.getKey}, Value: ${intRefPair.getValue}")
20-
}
21-
22-
@main def testPair2(): Unit = {
23-
intRefPair.setKey(2)
24-
intRefPair.setValue("two")
25-
println(s"Updated Key: ${intRefPair.getKey}, Updated Value: ${intRefPair.getValue}")
26-
}
27-
28-
@main def testPair3(): Unit = {
29-
println(s"Key: ${doubleLongPair.getKey}, Value: ${doubleLongPair.getValue}")
30-
}
31-
32-
@main def testPair4(): Unit = {
33-
doubleLongPair.setKey(6.28)
34-
doubleLongPair.setValue(84L)
35-
println(s"Updated Key: ${doubleLongPair.getKey}, Updated Value: ${doubleLongPair.getValue}")
36-
}
3718

3819
def passGenericPair[K, V](pair: Pair[K, V]): String = {
3920
s"Generic Pair - Key: ${pair.getKey}, Value: ${pair.getValue}" //InvokeReturnType, no InstrArgType
4021
}
4122

23+
@main def testPair1(): Unit = {
24+
println(s"Key: ${intRefPair.k}, Value: ${intRefPair.v}")
25+
}
26+
4227
@main def testPair5(): Unit = {
4328
val v = passGenericPair[Int, String](intRefPair)
4429
println(v)
4530
}
31+
}
4632

47-
@main def testPair6(): Unit = {
48-
val v = passGenericPair[Double, Long](doubleLongPair)
49-
println(v)
50-
}
33+
// @main def testPair2(): Unit = {
34+
// intRefPair.setKey(2)
35+
// intRefPair.setValue("two")
36+
// println(s"Updated Key: ${intRefPair.getKey}, Updated Value: ${intRefPair.getValue}")
37+
// }
5138

52-
@main def testPair7(): Unit = {
53-
println(s"Key: ${anyAnyPair.getKey}, Value: ${anyAnyPair.getValue}")
54-
}
39+
// @main def testPair3(): Unit = {
40+
// println(s"Key: ${doubleLongPair.getKey}, Value: ${doubleLongPair.getValue}")
41+
// }
5542

56-
@main def testPair8(): Unit = {
57-
anyAnyPair.setKey(123)
58-
anyAnyPair.setValue("newValue")
59-
println(s"Updated Key: ${anyAnyPair.getKey}, Updated Value: ${anyAnyPair.getValue}")
60-
}
43+
// @main def testPair4(): Unit = {
44+
// doubleLongPair.setKey(6.28)
45+
// doubleLongPair.setValue(84L)
46+
// println(s"Updated Key: ${doubleLongPair.getKey}, Updated Value: ${doubleLongPair.getValue}")
47+
// }
6148

62-
@main def testPair9(): Unit = {
63-
val v = passGenericPair[Any, Any](anyAnyPair)
64-
println(v)
65-
}
6649

67-
}
50+
51+
// @main def testPair6(): Unit = {
52+
// val v = passGenericPair[Double, Long](doubleLongPair)
53+
// println(v)
54+
// }
55+
56+
// @main def testPair7(): Unit = {
57+
// println(s"Key: ${anyAnyPair.getKey}, Value: ${anyAnyPair.getValue}")
58+
// }
59+
60+
// @main def testPair8(): Unit = {
61+
// anyAnyPair.setKey(123)
62+
// anyAnyPair.setValue("newValue")
63+
// println(s"Updated Key: ${anyAnyPair.getKey}, Updated Value: ${anyAnyPair.getValue}")
64+
// }
65+
66+
// @main def testPair9(): Unit = {
67+
// val v = passGenericPair[Any, Any](anyAnyPair)
68+
// println(v)
69+
// }
70+
71+
// }

0 commit comments

Comments
 (0)