1 /*******************************************************************************
2 * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v0.5
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v05.html
9 * IBM Corporation - initial API and implementation
10 ******************************************************************************/
11 package net.sourceforge.phpdt.internal.compiler.ast;
13 import net.sourceforge.phpdt.internal.compiler.codegen.CodeStream;
14 import net.sourceforge.phpdt.internal.compiler.codegen.Label;
15 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
17 public abstract class BranchStatement extends Statement {
19 public Label targetLabel;
20 public AstNode[] subroutines;
22 * BranchStatement constructor comment.
24 public BranchStatement(char[] l, int s,int e) {
30 * Branch code generation
32 * generate the finallyInvocationSequence.
34 public void generateCode(BlockScope currentScope, CodeStream codeStream) {
36 if ((bits & IsReachableMASK) == 0) {
39 int pc = codeStream.position;
41 // generation of code responsible for invoking the finally
43 if (subroutines != null){
44 for (int i = 0, max = subroutines.length; i < max; i++){
46 if ((sub = subroutines[i]) instanceof SynchronizedStatement){
47 codeStream.load(((SynchronizedStatement)sub).synchroVariable);
48 codeStream.monitorexit();
50 TryStatement trySub = (TryStatement) sub;
51 if (trySub.subRoutineCannotReturn) {
52 codeStream.goto_(trySub.subRoutineStartLabel);
53 codeStream.recordPositionsFrom(pc, this.sourceStart);
56 codeStream.jsr(trySub.subRoutineStartLabel);
61 codeStream.goto_(targetLabel);
62 codeStream.recordPositionsFrom(pc, this.sourceStart);
64 public void resetStateForCodeGeneration() {
65 this.targetLabel.resetStateForCodeGeneration();