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
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpeclipse.internal.compiler.ast;
13 import net.sourceforge.phpdt.internal.compiler.ASTVisitor;
14 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
15 import net.sourceforge.phpdt.internal.compiler.lookup.LocalVariableBinding;
16 import net.sourceforge.phpdt.internal.compiler.lookup.MethodScope;
17 import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding;
19 public class Argument extends LocalDeclaration {
21 public Argument(char[] name, long posNom, TypeReference tr, int modifiers) {
23 super(null, name, (int) (posNom >>> 32), (int) posNom);
24 this.declarationSourceEnd = (int) posNom;
25 this.modifiers = modifiers;
27 this.bits |= IsLocalDeclarationReachableMASK;
30 public void bind(MethodScope scope, TypeBinding typeBinding, boolean used) {
32 if (this.type != null)
33 this.type.resolvedType = typeBinding;
34 // record the resolved type into the type reference
35 int modifierFlag = this.modifiers;
36 if ((this.binding = scope.duplicateName(this.name)) != null) {
37 //the name already exist....may carry on with the first binding ....
38 scope.problemReporter().redefineArgument(this);
40 scope.addLocalVariable(
42 new LocalVariableBinding(this, typeBinding, modifierFlag, true));
43 //true stand for argument instead of just local
44 if (typeBinding != null && isTypeUseDeprecated(typeBinding, scope))
45 scope.problemReporter().deprecatedType(typeBinding, this.type);
46 this.binding.declaration = this;
47 this.binding.useFlag = used ? LocalVariableBinding.USED : LocalVariableBinding.UNUSED;
51 public TypeBinding resolveForCatch(BlockScope scope) {
53 // resolution on an argument of a catch clause
54 // provide the scope with a side effect : insertion of a LOCAL
55 // that represents the argument. The type must be from JavaThrowable
57 TypeBinding tb = type.resolveTypeExpecting(scope, scope.getJavaLangThrowable());
60 if ((binding = scope.duplicateName(name)) != null) {
61 // the name already exists....may carry on with the first binding ....
62 scope.problemReporter().redefineArgument(this);
65 binding = new LocalVariableBinding(this, tb, modifiers, false); // argument decl, but local var (where isArgument = false)
66 scope.addLocalVariable(binding);
67 binding.constant = NotAConstant;
71 public String toString(int tab) {
73 String s = ""; //$NON-NLS-1$
74 if (modifiers != AccDefault) {
75 s += modifiersString(modifiers);
78 s += "<no type> "; //$NON-NLS-1$
80 s += type.toString(tab) + " "; //$NON-NLS-1$
82 s += new String(name);
86 public void traverse(ASTVisitor visitor, BlockScope scope) {
88 if (visitor.visit(this, scope)) {
90 type.traverse(visitor, scope);
91 if (initialization != null)
92 initialization.traverse(visitor, scope);
94 visitor.endVisit(this, scope);