You've already forked linux-packaging-mono
Imported Upstream version 4.6.0.125
Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
This commit is contained in:
parent
a569aebcfd
commit
e79aa3c0ed
@@ -0,0 +1,63 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="AliasedExpr.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
namespace System.Data.Common.EntitySql.AST
|
||||
{
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
/// <summary>
|
||||
/// AST node for an aliased expression.
|
||||
/// </summary>
|
||||
internal sealed class AliasedExpr : Node
|
||||
{
|
||||
private readonly Node _expr;
|
||||
private readonly Identifier _alias;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs an aliased expression node.
|
||||
/// </summary>
|
||||
internal AliasedExpr(Node expr, Identifier alias)
|
||||
{
|
||||
Debug.Assert(expr != null, "expr != null");
|
||||
Debug.Assert(alias != null, "alias != null");
|
||||
|
||||
if (String.IsNullOrEmpty(alias.Name))
|
||||
{
|
||||
throw EntityUtil.EntitySqlError(alias.ErrCtx, System.Data.Entity.Strings.InvalidEmptyIdentifier);
|
||||
}
|
||||
|
||||
_expr = expr;
|
||||
_alias = alias;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs an aliased expression node with null alias.
|
||||
/// </summary>
|
||||
internal AliasedExpr(Node expr)
|
||||
{
|
||||
Debug.Assert(expr != null, "expr != null");
|
||||
|
||||
_expr = expr;
|
||||
}
|
||||
|
||||
internal Node Expr
|
||||
{
|
||||
get { return _expr; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns expression alias identifier, or null if not aliased.
|
||||
/// </summary>
|
||||
internal Identifier Alias
|
||||
{
|
||||
get { return _alias; }
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,104 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="AstNode.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
namespace System.Data.Common.EntitySql.AST
|
||||
{
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
/// <summary>
|
||||
/// Represents base class for nodes in the eSQL abstract syntax tree OM.
|
||||
/// </summary>
|
||||
internal abstract class Node
|
||||
{
|
||||
private ErrorContext _errCtx = new ErrorContext();
|
||||
|
||||
internal Node() { }
|
||||
|
||||
internal Node(string commandText, int inputPosition)
|
||||
{
|
||||
_errCtx.CommandText = commandText;
|
||||
_errCtx.InputPosition = inputPosition;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ast Node error context.
|
||||
/// </summary>
|
||||
internal ErrorContext ErrCtx
|
||||
{
|
||||
get { return _errCtx; }
|
||||
set { _errCtx = value; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An ast node represents a generic list of ast nodes.
|
||||
/// </summary>
|
||||
internal sealed class NodeList<T> : Node, System.Collections.Generic.IEnumerable<T>
|
||||
where T : Node
|
||||
{
|
||||
private readonly List<T> _list = new List<T>();
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor.
|
||||
/// </summary>
|
||||
internal NodeList()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes adding one item to the list.
|
||||
/// </summary>
|
||||
/// <param name="item">expression</param>
|
||||
internal NodeList(T item)
|
||||
{
|
||||
_list.Add(item);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add an item to the list, return the updated list.
|
||||
/// </summary>
|
||||
internal NodeList<T> Add(T item)
|
||||
{
|
||||
_list.Add(item);
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the number of elements in the list.
|
||||
/// </summary>
|
||||
internal int Count
|
||||
{
|
||||
get { return _list.Count; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indexer to the list entries.
|
||||
/// </summary>
|
||||
/// <param name="index">integer position of the element in the list</param>
|
||||
internal T this[int index]
|
||||
{
|
||||
get { return _list[index]; }
|
||||
}
|
||||
|
||||
#region GetEnumerator
|
||||
System.Collections.Generic.IEnumerator<T> System.Collections.Generic.IEnumerable<T>.GetEnumerator()
|
||||
{
|
||||
return _list.GetEnumerator();
|
||||
}
|
||||
|
||||
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
|
||||
{
|
||||
return _list.GetEnumerator();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,123 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="BuiltInExpr.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
namespace System.Data.Common.EntitySql.AST
|
||||
{
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
/// <summary>
|
||||
/// Defines the function class of builtin expressions.
|
||||
/// </summary>
|
||||
internal enum BuiltInKind
|
||||
{
|
||||
And,
|
||||
Or,
|
||||
Not,
|
||||
|
||||
Cast,
|
||||
OfType,
|
||||
Treat,
|
||||
IsOf,
|
||||
|
||||
Union,
|
||||
UnionAll,
|
||||
Intersect,
|
||||
Overlaps,
|
||||
AnyElement,
|
||||
Element,
|
||||
Except,
|
||||
Exists,
|
||||
Flatten,
|
||||
In,
|
||||
NotIn,
|
||||
Distinct,
|
||||
|
||||
IsNull,
|
||||
IsNotNull,
|
||||
|
||||
Like,
|
||||
|
||||
Equal,
|
||||
NotEqual,
|
||||
LessEqual,
|
||||
LessThan,
|
||||
GreaterThan,
|
||||
GreaterEqual,
|
||||
|
||||
Plus,
|
||||
Minus,
|
||||
Multiply,
|
||||
Divide,
|
||||
Modulus,
|
||||
UnaryMinus,
|
||||
UnaryPlus,
|
||||
|
||||
Between,
|
||||
NotBetween
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a builtin expression ast node.
|
||||
/// </summary>
|
||||
internal sealed class BuiltInExpr : Node
|
||||
{
|
||||
private BuiltInExpr(BuiltInKind kind, string name)
|
||||
{
|
||||
Kind = kind;
|
||||
Name = name.ToUpperInvariant();
|
||||
}
|
||||
|
||||
internal BuiltInExpr(BuiltInKind kind, string name, Node arg1)
|
||||
: this(kind, name)
|
||||
{
|
||||
ArgCount = 1;
|
||||
Arg1 = arg1;
|
||||
}
|
||||
|
||||
internal BuiltInExpr(BuiltInKind kind, string name, Node arg1, Node arg2)
|
||||
: this(kind, name)
|
||||
{
|
||||
ArgCount = 2;
|
||||
Arg1 = arg1;
|
||||
Arg2 = arg2;
|
||||
}
|
||||
|
||||
internal BuiltInExpr(BuiltInKind kind, string name, Node arg1, Node arg2, Node arg3)
|
||||
: this(kind, name)
|
||||
{
|
||||
ArgCount = 3;
|
||||
Arg1 = arg1;
|
||||
Arg2 = arg2;
|
||||
Arg3 = arg3;
|
||||
}
|
||||
|
||||
internal BuiltInExpr(BuiltInKind kind, string name, Node arg1, Node arg2, Node arg3, Node arg4)
|
||||
: this(kind, name)
|
||||
{
|
||||
ArgCount = 4;
|
||||
Arg1 = arg1;
|
||||
Arg2 = arg2;
|
||||
Arg3 = arg3;
|
||||
Arg4 = arg4;
|
||||
}
|
||||
|
||||
internal readonly BuiltInKind Kind;
|
||||
internal readonly string Name;
|
||||
|
||||
internal readonly int ArgCount;
|
||||
internal readonly Node Arg1;
|
||||
internal readonly Node Arg2;
|
||||
internal readonly Node Arg3;
|
||||
internal readonly Node Arg4;
|
||||
}
|
||||
}
|
@@ -0,0 +1,97 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="CaseExpr.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
namespace System.Data.Common.EntitySql.AST
|
||||
{
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the Seached Case Expression - CASE WHEN THEN [ELSE] END.
|
||||
/// </summary>
|
||||
internal sealed class CaseExpr : Node
|
||||
{
|
||||
private readonly NodeList<WhenThenExpr> _whenThenExpr;
|
||||
private readonly Node _elseExpr;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes case expression without else sub-expression.
|
||||
/// </summary>
|
||||
/// <param name="whenThenExpr">whenThen expression list</param>
|
||||
internal CaseExpr(NodeList<WhenThenExpr> whenThenExpr)
|
||||
: this(whenThenExpr, null)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes case expression with else sub-expression.
|
||||
/// </summary>
|
||||
/// <param name="whenThenExpr">whenThen expression list</param>
|
||||
/// <param name="elseExpr">else expression</param>
|
||||
internal CaseExpr(NodeList<WhenThenExpr> whenThenExpr, Node elseExpr)
|
||||
{
|
||||
_whenThenExpr = whenThenExpr;
|
||||
_elseExpr = elseExpr;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the list of WhenThen expressions.
|
||||
/// </summary>
|
||||
internal NodeList<WhenThenExpr> WhenThenExprList
|
||||
{
|
||||
get { return _whenThenExpr; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the optional Else expression.
|
||||
/// </summary>
|
||||
internal Node ElseExpr
|
||||
{
|
||||
get { return _elseExpr; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents the when then sub expression.
|
||||
/// </summary>
|
||||
internal class WhenThenExpr : Node
|
||||
{
|
||||
private readonly Node _whenExpr;
|
||||
private readonly Node _thenExpr;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes WhenThen sub-expression.
|
||||
/// </summary>
|
||||
/// <param name="whenExpr">When expression</param>
|
||||
/// <param name="thenExpr">Then expression</param>
|
||||
internal WhenThenExpr(Node whenExpr, Node thenExpr)
|
||||
{
|
||||
_whenExpr = whenExpr;
|
||||
_thenExpr = thenExpr;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns When expression.
|
||||
/// </summary>
|
||||
internal Node WhenExpr
|
||||
{
|
||||
get { return _whenExpr; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns Then Expression.
|
||||
/// </summary>
|
||||
internal Node ThenExpr
|
||||
{
|
||||
get { return _thenExpr; }
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,61 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="Command.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
namespace System.Data.Common.EntitySql.AST
|
||||
{
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
/// <summary>
|
||||
/// Represents eSQL command as node.
|
||||
/// </summary>
|
||||
internal sealed class Command : Node
|
||||
{
|
||||
private readonly NodeList<NamespaceImport> _namespaceImportList;
|
||||
private readonly Statement _statement;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes eSQL command.
|
||||
/// </summary>
|
||||
/// <param name="nsDeclList">optional namespace imports</param>
|
||||
/// <param name="statement">command statement</param>
|
||||
internal Command(NodeList<NamespaceImport> nsImportList, Statement statement)
|
||||
{
|
||||
_namespaceImportList = nsImportList;
|
||||
_statement = statement;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns optional namespace imports. May be null.
|
||||
/// </summary>
|
||||
internal NodeList<NamespaceImport> NamespaceImportList
|
||||
{
|
||||
get { return _namespaceImportList; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns command statement.
|
||||
/// </summary>
|
||||
internal Statement Statement
|
||||
{
|
||||
get { return _statement; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents base class for the following statements:
|
||||
/// - QueryStatement
|
||||
/// - InsertStatement
|
||||
/// - UpdateStatement
|
||||
/// - DeleteStatement
|
||||
/// </summary>
|
||||
internal abstract class Statement : Node { }
|
||||
}
|
@@ -0,0 +1,58 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="ConstructorExpr.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
namespace System.Data.Common.EntitySql.AST
|
||||
{
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
/// <summary>
|
||||
/// Represents Row contructor expression.
|
||||
/// </summary>
|
||||
internal sealed class RowConstructorExpr : Node
|
||||
{
|
||||
private readonly NodeList<AliasedExpr> _exprList;
|
||||
|
||||
internal RowConstructorExpr(NodeList<AliasedExpr> exprList)
|
||||
{
|
||||
_exprList = exprList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns list of elements as aliased expressions.
|
||||
/// </summary>
|
||||
internal NodeList<AliasedExpr> AliasedExprList
|
||||
{
|
||||
get { return _exprList; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents multiset constructor expression.
|
||||
/// </summary>
|
||||
internal sealed class MultisetConstructorExpr : Node
|
||||
{
|
||||
private readonly NodeList<Node> _exprList;
|
||||
|
||||
internal MultisetConstructorExpr(NodeList<Node> exprList)
|
||||
{
|
||||
_exprList = exprList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns list of elements as alias expressions.
|
||||
/// </summary>
|
||||
internal NodeList<Node> ExprList
|
||||
{
|
||||
get { return _exprList; }
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,91 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="CreateRefExpr.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
namespace System.Data.Common.EntitySql.AST
|
||||
{
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
/// <summary>
|
||||
/// Represents CREATEREF(entitySet, keys) expression.
|
||||
/// </summary>
|
||||
internal sealed class CreateRefExpr : Node
|
||||
{
|
||||
private readonly Node _entitySet;
|
||||
private readonly Node _keys;
|
||||
private readonly Node _typeIdentifier;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes CreateRefExpr.
|
||||
/// </summary>
|
||||
/// <param name="entitySet">expression representing the entity set</param>
|
||||
internal CreateRefExpr(Node entitySet, Node keys) : this(entitySet, keys, null)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes CreateRefExpr.
|
||||
/// </summary>
|
||||
internal CreateRefExpr(Node entitySet, Node keys, Node typeIdentifier)
|
||||
{
|
||||
_entitySet = entitySet;
|
||||
_keys = keys;
|
||||
_typeIdentifier = typeIdentifier;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the expression for the entity set.
|
||||
/// </summary>
|
||||
internal Node EntitySet
|
||||
{
|
||||
get { return _entitySet; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the expression for the keys.
|
||||
/// </summary>
|
||||
internal Node Keys
|
||||
{
|
||||
get { return _keys; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets optional typeidentifier. May be null.
|
||||
/// </summary>
|
||||
internal Node TypeIdentifier
|
||||
{
|
||||
get { return _typeIdentifier; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents KEY(expr) expression.
|
||||
/// </summary>
|
||||
internal class KeyExpr : Node
|
||||
{
|
||||
private readonly Node _argExpr;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes KEY expression.
|
||||
/// </summary>
|
||||
internal KeyExpr(Node argExpr)
|
||||
{
|
||||
_argExpr = argExpr;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns KEY argument expression.
|
||||
/// </summary>
|
||||
internal Node ArgExpr
|
||||
{
|
||||
get { return _argExpr; }
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,88 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="DotExpr.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
namespace System.Data.Common.EntitySql.AST
|
||||
{
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
/// <summary>
|
||||
/// Represents dotExpr: expr.Identifier
|
||||
/// </summary>
|
||||
internal sealed class DotExpr : Node
|
||||
{
|
||||
private readonly Node _leftExpr;
|
||||
private readonly Identifier _identifier;
|
||||
private bool? _isMultipartIdentifierComputed;
|
||||
private string[] _names;
|
||||
|
||||
/// <summary>
|
||||
/// initializes
|
||||
/// </summary>
|
||||
internal DotExpr(Node leftExpr, Identifier id)
|
||||
{
|
||||
_leftExpr = leftExpr;
|
||||
_identifier = id;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For the following expression: "a.b.c.d", Left returns "a.b.c".
|
||||
/// </summary>
|
||||
internal Node Left
|
||||
{
|
||||
get { return _leftExpr; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For the following expression: "a.b.c.d", Identifier returns "d".
|
||||
/// </summary>
|
||||
internal Identifier Identifier
|
||||
{
|
||||
get { return _identifier; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if all parts of this expression are identifiers like in "a.b.c",
|
||||
/// false for expressions like "FunctionCall().a.b.c".
|
||||
/// </summary>
|
||||
internal bool IsMultipartIdentifier(out string[] names)
|
||||
{
|
||||
if (_isMultipartIdentifierComputed.HasValue)
|
||||
{
|
||||
names = _names;
|
||||
return _isMultipartIdentifierComputed.Value;
|
||||
}
|
||||
|
||||
_names = null;
|
||||
Identifier leftIdenitifier = _leftExpr as Identifier;
|
||||
if (leftIdenitifier != null)
|
||||
{
|
||||
_names = new string[] { leftIdenitifier.Name, _identifier.Name };
|
||||
}
|
||||
|
||||
DotExpr leftDotExpr = _leftExpr as DotExpr;
|
||||
string[] leftNames;
|
||||
if (leftDotExpr != null && leftDotExpr.IsMultipartIdentifier(out leftNames))
|
||||
{
|
||||
_names = new string[leftNames.Length + 1];
|
||||
leftNames.CopyTo(_names, 0);
|
||||
_names[_names.Length - 1] = _identifier.Name;
|
||||
}
|
||||
|
||||
Debug.Assert(_names == null || _names.Length > 0, "_names must be null or non-empty");
|
||||
|
||||
_isMultipartIdentifierComputed = _names != null;
|
||||
names = _names;
|
||||
return _isMultipartIdentifierComputed.Value;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,80 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="FunctionDefinition.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
namespace System.Data.Common.EntitySql.AST
|
||||
{
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
/// <summary>
|
||||
/// Represents an ast node for an inline function definition.
|
||||
/// </summary>
|
||||
internal sealed class FunctionDefinition : Node
|
||||
{
|
||||
private readonly Identifier _name;
|
||||
private readonly NodeList<PropDefinition> _paramDefList;
|
||||
private readonly Node _body;
|
||||
private readonly int _startPosition;
|
||||
private readonly int _endPosition;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes function definition using the name, the optional argument definitions and the body expression.
|
||||
/// </summary>
|
||||
internal FunctionDefinition(Identifier name, NodeList<PropDefinition> argDefList, Node body, int startPosition, int endPosition)
|
||||
{
|
||||
this._name = name;
|
||||
this._paramDefList = argDefList;
|
||||
this._body = body;
|
||||
this._startPosition = startPosition;
|
||||
this._endPosition = endPosition;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns function name.
|
||||
/// </summary>
|
||||
internal string Name
|
||||
{
|
||||
get { return this._name.Name; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns optional parameter definition list. May be null.
|
||||
/// </summary>
|
||||
internal NodeList<PropDefinition> Parameters
|
||||
{
|
||||
get { return this._paramDefList; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns function body.
|
||||
/// </summary>
|
||||
internal Node Body
|
||||
{
|
||||
get { return this._body; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns start position of the function definition in the command text.
|
||||
/// </summary>
|
||||
internal int StartPosition
|
||||
{
|
||||
get { return this._startPosition; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns end position of the function definition in the command text.
|
||||
/// </summary>
|
||||
internal int EndPosition
|
||||
{
|
||||
get { return this._endPosition; }
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="GroupAggregateExpr.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
namespace System.Data.Common.EntitySql.AST
|
||||
{
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
/// <summary>
|
||||
/// Base class for <see cref="MethodExpr"/> and <see cref="GroupPartitionExpr"/>.
|
||||
/// </summary>
|
||||
internal abstract class GroupAggregateExpr : Node
|
||||
{
|
||||
internal GroupAggregateExpr(DistinctKind distinctKind)
|
||||
{
|
||||
DistinctKind = distinctKind;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// True if it is a "distinct" aggregate.
|
||||
/// </summary>
|
||||
internal readonly DistinctKind DistinctKind;
|
||||
|
||||
internal GroupAggregateInfo AggregateInfo;
|
||||
}
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="GroupPartitionExpr.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
namespace System.Data.Common.EntitySql.AST
|
||||
{
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
/// <summary>
|
||||
/// Represents GROUPPARTITION(expr) expression.
|
||||
/// </summary>
|
||||
internal sealed class GroupPartitionExpr : GroupAggregateExpr
|
||||
{
|
||||
private readonly Node _argExpr;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes GROUPPARTITION expression node.
|
||||
/// </summary>
|
||||
internal GroupPartitionExpr(DistinctKind distinctKind, Node refArgExpr)
|
||||
: base(distinctKind)
|
||||
{
|
||||
_argExpr = refArgExpr;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return GROUPPARTITION argument expression.
|
||||
/// </summary>
|
||||
internal Node ArgExpr
|
||||
{
|
||||
get { return _argExpr; }
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,68 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="IdentifierExpr.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
namespace System.Data.Common.EntitySql.AST
|
||||
{
|
||||
using System.Diagnostics;
|
||||
|
||||
/// <summary>
|
||||
/// Represents an identifier ast node.
|
||||
/// </summary>
|
||||
internal sealed class Identifier : Node
|
||||
{
|
||||
private readonly string _name;
|
||||
private readonly bool _isEscaped;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes identifier.
|
||||
/// </summary>
|
||||
internal Identifier(string name, bool isEscaped, string query, int inputPos) : base(query, inputPos)
|
||||
{
|
||||
// name may be empty in the case of "byte[]".
|
||||
// "byte" and "[]" come in as two identifiers where second one is escaped and empty.
|
||||
|
||||
Debug.Assert(isEscaped || name[0] != '[', "isEscaped || name[0] != '['");
|
||||
|
||||
if (!isEscaped)
|
||||
{
|
||||
bool isIdentifierASCII = true;
|
||||
if (!CqlLexer.IsLetterOrDigitOrUnderscore(name, out isIdentifierASCII))
|
||||
{
|
||||
if (isIdentifierASCII)
|
||||
{
|
||||
throw EntityUtil.EntitySqlError(this.ErrCtx, System.Data.Entity.Strings.InvalidSimpleIdentifier(name));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw EntityUtil.EntitySqlError(this.ErrCtx, System.Data.Entity.Strings.InvalidSimpleIdentifierNonASCII(name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_name = name;
|
||||
_isEscaped = isEscaped;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns identifier name (without escaping chars).
|
||||
/// </summary>
|
||||
internal string Name
|
||||
{
|
||||
get { return _name; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// True if an identifier is escaped.
|
||||
/// </summary>
|
||||
internal bool IsEscaped
|
||||
{
|
||||
get { return _isEscaped; }
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,84 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="MethodExpr.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
namespace System.Data.Common.EntitySql.AST
|
||||
{
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common.CommandTrees;
|
||||
using System.Diagnostics;
|
||||
|
||||
/// <summary>
|
||||
/// Represents invocation expression: expr(...)
|
||||
/// </summary>
|
||||
internal sealed class MethodExpr : GroupAggregateExpr
|
||||
{
|
||||
private readonly Node _expr;
|
||||
private readonly NodeList<Node> _args;
|
||||
private readonly NodeList<RelshipNavigationExpr> _relationships;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes method ast node.
|
||||
/// </summary>
|
||||
internal MethodExpr(Node expr,
|
||||
DistinctKind distinctKind,
|
||||
NodeList<Node> args) : this (expr, distinctKind, args, null)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Intializes a method ast node with relationships.
|
||||
/// </summary>
|
||||
internal MethodExpr(Node expr,
|
||||
DistinctKind distinctKind,
|
||||
NodeList<Node> args,
|
||||
NodeList<RelshipNavigationExpr> relationships) : base(distinctKind)
|
||||
{
|
||||
Debug.Assert(expr != null, "expr != null");
|
||||
Debug.Assert(args == null || args.Count > 0, "args must be null or a non-empty list");
|
||||
|
||||
_expr = expr;
|
||||
_args = args;
|
||||
_relationships = relationships;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For the following expression: "a.b.c.Foo()", returns "a.b.c.Foo".
|
||||
/// </summary>
|
||||
internal Node Expr
|
||||
{
|
||||
get { return _expr; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Argument list.
|
||||
/// </summary>
|
||||
internal NodeList<Node> Args
|
||||
{
|
||||
get { return _args; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// True if there are associated relationship expressions.
|
||||
/// </summary>
|
||||
internal bool HasRelationships
|
||||
{
|
||||
get { return null != _relationships && _relationships.Count > 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Optional relationship list.
|
||||
/// </summary>
|
||||
internal NodeList<RelshipNavigationExpr> Relationships
|
||||
{
|
||||
get { return _relationships; }
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,69 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="NamespaceImport.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
namespace System.Data.Common.EntitySql.AST
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an ast node for namespace import (using nsABC;)
|
||||
/// </summary>
|
||||
internal sealed class NamespaceImport : Node
|
||||
{
|
||||
private readonly Identifier _namespaceAlias;
|
||||
private readonly Node _namespaceName;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a single name import.
|
||||
/// </summary>
|
||||
internal NamespaceImport(Identifier idenitifier)
|
||||
{
|
||||
_namespaceName = idenitifier;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a single name import.
|
||||
/// </summary>
|
||||
internal NamespaceImport(DotExpr dorExpr)
|
||||
{
|
||||
_namespaceName = dorExpr;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes aliased import.
|
||||
/// </summary>
|
||||
internal NamespaceImport(BuiltInExpr bltInExpr)
|
||||
{
|
||||
_namespaceAlias = null;
|
||||
|
||||
Identifier aliasId = bltInExpr.Arg1 as Identifier;
|
||||
if (aliasId == null)
|
||||
{
|
||||
throw EntityUtil.EntitySqlError(bltInExpr.Arg1.ErrCtx, System.Data.Entity.Strings.InvalidNamespaceAlias);
|
||||
}
|
||||
|
||||
_namespaceAlias = aliasId;
|
||||
_namespaceName = bltInExpr.Arg2;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns ns alias id if exists.
|
||||
/// </summary>
|
||||
internal Identifier Alias
|
||||
{
|
||||
get { return _namespaceAlias; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns namespace name.
|
||||
/// </summary>
|
||||
internal Node NamespaceName
|
||||
{
|
||||
get { return _namespaceName; }
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,71 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="NavigationExpr.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
namespace System.Data.Common.EntitySql.AST
|
||||
{
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a relationship navigation operator NAVIGATE(sourceRefExpr, Relationship-Type-Name [,ToEndName [,FromEndName]]).
|
||||
/// Also used in WITH RELATIONSHIP clause as RELATIONSHIP(targetRefExpr, Relationship-Type-Name [,FromEndName [,ToEndName]]).
|
||||
/// </summary>
|
||||
internal sealed class RelshipNavigationExpr : Node
|
||||
{
|
||||
private readonly Node _refExpr;
|
||||
private readonly Node _relshipTypeName;
|
||||
private readonly Identifier _toEndIdentifier;
|
||||
private readonly Identifier _fromEndIdentifier;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes relationship navigation expression.
|
||||
/// </summary>
|
||||
internal RelshipNavigationExpr(Node refExpr, Node relshipTypeName, Identifier toEndIdentifier, Identifier fromEndIdentifier)
|
||||
{
|
||||
_refExpr = refExpr;
|
||||
_relshipTypeName = relshipTypeName;
|
||||
_toEndIdentifier = toEndIdentifier;
|
||||
_fromEndIdentifier = fromEndIdentifier;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Entity reference expression.
|
||||
/// </summary>
|
||||
internal Node RefExpr
|
||||
{
|
||||
get { return _refExpr; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Relship type name.
|
||||
/// </summary>
|
||||
internal Node TypeName
|
||||
{
|
||||
get { return _relshipTypeName; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// TO end identifier.
|
||||
/// </summary>
|
||||
internal Identifier ToEndIdentifier
|
||||
{
|
||||
get { return _toEndIdentifier; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// FROM end identifier.
|
||||
/// </summary>
|
||||
internal Identifier FromEndIdentifier
|
||||
{
|
||||
get { return _fromEndIdentifier; }
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="ParenExpr.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
namespace System.Data.Common.EntitySql.AST
|
||||
{
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a paren expression ast node.
|
||||
/// </summary>
|
||||
internal sealed class ParenExpr : Node
|
||||
{
|
||||
private readonly AST.Node _expr;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes paren expression.
|
||||
/// </summary>
|
||||
internal ParenExpr(AST.Node expr)
|
||||
{
|
||||
Debug.Assert(expr != null, "expr != null");
|
||||
_expr = expr;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the parenthesized expression.
|
||||
/// </summary>
|
||||
internal AST.Node Expr
|
||||
{
|
||||
get { return _expr; }
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,49 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="QueryParameter.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
namespace System.Data.Common.EntitySql.AST
|
||||
{
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// Represents an ast node for a query parameter.
|
||||
/// </summary>
|
||||
internal sealed class QueryParameter : Node
|
||||
{
|
||||
private readonly string _name;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes parameter
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <exception cref="System.Data.EntityException">Thrown if the parameter name does not conform to the expected format</exception>
|
||||
/// </remarks>
|
||||
internal QueryParameter(string parameterName, string query, int inputPos)
|
||||
: base(query, inputPos)
|
||||
{
|
||||
_name = parameterName.Substring(1);
|
||||
|
||||
//
|
||||
// valid parameter format is: @({LETTER})(_|{LETTER}|{DIGIT})*
|
||||
//
|
||||
if (_name.StartsWith("_", StringComparison.OrdinalIgnoreCase) || Char.IsDigit(_name, 0))
|
||||
{
|
||||
throw EntityUtil.EntitySqlError(ErrCtx, System.Data.Entity.Strings.InvalidParameterFormat(_name));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns parameter parameterName (without @ sign).
|
||||
/// </summary>
|
||||
internal string Name
|
||||
{
|
||||
get { return _name; }
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,52 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="QueryStatement.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
namespace System.Data.Common.EntitySql.AST
|
||||
{
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
/// <summary>
|
||||
/// Represents query statement AST.
|
||||
/// </summary>
|
||||
internal sealed class QueryStatement : Statement
|
||||
{
|
||||
private readonly NodeList<FunctionDefinition> _functionDefList;
|
||||
private readonly Node _expr;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes query statement.
|
||||
/// </summary>
|
||||
/// <param name="functionDefList">optional function definitions</param>
|
||||
/// <param name="statement">query top level expression</param>
|
||||
internal QueryStatement(NodeList<FunctionDefinition> functionDefList, Node expr)
|
||||
{
|
||||
_functionDefList = functionDefList;
|
||||
_expr = expr;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns optional function defintions. May be null.
|
||||
/// </summary>
|
||||
internal NodeList<FunctionDefinition> FunctionDefList
|
||||
{
|
||||
get { return _functionDefList; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns query top-level expression.
|
||||
/// </summary>
|
||||
internal Node Expr
|
||||
{
|
||||
get { return _expr; }
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user