001: // This file is part of KeY - Integrated Deductive Software Design
002: // Copyright (C) 2001-2007 Universitaet Karlsruhe, Germany
003: // Universitaet Koblenz-Landau, Germany
004: // Chalmers University of Technology, Sweden
005: //
006: // The KeY system is protected by the GNU General Public License.
007: // See LICENSE.TXT for details.
008: //
009: //
010:
011: package de.uka.ilkd.key.java.statement;
012:
013: import de.uka.ilkd.key.java.Label;
014: import de.uka.ilkd.key.java.ProgramElement;
015: import de.uka.ilkd.key.java.reference.NameReference;
016: import de.uka.ilkd.key.logic.ProgramElementName;
017: import de.uka.ilkd.key.util.ExtList;
018:
019: /**
020: * Label jump statement.
021: *
022: */
023:
024: public abstract class LabelJumpStatement extends JumpStatement
025: implements NameReference {
026:
027: /**
028: * Name.
029: */
030:
031: protected final Label name;
032:
033: /**
034: * Label jump statement.
035: */
036:
037: public LabelJumpStatement() {
038: name = null;
039: }
040:
041: /**
042: * Label jump statement.
043: * @param label the Label of this jump statement
044: */
045:
046: public LabelJumpStatement(Label label) {
047: super ();
048: name = label;
049:
050: }
051:
052: /**
053: * Constructor for the transformation of COMPOST ASTs to KeY.
054: * @param children the children of this AST element as KeY classes.
055: */
056: public LabelJumpStatement(ExtList children) {
057: super (children);
058: name = (Label) children.get(Label.class);
059: }
060:
061: /**
062: * Get name.
063: * @return the string.
064: */
065: public final String getName() {
066: return (name == null) ? null : name.toString();
067: }
068:
069: /**
070: * Get Label.
071: * @return the Label label
072: */
073:
074: public Label getLabel() {
075: return name;
076: }
077:
078: /**
079: * Get identifier.
080: * @return the identifier.
081: */
082: public ProgramElementName getProgramElementName() {
083: if ((name instanceof ProgramElementName) || (name == null)) {
084: return (ProgramElementName) name;
085: }
086: return null;
087: }
088:
089: /**
090: * Returns the number of children of this node.
091: * @return an int giving the number of children of this node
092: */
093: public int getChildCount() {
094: return (name != null) ? 1 : 0;
095: }
096:
097: /**
098: * Returns the child at the specified index in this node's "virtual"
099: * child array
100: * @param index an index into this node's "virtual" child array
101: * @return the program element at the given position
102: * @exception ArrayIndexOutOfBoundsException if <tt>index</tt> is out
103: * of bounds
104: */
105: public ProgramElement getChildAt(int index) {
106: if (name != null) {
107: if (index == 0)
108: return name;
109: }
110: throw new ArrayIndexOutOfBoundsException();
111: }
112:
113: }
|