/// <summary> /// Initializes a new instance of the <see cref="Artefacts.Service.ClientQueryProvider`1"/> class. /// </summary> /// <param name="repository">Repository.</param> /// <param name="visitor">Visitor.</param> public ClientQueryProvider(IRepository repository, ExpressionVisitor visitor = null) { if (repository == null) throw new ArgumentNullException("repository"); Repository = repository; _clientProxy = new RepositoryClientProxy(new NetTcpBinding(SecurityMode.None), "net.tcp://localhost:3334/ArtefactRepository"); }
public static Dictionary<string, FNode> BuildParameters(ExpressionVisitor Evaluator, HScriptParser.Bind_element_setContext context) { Dictionary<string, FNode> parameters = new Dictionary<string, FNode>(); if (context == null) return parameters; foreach (HScriptParser.Bind_elementContext ctx in context.bind_element()) { string key = ctx.SCALAR().GetText(); bool is_dynamic = (ctx.K_STATIC() == null) ? true : false; FNode value = (is_dynamic) ? Evaluator.ToNode(ctx.expression()) : new FNodeValue(null, new Cell(ctx.expression().GetText(), false)); parameters.Add(key, value); } return parameters; }
private static Expression ParseTokens(CommonTokenStream input) { ExpressionParser.ExpressionContext startContext = new ExpressionParser(input).expression(); ExpressionVisitor visit = new ExpressionVisitor(); Expression expr = visit.Visit(startContext); return expr; }
// Reads // public static StagedReadName RenderStagedReadPlan(Workspace Home, HScriptParser.Crudam_readContext context) { // Get the data source // DataSet data = VisitorHelper.GetData(Home, context.full_table_name()); string alias = (context.K_AS() != null) ? context.IDENTIFIER().GetText() : data.Name; // Create a local heap to work off of // MemoryStruct local_heap = new MemoryStruct(true); // Create a record register // StreamRegister memory = new StreamRegister(null); // Create expression visitor // ExpressionVisitor exp_vis = new ExpressionVisitor(local_heap, Home, alias, data.Columns, memory); // Where clause // Predicate where = VisitorHelper.GetWhere(exp_vis, context.where_clause()); // Create a reader // RecordReader reader = data.OpenReader(where); // Attach the reader to the register // memory.BaseStream = reader; // Create the action visitor // ActionVisitor act_vis = new ActionVisitor(Home, local_heap, exp_vis); // Get the declarations // if (context.crudam_declare_many() != null) { VisitorHelper.AllocateMemory(Home, local_heap, exp_vis, context.crudam_declare_many()); } // Get the initial actionset // TNode pre_run = (context.init_action() != null) ? act_vis.ToNode(context.init_action().query_action()) : new TNodeNothing(null); // Get the main actionset // TNode run = act_vis.ToNode(context.main_action().query_action()); // Get the final actionset // TNode post_run = (context.final_action() != null) ? act_vis.ToNode(context.final_action().query_action()) : new TNodeNothing(null); return new StagedReadName(reader, pre_run, run, post_run); }
protected override Expression Accept(ExpressionVisitor visitor) { return(base.Accept(visitor)); }
/// <summary> /// Dispatches to the specific visit method for this node type. /// </summary> protected internal override Expression Accept(ExpressionVisitor visitor) { return visitor.VisitMethodCall(this); }
/// <summary> /// Dispatches to the specific visit method for this node type. /// </summary> protected internal override Expression Accept(ExpressionVisitor visitor) { return visitor.VisitNewArray(this); }
// Partitions // public static int GetPartitions(ExpressionVisitor Evaluator, HScriptParser.PartitionsContext context) { // Null then assume 1 partition // if (context == null) return 1; // If the expression is null, then max out cores // if (context.expression() == null) return Environment.ProcessorCount; // Otherwise, get the value // int cnt = (int)Evaluator.ToNode(context.expression()).Evaluate().valueINT; // Bound it // cnt = Math.Min(cnt, Environment.ProcessorCount * 2); cnt = Math.Max(cnt, 1); return cnt; }
private static void AppendSet(ExpressionVisitor Evaluator, FNodeSet Fields, HScriptParser.EOW_table_starContext context) { string alias = context.IDENTIFIER()[0].GetText(); if (!Evaluator.Columns.ContainsKey(alias)) throw new Exception(string.Format("Alias '{0}' does not exist", alias)); FNodeSet nodes = new FNodeSet(Evaluator.Columns[alias]); nodes.AssignRegister(Evaluator.Registers[alias]); string suffix = (context.K_AS() == null) ? null : context.IDENTIFIER()[1].GetText(); for (int i = 0; i < nodes.Count; i++) { Fields.Add((suffix == null) ? nodes.Alias(i) : suffix + nodes.Alias(i), nodes[i]); } }
public static void AllocateMemory(Workspace Home, MemoryStruct Heap, ExpressionVisitor Evaluator, HScriptParser.Crudam_declare_manyContext context) { foreach (HScriptParser.Declare_genericContext ctx in context.declare_generic()) { AllocateMemory(Home, Heap, Evaluator, ctx); } }
protected override Expression VisitChildren(ExpressionVisitor visitor) => Update((SqlExpression)visitor.Visit(Expression));
public override T Accept <T>(ExpressionVisitor <T> v) { return(v.VisitPointerAddition(this)); }
public override T Accept <T, C>(ExpressionVisitor <T, C> v, C context) { return(v.VisitPointerAddition(this, context)); }
public override T Accept <T>(ExpressionVisitor <T> v) { return(v.VisitProcedureConstant(this)); }
public override T Accept <T, C>(ExpressionVisitor <T, C> v, C context) { return(v.VisitProcedureConstant(this, context)); }
public override T Accept <T>(ExpressionVisitor <T> v) { return(v.VisitApplication(this)); }
public override T Accept <T, C>(ExpressionVisitor <T, C> v, C context) { return(v.VisitApplication(this, context)); }
/// <summary> /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to /// the same compatibility standards as public APIs. It may be changed or removed without notice in /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// </summary> protected override Expression VisitChildren(ExpressionVisitor visitor) { Check.NotNull(visitor, nameof(visitor)); var changed = false; var projections = new List <ProjectionExpression>(); IDictionary <ProjectionMember, Expression> projectionMapping; if (Projection.Any()) { projectionMapping = _projectionMapping; foreach (var item in Projection) { var projection = (ProjectionExpression)visitor.Visit(item); projections.Add(projection); changed |= projection != item; } } else { projectionMapping = new Dictionary <ProjectionMember, Expression>(); foreach (var mapping in _projectionMapping) { var newProjection = visitor.Visit(mapping.Value); changed |= newProjection != mapping.Value; projectionMapping[mapping.Key] = newProjection; } } var fromExpression = (RootReferenceExpression)visitor.Visit(FromExpression); changed |= fromExpression != FromExpression; var predicate = (SqlExpression)visitor.Visit(Predicate); changed |= predicate != Predicate; var orderings = new List <OrderingExpression>(); foreach (var ordering in _orderings) { var orderingExpression = (SqlExpression)visitor.Visit(ordering.Expression); changed |= orderingExpression != ordering.Expression; orderings.Add(ordering.Update(orderingExpression)); } var offset = (SqlExpression)visitor.Visit(Offset); changed |= offset != Offset; var limit = (SqlExpression)visitor.Visit(Limit); changed |= limit != Limit; if (changed) { var newSelectExpression = new SelectExpression(projections, fromExpression, orderings) { _projectionMapping = projectionMapping, Predicate = predicate, Offset = offset, Limit = limit, IsDistinct = IsDistinct }; return(newSelectExpression); } return(this); }
public static void AllocateMemory(Workspace Home, MemoryStruct Heap, ExpressionVisitor Evaluator, HScriptParser.DeclareMatrixLiteralContext context) { string name = context.IDENTIFIER().GetText(); CellAffinity type = GetAffinity(context.type()); MatrixVisitor vis = new MatrixVisitor(Home, Heap, Evaluator); CellMatrix mat = vis.ToMatrix(context.matrix_expression()).Evaluate(); Heap.Arrays.Reallocate(name, mat); }
////////////////////////////////////////////// #region BoundVariableExpression Members public override Expression visit(ExpressionVisitor v) { return(v.visit(this)); }
// Expression or wildcard handelers // private static void AppendSet(ExpressionVisitor Evaluator, FNodeSet Fields, HScriptParser.EOW_expressionContext context) { FNode node = Evaluator.ToNode(context.expression_alias().expression()); string alias = ("F" + Fields.Count.ToString()); if (node.Name != null) alias = node.Name; if (context.expression_alias().K_AS() != null) alias = context.expression_alias().IDENTIFIER().GetText(); Fields.Add(alias, node); }
/// <inheritdoc /> protected override Expression Accept(ExpressionVisitor visitor) => visitor is NpgsqlQuerySqlGenerator npgsqlGenerator
private static void AppendSet(ExpressionVisitor Evaluator, FNodeSet Fields, HScriptParser.Expression_or_wildcardContext context) { if (context is HScriptParser.EOW_expressionContext) { AppendSet(Evaluator, Fields, context as HScriptParser.EOW_expressionContext); return; } if (context is HScriptParser.EOW_local_starContext) { AppendSet(Evaluator, Fields, context as HScriptParser.EOW_local_starContext); return; } if (context is HScriptParser.EOW_global_starContext) { AppendSet(Evaluator, Fields, context as HScriptParser.EOW_global_starContext); return; } if (context is HScriptParser.EOW_table_starContext) { AppendSet(Evaluator, Fields, context as HScriptParser.EOW_table_starContext); return; } if (context is HScriptParser.EOW_tables_starContext) { AppendSet(Evaluator, Fields, context as HScriptParser.EOW_tables_starContext); return; } }
public override void Accept(ExpressionVisitor vis) { vis.Visit(this); }
public override void OnAfterCall(Identifier stackReg, ProcedureSignature sigCallee, ExpressionVisitor<Expression> eval) { throw new NotImplementedException(); }
public override void Accept(ExpressionVisitor expressionVisitor) { expressionVisitor.Visit(this); }
public override void Visit(ExpressionVisitor visitor) { visitor.Visit(this); }
/// <summary> /// Reduces the node and then calls the visitor delegate on the reduced expression. /// The method throws an exception if the node is not /// reducible. /// </summary> /// <returns> /// The expression being visited, or an expression which should replace it in the tree. /// </returns> /// <param name="visitor">An instance of <see cref="T:System.Func`2" />.</param> protected override Expression VisitChildren(ExpressionVisitor visitor) => Update(visitor.Visit(Caller), visitor.Visit(AccessOperation));
public override Expression Accept(ExpressionVisitor visitor) { return visitor.VisitParameter(this); }
public override void OnAfterCall(Identifier sp, ProcedureSignature sigCallee, ExpressionVisitor <Expression> eval) { var spReg = (RegisterStorage)sp.Storage; var spVal = GetValue(spReg); var stackOffset = SetValue( spReg, new BinaryExpression( Operator.IAdd, spVal.DataType, sp, Constant.Create( PrimitiveType.CreateWord(spReg.DataType.Size), sigCallee.StackDelta)).Accept(eval)); if (stackOffset.IsValid) { if (stackOffset.ToInt32() > 0) { ErrorListener("Possible stack underflow detected."); } } }
/// <summary> /// Dispatches to the specific visit method for this node type. /// </summary> protected internal override Expression Accept(ExpressionVisitor visitor) { return visitor.VisitInvocation(this); }
// Heap allocations // public static void AllocateMemory(Workspace Home, MemoryStruct Heap, ExpressionVisitor Evaluator, HScriptParser.DeclareScalarContext context) { string name = context.IDENTIFIER().GetText(); CellAffinity type = GetAffinity(context.type()); Cell value = (context.ASSIGN() != null) ? Evaluator.ToNode(context.expression()).Evaluate() : new Cell(type); Heap.Scalars.Reallocate(name, value); }
protected override Expression VisitChildren(ExpressionVisitor visitor) { QueryExpression = visitor.Visit(QueryExpression); return(this); }
/// <inheritdoc /> protected override Expression VisitChildren(ExpressionVisitor visitor) => Update((SqlExpression)visitor.Visit(Array), (SqlExpression)visitor.Visit(Index));
public override void OnAfterCall(Identifier sp, ProcedureSignature sigCallee, ExpressionVisitor<Expression> eval) { }
public void Accept(ExpressionVisitor vis) { vis.Visit(this); }
public static void AllocateMemory(Workspace Home, MemoryStruct Heap, ExpressionVisitor Evaluator, HScriptParser.DeclareMatrix2DContext context) { string name = context.IDENTIFIER().GetText(); CellAffinity type = GetAffinity(context.type()); int rows = (int)Evaluator.ToNode(context.expression()[0]).Evaluate().valueINT; int cols = (int)Evaluator.ToNode(context.expression()[1]).Evaluate().valueINT; CellMatrix mat = new CellMatrix(rows, cols, type); Heap.Arrays.Reallocate(name, mat); }
public R Accept <R>(ExpressionVisitor <R> vis) { return(vis.Visit(this)); }
public static void AllocateMemory(Workspace Home, MemoryStruct Heap, ExpressionVisitor Evaluator, HScriptParser.Declare_genericContext context) { if (context is HScriptParser.DeclareScalarContext) { VisitorHelper.AllocateMemory(Home, Heap, Evaluator, context as HScriptParser.DeclareScalarContext); return; } if (context is HScriptParser.DeclareMatrix1DContext) { VisitorHelper.AllocateMemory(Home, Heap, Evaluator, context as HScriptParser.DeclareMatrix1DContext); return; } if (context is HScriptParser.DeclareMatrix2DContext) { VisitorHelper.AllocateMemory(Home, Heap, Evaluator, context as HScriptParser.DeclareMatrix2DContext); return; } if (context is HScriptParser.DeclareMatrixLiteralContext) { VisitorHelper.AllocateMemory(Home, Heap, Evaluator, context as HScriptParser.DeclareMatrixLiteralContext); return; } }
public override TResult Accept <TResult, TContext>(ExpressionVisitor <TResult, TContext> visitor, TContext ctx) { return(visitor.VisitVariable(ctx, this)); }
// Where clause // public static Predicate GetWhere(ExpressionVisitor Evaluator, HScriptParser.Where_clauseContext context) { if (context == null) return Predicate.TrueForAll; return Evaluator.ToPredicate(context.expression()); }
public override T Accept <T, C>(ExpressionVisitor <T, C> v, C context) { return(v.VisitOutArgument(this, context)); }
private static void AppendSet(ExpressionVisitor Evaluator, FNodeSet Fields, HScriptParser.EOW_global_starContext context) { string suffix = (context.K_AS() == null) ? null : context.IDENTIFIER().GetText(); for (int i = 0; i < Evaluator.GlobalHeap.Scalars.Count; i++) { string alias = (suffix == null) ? Evaluator.LocalHeap.Scalars.Name(i) : suffix + Evaluator.LocalHeap.Scalars.Name(i); FNode node = new FNodeHeapRef(null, Evaluator.GlobalHeap, i); Fields.Add(alias, node); } }
public override T Accept <T>(ExpressionVisitor <T> visitor) { return(visitor.VisitOutArgument(this)); }
private static void AppendSet(ExpressionVisitor Evaluator, FNodeSet Fields, HScriptParser.EOW_tables_starContext context) { if (Evaluator.Columns.Count == 0) return; // no need to toss an exception string alias = Evaluator.Columns.Keys.First(); FNodeSet nodes = new FNodeSet(Evaluator.Columns[alias]); nodes.AssignRegister(Evaluator.Registers[alias]); string suffix = (context.K_AS() == null) ? null : context.IDENTIFIER().GetText(); for (int i = 0; i < nodes.Count; i++) { Fields.Add((suffix == null) ? nodes.Alias(i) : suffix + nodes.Alias(i), nodes[i]); } }
/// <summary> /// Reduces the node and then calls the <see cref="ExpressionVisitor.Visit(System.Linq.Expressions.Expression)" /> method passing the /// reduced expression. /// Throws an exception if the node isn't reducible. /// </summary> /// <param name="visitor"> An instance of <see cref="ExpressionVisitor" />. </param> /// <returns> The expression being visited, or an expression which should replace it in the tree. </returns> /// <remarks> /// Override this method to provide logic to walk the node's children. /// A typical implementation will call visitor.Visit on each of its /// children, and if any of them change, should return a new copy of /// itself with the modified children. /// </remarks> protected override Expression VisitChildren(ExpressionVisitor visitor) { visitor.Visit(_tableExpression); return(this); }
public static FNodeSet GetReturnStatement(ExpressionVisitor Evaluator, HScriptParser.Expression_or_wildcard_setContext context) { FNodeSet nodes = new FNodeSet(); foreach (HScriptParser.Expression_or_wildcardContext ctx in context.expression_or_wildcard()) AppendSet(Evaluator, nodes, ctx); return nodes; }
/// <summary> /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to /// the same compatibility standards as public APIs. It may be changed or removed without notice in /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// </summary> protected override Expression VisitChildren(ExpressionVisitor visitor) { Check.NotNull(visitor, nameof(visitor)); return(Update((SqlExpression)visitor.Visit(Expression))); }
/// <summary> /// Dispatches to the specific visit method for this node type. /// </summary> protected internal override Expression Accept(ExpressionVisitor visitor) { return visitor.VisitConstant(this); }
protected override Expression VisitChildren(ExpressionVisitor visitor) { return(this); }
/// <summary> /// Dispatches to the specific visit method for this node type. /// </summary> protected internal override Expression Accept(ExpressionVisitor visitor) { return visitor.VisitRuntimeVariables(this); }
/// <summary> /// Dispatches to the specific visit method for this node type. /// </summary> protected internal override Expression Accept(ExpressionVisitor visitor) { return(visitor.VisitLambda(this)); }
public abstract void Visit(ExpressionVisitor visitor);
protected override Expression VisitChildren(ExpressionVisitor visitor) => this;
protected internal override Expression Accept(ExpressionVisitor visitor) { return visitor.VisitDebugInfo(this); }
/// <inheritdoc /> protected override Expression VisitChildren(ExpressionVisitor visitor) => throw new InvalidOperationException( CoreStrings.VisitIsNotAllowed($"{nameof(ShapedQueryExpression)}.{nameof(VisitChildren)}"));
public override void OnAfterCall(Identifier sp, ProcedureSignature sigCallee, ExpressionVisitor<Expression> eval) { var spReg = (RegisterStorage) sp.Storage; var spVal = GetValue(spReg); var stackOffset = SetValue( spReg, new BinaryExpression( Operator.IAdd, spVal.DataType, sp, Constant.Create( PrimitiveType.CreateWord(spReg.DataType.Size), sigCallee.StackDelta)).Accept(eval)); if (stackOffset.IsValid) { if (stackOffset.ToInt32() > 0) ErrorListener("Possible stack underflow detected."); } }
/// <summary> /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to /// the same compatibility standards as public APIs. It may be changed or removed without notice in /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// </summary> protected override Expression VisitChildren(ExpressionVisitor visitor) { Check.NotNull(visitor, nameof(visitor)); return(this); }
/// <summary> /// Dispatches to the specific visit method for this node type. /// </summary> protected internal override Expression Accept(ExpressionVisitor visitor) { return visitor.VisitTypeBinary(this); }
protected override Expression Accept(ExpressionVisitor visitor) { return(visitor.Visit(Constant(_blockParam, typeof(BlockParam)))); }