상속: Expression
예제 #1
0
        public Expression Update(Expression body, LabelExpression @break, LabelExpression @continue) {
            if (Body.Equals(body) && BreakExpression == @break && ContinueExpression == @continue) {
                return this;
            }

            return AstExpression.ForEach(_foreachStatement, this, Visitor);
        }
예제 #2
0
파일: Label.cs 프로젝트: takeshik/yacq
 internal static Label Label(LabelExpression expression)
 {
     return new Label()
     {
         Target = LabelTarget.Serialize(expression.Target),
         DefaultValue = expression.DefaultValue.Null(e => Serialize(e)),
     }.Apply(n => n.Type = TypeRef.Serialize(expression.Type));
 }
        private MSAst.LambdaExpression CreateOuterGeneratorFactory(Type lambdaType)
        {
            MSAst.LabelTarget returnLabelTarget = Ast.Label(lambdaType.GetMethod("Invoke").ReturnType);

            MSAst.Expression body = Ast.Return(
                returnLabelTarget,
                Ast.Call(
                    typeof(RuntimeOps),
                    "CreateDebugGenerator",
                    new[] { _generatorLabelTarget.Type },
                    Ast.Call(
                        typeof(RuntimeOps).GetMethod("CreateFrameForGenerator"),
                        _debugContextExpression,
                        _functionInfo
                        )
                    )
                );

            MSAst.LabelExpression returnLabel = null;
            if (returnLabelTarget.Type == typeof(void))
            {
                returnLabel = Ast.Label(returnLabelTarget, AstUtils.Void(body));
            }
            else
            {
                returnLabel = Ast.Label(returnLabelTarget, AstUtils.Convert(body, returnLabelTarget.Type));
            }

            return(Ast.Lambda(
                       lambdaType,
                       Ast.Block(
                           _lambdaVars,
                           returnLabel
                           ),
                       _alias,
                       _lambdaParams));
        }
예제 #4
0
 public LabelExpressionProxy(LabelExpression node) {
     _node = node;
 }
 /// <summary>
 /// Creates the lambda's return target label with the specified type.
 /// </summary>
 /// <param name="type">The target's type.</param>
 protected void CreateReturnTarget(Type type)
 {
     exitTarget = Expression.Label(type, "exit");
     exitLabel = Expression.Label(exitTarget, Expression.Default(type));
     defaultReturnExpression = Expression.Return(exitTarget, Expression.Default(type));
 }
 /// <summary>
 /// Creates the lambda's return target label with void type.
 /// </summary>
 protected void CreateReturnTarget()
 {
     exitTarget = Expression.Label("exit");
     exitLabel = Expression.Label(exitTarget);
     defaultReturnExpression = Expression.Return(exitTarget);
 }
    public virtual bool IsEvaluatableLabel (LabelExpression node)
    {
      ArgumentUtility.CheckNotNull ("node", node);

      return true;
    }
예제 #8
0
 private Variable VisitLabel(LabelExpression node)
 {
     throw new NotSupportedException("Expression of type " + node.NodeType + " is not supported");
     //this.Out("{ ... } ");
     //this.DumpLabel(node.Target);
     //this.Out(":");
 }
예제 #9
0
        protected internal virtual new Expression VisitLabel(LabelExpression node)
        {
            Contract.Requires(node != null);

            return(default(Expression));
        }
 /// <summary>
 /// Makes an expression slim representing a LabelExpression with the given children.
 /// </summary>
 /// <param name="node">Original expression.</param>
 /// <param name="target">Target label slim.</param>
 /// <param name="defaultValue">Default value expression slim.</param>
 /// <returns>Slim representation of the original expression.</returns>
 protected override ExpressionSlim MakeLabel(LabelExpression node, LabelTargetSlim target, ExpressionSlim defaultValue)
 {
     return(_factory.Label(target, defaultValue));
 }
예제 #11
0
 protected virtual Expression VisitLabel(LabelExpression node)
 {
     throw new NotImplementedException();
 }
 protected internal virtual new Expression VisitLabel(LabelExpression node)
 {
     return(default(Expression));
 }
예제 #13
0
 public LabelExpressionProxy(LabelExpression node)
 {
     ContractUtils.RequiresNotNull(node, nameof(node));
     _node = node;
 }
        protected override Expression VisitLabel(LabelExpression node)
        {
            var info = default(LabelInfo);
            if (TryGetLabelInfo(node.Target, out info))
            {
                var variable = info.Value;
                var newTarget = info.Target;

                var res =
                    Expression.Block(
                        Expression.Assign(variable, node.DefaultValue),
                        Expression.Label(newTarget),
                        variable
                    );

                return res;
            }

            return base.VisitLabel(node);
        }
예제 #15
0
            protected override Expression VisitLabel(LabelExpression node)
            {
                Labels.Add(node.Target);

                return base.VisitLabel(node);
            }
예제 #16
0
 /// <summary>
 ///     Visits the children of the <see cref="LabelExpression" />.
 /// </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 VisitLabel(LabelExpression node)
 {
     return(node.Update(VisitLabelTarget(node.Target), Visit(node.DefaultValue)));
 }
        protected override Expression VisitLabel(LabelExpression expression)
        {
            LabelExpression current;
            if (!TryGetCurrent(expression, out current))
            {
                return expression;
            }

            if (!(this.result &= current.Type == expression.Type))
            {
                return expression;
            }

            if (!(this.result &= current.NodeType == expression.NodeType))
            {
                return expression;
            }

            this.currentObject = current.Target;
            this.VisitLabelTarget(expression.Target);
            if (!this.result)
            {
                return expression;
            }

            this.currentObject = current.DefaultValue;
            this.Visit(expression.DefaultValue);
            if (!this.result)
            {
                return expression;
            }

            this.currentObject = current;
            return expression;
        }
예제 #18
0
 public LabelExpressionProxy(LabelExpression node)
 {
     ContractUtils.RequiresNotNull(node, nameof(node));
     _node = node;
 }
 protected override Expression VisitLabel(LabelExpression node)
 {
     throw new NotSupportedException();
 }
		}//end static method
		internal XElement LabelExpressionToXElement(LabelExpression e)
		{
			object value;
			string xName = "LabelExpression";
			object[] XElementValues = new object[5];
			value = ((LabelExpression)e).Type;
			XElementValues[0] = GenerateXmlFromProperty(typeof(System.Type),
				"Type", value ?? string.Empty);
			value = ((LabelExpression)e).NodeType;
			XElementValues[1] = GenerateXmlFromProperty(typeof(System.Linq.Expressions.ExpressionType),
				"NodeType", value ?? string.Empty);
			value = ((LabelExpression)e).Target;
			XElementValues[2] = GenerateXmlFromProperty(typeof(System.Linq.Expressions.LabelTarget),
				"Target", value ?? string.Empty);
			value = ((LabelExpression)e).DefaultValue;
			XElementValues[3] = GenerateXmlFromProperty(typeof(System.Linq.Expressions.Expression),
				"DefaultValue", value ?? string.Empty);
			value = ((LabelExpression)e).CanReduce;
			XElementValues[4] = GenerateXmlFromProperty(typeof(System.Boolean),
				"CanReduce", value ?? string.Empty);
			return new XElement(xName, XElementValues);
		}//end static method
예제 #21
0
 private static string VisitLabel(LabelExpression node)
 {
     throw new NotImplementedException();
 }
 protected override Expression VisitLabel(LabelExpression expression)
 {
     this.hashCode ^= expression.Target?.GetHashCode() ?? 0;
     return base.VisitLabel(expression);
 }