@@ -15,6 +15,7 @@ import scala.annotation.switch
15
15
import dotty .tools .asm
16
16
17
17
import dotc .ast .Trees ._
18
+ import core .Flags
18
19
import core .Types .Type
19
20
import core .StdNames
20
21
import core .Symbols .{Symbol , NoSymbol }
@@ -52,9 +53,9 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
52
53
53
54
/* ---------------- helper utils for generating methods and code ---------------- */
54
55
55
- def emit (opc : Int ) { mnode.visitInsn(opc) }
56
+ def emit (opc : Int ): Unit = { mnode.visitInsn(opc) }
56
57
57
- def emitZeroOf (tk : BType ) {
58
+ def emitZeroOf (tk : BType ): Unit = {
58
59
(tk.sort: @ switch) match {
59
60
case asm.Type .BOOLEAN => bc.boolconst(false )
60
61
case asm.Type .BYTE |
@@ -74,7 +75,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
74
75
* Two main cases: `tree` is an assignment,
75
76
* otherwise an `adapt()` to UNIT is performed if needed.
76
77
*/
77
- def genStat (tree : Tree ) {
78
+ def genStat (tree : Tree ): Unit = {
78
79
lineNumber(tree)
79
80
tree match {
80
81
case Assign (lhs @ Select (_, _), rhs) =>
@@ -340,12 +341,12 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
340
341
)
341
342
}
342
343
343
- def genLoad (tree : Tree ) {
344
+ def genLoad (tree : Tree ): Unit = {
344
345
genLoad(tree, tpeTK(tree))
345
346
}
346
347
347
348
/* Generate code for trees that produce values on the stack */
348
- def genLoad (tree : Tree , expectedType : BType ) {
349
+ def genLoad (tree : Tree , expectedType : BType ): Unit = {
349
350
var generatedType = expectedType
350
351
351
352
lineNumber(tree)
@@ -392,7 +393,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
392
393
// case ApplyDynamic(qual, args) => sys.error("No invokedynamic support yet.")
393
394
394
395
case This (qual) =>
395
- val symIsModuleClass = tree.symbol.isModuleClass
396
+ val symIsModuleClass = tree.symbol is Flags . ModuleVal
396
397
assert(tree.symbol == claszSymbol || symIsModuleClass,
397
398
s " Trying to access the this of another class: tree.symbol = ${tree.symbol}, class symbol = $claszSymbol compilation unit: $cunit" )
398
399
if (symIsModuleClass && tree.symbol != claszSymbol) {
@@ -406,7 +407,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
406
407
}
407
408
408
409
case Select (Ident (nme.EMPTY_PACKAGE_NAME ), module) =>
409
- assert(tree.symbol.isModule , s " Selection of non-module from empty package: $tree sym: ${tree.symbol} at: ${tree.pos}" )
410
+ assert(tree.symbol is Flags . ModuleVal , s " Selection of non-module from empty package: $tree sym: ${tree.symbol} at: ${tree.pos}" )
410
411
genLoadModule(tree)
411
412
412
413
case Select (qualifier, selector) =>
@@ -416,9 +417,9 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
416
417
debuglog(s " Host class of $sym with qual $qualifier ( ${qualifier.tpe}) is $hostClass" )
417
418
val qualSafeToElide = treeInfo isQualifierSafeToElide qualifier
418
419
419
- def genLoadQualUnlessElidable () { if (! qualSafeToElide) { genLoadQualifier(tree) } }
420
+ def genLoadQualUnlessElidable (): Unit = { if (! qualSafeToElide) { genLoadQualifier(tree) } }
420
421
421
- if (sym.isModule ) {
422
+ if (sym is Flags . ModuleVal ) {
422
423
genLoadQualUnlessElidable()
423
424
genLoadModule(tree)
424
425
}
@@ -435,7 +436,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
435
436
val sym = tree.symbol
436
437
if (! sym.isPackage) {
437
438
val tk = symInfoTK(sym)
438
- if (sym.isModule ) { genLoadModule(tree) }
439
+ if (sym is Flags . ModuleVal ) { genLoadModule(tree) }
439
440
else { locals.load(sym) }
440
441
generatedType = tk
441
442
}
@@ -481,20 +482,20 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
481
482
/*
482
483
* must-single-thread
483
484
*/
484
- def fieldLoad ( field : Symbol , hostClass : Symbol = null ) {
485
+ def fieldLoad ( field : Symbol , hostClass : Symbol = null ): Unit = {
485
486
fieldOp(field, isLoad = true , hostClass)
486
487
}
487
488
/*
488
489
* must-single-thread
489
490
*/
490
- def fieldStore (field : Symbol , hostClass : Symbol = null ) {
491
+ def fieldStore (field : Symbol , hostClass : Symbol = null ): Unit = {
491
492
fieldOp(field, isLoad = false , hostClass)
492
493
}
493
494
494
495
/*
495
496
* must-single-thread
496
497
*/
497
- private def fieldOp (field : Symbol , isLoad : Boolean , hostClass : Symbol ) {
498
+ private def fieldOp (field : Symbol , isLoad : Boolean , hostClass : Symbol ): Unit = {
498
499
// LOAD_FIELD.hostClass , CALL_METHOD.hostClass , and #4283
499
500
val owner =
500
501
if (hostClass == null ) internalName(field.owner)
@@ -516,7 +517,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
516
517
* must-single-thread
517
518
* Otherwise it's safe to call from multiple threads.
518
519
*/
519
- def genConstant (const : Constant ) {
520
+ def genConstant (const : Constant ): Unit = {
520
521
521
522
import dotc .core .Constants ._
522
523
@@ -565,15 +566,15 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
565
566
}
566
567
}
567
568
568
- private def genLabelDef (lblDf : LabelDef , expectedType : BType ) {
569
+ private def genLabelDef (lblDf : LabelDef , expectedType : BType ): Unit = {
569
570
// duplication of LabelDefs contained in `finally`-clauses is handled when emitting RETURN. No bookkeeping for that required here.
570
571
// no need to call index() over lblDf.params, on first access that magic happens (moreover, no LocalVariableTable entries needed for them).
571
572
markProgramPoint(programPoint(lblDf.symbol))
572
573
lineNumber(lblDf)
573
574
genLoad(lblDf.rhs, expectedType)
574
575
}
575
576
576
- private def genReturn (r : Return ) {
577
+ private def genReturn (r : Return ): Unit = {
577
578
val Return (expr) = r
578
579
val returnedKind = tpeTK(expr)
579
580
genLoad(expr, returnedKind)
@@ -735,11 +736,11 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
735
736
generatedType = genPrimitiveOp(app, expectedType)
736
737
} else { // normal method call
737
738
738
- def genNormalMethodCall () {
739
+ def genNormalMethodCall (): Unit = {
739
740
740
741
val invokeStyle =
741
742
if (sym.isStaticMember) icodes.opcodes.Static (onInstance = false )
742
- else if (sym.isPrivate || sym.isClassConstructor) icodes.opcodes.Static (onInstance = true )
743
+ else if (( sym is Flags . Private ) || sym.isClassConstructor) icodes.opcodes.Static (onInstance = true )
743
744
else icodes.opcodes.Dynamic ;
744
745
745
746
if (invokeStyle.hasInstance) {
@@ -756,12 +757,12 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
756
757
val qualSym = findHostClass(qual.tpe, sym)
757
758
if (qualSym == ArrayClass ) {
758
759
targetTypeKind = tpeTK(qual)
759
- log(s " Stored target type kind for ${sym.fullName} as $targetTypeKind" )
760
+ ctx. log(s " Stored target type kind for ${sym.fullName} as $targetTypeKind" )
760
761
}
761
762
else {
762
763
hostClass = qualSym
763
764
if (qual.tpe.typeSymbol != qualSym) {
764
- log(s " Precisified host class for $sym from ${qual.tpe.typeSymbol.fullName} to ${qualSym.fullName}" )
765
+ ctx. log(s " Precisified host class for $sym from ${qual.tpe.typeSymbol.fullName} to ${qualSym.fullName}" )
765
766
}
766
767
}
767
768
@@ -870,7 +871,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
870
871
generatedType
871
872
}
872
873
873
- def genBlock (tree : Block , expectedType : BType ) {
874
+ def genBlock (tree : Block , expectedType : BType ): Unit = {
874
875
val Block (stats, expr) = tree
875
876
val savedScope = varsInScope
876
877
varsInScope = Nil
@@ -902,7 +903,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
902
903
}
903
904
904
905
/* Emit code to Load the qualifier of `tree` on top of the stack. */
905
- def genLoadQualifier (tree : Tree ) {
906
+ def genLoadQualifier (tree : Tree ): Unit = {
906
907
lineNumber(tree)
907
908
tree match {
908
909
case Select (qualifier, _) => genLoad(qualifier)
@@ -911,7 +912,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
911
912
}
912
913
913
914
/* Generate code that loads args into label parameters. */
914
- def genLoadLabelArguments (args : List [Tree ], lblDef : LabelDef , gotoPos : dotc.util.Positions .Position ) {
915
+ def genLoadLabelArguments (args : List [Tree ], lblDef : LabelDef , gotoPos : dotc.util.Positions .Position ): Unit = {
915
916
916
917
val aps = {
917
918
val params : List [Symbol ] = lblDef.params.map(_.symbol)
@@ -939,24 +940,24 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
939
940
940
941
}
941
942
942
- def genLoadArguments (args : List [Tree ], btpes : List [BType ]) {
943
+ def genLoadArguments (args : List [Tree ], btpes : List [BType ]): Unit = {
943
944
(args zip btpes) foreach { case (arg, btpe) => genLoad(arg, btpe) }
944
945
}
945
946
946
947
def genLoadModule (tree : Tree ): BType = {
947
948
val module = (
948
- if (! tree.symbol.isPackageClass ) tree.symbol
949
+ if (! tree.symbol is Flags . PackageClass ) tree.symbol
949
950
else tree.symbol.info.member(nme.PACKAGE ) match {
950
- case NoSymbol => abort(s " SI-5604: Cannot use package as value: $tree" )
951
- case s => abort(s " SI-5604: found package class where package object expected: $tree" )
951
+ case NoDenotation => abort(s " SI-5604: Cannot use package as value: $tree" )
952
+ case s => abort(s " SI-5604: found package class where package object expected: $tree" )
952
953
}
953
954
)
954
955
lineNumber(tree)
955
956
genLoadModule(module)
956
957
symInfoTK(module)
957
958
}
958
959
959
- def genLoadModule (module : Symbol ) {
960
+ def genLoadModule (module : Symbol ): Unit = {
960
961
def inStaticMethod = methSymbol != null && methSymbol.isStaticMember
961
962
if (claszSymbol == module.moduleClass && jMethodName != " readResolve" && ! inStaticMethod) {
962
963
mnode.visitVarInsn(asm.Opcodes .ALOAD , 0 )
@@ -971,15 +972,15 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
971
972
}
972
973
}
973
974
974
- def genConversion (from : BType , to : BType , cast : Boolean ) {
975
+ def genConversion (from : BType , to : BType , cast : Boolean ): Unit = {
975
976
if (cast) { bc.emitT2T(from, to) }
976
977
else {
977
978
bc drop from
978
979
bc boolconst (from == to)
979
980
}
980
981
}
981
982
982
- def genCast (to : BType , cast : Boolean ) {
983
+ def genCast (to : BType , cast : Boolean ): Unit = {
983
984
if (cast) { bc checkCast to }
984
985
else { bc isInstance to }
985
986
}
@@ -988,7 +989,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
988
989
def isPrimitive (fun : Symbol ): Boolean = scalaPrimitives.isPrimitive(fun)
989
990
990
991
/* Generate coercion denoted by "code" */
991
- def genCoercion (code : Int ) {
992
+ def genCoercion (code : Int ): Unit = {
992
993
import scalaPrimitives ._
993
994
(code : @ switch) match {
994
995
case B2B | S2S | C2C | I2I | L2L | F2F | D2D => ()
@@ -1034,8 +1035,8 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
1034
1035
hostSymbol.info ; methodOwner.info
1035
1036
1036
1037
def needsInterfaceCall (sym : Symbol ) = (
1037
- sym.isInterface
1038
- || sym.isJavaDefined && sym.isNonBottomSubClass(definitions.ClassfileAnnotationClass )
1038
+ ( sym is Flags . Interface )
1039
+ || ( sym is Flags . JavaDefined ) && sym.isNonBottomSubClass(definitions.ClassfileAnnotationClass )
1039
1040
)
1040
1041
1041
1042
// whether to reference the type of the receiver or
@@ -1052,7 +1053,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
1052
1053
val bmType = asmMethodType(method)
1053
1054
val mdescr = bmType.getDescriptor
1054
1055
1055
- def initModule () {
1056
+ def initModule (): Unit = {
1056
1057
// we initialize the MODULE$ field immediately after the super ctor
1057
1058
if (! isModuleInitialized &&
1058
1059
jMethodName == INSTANCE_CONSTRUCTOR_NAME &&
@@ -1121,7 +1122,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
1121
1122
def ifOneIsNull (l : Tree , r : Tree ) = if (isNull(l)) r else if (isNull(r)) l else null
1122
1123
1123
1124
/* Emit code to compare the two top-most stack values using the 'op' operator. */
1124
- private def genCJUMP (success : asm.Label , failure : asm.Label , op : TestOp , tk : BType ) {
1125
+ private def genCJUMP (success : asm.Label , failure : asm.Label , op : TestOp , tk : BType ): Unit = {
1125
1126
if (tk.isIntSizedType) { // BOOL, BYTE, CHAR, SHORT, or INT
1126
1127
bc.emitIF_ICMP(op, success)
1127
1128
} else if (tk.isRefOrArrayType) { // REFERENCE(_) | ARRAY(_)
@@ -1142,7 +1143,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
1142
1143
}
1143
1144
1144
1145
/* Emits code to compare (and consume) stack-top and zero using the 'op' operator */
1145
- private def genCZJUMP (success : asm.Label , failure : asm.Label , op : TestOp , tk : BType ) {
1146
+ private def genCZJUMP (success : asm.Label , failure : asm.Label , op : TestOp , tk : BType ): Unit = {
1146
1147
if (tk.isIntSizedType) { // BOOL, BYTE, CHAR, SHORT, or INT
1147
1148
bc.emitIF(op, success)
1148
1149
} else if (tk.isRefOrArrayType) { // REFERENCE(_) | ARRAY(_)
@@ -1178,9 +1179,9 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
1178
1179
* Generate code for conditional expressions.
1179
1180
* The jump targets success/failure of the test are `then-target` and `else-target` resp.
1180
1181
*/
1181
- private def genCond (tree : Tree , success : asm.Label , failure : asm.Label ) {
1182
+ private def genCond (tree : Tree , success : asm.Label , failure : asm.Label ): Unit = {
1182
1183
1183
- def genComparisonOp (l : Tree , r : Tree , code : Int ) {
1184
+ def genComparisonOp (l : Tree , r : Tree , code : Int ): Unit = {
1184
1185
val op : TestOp = testOpForPrimitive(code - scalaPrimitives.ID )
1185
1186
// special-case reference (in)equality test for null (null eq x, x eq null)
1186
1187
var nonNullSide : Tree = null
@@ -1213,7 +1214,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
1213
1214
lazy val Select (lhs, _) = fun
1214
1215
val rhs = if (args.isEmpty) EmptyTree else args.head; // args.isEmpty only for ZNOT
1215
1216
1216
- def genZandOrZor (and : Boolean ) { // TODO WRONG
1217
+ def genZandOrZor (and : Boolean ): Unit = { // TODO WRONG
1217
1218
// reaching "keepGoing" indicates the rhs should be evaluated too (ie not short-circuited).
1218
1219
val keepGoing = new asm.Label
1219
1220
@@ -1253,7 +1254,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
1253
1254
* @param l left-hand-side of the '=='
1254
1255
* @param r right-hand-side of the '=='
1255
1256
*/
1256
- def genEqEqPrimitive (l : Tree , r : Tree , success : asm.Label , failure : asm.Label ) {
1257
+ def genEqEqPrimitive (l : Tree , r : Tree , success : asm.Label , failure : asm.Label ): Unit = {
1257
1258
1258
1259
/* True if the equality comparison is between values that require the use of the rich equality
1259
1260
* comparator (scala.runtime.Comparator.equals). This is the case when either side of the
0 commit comments