Skip to content

Instantly share code, notes, and snippets.

@bonprosoft
Created November 27, 2012 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bonprosoft/4154775 to your computer and use it in GitHub Desktop.
Save bonprosoft/4154775 to your computer and use it in GitHub Desktop.
HelloWorld on VBCPP AST(Another)
' ポイントはNewを殆ど使わず、メソッドチェーンで内容を付与していく点です。
' この式では、なるべくカッコは使いたくなかったので、リストなどを作る際、子を作り終わったらDefineで親に戻ります。
' LINQに触れてみて、感動したので、それに影響されたところがあります。
'★長所: (他の式に比べて)なかなか書きやすい!★
'★短所: Defineをしないうちは、別の中間生成物として表される必要が有るため、クラスが結構増える
Dim tree As New VBCPP_Program
tree.AddMethod( _
VBCPP_Method.CreateNew("SampleMethod",System.Reflection.MethodAttributes.Static Or Reflection.MethodAttributes.Public,LangName,Line,FileName) _
.SetBody _
.CreateCallStatement("Console").SetChild("WriteLine") _
.SetArgument _
.CreateLiteral("Hello,World",VBCPP_LiteralType.VBCPP_STRING).Define _
.Define _
.Define.Define _
.Define _
.Define _
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment