28th Wed
ScalaでASTを取得する方法
Scalaを使って関数のASTにアクセスするには、以下のようにすればいいらしい。
pre>>
scala> def f = print("hello")
f: Unit
scala> scala.reflect.Code.lift(f).tree
res3: scala.reflect.Tree = Select(Select(Select(Ident(Field(line4$object,PrefixedType(ThisType(RootSymbol),Class(line4$object)))),Field($iw,PrefixedType(ThisType(Class(line4$object)),Class($iw)))),Field($iw,PrefixedType(ThisType(Class($iw)),Class($iw)))),Method(f,PolyType(List(),List(),PrefixedType(ThisType(Class(scala)),Class(scala.Unit)))))
<<--
posted by
genki on Wed 28 Apr 2010 at 06:54 with 0 comments