internal GroupPartitionInfo( GroupPartitionExpr groupPartitionExpr, ErrorContext errCtx, GroupAggregateInfo containingAggregate, ScopeRegion definingScopeRegion) : base(GroupAggregateKind.Partition, groupPartitionExpr, errCtx, containingAggregate, definingScopeRegion) { Debug.Assert(groupPartitionExpr != null, "groupPartitionExpr != null"); }
internal GroupPartitionInfo( GroupPartitionExpr groupPartitionExpr, ErrorContext errCtx, GroupAggregateInfo containingAggregate, ScopeRegion definingScopeRegion) : base(GroupAggregateKind.Partition, groupPartitionExpr, errCtx, containingAggregate, definingScopeRegion) { DebugCheck.NotNull(groupPartitionExpr); }
internal GroupKeyAggregateInfo( GroupAggregateKind aggregateKind, ErrorContext errCtx, GroupAggregateInfo containingAggregate, ScopeRegion definingScopeRegion) : base(aggregateKind, (GroupAggregateExpr)null, errCtx, containingAggregate, definingScopeRegion) { }
internal GroupPartitionInfo( GroupPartitionExpr groupPartitionExpr, ErrorContext errCtx, GroupAggregateInfo containingAggregate, ScopeRegion definingScopeRegion) : base(GroupAggregateKind.Partition, (GroupAggregateExpr)groupPartitionExpr, errCtx, containingAggregate, definingScopeRegion) { }
internal FunctionAggregateInfo( MethodExpr methodExpr, ErrorContext errCtx, GroupAggregateInfo containingAggregate, ScopeRegion definingScopeRegion) : base(GroupAggregateKind.Function, (GroupAggregateExpr)methodExpr, errCtx, containingAggregate, definingScopeRegion) { }
internal void UpdateScopeIndex(int referencedScopeIndex, SemanticResolver sr) { ScopeRegion definingScopeRegion = sr.GetDefiningScopeRegion(referencedScopeIndex); if (this._innermostReferencedScopeRegion != null && this._innermostReferencedScopeRegion.ScopeRegionIndex >= definingScopeRegion.ScopeRegionIndex) { return; } this._innermostReferencedScopeRegion = definingScopeRegion; }
protected GroupAggregateInfo( GroupAggregateKind aggregateKind, GroupAggregateExpr astNode, ErrorContext errCtx, GroupAggregateInfo containingAggregate, ScopeRegion definingScopeRegion) { this.AggregateKind = aggregateKind; this.AstNode = astNode; this.ErrCtx = errCtx; this.DefiningScopeRegion = definingScopeRegion; this.SetContainingAggregate(containingAggregate); }
private DbExpression GetExpressionFromScopeEntry( ScopeEntry scopeEntry, int scopeIndex, string varName, ErrorContext errCtx) { DbExpression dbExpression = scopeEntry.GetExpression(varName, errCtx); if (this._currentGroupAggregateInfo != null) { ScopeRegion definingScopeRegion = this.GetDefiningScopeRegion(scopeIndex); if (definingScopeRegion.ScopeRegionIndex <= this._currentGroupAggregateInfo.DefiningScopeRegion.ScopeRegionIndex) { this._currentGroupAggregateInfo.UpdateScopeIndex(scopeIndex, this); IGroupExpressionExtendedInfo expressionExtendedInfo = scopeEntry as IGroupExpressionExtendedInfo; if (expressionExtendedInfo != null) { GroupAggregateInfo groupAggregateInfo = this._currentGroupAggregateInfo; while (groupAggregateInfo != null && groupAggregateInfo.DefiningScopeRegion.ScopeRegionIndex >= definingScopeRegion.ScopeRegionIndex && groupAggregateInfo.DefiningScopeRegion.ScopeRegionIndex != definingScopeRegion.ScopeRegionIndex) { groupAggregateInfo = groupAggregateInfo.ContainingAggregate; } if (groupAggregateInfo == null || groupAggregateInfo.DefiningScopeRegion.ScopeRegionIndex < definingScopeRegion.ScopeRegionIndex) { groupAggregateInfo = this._currentGroupAggregateInfo; } switch (groupAggregateInfo.AggregateKind) { case GroupAggregateKind.Function: if (expressionExtendedInfo.GroupVarBasedExpression != null) { dbExpression = expressionExtendedInfo.GroupVarBasedExpression; break; } break; case GroupAggregateKind.Partition: if (expressionExtendedInfo.GroupAggBasedExpression != null) { dbExpression = expressionExtendedInfo.GroupAggBasedExpression; break; } break; } } } } return(dbExpression); }
protected GroupAggregateInfo( GroupAggregateKind aggregateKind, GroupAggregateExpr astNode, ErrorContext errCtx, GroupAggregateInfo containingAggregate, ScopeRegion definingScopeRegion) { Debug.Assert(aggregateKind != GroupAggregateKind.None, "aggregateKind != GroupAggregateKind.None"); DebugCheck.NotNull(errCtx); DebugCheck.NotNull(definingScopeRegion); AggregateKind = aggregateKind; AstNode = astNode; ErrCtx = errCtx; DefiningScopeRegion = definingScopeRegion; SetContainingAggregate(containingAggregate); }
/// <summary> /// Enters a new scope region. /// </summary> internal IDisposable EnterScopeRegion() { // // Push new scope (the first scope in the new scope region) // _scopeManager.EnterScope(); // // Create new scope region and push it // var scopeRegion = new ScopeRegion(_scopeManager, CurrentScopeIndex, _scopeRegions.Count); _scopeRegions.Add(scopeRegion); // // Return scope region disposer that rolls back the scope. // return(new Disposer( delegate { Debug.Assert(CurrentScopeRegion == scopeRegion, "Scope region stack is corrupted."); // // Root scope region is permanent. // Debug.Assert(_scopeRegions.Count > 1, "_scopeRegionFlags.Count > 1"); // // Reset aggregate info of AST nodes of aggregates resolved to the CurrentScopeRegion. // CurrentScopeRegion.GroupAggregateInfos.ForEach(groupAggregateInfo => groupAggregateInfo.DetachFromAstNode()); // // Rollback scopes of the region. // CurrentScopeRegion.RollbackAllScopes(); // // Remove the scope region. // _scopeRegions.Remove(CurrentScopeRegion); })); }
internal void ValidateAndComputeEvaluatingScopeRegion(SemanticResolver sr) { this._evaluatingScopeRegion = this._innermostReferencedScopeRegion ?? this.DefiningScopeRegion; if (!this._evaluatingScopeRegion.IsAggregating) { int scopeRegionIndex = this._evaluatingScopeRegion.ScopeRegionIndex; this._evaluatingScopeRegion = (ScopeRegion)null; foreach (ScopeRegion scopeRegion in sr.ScopeRegions.Skip <ScopeRegion>(scopeRegionIndex)) { if (scopeRegion.IsAggregating) { this._evaluatingScopeRegion = scopeRegion; break; } } if (this._evaluatingScopeRegion == null) { throw new EntitySqlException(Strings.GroupVarNotFoundInScope); } } this.ValidateContainedAggregates(this._evaluatingScopeRegion.ScopeRegionIndex, this.DefiningScopeRegion.ScopeRegionIndex); }
internal FunctionAggregateInfo( MethodExpr methodExpr, ErrorContext errCtx, GroupAggregateInfo containingAggregate, ScopeRegion definingScopeRegion) : base(GroupAggregateKind.Function, methodExpr, errCtx, containingAggregate, definingScopeRegion) { DebugCheck.NotNull(methodExpr); }
internal FunctionAggregateInfo( MethodExpr methodExpr, ErrorContext errCtx, GroupAggregateInfo containingAggregate, ScopeRegion definingScopeRegion) : base(GroupAggregateKind.Function, methodExpr, errCtx, containingAggregate, definingScopeRegion) { Debug.Assert(methodExpr != null, "methodExpr != null"); }