diff options
author | paltherr <paltherr@epfl.ch> | 2003-05-09 15:28:18 +0000 |
---|---|---|
committer | paltherr <paltherr@epfl.ch> | 2003-05-09 15:28:18 +0000 |
commit | 52874b143e7599d268df80e220eac4964c20b201 (patch) | |
tree | 0bf1d8474c2d7433fb4b99f9fde1e461a9a8ca69 /sources/scalac/symtab/Type.java | |
parent | bbb471bf1afb636ff554ddb0ba4c2bc04bab53b2 (diff) | |
download | scala-52874b143e7599d268df80e220eac4964c20b201.tar.gz scala-52874b143e7599d268df80e220eac4964c20b201.tar.bz2 scala-52874b143e7599d268df80e220eac4964c20b201.zip |
- Removed code that is now in class SymbolTable...
- Removed code that is now in class SymbolTablePrinter Changed some
- toString methods to use SymbolTablePrinter
Diffstat (limited to 'sources/scalac/symtab/Type.java')
-rw-r--r-- | sources/scalac/symtab/Type.java | 130 |
1 files changed, 1 insertions, 129 deletions
diff --git a/sources/scalac/symtab/Type.java b/sources/scalac/symtab/Type.java index f98be55b21..f201027d75 100644 --- a/sources/scalac/symtab/Type.java +++ b/sources/scalac/symtab/Type.java @@ -2069,90 +2069,7 @@ public class Type implements Modifiers, Kinds, TypeTags { // Object Interface ----------------------------------------------------------------- public String toString() { - switch (this) { - case ErrorType: - return "<error>"; - case AnyType: - return "<any type>"; - case NoType: - return "<notype>"; - case ThisType(Symbol sym): - if (sym.isRoot()) return "<root>.this.type"; - else if (this == localThisType) return "<local>.this.type"; - else if (sym.isAnonymousClass()) return "this.type"; - else { - Type this1 = (Global.instance.debug) ? this : expandModuleThis(); - if (this1 == this) return sym.nameString() + ".this.type"; - else return this1.toString(); - } - case TypeRef(Type pre, Symbol sym, Type[] args): - if (sym.isRoot()) return "<root>"; - if (!Global.instance.debug) { - if (isFunctionType()) { - Type[] params = new Type[args.length - 1]; - System.arraycopy(args, 0, params, 0, params.length); - return ArrayApply.toString(params, "(", ",", ") => ") + - args[params.length]; - } else if (sym.isAnonymousClass()) { - return "<template: " + - ArrayApply.toString( - pre.memberInfo(sym).parents(), "", "", " with ") + - "{...}>"; - } - } - Type pre1 = (Global.instance.debug) ? pre : pre.expandModuleThis(); - String result = pre1.prefixString() + sym.nameString() + sym.idString(); - if (args.length != 0) - result = result + ArrayApply.toString(args, "[", ",", "]"); - return result; - case SingleType(Type pre, Symbol sym): - if ((sym.flags & SYNTHETIC) != 0 && !Global.instance.debug) - return widen().toString(); - if (sym.isRoot()) return "<root>.type"; - Type pre1 = (Global.instance.debug) ? pre : pre.expandModuleThis(); - return pre1.prefixString() + sym.nameString() + sym.idString() + ".type"; - case CompoundType(Type[] parts, Scope members): - validate();//debug - if (!Global.instance.debug && isFunctionType()) - return parts[1].toString(); - StringBuffer buf = new StringBuffer(); - if (parts.length > 0) { - buf.append(parts[0].toString()); - int i = 1; - while (i < parts.length) { - buf.append(" with "); - buf.append(parts[i].toString()); - i++; - } - } - boolean first = true; - for (Scope.SymbolIterator it = members.iterator(); it.hasNext(); ) { - Symbol sym = it.next(); - buf.append(first ? " with {" : ", "); - first = false; - buf.append(sym.defString()); - } - if (!first) buf.append("}"); - return buf.toString(); - case MethodType(Symbol[] vparams, Type result): - return ArrayApply.toString(paramTypeString(vparams), "(", ",", ")") + result; - case PolyType(Symbol[] tparams, Type result): - return ArrayApply.toString(Symbol.defString(tparams), "[", ",", "]") + - result; - case OverloadedType(Symbol[] alts, Type[] alttypes): - return ArrayApply.toString(alttypes, "", " <and> ", ""); - case TypeVar(Type origin, Constraint constr): - if (constr.inst != NoType) return constr.inst.toString(); - else return origin + "?"; - case UnboxedType(int kind): - return unboxedName(kind).toString(); - case UnboxedArrayType(Type elemtp): - return elemtp.toString() + "[]"; - case LazyType(): - return "<lazy type " + getClass() + ">"; - default: - return "<unknown type " + getClass() + ">"; - } + return new SymbolTablePrinter().printType(this).toString(); } public String toLongString() { @@ -2161,51 +2078,6 @@ public class Type implements Modifiers, Kinds, TypeTags { else return str; } - // used by Symbol.defString - String defString() { - StringBuffer buffer = new StringBuffer(); - switch (this) { - case MethodType(Symbol[] vparams, Type result): - buffer.append( - ArrayApply.toString(paramTypeString(vparams), "(", ",", ")")); - return buffer.append(result.defString()).toString(); - case PolyType(Symbol[] tparams, Type result): - if (tparams.length != 0) buffer.append( - ArrayApply.toString(Symbol.defString(tparams), "[", ",", "]")); - return buffer.append(result.defString()).toString(); - default: - return buffer.append(": ").append(this).toString(); - } - } - - private String prefixString() { - if ((symbol().kind == NONE || symbol().isRoot()) && !Global.instance.debug) { - return ""; - } else { - String spre = toString(); - if (spre.length() == 0) - return ""; - else if (spre.endsWith(".type")) - return spre.substring(0, spre.length() - 4); - else - return spre + "#"; - } - } - - private String[] paramTypeString(Symbol[] vparams) { - String[] ss = new String[vparams.length]; - for (int i = 0; i < ss.length; i++) { - Type tp = vparams[i].type(); - if ((vparams[i].flags & REPEATED) != 0 && - tp.symbol() == Global.instance.definitions.SEQ_CLASS && - tp.typeArgs().length == 1) - ss[i] = tp.typeArgs()[0].toString() + "*"; - else - ss[i] = tp.toString(); - } - return ss; - } - public int hashCode() { switch (this) { case ErrorType: |