Skip to content

Commit 71f15c3

Browse files
committed
Convert tools classes
1 parent 68e1fea commit 71f15c3

File tree

11 files changed

+130
-130
lines changed

11 files changed

+130
-130
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ trait BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
844844
}
845845
}
846846

847-
private def getGenericSignatureHelper(sym: Symbol, owner: Symbol, memberTpe: Type)(implicit ctx: Context): Option[String] = {
847+
private def getGenericSignatureHelper(sym: Symbol, owner: Symbol, memberTpe: Type)(using Context): Option[String] = {
848848
if (needsGenericSignature(sym)) {
849849
val erasedTypeSym = TypeErasure.fullErasure(sym.denot.info).typeSymbol
850850
if (erasedTypeSym.isPrimitiveValueClass) {
@@ -864,7 +864,7 @@ trait BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
864864
}
865865
}
866866

867-
private def verifySignature(sym: Symbol, sig: String)(implicit ctx: Context): Unit = {
867+
private def verifySignature(sym: Symbol, sig: String)(using Context): Unit = {
868868
import scala.tools.asm.util.CheckClassAdapter
869869
def wrap(body: => Unit): Unit = {
870870
try body

compiler/src/dotty/tools/backend/jvm/CollectSuperCalls.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package dotty.tools.backend.jvm
22

33
import dotty.tools.dotc.ast.tpd
4-
import dotty.tools.dotc.core.Contexts.Context
4+
import dotty.tools.dotc.core.Contexts.{Context, ctx}
55
import dotty.tools.dotc.core.Symbols._
66
import dotty.tools.dotc.core.Flags.Trait
77
import dotty.tools.dotc.transform.MegaPhase.MiniPhase
@@ -21,7 +21,7 @@ class CollectSuperCalls extends MiniPhase {
2121

2222
def phaseName: String = "collectSuperCalls"
2323

24-
override def transformSelect(tree: Select)(implicit ctx: Context): Tree = {
24+
override def transformSelect(tree: Select)(using Context): Tree = {
2525
tree.qualifier match {
2626
case sup: Super =>
2727
if (tree.symbol.owner.is(Trait))
@@ -31,7 +31,7 @@ class CollectSuperCalls extends MiniPhase {
3131
tree
3232
}
3333

34-
private def registerSuperCall(sym: ClassSymbol, calls: ClassSymbol)(implicit ctx: Context) = {
34+
private def registerSuperCall(sym: ClassSymbol, calls: ClassSymbol)(using Context) = {
3535
ctx.genBCodePhase match {
3636
case genBCodePhase: GenBCode =>
3737
genBCodePhase.registerSuperCall(sym, calls)

compiler/src/dotty/tools/backend/jvm/GenBCode.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,18 @@ class GenBCode extends Phase {
4040

4141
private var myOutput: AbstractFile = _
4242

43-
private def outputDir(implicit ctx: Context): AbstractFile = {
43+
private def outputDir(using Context): AbstractFile = {
4444
if (myOutput eq null)
4545
myOutput = ctx.settings.outputDir.value
4646
myOutput
4747
}
4848

49-
def run(implicit ctx: Context): Unit = {
49+
def run(using Context): Unit = {
5050
new GenBCodePipeline(new DottyBackendInterface(
5151
outputDir, superCallsMap.toMap)(using ctx))(using ctx).run(ctx.compilationUnit.tpdTree)
5252
}
5353

54-
override def runOn(units: List[CompilationUnit])(implicit ctx: Context): List[CompilationUnit] = {
54+
override def runOn(units: List[CompilationUnit])(using Context): List[CompilationUnit] = {
5555
try super.runOn(units)
5656
finally myOutput match {
5757
case jar: JarArchive =>

compiler/src/dotty/tools/backend/sjs/GenSJSIR.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import Phases._
88
class GenSJSIR extends Phase {
99
def phaseName: String = "genSJSIR"
1010

11-
override def isRunnable(implicit ctx: Context): Boolean =
11+
override def isRunnable(using Context): Boolean =
1212
super.isRunnable && ctx.settings.scalajs.value
1313

14-
def run(implicit ctx: Context): Unit =
14+
def run(using Context): Unit =
1515
new JSCodeGen().run()
1616
}

compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ import ScopedVar.withScopedVars
5555
* - `genMethod()` and similar methods generate the declarations of methods.
5656
* - `genStatOrExpr()` and everything else generate the bodies of methods.
5757
*/
58-
class JSCodeGen()(implicit ctx: Context) {
58+
class JSCodeGen()(using genCtx: Context) {
5959
import JSCodeGen._
6060
import tpd._
6161

6262
private val jsdefn = JSDefinitions.jsdefn
63-
private val primitives = new JSPrimitives(ctx)
63+
private val primitives = new JSPrimitives(genCtx)
6464

65-
private val positionConversions = new JSPositions()(using ctx)
65+
private val positionConversions = new JSPositions()(using genCtx)
6666
import positionConversions._
6767

6868
// Some state --------------------------------------------------------------
@@ -2732,7 +2732,7 @@ class JSCodeGen()(implicit ctx: Context) {
27322732
private def genActualJSArgs(sym: Symbol, args: List[Tree])(
27332733
implicit pos: Position): List[js.TreeOrJSSpread] = {
27342734

2735-
def paramNamesAndTypes(implicit ctx: Context): List[(Names.TermName, Type)] =
2735+
def paramNamesAndTypes(using Context): List[(Names.TermName, Type)] =
27362736
sym.info.paramNamess.flatten.zip(sym.info.paramInfoss.flatten)
27372737

27382738
val wereRepeated = ctx.atPhase(ctx.elimRepeatedPhase) {

compiler/src/dotty/tools/backend/sjs/JSDefinitions.scala

Lines changed: 75 additions & 75 deletions
Large diffs are not rendered by default.

compiler/src/dotty/tools/backend/sjs/JSEncoding.scala

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ object JSEncoding {
8888
def freshLocalIdent(base: TermName)(implicit pos: ir.Position): js.LocalIdent =
8989
freshLocalIdent(base.mangledString)
9090

91-
def localSymbolName(sym: Symbol)(implicit ctx: Context): LocalName = {
91+
def localSymbolName(sym: Symbol)(using Context): LocalName = {
9292
localSymbolNames.getOrElseUpdate(sym, {
9393
/* The emitter does not like local variables that start with a '$',
9494
* because it needs to encode them not to clash with emitter-generated
@@ -120,7 +120,7 @@ object JSEncoding {
120120
def freshLabelIdent(base: String)(implicit pos: ir.Position): js.LabelIdent =
121121
js.LabelIdent(freshLabelName(base))
122122

123-
def labelSymbolName(sym: Symbol)(implicit ctx: Context): LabelName =
123+
def labelSymbolName(sym: Symbol)(using Context): LabelName =
124124
labelSymbolNames.getOrElseUpdate(sym, freshLabelName(sym.javaSimpleName))
125125

126126
def getEnclosingReturnLabel()(implicit pos: ir.Position): js.LabelIdent = {
@@ -206,7 +206,7 @@ object JSEncoding {
206206
}
207207

208208
/** Computes the type ref for a type, to be used in a method signature. */
209-
private def paramOrResultTypeRef(tpe: Type)(implicit ctx: Context): jstpe.TypeRef = {
209+
private def paramOrResultTypeRef(tpe: Type)(using Context): jstpe.TypeRef = {
210210
toTypeRef(tpe) match {
211211
case jstpe.ClassRef(ScalaNullClassName) => jstpe.NullRef
212212
case jstpe.ClassRef(ScalaNothingClassName) => jstpe.NothingRef
@@ -221,7 +221,7 @@ object JSEncoding {
221221
js.LocalIdent(localNames.localSymbolName(sym))
222222
}
223223

224-
def encodeClassType(sym: Symbol)(implicit ctx: Context): jstpe.Type = {
224+
def encodeClassType(sym: Symbol)(using Context): jstpe.Type = {
225225
if (sym == defn.ObjectClass) jstpe.AnyType
226226
else if (isJSType(sym)) jstpe.AnyType
227227
else {
@@ -231,14 +231,14 @@ object JSEncoding {
231231
}
232232
}
233233

234-
def encodeClassRef(sym: Symbol)(implicit ctx: Context): jstpe.ClassRef =
234+
def encodeClassRef(sym: Symbol)(using Context): jstpe.ClassRef =
235235
jstpe.ClassRef(encodeClassName(sym))
236236

237237
def encodeClassNameIdent(sym: Symbol)(
238238
implicit ctx: Context, pos: ir.Position): js.ClassIdent =
239239
js.ClassIdent(encodeClassName(sym))
240240

241-
def encodeClassName(sym: Symbol)(implicit ctx: Context): ClassName = {
241+
def encodeClassName(sym: Symbol)(using Context): ClassName = {
242242
val sym1 =
243243
if (sym.isAllOf(ModuleClass | JavaDefined)) sym.linkedClass
244244
else sym
@@ -253,7 +253,7 @@ object JSEncoding {
253253
}
254254
}
255255

256-
def toIRType(tp: Type)(implicit ctx: Context): jstpe.Type = {
256+
def toIRType(tp: Type)(using Context): jstpe.Type = {
257257
val typeRefInternal = toTypeRefInternal(tp)
258258
typeRefInternal._1 match {
259259
case jstpe.PrimRef(irTpe) =>
@@ -275,10 +275,10 @@ object JSEncoding {
275275
}
276276
}
277277

278-
def toTypeRef(tp: Type)(implicit ctx: Context): jstpe.TypeRef =
278+
def toTypeRef(tp: Type)(using Context): jstpe.TypeRef =
279279
toTypeRefInternal(tp)._1
280280

281-
private def toTypeRefInternal(tp: Type)(implicit ctx: Context): (jstpe.TypeRef, Symbol) = {
281+
private def toTypeRefInternal(tp: Type)(using Context): (jstpe.TypeRef, Symbol) = {
282282
def primitiveOrClassToTypeRef(sym: Symbol): (jstpe.TypeRef, Symbol) = {
283283
assert(sym.isClass, sym)
284284
//assert(sym != defn.ArrayClass || isCompilingArray, sym)
@@ -343,7 +343,7 @@ object JSEncoding {
343343
* This method returns `UnitType` for constructor methods, and otherwise
344344
* `sym.info.resultType`.
345345
*/
346-
def patchedResultType(sym: Symbol)(implicit ctx: Context): Type =
346+
def patchedResultType(sym: Symbol)(using Context): Type =
347347
if (sym.isConstructor) defn.UnitType
348348
else sym.info.resultType
349349

@@ -355,13 +355,13 @@ object JSEncoding {
355355
else OriginalName(originalName)
356356
}
357357

358-
def originalNameOfField(sym: Symbol)(implicit ctx: Context): OriginalName =
358+
def originalNameOfField(sym: Symbol)(using Context): OriginalName =
359359
originalNameOf(sym.name)
360360

361-
def originalNameOfMethod(sym: Symbol)(implicit ctx: Context): OriginalName =
361+
def originalNameOfMethod(sym: Symbol)(using Context): OriginalName =
362362
originalNameOf(sym.name)
363363

364-
def originalNameOfClass(sym: Symbol)(implicit ctx: Context): OriginalName =
364+
def originalNameOfClass(sym: Symbol)(using Context): OriginalName =
365365
originalNameOf(sym.fullName)
366366

367367
private def originalNameOf(name: Name): OriginalName = {

compiler/src/dotty/tools/backend/sjs/JSInterop.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ import JSDefinitions._
1414
object JSInterop {
1515

1616
/** Is this symbol a JavaScript type? */
17-
def isJSType(sym: Symbol)(implicit ctx: Context): Boolean = {
17+
def isJSType(sym: Symbol)(using Context): Boolean = {
1818
//sym.hasAnnotation(jsdefn.RawJSTypeAnnot)
1919
ctx.atPhase(ctx.erasurePhase) {
2020
sym.derivesFrom(jsdefn.JSAnyClass)
2121
}
2222
}
2323

2424
/** Is this symbol a Scala.js-defined JS class, i.e., a non-native JS class? */
25-
def isScalaJSDefinedJSClass(sym: Symbol)(implicit ctx: Context): Boolean =
25+
def isScalaJSDefinedJSClass(sym: Symbol)(using Context): Boolean =
2626
isJSType(sym) && !sym.hasAnnotation(jsdefn.JSNativeAnnot)
2727

2828
/** Should this symbol be translated into a JS getter?
@@ -31,7 +31,7 @@ object JSInterop {
3131
* Unlike `SymDenotations.isGetter`, it applies to user-defined methods as
3232
* much as *accessor* methods created for `val`s and `var`s.
3333
*/
34-
def isJSGetter(sym: Symbol)(implicit ctx: Context): Boolean = {
34+
def isJSGetter(sym: Symbol)(using Context): Boolean = {
3535
sym.info.firstParamTypes.isEmpty && ctx.atPhase(ctx.erasurePhase) {
3636
sym.info.isParameterless
3737
}
@@ -43,21 +43,21 @@ object JSInterop {
4343
* Unlike `SymDenotations.isGetter`, it applies to user-defined methods as
4444
* much as *accessor* methods created for `var`s.
4545
*/
46-
def isJSSetter(sym: Symbol)(implicit ctx: Context): Boolean =
46+
def isJSSetter(sym: Symbol)(using Context): Boolean =
4747
sym.name.isSetterName && sym.is(Method)
4848

4949
/** Should this symbol be translated into a JS bracket access?
5050
*
5151
* This is true for methods annotated with `@JSBracketAccess`.
5252
*/
53-
def isJSBracketAccess(sym: Symbol)(implicit ctx: Context): Boolean =
53+
def isJSBracketAccess(sym: Symbol)(using Context): Boolean =
5454
sym.hasAnnotation(jsdefn.JSBracketAccessAnnot)
5555

5656
/** Should this symbol be translated into a JS bracket call?
5757
*
5858
* This is true for methods annotated with `@JSBracketCall`.
5959
*/
60-
def isJSBracketCall(sym: Symbol)(implicit ctx: Context): Boolean =
60+
def isJSBracketCall(sym: Symbol)(using Context): Boolean =
6161
sym.hasAnnotation(jsdefn.JSBracketCallAnnot)
6262

6363
/** Is this symbol a default param accessor for a JS method?
@@ -66,7 +66,7 @@ object JSInterop {
6666
* the companion *class* of the owner is a JS type; not whether the owner
6767
* is a JS type.
6868
*/
69-
def isJSDefaultParam(sym: Symbol)(implicit ctx: Context): Boolean = {
69+
def isJSDefaultParam(sym: Symbol)(using Context): Boolean = {
7070
sym.name.is(DefaultGetterName) && {
7171
val owner = sym.owner
7272
if (owner.is(ModuleClass)) {
@@ -89,7 +89,7 @@ object JSInterop {
8989
* If it is not explicitly specified with an `@JSName` annotation, the
9090
* JS name is inferred from the Scala name.
9191
*/
92-
def jsNameOf(sym: Symbol)(implicit ctx: Context): String = {
92+
def jsNameOf(sym: Symbol)(using Context): String = {
9393
sym.getAnnotation(jsdefn.JSNameAnnot).flatMap(_.argumentConstant(0)).fold {
9494
val base = sym.name.unexpandedName.decode.toString.stripSuffix("_=")
9595
if (sym.is(ModuleClass)) base.stripSuffix("$")
@@ -105,7 +105,7 @@ object JSInterop {
105105
* This is the JS name of the symbol qualified by the fully qualified JS
106106
* name of its original owner if the latter is a native JS object.
107107
*/
108-
def fullJSNameOf(sym: Symbol)(implicit ctx: Context): String = {
108+
def fullJSNameOf(sym: Symbol)(using Context): String = {
109109
assert(sym.isClass, s"fullJSNameOf called for non-class symbol $sym")
110110
sym.getAnnotation(jsdefn.JSFullNameAnnot).flatMap(_.argumentConstant(0)).fold {
111111
jsNameOf(sym)

compiler/src/dotty/tools/backend/sjs/JSPositions.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import dotty.tools.dotc.util.Spans.Span
99
import org.scalajs.ir
1010

1111
/** Conversion utilities from dotty Positions to IR Positions. */
12-
class JSPositions()(implicit ctx: Context) {
12+
class JSPositions()(using Context) {
1313

1414
private def sourceAndSpan2irPos(source: SourceFile, span: Span): ir.Position = {
1515
if (!span.exists) ir.Position.NoPosition

compiler/src/dotty/tools/backend/sjs/JSPrimitives.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,23 @@ object JSPrimitives {
4646

4747
}
4848

49-
class JSPrimitives(ctx: Context) extends DottyPrimitives(ctx) {
49+
class JSPrimitives(ictx: Context) extends DottyPrimitives(ictx) {
5050
import JSPrimitives._
5151
import dotty.tools.backend.ScalaPrimitivesOps._
5252

53-
private lazy val jsPrimitives: Map[Symbol, Int] = initJSPrimitives(ctx)
53+
private lazy val jsPrimitives: Map[Symbol, Int] = initJSPrimitives(using ictx)
5454

5555
override def getPrimitive(sym: Symbol): Int =
5656
jsPrimitives.getOrElse(sym, super.getPrimitive(sym))
5757

58-
override def getPrimitive(app: Apply, tpe: Type)(implicit ctx: Context): Int =
58+
override def getPrimitive(app: Apply, tpe: Type)(using Context): Int =
5959
jsPrimitives.getOrElse(app.fun.symbol, super.getPrimitive(app, tpe))
6060

6161
override def isPrimitive(fun: Tree): Boolean =
62-
jsPrimitives.contains(fun.symbol(using ctx)) || super.isPrimitive(fun)
62+
jsPrimitives.contains(fun.symbol(using ictx)) || super.isPrimitive(fun)
6363

6464
/** Initialize the primitive map */
65-
private def initJSPrimitives(implicit ctx: Context): Map[Symbol, Int] = {
65+
private def initJSPrimitives(using Context): Map[Symbol, Int] = {
6666

6767
val primitives = newMutableSymbolMap[Int]
6868

@@ -73,7 +73,7 @@ class JSPrimitives(ctx: Context) extends DottyPrimitives(ctx) {
7373
primitives(s) = code
7474
}
7575

76-
def addPrimitives(cls: Symbol, method: TermName, code: Int)(implicit ctx: Context): Unit = {
76+
def addPrimitives(cls: Symbol, method: TermName, code: Int)(using Context): Unit = {
7777
val alts = cls.info.member(method).alternatives.map(_.symbol)
7878
if (alts.isEmpty) {
7979
ctx.error(s"Unknown primitive method $cls.$method")

0 commit comments

Comments
 (0)