summaryrefslogtreecommitdiff
path: root/sources/scalac
diff options
context:
space:
mode:
authorpaltherr <paltherr@epfl.ch>2004-03-18 22:36:38 +0000
committerpaltherr <paltherr@epfl.ch>2004-03-18 22:36:38 +0000
commit164f433132c1585e268c7db27768422b716cd2ef (patch)
tree5e200824278b2bb3a1c7e70cf133358fba20135a /sources/scalac
parent29d6bb1eb31ff328955213e15e8555075a1b1d7d (diff)
downloadscala-164f433132c1585e268c7db27768422b716cd2ef.tar.gz
scala-164f433132c1585e268c7db27768422b716cd2ef.tar.bz2
scala-164f433132c1585e268c7db27768422b716cd2ef.zip
- Added attribute Symbol.IS_ANONYMOUS
- Added factory method Symbol.newAnonymousClass - Removed methods startsWith and endsWith from class Name
Diffstat (limited to 'sources/scalac')
-rw-r--r--sources/scalac/Global.java2
-rw-r--r--sources/scalac/ast/TreeGen.java6
-rw-r--r--sources/scalac/symtab/Symbol.java14
-rw-r--r--sources/scalac/typechecker/RefCheck.java9
-rw-r--r--sources/scalac/util/Name.java12
5 files changed, 19 insertions, 24 deletions
diff --git a/sources/scalac/Global.java b/sources/scalac/Global.java
index 43c540013f..c7546e4568 100644
--- a/sources/scalac/Global.java
+++ b/sources/scalac/Global.java
@@ -429,7 +429,7 @@ public abstract class Global {
switch (unit.body[i]) {
case ModuleDef(_, _, _, Tree.Template impl):
Symbol symbol = unit.body[i].symbol();
- if (!symbol.name.startsWith(CONSOLE_N)) break;
+ if (!symbol.name.toString().startsWith(CONSOLE_S)) break;
console = symbol;
if (impl.body.length <= 0) break;
imports.add(unit.body[i].symbol());
diff --git a/sources/scalac/ast/TreeGen.java b/sources/scalac/ast/TreeGen.java
index bba074a80a..5ffeade7ac 100644
--- a/sources/scalac/ast/TreeGen.java
+++ b/sources/scalac/ast/TreeGen.java
@@ -1107,8 +1107,7 @@ public class TreeGen implements Kinds, Modifiers, TypeTags {
Type[] parentTypes = {
definitions.ANYREF_TYPE(),
definitions.FUNCTION_TYPE(argtypes, restype) };
- Symbol clazz = owner.newClass(
- pos, 0, Names.ANON_CLASS_NAME.toTypeName());
+ Symbol clazz = owner.newAnonymousClass(pos);
clazz.setInfo(Type.compoundType(parentTypes, new Scope(), clazz));
clazz.allConstructors().setInfo(
Type.MethodType(Symbol.EMPTY_ARRAY, clazz.typeConstructor()));
@@ -1131,8 +1130,7 @@ public class TreeGen implements Kinds, Modifiers, TypeTags {
public Tree mkPartialFunction(int pos, Tree applyVisitor, Tree isDefinedAtVisitor,
Type pattype, Type restype, Symbol owner) {
- Symbol clazz = owner.newClass(
- pos, 0, Names.ANON_CLASS_NAME.toTypeName());
+ Symbol clazz = owner.newAnonymousClass(pos);
Type[] parentTypes = {
definitions.ANYREF_TYPE(),
definitions.PARTIALFUNCTION_TYPE(pattype, restype)};
diff --git a/sources/scalac/symtab/Symbol.java b/sources/scalac/symtab/Symbol.java
index 18c2a1aa2c..fc488aeb63 100644
--- a/sources/scalac/symtab/Symbol.java
+++ b/sources/scalac/symtab/Symbol.java
@@ -40,6 +40,7 @@ public abstract class Symbol implements Modifiers, Kinds {
// Attribues -------------------------------------------------------------
public static final int IS_ROOT = 0x00000001;
+ public static final int IS_ANONYMOUS = 0x00000002;
public static final int IS_LABEL = 0x00000010;
public static final int IS_THISTYPE = 0x20000000;
public static final int IS_LOCALDUMMY = 0x40000000;
@@ -244,11 +245,18 @@ public abstract class Symbol implements Modifiers, Kinds {
return newClass(pos, flags, name, 0, NONE);
}
- /** Creates a new module-class owned by this symbol. */
+ /** Creates a new module class owned by this symbol. */
public final ClassSymbol newModuleClass(int pos, int flags, Name name) {
return newModuleClass(pos, flags, name, 0, NONE);
}
+ /** Creates a new anonymous class owned by this symbol. */
+ public final ClassSymbol newAnonymousClass(int pos) {
+ assert isTerm(): Debug.show(this);
+ Name name = Names.ANON_CLASS_NAME.toTypeName();
+ return newClass(pos, 0, name, IS_ANONYMOUS, NONE);
+ }
+
/**
* Creates a new class with a dual module class, both owned by
* this symbol, initializes them with the loader and enters the
@@ -593,7 +601,7 @@ public abstract class Symbol implements Modifiers, Kinds {
/* Does this symbol denote an anonymous class? */
public final boolean isAnonymousClass() {
- return isClass() && name.startsWith(Names.ANON_CLASS_NAME);
+ return isClass() && (attrs & IS_ANONYMOUS) != 0;
}
/** Does this symbol denote the root class or root module?
@@ -943,7 +951,7 @@ public abstract class Symbol implements Modifiers, Kinds {
public Symbol accessed() {
assert (flags & ACCESSOR) != 0;
Name name1 = name;
- if (name1.endsWith(Names._EQ))
+ if (name1.toString().endsWith(Names._EQ.toString()))
name1 = name1.subName(0, name1.length() - Names._EQ.length());
return owner.info().lookup(Name.fromString(name1 + "$"));
}
diff --git a/sources/scalac/typechecker/RefCheck.java b/sources/scalac/typechecker/RefCheck.java
index c293ea2d13..0c17fc4a89 100644
--- a/sources/scalac/typechecker/RefCheck.java
+++ b/sources/scalac/typechecker/RefCheck.java
@@ -314,10 +314,11 @@ public class RefCheck extends Transformer implements Modifiers, Kinds {
/** compensate for renaming during addition of access functions
*/
- Name normalize(Name name) {
- return (name.endsWith(Name.fromString("$")))
- ? name.subName(0, name.length() - 1)
- : name;
+ String normalize(Name name) {
+ String string = name.toString();
+ return (string.endsWith("$"))
+ ? string.substring(0, string.length() - 1)
+ : string;
}
// Basetype Checking --------------------------------------------------------
diff --git a/sources/scalac/util/Name.java b/sources/scalac/util/Name.java
index f165ef441c..530a939ae1 100644
--- a/sources/scalac/util/Name.java
+++ b/sources/scalac/util/Name.java
@@ -125,18 +125,6 @@ public final class Name {
return string.lastIndexOf(c);
}
-/** does this name start with prefix?
- */
- public boolean startsWith(Name prefix) {
- return string.startsWith(prefix.string);
- }
-
-/** does this name end with suffix?
- */
- public boolean endsWith(Name suffix) {
- return string.endsWith(suffix.string);
- }
-
/** returns the subName starting at position start, excluding position end
*/
public Name subName(int start, int end) {