Skip to content

Commit 8bb5b5d

Browse files
committed
Create tasty.reflect.Kernel
1 parent afc03c9 commit 8bb5b5d

File tree

6 files changed

+713
-226
lines changed

6 files changed

+713
-226
lines changed
Lines changed: 1 addition & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -1,130 +1,8 @@
11
package dotty.tools.dotc
22
package tastyreflect
33

4-
import dotty.tools.dotc.ast.{tpd, untpd}
5-
import dotty.tools.dotc.core.Constants
6-
import dotty.tools.dotc.core.Types
7-
84
trait CoreImpl extends scala.tasty.reflect.Core {
95

10-
type Context = core.Contexts.Context
11-
12-
type Settings = config.ScalaSettings
13-
14-
type TermOrTypeTree = tpd.Tree
15-
16-
type Tree = tpd.Tree
17-
type PackageClause = tpd.PackageDef
18-
type Statement = tpd.Tree
19-
type Import = tpd.Import
20-
type Definition = tpd.Tree
21-
type PackageDef = PackageDefinition
22-
type ClassDef = tpd.TypeDef
23-
type TypeDef = tpd.TypeDef
24-
type DefDef = tpd.DefDef
25-
type ValDef = tpd.ValDef
26-
type Term = tpd.Tree
27-
val Term: TermCoreModuleImpl
28-
trait TermCoreModuleImpl extends TermCoreModule {
29-
type Ref = tpd.RefTree
30-
type Ident = tpd.Ident
31-
type Select = tpd.Select
32-
type Literal = tpd.Literal
33-
type This = tpd.This
34-
type New = tpd.New
35-
type NamedArg = tpd.NamedArg
36-
type Apply = tpd.Apply
37-
type TypeApply = tpd.TypeApply
38-
type Super = tpd.Super
39-
type Typed = tpd.Typed
40-
type Assign = tpd.Assign
41-
type Block = tpd.Block
42-
type Lambda = tpd.Closure
43-
type If = tpd.If
44-
type Match = tpd.Match
45-
type Try = tpd.Try
46-
type Return = tpd.Return
47-
type Repeated = tpd.SeqLiteral
48-
type Inlined = tpd.Inlined
49-
type SelectOuter = tpd.Select
50-
type While = tpd.WhileDo
51-
}
52-
53-
54-
type CaseDef = tpd.CaseDef
55-
type TypeCaseDef = tpd.CaseDef
56-
57-
type Pattern = tpd.Tree
58-
type Value = tpd.Tree
59-
type Bind = tpd.Bind
60-
type Unapply = tpd.UnApply
61-
type Alternatives = tpd.Alternative
62-
type TypeTest = tpd.Typed
63-
64-
type TypeOrBoundsTree = tpd.Tree
65-
type TypeTree = tpd.Tree
66-
val TypeTree: TypeTreeCoreModuleImpl
67-
trait TypeTreeCoreModuleImpl extends TypeTreeCoreModule {
68-
type Inferred = tpd.TypeTree
69-
type Ident = tpd.Ident
70-
type Select = tpd.Select
71-
type Projection = tpd.Select
72-
type Singleton = tpd.SingletonTypeTree
73-
type Refined = tpd.RefinedTypeTree
74-
type Applied = tpd.AppliedTypeTree
75-
type Annotated = tpd.Annotated
76-
type MatchType = tpd.MatchTypeTree
77-
type ByName = tpd.ByNameTypeTree
78-
type LambdaTypeTree = tpd.LambdaTypeTree
79-
type TypeBind = tpd.Bind
80-
type TypeBlock = tpd.Block
81-
}
82-
type TypeBoundsTree = tpd.TypeBoundsTree
83-
type WildcardType = tpd.TypeTree
84-
85-
type TypeOrBounds = Types.Type
86-
type NoPrefix = Types.NoPrefix.type
87-
type TypeBounds = Types.TypeBounds
88-
type Type = Types.Type
89-
type ConstantType = Types.ConstantType
90-
type SymRef = Types.NamedType
91-
type TermRef = Types.NamedType
92-
type TypeRef = Types.NamedType
93-
type SuperType = Types.SuperType
94-
type Refinement = Types.RefinedType
95-
type AppliedType = Types.AppliedType
96-
type AnnotatedType = Types.AnnotatedType
97-
type AndType = Types.AndType
98-
type OrType = Types.OrType
99-
type MatchType = Types.MatchType
100-
type ByNameType = Types.ExprType
101-
type ParamRef = Types.ParamRef
102-
type ThisType = Types.ThisType
103-
type RecursiveThis = Types.RecThis
104-
type RecursiveType = Types.RecType
105-
type LambdaType[ParamInfo] = Types.LambdaType { type PInfo = ParamInfo }
106-
type MethodType = Types.MethodType
107-
type PolyType = Types.PolyType
108-
type TypeLambda = Types.TypeLambda
109-
110-
type ImportSelector = untpd.Tree
111-
112-
type Id = untpd.Ident
113-
114-
type Signature = core.Signature
115-
116-
type Position = util.SourcePosition
117-
118-
type Constant = Constants.Constant
119-
120-
type Symbol = core.Symbols.Symbol
121-
type PackageSymbol = core.Symbols.Symbol
122-
type ClassSymbol = core.Symbols.ClassSymbol
123-
type TypeSymbol = core.Symbols.TypeSymbol
124-
type DefSymbol = core.Symbols.TermSymbol
125-
type BindSymbol = core.Symbols.TermSymbol
126-
type ValSymbol = core.Symbols.TermSymbol
127-
type NoSymbol = core.Symbols.NoSymbol.type
6+
final val kernel: KernelImpl = new KernelImpl
1287

129-
type Flags = core.Flags.FlagSet
1308
}
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
package dotty.tools.dotc
2+
package tastyreflect
3+
4+
import dotty.tools.dotc.ast.{tpd, untpd}
5+
import dotty.tools.dotc.core.Constants
6+
import dotty.tools.dotc.core.Types
7+
8+
import scala.tasty.reflect.Kernel
9+
10+
class KernelImpl extends Kernel {
11+
type Context = core.Contexts.Context
12+
13+
type Settings = config.ScalaSettings
14+
15+
type TermOrTypeTree = tpd.Tree
16+
17+
type Tree = tpd.Tree
18+
type PackageClause = tpd.PackageDef
19+
type Statement = tpd.Tree
20+
type Import = tpd.Import
21+
type Definition = tpd.Tree
22+
type PackageDef = PackageDefinition
23+
type ClassDef = tpd.TypeDef
24+
type TypeDef = tpd.TypeDef
25+
type DefDef = tpd.DefDef
26+
type ValDef = tpd.ValDef
27+
type Term = tpd.Tree
28+
type Term_Ref = tpd.RefTree
29+
type Term_Ident = tpd.Ident
30+
type Term_Select = tpd.Select
31+
type Term_Literal = tpd.Literal
32+
type Term_This = tpd.This
33+
type Term_New = tpd.New
34+
type Term_NamedArg = tpd.NamedArg
35+
type Term_Apply = tpd.Apply
36+
type Term_TypeApply = tpd.TypeApply
37+
type Term_Super = tpd.Super
38+
type Term_Typed = tpd.Typed
39+
type Term_Assign = tpd.Assign
40+
type Term_Block = tpd.Block
41+
type Term_Lambda = tpd.Closure
42+
type Term_If = tpd.If
43+
type Term_Match = tpd.Match
44+
type Term_Try = tpd.Try
45+
type Term_Return = tpd.Return
46+
type Term_Repeated = tpd.SeqLiteral
47+
type Term_Inlined = tpd.Inlined
48+
type Term_SelectOuter = tpd.Select
49+
type Term_While = tpd.WhileDo
50+
51+
type CaseDef = tpd.CaseDef
52+
type TypeCaseDef = tpd.CaseDef
53+
54+
type Pattern = tpd.Tree
55+
type Value = tpd.Tree
56+
type Bind = tpd.Bind
57+
type Unapply = tpd.UnApply
58+
type Alternatives = tpd.Alternative
59+
type TypeTest = tpd.Typed
60+
61+
type TypeOrBoundsTree = tpd.Tree
62+
type TypeTree = tpd.Tree
63+
type TypeTree_Inferred = tpd.TypeTree
64+
type TypeTree_Ident = tpd.Ident
65+
type TypeTree_Select = tpd.Select
66+
type TypeTree_Projection = tpd.Select
67+
type TypeTree_Singleton = tpd.SingletonTypeTree
68+
type TypeTree_Refined = tpd.RefinedTypeTree
69+
type TypeTree_Applied = tpd.AppliedTypeTree
70+
type TypeTree_Annotated = tpd.Annotated
71+
type TypeTree_MatchType = tpd.MatchTypeTree
72+
type TypeTree_ByName = tpd.ByNameTypeTree
73+
type TypeTree_LambdaTypeTree = tpd.LambdaTypeTree
74+
type TypeTree_TypeBind = tpd.Bind
75+
type TypeTree_TypeBlock = tpd.Block
76+
77+
type TypeBoundsTree = tpd.TypeBoundsTree
78+
type WildcardType = tpd.TypeTree
79+
80+
type TypeOrBounds = Types.Type
81+
type NoPrefix = Types.NoPrefix.type
82+
type TypeBounds = Types.TypeBounds
83+
type Type = Types.Type
84+
type ConstantType = Types.ConstantType
85+
type SymRef = Types.NamedType
86+
type TermRef = Types.NamedType
87+
type TypeRef = Types.NamedType
88+
type SuperType = Types.SuperType
89+
type Refinement = Types.RefinedType
90+
type AppliedType = Types.AppliedType
91+
type AnnotatedType = Types.AnnotatedType
92+
type AndType = Types.AndType
93+
type OrType = Types.OrType
94+
type MatchType = Types.MatchType
95+
type ByNameType = Types.ExprType
96+
type ParamRef = Types.ParamRef
97+
type ThisType = Types.ThisType
98+
type RecursiveThis = Types.RecThis
99+
type RecursiveType = Types.RecType
100+
type LambdaType[ParamInfo] = Types.LambdaType { type PInfo = ParamInfo }
101+
type MethodType = Types.MethodType
102+
type PolyType = Types.PolyType
103+
type TypeLambda = Types.TypeLambda
104+
105+
type ImportSelector = untpd.Tree
106+
107+
type Id = untpd.Ident
108+
109+
type Signature = core.Signature
110+
111+
type Position = util.SourcePosition
112+
113+
type Constant = Constants.Constant
114+
115+
type Symbol = core.Symbols.Symbol
116+
type PackageSymbol = core.Symbols.Symbol
117+
type ClassSymbol = core.Symbols.ClassSymbol
118+
type TypeSymbol = core.Symbols.TypeSymbol
119+
type DefSymbol = core.Symbols.TermSymbol
120+
type BindSymbol = core.Symbols.TermSymbol
121+
type ValSymbol = core.Symbols.TermSymbol
122+
type NoSymbol = core.Symbols.NoSymbol.type
123+
124+
type Flags = core.Flags.FlagSet
125+
}

compiler/src/dotty/tools/dotc/tastyreflect/TreeOpsImpl.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with RootPositionImpl with
368368
if (termOrTypeTree.isTerm) Some(termOrTypeTree) else None
369369
}
370370

371-
object Term extends TermModule with TermCoreModuleImpl {
371+
object Term extends TermModule with TermCoreModule {
372372

373373
object IsIdent extends IsIdentModule {
374374
def unapply(x: Term)(implicit ctx: Context): Option[Ident] = x match {
@@ -377,7 +377,6 @@ trait TreeOpsImpl extends scala.tasty.reflect.TreeOps with RootPositionImpl with
377377
}
378378
}
379379

380-
381380
object Ref extends RefModule {
382381
def apply(sym: Symbol)(implicit ctx: Context): Ref = withDefaultPos(ctx => tpd.ref(sym)(ctx).asInstanceOf[tpd.RefTree])
383382
}

compiler/src/dotty/tools/dotc/tastyreflect/TypeOrBoundsTreesOpsImpl.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ trait TypeOrBoundsTreesOpsImpl extends scala.tasty.reflect.TypeOrBoundsTreeOps w
9595
}
9696
}
9797

98-
object TypeTree extends TypeTreeModule with TypeTreeCoreModuleImpl {
98+
object TypeTree extends TypeTreeModule with TypeTreeCoreModule {
9999

100100
object IsInferred extends IsInferredModule {
101101
def unapply(tpt: TypeOrBoundsTree)(implicit ctx: Context): Option[Inferred] = tpt match {

0 commit comments

Comments
 (0)