From 5ac95b6a0f2ffd4ab06982f11e7cc2f21c3d57f0 Mon Sep 17 00:00:00 2001 From: Miguel Garcia Date: Thu, 13 Feb 2014 13:09:39 +0100 Subject: [PATCH 1/8] Flags.ModuleVal, Flags.PackageClass --- .../tools/dotc/backend/jvm/BCodeBodyBuilder.scala | 13 +++++++------ src/dotty/tools/dotc/backend/jvm/BCodeHelpers.scala | 4 ++-- src/dotty/tools/dotc/backend/jvm/BCodeTypes.scala | 6 +++--- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/dotty/tools/dotc/backend/jvm/BCodeBodyBuilder.scala b/src/dotty/tools/dotc/backend/jvm/BCodeBodyBuilder.scala index 16b0e2d93c69..cd2b5d47515e 100755 --- a/src/dotty/tools/dotc/backend/jvm/BCodeBodyBuilder.scala +++ b/src/dotty/tools/dotc/backend/jvm/BCodeBodyBuilder.scala @@ -15,6 +15,7 @@ import scala.annotation.switch import dotty.tools.asm import dotc.ast.Trees._ +import core.Flags import core.Types.Type import core.StdNames import core.Symbols.{Symbol, NoSymbol} @@ -392,7 +393,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder { // case ApplyDynamic(qual, args) => sys.error("No invokedynamic support yet.") case This(qual) => - val symIsModuleClass = tree.symbol.isModuleClass + val symIsModuleClass = tree.symbol is Flags.ModuleVal assert(tree.symbol == claszSymbol || symIsModuleClass, s"Trying to access the this of another class: tree.symbol = ${tree.symbol}, class symbol = $claszSymbol compilation unit: $cunit") if (symIsModuleClass && tree.symbol != claszSymbol) { @@ -406,7 +407,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder { } case Select(Ident(nme.EMPTY_PACKAGE_NAME), module) => - assert(tree.symbol.isModule, s"Selection of non-module from empty package: $tree sym: ${tree.symbol} at: ${tree.pos}") + assert(tree.symbol is Flags.ModuleVal, s"Selection of non-module from empty package: $tree sym: ${tree.symbol} at: ${tree.pos}") genLoadModule(tree) case Select(qualifier, selector) => @@ -418,7 +419,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder { def genLoadQualUnlessElidable() { if (!qualSafeToElide) { genLoadQualifier(tree) } } - if (sym.isModule) { + if (sym is Flags.ModuleVal) { genLoadQualUnlessElidable() genLoadModule(tree) } @@ -435,7 +436,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder { val sym = tree.symbol if (!sym.isPackage) { val tk = symInfoTK(sym) - if (sym.isModule) { genLoadModule(tree) } + if (sym is Flags.ModuleVal) { genLoadModule(tree) } else { locals.load(sym) } generatedType = tk } @@ -945,7 +946,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder { def genLoadModule(tree: Tree): BType = { val module = ( - if (!tree.symbol.isPackageClass) tree.symbol + if (!tree.symbol is Flags.PackageClass) tree.symbol else tree.symbol.info.member(nme.PACKAGE) match { case NoSymbol => abort(s"SI-5604: Cannot use package as value: $tree") case s => abort(s"SI-5604: found package class where package object expected: $tree") @@ -1035,7 +1036,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder { def needsInterfaceCall(sym: Symbol) = ( sym.isInterface - || sym.isJavaDefined && sym.isNonBottomSubClass(definitions.ClassfileAnnotationClass) + || (sym is Flags.JavaDefined) && sym.isNonBottomSubClass(definitions.ClassfileAnnotationClass) ) // whether to reference the type of the receiver or diff --git a/src/dotty/tools/dotc/backend/jvm/BCodeHelpers.scala b/src/dotty/tools/dotc/backend/jvm/BCodeHelpers.scala index 76e8612a4891..ed0e2cd4f745 100755 --- a/src/dotty/tools/dotc/backend/jvm/BCodeHelpers.scala +++ b/src/dotty/tools/dotc/backend/jvm/BCodeHelpers.scala @@ -238,7 +238,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters { */ def fieldSymbols(cls: Symbol)(implicit ctx: core.Contexts.Context): List[Symbol] = { for (f <- cls.info.decls.toList ; - if !f.isMethod && f.isTerm && !f.isModule + if !f.isMethod && f.isTerm && !(f is Flags.ModuleVal) ) yield f; } @@ -703,7 +703,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters { * must-single-thread */ private def shouldEmitAnnotation(annot: AnnotationInfo) = - annot.symbol.initialize.isJavaDefined && + (annot.symbol.initialize is Flags.JavaDefined) && annot.matches(definitions.ClassfileAnnotationClass) && annot.args.isEmpty && !annot.matches(definitions.DeprecatedAttr) diff --git a/src/dotty/tools/dotc/backend/jvm/BCodeTypes.scala b/src/dotty/tools/dotc/backend/jvm/BCodeTypes.scala index 6abcf623f4f6..c75bc2fc220b 100755 --- a/src/dotty/tools/dotc/backend/jvm/BCodeTypes.scala +++ b/src/dotty/tools/dotc/backend/jvm/BCodeTypes.scala @@ -334,7 +334,7 @@ abstract class BCodeTypes extends BCodeIdiomatic { final def isDeprecated(sym: Symbol): Boolean = { sym.annotations exists (_ matches definitions.DeprecatedAttr) } /* must-single-thread */ - final def hasInternalName(sym: Symbol) = { sym.isClass || (sym.isModule && !sym.isMethod) } + final def hasInternalName(sym: Symbol) = { sym.isClass || ((sym is Flags.ModuleVal) && !sym.isMethod) } /* must-single-thread */ def getSuperInterfaces(csym: Symbol): List[Symbol] = { @@ -698,7 +698,7 @@ abstract class BCodeTypes extends BCodeIdiomatic { * must-single-thread */ def innerClassSymbolFor(s: Symbol): Symbol = - if (s.isClass) s else if (s.isModule) s.moduleClass else NoSymbol + if (s.isClass) s else if (s is Flags.ModuleVal) s.moduleClass else NoSymbol /* * Computes the chain of inner-class (over the is-member-of relation) for the given argument. @@ -734,7 +734,7 @@ abstract class BCodeTypes extends BCodeIdiomatic { var x = ics while (x ne NoSymbol) { assert(x.isClass, s"not a class symbol: ${x.fullName}") - val isInner = !x.rawowner.isPackageClass + val isInner = !(x.rawowner is Flags.PackageClass) if (isInner) { chain ::= x x = innerClassSymbolFor(x.rawowner) From 0ade6aa2a81d0a785f0b074f46f1ee9dbf9c653e Mon Sep 17 00:00:00 2001 From: Miguel Garcia Date: Thu, 13 Feb 2014 13:25:08 +0100 Subject: [PATCH 2/8] Flags.ImplClass --- src/dotty/tools/dotc/backend/jvm/BCodeHelpers.scala | 2 +- src/dotty/tools/dotc/backend/jvm/BCodeSkelBuilder.scala | 2 +- src/dotty/tools/dotc/backend/jvm/BCodeTypes.scala | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/dotty/tools/dotc/backend/jvm/BCodeHelpers.scala b/src/dotty/tools/dotc/backend/jvm/BCodeHelpers.scala index ed0e2cd4f745..c3f8f9ad2cca 100755 --- a/src/dotty/tools/dotc/backend/jvm/BCodeHelpers.scala +++ b/src/dotty/tools/dotc/backend/jvm/BCodeHelpers.scala @@ -791,7 +791,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters { || sym.isArtifact || sym.isLiftedMethod || sym.isBridge - || (sym.ownerChain exists (_.isImplClass)) + || (sym.ownerChain exists (_ is Flags.ImplClass)) ) def getCurrentCUnit(): CompilationUnit diff --git a/src/dotty/tools/dotc/backend/jvm/BCodeSkelBuilder.scala b/src/dotty/tools/dotc/backend/jvm/BCodeSkelBuilder.scala index d0795eae3e70..87f5b710297f 100755 --- a/src/dotty/tools/dotc/backend/jvm/BCodeSkelBuilder.scala +++ b/src/dotty/tools/dotc/backend/jvm/BCodeSkelBuilder.scala @@ -185,7 +185,7 @@ abstract class BCodeSkelBuilder extends BCodeHelpers { if (lmoc != NoSymbol) { // it must be a top level class (name contains no $s) val isCandidateForForwarders = { - exitingPickler { !(lmoc.name.toString contains '$') && lmoc.hasModuleFlag && !lmoc.isImplClass && !lmoc.isNestedClass } + exitingPickler { !(lmoc.name.toString contains '$') && lmoc.hasModuleFlag && !(lmoc is Flags.ImplClass) && !lmoc.isNestedClass } } if (isCandidateForForwarders) { log(s"Adding static forwarders from '$claszSymbol' to implementations in '$lmoc'") diff --git a/src/dotty/tools/dotc/backend/jvm/BCodeTypes.scala b/src/dotty/tools/dotc/backend/jvm/BCodeTypes.scala index c75bc2fc220b..e53798efcaf1 100755 --- a/src/dotty/tools/dotc/backend/jvm/BCodeTypes.scala +++ b/src/dotty/tools/dotc/backend/jvm/BCodeTypes.scala @@ -421,7 +421,7 @@ abstract class BCodeTypes extends BCodeIdiomatic { */ private def buildExemplar(key: BType, csym: Symbol): Tracked = { val sc = - if (csym.isImplClass) definitions.ObjectClass + if (csym is Flags.ImplClass) definitions.ObjectClass else csym.superClass assert( if (csym == definitions.ObjectClass) @@ -653,14 +653,14 @@ abstract class BCodeTypes extends BCodeIdiomatic { * must-single-thread */ def isTopLevelModule(sym: Symbol): Boolean = { - exitingPickler { sym.isModuleClass && !sym.isImplClass && !sym.isNestedClass } + exitingPickler { sym.isModuleClass && !(sym is Flags.ImplClass) && !sym.isNestedClass } } /* * must-single-thread */ def isStaticModule(sym: Symbol): Boolean = { - sym.isModuleClass && !sym.isImplClass && !sym.isLifted + sym.isModuleClass && !(sym is Flags.ImplClass) && !sym.isLifted } // --------------------------------------------------------------------- From a7006d39d336fb4ef875bf5d5f8b77391b451293 Mon Sep 17 00:00:00 2001 From: Miguel Garcia Date: Thu, 13 Feb 2014 13:38:32 +0100 Subject: [PATCH 3/8] Flags.Private --- src/dotty/tools/dotc/backend/jvm/BCodeBodyBuilder.scala | 4 ++-- src/dotty/tools/dotc/backend/jvm/BCodeTypes.scala | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/dotty/tools/dotc/backend/jvm/BCodeBodyBuilder.scala b/src/dotty/tools/dotc/backend/jvm/BCodeBodyBuilder.scala index cd2b5d47515e..d677fa47b433 100755 --- a/src/dotty/tools/dotc/backend/jvm/BCodeBodyBuilder.scala +++ b/src/dotty/tools/dotc/backend/jvm/BCodeBodyBuilder.scala @@ -740,7 +740,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder { val invokeStyle = if (sym.isStaticMember) icodes.opcodes.Static(onInstance = false) - else if (sym.isPrivate || sym.isClassConstructor) icodes.opcodes.Static(onInstance = true) + else if ((sym is Flags.Private) || sym.isClassConstructor) icodes.opcodes.Static(onInstance = true) else icodes.opcodes.Dynamic; if (invokeStyle.hasInstance) { @@ -1035,7 +1035,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder { hostSymbol.info ; methodOwner.info def needsInterfaceCall(sym: Symbol) = ( - sym.isInterface + (sym is Flags.Interface) || (sym is Flags.JavaDefined) && sym.isNonBottomSubClass(definitions.ClassfileAnnotationClass) ) diff --git a/src/dotty/tools/dotc/backend/jvm/BCodeTypes.scala b/src/dotty/tools/dotc/backend/jvm/BCodeTypes.scala index e53798efcaf1..aacf30c69829 100755 --- a/src/dotty/tools/dotc/backend/jvm/BCodeTypes.scala +++ b/src/dotty/tools/dotc/backend/jvm/BCodeTypes.scala @@ -835,7 +835,7 @@ abstract class BCodeTypes extends BCodeIdiomatic { // constructors of module classes should be private // PP: why are they only being marked private at this stage and not earlier? val privateFlag = - sym.isPrivate || (sym.isPrimaryConstructor && isTopLevelModule(sym.owner)) + (sym is Flags.Private) || (sym.isPrimaryConstructor && isTopLevelModule(sym.owner)) // Final: the only fields which can receive ACC_FINAL are eager vals. // Neither vars nor lazy vals can, because: From a7ec28e35b1a30ce3409e9c6d283136e4dc2dd75 Mon Sep 17 00:00:00 2001 From: Miguel Garcia Date: Thu, 13 Feb 2014 13:40:53 +0100 Subject: [PATCH 4/8] Flags.Method --- src/dotty/tools/dotc/backend/jvm/BCodeHelpers.scala | 12 ++++++------ src/dotty/tools/dotc/backend/jvm/BCodeTypes.scala | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/dotty/tools/dotc/backend/jvm/BCodeHelpers.scala b/src/dotty/tools/dotc/backend/jvm/BCodeHelpers.scala index c3f8f9ad2cca..5d4dfb85165d 100755 --- a/src/dotty/tools/dotc/backend/jvm/BCodeHelpers.scala +++ b/src/dotty/tools/dotc/backend/jvm/BCodeHelpers.scala @@ -238,7 +238,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters { */ def fieldSymbols(cls: Symbol)(implicit ctx: core.Contexts.Context): List[Symbol] = { for (f <- cls.info.decls.toList ; - if !f.isMethod && f.isTerm && !(f is Flags.ModuleVal) + if !(f is Flags.Method) && f.isTerm && !(f is Flags.ModuleVal) ) yield f; } @@ -535,7 +535,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters { * must-single-thread */ def asmMethodType(msym: Symbol): BType = { - assert(msym.isMethod, s"not a method-symbol: $msym") + assert(msym is Flags.Method, s"not a method-symbol: $msym") val resT: BType = if (msym.isClassConstructor || msym.isConstructor) BType.VOID_TYPE else toTypeKind(msym.tpe.resultType); @@ -824,9 +824,9 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters { val isValidSignature = wrap { // Alternative: scala.tools.reflect.SigParser (frontend to sun.reflect.generics.parser.SignatureParser) import dotty.tools.asm.util.CheckClassAdapter - if (sym.isMethod) { CheckClassAdapter checkMethodSignature sig } - else if (sym.isTerm) { CheckClassAdapter checkFieldSignature sig } - else { CheckClassAdapter checkClassSignature sig } + if (sym is Flags.Method) { CheckClassAdapter checkMethodSignature sig } + else if (sym.isTerm) { CheckClassAdapter checkFieldSignature sig } + else { CheckClassAdapter checkClassSignature sig } } if (!isValidSignature) { @@ -1055,7 +1055,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters { var res: EnclMethodEntry = null val sym = clazz.originalEnclosingMethod - if (sym.isMethod) { + if (sym is Flags.Method) { debuglog(s"enclosing method for $clazz is $sym (in ${sym.enclClass})") res = newEEE(sym.enclClass, sym) } else if (clazz.isAnonymousClass) { diff --git a/src/dotty/tools/dotc/backend/jvm/BCodeTypes.scala b/src/dotty/tools/dotc/backend/jvm/BCodeTypes.scala index aacf30c69829..627df92597e0 100755 --- a/src/dotty/tools/dotc/backend/jvm/BCodeTypes.scala +++ b/src/dotty/tools/dotc/backend/jvm/BCodeTypes.scala @@ -334,7 +334,7 @@ abstract class BCodeTypes extends BCodeIdiomatic { final def isDeprecated(sym: Symbol): Boolean = { sym.annotations exists (_ matches definitions.DeprecatedAttr) } /* must-single-thread */ - final def hasInternalName(sym: Symbol) = { sym.isClass || ((sym is Flags.ModuleVal) && !sym.isMethod) } + final def hasInternalName(sym: Symbol) = { sym.isClass || ((sym is Flags.ModuleVal) && !(sym is Flags.Method)) } /* must-single-thread */ def getSuperInterfaces(csym: Symbol): List[Symbol] = { From 2059e1404f8249f66dc0d1f33ba6d7aff8ffdb35 Mon Sep 17 00:00:00 2001 From: Miguel Garcia Date: Thu, 13 Feb 2014 13:59:00 +0100 Subject: [PATCH 5/8] passing Context around --- .../tools/dotc/backend/jvm/BCodeHelpers.scala | 19 ++++++++++--------- .../tools/dotc/backend/jvm/BCodeTypes.scala | 5 ++++- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/dotty/tools/dotc/backend/jvm/BCodeHelpers.scala b/src/dotty/tools/dotc/backend/jvm/BCodeHelpers.scala index 5d4dfb85165d..77c60aa1ca07 100755 --- a/src/dotty/tools/dotc/backend/jvm/BCodeHelpers.scala +++ b/src/dotty/tools/dotc/backend/jvm/BCodeHelpers.scala @@ -405,14 +405,14 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters { * * must-single-thread */ - final def internalName(sym: Symbol): String = { asmClassType(sym).getInternalName } + final def internalName(sym: Symbol)(implicit ctx: core.Contexts.Context): String = asmClassType(sym).getInternalName /* * Tracks (if needed) the inner class given by `sym`. * * must-single-thread */ - final def asmClassType(sym: Symbol): BType = { + final def asmClassType(sym: Symbol)(implicit ctx: core.Contexts.Context): BType = { assert( hasInternalName(sym), { @@ -489,16 +489,17 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters { } def primitiveOrRefType2(sym: Symbol): BType = { + import core.Symbols.defn + primitiveTypeMap.get(sym) match { case Some(pt) => pt case None => - sym match { - case definitions.NullClass => RT_NULL - case definitions.NothingClass => RT_NOTHING - case _ if sym.isClass => newReference(sym) - case _ => - assert(sym.isType, sym) // it must be compiling Array[a] - ObjectReference + if (sym == defn.NullClass) RT_NULL + else if (sym == defn.NothingClass) RT_NOTHING + else if (sym.isClass) newReference(sym) + else { + assert(sym.isType, sym) // it must be compiling Array[a] + ObjectReference } } } diff --git a/src/dotty/tools/dotc/backend/jvm/BCodeTypes.scala b/src/dotty/tools/dotc/backend/jvm/BCodeTypes.scala index 627df92597e0..1f7edd9ec996 100755 --- a/src/dotty/tools/dotc/backend/jvm/BCodeTypes.scala +++ b/src/dotty/tools/dotc/backend/jvm/BCodeTypes.scala @@ -334,7 +334,10 @@ abstract class BCodeTypes extends BCodeIdiomatic { final def isDeprecated(sym: Symbol): Boolean = { sym.annotations exists (_ matches definitions.DeprecatedAttr) } /* must-single-thread */ - final def hasInternalName(sym: Symbol) = { sym.isClass || ((sym is Flags.ModuleVal) && !(sym is Flags.Method)) } + final def hasInternalName(sym: Symbol)(implicit ctx: core.Contexts.Context) = ( + sym.isClass || + ((sym is Flags.ModuleVal) && !(sym is Flags.Method)) + ) /* must-single-thread */ def getSuperInterfaces(csym: Symbol): List[Symbol] = { From e8a38ce3999d420e0723579f556b9524904f68f1 Mon Sep 17 00:00:00 2001 From: Miguel Garcia Date: Thu, 13 Feb 2014 14:19:24 +0100 Subject: [PATCH 6/8] log, abort --- .../tools/dotc/backend/jvm/BCodeBodyBuilder.scala | 8 ++++---- src/dotty/tools/dotc/backend/jvm/BCodeHelpers.scala | 10 +++++----- src/dotty/tools/dotc/backend/jvm/BCodeIdiomatic.scala | 6 ++++++ .../tools/dotc/backend/jvm/BCodeSkelBuilder.scala | 6 +----- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/dotty/tools/dotc/backend/jvm/BCodeBodyBuilder.scala b/src/dotty/tools/dotc/backend/jvm/BCodeBodyBuilder.scala index d677fa47b433..6ebe3c2d1ec5 100755 --- a/src/dotty/tools/dotc/backend/jvm/BCodeBodyBuilder.scala +++ b/src/dotty/tools/dotc/backend/jvm/BCodeBodyBuilder.scala @@ -757,12 +757,12 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder { val qualSym = findHostClass(qual.tpe, sym) if (qualSym == ArrayClass) { targetTypeKind = tpeTK(qual) - log(s"Stored target type kind for ${sym.fullName} as $targetTypeKind") + ctx.log(s"Stored target type kind for ${sym.fullName} as $targetTypeKind") } else { hostClass = qualSym if (qual.tpe.typeSymbol != qualSym) { - log(s"Precisified host class for $sym from ${qual.tpe.typeSymbol.fullName} to ${qualSym.fullName}") + ctx.log(s"Precisified host class for $sym from ${qual.tpe.typeSymbol.fullName} to ${qualSym.fullName}") } } @@ -948,8 +948,8 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder { val module = ( if (!tree.symbol is Flags.PackageClass) tree.symbol else tree.symbol.info.member(nme.PACKAGE) match { - case NoSymbol => abort(s"SI-5604: Cannot use package as value: $tree") - case s => abort(s"SI-5604: found package class where package object expected: $tree") + case NoDenotation => abort(s"SI-5604: Cannot use package as value: $tree") + case s => abort(s"SI-5604: found package class where package object expected: $tree") } ) lineNumber(tree) diff --git a/src/dotty/tools/dotc/backend/jvm/BCodeHelpers.scala b/src/dotty/tools/dotc/backend/jvm/BCodeHelpers.scala index 77c60aa1ca07..2c88db994936 100755 --- a/src/dotty/tools/dotc/backend/jvm/BCodeHelpers.scala +++ b/src/dotty/tools/dotc/backend/jvm/BCodeHelpers.scala @@ -209,7 +209,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters { /* * must-single-thread */ - def initBytecodeWriter(entryPoints: List[Symbol]): BytecodeWriter = { + def initBytecodeWriter(entryPoints: List[Symbol])(implicit ctx: core.Contexts.Context): BytecodeWriter = { settings.outputDirs.getSingleOutput match { case Some(f) if f hasExtension "jar" => // If no main class was specified, see if there's only one @@ -217,15 +217,15 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters { if (settings.mainClass.isDefault) { entryPoints map (_.fullName('.')) match { case Nil => - log("No Main-Class designated or discovered.") + ctx.log("No Main-Class designated or discovered.") case name :: Nil => - log(s"Unique entry point: setting Main-Class to $name") + ctx.log(s"Unique entry point: setting Main-Class to $name") settings.mainClass.value = name case names => - log(s"No Main-Class due to multiple entry points:\n ${names.mkString("\n ")}") + ctx.log(s"No Main-Class due to multiple entry points:\n ${names.mkString("\n ")}") } } - else log(s"Main-Class was specified: ${settings.mainClass.value}") + else ctx.log(s"Main-Class was specified: ${settings.mainClass.value}") new DirectToJarfileWriter(f.file) diff --git a/src/dotty/tools/dotc/backend/jvm/BCodeIdiomatic.scala b/src/dotty/tools/dotc/backend/jvm/BCodeIdiomatic.scala index b242a485c8a3..fb1c7da4b5ee 100755 --- a/src/dotty/tools/dotc/backend/jvm/BCodeIdiomatic.scala +++ b/src/dotty/tools/dotc/backend/jvm/BCodeIdiomatic.scala @@ -691,4 +691,10 @@ abstract class BCodeIdiomatic extends BCodeGlue { } } } + + def abort(msg: => AnyRef)(implicit ctx: core.Contexts.Context): Nothing = { + ctx.error(msg) + throw new FatalError(msg) + } + } diff --git a/src/dotty/tools/dotc/backend/jvm/BCodeSkelBuilder.scala b/src/dotty/tools/dotc/backend/jvm/BCodeSkelBuilder.scala index 87f5b710297f..dfb9de2d40e9 100755 --- a/src/dotty/tools/dotc/backend/jvm/BCodeSkelBuilder.scala +++ b/src/dotty/tools/dotc/backend/jvm/BCodeSkelBuilder.scala @@ -83,10 +83,6 @@ abstract class BCodeSkelBuilder extends BCodeHelpers { def tpeTK(tree: Tree): BType = { toTypeKind(tree.tpe) } - def log(msg: => AnyRef) { - global synchronized { global.log(msg) } - } - override def getCurrentCUnit(): CompilationUnit = { cunit } /* ---------------- helper utils for generating classes and fiels ---------------- */ @@ -188,7 +184,7 @@ abstract class BCodeSkelBuilder extends BCodeHelpers { exitingPickler { !(lmoc.name.toString contains '$') && lmoc.hasModuleFlag && !(lmoc is Flags.ImplClass) && !lmoc.isNestedClass } } if (isCandidateForForwarders) { - log(s"Adding static forwarders from '$claszSymbol' to implementations in '$lmoc'") + ctx.log(s"Adding static forwarders from '$claszSymbol' to implementations in '$lmoc'") addForwarders(isRemote(claszSymbol), cnode, thisName, lmoc.moduleClass) } } From a43deb703296523303e9eed63781ca5f3a7eb38b Mon Sep 17 00:00:00 2001 From: Miguel Garcia Date: Thu, 13 Feb 2014 14:33:19 +0100 Subject: [PATCH 7/8] the new procedural syntax --- .../dotc/backend/jvm/BCodeBodyBuilder.scala | 56 ++++++------ .../tools/dotc/backend/jvm/BCodeGlue.scala | 2 +- .../tools/dotc/backend/jvm/BCodeHelpers.scala | 24 +++--- .../dotc/backend/jvm/BCodeIdiomatic.scala | 86 +++++++++---------- .../dotc/backend/jvm/BCodeSkelBuilder.scala | 38 ++++---- .../dotc/backend/jvm/BCodeSyncAndTry.scala | 8 +- .../tools/dotc/backend/jvm/BCodeTypes.scala | 8 +- .../dotc/backend/jvm/BytecodeWriters.scala | 10 +-- .../tools/dotc/backend/jvm/GenBCode.scala | 16 ++-- .../dotc/backend/jvm/scalaPrimitives.scala | 6 +- 10 files changed, 127 insertions(+), 127 deletions(-) diff --git a/src/dotty/tools/dotc/backend/jvm/BCodeBodyBuilder.scala b/src/dotty/tools/dotc/backend/jvm/BCodeBodyBuilder.scala index 6ebe3c2d1ec5..bf351454cef2 100755 --- a/src/dotty/tools/dotc/backend/jvm/BCodeBodyBuilder.scala +++ b/src/dotty/tools/dotc/backend/jvm/BCodeBodyBuilder.scala @@ -53,9 +53,9 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder { /* ---------------- helper utils for generating methods and code ---------------- */ - def emit(opc: Int) { mnode.visitInsn(opc) } + def emit(opc: Int): Unit = { mnode.visitInsn(opc) } - def emitZeroOf(tk: BType) { + def emitZeroOf(tk: BType): Unit = { (tk.sort: @switch) match { case asm.Type.BOOLEAN => bc.boolconst(false) case asm.Type.BYTE | @@ -75,7 +75,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder { * Two main cases: `tree` is an assignment, * otherwise an `adapt()` to UNIT is performed if needed. */ - def genStat(tree: Tree) { + def genStat(tree: Tree): Unit = { lineNumber(tree) tree match { case Assign(lhs @ Select(_, _), rhs) => @@ -341,12 +341,12 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder { ) } - def genLoad(tree: Tree) { + def genLoad(tree: Tree): Unit = { genLoad(tree, tpeTK(tree)) } /* Generate code for trees that produce values on the stack */ - def genLoad(tree: Tree, expectedType: BType) { + def genLoad(tree: Tree, expectedType: BType): Unit = { var generatedType = expectedType lineNumber(tree) @@ -417,7 +417,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder { debuglog(s"Host class of $sym with qual $qualifier (${qualifier.tpe}) is $hostClass") val qualSafeToElide = treeInfo isQualifierSafeToElide qualifier - def genLoadQualUnlessElidable() { if (!qualSafeToElide) { genLoadQualifier(tree) } } + def genLoadQualUnlessElidable(): Unit = { if (!qualSafeToElide) { genLoadQualifier(tree) } } if (sym is Flags.ModuleVal) { genLoadQualUnlessElidable() @@ -482,20 +482,20 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder { /* * must-single-thread */ - def fieldLoad( field: Symbol, hostClass: Symbol = null) { + def fieldLoad( field: Symbol, hostClass: Symbol = null): Unit = { fieldOp(field, isLoad = true, hostClass) } /* * must-single-thread */ - def fieldStore(field: Symbol, hostClass: Symbol = null) { + def fieldStore(field: Symbol, hostClass: Symbol = null): Unit = { fieldOp(field, isLoad = false, hostClass) } /* * must-single-thread */ - private def fieldOp(field: Symbol, isLoad: Boolean, hostClass: Symbol) { + private def fieldOp(field: Symbol, isLoad: Boolean, hostClass: Symbol): Unit = { // LOAD_FIELD.hostClass , CALL_METHOD.hostClass , and #4283 val owner = if (hostClass == null) internalName(field.owner) @@ -517,7 +517,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder { * must-single-thread * Otherwise it's safe to call from multiple threads. */ - def genConstant(const: Constant) { + def genConstant(const: Constant): Unit = { import dotc.core.Constants._ @@ -566,7 +566,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder { } } - private def genLabelDef(lblDf: LabelDef, expectedType: BType) { + private def genLabelDef(lblDf: LabelDef, expectedType: BType): Unit = { // duplication of LabelDefs contained in `finally`-clauses is handled when emitting RETURN. No bookkeeping for that required here. // no need to call index() over lblDf.params, on first access that magic happens (moreover, no LocalVariableTable entries needed for them). markProgramPoint(programPoint(lblDf.symbol)) @@ -574,7 +574,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder { genLoad(lblDf.rhs, expectedType) } - private def genReturn(r: Return) { + private def genReturn(r: Return): Unit = { val Return(expr) = r val returnedKind = tpeTK(expr) genLoad(expr, returnedKind) @@ -736,7 +736,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder { generatedType = genPrimitiveOp(app, expectedType) } else { // normal method call - def genNormalMethodCall() { + def genNormalMethodCall(): Unit = { val invokeStyle = if (sym.isStaticMember) icodes.opcodes.Static(onInstance = false) @@ -871,7 +871,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder { generatedType } - def genBlock(tree: Block, expectedType: BType) { + def genBlock(tree: Block, expectedType: BType): Unit = { val Block(stats, expr) = tree val savedScope = varsInScope varsInScope = Nil @@ -903,7 +903,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder { } /* Emit code to Load the qualifier of `tree` on top of the stack. */ - def genLoadQualifier(tree: Tree) { + def genLoadQualifier(tree: Tree): Unit = { lineNumber(tree) tree match { case Select(qualifier, _) => genLoad(qualifier) @@ -912,7 +912,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder { } /* Generate code that loads args into label parameters. */ - def genLoadLabelArguments(args: List[Tree], lblDef: LabelDef, gotoPos: dotc.util.Positions.Position) { + def genLoadLabelArguments(args: List[Tree], lblDef: LabelDef, gotoPos: dotc.util.Positions.Position): Unit = { val aps = { val params: List[Symbol] = lblDef.params.map(_.symbol) @@ -940,7 +940,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder { } - def genLoadArguments(args: List[Tree], btpes: List[BType]) { + def genLoadArguments(args: List[Tree], btpes: List[BType]): Unit = { (args zip btpes) foreach { case (arg, btpe) => genLoad(arg, btpe) } } @@ -957,7 +957,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder { symInfoTK(module) } - def genLoadModule(module: Symbol) { + def genLoadModule(module: Symbol): Unit = { def inStaticMethod = methSymbol != null && methSymbol.isStaticMember if (claszSymbol == module.moduleClass && jMethodName != "readResolve" && !inStaticMethod) { mnode.visitVarInsn(asm.Opcodes.ALOAD, 0) @@ -972,7 +972,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder { } } - def genConversion(from: BType, to: BType, cast: Boolean) { + def genConversion(from: BType, to: BType, cast: Boolean): Unit = { if (cast) { bc.emitT2T(from, to) } else { bc drop from @@ -980,7 +980,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder { } } - def genCast(to: BType, cast: Boolean) { + def genCast(to: BType, cast: Boolean): Unit = { if (cast) { bc checkCast to } else { bc isInstance to } } @@ -989,7 +989,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder { def isPrimitive(fun: Symbol): Boolean = scalaPrimitives.isPrimitive(fun) /* Generate coercion denoted by "code" */ - def genCoercion(code: Int) { + def genCoercion(code: Int): Unit = { import scalaPrimitives._ (code: @switch) match { case B2B | S2S | C2C | I2I | L2L | F2F | D2D => () @@ -1053,7 +1053,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder { val bmType = asmMethodType(method) val mdescr = bmType.getDescriptor - def initModule() { + def initModule(): Unit = { // we initialize the MODULE$ field immediately after the super ctor if (!isModuleInitialized && jMethodName == INSTANCE_CONSTRUCTOR_NAME && @@ -1122,7 +1122,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder { def ifOneIsNull(l: Tree, r: Tree) = if (isNull(l)) r else if (isNull(r)) l else null /* Emit code to compare the two top-most stack values using the 'op' operator. */ - private def genCJUMP(success: asm.Label, failure: asm.Label, op: TestOp, tk: BType) { + private def genCJUMP(success: asm.Label, failure: asm.Label, op: TestOp, tk: BType): Unit = { if (tk.isIntSizedType) { // BOOL, BYTE, CHAR, SHORT, or INT bc.emitIF_ICMP(op, success) } else if (tk.isRefOrArrayType) { // REFERENCE(_) | ARRAY(_) @@ -1143,7 +1143,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder { } /* Emits code to compare (and consume) stack-top and zero using the 'op' operator */ - private def genCZJUMP(success: asm.Label, failure: asm.Label, op: TestOp, tk: BType) { + private def genCZJUMP(success: asm.Label, failure: asm.Label, op: TestOp, tk: BType): Unit = { if (tk.isIntSizedType) { // BOOL, BYTE, CHAR, SHORT, or INT bc.emitIF(op, success) } else if (tk.isRefOrArrayType) { // REFERENCE(_) | ARRAY(_) @@ -1179,9 +1179,9 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder { * Generate code for conditional expressions. * The jump targets success/failure of the test are `then-target` and `else-target` resp. */ - private def genCond(tree: Tree, success: asm.Label, failure: asm.Label) { + private def genCond(tree: Tree, success: asm.Label, failure: asm.Label): Unit = { - def genComparisonOp(l: Tree, r: Tree, code: Int) { + def genComparisonOp(l: Tree, r: Tree, code: Int): Unit = { val op: TestOp = testOpForPrimitive(code - scalaPrimitives.ID) // special-case reference (in)equality test for null (null eq x, x eq null) var nonNullSide: Tree = null @@ -1214,7 +1214,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder { lazy val Select(lhs, _) = fun val rhs = if (args.isEmpty) EmptyTree else args.head; // args.isEmpty only for ZNOT - def genZandOrZor(and: Boolean) { // TODO WRONG + def genZandOrZor(and: Boolean): Unit = { // TODO WRONG // reaching "keepGoing" indicates the rhs should be evaluated too (ie not short-circuited). val keepGoing = new asm.Label @@ -1254,7 +1254,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder { * @param l left-hand-side of the '==' * @param r right-hand-side of the '==' */ - def genEqEqPrimitive(l: Tree, r: Tree, success: asm.Label, failure: asm.Label) { + def genEqEqPrimitive(l: Tree, r: Tree, success: asm.Label, failure: asm.Label): Unit = { /* True if the equality comparison is between values that require the use of the rich equality * comparator (scala.runtime.Comparator.equals). This is the case when either side of the diff --git a/src/dotty/tools/dotc/backend/jvm/BCodeGlue.scala b/src/dotty/tools/dotc/backend/jvm/BCodeGlue.scala index f9386223fa9b..ba0425473e41 100755 --- a/src/dotty/tools/dotc/backend/jvm/BCodeGlue.scala +++ b/src/dotty/tools/dotc/backend/jvm/BCodeGlue.scala @@ -488,7 +488,7 @@ abstract class BCodeGlue { * * can-multi-thread */ - private def getDescriptor(buf: StringBuffer) { + private def getDescriptor(buf: StringBuffer): Unit = { if (isPrimitiveOrVoid) { // descriptor is in byte 3 of 'off' for primitive types (buf == null) buf.append(((off & 0xFF000000) >>> 24).asInstanceOf[Char]) diff --git a/src/dotty/tools/dotc/backend/jvm/BCodeHelpers.scala b/src/dotty/tools/dotc/backend/jvm/BCodeHelpers.scala index 2c88db994936..ed8d5cf150f2 100755 --- a/src/dotty/tools/dotc/backend/jvm/BCodeHelpers.scala +++ b/src/dotty/tools/dotc/backend/jvm/BCodeHelpers.scala @@ -263,7 +263,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters { * * can-multi-thread */ - final def addInnerClassesASM(jclass: asm.ClassVisitor, refedInnerClasses: Iterable[BType]) { + final def addInnerClassesASM(jclass: asm.ClassVisitor, refedInnerClasses: Iterable[BType]): Unit = { // used to detect duplicates. val seen = mutable.Map.empty[String, String] // result without duplicates, not yet sorted. @@ -714,7 +714,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters { * must-single-thread * but not necessarily always. */ - def emitAssocs(av: asm.AnnotationVisitor, assocs: List[(Name, ClassfileAnnotArg)]) { + def emitAssocs(av: asm.AnnotationVisitor, assocs: List[(Name, ClassfileAnnotArg)]): Unit = { for ((name, value) <- assocs) { emitArgument(av, name.toString(), value) } @@ -724,7 +724,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters { /* * must-single-thread */ - def emitAnnotations(cw: asm.ClassVisitor, annotations: List[AnnotationInfo]) { + def emitAnnotations(cw: asm.ClassVisitor, annotations: List[AnnotationInfo]): Unit = { for(annot <- annotations; if shouldEmitAnnotation(annot)) { val AnnotationInfo(typ, args, assocs) = annot assert(args.isEmpty, args) @@ -736,7 +736,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters { /* * must-single-thread */ - def emitAnnotations(mw: asm.MethodVisitor, annotations: List[AnnotationInfo]) { + def emitAnnotations(mw: asm.MethodVisitor, annotations: List[AnnotationInfo]): Unit = { for(annot <- annotations; if shouldEmitAnnotation(annot)) { val AnnotationInfo(typ, args, assocs) = annot assert(args.isEmpty, args) @@ -748,7 +748,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters { /* * must-single-thread */ - def emitAnnotations(fw: asm.FieldVisitor, annotations: List[AnnotationInfo]) { + def emitAnnotations(fw: asm.FieldVisitor, annotations: List[AnnotationInfo]): Unit = { for(annot <- annotations; if shouldEmitAnnotation(annot)) { val AnnotationInfo(typ, args, assocs) = annot assert(args.isEmpty, args) @@ -760,7 +760,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters { /* * must-single-thread */ - def emitParamAnnotations(jmethod: asm.MethodVisitor, pannotss: List[List[AnnotationInfo]]) { + def emitParamAnnotations(jmethod: asm.MethodVisitor, pannotss: List[List[AnnotationInfo]]): Unit = { val annotationss = pannotss map (_ filter shouldEmitAnnotation) if (annotationss forall (_.isEmpty)) return for ((annots, idx) <- annotationss.zipWithIndex; @@ -876,7 +876,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters { * * must-single-thread */ - def addRemoteExceptionAnnot(isRemoteClass: Boolean, isJMethodPublic: Boolean, meth: Symbol) { + def addRemoteExceptionAnnot(isRemoteClass: Boolean, isJMethodPublic: Boolean, meth: Symbol): Unit = { val needsAnnotation = ( ( isRemoteClass || isRemote(meth) && isJMethodPublic @@ -893,7 +893,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters { * * must-single-thread */ - private def addForwarder(isRemoteClass: Boolean, jclass: asm.ClassVisitor, module: Symbol, m: Symbol) { + private def addForwarder(isRemoteClass: Boolean, jclass: asm.ClassVisitor, module: Symbol, m: Symbol): Unit = { val moduleName = internalName(module) val methodInfo = module.thisType.memberInfo(m) val paramJavaTypes: List[BType] = methodInfo.paramTypes map toTypeKind @@ -955,7 +955,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters { * * must-single-thread */ - def addForwarders(isRemoteClass: Boolean, jclass: asm.ClassVisitor, jclassName: String, moduleClass: Symbol) { + def addForwarders(isRemoteClass: Boolean, jclass: asm.ClassVisitor, jclassName: String, moduleClass: Symbol): Unit = { assert(moduleClass.isModuleClass, moduleClass) debuglog(s"Dumping mirror class for object: $moduleClass") @@ -1015,7 +1015,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters { * * can-multi-thread */ - def addSerialVUID(id: Long, jclass: asm.ClassVisitor) { + def addSerialVUID(id: Long, jclass: asm.ClassVisitor): Unit = { // add static serialVersionUID field if `clasz` annotated with `@SerialVersionUID(uid: Long)` jclass.visitField( PublicStaticFinal, @@ -1215,7 +1215,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters { Array(exemplar(definitions.ClassClass).c, stringArrayJType, stringArrayJType) ) - def push(lst: List[String]) { + def push(lst: List[String]): Unit = { var fi = 0 for (f <- lst) { constructor.visitInsn(asm.Opcodes.DUP) @@ -1281,7 +1281,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters { /* * must-single-thread */ - def legacyAddCreatorCode(clinit: asm.MethodVisitor, cnode: asm.tree.ClassNode, thisName: String) { + def legacyAddCreatorCode(clinit: asm.MethodVisitor, cnode: asm.tree.ClassNode, thisName: String): Unit = { // this tracks the inner class in innerClassBufferASM, if needed. val androidCreatorType = asmClassType(AndroidCreatorClass) val tdesc_creator = androidCreatorType.getDescriptor diff --git a/src/dotty/tools/dotc/backend/jvm/BCodeIdiomatic.scala b/src/dotty/tools/dotc/backend/jvm/BCodeIdiomatic.scala index fb1c7da4b5ee..393a64ec76e9 100755 --- a/src/dotty/tools/dotc/backend/jvm/BCodeIdiomatic.scala +++ b/src/dotty/tools/dotc/backend/jvm/BCodeIdiomatic.scala @@ -133,12 +133,12 @@ abstract class BCodeIdiomatic extends BCodeGlue { import asm.Opcodes; import icodes.opcodes.{ Static, Dynamic, SuperCall } - final def emit(opc: Int) { jmethod.visitInsn(opc) } + final def emit(opc: Int): Unit = { jmethod.visitInsn(opc) } /* * can-multi-thread */ - final def genPrimitiveArithmetic(op: icodes.ArithmeticOp, kind: BType) { + final def genPrimitiveArithmetic(op: icodes.ArithmeticOp, kind: BType): Unit = { import icodes.{ ADD, SUB, MUL, DIV, REM, NOT } @@ -170,7 +170,7 @@ abstract class BCodeIdiomatic extends BCodeGlue { /* * can-multi-thread */ - final def genPrimitiveLogical(op: /* LogicalOp */ Int, kind: BType) { + final def genPrimitiveLogical(op: /* LogicalOp */ Int, kind: BType): Unit = { import scalaPrimitives.{ AND, OR, XOR } @@ -199,7 +199,7 @@ abstract class BCodeIdiomatic extends BCodeGlue { /* * can-multi-thread */ - final def genPrimitiveShift(op: /* ShiftOp */ Int, kind: BType) { + final def genPrimitiveShift(op: /* ShiftOp */ Int, kind: BType): Unit = { import scalaPrimitives.{ LSL, ASR, LSR } @@ -241,7 +241,7 @@ abstract class BCodeIdiomatic extends BCodeGlue { /* * can-multi-thread */ - final def genStringConcat(el: BType) { + final def genStringConcat(el: BType): Unit = { val jtype = if (el.isArray || el.hasObjectSort) JAVA_LANG_OBJECT @@ -267,14 +267,14 @@ abstract class BCodeIdiomatic extends BCodeGlue { * * can-multi-thread */ - final def emitT2T(from: BType, to: BType) { + final def emitT2T(from: BType, to: BType): Unit = { assert( from.isNonUnitValueType && to.isNonUnitValueType, s"Cannot emit primitive conversion from $from to $to" ) - def pickOne(opcs: Array[Int]) { // TODO index on to.sort + def pickOne(opcs: Array[Int]): Unit = { // TODO index on to.sort val chosen = (to: @unchecked) match { case BYTE => opcs(0) case SHORT => opcs(1) @@ -328,10 +328,10 @@ abstract class BCodeIdiomatic extends BCodeGlue { } // end of emitT2T() // can-multi-thread - final def boolconst(b: Boolean) { iconst(if (b) 1 else 0) } + final def boolconst(b: Boolean): Unit = { iconst(if (b) 1 else 0) } // can-multi-thread - final def iconst(cst: Int) { + final def iconst(cst: Int): Unit = { if (cst >= -1 && cst <= 5) { emit(Opcodes.ICONST_0 + cst) } else if (cst >= java.lang.Byte.MIN_VALUE && cst <= java.lang.Byte.MAX_VALUE) { @@ -344,7 +344,7 @@ abstract class BCodeIdiomatic extends BCodeGlue { } // can-multi-thread - final def lconst(cst: Long) { + final def lconst(cst: Long): Unit = { if (cst == 0L || cst == 1L) { emit(Opcodes.LCONST_0 + cst.asInstanceOf[Int]) } else { @@ -353,7 +353,7 @@ abstract class BCodeIdiomatic extends BCodeGlue { } // can-multi-thread - final def fconst(cst: Float) { + final def fconst(cst: Float): Unit = { val bits: Int = java.lang.Float.floatToIntBits(cst) if (bits == 0L || bits == 0x3f800000 || bits == 0x40000000) { // 0..2 emit(Opcodes.FCONST_0 + cst.asInstanceOf[Int]) @@ -363,7 +363,7 @@ abstract class BCodeIdiomatic extends BCodeGlue { } // can-multi-thread - final def dconst(cst: Double) { + final def dconst(cst: Double): Unit = { val bits: Long = java.lang.Double.doubleToLongBits(cst) if (bits == 0L || bits == 0x3ff0000000000000L) { // +0.0d and 1.0d emit(Opcodes.DCONST_0 + cst.asInstanceOf[Int]) @@ -373,7 +373,7 @@ abstract class BCodeIdiomatic extends BCodeGlue { } // can-multi-thread - final def newarray(elem: BType) { + final def newarray(elem: BType): Unit = { if (elem.isRefOrArrayType || elem.isPhantomType ) { /* phantom type at play in `Array(null)`, SI-1513. On the other hand, Array(()) has element type `scala.runtime.BoxedUnit` which hasObjectSort. */ jmethod.visitTypeInsn(Opcodes.ANEWARRAY, elem.getInternalName) @@ -396,55 +396,55 @@ abstract class BCodeIdiomatic extends BCodeGlue { } - final def load( idx: Int, tk: BType) { emitVarInsn(Opcodes.ILOAD, idx, tk) } // can-multi-thread - final def store(idx: Int, tk: BType) { emitVarInsn(Opcodes.ISTORE, idx, tk) } // can-multi-thread + final def load( idx: Int, tk: BType): Unit = { emitVarInsn(Opcodes.ILOAD, idx, tk) } // can-multi-thread + final def store(idx: Int, tk: BType): Unit = { emitVarInsn(Opcodes.ISTORE, idx, tk) } // can-multi-thread - final def aload( tk: BType) { emitTypeBased(JCodeMethodN.aloadOpcodes, tk) } // can-multi-thread - final def astore(tk: BType) { emitTypeBased(JCodeMethodN.astoreOpcodes, tk) } // can-multi-thread + final def aload( tk: BType): Unit = { emitTypeBased(JCodeMethodN.aloadOpcodes, tk) } // can-multi-thread + final def astore(tk: BType): Unit = { emitTypeBased(JCodeMethodN.astoreOpcodes, tk) } // can-multi-thread - final def neg(tk: BType) { emitPrimitive(JCodeMethodN.negOpcodes, tk) } // can-multi-thread - final def add(tk: BType) { emitPrimitive(JCodeMethodN.addOpcodes, tk) } // can-multi-thread - final def sub(tk: BType) { emitPrimitive(JCodeMethodN.subOpcodes, tk) } // can-multi-thread - final def mul(tk: BType) { emitPrimitive(JCodeMethodN.mulOpcodes, tk) } // can-multi-thread - final def div(tk: BType) { emitPrimitive(JCodeMethodN.divOpcodes, tk) } // can-multi-thread - final def rem(tk: BType) { emitPrimitive(JCodeMethodN.remOpcodes, tk) } // can-multi-thread + final def neg(tk: BType): Unit = { emitPrimitive(JCodeMethodN.negOpcodes, tk) } // can-multi-thread + final def add(tk: BType): Unit = { emitPrimitive(JCodeMethodN.addOpcodes, tk) } // can-multi-thread + final def sub(tk: BType): Unit = { emitPrimitive(JCodeMethodN.subOpcodes, tk) } // can-multi-thread + final def mul(tk: BType): Unit = { emitPrimitive(JCodeMethodN.mulOpcodes, tk) } // can-multi-thread + final def div(tk: BType): Unit = { emitPrimitive(JCodeMethodN.divOpcodes, tk) } // can-multi-thread + final def rem(tk: BType): Unit = { emitPrimitive(JCodeMethodN.remOpcodes, tk) } // can-multi-thread // can-multi-thread - final def invokespecial(owner: String, name: String, desc: String) { + final def invokespecial(owner: String, name: String, desc: String): Unit = { jmethod.visitMethodInsn(Opcodes.INVOKESPECIAL, owner, name, desc) } // can-multi-thread - final def invokestatic(owner: String, name: String, desc: String) { + final def invokestatic(owner: String, name: String, desc: String): Unit = { jmethod.visitMethodInsn(Opcodes.INVOKESTATIC, owner, name, desc) } // can-multi-thread - final def invokeinterface(owner: String, name: String, desc: String) { + final def invokeinterface(owner: String, name: String, desc: String): Unit = { jmethod.visitMethodInsn(Opcodes.INVOKEINTERFACE, owner, name, desc) } // can-multi-thread - final def invokevirtual(owner: String, name: String, desc: String) { + final def invokevirtual(owner: String, name: String, desc: String): Unit = { jmethod.visitMethodInsn(Opcodes.INVOKEVIRTUAL, owner, name, desc) } // can-multi-thread - final def goTo(label: asm.Label) { jmethod.visitJumpInsn(Opcodes.GOTO, label) } + final def goTo(label: asm.Label): Unit = { jmethod.visitJumpInsn(Opcodes.GOTO, label) } // can-multi-thread - final def emitIF(cond: icodes.TestOp, label: asm.Label) { jmethod.visitJumpInsn(cond.opcodeIF, label) } + final def emitIF(cond: icodes.TestOp, label: asm.Label): Unit = { jmethod.visitJumpInsn(cond.opcodeIF, label) } // can-multi-thread - final def emitIF_ICMP(cond: icodes.TestOp, label: asm.Label) { jmethod.visitJumpInsn(cond.opcodeIFICMP, label) } + final def emitIF_ICMP(cond: icodes.TestOp, label: asm.Label): Unit = { jmethod.visitJumpInsn(cond.opcodeIFICMP, label) } // can-multi-thread - final def emitIF_ACMP(cond: icodes.TestOp, label: asm.Label) { + final def emitIF_ACMP(cond: icodes.TestOp, label: asm.Label): Unit = { assert((cond == icodes.EQ) || (cond == icodes.NE), cond) val opc = (if (cond == icodes.EQ) Opcodes.IF_ACMPEQ else Opcodes.IF_ACMPNE) jmethod.visitJumpInsn(opc, label) } // can-multi-thread - final def emitIFNONNULL(label: asm.Label) { jmethod.visitJumpInsn(Opcodes.IFNONNULL, label) } + final def emitIFNONNULL(label: asm.Label): Unit = { jmethod.visitJumpInsn(Opcodes.IFNONNULL, label) } // can-multi-thread - final def emitIFNULL (label: asm.Label) { jmethod.visitJumpInsn(Opcodes.IFNULL, label) } + final def emitIFNULL (label: asm.Label): Unit = { jmethod.visitJumpInsn(Opcodes.IFNULL, label) } // can-multi-thread - final def emitRETURN(tk: BType) { + final def emitRETURN(tk: BType): Unit = { if (tk == UNIT) { emit(Opcodes.RETURN) } else { emitTypeBased(JCodeMethodN.returnOpcodes, tk) } } @@ -453,7 +453,7 @@ abstract class BCodeIdiomatic extends BCodeGlue { * * can-multi-thread */ - final def emitSWITCH(keys: Array[Int], branches: Array[asm.Label], defaultBranch: asm.Label, minDensity: Double) { + final def emitSWITCH(keys: Array[Int], branches: Array[asm.Label], defaultBranch: asm.Label, minDensity: Double): Unit = { assert(keys.length == branches.length) // For empty keys, it makes sense emitting LOOKUPSWITCH with defaultBranch only. @@ -529,7 +529,7 @@ abstract class BCodeIdiomatic extends BCodeGlue { // don't make private otherwise inlining will suffer // can-multi-thread - final def emitVarInsn(opc: Int, idx: Int, tk: BType) { + final def emitVarInsn(opc: Int, idx: Int, tk: BType): Unit = { assert((opc == Opcodes.ILOAD) || (opc == Opcodes.ISTORE), opc) jmethod.visitVarInsn(tk.getOpcode(opc), idx) } @@ -537,7 +537,7 @@ abstract class BCodeIdiomatic extends BCodeGlue { // ---------------- array load and store ---------------- // can-multi-thread - final def emitTypeBased(opcs: Array[Int], tk: BType) { + final def emitTypeBased(opcs: Array[Int], tk: BType): Unit = { assert(tk != UNIT, tk) val opc = { if (tk.isRefOrArrayType) { opcs(0) } @@ -562,7 +562,7 @@ abstract class BCodeIdiomatic extends BCodeGlue { // ---------------- primitive operations ---------------- // can-multi-thread - final def emitPrimitive(opcs: Array[Int], tk: BType) { + final def emitPrimitive(opcs: Array[Int], tk: BType): Unit = { val opc = { // using `asm.Type.SHORT` instead of `BType.SHORT` because otherwise "warning: could not emit switch for @switch annotated match" (tk.sort: @switch) match { @@ -576,7 +576,7 @@ abstract class BCodeIdiomatic extends BCodeGlue { } // can-multi-thread - final def drop(tk: BType) { emit(if (tk.isWideType) Opcodes.POP2 else Opcodes.POP) } + final def drop(tk: BType): Unit = { emit(if (tk.isWideType) Opcodes.POP2 else Opcodes.POP) } // can-multi-thread final def dup(tk: BType) { emit(if (tk.isWideType) Opcodes.DUP2 else Opcodes.DUP) } @@ -584,12 +584,12 @@ abstract class BCodeIdiomatic extends BCodeGlue { // ---------------- type checks and casts ---------------- // can-multi-thread - final def isInstance(tk: BType) { + final def isInstance(tk: BType): Unit = { jmethod.visitTypeInsn(Opcodes.INSTANCEOF, tk.getInternalName) } // can-multi-thread - final def checkCast(tk: BType) { + final def checkCast(tk: BType): Unit = { assert(tk.isRefOrArrayType, s"checkcast on primitive type: $tk") // TODO ICode also requires: but that's too much, right? assert(!isBoxedType(tk), "checkcast on boxed type: " + tk) jmethod.visitTypeInsn(Opcodes.CHECKCAST, tk.getInternalName) @@ -679,12 +679,12 @@ abstract class BCodeIdiomatic extends BCodeGlue { } implicit class InsnIterMethodNode(mnode: asm.tree.MethodNode) { - @inline final def foreachInsn(f: (asm.tree.AbstractInsnNode) => Unit) { mnode.instructions.foreachInsn(f) } + @inline final def foreachInsn(f: (asm.tree.AbstractInsnNode) => Unit): Unit = { mnode.instructions.foreachInsn(f) } } implicit class InsnIterInsnList(lst: asm.tree.InsnList) { - @inline final def foreachInsn(f: (asm.tree.AbstractInsnNode) => Unit) { + @inline final def foreachInsn(f: (asm.tree.AbstractInsnNode) => Unit): Unit = { val insnIter = lst.iterator() while (insnIter.hasNext) { f(insnIter.next()) diff --git a/src/dotty/tools/dotc/backend/jvm/BCodeSkelBuilder.scala b/src/dotty/tools/dotc/backend/jvm/BCodeSkelBuilder.scala index dfb9de2d40e9..b27e6a93ff00 100755 --- a/src/dotty/tools/dotc/backend/jvm/BCodeSkelBuilder.scala +++ b/src/dotty/tools/dotc/backend/jvm/BCodeSkelBuilder.scala @@ -87,7 +87,7 @@ abstract class BCodeSkelBuilder extends BCodeHelpers { /* ---------------- helper utils for generating classes and fiels ---------------- */ - def genPlainClass(cd: TypeDef) { + def genPlainClass(cd: TypeDef): Unit = { assert(cnode == null, "GenBCode detected nested methods.") innerClassBufferASM.clear() @@ -125,7 +125,7 @@ abstract class BCodeSkelBuilder extends BCodeHelpers { /* * must-single-thread */ - private def initJClass(jclass: asm.ClassVisitor) { + private def initJClass(jclass: asm.ClassVisitor): Unit = { val ps = claszSymbol.info.parents val superClass: String = if (ps.isEmpty) JAVA_LANG_OBJECT.getInternalName else internalName(ps.head.typeSymbol); @@ -199,7 +199,7 @@ abstract class BCodeSkelBuilder extends BCodeHelpers { /* * can-multi-thread */ - private def addModuleInstanceField() { + private def addModuleInstanceField(): Unit = { val fv = cnode.visitField(PublicStaticFinal, // TODO confirm whether we really don't want ACC_SYNTHETIC nor ACC_DEPRECATED strMODULE_INSTANCE_FIELD, @@ -214,7 +214,7 @@ abstract class BCodeSkelBuilder extends BCodeHelpers { /* * must-single-thread */ - private def fabricateStaticInit() { + private def fabricateStaticInit(): Unit = { val clinit: asm.MethodVisitor = cnode.visitMethod( PublicStatic, // TODO confirm whether we really don't want ACC_SYNTHETIC nor ACC_DEPRECATED @@ -238,7 +238,7 @@ abstract class BCodeSkelBuilder extends BCodeHelpers { clinit.visitEnd() } - def addClassFields() { + def addClassFields(): Unit = { /* Non-method term members are fields, except for module members. Module * members can only happen on .NET (no flatten) for inner traits. There, * a module symbol is generated (transformInfo in mixin) which is used @@ -336,10 +336,10 @@ abstract class BCodeSkelBuilder extends BCodeHelpers { * emitted for that purpose as described in `genLoadTry()` and `genSynchronized()`. */ var cleanups: List[asm.Label] = Nil - def registerCleanup(finCleanup: asm.Label) { + def registerCleanup(finCleanup: asm.Label): Unit = { if (finCleanup != null) { cleanups = finCleanup :: cleanups } } - def unregisterCleanup(finCleanup: asm.Label) { + def unregisterCleanup(finCleanup: asm.Label): Unit = { if (finCleanup != null) { assert(cleanups.head eq finCleanup, s"Bad nesting of cleanup operations: $cleanups trying to unregister: $finCleanup") @@ -360,7 +360,7 @@ abstract class BCodeSkelBuilder extends BCodeHelpers { private var nxtIdx = -1 // next available index for local-var - def reset(isStaticMethod: Boolean) { + def reset(isStaticMethod: Boolean): Unit = { slots.clear() nxtIdx = if (isStaticMethod) 0 else 1 } @@ -398,12 +398,12 @@ abstract class BCodeSkelBuilder extends BCodeHelpers { } // not to be confused with `fieldStore` and `fieldLoad` which also take a symbol but a field-symbol. - def store(locSym: Symbol) { + def store(locSym: Symbol): Unit = { val Local(tk, _, idx, _) = slots(locSym) bc.store(idx, tk) } - def load(locSym: Symbol) { + def load(locSym: Symbol): Unit = { val Local(tk, _, idx, _) = slots(locSym) bc.load(idx, tk) } @@ -452,14 +452,14 @@ abstract class BCodeSkelBuilder extends BCodeHelpers { pp } } - def markProgramPoint(lbl: asm.Label) { + def markProgramPoint(lbl: asm.Label): Unit = { val skip = (lbl == null) || isAtProgramPoint(lbl) if (!skip) { mnode visitLabel lbl } } def isAtProgramPoint(lbl: asm.Label): Boolean = { (lastInsn match { case labnode: asm.tree.LabelNode => (labnode.getLabel == lbl); case _ => false } ) } - def lineNumber(tree: Tree) { + def lineNumber(tree: Tree): Unit = { if (!emitLines || !tree.pos.isDefined) return; val nr = tree.pos.finalPosition.line if (nr != lastEmittedLineNr) { @@ -475,7 +475,7 @@ abstract class BCodeSkelBuilder extends BCodeHelpers { } // on entering a method - def resetMethodBookkeeping(dd: DefDef) { + def resetMethodBookkeeping(dd: DefDef): Unit = { locals.reset(isStaticMethod = methSymbol.isStaticMember) jumpDest = immutable.Map.empty[ /* LabelDef */ Symbol, asm.Label ] // populate labelDefsAtOrUnder @@ -496,7 +496,7 @@ abstract class BCodeSkelBuilder extends BCodeHelpers { /* ---------------- top-down traversal invoking ASM Tree API along the way ---------------- */ - def gen(tree: Tree) { + def gen(tree: Tree): Unit = { tree match { case EmptyTree => () @@ -515,7 +515,7 @@ abstract class BCodeSkelBuilder extends BCodeHelpers { /* * must-single-thread */ - def initJMethod(flags: Int, paramAnnotations: List[List[AnnotationInfo]]) { + def initJMethod(flags: Int, paramAnnotations: List[List[AnnotationInfo]]): Unit = { val jgensig = getGenericSignature(methSymbol, claszSymbol) addRemoteExceptionAnnot(isCZRemote, hasPublicBitSet(flags), methSymbol) @@ -543,7 +543,7 @@ abstract class BCodeSkelBuilder extends BCodeHelpers { } // end of method initJMethod - def genDefDef(dd: DefDef) { + def genDefDef(dd: DefDef): Unit = { // the only method whose implementation is not emitted: getClass() if (definitions.isGetClass(dd.symbol)) { return } assert(mnode == null, "GenBCode detected nested method.") @@ -599,7 +599,7 @@ abstract class BCodeSkelBuilder extends BCodeHelpers { if (!isAbstractMethod && !isNative) { - def emitNormalMethodBody() { + def emitNormalMethodBody(): Unit = { val veryFirstProgramPoint = currProgramPoint() genLoad(rhs, returnType) @@ -648,7 +648,7 @@ abstract class BCodeSkelBuilder extends BCodeHelpers { * * TODO document, explain interplay with `fabricateStaticInit()` */ - private def appendToStaticCtor(dd: DefDef) { + private def appendToStaticCtor(dd: DefDef): Unit = { def insertBefore( location: asm.tree.AbstractInsnNode, @@ -711,7 +711,7 @@ abstract class BCodeSkelBuilder extends BCodeHelpers { } - def emitLocalVarScope(sym: Symbol, start: asm.Label, end: asm.Label, force: Boolean = false) { + def emitLocalVarScope(sym: Symbol, start: asm.Label, end: asm.Label, force: Boolean = false): Unit = { val Local(tk, name, idx, isSynth) = locals(sym) if (force || !isSynth) { mnode.visitLocalVariable(name, tk.getDescriptor, null, start, end, idx) diff --git a/src/dotty/tools/dotc/backend/jvm/BCodeSyncAndTry.scala b/src/dotty/tools/dotc/backend/jvm/BCodeSyncAndTry.scala index 700dac0673ba..8a12d0f149df 100755 --- a/src/dotty/tools/dotc/backend/jvm/BCodeSyncAndTry.scala +++ b/src/dotty/tools/dotc/backend/jvm/BCodeSyncAndTry.scala @@ -115,7 +115,7 @@ abstract class BCodeSyncAndTry extends BCodeBodyBuilder { * Useful to avoid emitting an empty try-block being protected by exception handlers, * which results in "java.lang.ClassFormatError: Illegal exception table range". See SI-6102. */ - def nopIfNeeded(lbl: asm.Label) { + def nopIfNeeded(lbl: asm.Label): Unit = { val noInstructionEmitted = isAtProgramPoint(lbl) if (noInstructionEmitted) { emit(asm.Opcodes.NOP) } } @@ -348,7 +348,7 @@ abstract class BCodeSyncAndTry extends BCodeBodyBuilder { } // end of genLoadTry() /* if no more pending cleanups, all that remains to do is return. Otherwise jump to the next (outer) pending cleanup. */ - private def pendingCleanups() { + private def pendingCleanups(): Unit = { cleanups match { case Nil => if (earlyReturnVar != null) { @@ -364,7 +364,7 @@ abstract class BCodeSyncAndTry extends BCodeBodyBuilder { } } - def protect(start: asm.Label, end: asm.Label, handler: asm.Label, excType: BType) { + def protect(start: asm.Label, end: asm.Label, handler: asm.Label, excType: BType): Unit = { val excInternalName: String = if (excType == null) null else excType.getInternalName @@ -373,7 +373,7 @@ abstract class BCodeSyncAndTry extends BCodeBodyBuilder { } /* `tmp` (if non-null) is the symbol of the local-var used to preserve the result of the try-body, see `guardResult` */ - def emitFinalizer(finalizer: Tree, tmp: Symbol, isDuplicate: Boolean) { + def emitFinalizer(finalizer: Tree, tmp: Symbol, isDuplicate: Boolean): Unit = { var saved: immutable.Map[ /* LabelDef */ Symbol, asm.Label ] = null if (isDuplicate) { saved = jumpDest diff --git a/src/dotty/tools/dotc/backend/jvm/BCodeTypes.scala b/src/dotty/tools/dotc/backend/jvm/BCodeTypes.scala index 1f7edd9ec996..bf95c5c95144 100755 --- a/src/dotty/tools/dotc/backend/jvm/BCodeTypes.scala +++ b/src/dotty/tools/dotc/backend/jvm/BCodeTypes.scala @@ -78,7 +78,7 @@ abstract class BCodeTypes extends BCodeIdiomatic { /* * must-single-thread */ - def initBCodeTypes(implicit ctx: core.Contexts.Context) { + def initBCodeTypes(implicit ctx: core.Contexts.Context): Unit = { import core.Symbols.defn @@ -193,7 +193,7 @@ abstract class BCodeTypes extends BCodeIdiomatic { /* * must-single-thread */ - def clearBCodeTypes() { + def clearBCodeTypes(): Unit = { symExemplars.clear() exemplars.clear() } @@ -237,7 +237,7 @@ abstract class BCodeTypes extends BCodeIdiomatic { _directMemberClasses } - def directMemberClasses_=(bs: List[BType]) { + def directMemberClasses_=(bs: List[BType]): Unit = { if (_directMemberClasses != null) { // TODO we enter here when both mirror class and plain class are emitted for the same ModuleClassSymbol. assert(_directMemberClasses == bs.sortBy(_.off)) @@ -481,7 +481,7 @@ abstract class BCodeTypes extends BCodeIdiomatic { def allInterfaces(is: Iterable[Tracked]): Boolean = { is forall { i => i.isInterface } } def nonInterfaces(is: Iterable[Tracked]): Iterable[Tracked] = { is filterNot { i => i.isInterface } } - def checkAllInterfaces(ifaces: Iterable[Tracked]) { + def checkAllInterfaces(ifaces: Iterable[Tracked]): Unit = { assert(allInterfaces(ifaces), s"Non-interfaces: ${nonInterfaces(ifaces).mkString}") } diff --git a/src/dotty/tools/dotc/backend/jvm/BytecodeWriters.scala b/src/dotty/tools/dotc/backend/jvm/BytecodeWriters.scala index b414f6949509..f71e511d5303 100755 --- a/src/dotty/tools/dotc/backend/jvm/BytecodeWriters.scala +++ b/src/dotty/tools/dotc/backend/jvm/BytecodeWriters.scala @@ -62,7 +62,7 @@ trait BytecodeWriters { ) val writer = new Jar(jfile).jarWriter(jarMainAttrs: _*) - def writeClass(label: String, jclassName: String, jclassBytes: Array[Byte], outfile: AbstractFile) { + def writeClass(label: String, jclassName: String, jclassBytes: Array[Byte], outfile: AbstractFile): Unit = { assert(outfile == null, "The outfile formal param is there just because ClassBytecodeWriter overrides this method and uses it.") val path = jclassName + ".class" @@ -89,7 +89,7 @@ trait BytecodeWriters { private val baseDir = Directory(settings.Ygenasmp.value).createDirectory() - private def emitAsmp(jclassBytes: Array[Byte], asmpFile: io.File) { + private def emitAsmp(jclassBytes: Array[Byte], asmpFile: io.File): Unit = { val pw = asmpFile.printWriter() try { val cnode = new asm.tree.ClassNode() @@ -102,7 +102,7 @@ trait BytecodeWriters { finally pw.close() } - abstract override def writeClass(label: String, jclassName: String, jclassBytes: Array[Byte], outfile: AbstractFile) { + abstract override def writeClass(label: String, jclassName: String, jclassBytes: Array[Byte], outfile: AbstractFile): Unit = { super.writeClass(label, jclassName, jclassBytes, outfile) val segments = jclassName.split("[./]") @@ -114,7 +114,7 @@ trait BytecodeWriters { } trait ClassBytecodeWriter extends BytecodeWriter { - def writeClass(label: String, jclassName: String, jclassBytes: Array[Byte], outfile: AbstractFile) { + def writeClass(label: String, jclassName: String, jclassBytes: Array[Byte], outfile: AbstractFile): Unit = { assert(outfile != null, "Precisely this override requires its invoker to hand out a non-null AbstractFile.") val outstream = new DataOutputStream(outfile.bufferedOutput) @@ -128,7 +128,7 @@ trait BytecodeWriters { trait DumpBytecodeWriter extends BytecodeWriter { val baseDir = Directory(settings.Ydumpclasses.value).createDirectory() - abstract override def writeClass(label: String, jclassName: String, jclassBytes: Array[Byte], outfile: AbstractFile) { + abstract override def writeClass(label: String, jclassName: String, jclassBytes: Array[Byte], outfile: AbstractFile): Unit = { super.writeClass(label, jclassName, jclassBytes, outfile) val pathName = jclassName diff --git a/src/dotty/tools/dotc/backend/jvm/GenBCode.scala b/src/dotty/tools/dotc/backend/jvm/GenBCode.scala index d52abbc5c748..03fecd0998f0 100755 --- a/src/dotty/tools/dotc/backend/jvm/GenBCode.scala +++ b/src/dotty/tools/dotc/backend/jvm/GenBCode.scala @@ -123,7 +123,7 @@ object GenBCode extends BCodeSyncAndTry { val caseInsensitively = mutable.Map.empty[String, Symbol] - def run() { + def run(): Unit = { while (true) { val item = q1.poll if (item.isPoison) { @@ -147,7 +147,7 @@ object GenBCode extends BCodeSyncAndTry { * enqueues them in queue-2. * */ - def visit(item: Item1) { + def visit(item: Item1): Unit = { val Item1(arrivalPos, cd, cunit) = item val claszSymbol = cd.symbol @@ -212,7 +212,7 @@ object GenBCode extends BCodeSyncAndTry { */ class Worker2 { - def run() { + def run(): Unit = { while (true) { val item = q2.poll if (item.isPoison) { @@ -230,7 +230,7 @@ object GenBCode extends BCodeSyncAndTry { } } - private def addToQ3(item: Item2) { + private def addToQ3(item: Item2): Unit = { def getByteArray(cn: asm.tree.ClassNode): Array[Byte] = { val cw = new CClassWriter(extraProc) @@ -318,15 +318,15 @@ object GenBCode extends BCodeSyncAndTry { } /* Feed pipeline-1: place all ClassDefs on q1, recording their arrival position. */ - private def feedPipeline1(units: List[CompilationUnit]) { + private def feedPipeline1(units: List[CompilationUnit]): Unit = { units forech apply q1 add poison1 } /* Pipeline that writes classfile representations to disk. */ - private def drainQ3() { + private def drainQ3(): Unit = { - def sendToDisk(cfr: SubItem3, outFolder: scala.tools.nsc.io.AbstractFile) { + def sendToDisk(cfr: SubItem3, outFolder: scala.tools.nsc.io.AbstractFile): Unit = { if (cfr != null){ val SubItem3(jclassName, jclassBytes) = cfr try { @@ -368,7 +368,7 @@ object GenBCode extends BCodeSyncAndTry { override def apply(cunit: CompilationUnit): Unit = { - def gen(tree: Trees.Tree) { + def gen(tree: Trees.Tree): Unit = { import Trees.{PackageDef, TypeDef} diff --git a/src/dotty/tools/dotc/backend/jvm/scalaPrimitives.scala b/src/dotty/tools/dotc/backend/jvm/scalaPrimitives.scala index 63448aabb648..c4ef47b88429 100755 --- a/src/dotty/tools/dotc/backend/jvm/scalaPrimitives.scala +++ b/src/dotty/tools/dotc/backend/jvm/scalaPrimitives.scala @@ -195,7 +195,7 @@ object scalaPrimitives { } /** Initialize the primitive map */ - def init(implicit ctx: core.Contexts.Context) { + def init(implicit ctx: core.Contexts.Context): Unit = { import core.Symbols.defn @@ -452,12 +452,12 @@ object scalaPrimitives { } /** Add a primitive operation to the map */ - def addPrimitive(s: Symbol, code: Int) { + def addPrimitive(s: Symbol, code: Int): Unit = { assert(!(primitives contains s), "Duplicate primitive " + s) primitives(s) = code } - def addPrimitives(cls: Symbol, method: dotc.core.Names.TermName, code: Int) { + def addPrimitives(cls: Symbol, method: dotc.core.Names.TermName, code: Int): Unit = { val alts = (cls.info member method).alternatives if (alts.isEmpty) inform(s"Unknown primitive method $cls.$method") From f5d03f2c7c3e8372793fecab748ed3ea4cf4f27e Mon Sep 17 00:00:00 2001 From: Miguel Garcia Date: Thu, 13 Feb 2014 14:40:56 +0100 Subject: [PATCH 8/8] more passing context around --- src/dotty/tools/dotc/backend/jvm/BCodeHelpers.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/dotty/tools/dotc/backend/jvm/BCodeHelpers.scala b/src/dotty/tools/dotc/backend/jvm/BCodeHelpers.scala index ed8d5cf150f2..d8198933efa1 100755 --- a/src/dotty/tools/dotc/backend/jvm/BCodeHelpers.scala +++ b/src/dotty/tools/dotc/backend/jvm/BCodeHelpers.scala @@ -535,7 +535,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters { /* * must-single-thread */ - def asmMethodType(msym: Symbol): BType = { + def asmMethodType(msym: Symbol)(implicit ctx: core.Contexts.Context): BType = { assert(msym is Flags.Method, s"not a method-symbol: $msym") val resT: BType = if (msym.isClassConstructor || msym.isConstructor) BType.VOID_TYPE @@ -550,7 +550,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters { * * must-single-thread */ - final def trackMemberClasses(csym: Symbol, lateClosuresBTs: List[BType]): List[BType] = { + final def trackMemberClasses(csym: Symbol, lateClosuresBTs: List[BType])(implicit ctx: core.Contexts.Context): List[BType] = { val lateInnerClasses = exitingErasure { for (sym <- List(csym, csym.linkedClassOfClass); memberc <- sym.info.decls.map(innerClassSymbolFor) if memberc.isClass) yield memberc @@ -574,14 +574,14 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters { * * must-single-thread */ - final def descriptor(t: Type): String = { toTypeKind(t).getDescriptor } + final def descriptor(t: Type)(implicit ctx: core.Contexts.Context): String = (toTypeKind(t).getDescriptor) /* * Tracks (if needed) the inner class given by `sym`. * * must-single-thread */ - final def descriptor(sym: Symbol): String = { asmClassType(sym).getDescriptor } + final def descriptor(sym: Symbol)(implicit ctx: core.Contexts.Context): String = (asmClassType(sym).getDescriptor) } // end of trait BCInnerClassGen