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.IAbstractSyntaxTreeVisitor;
14 import net.sourceforge.phpdt.internal.compiler.lookup.*;
16 public class Argument extends LocalDeclaration {
18 public Argument(char[] name, long posNom, TypeReference tr, int modifiers) {
20 super(null, name, (int) (posNom >>> 32), (int) posNom);
21 this.modifiers = modifiers;
23 this.bits |= IsLocalDeclarationReachableMASK;
26 public void bind(MethodScope scope, TypeBinding typeBinding, boolean used) {
28 if (this.type != null)
29 this.type.binding = typeBinding;
30 // record the resolved type into the type reference
31 int modifierFlag = this.modifiers;
32 if ((this.binding = scope.duplicateName(this.name)) != null) {
33 //the name already exist....may carry on with the first binding ....
34 scope.problemReporter().redefineArgument(this);
36 scope.addLocalVariable(
38 new LocalVariableBinding(this, typeBinding, modifierFlag, true));
39 //true stand for argument instead of just local
40 if (typeBinding != null && isTypeUseDeprecated(typeBinding, scope))
41 scope.problemReporter().deprecatedType(typeBinding, this.type);
42 this.binding.declaration = this;
43 this.binding.used = used;
47 public TypeBinding resolveForCatch(BlockScope scope) {
49 // resolution on an argument of a catch clause
50 // provide the scope with a side effect : insertion of a LOCAL
51 // that represents the argument. The type must be from JavaThrowable
53 TypeBinding tb = type.resolveTypeExpecting(scope, scope.getJavaLangThrowable());
56 if ((binding = scope.duplicateName(name)) != null) {
57 // the name already exists....may carry on with the first binding ....
58 scope.problemReporter().redefineArgument(this);
61 binding = new LocalVariableBinding(this, tb, modifiers, false); // argument decl, but local var (i.e. isArgument = false)
62 scope.addLocalVariable(binding);
63 binding.constant = NotAConstant;
67 public String toString(int tab) {
69 String s = ""; //$NON-NLS-1$
70 if (modifiers != AccDefault) {
71 s += modifiersString(modifiers);
74 s += "<no type> "; //$NON-NLS-1$
76 s += type.toString(tab) + " "; //$NON-NLS-1$
78 s += new String(name);
82 public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope scope) {
84 if (visitor.visit(this, scope)) {
86 type.traverse(visitor, scope);
87 if (initialization != null)
88 initialization.traverse(visitor, scope);
90 visitor.endVisit(this, scope);