Exemplo n.º 1
0
 protected override ICode VisitJsArrayLiteral(ExprJsArrayLiteral e)
 {
     this.code.Append("[");
     if (e.Elements.Any())
     {
         foreach (var element in e.Elements)
         {
             this.Visit(element);
             this.code.Append(", ");
         }
         this.code.Length -= 2;
     }
     this.code.Append("]");
     return(e);
 }
Exemplo n.º 2
0
        public static Expr Copy(ICall call)
        {
            // d = arg[0].slice(arg[1],arg[4]+arg[1])
            // Array.prototype.splice.apply(arg[2], [arg[3], arg[4]].concat(d))
            var ctx             = call.Ctx;
            var src             = call.Args.ElementAt(0);
            var srcIdx          = call.Args.ElementAt(1);
            var dst             = call.Args.ElementAt(2);
            var dstIdx          = call.Args.ElementAt(3);
            var length          = call.Args.ElementAt(4);
            var arrayPart       = new ExprJsResolvedMethod(ctx, src.Type, src, "slice", srcIdx, ctx.ExprGen.Add(srcIdx, length));
            var spliceFixedArgs = new ExprJsArrayLiteral(ctx, ctx.Object, dstIdx, length);
            var spliceArgs      = new ExprJsResolvedMethod(ctx, spliceFixedArgs.Type, spliceFixedArgs, "concat", arrayPart);
            var copy            = new ExprJsResolvedMethod(ctx, ctx.Void, null, "Array.prototype.splice.apply", dst, spliceArgs);

            return(copy);
        }