All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sun.jdo.api.persistence.enhancer.classfile.InsnMultiDimArrayNew Maven / Gradle / Ivy

/*
 * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v. 2.0, which is available at
 * http://www.eclipse.org/legal/epl-2.0.
 *
 * This Source Code may also be made available under the following Secondary
 * Licenses when the conditions for such availability set forth in the
 * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
 * version 2 with the GNU Classpath Exception, which is available at
 * https://www.gnu.org/software/classpath/license.html.
 *
 * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
 */

package com.sun.jdo.api.persistence.enhancer.classfile;

import java.io.PrintStream;

/**
 * Special instruction form for the opc_multianewarray instruction
 */
public class InsnMultiDimArrayNew extends Insn {
    /* The array class for creation */
    private ConstClass classOp;

    /* The number of dimensions present on the stack */
    private int nDimsOp;

    /* public accessors */

    public boolean isSimpleLoad() {
        return false;
    }

    public int nStackArgs() {
        return nDimsOp;
    }

    public int nStackResults() {
        return 1;
    }

    /**
     * What are the types of the stack operands ?
     */
    public String argTypes() {
        StringBuffer buf = new StringBuffer();
        for (int i=0; i 0 and <= number of array dimensions for classOp
     */
    public InsnMultiDimArrayNew (ConstClass classOp, int nDimsOp) {
        this(classOp, nDimsOp, NO_OFFSET);
    }

    /* package local methods */

    InsnMultiDimArrayNew (ConstClass classOp, int nDimsOp, int offset) {
        super(opc_multianewarray, offset);

        this.classOp = classOp;
        this.nDimsOp = nDimsOp;

        if (classOp == null || nDimsOp < 1)
            throw new InsnError ("attempt to create an opc_multianewarray" +//NOI18N
                " with invalid operands");//NOI18N
    }



    void print (PrintStream out, int indent) {
        ClassPrint.spaces(out, indent);
        out.println(offset() + "  opc_multianewarray  pool(" +//NOI18N
            classOp.getIndex() + ")," + nDimsOp);//NOI18N
    }

    int store(byte[] buf, int index) {
        buf[index++] = (byte) opcode();
        index = storeShort(buf, index, (short) classOp.getIndex());
        buf[index++] = (byte) nDimsOp;
        return index;
    }

    int size() {
        return 4;
    }

    static InsnMultiDimArrayNew read (InsnReadEnv insnEnv, int myPC) {
        ConstClass classOp = (ConstClass)
            insnEnv.pool().constantAt(insnEnv.getUShort());
        int nDims = insnEnv.getUByte();
        return new InsnMultiDimArrayNew(classOp, nDims, myPC);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy