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.lookup;
13 import net.sourceforge.phpdt.internal.compiler.ast.AbstractMethodDeclaration;
14 import net.sourceforge.phpdt.internal.compiler.ast.Argument;
15 import net.sourceforge.phpdt.internal.compiler.ast.AstNode;
16 import net.sourceforge.phpdt.internal.compiler.ast.ConstructorDeclaration;
17 import net.sourceforge.phpdt.internal.compiler.ast.TypeDeclaration;
18 import net.sourceforge.phpdt.internal.compiler.codegen.CodeStream;
19 import net.sourceforge.phpdt.internal.compiler.impl.CompilerOptions;
20 import net.sourceforge.phpdt.internal.compiler.impl.Constant;
21 import net.sourceforge.phpdt.internal.compiler.problem.ProblemReporter;
22 import net.sourceforge.phpdt.internal.compiler.util.CharOperation;
24 public class BlockScope extends Scope {
26 // Local variable management
27 public LocalVariableBinding[] locals;
28 public int localIndex; // position for next variable
29 public int startIndex; // start position in this scope - for ordering scopes vs. variables
30 public int offset; // for variable allocation throughout scopes
31 public int maxOffset; // for variable allocation throughout scopes
33 // finally scopes must be shifted behind respective try scope
34 public BlockScope[] shiftScopes;
36 public final static VariableBinding[] EmulationPathToImplicitThis = {};
38 public Scope[] subscopes = new Scope[1]; // need access from code assist
39 public int scopeIndex = 0; // need access from code assist
41 protected BlockScope(int kind, Scope parent) {
46 public BlockScope(BlockScope parent) {
51 public BlockScope(BlockScope parent, boolean addToParentScope) {
53 this(BLOCK_SCOPE, parent);
54 locals = new LocalVariableBinding[5];
55 if (addToParentScope) parent.addSubscope(this);
56 this.startIndex = parent.localIndex;
59 public BlockScope(BlockScope parent, int variableCount) {
61 this(BLOCK_SCOPE, parent);
62 locals = new LocalVariableBinding[variableCount];
63 parent.addSubscope(this);
64 this.startIndex = parent.localIndex;
67 /* Create the class scope & binding for the anonymous type.
69 public final void addAnonymousType(
70 TypeDeclaration anonymousType,
71 ReferenceBinding superBinding) {
73 ClassScope anonymousClassScope = new ClassScope(this, anonymousType);
74 anonymousClassScope.buildAnonymousTypeBinding(
75 enclosingSourceType(),
79 /* Create the class scope & binding for the local type.
81 public final void addLocalType(TypeDeclaration localType) {
83 // check that the localType does not conflict with an enclosing type
84 ReferenceBinding type = enclosingSourceType();
86 if (CharOperation.equals(type.sourceName, localType.name)) {
87 problemReporter().hidingEnclosingType(localType);
90 type = type.enclosingType();
91 } while (type != null);
93 // check that the localType does not conflict with another sibling local type
96 if (((BlockScope) scope).findLocalType(localType.name) != null) {
97 problemReporter().duplicateNestedType(localType);
100 } while ((scope = scope.parent) instanceof BlockScope);
102 ClassScope localTypeScope = new ClassScope(this, localType);
103 localTypeScope.buildLocalTypeBinding(enclosingSourceType());
104 addSubscope(localTypeScope);
107 /* Insert a local variable into a given scope, updating its position
108 * and checking there are not too many locals or arguments allocated.
110 public final void addLocalVariable(LocalVariableBinding binding) {
112 checkAndSetModifiersForVariable(binding);
114 // insert local in scope
115 if (localIndex == locals.length)
119 (locals = new LocalVariableBinding[localIndex * 2]),
122 locals[localIndex++] = binding;
124 // update local variable binding
125 binding.declaringScope = this;
126 binding.id = this.outerMostMethodScope().analysisIndex++;
127 // share the outermost method scope analysisIndex
130 public void addSubscope(Scope childScope) {
131 if (scopeIndex == subscopes.length)
135 (subscopes = new Scope[scopeIndex * 2]),
138 subscopes[scopeIndex++] = childScope;
141 /* Answer true if the receiver is suitable for assigning final blank fields.
143 * i.e. is inside an initializer, a constructor or a clinit
145 public final boolean allowBlankFinalFieldAssignment(FieldBinding binding) {
147 if (enclosingSourceType() != binding.declaringClass)
150 MethodScope methodScope = methodScope();
151 if (methodScope.isStatic != binding.isStatic())
153 return methodScope.isInsideInitializer() // inside initializer
154 || ((AbstractMethodDeclaration) methodScope.referenceContext)
155 .isInitializationMethod();
156 // inside constructor or clinit
158 String basicToString(int tab) {
159 String newLine = "\n"; //$NON-NLS-1$
160 for (int i = tab; --i >= 0;)
161 newLine += "\t"; //$NON-NLS-1$
163 String s = newLine + "--- Block Scope ---"; //$NON-NLS-1$
164 newLine += "\t"; //$NON-NLS-1$
165 s += newLine + "locals:"; //$NON-NLS-1$
166 for (int i = 0; i < localIndex; i++)
167 s += newLine + "\t" + locals[i].toString(); //$NON-NLS-1$
168 s += newLine + "startIndex = " + startIndex; //$NON-NLS-1$
172 private void checkAndSetModifiersForVariable(LocalVariableBinding varBinding) {
174 int modifiers = varBinding.modifiers;
175 if ((modifiers & AccAlternateModifierProblem) != 0 && varBinding.declaration != null){
176 problemReporter().duplicateModifierForVariable(varBinding.declaration, this instanceof MethodScope);
178 int realModifiers = modifiers & AccJustFlag;
180 int unexpectedModifiers = ~AccFinal;
181 if ((realModifiers & unexpectedModifiers) != 0 && varBinding.declaration != null){
182 problemReporter().illegalModifierForVariable(varBinding.declaration, this instanceof MethodScope);
184 varBinding.modifiers = modifiers;
187 /* Compute variable positions in scopes given an initial position offset
188 * ignoring unused local variables.
190 * Special treatment to have Try secret return address variables located at non
191 * colliding positions. Return addresses are not allocated initially, but gathered
192 * and allocated behind all other variables.
194 public void computeLocalVariablePositions(
196 CodeStream codeStream) {
198 this.offset = initOffset;
199 this.maxOffset = initOffset;
201 // local variable init
202 int ilocal = 0, maxLocals = 0, localsLength = locals.length;
203 while ((maxLocals < localsLength) && (locals[maxLocals] != null))
205 boolean hasMoreVariables = maxLocals > 0;
208 int iscope = 0, maxScopes = 0, subscopesLength = subscopes.length;
209 while ((maxScopes < subscopesLength) && (subscopes[maxScopes] != null))
211 boolean hasMoreScopes = maxScopes > 0;
213 // iterate scopes and variables in parallel
214 while (hasMoreVariables || hasMoreScopes) {
216 && (!hasMoreVariables || (subscopes[iscope].startIndex() <= ilocal))) {
217 // consider subscope first
218 if (subscopes[iscope] instanceof BlockScope) {
219 BlockScope subscope = (BlockScope) subscopes[iscope];
220 int subOffset = subscope.shiftScopes == null ? this.offset : subscope.maxShiftedOffset();
221 subscope.computeLocalVariablePositions(subOffset, codeStream);
222 if (subscope.maxOffset > this.maxOffset)
223 this.maxOffset = subscope.maxOffset;
225 hasMoreScopes = ++iscope < maxScopes;
227 // consider variable first
228 LocalVariableBinding local = locals[ilocal];
230 // check if variable is actually used, and may force it to be preserved
231 boolean generatesLocal =
232 (local.used && (local.constant == Constant.NotAConstant)) || local.isArgument;
234 && (local.declaration != null) // unused (and non secret) local
235 && ((local.declaration.bits & AstNode.IsLocalDeclarationReachableMASK) != 0)) { // declaration is reachable
236 if (local.isArgument) // method argument
237 this.problemReporter().unusedArgument(local.declaration);
238 else if (!(local.declaration instanceof Argument)) // do not report unused catch arguments
239 this.problemReporter().unusedLocalVariable(local.declaration);
241 if (!generatesLocal) {
242 if (local.declaration != null
243 && environment().options.preserveAllLocalVariables) {
244 generatesLocal = true; // force it to be preserved in the generated code
248 if (generatesLocal) {
250 if (local.declaration != null) {
251 codeStream.record(local);
252 // record user local variables for attribute generation
254 // allocate variable position
255 local.resolvedPosition = this.offset;
257 // check for too many arguments/local variables
258 if (local.isArgument) {
259 if (this.offset > 0xFF) { // no more than 255 words of arguments
260 this.problemReporter().noMoreAvailableSpaceForArgument(local, local.declaration);
263 if (this.offset > 0xFFFF) { // no more than 65535 words of locals
264 this.problemReporter().noMoreAvailableSpaceForLocal(
265 local, local.declaration == null ? (AstNode)this.methodScope().referenceContext : local.declaration);
270 if ((local.type == LongBinding) || (local.type == DoubleBinding)) {
276 local.resolvedPosition = -1; // not generated
278 hasMoreVariables = ++ilocal < maxLocals;
281 if (this.offset > this.maxOffset)
282 this.maxOffset = this.offset;
285 /* Answer true if the variable name already exists within the receiver's scope.
287 public final LocalVariableBinding duplicateName(char[] name) {
288 for (int i = 0; i < localIndex; i++)
289 if (CharOperation.equals(name, locals[i].name))
292 if (this instanceof MethodScope)
295 return ((BlockScope) parent).duplicateName(name);
299 * Record the suitable binding denoting a synthetic field or constructor argument,
300 * mapping to the actual outer local variable in the scope context.
301 * Note that this may not need any effect, in case the outer local variable does not
302 * need to be emulated and can directly be used as is (using its back pointer to its
305 public void emulateOuterAccess(LocalVariableBinding outerLocalVariable) {
307 MethodScope currentMethodScope;
308 if ((currentMethodScope = this.methodScope())
309 != outerLocalVariable.declaringScope.methodScope()) {
310 NestedTypeBinding currentType = (NestedTypeBinding) this.enclosingSourceType();
312 //do nothing for member types, pre emulation was performed already
313 if (!currentType.isLocalType()) {
316 // must also add a synthetic field if we're not inside a constructor
317 if (!currentMethodScope.isInsideInitializerOrConstructor()) {
318 currentType.addSyntheticArgumentAndField(outerLocalVariable);
320 currentType.addSyntheticArgument(outerLocalVariable);
326 * Record the suitable binding denoting a synthetic field or constructor argument,
327 * mapping to a given actual enclosing instance type in the scope context.
328 * Skip it if the enclosingType is actually the current scope's enclosing type.
331 public void emulateOuterAccess(
332 ReferenceBinding targetEnclosingType,
333 boolean useDirectReference) {
335 ReferenceBinding currentType = enclosingSourceType();
336 if (currentType.isNestedType()
337 && currentType != targetEnclosingType){
338 /*&& !targetEnclosingType.isSuperclassOf(currentType)*/
340 if (useDirectReference) {
341 // the target enclosing type is not in scope, we directly refer it
342 // must also add a synthetic field if we're not inside a constructor
343 NestedTypeBinding currentNestedType = (NestedTypeBinding) currentType;
344 if (methodScope().isInsideInitializerOrConstructor())
345 currentNestedType.addSyntheticArgument(targetEnclosingType);
347 currentNestedType.addSyntheticArgumentAndField(targetEnclosingType);
349 } else { // indirect reference sequence
352 // saturate all the way up until reaching compatible enclosing type
353 while (currentType.isLocalType()){
354 NestedTypeBinding currentNestedType = (NestedTypeBinding) currentType;
355 currentType = currentNestedType.enclosingType;
358 if (methodScope().isInsideInitializerOrConstructor()) {
359 // must also add a synthetic field if we're not inside a constructor
360 currentNestedType.addSyntheticArgument(currentType);
362 currentNestedType.addSyntheticArgumentAndField(currentType);
364 } else if (currentNestedType == targetEnclosingType
365 || targetEnclosingType.isSuperclassOf(currentNestedType)) {
368 currentNestedType.addSyntheticArgumentAndField(currentType);
376 /* Note that it must never produce a direct access to the targetEnclosingType,
377 * but instead a field sequence (this$2.this$1.this$0) so as to handle such a test case:
385 * return (Object) A.this == (Object) B.this;
390 * new A().new B().new C();
393 * where we only want to deal with ONE enclosing instance for C (could not figure out an A for C)
395 public final ReferenceBinding findLocalType(char[] name) {
397 for (int i = 0, length = scopeIndex; i < length; i++) {
398 if (subscopes[i] instanceof ClassScope) {
399 SourceTypeBinding sourceType =
400 ((ClassScope) subscopes[i]).referenceContext.binding;
401 if (CharOperation.equals(sourceType.sourceName(), name))
408 public LocalVariableBinding findVariable(char[] variable) {
410 int variableLength = variable.length;
411 for (int i = 0, length = locals.length; i < length; i++) {
412 LocalVariableBinding local = locals[i];
415 if (local.name.length == variableLength
416 && CharOperation.prefixEquals(local.name, variable))
422 * flag is a mask of the following values VARIABLE (= FIELD or LOCAL), TYPE.
423 * Only bindings corresponding to the mask will be answered.
425 * if the VARIABLE mask is set then
426 * If the first name provided is a field (or local) then the field (or local) is answered
427 * Otherwise, package names and type names are consumed until a field is found.
428 * In this case, the field is answered.
430 * if the TYPE mask is set,
431 * package names and type names are consumed until the end of the input.
432 * Only if all of the input is consumed is the type answered
434 * All other conditions are errors, and a problem binding is returned.
436 * NOTE: If a problem binding is returned, senders should extract the compound name
437 * from the binding & not assume the problem applies to the entire compoundName.
439 * The VARIABLE mask has precedence over the TYPE mask.
441 * InvocationSite implements
442 * isSuperAccess(); this is used to determine if the discovered field is visible.
443 * setFieldIndex(int); this is used to record the number of names that were consumed.
445 * For example, getBinding({"foo","y","q", VARIABLE, site) will answer
446 * the binding for the field or local named "foo" (or an error binding if none exists).
447 * In addition, setFieldIndex(1) will be sent to the invocation site.
448 * If a type named "foo" exists, it will not be detected (and an error binding will be answered)
450 * IMPORTANT NOTE: This method is written under the assumption that compoundName is longer than length 1.
452 public Binding getBinding(char[][] compoundName, int mask, InvocationSite invocationSite) {
454 Binding binding = getBinding(compoundName[0], mask | TYPE | PACKAGE, invocationSite);
455 invocationSite.setFieldIndex(1);
456 if (binding instanceof VariableBinding) return binding;
457 compilationUnitScope().recordSimpleReference(compoundName[0]);
458 if (!binding.isValidBinding()) return binding;
460 int length = compoundName.length;
461 int currentIndex = 1;
462 foundType : if (binding instanceof PackageBinding) {
463 PackageBinding packageBinding = (PackageBinding) binding;
464 while (currentIndex < length) {
465 compilationUnitScope().recordReference(packageBinding.compoundName, compoundName[currentIndex]);
466 binding = packageBinding.getTypeOrPackage(compoundName[currentIndex++]);
467 invocationSite.setFieldIndex(currentIndex);
468 if (binding == null) {
469 if (currentIndex == length)
470 // must be a type if its the last name, otherwise we have no idea if its a package or type
471 return new ProblemReferenceBinding(
472 CharOperation.subarray(compoundName, 0, currentIndex),
475 return new ProblemBinding(
476 CharOperation.subarray(compoundName, 0, currentIndex),
479 if (binding instanceof ReferenceBinding) {
480 if (!binding.isValidBinding())
481 return new ProblemReferenceBinding(
482 CharOperation.subarray(compoundName, 0, currentIndex),
483 binding.problemId());
484 if (!((ReferenceBinding) binding).canBeSeenBy(this))
485 return new ProblemReferenceBinding(
486 CharOperation.subarray(compoundName, 0, currentIndex),
491 packageBinding = (PackageBinding) binding;
494 // It is illegal to request a PACKAGE from this method.
495 return new ProblemReferenceBinding(
496 CharOperation.subarray(compoundName, 0, currentIndex),
500 // know binding is now a ReferenceBinding
501 while (currentIndex < length) {
502 ReferenceBinding typeBinding = (ReferenceBinding) binding;
503 char[] nextName = compoundName[currentIndex++];
504 invocationSite.setFieldIndex(currentIndex);
505 invocationSite.setActualReceiverType(typeBinding);
506 if ((binding = findField(typeBinding, nextName, invocationSite)) != null) {
507 if (!binding.isValidBinding())
508 return new ProblemFieldBinding(
509 ((FieldBinding) binding).declaringClass,
510 CharOperation.subarray(compoundName, 0, currentIndex),
511 binding.problemId());
512 break; // binding is now a field
514 if ((binding = findMemberType(nextName, typeBinding)) == null)
515 return new ProblemBinding(
516 CharOperation.subarray(compoundName, 0, currentIndex),
519 if (!binding.isValidBinding())
520 return new ProblemReferenceBinding(
521 CharOperation.subarray(compoundName, 0, currentIndex),
522 binding.problemId());
525 if ((mask & FIELD) != 0 && (binding instanceof FieldBinding)) {
526 // was looking for a field and found a field
527 FieldBinding field = (FieldBinding) binding;
528 if (!field.isStatic())
529 return new ProblemFieldBinding(
530 field.declaringClass,
531 CharOperation.subarray(compoundName, 0, currentIndex),
532 NonStaticReferenceInStaticContext);
535 if ((mask & TYPE) != 0 && (binding instanceof ReferenceBinding)) {
536 // was looking for a type and found a type
540 // handle the case when a field or type was asked for but we resolved the compoundName to a type or field
541 return new ProblemBinding(
542 CharOperation.subarray(compoundName, 0, currentIndex),
546 // Added for code assist... NOT Public API
547 public final Binding getBinding(
548 char[][] compoundName,
549 InvocationSite invocationSite) {
550 int currentIndex = 0;
551 int length = compoundName.length;
554 compoundName[currentIndex++],
555 VARIABLE | TYPE | PACKAGE,
557 if (!binding.isValidBinding())
560 foundType : if (binding instanceof PackageBinding) {
561 while (currentIndex < length) {
562 PackageBinding packageBinding = (PackageBinding) binding;
563 binding = packageBinding.getTypeOrPackage(compoundName[currentIndex++]);
564 if (binding == null) {
565 if (currentIndex == length)
566 // must be a type if its the last name, otherwise we have no idea if its a package or type
567 return new ProblemReferenceBinding(
568 CharOperation.subarray(compoundName, 0, currentIndex),
571 return new ProblemBinding(
572 CharOperation.subarray(compoundName, 0, currentIndex),
575 if (binding instanceof ReferenceBinding) {
576 if (!binding.isValidBinding())
577 return new ProblemReferenceBinding(
578 CharOperation.subarray(compoundName, 0, currentIndex),
579 binding.problemId());
580 if (!((ReferenceBinding) binding).canBeSeenBy(this))
581 return new ProblemReferenceBinding(
582 CharOperation.subarray(compoundName, 0, currentIndex),
591 foundField : if (binding instanceof ReferenceBinding) {
592 while (currentIndex < length) {
593 ReferenceBinding typeBinding = (ReferenceBinding) binding;
594 char[] nextName = compoundName[currentIndex++];
595 if ((binding = findField(typeBinding, nextName, invocationSite)) != null) {
596 if (!binding.isValidBinding())
597 return new ProblemFieldBinding(
598 ((FieldBinding) binding).declaringClass,
599 CharOperation.subarray(compoundName, 0, currentIndex),
600 binding.problemId());
601 if (!((FieldBinding) binding).isStatic())
602 return new ProblemFieldBinding(
603 ((FieldBinding) binding).declaringClass,
604 CharOperation.subarray(compoundName, 0, currentIndex),
605 NonStaticReferenceInStaticContext);
606 break foundField; // binding is now a field
608 if ((binding = findMemberType(nextName, typeBinding)) == null)
609 return new ProblemBinding(
610 CharOperation.subarray(compoundName, 0, currentIndex),
613 if (!binding.isValidBinding())
614 return new ProblemReferenceBinding(
615 CharOperation.subarray(compoundName, 0, currentIndex),
616 binding.problemId());
621 VariableBinding variableBinding = (VariableBinding) binding;
622 while (currentIndex < length) {
623 TypeBinding typeBinding = variableBinding.type;
624 if (typeBinding == null)
625 return new ProblemFieldBinding(
627 CharOperation.subarray(compoundName, 0, currentIndex + 1),
630 findField(typeBinding, compoundName[currentIndex++], invocationSite);
631 if (variableBinding == null)
632 return new ProblemFieldBinding(
634 CharOperation.subarray(compoundName, 0, currentIndex),
636 if (!variableBinding.isValidBinding())
637 return variableBinding;
639 return variableBinding;
644 * Answer the binding that corresponds to the argument name.
645 * flag is a mask of the following values VARIABLE (= FIELD or LOCAL), TYPE, PACKAGE.
646 * Only bindings corresponding to the mask can be answered.
648 * For example, getBinding("foo", VARIABLE, site) will answer
649 * the binding for the field or local named "foo" (or an error binding if none exists).
650 * If a type named "foo" exists, it will not be detected (and an error binding will be answered)
652 * The VARIABLE mask has precedence over the TYPE mask.
654 * If the VARIABLE mask is not set, neither fields nor locals will be looked for.
656 * InvocationSite implements:
657 * isSuperAccess(); this is used to determine if the discovered field is visible.
659 * Limitations: cannot request FIELD independently of LOCAL, or vice versa
661 public Binding getBinding(char[] name, int mask, InvocationSite invocationSite) {
663 Binding binding = null;
664 FieldBinding problemField = null;
665 if ((mask & VARIABLE) != 0) {
666 if (this.kind == BLOCK_SCOPE || this.kind == METHOD_SCOPE) {
667 LocalVariableBinding variableBinding = findVariable(name);
668 // looks in this scope only
669 if (variableBinding != null) return variableBinding;
672 boolean insideStaticContext = false;
673 boolean insideConstructorCall = false;
674 if (this.kind == METHOD_SCOPE) {
675 MethodScope methodScope = (MethodScope) this;
676 insideStaticContext |= methodScope.isStatic;
677 insideConstructorCall |= methodScope.isConstructorCall;
680 FieldBinding foundField = null;
681 // can be a problem field which is answered if a valid field is not found
682 ProblemFieldBinding foundInsideProblem = null;
683 // inside Constructor call or inside static context
684 Scope scope = parent;
687 ReferenceBinding foundActualReceiverType = null;
688 done : while (true) { // done when a COMPILATION_UNIT_SCOPE is found
689 switch (scope.kind) {
691 MethodScope methodScope = (MethodScope) scope;
692 insideStaticContext |= methodScope.isStatic;
693 insideConstructorCall |= methodScope.isConstructorCall;
694 // Fall through... could duplicate the code below to save a cast - questionable optimization
696 LocalVariableBinding variableBinding = ((BlockScope) scope).findVariable(name);
697 // looks in this scope only
698 if (variableBinding != null) {
699 if (foundField != null && foundField.isValidBinding())
700 return new ProblemFieldBinding(
701 foundField.declaringClass,
703 InheritedNameHidesEnclosingName);
705 invocationSite.setDepth(depth);
706 return variableBinding;
710 ClassScope classScope = (ClassScope) scope;
711 SourceTypeBinding enclosingType = classScope.referenceContext.binding;
712 FieldBinding fieldBinding =
713 classScope.findField(enclosingType, name, invocationSite);
714 // Use next line instead if willing to enable protected access accross inner types
715 // FieldBinding fieldBinding = findField(enclosingType, name, invocationSite);
716 if (fieldBinding != null) { // skip it if we did not find anything
717 if (fieldBinding.problemId() == Ambiguous) {
718 if (foundField == null || foundField.problemId() == NotVisible)
719 // supercedes any potential InheritedNameHidesEnclosingName problem
722 // make the user qualify the field, likely wants the first inherited field (javac generates an ambiguous error instead)
723 return new ProblemFieldBinding(
724 fieldBinding.declaringClass,
726 InheritedNameHidesEnclosingName);
729 ProblemFieldBinding insideProblem = null;
730 if (fieldBinding.isValidBinding()) {
731 if (!fieldBinding.isStatic()) {
732 if (insideConstructorCall) {
734 new ProblemFieldBinding(
735 fieldBinding.declaringClass,
737 NonStaticReferenceInConstructorInvocation);
738 } else if (insideStaticContext) {
740 new ProblemFieldBinding(
741 fieldBinding.declaringClass,
743 NonStaticReferenceInStaticContext);
746 if (enclosingType == fieldBinding.declaringClass
747 || environment().options.complianceLevel >= CompilerOptions.JDK1_4){
748 // found a valid field in the 'immediate' scope (ie. not inherited)
749 // OR in 1.4 mode (inherited shadows enclosing)
750 if (foundField == null) {
752 invocationSite.setDepth(depth);
753 invocationSite.setActualReceiverType(enclosingType);
755 // return the fieldBinding if it is not declared in a superclass of the scope's binding (i.e. "inherited")
756 return insideProblem == null ? fieldBinding : insideProblem;
758 if (foundField.isValidBinding())
759 // if a valid field was found, complain when another is found in an 'immediate' enclosing type (ie. not inherited)
760 if (foundField.declaringClass != fieldBinding.declaringClass)
761 // ie. have we found the same field - do not trust field identity yet
762 return new ProblemFieldBinding(
763 fieldBinding.declaringClass,
765 InheritedNameHidesEnclosingName);
769 if (foundField == null
770 || (foundField.problemId() == NotVisible
771 && fieldBinding.problemId() != NotVisible)) {
772 // only remember the fieldBinding if its the first one found or the previous one was not visible & fieldBinding is...
774 foundActualReceiverType = enclosingType;
775 foundInsideProblem = insideProblem;
776 foundField = fieldBinding;
780 insideStaticContext |= enclosingType.isStatic();
781 // 1EX5I8Z - accessing outer fields within a constructor call is permitted
782 // in order to do so, we change the flag as we exit from the type, not the method
783 // itself, because the class scope is used to retrieve the fields.
784 MethodScope enclosingMethodScope = scope.methodScope();
785 insideConstructorCall =
786 enclosingMethodScope == null ? false : enclosingMethodScope.isConstructorCall;
788 case COMPILATION_UNIT_SCOPE :
791 scope = scope.parent;
794 if (foundInsideProblem != null){
795 return foundInsideProblem;
797 if (foundField != null) {
798 if (foundField.isValidBinding()){
800 invocationSite.setDepth(foundDepth);
801 invocationSite.setActualReceiverType(foundActualReceiverType);
805 problemField = foundField;
809 // We did not find a local or instance variable.
810 if ((mask & TYPE) != 0) {
811 if ((binding = getBaseType(name)) != null)
813 binding = getTypeOrPackage(name, (mask & PACKAGE) == 0 ? TYPE : TYPE | PACKAGE);
814 if (binding.isValidBinding() || mask == TYPE)
816 // answer the problem type binding if we are only looking for a type
817 } else if ((mask & PACKAGE) != 0) {
818 compilationUnitScope().recordSimpleReference(name);
819 if ((binding = environment().getTopLevelPackage(name)) != null)
822 if (problemField != null)
825 return new ProblemBinding(name, enclosingSourceType(), NotFound);
829 * This retrieves the argument that maps to an enclosing instance of the suitable type,
830 * if not found then answers nil -- do not create one
832 * #implicitThis : the implicit this will be ok
833 * #((arg) this$n) : available as a constructor arg
834 * #((arg) this$n access$m... access$p) : available as as a constructor arg + a sequence of synthetic accessors to synthetic fields
835 * #((fieldDescr) this$n access#m... access$p) : available as a first synthetic field + a sequence of synthetic accessors to synthetic fields
839 public Object[] getCompatibleEmulationPath(ReferenceBinding targetEnclosingType) {
841 MethodScope currentMethodScope = this.methodScope();
842 SourceTypeBinding sourceType = currentMethodScope.enclosingSourceType();
845 if (!currentMethodScope.isStatic
846 && !currentMethodScope.isConstructorCall
847 && (sourceType == targetEnclosingType
848 || targetEnclosingType.isSuperclassOf(sourceType))) {
849 return EmulationPathToImplicitThis; // implicit this is good enough
851 if (!sourceType.isNestedType()
852 || sourceType.isStatic()) { // no emulation from within non-inner types
855 boolean insideConstructor =
856 currentMethodScope.isInsideInitializerOrConstructor();
857 // use synthetic constructor arguments if possible
858 if (insideConstructor) {
859 SyntheticArgumentBinding syntheticArg;
860 if ((syntheticArg = ((NestedTypeBinding) sourceType).getSyntheticArgument(targetEnclosingType, this, false)) != null) {
861 return new Object[] { syntheticArg };
865 // use a direct synthetic field then
866 if (!currentMethodScope.isStatic) {
867 FieldBinding syntheticField;
868 if ((syntheticField = sourceType.getSyntheticField(targetEnclosingType, this, false)) != null) {
869 return new Object[] { syntheticField };
871 // could be reached through a sequence of enclosing instance link (nested members)
872 Object[] path = new Object[2]; // probably at least 2 of them
873 ReferenceBinding currentType = sourceType.enclosingType();
874 if (insideConstructor) {
875 path[0] = ((NestedTypeBinding) sourceType).getSyntheticArgument((SourceTypeBinding) currentType, this, false);
878 sourceType.getSyntheticField((SourceTypeBinding) currentType, this, false);
880 if (path[0] != null) { // keep accumulating
882 ReferenceBinding currentEnclosingType;
883 while ((currentEnclosingType = currentType.enclosingType()) != null) {
885 if (currentType == targetEnclosingType
886 || targetEnclosingType.isSuperclassOf(currentType))
888 syntheticField = ((NestedTypeBinding) currentType).getSyntheticField((SourceTypeBinding) currentEnclosingType, this, false);
889 if (syntheticField == null)
891 // append inside the path
892 if (count == path.length) {
893 System.arraycopy(path, 0, (path = new Object[count + 1]), 0, count);
895 // private access emulation is necessary since synthetic field is private
896 path[count++] = ((SourceTypeBinding) syntheticField.declaringClass).addSyntheticMethod(syntheticField, true);
897 currentType = currentEnclosingType;
899 if (currentType == targetEnclosingType
900 || targetEnclosingType.isSuperclassOf(currentType)) {
910 * Answer the constructor binding that corresponds to receiverType, argumentTypes.
912 * InvocationSite implements
913 * isSuperAccess(); this is used to determine if the discovered constructor is visible.
915 * If no visible constructor is discovered, an error binding is answered.
917 public MethodBinding getConstructor(
918 ReferenceBinding receiverType,
919 TypeBinding[] argumentTypes,
920 InvocationSite invocationSite) {
922 compilationUnitScope().recordTypeReference(receiverType);
923 compilationUnitScope().recordTypeReferences(argumentTypes);
924 MethodBinding methodBinding = receiverType.getExactConstructor(argumentTypes);
925 if (methodBinding != null)
926 if (methodBinding.canBeSeenBy(invocationSite, this))
927 return methodBinding;
929 MethodBinding[] methods =
930 receiverType.getMethods(ConstructorDeclaration.ConstantPoolName);
931 if (methods == NoMethods)
932 return new ProblemMethodBinding(
933 ConstructorDeclaration.ConstantPoolName,
937 MethodBinding[] compatible = new MethodBinding[methods.length];
938 int compatibleIndex = 0;
939 for (int i = 0, length = methods.length; i < length; i++)
940 if (areParametersAssignable(methods[i].parameters, argumentTypes))
941 compatible[compatibleIndex++] = methods[i];
942 if (compatibleIndex == 0)
943 return new ProblemMethodBinding(
944 ConstructorDeclaration.ConstantPoolName,
947 // need a more descriptive error... cannot convert from X to Y
949 MethodBinding[] visible = new MethodBinding[compatibleIndex];
950 int visibleIndex = 0;
951 for (int i = 0; i < compatibleIndex; i++) {
952 MethodBinding method = compatible[i];
953 if (method.canBeSeenBy(invocationSite, this))
954 visible[visibleIndex++] = method;
956 if (visibleIndex == 1)
958 if (visibleIndex == 0)
959 return new ProblemMethodBinding(
960 ConstructorDeclaration.ConstantPoolName,
963 return mostSpecificClassMethodBinding(visible, visibleIndex);
967 * This retrieves the argument that maps to an enclosing instance of the suitable type,
968 * if not found then answers nil -- do not create one
970 * #implicitThis : the implicit this will be ok
971 * #((arg) this$n) : available as a constructor arg
972 * #((arg) this$n ... this$p) : available as as a constructor arg + a sequence of fields
973 * #((fieldDescr) this$n ... this$p) : available as a sequence of fields
976 * Note that this algorithm should answer the shortest possible sequence when
977 * shortcuts are available:
978 * this$0 . this$0 . this$0
980 * this$2 . this$1 . this$0 . this$1 . this$0
981 * thus the code generation will be more compact and runtime faster
983 public VariableBinding[] getEmulationPath(LocalVariableBinding outerLocalVariable) {
985 MethodScope currentMethodScope = this.methodScope();
986 SourceTypeBinding sourceType = currentMethodScope.enclosingSourceType();
989 if (currentMethodScope == outerLocalVariable.declaringScope.methodScope()) {
990 return new VariableBinding[] { outerLocalVariable };
991 // implicit this is good enough
993 // use synthetic constructor arguments if possible
994 if (currentMethodScope.isInsideInitializerOrConstructor()
995 && (sourceType.isNestedType())) {
996 SyntheticArgumentBinding syntheticArg;
997 if ((syntheticArg = ((NestedTypeBinding) sourceType).getSyntheticArgument(outerLocalVariable)) != null) {
998 return new VariableBinding[] { syntheticArg };
1001 // use a synthetic field then
1002 if (!currentMethodScope.isStatic) {
1003 FieldBinding syntheticField;
1004 if ((syntheticField = sourceType.getSyntheticField(outerLocalVariable)) != null) {
1005 return new VariableBinding[] { syntheticField };
1012 * This retrieves the argument that maps to an enclosing instance of the suitable type,
1013 * if not found then answers nil -- do not create one
1015 * #implicitThis : the implicit this will be ok
1016 * #((arg) this$n) : available as a constructor arg
1017 * #((arg) this$n access$m... access$p) : available as as a constructor arg + a sequence of synthetic accessors to synthetic fields
1018 * #((fieldDescr) this$n access#m... access$p) : available as a first synthetic field + a sequence of synthetic accessors to synthetic fields
1021 * EXACT MATCH VERSION - no type compatibility is performed
1023 public Object[] getExactEmulationPath(ReferenceBinding targetEnclosingType) {
1025 MethodScope currentMethodScope = this.methodScope();
1026 SourceTypeBinding sourceType = currentMethodScope.enclosingSourceType();
1029 if (!currentMethodScope.isStatic
1030 && !currentMethodScope.isConstructorCall
1031 && (sourceType == targetEnclosingType)) {
1032 return EmulationPathToImplicitThis; // implicit this is good enough
1034 if (!sourceType.isNestedType()
1035 || sourceType.isStatic()) { // no emulation from within non-inner types
1039 boolean insideConstructor =
1040 currentMethodScope.isInsideInitializerOrConstructor();
1041 // use synthetic constructor arguments if possible
1042 if (insideConstructor) {
1043 SyntheticArgumentBinding syntheticArg;
1044 if ((syntheticArg = ((NestedTypeBinding) sourceType).getSyntheticArgument(targetEnclosingType, this, true)) != null) {
1045 return new Object[] { syntheticArg };
1048 // use a direct synthetic field then
1049 if (!currentMethodScope.isStatic) {
1050 FieldBinding syntheticField;
1051 if ((syntheticField = sourceType.getSyntheticField(targetEnclosingType, this, true)) != null) {
1052 return new Object[] { syntheticField };
1054 // could be reached through a sequence of enclosing instance link (nested members)
1055 Object[] path = new Object[2]; // probably at least 2 of them
1056 ReferenceBinding currentType = sourceType.enclosingType();
1057 if (insideConstructor) {
1059 ((NestedTypeBinding) sourceType).getSyntheticArgument((SourceTypeBinding) currentType, this, true);
1062 sourceType.getSyntheticField((SourceTypeBinding) currentType, this, true);
1064 if (path[0] != null) { // keep accumulating
1066 ReferenceBinding currentEnclosingType;
1067 while ((currentEnclosingType = currentType.enclosingType()) != null) {
1069 if (currentType == targetEnclosingType)
1072 ((NestedTypeBinding) currentType).getSyntheticField(
1073 (SourceTypeBinding) currentEnclosingType,
1076 if (syntheticField == null)
1078 // append inside the path
1079 if (count == path.length) {
1080 System.arraycopy(path, 0, (path = new Object[count + 1]), 0, count);
1082 // private access emulation is necessary since synthetic field is private
1083 path[count++] = ((SourceTypeBinding) syntheticField.declaringClass).addSyntheticMethod(syntheticField, true);
1084 currentType = currentEnclosingType;
1086 if (currentType == targetEnclosingType) {
1096 * Answer the field binding that corresponds to fieldName.
1097 * Start the lookup at the receiverType.
1098 * InvocationSite implements
1099 * isSuperAccess(); this is used to determine if the discovered field is visible.
1100 * Only fields defined by the receiverType or its supertypes are answered;
1101 * a field of an enclosing type will not be found using this API.
1103 * If no visible field is discovered, an error binding is answered.
1105 public FieldBinding getField(
1106 TypeBinding receiverType,
1108 InvocationSite invocationSite) {
1110 FieldBinding field = findField(receiverType, fieldName, invocationSite);
1112 return new ProblemFieldBinding(
1113 receiverType instanceof ReferenceBinding
1114 ? (ReferenceBinding) receiverType
1124 * Answer the method binding that corresponds to selector, argumentTypes.
1125 * Start the lookup at the enclosing type of the receiver.
1126 * InvocationSite implements
1127 * isSuperAccess(); this is used to determine if the discovered method is visible.
1128 * setDepth(int); this is used to record the depth of the discovered method
1129 * relative to the enclosing type of the receiver. (If the method is defined
1130 * in the enclosing type of the receiver, the depth is 0; in the next enclosing
1131 * type, the depth is 1; and so on
1133 * If no visible method is discovered, an error binding is answered.
1135 public MethodBinding getImplicitMethod(
1137 TypeBinding[] argumentTypes,
1138 InvocationSite invocationSite) {
1140 boolean insideStaticContext = false;
1141 boolean insideConstructorCall = false;
1142 MethodBinding foundMethod = null;
1143 ProblemMethodBinding foundFuzzyProblem = null;
1144 // the weird method lookup case (matches method name in scope, then arg types, then visibility)
1145 ProblemMethodBinding foundInsideProblem = null;
1146 // inside Constructor call or inside static context
1149 done : while (true) { // done when a COMPILATION_UNIT_SCOPE is found
1150 switch (scope.kind) {
1152 MethodScope methodScope = (MethodScope) scope;
1153 insideStaticContext |= methodScope.isStatic;
1154 insideConstructorCall |= methodScope.isConstructorCall;
1157 ClassScope classScope = (ClassScope) scope;
1158 SourceTypeBinding receiverType = classScope.referenceContext.binding;
1159 boolean isExactMatch = true;
1160 // retrieve an exact visible match (if possible)
1161 MethodBinding methodBinding =
1162 (foundMethod == null)
1163 ? classScope.findExactMethod(
1168 : classScope.findExactMethod(
1170 foundMethod.selector,
1171 foundMethod.parameters,
1173 // ? findExactMethod(receiverType, selector, argumentTypes, invocationSite)
1174 // : findExactMethod(receiverType, foundMethod.selector, foundMethod.parameters, invocationSite);
1175 if (methodBinding == null) {
1176 // answers closest approximation, may not check argumentTypes or visibility
1177 isExactMatch = false;
1179 classScope.findMethod(receiverType, selector, argumentTypes, invocationSite);
1180 // methodBinding = findMethod(receiverType, selector, argumentTypes, invocationSite);
1182 if (methodBinding != null) { // skip it if we did not find anything
1183 if (methodBinding.problemId() == Ambiguous) {
1184 if (foundMethod == null || foundMethod.problemId() == NotVisible)
1185 // supercedes any potential InheritedNameHidesEnclosingName problem
1186 return methodBinding;
1188 // make the user qualify the method, likely wants the first inherited method (javac generates an ambiguous error instead)
1189 return new ProblemMethodBinding(
1192 InheritedNameHidesEnclosingName);
1195 ProblemMethodBinding fuzzyProblem = null;
1196 ProblemMethodBinding insideProblem = null;
1197 if (methodBinding.isValidBinding()) {
1198 if (!isExactMatch) {
1199 if (!areParametersAssignable(methodBinding.parameters, argumentTypes)) {
1200 if (foundMethod == null || foundMethod.problemId() == NotVisible){
1201 // inherited mismatch is reported directly, not looking at enclosing matches
1202 return new ProblemMethodBinding(methodBinding, selector, argumentTypes, NotFound);
1204 // make the user qualify the method, likely wants the first inherited method (javac generates an ambiguous error instead)
1205 fuzzyProblem = new ProblemMethodBinding(selector, argumentTypes, InheritedNameHidesEnclosingName);
1207 } else if (!methodBinding.canBeSeenBy(receiverType, invocationSite, classScope)) {
1208 // using <classScope> instead of <this> for visibility check does grant all access to innerclass
1210 new ProblemMethodBinding(
1213 methodBinding.declaringClass,
1217 if (fuzzyProblem == null && !methodBinding.isStatic()) {
1218 if (insideConstructorCall) {
1220 new ProblemMethodBinding(
1221 methodBinding.selector,
1222 methodBinding.parameters,
1223 NonStaticReferenceInConstructorInvocation);
1224 } else if (insideStaticContext) {
1226 new ProblemMethodBinding(
1227 methodBinding.selector,
1228 methodBinding.parameters,
1229 NonStaticReferenceInStaticContext);
1233 if (receiverType == methodBinding.declaringClass
1234 || (receiverType.getMethods(selector)) != NoMethods
1235 || ((fuzzyProblem == null || fuzzyProblem.problemId() != NotVisible) && environment().options.complianceLevel >= CompilerOptions.JDK1_4)){
1236 // found a valid method in the 'immediate' scope (ie. not inherited)
1237 // OR the receiverType implemented a method with the correct name
1238 // OR in 1.4 mode (inherited visible shadows enclosing)
1239 if (foundMethod == null) {
1241 invocationSite.setDepth(depth);
1242 invocationSite.setActualReceiverType(receiverType);
1244 // return the methodBinding if it is not declared in a superclass of the scope's binding (i.e. "inherited")
1245 if (fuzzyProblem != null)
1246 return fuzzyProblem;
1247 if (insideProblem != null)
1248 return insideProblem;
1249 return methodBinding;
1251 // if a method was found, complain when another is found in an 'immediate' enclosing type (ie. not inherited)
1252 // NOTE: Unlike fields, a non visible method hides a visible method
1253 if (foundMethod.declaringClass != methodBinding.declaringClass)
1254 // ie. have we found the same method - do not trust field identity yet
1255 return new ProblemMethodBinding(
1256 methodBinding.selector,
1257 methodBinding.parameters,
1258 InheritedNameHidesEnclosingName);
1262 if (foundMethod == null
1263 || (foundMethod.problemId() == NotVisible
1264 && methodBinding.problemId() != NotVisible)) {
1265 // only remember the methodBinding if its the first one found or the previous one was not visible & methodBinding is...
1266 // remember that private methods are visible if defined directly by an enclosing class
1268 invocationSite.setDepth(depth);
1269 invocationSite.setActualReceiverType(receiverType);
1271 foundFuzzyProblem = fuzzyProblem;
1272 foundInsideProblem = insideProblem;
1273 if (fuzzyProblem == null)
1274 foundMethod = methodBinding; // only keep it if no error was found
1278 insideStaticContext |= receiverType.isStatic();
1279 // 1EX5I8Z - accessing outer fields within a constructor call is permitted
1280 // in order to do so, we change the flag as we exit from the type, not the method
1281 // itself, because the class scope is used to retrieve the fields.
1282 MethodScope enclosingMethodScope = scope.methodScope();
1283 insideConstructorCall =
1284 enclosingMethodScope == null ? false : enclosingMethodScope.isConstructorCall;
1286 case COMPILATION_UNIT_SCOPE :
1289 scope = scope.parent;
1292 if (foundFuzzyProblem != null)
1293 return foundFuzzyProblem;
1294 if (foundInsideProblem != null)
1295 return foundInsideProblem;
1296 if (foundMethod != null)
1298 return new ProblemMethodBinding(selector, argumentTypes, NotFound);
1303 * Answer the method binding that corresponds to selector, argumentTypes.
1304 * Start the lookup at the receiverType.
1305 * InvocationSite implements
1306 * isSuperAccess(); this is used to determine if the discovered method is visible.
1308 * Only methods defined by the receiverType or its supertypes are answered;
1309 * use getImplicitMethod() to discover methods of enclosing types.
1311 * If no visible method is discovered, an error binding is answered.
1313 public MethodBinding getMethod(
1314 TypeBinding receiverType,
1316 TypeBinding[] argumentTypes,
1317 InvocationSite invocationSite) {
1319 if (receiverType.isArrayType())
1320 return findMethodForArray(
1321 (ArrayBinding) receiverType,
1325 if (receiverType.isBaseType())
1326 return new ProblemMethodBinding(selector, argumentTypes, NotFound);
1328 ReferenceBinding currentType = (ReferenceBinding) receiverType;
1329 if (!currentType.canBeSeenBy(this))
1330 return new ProblemMethodBinding(selector, argumentTypes, NotVisible);
1331 // *** Need a new problem id - TypeNotVisible?
1333 // retrieve an exact visible match (if possible)
1334 MethodBinding methodBinding =
1335 findExactMethod(currentType, selector, argumentTypes, invocationSite);
1336 if (methodBinding != null)
1337 return methodBinding;
1339 // answers closest approximation, may not check argumentTypes or visibility
1341 findMethod(currentType, selector, argumentTypes, invocationSite);
1342 if (methodBinding == null)
1343 return new ProblemMethodBinding(selector, argumentTypes, NotFound);
1344 if (methodBinding.isValidBinding()) {
1345 if (!areParametersAssignable(methodBinding.parameters, argumentTypes))
1346 return new ProblemMethodBinding(
1351 if (!methodBinding.canBeSeenBy(currentType, invocationSite, this))
1352 return new ProblemMethodBinding(
1355 methodBinding.declaringClass,
1358 return methodBinding;
1361 public int maxShiftedOffset() {
1363 if (this.shiftScopes != null){
1364 for (int i = 0, length = this.shiftScopes.length; i < length; i++){
1365 int subMaxOffset = this.shiftScopes[i].maxOffset;
1366 if (subMaxOffset > max) max = subMaxOffset;
1372 /* Answer the problem reporter to use for raising new problems.
1374 * Note that as a side-effect, this updates the current reference context
1375 * (unit, type or method) in case the problem handler decides it is necessary
1378 public ProblemReporter problemReporter() {
1380 return outerMostMethodScope().problemReporter();
1384 * Code responsible to request some more emulation work inside the invocation type, so as to supply
1385 * correct synthetic arguments to any allocation of the target type.
1387 public void propagateInnerEmulation(
1388 ReferenceBinding targetType,
1389 boolean isEnclosingInstanceSupplied,
1390 boolean useDirectReference) {
1392 // perform some emulation work in case there is some and we are inside a local type only
1393 // propage emulation of the enclosing instances
1394 ReferenceBinding[] syntheticArgumentTypes;
1395 if ((syntheticArgumentTypes = targetType.syntheticEnclosingInstanceTypes())
1397 for (int i = 0, max = syntheticArgumentTypes.length; i < max; i++) {
1398 ReferenceBinding syntheticArgType = syntheticArgumentTypes[i];
1399 // need to filter out the one that could match a supplied enclosing instance
1400 if (!(isEnclosingInstanceSupplied
1401 && (syntheticArgType == targetType.enclosingType()))) {
1402 this.emulateOuterAccess(syntheticArgType, useDirectReference);
1406 SyntheticArgumentBinding[] syntheticArguments;
1407 if ((syntheticArguments = targetType.syntheticOuterLocalVariables()) != null) {
1408 for (int i = 0, max = syntheticArguments.length; i < max; i++) {
1409 SyntheticArgumentBinding syntheticArg = syntheticArguments[i];
1410 // need to filter out the one that could match a supplied enclosing instance
1411 if (!(isEnclosingInstanceSupplied
1412 && (syntheticArg.type == targetType.enclosingType()))) {
1413 this.emulateOuterAccess(syntheticArg.actualOuterLocalVariable);
1419 /* Answer the reference type of this scope.
1421 * i.e. the nearest enclosing type of this scope.
1423 public TypeDeclaration referenceType() {
1425 return methodScope().referenceType();
1428 // start position in this scope - for ordering scopes vs. variables
1433 public String toString() {
1437 public String toString(int tab) {
1439 String s = basicToString(tab);
1440 for (int i = 0; i < scopeIndex; i++)
1441 if (subscopes[i] instanceof BlockScope)
1442 s += ((BlockScope) subscopes[i]).toString(tab + 1) + "\n"; //$NON-NLS-1$