Skip to content

Commit a43deb7

Browse files
committed
the new procedural syntax
1 parent e8a38ce commit a43deb7

10 files changed

+127
-127
lines changed

src/dotty/tools/dotc/backend/jvm/BCodeBodyBuilder.scala

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
5353

5454
/* ---------------- helper utils for generating methods and code ---------------- */
5555

56-
def emit(opc: Int) { mnode.visitInsn(opc) }
56+
def emit(opc: Int): Unit = { mnode.visitInsn(opc) }
5757

58-
def emitZeroOf(tk: BType) {
58+
def emitZeroOf(tk: BType): Unit = {
5959
(tk.sort: @switch) match {
6060
case asm.Type.BOOLEAN => bc.boolconst(false)
6161
case asm.Type.BYTE |
@@ -75,7 +75,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
7575
* Two main cases: `tree` is an assignment,
7676
* otherwise an `adapt()` to UNIT is performed if needed.
7777
*/
78-
def genStat(tree: Tree) {
78+
def genStat(tree: Tree): Unit = {
7979
lineNumber(tree)
8080
tree match {
8181
case Assign(lhs @ Select(_, _), rhs) =>
@@ -341,12 +341,12 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
341341
)
342342
}
343343

344-
def genLoad(tree: Tree) {
344+
def genLoad(tree: Tree): Unit = {
345345
genLoad(tree, tpeTK(tree))
346346
}
347347

348348
/* Generate code for trees that produce values on the stack */
349-
def genLoad(tree: Tree, expectedType: BType) {
349+
def genLoad(tree: Tree, expectedType: BType): Unit = {
350350
var generatedType = expectedType
351351

352352
lineNumber(tree)
@@ -417,7 +417,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
417417
debuglog(s"Host class of $sym with qual $qualifier (${qualifier.tpe}) is $hostClass")
418418
val qualSafeToElide = treeInfo isQualifierSafeToElide qualifier
419419

420-
def genLoadQualUnlessElidable() { if (!qualSafeToElide) { genLoadQualifier(tree) } }
420+
def genLoadQualUnlessElidable(): Unit = { if (!qualSafeToElide) { genLoadQualifier(tree) } }
421421

422422
if (sym is Flags.ModuleVal) {
423423
genLoadQualUnlessElidable()
@@ -482,20 +482,20 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
482482
/*
483483
* must-single-thread
484484
*/
485-
def fieldLoad( field: Symbol, hostClass: Symbol = null) {
485+
def fieldLoad( field: Symbol, hostClass: Symbol = null): Unit = {
486486
fieldOp(field, isLoad = true, hostClass)
487487
}
488488
/*
489489
* must-single-thread
490490
*/
491-
def fieldStore(field: Symbol, hostClass: Symbol = null) {
491+
def fieldStore(field: Symbol, hostClass: Symbol = null): Unit = {
492492
fieldOp(field, isLoad = false, hostClass)
493493
}
494494

495495
/*
496496
* must-single-thread
497497
*/
498-
private def fieldOp(field: Symbol, isLoad: Boolean, hostClass: Symbol) {
498+
private def fieldOp(field: Symbol, isLoad: Boolean, hostClass: Symbol): Unit = {
499499
// LOAD_FIELD.hostClass , CALL_METHOD.hostClass , and #4283
500500
val owner =
501501
if (hostClass == null) internalName(field.owner)
@@ -517,7 +517,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
517517
* must-single-thread
518518
* Otherwise it's safe to call from multiple threads.
519519
*/
520-
def genConstant(const: Constant) {
520+
def genConstant(const: Constant): Unit = {
521521

522522
import dotc.core.Constants._
523523

@@ -566,15 +566,15 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
566566
}
567567
}
568568

569-
private def genLabelDef(lblDf: LabelDef, expectedType: BType) {
569+
private def genLabelDef(lblDf: LabelDef, expectedType: BType): Unit = {
570570
// duplication of LabelDefs contained in `finally`-clauses is handled when emitting RETURN. No bookkeeping for that required here.
571571
// no need to call index() over lblDf.params, on first access that magic happens (moreover, no LocalVariableTable entries needed for them).
572572
markProgramPoint(programPoint(lblDf.symbol))
573573
lineNumber(lblDf)
574574
genLoad(lblDf.rhs, expectedType)
575575
}
576576

577-
private def genReturn(r: Return) {
577+
private def genReturn(r: Return): Unit = {
578578
val Return(expr) = r
579579
val returnedKind = tpeTK(expr)
580580
genLoad(expr, returnedKind)
@@ -736,7 +736,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
736736
generatedType = genPrimitiveOp(app, expectedType)
737737
} else { // normal method call
738738

739-
def genNormalMethodCall() {
739+
def genNormalMethodCall(): Unit = {
740740

741741
val invokeStyle =
742742
if (sym.isStaticMember) icodes.opcodes.Static(onInstance = false)
@@ -871,7 +871,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
871871
generatedType
872872
}
873873

874-
def genBlock(tree: Block, expectedType: BType) {
874+
def genBlock(tree: Block, expectedType: BType): Unit = {
875875
val Block(stats, expr) = tree
876876
val savedScope = varsInScope
877877
varsInScope = Nil
@@ -903,7 +903,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
903903
}
904904

905905
/* Emit code to Load the qualifier of `tree` on top of the stack. */
906-
def genLoadQualifier(tree: Tree) {
906+
def genLoadQualifier(tree: Tree): Unit = {
907907
lineNumber(tree)
908908
tree match {
909909
case Select(qualifier, _) => genLoad(qualifier)
@@ -912,7 +912,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
912912
}
913913

914914
/* Generate code that loads args into label parameters. */
915-
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 = {
916916

917917
val aps = {
918918
val params: List[Symbol] = lblDef.params.map(_.symbol)
@@ -940,7 +940,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
940940

941941
}
942942

943-
def genLoadArguments(args: List[Tree], btpes: List[BType]) {
943+
def genLoadArguments(args: List[Tree], btpes: List[BType]): Unit = {
944944
(args zip btpes) foreach { case (arg, btpe) => genLoad(arg, btpe) }
945945
}
946946

@@ -957,7 +957,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
957957
symInfoTK(module)
958958
}
959959

960-
def genLoadModule(module: Symbol) {
960+
def genLoadModule(module: Symbol): Unit = {
961961
def inStaticMethod = methSymbol != null && methSymbol.isStaticMember
962962
if (claszSymbol == module.moduleClass && jMethodName != "readResolve" && !inStaticMethod) {
963963
mnode.visitVarInsn(asm.Opcodes.ALOAD, 0)
@@ -972,15 +972,15 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
972972
}
973973
}
974974

975-
def genConversion(from: BType, to: BType, cast: Boolean) {
975+
def genConversion(from: BType, to: BType, cast: Boolean): Unit = {
976976
if (cast) { bc.emitT2T(from, to) }
977977
else {
978978
bc drop from
979979
bc boolconst (from == to)
980980
}
981981
}
982982

983-
def genCast(to: BType, cast: Boolean) {
983+
def genCast(to: BType, cast: Boolean): Unit = {
984984
if (cast) { bc checkCast to }
985985
else { bc isInstance to }
986986
}
@@ -989,7 +989,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
989989
def isPrimitive(fun: Symbol): Boolean = scalaPrimitives.isPrimitive(fun)
990990

991991
/* Generate coercion denoted by "code" */
992-
def genCoercion(code: Int) {
992+
def genCoercion(code: Int): Unit = {
993993
import scalaPrimitives._
994994
(code: @switch) match {
995995
case B2B | S2S | C2C | I2I | L2L | F2F | D2D => ()
@@ -1053,7 +1053,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
10531053
val bmType = asmMethodType(method)
10541054
val mdescr = bmType.getDescriptor
10551055

1056-
def initModule() {
1056+
def initModule(): Unit = {
10571057
// we initialize the MODULE$ field immediately after the super ctor
10581058
if (!isModuleInitialized &&
10591059
jMethodName == INSTANCE_CONSTRUCTOR_NAME &&
@@ -1122,7 +1122,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
11221122
def ifOneIsNull(l: Tree, r: Tree) = if (isNull(l)) r else if (isNull(r)) l else null
11231123

11241124
/* Emit code to compare the two top-most stack values using the 'op' operator. */
1125-
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 = {
11261126
if (tk.isIntSizedType) { // BOOL, BYTE, CHAR, SHORT, or INT
11271127
bc.emitIF_ICMP(op, success)
11281128
} else if (tk.isRefOrArrayType) { // REFERENCE(_) | ARRAY(_)
@@ -1143,7 +1143,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
11431143
}
11441144

11451145
/* Emits code to compare (and consume) stack-top and zero using the 'op' operator */
1146-
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 = {
11471147
if (tk.isIntSizedType) { // BOOL, BYTE, CHAR, SHORT, or INT
11481148
bc.emitIF(op, success)
11491149
} else if (tk.isRefOrArrayType) { // REFERENCE(_) | ARRAY(_)
@@ -1179,9 +1179,9 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
11791179
* Generate code for conditional expressions.
11801180
* The jump targets success/failure of the test are `then-target` and `else-target` resp.
11811181
*/
1182-
private def genCond(tree: Tree, success: asm.Label, failure: asm.Label) {
1182+
private def genCond(tree: Tree, success: asm.Label, failure: asm.Label): Unit = {
11831183

1184-
def genComparisonOp(l: Tree, r: Tree, code: Int) {
1184+
def genComparisonOp(l: Tree, r: Tree, code: Int): Unit = {
11851185
val op: TestOp = testOpForPrimitive(code - scalaPrimitives.ID)
11861186
// special-case reference (in)equality test for null (null eq x, x eq null)
11871187
var nonNullSide: Tree = null
@@ -1214,7 +1214,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
12141214
lazy val Select(lhs, _) = fun
12151215
val rhs = if (args.isEmpty) EmptyTree else args.head; // args.isEmpty only for ZNOT
12161216

1217-
def genZandOrZor(and: Boolean) { // TODO WRONG
1217+
def genZandOrZor(and: Boolean): Unit = { // TODO WRONG
12181218
// reaching "keepGoing" indicates the rhs should be evaluated too (ie not short-circuited).
12191219
val keepGoing = new asm.Label
12201220

@@ -1254,7 +1254,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
12541254
* @param l left-hand-side of the '=='
12551255
* @param r right-hand-side of the '=='
12561256
*/
1257-
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 = {
12581258

12591259
/* True if the equality comparison is between values that require the use of the rich equality
12601260
* comparator (scala.runtime.Comparator.equals). This is the case when either side of the

src/dotty/tools/dotc/backend/jvm/BCodeGlue.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ abstract class BCodeGlue {
488488
*
489489
* can-multi-thread
490490
*/
491-
private def getDescriptor(buf: StringBuffer) {
491+
private def getDescriptor(buf: StringBuffer): Unit = {
492492
if (isPrimitiveOrVoid) {
493493
// descriptor is in byte 3 of 'off' for primitive types (buf == null)
494494
buf.append(((off & 0xFF000000) >>> 24).asInstanceOf[Char])

src/dotty/tools/dotc/backend/jvm/BCodeHelpers.scala

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters {
263263
*
264264
* can-multi-thread
265265
*/
266-
final def addInnerClassesASM(jclass: asm.ClassVisitor, refedInnerClasses: Iterable[BType]) {
266+
final def addInnerClassesASM(jclass: asm.ClassVisitor, refedInnerClasses: Iterable[BType]): Unit = {
267267
// used to detect duplicates.
268268
val seen = mutable.Map.empty[String, String]
269269
// result without duplicates, not yet sorted.
@@ -714,7 +714,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters {
714714
* must-single-thread
715715
* but not necessarily always.
716716
*/
717-
def emitAssocs(av: asm.AnnotationVisitor, assocs: List[(Name, ClassfileAnnotArg)]) {
717+
def emitAssocs(av: asm.AnnotationVisitor, assocs: List[(Name, ClassfileAnnotArg)]): Unit = {
718718
for ((name, value) <- assocs) {
719719
emitArgument(av, name.toString(), value)
720720
}
@@ -724,7 +724,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters {
724724
/*
725725
* must-single-thread
726726
*/
727-
def emitAnnotations(cw: asm.ClassVisitor, annotations: List[AnnotationInfo]) {
727+
def emitAnnotations(cw: asm.ClassVisitor, annotations: List[AnnotationInfo]): Unit = {
728728
for(annot <- annotations; if shouldEmitAnnotation(annot)) {
729729
val AnnotationInfo(typ, args, assocs) = annot
730730
assert(args.isEmpty, args)
@@ -736,7 +736,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters {
736736
/*
737737
* must-single-thread
738738
*/
739-
def emitAnnotations(mw: asm.MethodVisitor, annotations: List[AnnotationInfo]) {
739+
def emitAnnotations(mw: asm.MethodVisitor, annotations: List[AnnotationInfo]): Unit = {
740740
for(annot <- annotations; if shouldEmitAnnotation(annot)) {
741741
val AnnotationInfo(typ, args, assocs) = annot
742742
assert(args.isEmpty, args)
@@ -748,7 +748,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters {
748748
/*
749749
* must-single-thread
750750
*/
751-
def emitAnnotations(fw: asm.FieldVisitor, annotations: List[AnnotationInfo]) {
751+
def emitAnnotations(fw: asm.FieldVisitor, annotations: List[AnnotationInfo]): Unit = {
752752
for(annot <- annotations; if shouldEmitAnnotation(annot)) {
753753
val AnnotationInfo(typ, args, assocs) = annot
754754
assert(args.isEmpty, args)
@@ -760,7 +760,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters {
760760
/*
761761
* must-single-thread
762762
*/
763-
def emitParamAnnotations(jmethod: asm.MethodVisitor, pannotss: List[List[AnnotationInfo]]) {
763+
def emitParamAnnotations(jmethod: asm.MethodVisitor, pannotss: List[List[AnnotationInfo]]): Unit = {
764764
val annotationss = pannotss map (_ filter shouldEmitAnnotation)
765765
if (annotationss forall (_.isEmpty)) return
766766
for ((annots, idx) <- annotationss.zipWithIndex;
@@ -876,7 +876,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters {
876876
*
877877
* must-single-thread
878878
*/
879-
def addRemoteExceptionAnnot(isRemoteClass: Boolean, isJMethodPublic: Boolean, meth: Symbol) {
879+
def addRemoteExceptionAnnot(isRemoteClass: Boolean, isJMethodPublic: Boolean, meth: Symbol): Unit = {
880880
val needsAnnotation = (
881881
( isRemoteClass ||
882882
isRemote(meth) && isJMethodPublic
@@ -893,7 +893,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters {
893893
*
894894
* must-single-thread
895895
*/
896-
private def addForwarder(isRemoteClass: Boolean, jclass: asm.ClassVisitor, module: Symbol, m: Symbol) {
896+
private def addForwarder(isRemoteClass: Boolean, jclass: asm.ClassVisitor, module: Symbol, m: Symbol): Unit = {
897897
val moduleName = internalName(module)
898898
val methodInfo = module.thisType.memberInfo(m)
899899
val paramJavaTypes: List[BType] = methodInfo.paramTypes map toTypeKind
@@ -955,7 +955,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters {
955955
*
956956
* must-single-thread
957957
*/
958-
def addForwarders(isRemoteClass: Boolean, jclass: asm.ClassVisitor, jclassName: String, moduleClass: Symbol) {
958+
def addForwarders(isRemoteClass: Boolean, jclass: asm.ClassVisitor, jclassName: String, moduleClass: Symbol): Unit = {
959959
assert(moduleClass.isModuleClass, moduleClass)
960960
debuglog(s"Dumping mirror class for object: $moduleClass")
961961

@@ -1015,7 +1015,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters {
10151015
*
10161016
* can-multi-thread
10171017
*/
1018-
def addSerialVUID(id: Long, jclass: asm.ClassVisitor) {
1018+
def addSerialVUID(id: Long, jclass: asm.ClassVisitor): Unit = {
10191019
// add static serialVersionUID field if `clasz` annotated with `@SerialVersionUID(uid: Long)`
10201020
jclass.visitField(
10211021
PublicStaticFinal,
@@ -1215,7 +1215,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters {
12151215
Array(exemplar(definitions.ClassClass).c, stringArrayJType, stringArrayJType)
12161216
)
12171217

1218-
def push(lst: List[String]) {
1218+
def push(lst: List[String]): Unit = {
12191219
var fi = 0
12201220
for (f <- lst) {
12211221
constructor.visitInsn(asm.Opcodes.DUP)
@@ -1281,7 +1281,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters {
12811281
/*
12821282
* must-single-thread
12831283
*/
1284-
def legacyAddCreatorCode(clinit: asm.MethodVisitor, cnode: asm.tree.ClassNode, thisName: String) {
1284+
def legacyAddCreatorCode(clinit: asm.MethodVisitor, cnode: asm.tree.ClassNode, thisName: String): Unit = {
12851285
// this tracks the inner class in innerClassBufferASM, if needed.
12861286
val androidCreatorType = asmClassType(AndroidCreatorClass)
12871287
val tdesc_creator = androidCreatorType.getDescriptor

0 commit comments

Comments
 (0)