è¨äºè¨æ£: DLR AST ã®ç´æ¥ã³ã³ãã¤ã«ã¯ä¾ç¶ã¨ãã¦æ¨æºãµãã¼ãã§ãã
Microsoft.Scripting.Ast.TreeCompiler
ãC#, DLR AST, meta programmingãã§ãDLR AST ã®ç´æ¥ã³ã³ãã¤ã«ã¯ public ã¯ã©ã¹ããã¯ã§ããªããã¨æ¸ãã¾ãããï¼ãã¿ã¾ããï¼èª¤å ±ã§ããï¼
èäºããã®ã¨ã³ããªãDLRのASTのみを使うãã«ããããã«ï¼TreeCompiler ã¯ã©ã¹ã®ã¹ã¿ãã£ãã¯ã¡ã½ããã使ãã°ï¼ãªãªã¸ãã«ã® Microsoft.Scripting.dll ãåç
§è¨å®ã«å ããã ã㧠DLR AST ãç´æ¥ã³ã³ãã¤ã«ã§ãã¾ãï¼
using System; using System.Collections.Generic; using Microsoft.Scripting; using Microsoft.Scripting.Ast; static class Program { static void Main(string[] args) { var cw = typeof(Console).GetMethod("WriteLine", new[] { typeof(string) }); var cb = Ast.CodeBlock("MyFunc", typeof(void)); cb.Body = Ast.Block( Ast.Call(cw, Ast.Constant("Hello, World!")), Ast.Call(cw, Ast.Constant("Hello, World!")), Ast.Call(cw, Ast.Constant("Hello, World!")) ); var dynamicFunc = TreeCompiler.CompileBlock<Action>(cb); dynamicFunc(); } }
Compiler ã¯ã©ã¹ã¯ç¢ºãã« internal ã«å¼ã£è¾¼ãã§ãã¾ã£ãã®ã§ããï¼æ°ããã¯ã©ã¹ã追å ããã¦ããã®ã«æ°ä»ãã¦ã¾ããã§ããï¼ä»¥ä¸ã®è¨äºã¨ãµã³ãã«ã³ã¼ãã¯ï¼IronPython 2.0 A8 ã® TreeCompiler ç¨ã«ä¿®æ£ãã¦ããã¾ãï¼
ãI love tree - 荒井省三のBlogãã§ç´¹ä»ããã¦ãã Martin æ°ã®ã¨ã³ããªãé常ã«åèã«ãªãã¾ãï¼
æãã¡ã¿ã«ãªããåå¿è ç¨ Evalã㯠DLR AST
ã¨ããããã§ï¼
- C# 1.x 並ã«ã·ã³ãã«ãªï¼æç¶ãåè¨èªã®ã¨ã£ã¤ãããã
- åçåä»ãè¨èªã®æè»æ§
- CLR ã«ããåæ¤è¨¼
- æ¢åã® .NET ã¯ã©ã¹ã¨ã®é£æºæ§
- JIT ã³ã³ãã¤ã«ã«ãããã¤ãã£ãã³ã¼ãçæ
ãããå
¨ã¦ãå
¼ãåããï¼æãã¡ã¿ã«ãªããåå¿è
ç¨ Evalãã¨ãã¦ï¼DLR AST ãå¼·ãæ¨ãããã¨ããã§ãï¼
ãããï¼DLR AST ã¯å¥½ããªè¨èªã§æ¸ããã¨ãã§ãã¾ãï¼C# ã§ï¼F# ã§ï¼IronRuby ã§ï¼ããã㯠DLR AST èªèº«ã§ DLR AST ãåºåããããã¨ã ã£ã¦å¯è½ã§ãï¼
å人çã«ã¯ï¼Silverlight 2.0 㧠DLR AST ã使ãããã©ãããæ¿ããæ°ã«ãªãã¨ããã§ãï¼ããã許ãããã®ã§ããã°ï¼å®è¡ç°å¢ãä¸æ°ã«åºããã¾ããã®ãï¼ãã®å
ã«ã¯ï¼Ajax ã§ãã£ã¦ããããã«ï¼ã³ã¼ãçããµã¼ãããã¯ã©ã¤ã¢ã³ãã«åçã«ããã·ã¥ããã¨ãã£ãå±éãèãããã¾ãï¼ããã¦ãããè¨èªéä¾åã£ã¦ã®ã¯é¢ç½ãã¨ï¼