public UngroupedAndUnaggregatedColumnFinder(ExpressionNode[] groupByExpressions)
        {
            _groupByExpressions = groupByExpressions;

            // Special handling for the case the user entered something like this:
            //
            // SELECT	*
            // FROM		Employees e
            // GROUP	BY e
            //
            // In this case, all columns from e are implicitly grouped.

            if (_groupByExpressions == null)
            {
                _groupedTableRefs = new TableRefBinding[0];
            }
            else
            {
                List<TableRefBinding> groupedTableRefList = new List<TableRefBinding>();

                foreach (ExpressionNode groupByExpression in _groupByExpressions)
                {
                    ColumnExpression exprAsColumn = groupByExpression as ColumnExpression;

                    if (exprAsColumn != null && exprAsColumn.Column.ColumnBinding is RowColumnBinding)
                    {
                        TableRefBinding groupedTableRef = exprAsColumn.Column.TableRefBinding;
                        if (!groupedTableRefList.Contains(groupedTableRef))
                            groupedTableRefList.Add(groupedTableRef);
                    }
                }

                _groupedTableRefs = groupedTableRefList.ToArray();
            }
        }
Ejemplo n.º 2
0
		public FunctionInvocationExpression(Identifier identifier, ExpressionNode[] arguments, bool hasStarModifier)
			: this()
		{
			_name = identifier;
			_arguments = arguments;
			_hasAsteriskModifier = hasStarModifier;
		}
Ejemplo n.º 3
0
		public CastExpression(ExpressionNode expression, Type targetType)
		{			
			_expression = expression;
			_typeReference = new TypeReference();
			_typeReference.TypeName = targetType.AssemblyQualifiedName;
			_typeReference.ResolvedType = targetType;
		}
Ejemplo n.º 4
0
		private static AlgebraNode WrapWithFilter(AlgebraNode input, ExpressionNode predicate)
		{
			if (predicate == null)
				return input;

			FilterAlgebraNode filterAlgebraNode = new FilterAlgebraNode();
			filterAlgebraNode.Input = input;
			filterAlgebraNode.Predicate = predicate;
			return filterAlgebraNode;
		}
Ejemplo n.º 5
0
		private static bool AndPartHasOuterReference(ExpressionNode andPart, RowBufferEntry[] definedValues)
		{
			RowBufferEntry[] rowBufferEntries = AstUtil.GetRowBufferEntryReferences(andPart);
			foreach (RowBufferEntry rowBufferEntry in rowBufferEntries)
			{
				if (!ArrayHelpers.Contains(definedValues, rowBufferEntry))
					return true;
			}

			return false;
		}
Ejemplo n.º 6
0
		public static int FindStructuralEquivalentExpression(ExpressionNode[] expressions, ExpressionNode expr)
		{
			for (int i = 0; i < expressions.Length; i++)
			{
				ExpressionNode node = expressions[i];

				if (node.IsStructuralEqualTo(expr))
					return i;
			}

			return -1;
		}
Ejemplo n.º 7
0
		private static bool NeedParentheses(ExpressionNode childExpression, int parentPrecedence, bool isRightOperand)
		{
			// If childExpression is also an operator expression we may need parentheses.
			//
			// This depends on the precedence and associativity of the child operator.
			// Since we have unary, binary and ternary operators we extract theses pieces
			// of information using casts.

			int childPrecedence;
			bool isRightAssociative;

			OperatorExpression expressionOperatorExpression = childExpression as OperatorExpression;

			if (expressionOperatorExpression != null)
			{
				// It is a binary or unary operator.

				childPrecedence = expressionOperatorExpression.Op.Precedence;
				isRightAssociative = expressionOperatorExpression.Op.IsRightAssociative;
			}
			else
			{
				// Special handling for the only ternary operator.

				BetweenExpression expressionAsBetweenExpression = childExpression as BetweenExpression;

				if (expressionAsBetweenExpression != null)
				{
					childPrecedence = Operator.BETWEEN_PRECEDENCE;
					isRightAssociative = false;
				}
				else
				{
					return false;
				}
			}

			// Analyze precedences.

			if (childPrecedence < parentPrecedence)
				return true;

			if (childPrecedence == parentPrecedence)
			{
				if (isRightOperand && !isRightAssociative)
					return true;

				if (!isRightOperand && isRightAssociative)
					return true;
			}

			return false;
		}
Ejemplo n.º 8
0
		private static bool SemiJoinDoesNotDependOn(JoinAlgebraNode.JoinOperator op, ExpressionNode part, RowBufferEntry[] leftDefinedValues, RowBufferEntry[] rightDefinedValues)
		{
			if (op == JoinAlgebraNode.JoinOperator.LeftSemiJoin ||
				op == JoinAlgebraNode.JoinOperator.LeftAntiSemiJoin)
			{
				return AstUtil.ExpressionDoesNotReference(part, rightDefinedValues);
			}

			if (op == JoinAlgebraNode.JoinOperator.RightSemiJoin ||
				op == JoinAlgebraNode.JoinOperator.RightAntiSemiJoin)
			{
				return AstUtil.ExpressionDoesNotReference(part, leftDefinedValues);
			}

			return true;
		}
Ejemplo n.º 9
0
		public static RuntimeExpression CreateCompiled(ExpressionNode expressionNode)
		{
			string expressionSource = expressionNode.GenerateSource();
			ILEmitContext ilEmitContext = new ILEmitContext(expressionSource);
			
			ILParameterRegisterer ilParameterRegisterer = new ILParameterRegisterer(ilEmitContext);
			ilParameterRegisterer.Visit(expressionNode);

			ILTranslator ilTranslator = new ILTranslator(ilEmitContext);
			ilTranslator.Visit(expressionNode);

			CompiledExpressionDelegate compiledExpressionDelegate = ilEmitContext.CreateDelegate();
			object[] arguments = ilEmitContext.GetArguments();

			return new CompiledRuntimeExpression(expressionSource, expressionNode.ExpressionType, compiledExpressionDelegate, arguments);
		}
Ejemplo n.º 10
0
		public UnaryExpression(UnaryOperator op, ExpressionNode operand)
		{
			_op = op;
			_operand = operand;
		}
Ejemplo n.º 11
0
 void IErrorReporter.AggregateContainsColumnsFromDifferentQueries(ExpressionNode aggregateArgument)
 {
     string message = String.Format(CultureInfo.CurrentCulture, Resources.AggregateContainsColumnsFromDifferentQueries, aggregateArgument.GenerateSource());
     HandleError(ErrorId.AggregateContainsColumnsFromDifferentQueries, message);
 }
Ejemplo n.º 12
0
		public OrderByColumn(ExpressionNode expression, SortOrder sortOrder)
			: this()
		{
			_expression = expression;
			_sortOrder = sortOrder;
		}
Ejemplo n.º 13
0
	    private ExpressionNode ResolveExpression(ExpressionNode expressionBeforeDot)
	    {
	        ExpressionNode resolvedExpression = _normalizer.VisitExpression(expressionBeforeDot);
	        return _resolver.VisitExpression(resolvedExpression);
	    }
Ejemplo n.º 14
0
        private ExpressionNode ParsePrimaryExpression()
        {
            switch (_token.Id)
            {
                case TokenId.NULL:
                    NextToken();
                    return LiteralExpression.FromNull();

                case TokenId.TRUE:
                case TokenId.FALSE:
                    return ParseBooleanLiteral();

                case TokenId.Date:
                    return ParseDateLiteral();

                case TokenId.Number:
                    return ParseNumberLiteral();

                case TokenId.String:
                    return LiteralExpression.FromString(ParseString());

                case TokenId.EXISTS:
                {
                    ExistsSubselect result = new ExistsSubselect();
                    NextToken();
                    Match(TokenId.LeftParentheses);
                    result.Query = ParseQuery();
                    Match(TokenId.RightParentheses);

                    return result;
                }

                case TokenId.ParameterMarker:
                {
                    _rangeRecorder.Begin();
                    NextToken();
                    Identifier name = ParseIdentifier();
                    SourceRange nameSourceRange = _rangeRecorder.End();

                    ParameterExpression result = new ParameterExpression();
                    result.Name = name;
                    result.NameSourceRange = nameSourceRange;
                    return result;
                }

                case TokenId.CAST:
                {
                    NextToken();
                    CastExpression castExpression = new CastExpression();
                    Match(TokenId.LeftParentheses);
                    castExpression.Expression = ParseExpression();
                    Match(TokenId.AS);
                    castExpression.TypeReference = ParseTypeReference();
                    Match(TokenId.RightParentheses);

                    return castExpression;
                }

                case TokenId.CASE:
                {
                    NextToken();

                    CaseExpression caseExpression = new CaseExpression();

                    if (_token.Id != TokenId.WHEN && _token.Id != TokenId.ELSE && _token.Id != TokenId.END)
                        caseExpression.InputExpression = ParseExpression();

                    List<ExpressionNode> whenExpressionList = new List<ExpressionNode>();
                    List<ExpressionNode> expressionList = new List<ExpressionNode>();

                    if (_token.Id != TokenId.WHEN)
                    {
                        Match(TokenId.WHEN);
                    }
                    else
                    {
                        while (_token.Id == TokenId.WHEN)
                        {
                            NextToken();

                            whenExpressionList.Add(ParseExpression());
                            Match(TokenId.THEN);
                            expressionList.Add(ParseExpression());
                        }
                    }

                    caseExpression.WhenExpressions = whenExpressionList.ToArray();
                    caseExpression.ThenExpressions = expressionList.ToArray();

                    if (_token.Id == TokenId.ELSE)
                    {
                        NextToken();
                        caseExpression.ElseExpression = ParseExpression();
                    }

                    Match(TokenId.END);

                    return caseExpression;
                }

                case TokenId.COALESCE:
                {
                    NextToken();
                    CoalesceExpression coalesceExpression = new CoalesceExpression();
                    coalesceExpression.Expressions = ParseExpressionList();
                    return coalesceExpression;
                }

                case TokenId.NULLIF:
                {
                    NextToken();
                    NullIfExpression nullIfExpression = new NullIfExpression();
                    Match(TokenId.LeftParentheses);
                    nullIfExpression.LeftExpression = ParseExpression();
                    Match(TokenId.Comma);
                    nullIfExpression.RightExpression = ParseExpression();
                    Match(TokenId.RightParentheses);
                    return nullIfExpression;
                }

                case TokenId.Identifier:
                {
                    _rangeRecorder.Begin();
                    Identifier name = ParseIdentifier();
                    SourceRange nameSourceRange = _rangeRecorder.End();

                    if (_token.Id != TokenId.LeftParentheses)
                    {
                        NameExpression result = new NameExpression();
                        result.Name = name;
                        result.NameSourceRange = nameSourceRange;
                        return result;
                    }
                    else
                    {
                        bool hasAsteriskModifier;
                        ExpressionNode[] args;

                        if (_lookahead.Id != TokenId.Multiply)
                        {
                            hasAsteriskModifier = false;
                            args = ParseExpressionList();
                        }
                        else
                        {
                            NextToken();
                            NextToken();
                            Match(TokenId.RightParentheses);

                            hasAsteriskModifier = true;
                            args = new ExpressionNode[0];
                        }

                        FunctionInvocationExpression result = new FunctionInvocationExpression();
                        result.Name = name;
                        result.NameSourceRange = nameSourceRange;
                        result.Arguments = args;
                        result.HasAsteriskModifier = hasAsteriskModifier;
                        return result;
                    }
                }

                case TokenId.LeftParentheses:
                {
                    NextToken();

                    ExpressionNode expr;

                    if (_token.Id != TokenId.SELECT)
                    {
                        expr = ParseExpression();
                    }
                    else
                    {
                        SingleRowSubselect singleRowSubselect = new SingleRowSubselect();
                        singleRowSubselect.Query = ParseQuery();
                        expr = singleRowSubselect;
                    }

                    Match(TokenId.RightParentheses);
                    return expr;
                }

                default:
                {
                    _errorReporter.SimpleExpressionExpected(_token.Range, _token.Text);
                    return LiteralExpression.FromNull();
                }
            }
        }
Ejemplo n.º 15
0
		public static ExpressionNode[] SplitCondition(LogicalOperator logicalOperator, ExpressionNode condition)
		{
			PartExtractor partExtractor = new PartExtractor(logicalOperator);
			partExtractor.Visit(condition);
			return partExtractor.GetParts();
		}
Ejemplo n.º 16
0
        private void EmitCall(MethodInfo method, ExpressionNode instance, params ExpressionNode[] args)
        {
            ParameterInfo[] parameterInfos     = method.GetParameters();
            int             instanceLocalIndex = -1;

            if (instance != null)
            {
                instanceLocalIndex = DeclareLocal();
            }

            int[] argLocalIndexes = new int[args.Length];

            for (int i = 0; i < args.Length; i++)
            {
                argLocalIndexes[i] = DeclareLocal();
            }

            if (instance != null)
            {
                Visit(instance);
                _ilEmitContext.ILGenerator.Emit(OpCodes.Stloc, instanceLocalIndex);
            }

            for (int i = 0; i < args.Length; i++)
            {
                Visit(args[i]);
                _ilEmitContext.ILGenerator.Emit(OpCodes.Stloc, argLocalIndexes[i]);
            }

            Label loadNullLabel = _ilEmitContext.ILGenerator.DefineLabel();
            Label finishLabel   = _ilEmitContext.ILGenerator.DefineLabel();

            if (instance != null)
            {
                _ilEmitContext.ILGenerator.Emit(OpCodes.Ldloc, instanceLocalIndex);
                _ilEmitContext.ILGenerator.Emit(OpCodes.Brfalse, loadNullLabel);
            }

            for (int i = 0; i < args.Length; i++)
            {
                _ilEmitContext.ILGenerator.Emit(OpCodes.Ldloc, argLocalIndexes[i]);
                _ilEmitContext.ILGenerator.Emit(OpCodes.Brfalse, loadNullLabel);
            }

            if (instance != null)
            {
                _ilEmitContext.ILGenerator.Emit(OpCodes.Ldloc, instanceLocalIndex);
                EmitThisArgumentPointer(instance.ExpressionType);
            }

            for (int i = 0; i < args.Length; i++)
            {
                _ilEmitContext.ILGenerator.Emit(OpCodes.Ldloc, argLocalIndexes[i]);
                if (parameterInfos[i].ParameterType != typeof(object))
                {
                    EmitConversion(parameterInfos[i].ParameterType);
                }
            }

            EmitRawCall(method, instance == null ? null : instance.ExpressionType);

            if (method.ReturnType.IsValueType)
            {
                _ilEmitContext.ILGenerator.Emit(OpCodes.Box, method.ReturnType);
            }
            _ilEmitContext.ILGenerator.Emit(OpCodes.Br, finishLabel);

            _ilEmitContext.ILGenerator.MarkLabel(loadNullLabel);
            _ilEmitContext.ILGenerator.Emit(OpCodes.Ldnull);

            _ilEmitContext.ILGenerator.MarkLabel(finishLabel);
        }
Ejemplo n.º 17
0
 public static RuntimeExpression CreateInterpreded(ExpressionNode expressionNode)
 {
     return(new InterpretedRuntimeExpression(expressionNode));
 }
Ejemplo n.º 18
0
			public InterpretedRuntimeExpression(ExpressionNode expressionNode)
			{
				_expressionNode = expressionNode;
			}
Ejemplo n.º 19
0
		public static RuntimeExpression CreateInterpreded(ExpressionNode expressionNode)
		{
			return new InterpretedRuntimeExpression(expressionNode);
		}
Ejemplo n.º 20
0
        public override ExpressionNode VisitCaseExpression(CaseExpression expression)
        {
            // NOTE: It is assumed that simple case expressions are already transformed into
            //       searched case expressions, i.e.
            //       CASE
            //          WHEN Pred1 THEN Expr1 ...
            //          WHEN PredN THEN ExprN
            //          [ELSE ElseExpr]
            //       END

            List<ExpressionNode> processedWhenExpressions = new List<ExpressionNode>();

            for (int i = 0; i < expression.WhenExpressions.Length; i++)
            {
                SetWhenPassthru(processedWhenExpressions);
                expression.WhenExpressions[i] = VisitExpression(expression.WhenExpressions[i]);
                processedWhenExpressions.Add(expression.WhenExpressions[i]);

                SetThenPassthru(processedWhenExpressions);
                expression.ThenExpressions[i] = VisitExpression(expression.ThenExpressions[i]);
            }

            if (expression.ElseExpression != null)
            {
                SetWhenPassthru(processedWhenExpressions);
                expression.ElseExpression = VisitExpression(expression.ElseExpression);
            }

            _currentPassthruPredicate = null;

            return expression;
        }
Ejemplo n.º 21
0
 void IErrorReporter.CannotCast(ExpressionNode expression, Type targetType)
 {
     string message = String.Format(CultureInfo.CurrentCulture, Resources.CannotCast, expression.GenerateSource(), FormattingHelpers.FormatType(expression.ExpressionType), FormattingHelpers.FormatType(targetType));
     HandleError(ErrorId.CannotCast, message);
 }
Ejemplo n.º 22
0
 void IErrorReporter.AsteriskModifierNotAllowed(SourceRange sourceRange, ExpressionNode functionInvocation)
 {
     string message = String.Format(CultureInfo.CurrentCulture, Resources.AsteriskModifierNotAllowed, functionInvocation.GenerateSource());
     HandleError(sourceRange, ErrorId.AsteriskModifierNotAllowed, message);
 }
Ejemplo n.º 23
0
 public void Push(ExpressionNode expression)
 {
     _expressionStack.Push(expression);
 }
Ejemplo n.º 24
0
		public static bool IsNull(ExpressionNode expression)
		{
			ConstantExpression constantExpression = expression as ConstantExpression;
			return (constantExpression != null && constantExpression.IsNullValue);
		}
Ejemplo n.º 25
0
        private void SetWhenPassthru(ICollection<ExpressionNode> processedWhenExpressions)
        {
            if (processedWhenExpressions.Count == 0)
            {
                _currentPassthruPredicate = null;
            }
            else
            {
                foreach (ExpressionNode processedWhenExpression in processedWhenExpressions)
                {
                    ExpressionNode clonedExpr = (ExpressionNode) processedWhenExpression.Clone();
                    _expressionBuilder.Push(clonedExpr);
                }

                _expressionBuilder.PushNAry(LogicalOperator.Or);
                _currentPassthruPredicate = _expressionBuilder.Pop();
            }
        }
Ejemplo n.º 26
0
 void IErrorReporter.WhenMustEvaluateToBoolIfCaseInputIsOmitted(ExpressionNode whenExpression)
 {
     string message = String.Format(CultureInfo.CurrentCulture, Resources.WhenMustEvaluateToBoolIfCaseInputIsOmitted, whenExpression.GenerateSource(), FormattingHelpers.FormatType(typeof(bool)));
     HandleError(ErrorId.WhenMustEvaluateToBoolIfCaseInputIsOmitted, message);
 }
Ejemplo n.º 27
0
		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
		}
Ejemplo n.º 28
0
 private static ExpressionNode ReplaceAlreadyComputedSubsequences(ExpressionNode expression, IEnumerable<ComputedValueDefinition> alreadyComputedBufferedValues)
 {
     ComputedSubsequenceReplacer replacer = new ComputedSubsequenceReplacer(alreadyComputedBufferedValues);
     return replacer.VisitExpression(expression);
 }
Ejemplo n.º 29
0
		public IsNullExpression(bool negated, ExpressionNode expression)
		{
			_negated = negated;
			_expression = expression;
		}
Ejemplo n.º 30
0
 public UnaryExpression(UnaryOperator op, ExpressionNode operand)
 {
     _op      = op;
     _operand = operand;
 }
Ejemplo n.º 31
0
		public SelectColumn(ExpressionNode expression, Identifier columnAlias)
		{
			_expression = expression;
			_alias = columnAlias;
		}
Ejemplo n.º 32
0
        private ExpressionNode ParseSubExpression(ExpressionNode left, int precedence)
        {
            if (left == null)
            {
                // No left operand, so we parse one and take care about leading unary operators

                if (_token.Info.UnaryOperator != null)
                {
                    UnaryOperator op = _token.Info.UnaryOperator;

                    NextToken();

                    ExpressionNode expr = ParseSubExpression(null, op.Precedence);
                    left = new UnaryExpression(op, expr);
                }
                else
                {
                    left = ParseSimpleExpression();
                }
            }

            while (_token.Id != TokenId.Eof)
            {
                // Special handling for NOT BETWEEN, NOT IN, NOT LIKE, NOT SIMILAR TO, and NOT SOUNDSLIKE.

                bool negated = false;

                if (_token.Id == TokenId.NOT)
                {
                    if (_lookahead.Id == TokenId.BETWEEN ||
                        _lookahead.Id == TokenId.IN ||
                        _lookahead.Id == TokenId.LIKE ||
                        _lookahead.Id == TokenId.SIMILAR ||
                        _lookahead.Id == TokenId.SOUNDSLIKE)
                    {
                        NextToken();
                        negated = true;
                    }
                }

                // Special handling for the only ternary operator BETWEEN

                if (_token.Id == TokenId.BETWEEN)
                {
                    NextToken();
                    ExpressionNode lowerBound = ParseSubExpression(null, Operator.BETWEEN_PRECEDENCE);
                    Match(TokenId.AND);
                    ExpressionNode upperBound = ParseSubExpression(null, Operator.BETWEEN_PRECEDENCE);

                    left = new BetweenExpression(left, lowerBound, upperBound);
                }
                else
                {
                    // If there is no binary operator we are finished

                    if (_token.Info.BinaryOperator == null)
                        break;

                    BinaryOperator binaryOp = _token.Info.BinaryOperator;

                    // Precedence is lower, parse it later

                    if (binaryOp.Precedence < precedence)
                        break;

                    // Precedence is equal, but operator ist not right associative, parse it later

                    if (binaryOp.Precedence == precedence && !binaryOp.IsRightAssociative)
                        break;

                    // Precedence is higher

                    NextToken();

                    // Special handling for SIMILAR TO

                    if (binaryOp == BinaryOperator.SimilarTo)
                        Match(TokenId.TO);

                    if (binaryOp == BinaryOperator.In)
                    {
                        // Special handling for IN

                        InExpression inExpression = new InExpression();
                        inExpression.Left = left;
                        inExpression.RightExpressions = ParseSimpleQueryExpressionList();
                        left = inExpression;
                    }
                    else if (_token.Id == TokenId.ANY || _token.Id == TokenId.SOME || _token.Id == TokenId.ALL)
                    {
                        // Special handling for ANY (SOME) and ALL

                        if (binaryOp != BinaryOperator.Equal &&
                            binaryOp != BinaryOperator.NotEqual &&
                            binaryOp != BinaryOperator.Less &&
                            binaryOp != BinaryOperator.LessOrEqual &&
                            binaryOp != BinaryOperator.Greater &&
                            binaryOp != BinaryOperator.GreaterOrEqual)
                        {
                            _errorReporter.InvalidOperatorForAllAny(_token.Range, binaryOp);
                        }

                        AllAnySubselect allAnySubselect = new AllAnySubselect();
                        allAnySubselect.Left = left;
                        allAnySubselect.Op = binaryOp;
                        allAnySubselect.Type = (_token.Id == TokenId.ALL) ? AllAnySubselect.AllAnyType.All : AllAnySubselect.AllAnyType.Any;
                        NextToken();
                        Match(TokenId.LeftParentheses);
                        allAnySubselect.Query = ParseQuery();
                        Match(TokenId.RightParentheses);
                        left = allAnySubselect;
                    }
                    else
                    {
                        left = new BinaryExpression(binaryOp, left, ParseSubExpression(null, binaryOp.Precedence));
                    }
                }

                // Special handling for negated expressions (see above)

                if (negated)
                    left = new UnaryExpression(UnaryOperator.LogicalNot, left);
            }

            return left;
        }
Ejemplo n.º 33
0
        private static void CreateBufferedValue(ExpressionNode expression, ICollection<ComputedValueDefinition> computedColumnList, ICollection<RowBufferEntry> columnList, IEnumerable<ComputedValueDefinition> alreadyComputedBufferedValues)
        {
            if (alreadyComputedBufferedValues != null)
                expression = ReplaceAlreadyComputedSubsequences(expression, alreadyComputedBufferedValues);

            foreach (ComputedValueDefinition computedBufferedValue in computedColumnList)
            {
                if (expression.IsStructuralEqualTo(computedBufferedValue.Expression))
                {
                    columnList.Add(computedBufferedValue.Target);
                    return;
                }
            }

            RowBufferEntryExpression rowBufferExpression = expression as RowBufferEntryExpression;
            if (rowBufferExpression != null)
            {
                columnList.Add(rowBufferExpression.RowBufferEntry);
            }
            else
            {
                RowBufferEntry rowBufferEntry = new RowBufferEntry(expression.ExpressionType);
                columnList.Add(rowBufferEntry);

                ComputedValueDefinition computedValue = new ComputedValueDefinition();
                computedValue.Target = rowBufferEntry;
                computedValue.Expression = expression;
                computedColumnList.Add(computedValue);
            }
        }
Ejemplo n.º 34
0
 public InterpretedRuntimeExpression(ExpressionNode expressionNode)
 {
     _expressionNode = expressionNode;
 }