protected internal virtual Expression VisitBlock(BlockExpression node) { int expressionCount = node.ExpressionCount; Expression[] args = null; for (int i = 0; i < expressionCount; i++) { Expression expression = node.GetExpression(i); Expression expression2 = this.Visit(expression); if (expression != expression2) { if (args == null) { args = new Expression[expressionCount]; } args[i] = expression2; } } ReadOnlyCollection <ParameterExpression> variables = this.VisitAndConvert <ParameterExpression>(node.Variables, "VisitBlock"); if ((variables == node.Variables) && (args == null)) { return(node); } for (int j = 0; j < expressionCount; j++) { if (args[j] == null) { args[j] = node.GetExpression(j); } } return(node.Rewrite(variables, args)); }
public int IndexOf(Expression item) { if (_arg0 == item) { return(0); } for (int i = 1; i < _block.ExpressionCount; i++) { if (_block.GetExpression(i) == item) { return(i); } } return(-1); }
protected internal override Expression VisitBlock(BlockExpression node) { this.Out(".Block"); if (node.Type != node.GetExpression(node.ExpressionCount - 1).Type) { this.Out(string.Format(CultureInfo.CurrentCulture, "<{0}>", new object[] { node.Type.ToString() })); } this.VisitDeclarations(node.Variables); this.Out(" "); this.VisitExpressions <Expression>('{', ';', node.Expressions); return(node); }
public Expression this[int index] { get { if (index == 0) { return(_arg0); } return(_block.GetExpression(index)); } set => throw ContractUtils.Unreachable;
/// <summary> /// Visits the children of the <see cref="BlockExpression" />. /// </summary> /// <param name="node">The expression to visit.</param> /// <returns>The modified expression, if it or any subexpression was modified; /// otherwise, returns the original expression.</returns> protected internal virtual Expression VisitBlock(BlockExpression node) { int count = node.ExpressionCount; Expression[] nodes = null; for (int i = 0; i < count; i++) { Expression oldNode = node.GetExpression(i); Expression newNode = Visit(oldNode); if (oldNode != newNode) { if (nodes == null) { nodes = new Expression[count]; } nodes[i] = newNode; } } var v = VisitAndConvert(node.Variables, "VisitBlock"); if (v == node.Variables && nodes == null) { return(node); } if (nodes != null) { for (int i = 0; i < count; i++) { if (nodes[i] == null) { nodes[i] = node.GetExpression(i); } } } return(node.Rewrite(v, nodes)); }
public static Expression[] VisitBlockExpressions(ExpressionVisitor visitor, BlockExpression block) { Expression[] newNodes = null; for (int i = 0, n = block.ExpressionCount; i < n; i++) { Expression curNode = block.GetExpression(i); Expression node = visitor.Visit(curNode); if (newNodes != null) { newNodes[i] = node; } else if (!object.ReferenceEquals(node, curNode)) { newNodes = new Expression[n]; for (int j = 0; j < i; j++) { newNodes[j] = block.GetExpression(j); } newNodes[i] = node; } } return newNodes; }
protected internal override Expression VisitBlock(BlockExpression node) { Out(".Block"); // Display <type> if the type of the BlockExpression is different from the // last expression's type in the block. if (node.Type != node.GetExpression(node.ExpressionCount - 1).Type) { Out(string.Format(CultureInfo.CurrentCulture, "<{0}>", node.Type.ToString())); } VisitDeclarations(node.Variables.AsArrayInternal()); Out(" "); // Use ; to separate expressions in the block VisitExpressions('{', ';', node.Expressions.AsArrayInternal()); return(node); }
protected internal override Expression VisitBlock(BlockExpression node) { Out(".Block"); // Display <type> if the type of the BlockExpression is different from the // last expression's type in the block. if (node.Type != node.GetExpression(node.ExpressionCount - 1).Type) { Out($"<{node.Type}>"); } VisitDeclarations(node.Variables); Out(" "); // Use ; to separate expressions in the block VisitExpressions('{', ';', node.Expressions); return(node); }