public static void StoreDebugImplementation(PFunction func, Engine targetEngine) { const FunctionLinking linking = FunctionLinking.FullyStatic; var pass = new CompilerPass(linking); var m = pass.DefineImplementationMethod(func.Id); var il = CompilerPass.GetIlGenerator(m); _compile(func, il, targetEngine, pass, linking); pass.TargetType.CreateType(); //var sm = tb.DefineMethod("whoop", MethodAttributes.Static | MethodAttributes.Public); //ab.SetEntryPoint(sm); pass.Assembly.Save(pass.Assembly.GetName().Name + ".dll"); }
public static bool TryCompile(PFunction func, Engine targetEngine, FunctionLinking linking) { if (_checkQualification(func, targetEngine)) { var pass = new CompilerPass(func.ParentApplication, linking); var m = pass.DefineImplementationMethod(func.Id); var il = CompilerPass.GetIlGenerator(m); _compile(func, il, targetEngine, pass, linking); func.Declaration.CilImplementation = pass.GetDelegate(m); pass.LinkMetadata(func); return true; } return false; }
public static void StoreDebugImplementation(Application app, Engine targetEngine) { _checkQualification(app.Functions, targetEngine); const FunctionLinking linking = FunctionLinking.FullyStatic; var pass = new CompilerPass(linking); var qfuncs = new List<PFunction>(); foreach (var func in app.Functions) { if (!func.Meta.GetDefault(PFunction.VolatileKey, false)) { qfuncs.Add(func); pass.DefineImplementationMethod(func.Id); } } foreach (var func in qfuncs) { _compile(func, pass.GetIlGenerator(func.Id), targetEngine, pass, linking); } pass.TargetType.CreateType(); pass.Assembly.Save(pass.Assembly.GetName().Name + ".dll"); }
public static void Compile(IEnumerable<PFunction> functions, Engine targetEngine, FunctionLinking linking) { _checkQualification(functions, targetEngine); var qfuncs = new List<PFunction>(); //Get a list of qualifying functions foreach (var func in functions) if (!func.Meta.GetDefault(PFunction.VolatileKey, false)) qfuncs.Add(func); if (qfuncs.Count == 0) return; //No compilation to be done var pass = new CompilerPass(linking); //Generate method stubs foreach (var func in qfuncs) pass.DefineImplementationMethod(func.Id); //Emit IL foreach (var func in qfuncs) { _compile(func, CompilerPass.GetIlGenerator(pass.Implementations[func.Id]), targetEngine, pass, linking); } //Enable by name linking and link meta data to CIL implementations foreach (var func in qfuncs) { func.Declaration.CilImplementation = pass.GetDelegate(func.Id); pass.LinkMetadata(func); } }