KickJava   Java API By Example, From Geeks To Geeks.

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


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.*;
14 import org.eclipse.jdt.internal.compiler.lookup.*;
15
16 public abstract class BranchStatement extends Statement {
17     
18     public char[] label;
19     public BranchLabel targetLabel;
20     public SubRoutineStatement[] subroutines;
21     public int initStateIndex = -1;
22
23 /**
24  * BranchStatement constructor comment.
25  */

26 public BranchStatement(char[] label, int sourceStart,int sourceEnd) {
27     this.label = label ;
28     this.sourceStart = sourceStart;
29     this.sourceEnd = sourceEnd;
30 }
31
32 /**
33  * Branch code generation
34  *
35  * generate the finallyInvocationSequence.
36  */

37 public void generateCode(BlockScope currentScope, CodeStream codeStream) {
38     if ((this.bits & ASTNode.IsReachable) == 0) {
39         return;
40     }
41     int pc = codeStream.position;
42
43     // generation of code responsible for invoking the finally
44
// blocks in sequence
45
if (this.subroutines != null){
46         for (int i = 0, max = this.subroutines.length; i < max; i++){
47             SubRoutineStatement sub = this.subroutines[i];
48             boolean didEscape = sub.generateSubRoutineInvocation(currentScope, codeStream, this.targetLabel, this.initStateIndex, null);
49             if (didEscape) {
50                     codeStream.recordPositionsFrom(pc, this.sourceStart);
51                     SubRoutineStatement.reenterAllExceptionHandlers(this.subroutines, i, codeStream);
52                     if (this.initStateIndex != -1) {
53                         codeStream.removeNotDefinitelyAssignedVariables(currentScope, this.initStateIndex);
54                         codeStream.addDefinitelyAssignedVariables(currentScope, this.initStateIndex);
55                     }
56                     return;
57             }
58         }
59     }
60     codeStream.goto_(this.targetLabel);
61     codeStream.recordPositionsFrom(pc, this.sourceStart);
62     SubRoutineStatement.reenterAllExceptionHandlers(this.subroutines, -1, codeStream);
63     if (this.initStateIndex != -1) {
64         codeStream.removeNotDefinitelyAssignedVariables(currentScope, this.initStateIndex);
65         codeStream.addDefinitelyAssignedVariables(currentScope, this.initStateIndex);
66     }
67 }
68
69 public void resolve(BlockScope scope) {
70     // nothing to do during name resolution
71
}
72 }
73
Popular Tags