private void Compile(string expression, ExpressionOptions options) { // Add the services that will be used by elements during the compile IServiceContainer services = new ServiceContainer(); this.AddServices(services); // Parse and get the root element of the parse tree var topElement = this.Context.Parse(expression, services); if (options.ResultType == null) { options.ResultType = topElement.ResultType; } var rootElement = new RootExpressionElement(topElement, options.ResultType); var dm = this.CreateDynamicMethod(); var ilg = new FleeIlGenerator(dm.GetILGenerator()); // Emit the IL rootElement.Emit(ilg, services); ilg.ValidateLength(); // Emit to an assembly if required if (options.EmitToAssembly) { EmitToAssembly(rootElement, services); } var delegateType = typeof(ExpressionEvaluator <>).MakeGenericType(typeof(T)); this.myEvaluator = (ExpressionEvaluator <T>)dm.CreateDelegate(delegateType); }