1 /*
   2  * reserved comment block
   3  * DO NOT REMOVE OR ALTER!
   4  */
   5 /*
   6  * Copyright 2001-2004 The Apache Software Foundation.
   7  *
   8  * Licensed under the Apache License, Version 2.0 (the "License");
   9  * you may not use this file except in compliance with the License.
  10  * You may obtain a copy of the License at
  11  *
  12  *     http://www.apache.org/licenses/LICENSE-2.0
  13  *
  14  * Unless required by applicable law or agreed to in writing, software
  15  * distributed under the License is distributed on an "AS IS" BASIS,
  16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17  * See the License for the specific language governing permissions and
  18  * limitations under the License.
  19  */
  20 
  21 /*
  22  * $Id: MethodGenerator.java,v 1.10 2010-11-01 04:34:19 joehw Exp $
  23  */
  24 package com.sun.org.apache.xalan.internal.xsltc.compiler.util;
  25 import java.io.DataOutputStream;
  26 import java.io.IOException;
  27 
  28 import com.sun.org.apache.bcel.internal.Constants;
  29 import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen;
  30 import com.sun.org.apache.bcel.internal.generic.Instruction;
  31 import com.sun.org.apache.bcel.internal.generic.Visitor;
  32 
  33 /**
  34  * A special abstract dummy subclass of
  35  * {@link org.apache.bcel.generic.Instruction} used to mark locations of
  36  * interest in an {@link com.sun.org.apache.bcel.internal.generic.InstructionList}.  It and
  37  * its subclasses are only used as placeholders, and do not contribute to the
  38  * actual byte code instruction stream.
  39  */
  40 abstract class MarkerInstruction extends Instruction {
  41     /**
  42      * Zero-argument constructor.  Sets the opcode to an invalid value and
  43      * sets the length to zero, as it will not be written as part of the
  44      * generated byte code.
  45      */
  46     public MarkerInstruction() {
  47         super(Constants.UNDEFINED, (short) 0);
  48     }
  49 
  50     /**
  51      * {@link com.sun.org.apache.bcel.internal.generic.Visitor}s will know nothing about this
  52      * kind of {@link org.apche.bcel.generic.Instruction}, so this method does
  53      * nothing.
  54      */
  55     public void accept(Visitor v) {
  56     }
  57 
  58     /**
  59      * The number of JVM stack entries consumed by the instruction.
  60      * This instruction is just a place holder, so it does not consume any
  61      * stack entries.
  62      * @param cpg The {@link com.sun.org.apache.bcel.internal.generic.ConstantPoolGen} for the
  63      * current {@link com.sun.org.apache.bcel.internal.generic.ClassGen}
  64      * @return <code>0</code> always
  65      */
  66     final public int consumeStack(ConstantPoolGen cpg) {
  67         return 0;
  68     }
  69     /**
  70      * The number of JVM stack entries produced by the instruction.
  71      * This instruction is just a place holder, so it does not produce any
  72      * stack entries.
  73      * @param cpg The {@link com.sun.org.apache.bcel.internal.generic.ConstantPoolGen} for the
  74      * current {@link com.sun.org.apache.bcel.internal.generic.ClassGen}
  75      * @return <code>0</code> always
  76      */
  77     final public int produceStack(ConstantPoolGen cpg) {
  78         return 0;
  79     }
  80 
  81     /**
  82      * Produce a copy of the instruction.  By default a
  83      * {@link MarkerInstruction} has no parameters, so the base implementation
  84      * of {@link #copy()} returns the instruction itself.
  85      * @return The instruction itself.
  86      */
  87     public Instruction copy() {
  88         return this;
  89     }
  90     /**
  91      * Dump instruction as byte code to stream out.  A {@link MarkerInstruction}
  92      * has no effect on the generated byte code so it is never emitted to the
  93      * output stream.
  94      * @param out Output stream
  95      */
  96     final public void dump(DataOutputStream out) throws IOException {
  97     }
  98 }