diff options
Diffstat (limited to 'sources/scalac')
-rw-r--r-- | sources/scalac/Unit.java | 5 | ||||
-rw-r--r-- | sources/scalac/symtab/NameMangler.java | 23 | ||||
-rw-r--r-- | sources/scalac/symtab/Symbol.java | 86 |
3 files changed, 9 insertions, 105 deletions
diff --git a/sources/scalac/Unit.java b/sources/scalac/Unit.java index 97058d73d8..615d98ae87 100644 --- a/sources/scalac/Unit.java +++ b/sources/scalac/Unit.java @@ -11,7 +11,6 @@ package scalac; import ch.epfl.lamp.util.SourceFile; import ch.epfl.lamp.util.Position; -import scalac.symtab.NameMangler; import scalac.ast.Tree; import scalac.atree.ARepository; import java.util.HashMap; @@ -45,10 +44,6 @@ public class Unit { public Tree[] body; public ARepository repository; - /** the name mangler - */ - public NameMangler mangler = new NameMangler(); - public Unit(Global global, SourceFile source, boolean console, boolean mixinOnly) { this.global = global; diff --git a/sources/scalac/symtab/NameMangler.java b/sources/scalac/symtab/NameMangler.java deleted file mode 100644 index 7add579fa5..0000000000 --- a/sources/scalac/symtab/NameMangler.java +++ /dev/null @@ -1,23 +0,0 @@ -/* ____ ____ ____ ____ ______ *\ -** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** -** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** -** /_____/\____/\___/\____/____/ ** -** -** $Id$ -\* */ - -package scalac.symtab; - -import scalac.util.Name; -import java.util.HashMap; - -public class NameMangler { - - private int cnt = 0; - - public void setMangledName(Symbol innerclazz) { - Symbol topclazz = innerclazz.enclToplevelClass(); - innerclazz.setMangledName( - Name.fromString(topclazz.name + "$" + (cnt++) + innerclazz.name)); - } -} diff --git a/sources/scalac/symtab/Symbol.java b/sources/scalac/symtab/Symbol.java index a49b13a3a8..2eb9d4d78c 100644 --- a/sources/scalac/symtab/Symbol.java +++ b/sources/scalac/symtab/Symbol.java @@ -39,6 +39,9 @@ public abstract class Symbol implements Modifiers, Kinds { // Fields ------------------------------------------------------------- + /** The unique identifier generator */ + private static int ids; + /** The kind of the symbol */ public int kind; @@ -60,6 +63,10 @@ public abstract class Symbol implements Modifiers, Kinds { /** The attributes of the symbol */ private final int attrs; + /** The unique identifier */ + public final int id; + + // Constructors ----------------------------------------------------------- /** Generic symbol constructor */ @@ -70,6 +77,7 @@ public abstract class Symbol implements Modifiers, Kinds { this.owner = owner == null ? this : owner; this.flags = flags & ~(INITIALIZED | LOCKED); // safety first this.attrs = attrs; + this.id = ids++; } protected void update(int pos, int flags) { @@ -145,11 +153,6 @@ public abstract class Symbol implements Modifiers, Kinds { // Setters --------------------------------------------------------------- - /** Set the mangled name of this Symbol */ - public Symbol setMangledName(Name name) { - throw new ApplicationError("illegal operation on " + getClass()); - } - /** Set owner */ public Symbol setOwner(Symbol owner) { assert !isConstructor() && !isNone() && !isError(): Debug.show(this); @@ -583,18 +586,6 @@ public abstract class Symbol implements Modifiers, Kinds { return simpleName(); } - /** Get the mangled name of this Symbol - * (this is always a normal name, never a type name) - */ - public Name mangledName() { - return isConstructor() ? constructorClass().name.toTermName() : name.toTermName(); - } - - /** Get the fully qualified mangled name of this Symbol */ - public Name mangledFullName() { - return fullName().replace((byte)'.', (byte)'$'); - } - // Acess to related symbols ----------------------------------------------------- /** Get type parameters */ @@ -1037,25 +1028,7 @@ public abstract class Symbol implements Modifiers, Kinds { } else if (that.isType()) { return false; } - - diff = that.mangledName().index - this.mangledName().index; - if (diff > 0) return true; - if (diff < 0) return false; - - diff = that.mangledFullName().index - this.mangledFullName().index; - if (diff > 0) return true; - if (diff < 0) return false; - - diff = that.hashCode() - this.hashCode(); - if (diff > 0) return true; - if (diff < 0) return false; - - if (owner().isLess(that.owner())) return true; - if (that.owner().isLess(owner())) return false; - - throw new ApplicationError( - "Giving up: can't order two incarnations of class " + - this.mangledFullName()); + return this.id < that.id; } /** Return the symbol's type itself followed by all its direct and indirect @@ -1692,9 +1665,6 @@ public class AbsTypeSymbol extends TypeSymbol { */ public class ClassSymbol extends TypeSymbol { - /** The mangled class name */ - private Name mangled; - /** The module belonging to the class. This means: * For Java classes, its statics parts. * For module classes, the corresponding module. @@ -1721,7 +1691,6 @@ public class ClassSymbol extends TypeSymbol { } public ClassSymbol(int pos, Name name, Symbol owner, int flags, int attrs) { super(CLASS, pos, name, owner, flags, attrs); - this.mangled = name; this.rebindSym = new AliasTypeSymbol(pos, Names.ALIAS(this), owner, 0); Type rebindType = new ClassAliasLazyType(); this.rebindSym.setInfo(rebindType); @@ -1778,7 +1747,6 @@ public class ClassSymbol extends TypeSymbol { other.module = module; other.setInfo(info()); copyConstructorInfo(other); - other.mangled = mangled; if (thisSym != this) other.setTypeOfThis(typeOfThis()); return other; } @@ -1799,12 +1767,6 @@ public class ClassSymbol extends TypeSymbol { */ void setModule(Symbol module) { this.module = module; } - /** Set the mangled name of this Symbol */ - public Symbol setMangledName(Name name) { - this.mangled = name; - return this; - } - /** Get the fully qualified name of this Symbol */ public Name fullName() { if (owner().kind == CLASS && !owner().isRoot()) @@ -1813,26 +1775,6 @@ public class ClassSymbol extends TypeSymbol { return name.toTermName(); } - /** Get the mangled name of this Symbol */ - public Name mangledName() { - return mangled; - } - - /** Get the fully qualified mangled name of this Symbol */ - public Name mangledFullName() { - if (mangled == name) { - return fullName().replace((byte)'.', (byte)'$'); - } else { - Symbol tc = enclToplevelClass(); - if (tc != this) { - return Name.fromString( - enclToplevelClass().mangledFullName() + "$" + mangled); - } else { - return mangled; - } - } - } - public Type thisType() { return thistp; } @@ -1903,11 +1845,6 @@ public final class ErrorSymbol extends Symbol { return this; } - /** Set the mangled name of this Symbol */ - public Symbol mangled(Name name) { - return this; - } - /** Set type */ public Symbol setInfo(Type info) { assert info == Type.ErrorType : info; @@ -1954,11 +1891,6 @@ public final class NoSymbol extends Symbol { return this; } - /** Set the mangled name of this Symbol */ - public Symbol mangled(Name name) { - throw new ApplicationError("illegal operation on " + getClass()); - } - /** Set type */ public Symbol setInfo(Type info) { assert info == Type.NoType : info; |