X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Feclipse%2Fjdt%2Finternal%2Fcompiler%2Fcodegen%2FCaseLabel.java;fp=src%2Forg%2Feclipse%2Fjdt%2Finternal%2Fcompiler%2Fcodegen%2FCaseLabel.java;h=725588ebb3e761eac5f5554dbd8cdef0b63c5f00;hb=040fa5af2cd00017cf3575950cdaade34a6d7f6c;hp=0000000000000000000000000000000000000000;hpb=a580fb8376d315d05e4d6bfdff9ff1101a151cd6;p=org.ibex.tool.git diff --git a/src/org/eclipse/jdt/internal/compiler/codegen/CaseLabel.java b/src/org/eclipse/jdt/internal/compiler/codegen/CaseLabel.java new file mode 100644 index 0000000..725588e --- /dev/null +++ b/src/org/eclipse/jdt/internal/compiler/codegen/CaseLabel.java @@ -0,0 +1,81 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.jdt.internal.compiler.codegen; + +public class CaseLabel extends Label { + public int instructionPosition = POS_NOT_SET; + public int backwardsBranch = POS_NOT_SET; +/** + * CaseLabel constructor comment. + * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream + */ +public CaseLabel(CodeStream codeStream) { + super(codeStream); +} +/* +* Put down a refernece to the array at the location in the codestream. +*/ +void branch() { + if (position == POS_NOT_SET) { + addForwardReference(codeStream.position); + // Leave 4 bytes free to generate the jump offset afterwards + codeStream.position += 4; + codeStream.classFileOffset += 4; + } else { //Position is set. Write it! + codeStream.writeSignedWord(position - codeStream.position + 1); + } +} +/* +* Put down a refernece to the array at the location in the codestream. +*/ +void branchWide() { + if (position == POS_NOT_SET) { + addForwardReference(codeStream.position); + // Leave 4 bytes free to generate the jump offset afterwards + codeStream.position += 4; + } else { //Position is set. Write it! + codeStream.writeSignedWord(position - codeStream.position + 1); + } +} +public boolean isStandardLabel(){ + return false; +} +/* +* Put down a reference to the array at the location in the codestream. +*/ +public void place() { + position = codeStream.position; + if (instructionPosition == POS_NOT_SET) + backwardsBranch = position; + else { + int offset = position - instructionPosition; + for (int i = 0; i < forwardReferenceCount; i++) { + codeStream.writeSignedWord(forwardReferences[i], offset); + } + // add the label int the codeStream labels collection + codeStream.addLabel(this); + } +} +/* +* Put down a refernece to the array at the location in the codestream. +*/ +void placeInstruction() { + if (instructionPosition == POS_NOT_SET) { + instructionPosition = codeStream.position; + if (backwardsBranch != POS_NOT_SET) { + int offset = backwardsBranch - instructionPosition; + for (int i = 0; i < forwardReferenceCount; i++) + codeStream.writeSignedWord(forwardReferences[i], offset); + backwardsBranch = POS_NOT_SET; + } + } +} +}