• 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30

Scalaを使って関数のASTにアクセスするには、以下のようにすればいいらしい。

   1  scala> def f = print("hello")
   2  f: Unit
   3  
   4  scala> scala.reflect.Code.lift(f).tree     
   5  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 Png genki on Wed 28 Apr 2010 at 06:59

Comments:

or Preview
Social Bookmarks
  • Delicious
  • B_entry1759
  • Clip_16_12_w
Services from s21g
twpro(ツイプロ)
Twitterプロフィールを快適検索
地価2009
土地の値段を調べてみよう
MyRestaurant
自分だけのレストラン手帳
Formula
ブログに数式を埋め込める数式コミュニティ