private void Compile() { if (DataContext == null) { throw ExceptionBuilder.PropertyNotInitialized("DataContext"); } if (Text == null || Text.Length == 0) { throw ExceptionBuilder.PropertyNotInitialized("Text"); } // Compile expression ClearCompiledState(); Compiler compiler = new Compiler(_errorCollector); ExpressionNode expressionNode = compiler.CompileExpression(Text, _targetType, Scope); if (_errorCollector.ErrorsSeen) { IList <CompilationError> errors = _errorCollector.GetErrors(); OnCompilationFailed(new CompilationFailedEventArgs(errors)); throw ExceptionBuilder.ExpressionCompilationFailed(errors); } OnCompilationSucceeded(EventArgs.Empty); _runtimeExpression = ExpressionCompiler.CreateCompiled(expressionNode); ILEmitContext.CompleteILCompilation(); }
private RuntimeExpression CreateRuntimeExpression(ExpressionNode expression, params BoundRowBufferEntrySet[] boundRowBufferEntrySets) { // Update row buffer references List <BoundRowBufferEntrySet> boundRowBufferEntrySetList = new List <BoundRowBufferEntrySet>(); boundRowBufferEntrySetList.AddRange(boundRowBufferEntrySets); foreach (BoundRowBufferEntrySet outerreferenceBoundRowBufferEntrySet in _outerReferenceStack) { boundRowBufferEntrySetList.Add(outerreferenceBoundRowBufferEntrySet); } boundRowBufferEntrySets = boundRowBufferEntrySetList.ToArray(); RowBufferEntryExpressionUpdater rowBufferEntryExpressionUpdater = new RowBufferEntryExpressionUpdater(boundRowBufferEntrySets); expression = rowBufferEntryExpressionUpdater.VisitExpression(expression); #if COMPILE_IL return(ExpressionCompiler.CreateCompiled(expression)); #else return(ExpressionCompiler.CreateInterpreded(expression)); #endif }