Created
February 24, 2014 18:37
-
-
Save MasseGuillaume/9194161 to your computer and use it in GitHub Desktop.
Worksheet using scala reflexion toolbox
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
val code = """def html[X, Y](xs: List[(X, Y)]) = xs.toString | |
val a = List((1,1)) | |
a | |
val b = List((1,1)) | |
b""" | |
val tree = tb.parse(code) | |
val identifiers = tree.children.collect{ case i @ Ident(_) => i } | |
val instrumentation = identifiers.map{ i => | |
Apply(Select(Ident("scala"), TermName("Tuple2")), | |
List(Literal(Constant(i.pos.line)), | |
Apply(Ident(TermName("html")), List(i)) | |
) | |
) | |
} | |
val result = Apply(Ident(TermName("List")), instrumentation) | |
tb.eval(Block(tree.children, result)).asInstanceOf[List[(Int, Any)]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment