summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpaltherr <paltherr@epfl.ch>2004-03-09 19:31:37 +0000
committerpaltherr <paltherr@epfl.ch>2004-03-09 19:31:37 +0000
commitb93f7b2512dbcf2acabc009dae7d5f78a0919d82 (patch)
tree0d2e56839a6817483612578d629f3ef2258dea8c
parent774209bb21ac348acfaec6be004d0b3fa37d56ef (diff)
downloadscala-b93f7b2512dbcf2acabc009dae7d5f78a0919d82.tar.gz
scala-b93f7b2512dbcf2acabc009dae7d5f78a0919d82.tar.bz2
scala-b93f7b2512dbcf2acabc009dae7d5f78a0919d82.zip
- Added method Symbol.newCompoundClass
- Added Symbol.IS_COMPOUND - Adapted Type.ExtCompoundType to use method Symbol.newCompoundClass
-rw-r--r--sources/scalac/symtab/Symbol.java21
-rw-r--r--sources/scalac/symtab/Type.java33
2 files changed, 28 insertions, 26 deletions
diff --git a/sources/scalac/symtab/Symbol.java b/sources/scalac/symtab/Symbol.java
index 29f9a134e2..d5785891d3 100644
--- a/sources/scalac/symtab/Symbol.java
+++ b/sources/scalac/symtab/Symbol.java
@@ -39,7 +39,8 @@ public abstract class Symbol implements Modifiers, Kinds {
// Attribues -------------------------------------------------------------
- public static final int IS_ROOT = 0x00000001;
+ public static final int IS_ROOT = 0x00000001;
+ public static final int IS_COMPOUND = 0x80000000;
// Fields -------------------------------------------------------------
@@ -115,6 +116,19 @@ public abstract class Symbol implements Modifiers, Kinds {
return clasz;
}
+ /** Creates a new compound class. */
+ final ClassSymbol newCompoundClass(Type info) {
+ int pos = Position.FIRSTPOS;
+ Name name = Names.COMPOUND_NAME.toTypeName();
+ int flags = ABSTRACT | SYNTHETIC;
+ int attrs = IS_COMPOUND;
+ ClassSymbol clasz = newClass(pos, flags, name, attrs, NONE);
+ clasz.setInfo(info);
+ clasz.primaryConstructor().setInfo(
+ Type.MethodType(Symbol.EMPTY_ARRAY, clasz.typeConstructor()));
+ return clasz;
+ }
+
// Copying & cloning ------------------------------------------------------
protected void update(int pos, int flags) {
@@ -452,10 +466,9 @@ public abstract class Symbol implements Modifiers, Kinds {
return kind == CLASS && (flags & TRAIT) != 0;
}
- /** Does this class symbol denote a compound type symbol?
- */
+ /** Does this class symbol denote a compound type symbol? */
public final boolean isCompoundSym() {
- return name == Names.COMPOUND_NAME.toTypeName();
+ return (attrs & IS_COMPOUND) != 0;
}
/** Does this symbol denote a this symbol? */
diff --git a/sources/scalac/symtab/Type.java b/sources/scalac/symtab/Type.java
index d1df9d6e35..c7d4e38a03 100644
--- a/sources/scalac/symtab/Type.java
+++ b/sources/scalac/symtab/Type.java
@@ -237,20 +237,11 @@ public class Type implements Modifiers, Kinds, TypeTags, EntryTags {
public static CompoundType compoundType(Type[] parts, Scope members,
Symbol clazz) {
- ExtCompoundType res = new ExtCompoundType(parts, members);
- res.tsym = clazz;
- return res;
+ return new ExtCompoundType(parts, members, clazz);
}
public static CompoundType compoundTypeWithOwner(Symbol owner, Type[] parts, Scope members) {
- ExtCompoundType res = new ExtCompoundType(parts, members);
- res.tsym = new ClassSymbol(
- Position.FIRSTPOS, Names.COMPOUND_NAME.toTypeName(), owner,
- SYNTHETIC | ABSTRACT);
- res.tsym.setInfo(res);
- res.tsym.primaryConstructor().setInfo(
- Type.MethodType(Symbol.EMPTY_ARRAY, Type.typeRef(res.tsym.owner().thisType(), res.tsym, Type.EMPTY_ARRAY)));
- return res;
+ return new ExtCompoundType(owner, parts, members);
}
static class ExtSingleType extends SingleType {
@@ -274,23 +265,21 @@ public class Type implements Modifiers, Kinds, TypeTags, EntryTags {
}
}
- static class ExtCompoundType extends CompoundType {
- Symbol tsym;
- ExtCompoundType(Type[] parts, Scope members) {
+ private static final class ExtCompoundType extends CompoundType {
+ private final Symbol clasz;
+ public ExtCompoundType(Symbol owner, Type[] parts, Scope members) {
super(parts, members);
+ this.clasz = owner.newCompoundClass(this);
}
- public Symbol symbol() {
- return tsym;
+ public ExtCompoundType(Type[] parts, Scope members, Symbol clasz) {
+ super(parts, members);
+ this.clasz = clasz;
}
- void validate() {//debug
- for (Scope.SymbolIterator it = members.iterator(true); it.hasNext(); )
- assert it.next().owner() == tsym;
+ public Symbol symbol() {
+ return clasz;
}
}
- void validate() {//debug
- }
-
// Access methods ---------------------------------------------------------------
/** If this is a thistype, named type, applied type, singleton type, or compound type,