summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2006-09-06 13:22:23 +0000
committermichelou <michelou@epfl.ch>2006-09-06 13:22:23 +0000
commit75df1caebc4735dcfac8b7e29ce059692449ddd6 (patch)
treee6ca28b198be012b12f6c982a0176b2c13b6d415
parent0482a0c416de901c9e3cb4f5efc3b6134358ee55 (diff)
downloadscala-75df1caebc4735dcfac8b7e29ce059692449ddd6.tar.gz
scala-75df1caebc4735dcfac8b7e29ce059692449ddd6.tar.bz2
scala-75df1caebc4735dcfac8b7e29ce059692449ddd6.zip
removed leading/trailing tabs/blanks in symtab/...
removed leading/trailing tabs/blanks in symtab/Symbol*.scala
-rw-r--r--src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala191
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Symbols.scala56
2 files changed, 138 insertions, 109 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala
index 120ba46ce3..049fb717ff 100644
--- a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala
+++ b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala
@@ -1,23 +1,27 @@
-/* NSC -- new scala compiler
- * Copyright 2005 LAMP/EPFL
+/* NSC -- new Scala compiler
+ * Copyright 2005-2006 LAMP/EPFL
* @author Martin Odersky
*/
// $Id$
-package scala.tools.nsc.symtab;
+package scala.tools.nsc.symtab
-import java.io.{File, IOException};
-import scala.tools.nsc.util.{Position, ClassPath};
-import scala.tools.nsc.io.AbstractFile;
-import scala.tools.nsc.util.NameTransformer;
-import scala.collection.mutable.HashMap;
-import classfile.{ClassfileParser, SymblfileParser};
-import Flags._;
+import java.io.{File, IOException}
+import scala.collection.mutable.HashMap
+import scala.tools.nsc.io.AbstractFile
+import scala.tools.nsc.util.{ClassPath, NameTransformer, Position}
+import classfile.{ClassfileParser, SymblfileParser}
+import Flags._
+/** This class ...
+ *
+ * @author Martin Odersky
+ * @version 1.0
+ */
abstract class SymbolLoaders {
- val global: Global;
- import global._;
+ val global: Global
+ import global._
/** A lazy type that completes itself by calling parameter doComplete.
* Any linked modules/classes or module classes are also initialized.
@@ -27,51 +31,54 @@ abstract class SymbolLoaders {
* Can throw an IOException on error.
*/
abstract class SymbolLoader extends LazyType {
+
/** Load source or class file for `root', return */
- protected def doComplete(root: Symbol): unit;
+ protected def doComplete(root: Symbol): unit
+
/** The kind of file that's processed by this loader */
- protected def kindString: String;
- private var ok = false;
+ protected def kindString: String
+
+ private var ok = false
/*
private def setSource(sym: Symbol, sourceFile0: AbstractFile): unit = sym match {
case clazz: ClassSymbol => if (sourceFile0 != null) clazz.sourceFile = sourceFile0;
case _ => if (sourceFile0 != null) if (false) System.err.println("YYY: " + sym + " " + sourceFile0);
}
*/
- def sourceFile : AbstractFile = null;
- protected def sourceString : String;
+ def sourceFile : AbstractFile = null
+ protected def sourceString : String
override def complete(root: Symbol): unit = {
try {
- val start = System.currentTimeMillis();
- val currentphase = phase;
- doComplete(root);
- phase = currentphase;
- def source = kindString + " " + sourceString;
- informTime("loaded " + source, start);
+ val start = System.currentTimeMillis()
+ val currentphase = phase
+ doComplete(root)
+ phase = currentphase
+ def source = kindString + " " + sourceString
+ informTime("loaded " + source, start)
if (root.rawInfo == this && root.linkedSym.rawInfo == this)
throw new TypeError(source + " does not define " + root)
- ok = true;
+ ok = true
} catch {
case ex: IOException =>
- ok = false;
- if (settings.debug.value) ex.printStackTrace();
- val msg = ex.getMessage();
+ ok = false
+ if (settings.debug.value) ex.printStackTrace();
+ val msg = ex.getMessage()
error(
if (msg == null) "i/o error while loading " + root.name
else "error while loading " + root.name + ", " + msg);
}
- initRoot(root);
- if (!root.isPackageClass) initRoot(root.linkedSym);
+ initRoot(root)
+ if (!root.isPackageClass) initRoot(root.linkedSym)
}
- override def load(root: Symbol): unit = complete(root);
+ override def load(root: Symbol): unit = complete(root)
private def initRoot(root: Symbol): unit = {
if (root.rawInfo == this) {
def markAbsent(sym: Symbol) =
if (sym != NoSymbol) sym.setInfo(if (ok) NoType else ErrorType);
- markAbsent(root);
+ markAbsent(root)
markAbsent(root.moduleClass)
} else if (root.isClass && !root.isModuleClass) root.rawInfo.load(root)
}
@@ -80,88 +87,89 @@ abstract class SymbolLoaders {
/** Load contents of a package
*/
class PackageLoader(directory: global.classPath0.Context) extends SymbolLoader {
- // System.err.println("PACKAGE LOADER: " + directory);
+ // System.err.println("PACKAGE LOADER: " + directory)
- protected def sourceString = directory.toString();
+ protected def sourceString = directory.toString()
protected def doComplete(root: Symbol): unit = {
- assert(root.isPackageClass, root);
+ assert(root.isPackageClass, root)
val scope = newScope
- root.setInfo(new PackageClassInfoType(scope, root));
+ root.setInfo(new PackageClassInfoType(scope, root))
/** Is the given name a valid input file base name? */
def isValid(name: String): boolean =
name.length() > 0 && !name.endsWith("$class") && name.indexOf("$anon") == -1;
def enterPackage(str: String, completer: SymbolLoader): unit = {
- val pkg = root.newPackage(NoPos, newTermName(str));
- pkg.moduleClass.setInfo(completer);
- pkg.setInfo(pkg.moduleClass.tpe);
+ val pkg = root.newPackage(NoPos, newTermName(str))
+ pkg.moduleClass.setInfo(completer)
+ pkg.setInfo(pkg.moduleClass.tpe)
root.info.decls.enter(pkg)
}
def enterClassAndModule(str: String, completer: SymbolLoader): unit = {
- val owner = if (root.isRoot) definitions.EmptyPackageClass else root;
- val name = newTermName(str);
- val clazz = owner.newClass(NoPos, name.toTypeName);
- val module = owner.newModule(NoPos, name);
- clazz.setInfo(completer);
- module.setInfo(completer);
- module.moduleClass.setInfo(moduleClassLoader);
- owner.info.decls.enter(clazz);
- owner.info.decls.enter(module);
+ val owner = if (root.isRoot) definitions.EmptyPackageClass else root
+ val name = newTermName(str)
+ val clazz = owner.newClass(NoPos, name.toTypeName)
+ val module = owner.newModule(NoPos, name)
+ clazz.setInfo(completer)
+ module.setInfo(completer)
+ module.moduleClass.setInfo(moduleClassLoader)
+ owner.info.decls.enter(clazz)
+ owner.info.decls.enter(module)
/*
- if (completer.sourceFile != null) {
+ if (completer.sourceFile != null) {
clazz.sourceFile = completer.sourceFile;
module.moduleClass.sourceFile = completer.sourceFile
}
*/
- assert(clazz.linkedModuleOfClass == module, module);
- assert(module.linkedClassOfModule == clazz, clazz);
+ assert(clazz.linkedModuleOfClass == module, module)
+ assert(module.linkedClassOfModule == clazz, clazz)
}
- val classes = new HashMap[String, global.classPath0.Context];
- val packages = new HashMap[String, global.classPath0.Context];
+ val classes = new HashMap[String, global.classPath0.Context]
+ val packages = new HashMap[String, global.classPath0.Context]
for (val dir <- directory.entries) if (dir.location != null) {
for (val file <- dir.location) {
- if (file.isDirectory && directory.validPackage(file.name) && !packages.isDefinedAt(file.name))
- packages(file.name) = directory.find(file.name, true);
- else if (!file.isDirectory && file.name.endsWith(".class")) {
- val name = file.name.substring(0, file.name.length() - (".class").length());
- if (isValid(name) && !classes.isDefinedAt(name)) {
- val clazz = directory.find(name, false);
- if (clazz != null) classes(name) = clazz;
+ if (file.isDirectory && directory.validPackage(file.name) && !packages.isDefinedAt(file.name))
+ packages(file.name) = directory.find(file.name, true);
+ else if (!file.isDirectory && file.name.endsWith(".class")) {
+ val name = file.name.substring(0, file.name.length() - (".class").length());
+ if (isValid(name) && !classes.isDefinedAt(name)) {
+ val clazz = directory.find(name, false)
+ if (clazz != null) classes(name) = clazz
}
- }
- }
+ }
+ }
}
for (val dir <- directory.entries) if (dir.source != null) {
for (val file <- dir.source.location) {
- if (file.isDirectory && directory.validPackage(file.name) && !packages.isDefinedAt(file.name))
- packages(file.name) = directory.find(file.name, true);
- else if (dir.source.compile && !file.isDirectory && file.name.endsWith(".scala")) {
- val name = file.name.substring(0, file.name.length() - (".scala").length());
- if (isValid(name) && !classes.isDefinedAt(name)) {
- val source = directory.find(name, false);
- if (source != null) classes(name) = source;
+ if (file.isDirectory && directory.validPackage(file.name) && !packages.isDefinedAt(file.name))
+ packages(file.name) = directory.find(file.name, true);
+ else if (dir.source.compile && !file.isDirectory && file.name.endsWith(".scala")) {
+ val name = file.name.substring(0, file.name.length() - (".scala").length());
+ if (isValid(name) && !classes.isDefinedAt(name)) {
+ val source = directory.find(name, false)
+ if (source != null) classes(name) = source
}
- }
- }
+ }
+ }
}
- //if (!packages.isEmpty) System.err.println("COMPLETE: " + packages);
- //if (! classes.isEmpty) System.err.println("COMPLETE: " + classes);
+ //if (!packages.isEmpty) System.err.println("COMPLETE: " + packages)
+ //if (! classes.isEmpty) System.err.println("COMPLETE: " + classes)
// do classes first
for (val Pair(name, file) <- classes.elements) {
- val loader = if (!file.isSourceFile) {
- new ClassfileLoader(file.classFile, file.sourceFile, file.sourcePath);
- } else {
- assert(file.sourceFile != null);
- new SourcefileLoader(file.sourceFile);
- }
- enterClassAndModule(name, loader);
+ val loader = if (!file.isSourceFile) {
+ new ClassfileLoader(file.classFile, file.sourceFile, file.sourcePath);
+ } else {
+ assert(file.sourceFile != null)
+ new SourcefileLoader(file.sourceFile)
+ }
+ enterClassAndModule(name, loader)
}
- for (val Pair(name, file) <- packages.elements) enterPackage(name, new PackageLoader(file));
+ for (val Pair(name, file) <- packages.elements)
+ enterPackage(name, new PackageLoader(file))
}
protected def kindString: String = "directory path"
}
@@ -174,18 +182,18 @@ abstract class SymbolLoaders {
class ClassfileLoader(classFile: AbstractFile, override val sourceFile: AbstractFile, sourcePath0: AbstractFile) extends SymbolLoader {
private object classfileParser extends ClassfileParser {
- val global: SymbolLoaders.this.global.type = SymbolLoaders.this.global;
- override def sourcePath = sourcePath0; /* could be null */
+ val global: SymbolLoaders.this.global.type = SymbolLoaders.this.global
+ override def sourcePath = sourcePath0 /* could be null */
}
protected def doComplete(root: Symbol): unit = {
- classfileParser.parse(classFile, root);
+ classfileParser.parse(classFile, root)
if (sourceFile != null) root match {
- case clazz : ClassSymbol => clazz.sourceFile = sourceFile;
- case _ =>
+ case clazz : ClassSymbol => clazz.sourceFile = sourceFile
+ case _ =>
}
}
- protected def kindString: String = "class file";
- protected def sourceString = classFile.toString();
+ protected def kindString: String = "class file"
+ protected def sourceString = classFile.toString()
}
/*
class SymblfileLoader(file: AbstractFile) extends SymbolLoader(file) {
@@ -194,13 +202,14 @@ abstract class SymbolLoaders {
}
*/
class SourcefileLoader(override val sourceFile: AbstractFile) extends SymbolLoader {
- protected def doComplete(root: Symbol): unit = global.currentRun.compileLate(sourceFile);
- protected def kindString: String = "source file";
- protected def sourceString = sourceFile.toString();
+ protected def doComplete(root: Symbol): unit =
+ global.currentRun.compileLate(sourceFile)
+ protected def kindString: String = "source file"
+ protected def sourceString = sourceFile.toString()
}
object moduleClassLoader extends SymbolLoader {
- protected def doComplete(root: Symbol): unit = root.sourceModule.initialize;
+ protected def doComplete(root: Symbol): unit = root.sourceModule.initialize
protected def kindString: String = "";
protected def sourceString = "";
}
diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
index 2cc39d5576..7df3ebd30f 100644
--- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
@@ -99,7 +99,8 @@ trait Symbols requires SymbolTable {
final def newConstructor(pos: PositionType) =
newMethod(pos, nme.CONSTRUCTOR)
final def newModule(pos: PositionType, name: Name, clazz: ClassSymbol) =
- new ModuleSymbol(this, pos, name).setFlag(MODULE | FINAL).setModuleClass(clazz)
+ new ModuleSymbol(this, pos, name).setFlag(MODULE | FINAL)
+ .setModuleClass(clazz)
final def newModule(pos: PositionType, name: Name) = {
val m = new ModuleSymbol(this, pos, name).setFlag(MODULE | FINAL)
m.setModuleClass(new ModuleClassSymbol(m))
@@ -271,8 +272,13 @@ trait Symbols requires SymbolTable {
isClass && (isAnonymousClass || isRefinementClass || isLocal ||
!owner.isPackageClass && owner.isLocalClass)
- /** A a member of class `base' is incomplete if (1) it is declared deferred or
- * (2) it is abstract override and its super symbol in `base' is nonexistent or inclomplete.
+ /** A a member of class `base' is incomplete if
+ * (1) it is declared deferred or
+ * (2) it is abstract override and its super symbol in `base' is
+ * nonexistent or inclomplete.
+ *
+ * @param base ...
+ * @return ...
*/
final def isIncompleteIn(base: Symbol): boolean = (
(this hasFlag DEFERRED) ||
@@ -505,10 +511,9 @@ trait Symbols requires SymbolTable {
owner == that || owner != NoSymbol && (owner isNestedIn that)
/** Is this class symbol a subclass of that symbol? */
- final def isNonBottomSubClass(that: Symbol): boolean = {
+ final def isNonBottomSubClass(that: Symbol): boolean =
this == that || this.isError || that.isError ||
info.closurePos(that) >= 0
- }
final def isSubClass(that: Symbol): boolean = {
isNonBottomSubClass(that) ||
@@ -566,11 +571,14 @@ trait Symbols requires SymbolTable {
/** The primary constructor of a class */
def primaryConstructor: Symbol = {
- val c = info.decl(if (isTrait || isImplClass) nme.MIXIN_CONSTRUCTOR else nme.CONSTRUCTOR)
+ val c = info.decl(
+ if (isTrait || isImplClass) nme.MIXIN_CONSTRUCTOR
+ else nme.CONSTRUCTOR)
if (c hasFlag OVERLOADED) c.alternatives.head else c
}
- /** The self symbol of a class with explicit self type, or else the symbol itself.
+ /** The self symbol of a class with explicit self type, or else the
+ * symbol itself.
*/
def thisSym: Symbol = this
@@ -581,7 +589,9 @@ trait Symbols requires SymbolTable {
def typeOfThis_=(tp: Type): unit =
throw new Error("typeOfThis cannot be set for " + this)
- /** If symbol is a class, the type this.type in this class, otherwise NoPrefix */
+ /** If symbol is a class, the type <code>this.type</code> in this class,
+ * otherwise <code>NoPrefix</code>.
+ */
def thisType: Type = NoPrefix
/** Return every accessor of a primary constructor parameter in this case class
@@ -602,8 +612,8 @@ trait Symbols requires SymbolTable {
final def implClass: Symbol = owner.info.decl(nme.implClassName(name))
- /** For a paramaccessor: a superclass paramaccessor for which this symbol is
- * an alias, NoSymbol for all others */
+ /** For a paramaccessor: a superclass paramaccessor for which this symbol
+ * is an alias, NoSymbol for all others */
def alias: Symbol = NoSymbol
/** The top-level class containing this symbol */
@@ -628,14 +638,17 @@ trait Symbols requires SymbolTable {
sym => (sym hasFlag MODULE) && (sym.rawInfo ne NoType))
} else NoSymbol
- /** For a module its linked class, for a class its linked module or case factory otherwise */
+ /** For a module its linked class, for a class its linked module or case
+ * factory otherwise.
+ */
final def linkedSym: Symbol =
if (isTerm) linkedClassOfModule
else if (isClass) owner.info.decl(name.toTermName).suchThat(sym => sym.rawInfo ne NoType)
else NoSymbol
/** For a module class its linked class, for a plain class
- * the module class of itys linked module */
+ * the module class of itys linked module.
+ */
final def linkedClassOfClass: Symbol =
if (isModuleClass) linkedClassOfModule else linkedModuleOfClass.moduleClass
@@ -802,7 +815,7 @@ trait Symbols requires SymbolTable {
def nameString: String =
simpleName.decode + idString
- /** String representation of symbol's full name with `separator'
+ /** String representation of symbol's full name with <code>separator</code>
* between class names.
* Never translates expansions of operators back to operator symbol.
* Never adds id.
@@ -960,7 +973,9 @@ trait Symbols requires SymbolTable {
}
/** A class for type parameters viewed from inside their scopes */
- class ThisSkolem(initOwner: Symbol, initPos: PositionType, initName: Name, clazz: Symbol) extends TermSymbol(initOwner, initPos, initName) {
+ class ThisSkolem(initOwner: Symbol, initPos: PositionType,
+ initName: Name, clazz: Symbol)
+ extends TermSymbol(initOwner, initPos, initName) {
override def deSkolemize = clazz
override def cloneSymbolImpl(owner: Symbol): Symbol = {
throw new Error("should not clone a this skolem")
@@ -1032,7 +1047,9 @@ trait Symbols requires SymbolTable {
}
/** A class for type parameters viewed from inside their scopes */
- class TypeSkolem(initOwner: Symbol, initPos: PositionType, initName: Name, typeParam: Symbol) extends TypeSymbol(initOwner, initPos, initName) {
+ class TypeSkolem(initOwner: Symbol, initPos: PositionType,
+ initName: Name, typeParam: Symbol)
+ extends TypeSymbol(initOwner, initPos, initName) {
override def deSkolemize = typeParam
override def cloneSymbolImpl(owner: Symbol): Symbol = {
throw new Error("should not clone a type skolem")
@@ -1043,12 +1060,14 @@ trait Symbols requires SymbolTable {
}
/** A class for class symbols */
- class ClassSymbol(initOwner: Symbol, initPos: PositionType, initName: Name) extends TypeSymbol(initOwner, initPos, initName) {
+ class ClassSymbol(initOwner: Symbol, initPos: PositionType, initName: Name)
+ extends TypeSymbol(initOwner, initPos, initName) {
/** The classfile from which this class was loaded. Maybe null. */
var classFile: AbstractFile = null;
private var source: AbstractFile = null
- override def sourceFile = if (owner.isPackageClass) source else super.sourceFile
+ override def sourceFile =
+ if (owner.isPackageClass) source else super.sourceFile
override def sourceFile_=(f: AbstractFile): unit = {
//System.err.println("set source file of " + this + ": " + f);
source = f
@@ -1122,7 +1141,8 @@ trait Symbols requires SymbolTable {
* Note: Not all module classes are of this type; when unpickled, we get
* plain class symbols!
*/
- class ModuleClassSymbol(owner: Symbol, pos: PositionType, name: Name) extends ClassSymbol(owner, pos, name) {
+ class ModuleClassSymbol(owner: Symbol, pos: PositionType, name: Name)
+ extends ClassSymbol(owner, pos, name) {
private var module: Symbol = null
def this(module: TermSymbol) = {
this(module.owner, module.pos, module.name.toTypeName)