Skip to content

Commit 274ce61

Browse files
committed
Getting liftCode to work.
1 parent 5d58268 commit 274ce61

File tree

12 files changed

+214
-274
lines changed

12 files changed

+214
-274
lines changed

src/compiler/scala/reflect/internal/Importers.scala

Lines changed: 68 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -18,72 +18,81 @@ trait Importers { self: SymbolTable =>
1818
def importPosition(pos: from.Position): Position = NoPosition
1919

2020
def importSymbol(sym: from.Symbol): Symbol = {
21-
def importOrRelink: Symbol =
22-
if (sym == null)
23-
null
24-
else if (sym.getClass == NoSymbol.getClass)
25-
NoSymbol
26-
else if (sym.isRoot)
27-
definitions.RootClass
28-
else {
29-
val myowner = importSymbol(sym.owner)
30-
val mypos = importPosition(sym.pos)
31-
val myname = importName(sym.name)
32-
33-
def doImport: Symbol = {
34-
val mysym = sym match {
35-
case x: from.MethodSymbol =>
36-
val mysym = new MethodSymbol(myowner, mypos, myname)
37-
mysym.referenced = importSymbol(x.referenced)
38-
mysym
39-
case x: from.ModuleSymbol =>
40-
new ModuleSymbol(myowner, mypos, myname)
41-
case x: from.FreeVar =>
42-
new FreeVar(importName(x.name), importType(x.tpe), x.value)
43-
case x: from.TermSymbol =>
44-
new TermSymbol(myowner, mypos, myname)
45-
case x: from.TypeSkolem =>
46-
new TypeSkolem(myowner, mypos, myname.toTypeName, x.unpackLocation match {
47-
case null => null
48-
case y: from.Tree => importTree(y)
49-
case y: from.Symbol => importSymbol(y)
50-
})
51-
/*
21+
def doImport(sym: from.Symbol): Symbol = {
22+
val myowner = importSymbol(sym.owner)
23+
val mypos = importPosition(sym.pos)
24+
val myname = importName(sym.name)
25+
def linkReferenced(mysym: TermSymbol, x: from.TermSymbol, op: from.Symbol => Symbol): Symbol = {
26+
println("link referenced " + mysym + " " + x.referenced)
27+
symMap(x) = mysym
28+
mysym.referenced = op(x.referenced)
29+
mysym
30+
}
31+
val mysym = sym match {
32+
case x: from.MethodSymbol =>
33+
linkReferenced(new MethodSymbol(myowner, mypos, myname), x, importSymbol)
34+
case x: from.ModuleSymbol =>
35+
linkReferenced(new ModuleSymbol(myowner, mypos, myname), x, doImport)
36+
case x: from.FreeVar =>
37+
new FreeVar(importName(x.name), importType(x.tpe), x.value)
38+
case x: from.TermSymbol =>
39+
linkReferenced(new TermSymbol(myowner, mypos, myname), x, importSymbol)
40+
case x: from.TypeSkolem =>
41+
new TypeSkolem(myowner, mypos, myname.toTypeName, x.unpackLocation match {
42+
case null => null
43+
case y: from.Tree => importTree(y)
44+
case y: from.Symbol => importSymbol(y)
45+
})
46+
/*
5247
case x: from.ModuleClassSymbol =>
5348
val mysym = new ModuleClassSymbol(myowner, mypos, myname.toTypeName)
5449
mysym.sourceModule = importSymbol(x.sourceModule)
5550
mysym
5651
*/
57-
case x: from.ClassSymbol =>
58-
val mysym = new ClassSymbol(myowner, mypos, myname.toTypeName)
59-
if (sym.thisSym != sym) {
60-
mysym.typeOfThis = importType(sym.typeOfThis)
61-
mysym.thisSym.name = importName(sym.thisSym.name)
62-
}
63-
mysym
64-
case x: from.TypeSymbol =>
65-
new TypeSymbol(myowner, mypos, myname.toTypeName)
52+
case x: from.ClassSymbol =>
53+
val mysym = new ClassSymbol(myowner, mypos, myname.toTypeName)
54+
if (sym.thisSym != sym) {
55+
mysym.typeOfThis = importType(sym.typeOfThis)
56+
mysym.thisSym.name = importName(sym.thisSym.name)
6657
}
67-
symMap(sym) = mysym
68-
mysym setFlag sym.flags | Flags.LOCKED
69-
mysym setInfo {
70-
val mytypeParams = sym.typeParams map importSymbol
71-
new LazyPolyType(mytypeParams) {
72-
override def complete(s: Symbol) {
73-
val result = sym.info match {
74-
case from.PolyType(_, res) => res
75-
case result => result
76-
}
77-
s setInfo polyType(mytypeParams, importType(result))
78-
s setAnnotations (sym.annotations map importAnnotationInfo)
79-
}
58+
mysym
59+
case x: from.TypeSymbol =>
60+
new TypeSymbol(myowner, mypos, myname.toTypeName)
61+
}
62+
symMap(sym) = mysym
63+
mysym setFlag sym.flags | Flags.LOCKED
64+
mysym setInfo {
65+
val mytypeParams = sym.typeParams map doImport
66+
new LazyPolyType(mytypeParams) {
67+
override def complete(s: Symbol) {
68+
val result = sym.info match {
69+
case from.PolyType(_, res) => res
70+
case result => result
8071
}
72+
s setInfo polyType(mytypeParams, importType(result))
73+
s setAnnotations (sym.annotations map importAnnotationInfo)
8174
}
82-
mysym resetFlag Flags.LOCKED
83-
} // end doImport
75+
}
76+
}
77+
mysym resetFlag Flags.LOCKED
78+
} // end doImport
8479

80+
def importOrRelink: Symbol =
81+
if (sym == null)
82+
null
83+
else if (sym == from.NoSymbol)
84+
NoSymbol
85+
else if (sym.isRoot)
86+
definitions.RootClass
87+
else {
88+
val myowner = importSymbol(sym.owner)
89+
val myname = importName(sym.name)
8590
if (sym.isModuleClass) {
86-
importSymbol(sym.sourceModule).moduleClass
91+
assert(sym.sourceModule != NoSymbol, sym)
92+
val mymodule = importSymbol(sym.sourceModule)
93+
assert(mymodule != NoSymbol, sym)
94+
assert(mymodule.moduleClass != NoSymbol, mymodule)
95+
mymodule.moduleClass
8796
} else if (myowner.isClass && !myowner.isRefinementClass && !(myowner hasFlag Flags.LOCKED) && sym.owner.info.decl(sym.name).exists) {
8897
// symbol is in class scope, try to find equivalent one in local scope
8998
if (sym.isOverloaded)
@@ -93,7 +102,7 @@ trait Importers { self: SymbolTable =>
93102
if (existing.isOverloaded) {
94103
existing =
95104
if (sym.isMethod) {
96-
val localCopy = doImport
105+
val localCopy = doImport(sym)
97106
existing filter (_.tpe matches localCopy.tpe)
98107
} else {
99108
existing filter (!_.isMethod)
@@ -104,7 +113,7 @@ trait Importers { self: SymbolTable =>
104113
}
105114
if (existing != NoSymbol) existing
106115
else {
107-
val mysym = doImport
116+
val mysym = doImport(sym)
108117
assert(myowner.info.decls.lookup(myname) == NoSymbol, myname+" "+myowner.info.decl(myname)+" "+existing)
109118
myowner.info.decls enter mysym
110119
mysym
@@ -118,7 +127,7 @@ trait Importers { self: SymbolTable =>
118127
println(myowner.rawInfo)
119128
myowner.typeParams(sym.paramPos)
120129
} else
121-
doImport
130+
doImport(sym)
122131
}
123132
symMap getOrElseUpdate (sym, importOrRelink)
124133
}

src/compiler/scala/reflect/internal/Symbols.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,6 +1794,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
17941794
else if (isTrait) "trait"
17951795
else if (isClass) "class"
17961796
else if (isType) "type"
1797+
else if (isInstanceOf[FreeVar]) "free variable"
17971798
else if (isTerm && isLazy) "lazy value"
17981799
else if (isVariable) "variable"
17991800
else if (isClassConstructor) "constructor"

src/compiler/scala/reflect/runtime/Mirror.scala

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import java.lang.reflect.Array
66

77
/** The mirror for standard runtime reflection from Java.
88
*/
9-
class Mirror extends Universe with RuntimeTypes with ToolBoxes with api.Mirror {
9+
class Mirror extends Universe with RuntimeTypes with TreeBuildUtil with ToolBoxes with api.Mirror {
1010

1111
import definitions._
1212

@@ -36,38 +36,6 @@ class Mirror extends Universe with RuntimeTypes with ToolBoxes with api.Mirror {
3636
override def classToType(jclazz: java.lang.Class[_]): Type = typeToScala(jclazz)
3737
override def classToSymbol(jclazz: java.lang.Class[_]): Symbol = classToScala(jclazz)
3838

39-
def staticClass(name: String): Symbol = definitions.getClass(newTypeName(name))
40-
def staticModule(name: String): Symbol = definitions.getModule(newTermName(name))
41-
42-
def freeVar(name: String, info: Type, value: Any) = new FreeVar(name, info, value)
43-
44-
/** Selects type symbol with given name from the defined members of prefix type
45-
*/
46-
def selectType(owner: Symbol, name: String): Symbol =
47-
owner.info.decl(newTypeName(name))
48-
49-
/** Selects term symbol with given name and type from the defined members of prefix type
50-
* @pre The prefix type
51-
* @name The name of the selected member
52-
* @tpe The type of the selected member
53-
*/
54-
def selectTerm(owner: Symbol, name: String, tpe: Type): Symbol =
55-
owner.info.decl(newTermName(name)) suchThat (_.tpe == tpe)
56-
57-
def selectParam(owner: Symbol, idx: Int): Symbol = {
58-
def selectInList(params: List[Symbol], idx: Int, fallback: Type): Symbol = {
59-
if (params.isEmpty) selectIn(fallback, idx)
60-
else if (idx == 0) params.head
61-
else selectInList(params.tail, idx - 1, fallback)
62-
}
63-
def selectIn(tpe: Type, idx: Int): Symbol = tpe match {
64-
case PolyType(tparams, res) => selectInList(tparams, idx, res)
65-
case MethodType(params, res) => selectInList(params, idx, res)
66-
case _ => NoSymbol
67-
}
68-
selectIn(owner.info, idx)
69-
}
70-
7139
}
7240

7341
object Mirror extends Mirror

src/compiler/scala/tools/nsc/settings/ScalaSettings.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ trait ScalaSettings extends AbsScalaSettings
158158
val Ytyperdebug = BooleanSetting ("-Ytyper-debug", "Trace all type assignments.")
159159
val Yinferdebug = BooleanSetting ("-Yinfer-debug", "Trace type inference and implicit search.")
160160
val Ypmatdebug = BooleanSetting ("-Ypmat-debug", "Trace all pattern matcher activity.")
161+
val Yreifydebug = BooleanSetting ("-Yreify-debug", "Trace reification actions.")
161162
val Yreplsync = BooleanSetting ("-Yrepl-sync", "Do not use asynchronous code for repl startup")
162163
val Yrepldebug = BooleanSetting ("-Yrepl-debug", "Trace all repl activity.") .
163164
withPostSetHook(_ => interpreter.replProps.debug setValue true)

0 commit comments

Comments
 (0)