/*
 * Copyright (c) 2009-2012 Panxiaobo
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.googlecode.dex2jar.ir.expr;

import org.objectweb.asm.Type;

import com.googlecode.dex2jar.ir.Value;
import com.googlecode.dex2jar.ir.Value.EnExpr;
import com.googlecode.dex2jar.ir.Value.VT;
import com.googlecode.dex2jar.ir.ValueBox;

/**
 * Represent a FILLED_ARRAY expression.
 * 
 * @see VT#FILLED_ARRAY
 */
public class FilledArrayExpr extends EnExpr {

    public Type type;

    public FilledArrayExpr(ValueBox[] datas, Type type) {
        super(VT.FILLED_ARRAY, datas);
        this.type = type;
    }

    @Override
    public Value clone() {
        ValueBox[] nOps = new ValueBox[ops.length];
        for (int i = 0; i < nOps.length; i++) {
            nOps[i] = new ValueBox(ops[i].value.clone());
        }
        return new FilledArrayExpr(nOps, type);
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder().append('{');
        for (int i = 0; i < ops.length - 1; i++) {
            sb.append(ops[i]).append(", ");
        }
        sb.append(ops[ops.length - 1]).append('}');
        return sb.toString();
    }

}

@@ -1579,20 +1579,16 @@
 s.length
- - 1
 ; i++) %7B
@@ -1581,32 +1581,32 @@
 length; i++) %7B%0D%0A
+
             sb.a
@@ -1657,38 +1657,116 @@
     
-sb.append(ops%5Bops
+if (ops.length %3E 0) %7B%0D%0A            sb.setLength(sb
 .length
+()
  - 
-1%5D)
+2); // remove tail %22, %22%0D%0A        %7D%0D%0A        sb
 .app
@@ -1807,20 +1807,18 @@
 ing();%0D%0A
+
     %7D%0D%0A
-%0D%0A
 %7D%0D%0A

fix ArrayIndexOutOfBoundsException when zero-ops in FilledArrayExpr