diff options
author | Martin Odersky <odersky@gmail.com> | 2003-02-17 09:02:01 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2003-02-17 09:02:01 +0000 |
commit | faca8cb93fb09150e59108294c9321bf1e690dd7 (patch) | |
tree | ee8563786f9e01e791c05e87110a3619222bbb18 /sources/scalac/symtab | |
parent | 8001992607e0173b57989046c2c2488345842847 (diff) | |
download | scala-faca8cb93fb09150e59108294c9321bf1e690dd7.tar.gz scala-faca8cb93fb09150e59108294c9321bf1e690dd7.tar.bz2 scala-faca8cb93fb09150e59108294c9321bf1e690dd7.zip |
Syntax changes for tuples and sequences; symbols.
Diffstat (limited to 'sources/scalac/symtab')
-rw-r--r-- | sources/scalac/symtab/Definitions.java | 13 | ||||
-rw-r--r-- | sources/scalac/symtab/Modifiers.java | 15 | ||||
-rw-r--r-- | sources/scalac/symtab/Symbol.java | 12 | ||||
-rw-r--r-- | sources/scalac/symtab/Type.java | 28 |
4 files changed, 25 insertions, 43 deletions
diff --git a/sources/scalac/symtab/Definitions.java b/sources/scalac/symtab/Definitions.java index 6d67edac42..f9e5a6f0ec 100644 --- a/sources/scalac/symtab/Definitions.java +++ b/sources/scalac/symtab/Definitions.java @@ -125,6 +125,8 @@ public class Definitions { public final Symbol STRING_CLASS; public final Type STRING_TYPE; + public final Symbol SEQ_CLASS; + /** string concatenation pseudo-methods of classes scala.Any and * java.lang.String */ @@ -261,6 +263,8 @@ public class Definitions { STRING_TYPE = monoType(STRING_CLASS); SCALA.members().enter(STRING_CLASS); + SEQ_CLASS = getClass(Names.scala_Seq); + /* ANY_PLUS_STRING = new TermSymbol( Position.NOPOS, Names.PLUS, ANY_CLASS, Modifiers.FINAL); @@ -410,12 +414,7 @@ public class Definitions { argtps1); } - public Type tupleType(Type[] args) { - assert args.length > 0; - Type[] args1 = new Type[args.length]; - for (int i = 0; i < args.length; i++) - args1[i] = Type.covarType(args[i]); - return Type.appliedType( - getType(Name.fromString("scala.Tuple" + args.length)), args1); + public Type seqType(Type argtpe) { + return Type.appliedType(getType(Names.scala_Seq), new Type[]{argtpe}); } } diff --git a/sources/scalac/symtab/Modifiers.java b/sources/scalac/symtab/Modifiers.java index 3fc119419e..38f5a042d6 100644 --- a/sources/scalac/symtab/Modifiers.java +++ b/sources/scalac/symtab/Modifiers.java @@ -22,13 +22,14 @@ public interface Modifiers { int ABSTRACTCLASS = 0x00000080; // abstract class int DEF = 0x00000100; // a def parameter - int SYNTHETIC = 0x00000200; - int DEPRECATED = 0x00000400; - int JAVA = 0x00000800; // symbol was defined by a Java class - - int MODUL = 0x00001000; // symbol is module or class implementing a module - int MUTABLE = 0x00002000; // symbol is a mutable variable. - int PARAM = 0x00004000; // symbol is a (type) parameter to a method + int REPEATED = 0x00000200; // a repeated parameter + int SYNTHETIC = 0x00000400; + int DEPRECATED = 0x00000800; + + int JAVA = 0x00001000; // symbol was defined by a Java class + int MODUL = 0x00002000; // symbol is module or class implementing a module + int MUTABLE = 0x00004000; // symbol is a mutable variable. + int PARAM = 0x00008000; // symbol is a (type) parameter to a method int INITIALIZED = 0x00010000; // symbol's definition is complete int LOCKED = 0x00020000; // temporary flag to catch cyclic dependencies diff --git a/sources/scalac/symtab/Symbol.java b/sources/scalac/symtab/Symbol.java index f13192848b..4b31aeef9c 100644 --- a/sources/scalac/symtab/Symbol.java +++ b/sources/scalac/symtab/Symbol.java @@ -269,7 +269,7 @@ public abstract class Symbol implements Modifiers, Kinds { /** Is this symbol the primary constructor of a type? */ public final boolean isPrimaryConstructor() { - return isConstructor() && this == constructorClass().constructor(); + return isConstructor() && this == primaryConstructorClass().constructor(); } public boolean isGenerated() { @@ -332,7 +332,7 @@ public abstract class Symbol implements Modifiers, Kinds { */ public Symbol classOwner() { Symbol owner = owner(); - Symbol clazz = owner.constructorClass(); + Symbol clazz = owner.primaryConstructorClass(); if (clazz.constructor() == owner) return clazz; else return owner; } @@ -353,10 +353,10 @@ public abstract class Symbol implements Modifiers, Kinds { return sym; } - /* If this is a constructor, return the class it constructs. + /* If this is a primary constructor, return the class it constructs. * Otherwise return the symbol itself. */ - public Symbol constructorClass() { + public Symbol primaryConstructorClass() { return this; } @@ -874,8 +874,8 @@ public class TermSymbol extends Symbol { return other; } - public Symbol constructorClass() { - return isConstructor() ? clazz : this; + public Symbol primaryConstructorClass() { + return isConstructor() && clazz != null ? clazz : this; } public Symbol moduleClass() { diff --git a/sources/scalac/symtab/Type.java b/sources/scalac/symtab/Type.java index e9d2e93864..54f690f7bb 100644 --- a/sources/scalac/symtab/Type.java +++ b/sources/scalac/symtab/Type.java @@ -428,33 +428,18 @@ public class Type implements Modifiers, Kinds, TypeTags { } } - /** Is this type of the form scala.Tuple_N[+T_0, ..., +T_N-1]? - */ - public boolean isTupleType() { - switch (this) { - case TypeRef(Type pre, Symbol sym, Type[] args): - if (sym.owner() == Global.instance.definitions.SCALA_CLASS && - sym.name.startsWith(Names.Tuple)) { - for (int i = 0; i < args.length; i++) - if (!args[i].isCovarType()) return false; - return true; - } - } - return false; - } - /** Is this type of the form scala.FunctionN[T_1, ..., T_n, +T]? */ public boolean isFunctionType() { switch (this) { case TypeRef(Type pre, Symbol sym, Type[] args): - if (sym.fullName().startsWith(Names.Function)) + if (sym.fullName().startsWith(Names.Function)) { for (int i = 0; i < args.length - 1; i++) if (args[i].isCovarType()) return false; - return args.length > 0 && args[args.length - 1].isCovarType(); - default: - return false; + return args.length > 0 && args[args.length - 1].isCovarType(); + } } + return false; } // Members and Lookup ------------------------------------------------------- @@ -814,7 +799,7 @@ public class Type implements Modifiers, Kinds, TypeTags { if (pre == NoType || clazz.kind != CLASS) return this; Symbol sym = symbol(); - Symbol ownclass = sym.owner().constructorClass(); + Symbol ownclass = sym.owner().primaryConstructorClass(); if (ownclass.isSubClass(clazz) && pre.symbol().isSubClass(ownclass)) { switch (pre.baseType(ownclass)) { @@ -2018,9 +2003,6 @@ public class Type implements Modifiers, Kinds, TypeTags { case TypeRef(Type pre, Symbol sym, Type[] args): if (sym.isRoot()) return "<root>"; if (!Global.instance.debug) { - if (isTupleType()) - return ArrayApply.toString( - dropVarianceMap.map(args), "[", ",", "]"); if (isFunctionType()) { Type[] params = new Type[args.length - 1]; System.arraycopy(args, 0, params, 0, params.length); |