KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > compiler > ast > SubRoutineStatement


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.compiler.ast;
12
13 import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
14 import org.eclipse.jdt.internal.compiler.codegen.ExceptionLabel;
15 import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
16 import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
17
18 /**
19  * Extra behavior for statements which are generating subroutines
20  */

21 public abstract class SubRoutineStatement extends Statement {
22     
23     public static void reenterAllExceptionHandlers(SubRoutineStatement[] subroutines, int max, CodeStream codeStream) {
24         if (subroutines == null) return;
25         if (max < 0) max = subroutines.length;
26         for (int i = 0; i < max; i++) {
27             SubRoutineStatement sub = subroutines[i];
28             sub.enterAnyExceptionHandler(codeStream);
29             sub.enterDeclaredExceptionHandlers(codeStream);
30         }
31     }
32     
33     ExceptionLabel anyExceptionLabel;
34
35     public ExceptionLabel enterAnyExceptionHandler(CodeStream codeStream) {
36         
37         if (this.anyExceptionLabel == null) {
38             this.anyExceptionLabel = new ExceptionLabel(codeStream, null /*any exception*/);
39         }
40         this.anyExceptionLabel.placeStart();
41         return this.anyExceptionLabel;
42     }
43     
44     public void enterDeclaredExceptionHandlers(CodeStream codeStream) {
45         // do nothing by default
46
}
47
48     public void exitAnyExceptionHandler() {
49         if (this.anyExceptionLabel != null) {
50             this.anyExceptionLabel.placeEnd();
51         }
52     }
53
54     public void exitDeclaredExceptionHandlers(CodeStream codeStream) {
55         // do nothing by default
56
}
57     
58
59     public abstract boolean generateSubRoutineInvocation(BlockScope currentScope, CodeStream codeStream, Object JavaDoc targetLocation, int stateIndex, LocalVariableBinding secretLocal);
60     
61     public abstract boolean isSubRoutineEscaping();
62     
63     public void placeAllAnyExceptionHandler() {
64         this.anyExceptionLabel.place();
65     }
66 }
67
Popular Tags