-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ScalaCompiler: Include plug-ins from platform modules
Closes #16.
- Loading branch information
Showing
5 changed files
with
74 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# See https://github.com/tindzk/seed/issues/16 | ||
[project] | ||
scalaVersion = "2.11.12" | ||
scalaJsVersion = "0.6.26" | ||
scalaOptions = ["-encoding", "UTF-8", "-unchecked", "-deprecation", "-Xfuture"] | ||
|
||
[module.macros] | ||
root = "macros" | ||
sources = ["macros"] | ||
targets = ["jvm", "js"] | ||
|
||
[module.macros.jvm] | ||
compilerDeps = [ | ||
["org.scalamacros", "paradise", "2.1.1", "full"] | ||
] | ||
|
||
[module.macros.js] | ||
compilerDeps = [ | ||
["org.scalamacros", "paradise", "2.1.1", "full"] | ||
] | ||
|
||
[module.example] | ||
root = "example" | ||
sources = ["example"] | ||
targets = ["jvm", "js"] | ||
moduleDeps = ["macros"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
@hello | ||
object Test extends App { | ||
println(this.hello) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import scala.reflect.macros.blackbox | ||
import scala.language.experimental.macros | ||
import scala.annotation.StaticAnnotation | ||
|
||
object helloMacro { | ||
def impl(c: blackbox.Context)(annottees: c.Expr[Any]*): c.Expr[Any] = { | ||
import c.universe._ | ||
import Flag._ | ||
val result = { | ||
annottees.map(_.tree).toList match { | ||
case q"object $name extends ..$parents { ..$body }" :: Nil => | ||
q""" | ||
object $name extends ..$parents { | ||
def hello: ${typeOf[String]} = "hello" | ||
..$body | ||
} | ||
""" | ||
} | ||
} | ||
c.Expr[Any](result) | ||
} | ||
} | ||
|
||
class hello extends StaticAnnotation { | ||
def macroTransform(annottees: Any*): Any = macro helloMacro.impl | ||
} |