|
From: <caw...@us...> - 2007-03-13 18:17:25
|
Revision: 2147
http://svn.sourceforge.net/rubyeclipse/?rev=2147&view=rev
Author: cawilliams
Date: 2007-03-13 11:17:22 -0700 (Tue, 13 Mar 2007)
Log Message:
-----------
Added Paths:
-----------
branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/lookup/Scope.java
Added: branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/lookup/Scope.java
===================================================================
--- branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/lookup/Scope.java (rev 0)
+++ branches/search_engine/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/env/lookup/Scope.java 2007-03-13 18:17:22 UTC (rev 2147)
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.compiler.env.lookup;
+
+import org.rubypeople.rdt.internal.compiler.lookup.LookupEnvironment;
+
+
+public abstract class Scope implements TypeConstants {
+
+ /* Scope kinds */
+ public final static int BLOCK_SCOPE = 1;
+ public final static int CLASS_SCOPE = 3;
+ public final static int COMPILATION_UNIT_SCOPE = 4;
+ public final static int METHOD_SCOPE = 2;
+
+ /* Argument Compatibilities */
+ public final static int NOT_COMPATIBLE = -1;
+ public final static int COMPATIBLE = 0;
+ public final static int AUTOBOX_COMPATIBLE = 1;
+ public final static int VARARGS_COMPATIBLE = 2;
+
+ /* Type Compatibilities */
+ public static final int EQUAL_OR_MORE_SPECIFIC = -1;
+ public static final int NOT_RELATED = 0;
+ public static final int MORE_GENERIC = 1;
+
+ public int kind;
+ public Scope parent;
+
+ protected Scope(int kind, Scope parent) {
+ this.kind = kind;
+ this.parent = parent;
+ }
+
+ public final TypeScope classScope() {
+ Scope scope = this;
+ do {
+ if (scope instanceof TypeScope)
+ return (TypeScope) scope;
+ scope = scope.parent;
+ } while (scope != null);
+ return null;
+ }
+
+ public final SourceModuleScope compilationUnitScope() {
+ Scope lastScope = null;
+ Scope scope = this;
+ do {
+ lastScope = scope;
+ scope = scope.parent;
+ } while (scope != null);
+ return (SourceModuleScope) lastScope;
+ }
+
+ public final TypeScope enclosingClassScope() {
+ Scope scope = this;
+ while ((scope = scope.parent) != null) {
+ if (scope instanceof TypeScope) return (TypeScope) scope;
+ }
+ return null; // may answer null if no type around
+ }
+
+ public final MethodScope enclosingMethodScope() {
+ Scope scope = this;
+ while ((scope = scope.parent) != null) {
+ if (scope instanceof MethodScope) return (MethodScope) scope;
+ }
+ return null; // may answer null if no method around
+ }
+
+ public final LookupEnvironment environment() {
+ Scope scope, unitScope = this;
+ while ((scope = unitScope.parent) != null)
+ unitScope = scope;
+ return ((SourceModuleScope) unitScope).environment;
+ }
+
+ // start position in this scope - for ordering scopes vs. variables
+ int startIndex() {
+ return 0;
+ }
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|