Esempio n. 1
0
        public UnifiedElement VisitObjectCreateExpression(
            ObjectCreateExpression create, object data)
        {
            var uType = LookupType(create.Type);
            var args  = create.Arguments.AcceptVisitorAsArgs(this, data);

            return(UnifiedNew.Create(uType, args));
        }
Esempio n. 2
0
 public override bool Visit(UnifiedNew element, VisitorArgument arg)
 {
     Writer.Write("new ");
     element.GenericArguments.TryAccept(this, arg);
     element.Target.TryAccept(this, arg);
     element.Arguments.TryAccept(this, arg.Set(Paren));
     element.InitialValue.TryAccept(this, arg.Set(Brace));
     element.Body.TryAccept(this, arg);
     return(false);
 }
 //配列orオブジェクトのインスタンス化式
 public override bool Visit(UnifiedNew element, VisitorArgument arg)
 {
     //配列 : e.g. var a = [1, 2, 3] の [1, 2, 3];
     if (element.InitialValue != null) {
         element.InitialValue.TryAccept(this, arg.Set(Brace));
         return true;
     }
     //オブジェクト : e.g. var a = new X();
     Writer.Write("new ");
     element.Target.TryAccept(this, arg);
     element.Arguments.TryAccept(this, arg.Set(Paren));
     return true;
 }
 //配列orオブジェクトのインスタンス化式
 public override bool Visit(UnifiedNew element, VisitorArgument arg)
 {
     //配列 : e.g. var a = [1, 2, 3] の [1, 2, 3];
     if (element.InitialValue != null)
     {
         element.InitialValue.TryAccept(this, arg.Set(Brace));
         return(true);
     }
     //オブジェクト : e.g. var a = new X();
     Writer.Write("new ");
     element.Target.TryAccept(this, arg);
     element.Arguments.TryAccept(this, arg.Set(Paren));
     return(true);
 }
Esempio n. 5
0
        public UnifiedElement VisitAnonymousTypeCreateExpression(
            AnonymousTypeCreateExpression expr, object data)
        {
            var block = UnifiedBlock.Create();

            foreach (var nExpr in expr.Initializers)
            {
                var uExpr = nExpr.TryAcceptForExpression(this);
                if (uExpr != null)
                {
                    block.Add(uExpr);
                }
            }
            return(UnifiedNew.Create(body: block));
        }
Esempio n. 6
0
        public UnifiedElement VisitArrayCreateExpression(
            ArrayCreateExpression array, object data)
        {
            var type       = LookupType(array.Type);
            var uArgs      = array.Arguments.AcceptVisitorAsArgs(this, data);
            var initValues = null as UnifiedArrayLiteral;

            if (array.Initializer != null)
            {
                initValues =
                    array.Initializer.AcceptVisitor(this, data) as
                    UnifiedArrayLiteral;
            }
            return(UnifiedNew.Create(
                       type.WrapRectangleArray(uArgs), initialValues: initValues));
        }
 public override bool Visit(UnifiedNew element, VisitorArgument arg)
 {
     Writer.Write("new ");
     element.GenericArguments.TryAccept(this, arg);
     element.Target.TryAccept(this, arg);
     element.Arguments.TryAccept(this, arg.Set(Paren));
     element.InitialValue.TryAccept(this, arg.Set(Brace));
     element.Body.TryAccept(this, arg);
     return false;
 }