001/* 002 * BioJava development code 003 * 004 * This code may be freely distributed and modified under the 005 * terms of the GNU Lesser General Public Licence. This should 006 * be distributed with the code. If you do not have a copy, 007 * see: 008 * 009 * http://www.gnu.org/copyleft/lesser.html 010 * 011 * Copyright for this code is held jointly by the individual 012 * authors. These should be listed in @author doc comments. 013 * 014 * For more information on the BioJava project and its aims, 015 * or to join the biojava-l mailing list, visit the home page 016 * at: 017 * 018 * http://www.biojava.org/ 019 * 020 */ 021package org.biojava.utils.bytecode; 022 023/** 024 * A Label used to mark a position in byte code. 025 * 026 * <p> 027 * Labels are used as the targets for jumps, and for exception handlers. Labels 028 * can be named. They implement CodeGenerator, which allows them to be added 029 * to things like an InstructionVector. The writeCode method takes care of 030 * marking the label with the context. 031 * </p> 032 * 033 * @author Thomas Down 034 * @author Matthew Pocock 035 */ 036public class Label implements CodeGenerator { 037 public String name; 038 039 public Label() { 040 name = null; 041 } 042 043 public Label(String name) { 044 this.name = name; 045 } 046 047 public String toString() { 048 if (name != null) 049 return name; 050 return super.toString(); 051 } 052 053 public void writeCode(CodeContext ctx) throws CodeException { 054 ctx.markLabel(this); 055 } 056 057 public int stackDepth() { 058 return 0; 059 } 060 061 public int stackDelta() { 062 return 0; 063 } 064}