Permalink
Browse files

First successful pass of "lite" code

  • Loading branch information...
1 parent c1511d1 commit 975319457f596eda276666d4022b95a6e8e1b188 @kevinwright committed Mar 30, 2011
@@ -146,15 +146,18 @@ class AutoProxyPlugin(val global: Global) extends Plugin {
}
}
+// val components = List[PluginComponent](
+// new MyTreePrinter(global, "parser"),
+// earlyNamer,
+// earlyTyper,
+// new MyTreePrinter(global, "earlytyper"),
+// new GenerateSynthetics(this, global),
+// new MyTreePrinter(global, "generatesynthetics")
+// //new ErrorRetyper(this, global),
+// //new MyTreePrinter(global, "errorretyper")
+// )
val components = List[PluginComponent](
- new MyTreePrinter(global, "parser"),
- earlyNamer,
- earlyTyper,
- new MyTreePrinter(global, "earlytyper"),
- new GenerateSynthetics(this, global),
- new MyTreePrinter(global, "generatesynthetics")
- //new ErrorRetyper(this, global),
- //new MyTreePrinter(global, "errorretyper")
- )
+ new GenerateSynthetics(this, global)
+ )
}
@@ -26,7 +26,7 @@ class GenerateSynthetics(plugin: AutoProxyPlugin, val global: Global) extends Pl
import global.Tree
- val runsAfter = List[String]("earlytyper")
+ val runsAfter = List[String]("typer")
val phaseName = "generatesynthetics"
def newTransformer(unit: CompilationUnit) = new AutoProxyTransformer(unit)
@@ -88,7 +88,7 @@ class GenerateSynthetics(plugin: AutoProxyPlugin, val global: Global) extends Pl
val definedMethods = publicMembersOf(cls)
val requiredMethods =
- publicMembersOf(symbolToProxy).filter(mem => !definedMethods.contains(mem))
+ publicMembersOf(symbolToProxy).filter(mem => !definedMethods.contains(mem))
log("defined methods: " + definedMethods.mkString(", "))
log("missing methods: " + requiredMethods.mkString(", "))
@@ -106,21 +106,25 @@ class GenerateSynthetics(plugin: AutoProxyPlugin, val global: Global) extends Pl
}
def shouldAutoProxySym(sym: Symbol) = {
+ println("testing symbol")
if (sym != null) {
val testSym = if (sym.isModule) sym.moduleClass else sym
+ testSym.annotations foreach { println(_) }
testSym.annotations exists {_.toString == plugin.AutoproxyAnnotationClass}
} else false
}
def shouldAutoProxy(tree: Tree) = {
- val nodeStr = nodePrinters.nodeToString(tree)
+// val nodeStr = nodePrinters.nodeToString(tree)
+ println("testing tree")
!isAccessor(tree) && shouldAutoProxySym(tree.symbol)
}
val newTree = tree match {
case ClassDef(mods, name, tparams, impl) =>
val delegs = for (member <- impl.body if shouldAutoProxy(member)) yield {
log("found annotated member: " + member)
+ println(impl.symbol)
generateDelegates(impl, member.symbol)
}
val newImpl = treeCopy.Template(impl, impl.parents, impl.self, delegs.flatten ::: impl.body)
@@ -8,15 +8,15 @@ package autoproxy.test
//@ compiler-debug-print-ast-after-errorretyper
//@ compiler-debug-browse-ast-after-errorretyper
-class PropertyAccessorsProps {
+trait PropertyAccessorsProps {
val s : String = "hello world"
var i : Int = 0
}
-class PropertyAccessors {
+class PropertyAccessors extends PropertyAccessorsProps {
- @proxy val props = new PropertyAccessorsProps
- def i2 = props.i
+ @proxy val props = new Object with PropertyAccessorsProps
+ def i2 = props.i
def i2_=(x$1: Int) = props.i = x$1
// def s = props.s
@@ -1,39 +1,37 @@
package autoproxy.plugin
import org.specs.Specification
-import tools.nsc.{CompilerCommand, Settings, Global, Main}
-import tools.nsc.reporters.{ConsoleReporter, StoreReporter}
-import tools.nsc.util.{ClassPath, FakePos}
-import tools.nsc.plugins.Plugin
+import tools.nsc.{CompilerCommand, Settings, Global}
+import tools.nsc.reporters.ConsoleReporter
+import tools.nsc.util.ClassPath
class PluginSpec extends Specification {
"The plugin should" should {
"compile a simple class" in {
def scalacError(msg: String): Unit = println(msg + "\n scalac -help gives more information")
val context = Thread.currentThread.getContextClassLoader.asInstanceOf[java.net.URLClassLoader]
- val allcpurls = context.getURLs.toList
- val cpurls = allcpurls filter {url => !url.toString.contains("project/boot") }
+ val allcpurls = context.getURLs.toList
+ val cpurls = allcpurls filter {url => !url.toString.contains("project/boot") }
val cpurlString = ClassPath.join(cpurls map (_.getPath) : _*)
- val testRoot = "src/test/resources/autoproxy/test/"
+ val testRoot = "src/test/projects/simple/autoproxy/test/"
val sources = List(
"Main.scala",
"PropertyAccessors.scala",
"proxyAnnotation.scala") map {testRoot + _}
val args = List(
"-cp", cpurlString,
+ "-d", "target/test-projects/simple",
"-verbose",
- //"-usejavacp",
- //"-nobootcp",
+ "-Xprint:generatesynthetics",
+// "-Yshow-trees",
+// "-Xshow-phases",
"-Xplugin:test-projects/stub-jar/dynamic-mixin-stub.jar",
"-Xplugin-require:autoproxy"
-// "-Xshow-phases"
-// "-Xplugin-list"
) ::: sources
-
val ss = new Settings(scalacError)
// val reporter = new StoreReporter
val reporter = new ConsoleReporter(ss)
@@ -42,8 +40,7 @@ class PluginSpec extends Specification {
val compiler = new Global(settings, reporter)
-// new AutoProxyPlugin(compiler)
-
+
if (reporter.hasErrors) {
// reporter.infos foreach { println }
reporter.flush

0 comments on commit 9753194

Please sign in to comment.