summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormoez <moez@epfl.ch>2005-10-05 14:29:14 +0000
committermoez <moez@epfl.ch>2005-10-05 14:29:14 +0000
commita4409bd62f01d766a0a3dfbc32a3ef5d1fc36aed (patch)
treecfb25e54de4ef2df5e0da70caff6977bd1e84964
parent897ffc2114a6a838cf54fea0c69590c99c2c2841 (diff)
downloadscala-a4409bd62f01d766a0a3dfbc32a3ef5d1fc36aed.tar.gz
scala-a4409bd62f01d766a0a3dfbc32a3ef5d1fc36aed.tar.bz2
scala-a4409bd62f01d766a0a3dfbc32a3ef5d1fc36aed.zip
*** empty log message ***
-rw-r--r--sources/scala/tools/nsc/Interpreter.scala8
-rwxr-xr-xsources/scala/tools/nsc/Main.scala28
-rw-r--r--sources/scala/tools/nsc/Settings.scala32
-rwxr-xr-xsources/scala/tools/nsc/symtab/Symbols.scala181
4 files changed, 125 insertions, 124 deletions
diff --git a/sources/scala/tools/nsc/Interpreter.scala b/sources/scala/tools/nsc/Interpreter.scala
index f5d215888a..a5ec788f09 100644
--- a/sources/scala/tools/nsc/Interpreter.scala
+++ b/sources/scala/tools/nsc/Interpreter.scala
@@ -41,13 +41,13 @@ abstract class Interpreter {
val importVars = ivt.importVars;
val lineno = prevDefines.length;
- val filename = getTempPath().getPath()+java.io.File.separator+"InterpreterTemp.scala";
+ //todo: it is probably nice to include date & time, as well as a process id, in the filename
+ val filename = getTempPath().getPath()+java.io.File.separator+"InterpreterTempLine"+lineno+".scala";
writeTempScalaFile(filename, line, lineno, definedVars, importVars);
// first phase: compile auto-generated file
- val args = List.fromString(filename, ' ');
- val command = new CompilerCommand(args, error, true);
- (new compiler.Run).compile(command.files);
+ compiler.settings.outdir.value = getTempPath().getPath();
+ (new compiler.Run) compile List(filename);
/*
//todo: if no errors in compilation then
diff --git a/sources/scala/tools/nsc/Main.scala b/sources/scala/tools/nsc/Main.scala
index 3f96e66799..02b758b662 100755
--- a/sources/scala/tools/nsc/Main.scala
+++ b/sources/scala/tools/nsc/Main.scala
@@ -59,7 +59,7 @@ object Main {
})
}
- def interprete(gCompiler: Global): unit = {
+ def interpret(gCompiler: Global): unit = {
val interpreter = new Interpreter {
val compiler: gCompiler.type = gCompiler
};
@@ -76,20 +76,20 @@ object Main {
reporter.info(null, command.usageMsg, true)
else {
try {
- val compiler = new Global(command.settings, reporter);
- if (command.settings.resident.value)
- resident(compiler);
- else if (command.settings.interprete.value)
- interprete(compiler);
- else if (command.files.isEmpty)
- reporter.info(null, command.usageMsg, true)
- else
- (new compiler.Run) compile command.files;
+ val compiler = new Global(command.settings, reporter);
+ if (command.settings.resident.value)
+ resident(compiler);
+ else if (command.settings.interpret.value)
+ interpret(compiler);
+ else if (command.files.isEmpty)
+ reporter.info(null, command.usageMsg, true)
+ else
+ (new compiler.Run) compile command.files;
} catch {
- case ex @ FatalError(msg) =>
- if (command.settings.debug.value)
- ex.printStackTrace();
- reporter.error(null, "fatal error: " + msg);
+ case ex @ FatalError(msg) =>
+ if (command.settings.debug.value)
+ ex.printStackTrace();
+ reporter.error(null, "fatal error: " + msg);
}
reporter.printSummary()
}
diff --git a/sources/scala/tools/nsc/Settings.scala b/sources/scala/tools/nsc/Settings.scala
index 885af03ede..0e927e2c34 100644
--- a/sources/scala/tools/nsc/Settings.scala
+++ b/sources/scala/tools/nsc/Settings.scala
@@ -29,7 +29,7 @@ class Settings(error: String => unit) {
val debug = BooleanSetting("-debug", "Output debugging messages");
val statistics = BooleanSetting("-statistics", "Print compiler statistics");
val explaintypes = BooleanSetting("-explaintypes", "Explain type errors in more detail");
- val interprete = BooleanSetting("-interprete", "Run interpreter");
+ val interpret = BooleanSetting("-interpret", "Run interpreter");
val resident = BooleanSetting("-resident", "Compiler stays resident, files to compile are read from standard input");
val uniqid = BooleanSetting("-uniqid", "Print identifiers with unique names (debugging option)");
val printtypes = BooleanSetting("-printtypes", "Print tree types (debugging option)");
@@ -38,7 +38,7 @@ class Settings(error: String => unit) {
val nopredefs = BooleanSetting("-nopredefs", "Compile without any implicit predefined values");
val skip = PhasesSetting ("-skip", "Skip");
val check = PhasesSetting ("-check", "Check the tree at start of");
- val print = PhasesSetting ("-print", "Print out program after");
+ val print = PhasesSetting ("-print", "Print out program after");
val printer = ChoiceSetting ("-printer", "Printer to use", List("text", "html"), "text");
val printfile = StringSetting ("-printfile", "file", "Specify file in which to print trees", "-");
val graph = PhasesSetting ("-graph", "Graph the program after");
@@ -78,7 +78,7 @@ class Settings(error: String => unit) {
allsettings = this :: allsettings;
}
- /** A setting represented by a boolean flag (false, unless set */
+ /** A setting represented by a boolean flag (false, unless set) */
case class BooleanSetting(name: String, descr: String)
extends Setting(name, descr) {
var value: boolean = false;
@@ -97,12 +97,12 @@ class Settings(error: String => unit) {
def tryToSet(args: List[String]): List[String] = args match {
case n :: rest if (n == name) =>
if (rest.isEmpty) {
- error("missing argument");
- List()
- } else {
- value = rest.head;
- rest.tail
- }
+ error("missing argument");
+ List()
+ } else {
+ value = rest.head;
+ rest.tail
+ }
case _ => args
}
@@ -125,11 +125,11 @@ class Settings(error: String => unit) {
error(
if (choice == "") "missing " + argument
else "unknown " + argument + " '" + choice + "'");
- List()
- } else {
+ List()
+ } else {
value = choice;
rest
- }
+ }
case _ => args
}
@@ -148,12 +148,12 @@ class Settings(error: String => unit) {
case n :: rest if (n startsWith (name + ":")) =>
val phase = n.substring(name.length() + 1);
if (phase == "") {
- error("missing phase");
- List()
- } else {
+ error("missing phase");
+ List()
+ } else {
value = value ::: List(phase);
rest
- }
+ }
case _ => args
}
diff --git a/sources/scala/tools/nsc/symtab/Symbols.scala b/sources/scala/tools/nsc/symtab/Symbols.scala
index 959b6cc31a..9e92ea6c8c 100755
--- a/sources/scala/tools/nsc/symtab/Symbols.scala
+++ b/sources/scala/tools/nsc/symtab/Symbols.scala
@@ -180,10 +180,10 @@ import Flags._;
/** Is this symbol a constant? */
final def isConstant: boolean =
isStable && (tpe match {
- case ConstantType(_) => true
- case PolyType(_, ConstantType(_)) => true
- case MethodType(_, ConstantType(_)) => true
- case _ => false
+ case ConstantType(_) => true
+ case PolyType(_, ConstantType(_)) => true
+ case MethodType(_, ConstantType(_)) => true
+ case _ => false
});
/** Is this class nested in another class or module (not a package)? */
@@ -260,32 +260,32 @@ import Flags._;
final def info: Type = {
var cnt = 0;
while (validForRun != currentRun) {
- //if (settings.debug.value) System.out.println("completing " + this);//DEBUG
+ //if (settings.debug.value) System.out.println("completing " + this);//DEBUG
var ifs = infos;
assert(ifs != null, this.name);
while (ifs.prev != null) {
ifs = ifs.prev;
}
- val tp = ifs.info;
- //if (settings.debug.value) System.out.println("completing " + this.rawname + tp.getClass());//debug
+ val tp = ifs.info;
+ //if (settings.debug.value) System.out.println("completing " + this.rawname + tp.getClass());//debug
if ((rawflags & LOCKED) != 0) {
setInfo(ErrorType);
throw CyclicReference(this, tp);
}
rawflags = rawflags | LOCKED;
- val current = phase;
+ val current = phase;
try {
- phase = phaseWithId(ifs.start);
+ phase = phaseWithId(ifs.start);
tp.complete(this);
- // if (settings.debug.value && (validForRun == currentRun) System.out.println("completed " + this/* + ":" + info*/);//DEBUG
+ // if (settings.debug.value && (validForRun == currentRun) System.out.println("completed " + this/* + ":" + info*/);//DEBUG
rawflags = rawflags & ~LOCKED
} finally {
- phase = current
+ phase = current
}
- cnt = cnt + 1;
- // allow for two completions:
- // one: sourceCompleter to LazyType, two: LazyType to completed type
- if (cnt == 3) throw new Error("no progress in completing " + this + ":" + tp);
+ cnt = cnt + 1;
+ // allow for two completions:
+ // one: sourceCompleter to LazyType, two: LazyType to completed type
+ if (cnt == 3) throw new Error("no progress in completing " + this + ":" + tp);
}
rawInfo
}
@@ -322,28 +322,28 @@ import Flags._;
/** Return info without checking for initialization or completing */
final def rawInfo: Type = {
if (limit < phase.id) {
- if (validForRun == currentRun) {
- val current = phase;
+ if (validForRun == currentRun) {
+ val current = phase;
var itr = infoTransformers.nextFrom(limit);
infoTransformers = itr; // caching optimization
while (itr.pid != NoPhase.id && itr.pid < current.id) {
phase = phaseWithId(itr.pid);
val info1 = itr.transform(this, infos.info);
limit = phase.id + 1;
- if (info1 ne infos.info) {
- infos = new TypeHistory(limit, info1, infos);
+ if (info1 ne infos.info) {
+ infos = new TypeHistory(limit, info1, infos);
}
itr = itr.nextFrom(limit)
}
phase = current;
limit = current.id;
- }
- assert(infos != null, name);
- infos.info
+ }
+ assert(infos != null, name);
+ infos.info
} else {
- var infos = this.infos;
- while (phase.id < infos.start && infos.prev != null) infos = infos.prev;
- infos.info
+ var infos = this.infos;
+ while (phase.id < infos.start && infos.prev != null) infos = infos.prev;
+ infos.info
}
}
@@ -392,14 +392,14 @@ import Flags._;
*/
final def isLess(that: Symbol): boolean = {
def closureLength(sym: Symbol) =
- if (sym.isAbstractType) 1 + sym.info.bounds.hi.closure.length
- else sym.info.closure.length;
+ if (sym.isAbstractType) 1 + sym.info.bounds.hi.closure.length
+ else sym.info.closure.length;
if (this.isType)
- that.isType &&
- {val diff = closureLength(this) - closureLength(that);
- diff > 0 || diff == 0 && this.id < that.id}
+ that.isType &&
+ {val diff = closureLength(this) - closureLength(that);
+ diff > 0 || diff == 0 && this.id < that.id}
else
- that.isType || this.id < that.id;
+ that.isType || this.id < that.id;
}
/** A partial ordering between symbols.
@@ -415,7 +415,7 @@ import Flags._;
info.closurePos(that) >= 0 ||
this == AllClass ||
this == AllRefClass &&
- (that == AnyClass ||
+ (that == AnyClass ||
that != AllClass && (that isSubClass AnyRefClass));
// Overloaded Alternatives ---------------------------------------------------------
@@ -427,12 +427,12 @@ import Flags._;
def filter(cond: Symbol => boolean): Symbol =
if (hasFlag(OVERLOADED)) {
//assert(info.isInstanceOf[OverloadedType], "" + this + ":" + info);//DEBUG
- val alts = alternatives;
- val alts1 = alts filter cond;
- if (alts1 eq alts) this
- else if (alts1.isEmpty) NoSymbol
- else if (alts1.tail.isEmpty) alts1.head
- else owner.newOverloaded(info.prefix, alts1)
+ val alts = alternatives;
+ val alts1 = alts filter cond;
+ if (alts1 eq alts) this
+ else if (alts1.isEmpty) NoSymbol
+ else if (alts1.tail.isEmpty) alts1.head
+ else owner.newOverloaded(info.prefix, alts1)
} else if (cond(this)) this
else NoSymbol;
@@ -510,7 +510,7 @@ import Flags._;
*/
final def linkedClass: Symbol = {
if (owner.isPackageClass)
- owner.info.decl(name.toTypeName).suchThat(sym => sym.rawInfo ne NoType)
+ owner.info.decl(name.toTypeName).suchThat(sym => sym.rawInfo ne NoType)
else NoSymbol;
}
@@ -519,7 +519,7 @@ import Flags._;
*/
final def linkedModule: Symbol =
if (owner.isPackageClass)
- owner.info.decl(name.toTermName).suchThat(
+ owner.info.decl(name.toTermName).suchThat(
sym => (sym hasFlag MODULE) && (sym.rawInfo ne NoType));
else NoSymbol;
@@ -536,9 +536,9 @@ import Flags._;
final def toInterface: Symbol =
if (isImplClass) {
- val iface = tpe.parents.last.symbol;
- assert(nme.implClassName(iface.name) == name, this);
- iface
+ val iface = tpe.parents.last.symbol;
+ assert(nme.implClassName(iface.name) == name, this);
+ iface
} else this;
/** The module corresponding to this module class (note that this
@@ -569,8 +569,8 @@ import Flags._;
var sym: Symbol = NoSymbol;
while (!bcs.isEmpty && sym == NoSymbol) {
if (!bcs.head.isImplClass)
- sym = overriddenSymbol(bcs.head).suchThat(sym => !sym.hasFlag(DEFERRED));
- bcs = bcs.tail
+ sym = overriddenSymbol(bcs.head).suchThat(sym => !sym.hasFlag(DEFERRED));
+ bcs = bcs.tail
}
sym
}
@@ -590,7 +590,7 @@ import Flags._;
if (isTerm && (this hasFlag PRIVATE)) {
setFlag(notPRIVATE);
if (!hasFlag(DEFERRED)) setFlag(lateFINAL);
- expandName(base)
+ expandName(base)
}
/** change name by appending $$<fully-qualified-name-of-class `base'>
@@ -690,40 +690,40 @@ import Flags._;
final def locationString: String =
if (owner.isClass &&
(!owner.isAnonymousClass && !owner.isRefinementClass || settings.debug.value))
- " in " + (if (owner.isModuleClass) "object " + owner.nameString else owner)
+ " in " + (if (owner.isModuleClass) "object " + owner.nameString else owner)
else "";
/** String representation of symbol's definition following its name */
final def infoString(tp: Type): String = {
def typeParamsString: String = tp match {
- case PolyType(tparams, _) if (tparams.length != 0) =>
- (tparams map (.defString)).mkString("[", ",", "]")
- case _ =>
- ""
+ case PolyType(tparams, _) if (tparams.length != 0) =>
+ (tparams map (.defString)).mkString("[", ",", "]")
+ case _ =>
+ ""
}
if (isClass)
- typeParamsString + " extends " + tp.resultType
+ typeParamsString + " extends " + tp.resultType
else if (isAliasType)
- typeParamsString + " = " + tp.resultType
+ typeParamsString + " = " + tp.resultType
else if (isAbstractType)
- tp match {
- case TypeBounds(lo, hi) =>
- (if (lo.symbol == AllClass) "" else " >: " + lo) +
- (if (hi.symbol == AnyClass) "" else " <: " + hi)
- case _ =>
- "<: " + tp;
- }
+ tp match {
+ case TypeBounds(lo, hi) =>
+ (if (lo.symbol == AllClass) "" else " >: " + lo) +
+ (if (hi.symbol == AnyClass) "" else " <: " + hi)
+ case _ =>
+ "<: " + tp;
+ }
else if (isModule)
- moduleClass.infoString(tp)
+ moduleClass.infoString(tp)
else
- tp match {
- case PolyType(tparams, res) =>
- typeParamsString + infoString(res)
- case MethodType(pts, res) =>
- pts.mkString("(", ",", ")") + infoString(res)
- case _ =>
- ": " + tp
- }
+ tp match {
+ case PolyType(tparams, res) =>
+ typeParamsString + infoString(res)
+ case MethodType(pts, res) =>
+ pts.mkString("(", ",", ")") + infoString(res)
+ case _ =>
+ ": " + tp
+ }
}
def infosString = infos.toString();
@@ -737,8 +737,8 @@ import Flags._;
/** String representation of symbol's definition */
final def defString: String =
compose(List(flagsToString(flags & ExplicitFlags),
- keyString,
- varianceString + nameString + infoString(rawInfo)));
+ keyString,
+ varianceString + nameString + infoString(rawInfo)));
/** Concatenate strings separated by spaces */
private def compose(ss: List[String]): String =
@@ -790,11 +790,11 @@ import Flags._;
override def name: Name =
if (phase.flatClasses && !hasFlag(METHOD) &&
rawowner != NoSymbol && !rawowner.isPackageClass) {
- if (flatname == nme.EMPTY) {
- assert(rawowner.isClass);
- flatname = newTermName(rawowner.name.toString() + "$" + rawname);
- }
- flatname
+ if (flatname == nme.EMPTY) {
+ assert(rawowner.isClass);
+ flatname = newTermName(rawowner.name.toString() + "$" + rawname);
+ }
+ flatname
} else rawname;
override def cloneSymbolImpl(owner: Symbol): Symbol = {
@@ -817,12 +817,12 @@ import Flags._;
assert(tpeCache ne NoType, this);
if (tpePhase != phase) {
if (isValid(tpePhase)) {
- tpePhase = phase
+ tpePhase = phase
} else {
if (isInitialized) tpePhase = phase;
tpeCache = NoType;
- val targs = if (phase.erasedTypes && this != ArrayClass) List()
- else unsafeTypeParams map (.tpe);
+ val targs = if (phase.erasedTypes && this != ArrayClass) List()
+ else unsafeTypeParams map (.tpe);
tpeCache = typeRef(if (isTypeParameter) NoPrefix else owner.thisType, this, targs)
}
}
@@ -831,7 +831,7 @@ import Flags._;
}
override def typeConstructor: Type = {
if (tyconCache == null || tyconRun != currentRun) {
- tyconCache = typeRef(if (isTypeParameter) NoPrefix else owner.thisType, this, List());
+ tyconCache = typeRef(if (isTypeParameter) NoPrefix else owner.thisType, this, List());
tyconRun = currentRun;
}
assert(tyconCache != null);
@@ -871,11 +871,11 @@ import Flags._;
override def name: Name =
if (phase.flatClasses && rawowner != NoSymbol && !rawowner.isPackageClass) {
- if (flatname == nme.EMPTY) {
- assert(rawowner.isClass);
- flatname = newTypeName(rawowner.name.toString() + "$" + rawname);
- }
- flatname
+ if (flatname == nme.EMPTY) {
+ assert(rawowner.isClass);
+ flatname = newTypeName(rawowner.name.toString() + "$" + rawname);
+ }
+ flatname
} else rawname;
private var thisTypeCache: Type = _;
@@ -887,11 +887,11 @@ import Flags._;
if (p != phase) {
thisTypePhase = phase;
if (!(isValid(p) /*||
- thisTypePhase != null && thisTypePhase.erasedTypes && phase.erasedTypes*/)) {
- thisTypeCache =
- if (isModuleClass && !isRoot && !phase.erasedTypes)
- singleType(owner.thisType, sourceModule);
- else ThisType(this);
+ thisTypePhase != null && thisTypePhase.erasedTypes && phase.erasedTypes*/)) {
+ thisTypeCache =
+ if (isModuleClass && !isRoot && !phase.erasedTypes)
+ singleType(owner.thisType, sourceModule);
+ else ThisType(this);
}
}
thisTypeCache
@@ -961,6 +961,7 @@ import Flags._;
/** A class for type histories */
private case class TypeHistory(start: Phase#Id, info: Type, prev: TypeHistory) {
assert(prev == null || start > prev.start, this);
+ assert(start != 0);
override def toString() = "TypeHistory(" + phaseWithId(start) + "," + info + "," + prev + ")";
}
}