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