私は、DLR を使用して Racket 言語を .NET に移植するプロジェクトに取り組んでいます。
式ツリーを構築し、CompileToMethod()
メソッドを呼び出します。
関連する実行可能エミッション コード: ( How to Save an Expression Tree as the Main Entry Point to a New Executable Disk File?から取得)
//Wrap the program into a block expression
Expression code = Expression.Block(new ParameterExpression[] { env, voidSingleton}, program);
var asmName = new AssemblyName("Foo");
var asmBuilder = AssemblyBuilder.DefineDynamicAssembly(asmName, AssemblyBuilderAccess.RunAndSave);
var moduleBuilder = asmBuilder.DefineDynamicModule("Foo", "Foo.exe");
var typeBuilder = moduleBuilder.DefineType("Program", TypeAttributes.Public);
var methodBuilder = typeBuilder.DefineMethod("Main",
MethodAttributes.Static, typeof(void), new[] { typeof(string) });
Expression.Lambda<Action>(code).CompileToMethod(methodBuilder);
typeBuilder.CreateType();
asmBuilder.SetEntryPoint(methodBuilder);
asmBuilder.Save("Foo.exe");
Runtime_rkt.dll
関連するランタイム型変換、バッキング オブジェクトなどを含むランタイム ライブラリがあります。
Foo.exe
とをRuntime_rkt.dll
同じディレクトリに配置すると、すべて正常に動作します。私たちが抱えている問題は、(明らかに) ランタイム ライブラリを別の場所に移動したときです。最終的には、C:\Windows\Microsoft.NET\assembly\GAC_MSIL
IronPython のようにインストールする必要があります。【GACで解決】
[編集] Extra pts に関する新しい質問 すべての実行時メソッドを実行可能ファイルに静的にコンパイルする方法はありますか?