public Reckoner GetReckoner(Formula f, LeftFormula m) { CombinedReckoner reckoner = CombineReckoner(f, m); Reckoner ev = new Reckoner(reckoner.Reckon); return(ev); }
public Reckoner GetReckoner(CombinedFormula m) { CombinedReckoner reckoner = CombineReckoner(m); Reckoner ev = new Reckoner(reckoner.Reckon); return(ev); }
public static CombinedReckoner Compile(Formula formula) { if (MODULE == null) { AssemblyName assemblyName = new AssemblyName(); assemblyName.Name = "EmittedAssembly"; ASSEMBLY = AssemblyBuilder.DefineDynamicAssembly(assemblyName, CollectMode ? AssemblyBuilderAccess.RunAndCollect : AssemblyBuilderAccess.Run); MODULE = ASSEMBLY.DefineDynamicModule("EmittedModule"); CLASS_ID = 0; } CLASS_ID++; TypeBuilder MathlineFormula = MODULE.DefineType(TYPE_PREFIX + CLASS_ID, TypeAttributes.Public, typeof(CombinedReckoner)); Type[] constructorArgs = { }; ConstructorBuilder constructor = MathlineFormula.DefineConstructor( MethodAttributes.Public, CallingConventions.Standard, null); ILGenerator constructorIL = constructor.GetILGenerator(); constructorIL.Emit(OpCodes.Ldarg_0); ConstructorInfo superConstructor = typeof(Object).GetConstructor(new Type[0]); constructorIL.Emit(OpCodes.Call, superConstructor); constructorIL.Emit(OpCodes.Ret); Type[] args = { }; MethodBuilder fxMethod = MathlineFormula.DefineMethod("Reckon", MethodAttributes.Public | MethodAttributes.Virtual, typeof(void), args); ILGenerator methodIL = fxMethod.GetILGenerator(); CompilerContext context = new CompilerContext(); // first pass calculate the parameters // initialize and declare the parameters, start with // localVectorI = parameters[i]; // next pass implements the function formula.Compile(methodIL, context); context.NextPass(); context.GenerateLocalInit(methodIL); formula.Compile(methodIL, context); // finally return methodIL.Emit(OpCodes.Ret); // create the class... Type mxt = MathlineFormula.CreateTypeInfo(); CombinedReckoner reckoner = (CombinedReckoner)Activator.CreateInstance(mxt, new Object[] { }); reckoner.SetParams(context.ParamCards, context.Count); return(reckoner); }
public CombinedReckoner CombineReckoner(Formula f, LeftFormula m) { CombinedReckoner reckoner = Compiler.Compile(new CombinedFormula(m, f)); return(reckoner); }
public Reckoner GetReckoner(CombinedReckoner e) { Reckoner ev = new Reckoner(e.Reckon); return(ev); }
public void Reckon(CombinedReckoner ev) { Reckoner e = new Reckoner(ev.Reckon); e(); }