Start the debugger through setting the url with "?DBGSESSID=1@clienthost:10001" in...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / internal / compiler / ast / ThrowStatement.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2003 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package net.sourceforge.phpeclipse.internal.compiler.ast;
12
13 import net.sourceforge.phpdt.internal.compiler.IAbstractSyntaxTreeVisitor;
14 import net.sourceforge.phpdt.internal.compiler.flow.FlowContext;
15 import net.sourceforge.phpdt.internal.compiler.flow.FlowInfo;
16 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
17 import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding;
18
19 public class ThrowStatement extends Statement {
20         public Expression exception;
21         public TypeBinding exceptionType;
22
23         public ThrowStatement(Expression exception, int startPosition) {
24                 this.exception = exception;
25                 this.sourceStart = startPosition;
26                 this.sourceEnd = exception.sourceEnd;
27         }
28
29         public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
30
31                 exception.analyseCode(currentScope, flowContext, flowInfo);
32                 // need to check that exception thrown is actually caught somewhere
33                 flowContext.checkExceptionHandlers(exceptionType, this, flowInfo, currentScope);
34                 return FlowInfo.DEAD_END;
35         }
36
37         /**
38          * Throw code generation
39          *
40          * @param currentScope org.eclipse.jdt.internal.compiler.lookup.BlockScope
41          * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
42          */
43 //      public void generateCode(BlockScope currentScope, CodeStream codeStream) {
44 //
45 //              if ((bits & IsReachableMASK) == 0)
46 //                      return;
47 //              int pc = codeStream.position;
48 //              exception.generateCode(currentScope, codeStream, true);
49 //              codeStream.athrow();
50 //              codeStream.recordPositionsFrom(pc, this.sourceStart);
51 //      }
52
53         public void resolve(BlockScope scope) {
54                 
55                 exceptionType = exception.resolveTypeExpecting(scope, scope.getJavaLangThrowable());
56                 
57 //              if (exceptionType == NullBinding
58 //                              && scope.environment().options.complianceLevel <= CompilerOptions.JDK1_3){
59 //                      // if compliant with 1.4, this problem will not be reported
60 //                      scope.problemReporter().cannotThrowNull(this);
61 //              }
62                 exception.implicitWidening(exceptionType, exceptionType);
63         }
64
65         public String toString(int tab) {
66                 String s = tabString(tab);
67                 s = s + "throw "; //$NON-NLS-1$
68                 s = s + exception.toStringExpression();
69                 return s;
70         }
71
72         public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope blockScope) {
73                 if (visitor.visit(this, blockScope))
74                         exception.traverse(visitor, blockScope);
75                 visitor.endVisit(this, blockScope);
76         }
77 }