summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2006-06-01 14:27:39 +0000
committerMartin Odersky <odersky@gmail.com>2006-06-01 14:27:39 +0000
commit4150f7e6fc64cd8d78d48cf275955b90d5c8b475 (patch)
tree0c601da1530d5eb0c1afcfa6ea7cd3f41daeff65 /src/compiler/scala/tools
parentc49cb64a8af13b608fb5c974b377086b19b16e9e (diff)
downloadscala-4150f7e6fc64cd8d78d48cf275955b90d5c8b475.tar.gz
scala-4150f7e6fc64cd8d78d48cf275955b90d5c8b475.tar.bz2
scala-4150f7e6fc64cd8d78d48cf275955b90d5c8b475.zip
some changes to plug space leaks
Diffstat (limited to 'src/compiler/scala/tools')
-rw-r--r--src/compiler/scala/tools/nsc/CompilationUnits.scala16
-rw-r--r--src/compiler/scala/tools/nsc/Global.scala216
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Scanners.scala4
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Definitions.scala6
-rw-r--r--src/compiler/scala/tools/nsc/symtab/RunId.scala11
-rw-r--r--src/compiler/scala/tools/nsc/symtab/SymbolTable.scala4
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Symbols.scala20
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Types.scala4
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala476
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala2
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala6
-rw-r--r--src/compiler/scala/tools/nsc/transform/Erasure.scala41
-rw-r--r--src/compiler/scala/tools/nsc/transform/LiftCode.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Contexts.scala225
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Namers.scala2
-rw-r--r--src/compiler/scala/tools/nsc/util/ShowPickled.scala2
16 files changed, 535 insertions, 502 deletions
diff --git a/src/compiler/scala/tools/nsc/CompilationUnits.scala b/src/compiler/scala/tools/nsc/CompilationUnits.scala
index 64a3cc97b1..6633f7d311 100644
--- a/src/compiler/scala/tools/nsc/CompilationUnits.scala
+++ b/src/compiler/scala/tools/nsc/CompilationUnits.scala
@@ -13,10 +13,18 @@ import scala.collection.mutable.HashSet;
trait CompilationUnits requires Global {
+ private var unitCount = 0;
+
class CompilationUnit(val source: SourceFile) {
+ unitCount = unitCount + 1
+ if (settings.statistics.value) Console.println("creating unit: "+unitCount)
+ override def finalize() = {
+ unitCount = unitCount - 1
+ if (settings.statistics.value) Console.println("collecting unit: "+unitCount)
+ }
/** the fresh name creator */
- val fresh = new FreshNameCreator;
+ var fresh = new FreshNameCreator;
/** the content of the compilation unit in tree form */
var body: Tree = EmptyTree;
@@ -36,6 +44,12 @@ trait CompilationUnits requires Global {
def warning(pos: int, msg: String) = reporter.warning(position(pos), msg);
override def toString() = source.toString();
+ def clear() = {
+ fresh = null
+ body = null
+ depends.clear
+ errorPositions.clear
+ }
}
}
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala
index 12c1a80f02..d6b650c27c 100644
--- a/src/compiler/scala/tools/nsc/Global.scala
+++ b/src/compiler/scala/tools/nsc/Global.scala
@@ -39,12 +39,12 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable
object treePrinters extends TreePrinters {
val global: Global.this.type = Global.this
}
- val treePrinter = treePrinters.create();
+ val treePrinter = treePrinters.create()
object treeBrowsers extends TreeBrowsers {
val global: Global.this.type = Global.this
}
- val treeBrowser = treeBrowsers.create();
+ val treeBrowser = treeBrowsers.create()
object treeInfo extends TreeInfo {
val global: Global.this.type = Global.this
@@ -67,11 +67,11 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable
}
object analysis extends TypeFlowAnalysis {
- val global: Global.this.type = Global.this;
+ val global: Global.this.type = Global.this
}
object copyPropagation extends CopyPropagation {
- val global: Global.this.type = Global.this;
+ val global: Global.this.type = Global.this
}
object checkers extends Checkers {
@@ -86,11 +86,11 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable
val global: Global.this.type = Global.this
}
- val copy = new LazyTreeCopier();
+ val copy = new LazyTreeCopier()
val comments =
- if (onlyPresentation) new HashMap[Symbol,String];
- else null;
+ if (onlyPresentation) new HashMap[Symbol,String]
+ else null
// reporting -------------------------------------------------------
@@ -99,7 +99,8 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable
def inform(msg: String) = System.err.println(msg)
def inform[T](msg: String, value: T): T = { inform(msg+value); value }
- //reporter.info(null, msg, true);
+ //reporter.info(null, msg, true)
+
def informProgress(msg: String) =
if (settings.verbose.value) inform("[" + msg + "]")
@@ -123,7 +124,7 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable
body
} catch {
case e : ErrorWithPosition =>
- logError("POS: " + source.dbg(e.pos), e);
+ logError("POS: " + source.dbg(e.pos), e)
throw e.error
}
@@ -149,7 +150,7 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable
error("unsupported charset '" + settings.encoding.value + "'")
stdCharset
}
- new SourceReader(charset.newDecoder());
+ new SourceReader(charset.newDecoder())
}
val classPath0 = new ClassPath(onlyPresentation)
@@ -159,7 +160,7 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable
settings.sourcepath.value,
settings.outdir.value,
settings.bootclasspath.value,
- settings.extdirs.value);
+ settings.extdirs.value)
if (settings.verbose.value) {
System.err.println("classpath = " + classPath)
@@ -171,14 +172,14 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable
def getSourceFile(name: String): SourceFile = {
val f = AbstractFile.getFile(name)
if (f == null) throw new FileNotFoundException(
- "source file '" + name + "' could not be found");
+ "source file '" + name + "' could not be found")
getSourceFile(f)
}
def getSourceFile(clazz: Symbol): SourceFile = {
val ret = classPath.root.find(clazz.fullNameString(File.separatorChar), false)
if (!ret.isSourceFile) throw new FileNotFoundException(
- "source file for " + clazz + " could not be found");
+ "source file for " + clazz + " could not be found")
getSourceFile(ret.sourceFile)
}
@@ -188,7 +189,7 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable
def rootLoader: LazyType = new loaders.PackageLoader(classPath.root /* getRoot() */)
- val migrateMsg = "migration problem when moving from Scala version 1.0 to version 2.0:\n";
+ val migrateMsg = "migration problem when moving from Scala version 1.0 to version 2.0:\n"
// Phases ------------------------------------------------------------
@@ -196,29 +197,34 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable
val MaxPhases = 64
- val phaseWithId = new Array[Phase](MaxPhases);
+ val phaseWithId = new Array[Phase](MaxPhases)
{ for (val i <- List.range(0, MaxPhases)) phaseWithId(i) = NoPhase }
abstract class GlobalPhase(prev: Phase) extends Phase(prev) {
phaseWithId(id) = this
- def run: unit = currentRun.units foreach applyPhase;
+ def run: unit = currentRun.units foreach applyPhase
- def apply(unit: CompilationUnit): unit;
- private val isErased = prev.name == "erasure" || prev.erasedTypes;
- override def erasedTypes: boolean = isErased;
- private val isFlat = prev.name == "flatten" || prev.flatClasses;
- override def flatClasses: boolean = isFlat;
+ def apply(unit: CompilationUnit): unit
+ private val isErased = prev.name == "erasure" || prev.erasedTypes
+ override def erasedTypes: boolean = isErased
+ private val isFlat = prev.name == "flatten" || prev.flatClasses
+ override def flatClasses: boolean = isFlat
final def applyPhase(unit: CompilationUnit): unit = {
- if (settings.debug.value) inform("[running phase " + name + " on " + unit + "]");
- val unit0 = currentRun.currentUnit;
- currentRun.currentUnit = unit;
- apply(unit);
- currentRun.advanceUnit;
- assert(currentRun.currentUnit == unit);
- currentRun.currentUnit = unit0;
+ if (settings.debug.value) inform("[running phase " + name + " on " + unit + "]")
+ val unit0 = currentRun.currentUnit
+ currentRun.currentUnit = unit
+ apply(unit)
+ currentRun.advanceUnit
+ assert(currentRun.currentUnit == unit)
+ currentRun.currentUnit = unit0
}
}
+ class TerminalPhase(prev: Phase) extends GlobalPhase(prev) {
+ def name = "terminal"
+ def apply(unit: CompilationUnit): unit = {}
+ }
+
object syntaxAnalyzer extends SyntaxAnalyzer {
val global: Global.this.type = Global.this
}
@@ -351,34 +357,41 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable
closureElimination,
deadCode,
genJVM,
- sampleTransform);
+ sampleTransform)
protected def insertBefore(c: SubComponent, cs: List[SubComponent], before: SubComponent): List[SubComponent] = cs match {
case List() => List(c)
case c1 :: cs1 => if (c1 == before) c :: cs else c1 :: insertBefore(c, cs1, before)
}
- private var curRun: Run = NoRun
- override def currentRun: Run = curRun
+ private var curRun: Run = null
+ def currentRun: Run = curRun
+ override def currentRunId: RunId = if (curRun == null) NoRunId else curRun.id
- def onlyPresentation = settings.doc.value
+ private var runCount = 0;
- def forCLDC: Boolean = settings.target.value == "cldc"
+ class Run {
+ runCount = runCount + 1
+ if (settings.statistics.value) Console.println("creating run: "+runCount)
+ override def finalize() = {
+ runCount = runCount - 1
+ if (settings.statistics.value) Console.println("collecting run: "+runCount)
+ }
- class Run extends CompilerRun {
+ val id = new RunId
var currentUnit: CompilationUnit = _
curRun = this
- override val firstPhase = syntaxAnalyzer.newPhase(NoPhase);
- phase = firstPhase;
+ val firstPhase = syntaxAnalyzer.newPhase(NoPhase)
+ phase = firstPhase
definitions.init; // needs firstPhase and phase to be defined != NoPhase,
// that's why it is placed here.
- icodes.init;
+ icodes.init
private var p: Phase = firstPhase
private var stopped = false
for (val pd <- phaseDescriptors) {
if (!stopped) {
- if (!(settings.skip contains pd.phaseName)) p = pd.newPhase(p);
+ if (!(settings.skip contains pd.phaseName)) p = pd.newPhase(p)
stopped = settings.stop contains pd.phaseName
}
}
@@ -398,33 +411,30 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable
}
private def refreshProgress = if (fileset.size > 0)
progress((phasec * fileset.size) + unitc,
- (phaseDescriptors.length+1) * fileset.size);
+ (phaseDescriptors.length+1) * fileset.size)
- override def phaseNamed(name: String): Phase = {
+ def phaseNamed(name: String): Phase = {
var p: Phase = firstPhase
- while (p.next != p && p.name != name) p = p.next;
+ while (p.next != p && p.name != name) p = p.next
if (p.name != name) NoPhase else p
}
- override val namerPhase = phaseNamed("namer")
- override val typerPhase = phaseNamed("typer")
- override val refchecksPhase = phaseNamed("refchecks")
+ val namerPhase = phaseNamed("namer")
+ val typerPhase = phaseNamed("typer")
+ val refchecksPhase = phaseNamed("refchecks")
- override val explicitOuterPhase = phaseNamed("explicitouter")
- override val erasurePhase = phaseNamed("erasure")
- override val flattenPhase = phaseNamed("flatten")
- override val mixinPhase = phaseNamed("mixin")
- override val icodePhase = phaseNamed("icode")
+ val explicitOuterPhase = phaseNamed("explicitouter")
+ val erasurePhase = phaseNamed("erasure")
+ val flattenPhase = phaseNamed("flatten")
+ val mixinPhase = phaseNamed("mixin")
+ val icodePhase = phaseNamed("icode")
- private var unitbuf = new ListBuffer[CompilationUnit];
- private var fileset = new HashSet[AbstractFile];
+ private var unitbuf = new ListBuffer[CompilationUnit]
+ private var fileset = new HashSet[AbstractFile]
- override val terminalPhase : Phase =
+ val terminalPhase : Phase =
if (onlyPresentation) typerPhase.next.next
- else /* new GlobalPhase(p) {
- def name = "terminal"
- def apply(unit: CompilationUnit): unit = {}
- }*/ p;
+ else new TerminalPhase(p)
private def addUnit(unit: CompilationUnit): unit = {
unitbuf += unit
@@ -445,64 +455,66 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable
else if (symSource.isDefinedAt(sym)) true
else if (!sym.owner.isPackageClass) compiles(sym.toplevelClass)
else if (sym.isModuleClass) compiles(sym.sourceModule)
- else false;
+ else false
def compileSources(sources: List[SourceFile]): unit = {
- val startTime = System.currentTimeMillis();
+ val startTime = System.currentTimeMillis()
reporter.reset
for (val source <- sources)
- addUnit(new CompilationUnit(source));
+ addUnit(new CompilationUnit(source))
globalPhase = firstPhase
while (globalPhase != terminalPhase && reporter.errors == 0) {
- val startTime = System.currentTimeMillis();
- phase = globalPhase;
- globalPhase.run;
+ val startTime = System.currentTimeMillis()
+ phase = globalPhase
+ globalPhase.run
if (settings.print contains globalPhase.name)
if (globalPhase.id >= icodePhase.id) writeICode()
- else treePrinter.printAll();
- if (settings.browse contains globalPhase.name) treeBrowser.browse(units);
- informTime(globalPhase.description, startTime);
- globalPhase = globalPhase.next;
+ else treePrinter.printAll()
+ if (settings.browse contains globalPhase.name) treeBrowser.browse(units)
+ informTime(globalPhase.description, startTime)
+ globalPhase = globalPhase.next
if (settings.check contains globalPhase.name) {
- phase = globalPhase;
- if (globalPhase.id >= icodePhase.id) icodeChecker.checkICodes;
- else checker.checkTrees;
+ phase = globalPhase
+ if (globalPhase.id >= icodePhase.id) icodeChecker.checkICodes
+ else checker.checkTrees
}
- if (settings.statistics.value) statistics.print(phase);
+ if (settings.statistics.value) statistics.print(phase)
advancePhase
}
- if (settings.Xshowcls.value != "") showDef(newTermName(settings.Xshowcls.value), false);
- if (settings.Xshowobj.value != "") showDef(newTermName(settings.Xshowobj.value), true);
+ if (settings.Xshowcls.value != "") showDef(newTermName(settings.Xshowcls.value), false)
+ if (settings.Xshowobj.value != "") showDef(newTermName(settings.Xshowobj.value), true)
if (reporter.errors == 0) {
- assert(stopped || symData.isEmpty, symData.elements.toList);
+ assert(stopped || symData.isEmpty, symData.elements.toList)
} else {
for (val Pair(sym, file) <- symSource.elements) {
sym.reset(new loaders.SourcefileLoader(file));
- if (sym.isTerm) sym.moduleClass.reset(loaders.moduleClassLoader);
+ if (sym.isTerm) sym.moduleClass.reset(loaders.moduleClassLoader)
}
}
- for (val Pair(sym, file) <- symSource.elements) resetPackageClass(sym.owner);
+ for (val Pair(sym, file) <- symSource.elements) resetPackageClass(sym.owner)
+ //units foreach (.clear())
informTime("total", startTime)
+ curRun = null
}
def compileLate(file: AbstractFile): unit =
if (fileset == null) {
val msg = "No class file for " + file +
- " was found\n(This file cannot be loaded as a source file)";
+ " was found\n(This file cannot be loaded as a source file)"
System.err.println(msg)
throw new FatalError(msg)
}
else if (!(fileset contains file)) {
- val unit = new CompilationUnit(getSourceFile(file));
- addUnit(unit);
- var localPhase = firstPhase.asInstanceOf[GlobalPhase];
+ val unit = new CompilationUnit(getSourceFile(file))
+ addUnit(unit)
+ var localPhase = firstPhase.asInstanceOf[GlobalPhase]
while ((localPhase.id < globalPhase.id || localPhase.id <= namerPhase.id) &&
reporter.errors == 0) {
- atPhase(localPhase)(localPhase.applyPhase(unit));
- localPhase = localPhase.next.asInstanceOf[GlobalPhase];
+ atPhase(localPhase)(localPhase.applyPhase(unit))
+ localPhase = localPhase.next.asInstanceOf[GlobalPhase]
}
refreshProgress
}
@@ -522,7 +534,7 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable
}
private def resetPackageClass(pclazz: Symbol): unit = {
- assert(pclazz.isPackageClass, pclazz);
+ assert(pclazz.isPackageClass, pclazz)
atPhase(firstPhase) {
pclazz.setInfo(atPhase(typerPhase)(pclazz.info))
}
@@ -543,7 +555,7 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable
root.info.member(selector)
}
}
- val sym = getSym(name, module);
+ val sym = getSym(name, module)
System.err.println("" + sym.name + ":" +
(if (module) sym.tpe.symbol.info else sym.info))
}
@@ -556,9 +568,9 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable
var start = 0
var end = filename.indexOf('.', start)
while (end >= start) {
- outdir = new File(outdir, filename.substring(start, end));
- if (!outdir.exists()) outdir.mkdir();
- start = end + 1;
+ outdir = new File(outdir, filename.substring(start, end))
+ if (!outdir.exists()) outdir.mkdir()
+ start = end + 1
end = filename.indexOf('.', start)
}
new File(outdir, filename.substring(start) + suffix)
@@ -567,35 +579,37 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable
private def writeSymblFile(clazz: Symbol, pickled: PickleBuffer) = {
val file = getFile(clazz, ".symbl")
try {
- val stream = new FileOutputStream(file);
- stream.write(pickled.bytes, 0, pickled.writeIndex);
- stream.close();
+ val stream = new FileOutputStream(file)
+ stream.write(pickled.bytes, 0, pickled.writeIndex)
+ stream.close()
informProgress("wrote " + file)
} catch {
case ex: IOException =>
- if (settings.debug.value) ex.printStackTrace();
+ if (settings.debug.value) ex.printStackTrace()
error("could not write file " + file)
}
}
private def writeICode(): Unit = {
- val printer = new icodePrinter.TextPrinter(null, icodes.linearizer);
+ val printer = new icodePrinter.TextPrinter(null, icodes.linearizer)
icodes.classes.values.foreach((cls) => {
- val suffix = if (cls.symbol.hasFlag(Flags.MODULE)) "$.icode" else ".icode";
- var file = getFile(cls.symbol, suffix);
+ val suffix = if (cls.symbol.hasFlag(Flags.MODULE)) "$.icode" else ".icode"
+ var file = getFile(cls.symbol, suffix)
// if (file.exists())
-// file = new File(file.getParentFile(), file.getName() + "1");
+// file = new File(file.getParentFile(), file.getName() + "1")
try {
- val stream = new FileOutputStream(file);
- printer.setWriter(new PrintWriter(stream, true));
- printer.printClass(cls);
- informProgress("wrote " + file);
+ val stream = new FileOutputStream(file)
+ printer.setWriter(new PrintWriter(stream, true))
+ printer.printClass(cls)
+ informProgress("wrote " + file)
} catch {
case ex: IOException =>
- if (settings.debug.value) ex.printStackTrace();
- error("could not write file " + file);
+ if (settings.debug.value) ex.printStackTrace()
+ error("could not write file " + file)
}
- });
+ })
}
+ def forCLDC: Boolean = settings.target.value == "cldc"
+ def onlyPresentation = settings.doc.value
}
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
index 7936b250b0..0e1a028bd2 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
@@ -832,9 +832,9 @@ trait Scanners requires SyntaxAnalyzer {
// Build keyword array
key = new Array[byte](maxKey+1)
- for (val i <- Iterator.range(0, maxKey + 1))
+ for (val i <- 0 to maxKey)
key(i) = IDENTIFIER
- for (val j <- Iterator.range(0, tokenCount))
+ for (val j <- 0 until tokenCount)
if (tokenName(j) != null)
key(tokenName(j).start) = j.asInstanceOf[byte]
diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala
index 7dff504182..723db0a7fc 100644
--- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala
@@ -505,10 +505,10 @@ trait Definitions requires SymbolTable {
tparam => typeRef(SeqClass.typeConstructor.prefix, SeqClass, List(tparam.typeConstructor)));
ByNameParamClass = newCovariantPolyClass(
ScalaPackageClass, nme.BYNAME_PARAM_CLASS_NAME, tparam => AnyClass.typeConstructor);
- for (val i <- Iterator.range(1, MaxTupleArity + 1))
+ for (val i <- 1 to MaxTupleArity)
TupleClass(i) = getClass("scala.Tuple" + i);
- for (val i <- Iterator.range(0, MaxFunctionArity + 1))
- FunctionClass(i) = getClass("scala.Function" + i);
+ for (val i <- 0 to MaxFunctionArity)
+ FunctionClass(i) = getClass("scala.Function" + i);
//for (val i <- Iterator.range(0, MaxFunctionArity + 1)) {
// FunctionClass(i) = getClass("scala.Function" + i)
// RemoteFunctionClass(i) = getClass("scala.distributed.RemoteFunction" + i)
diff --git a/src/compiler/scala/tools/nsc/symtab/RunId.scala b/src/compiler/scala/tools/nsc/symtab/RunId.scala
new file mode 100644
index 0000000000..3dce5340d3
--- /dev/null
+++ b/src/compiler/scala/tools/nsc/symtab/RunId.scala
@@ -0,0 +1,11 @@
+/* NSC -- new Scala compiler
+ * Copyright 2005-2006 LAMP/EPFL
+ * @author Martin Odersky
+ */
+// $Id: RunId.scala 7272 2006-04-27 17:40:29 +0200 (Thu, 27 Apr 2006) michelou $
+
+package scala.tools.nsc.symtab
+
+class RunId {
+}
+
diff --git a/src/compiler/scala/tools/nsc/symtab/SymbolTable.scala b/src/compiler/scala/tools/nsc/symtab/SymbolTable.scala
index 7481431e96..1ff1bb2d5b 100644
--- a/src/compiler/scala/tools/nsc/symtab/SymbolTable.scala
+++ b/src/compiler/scala/tools/nsc/symtab/SymbolTable.scala
@@ -30,10 +30,10 @@ abstract class SymbolTable extends Names
ph = p
}
- final val NoRun = null;
+ final val NoRunId = null;
/** The current compiler run. */
- def currentRun: CompilerRun;
+ def currentRunId: RunId;
def atPhase[T](ph: Phase)(op: => T): T = {
val current = phase;
diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
index c13d13d86b..c075908ca8 100644
--- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
@@ -33,7 +33,7 @@ trait Symbols requires SymbolTable {
private var rawpos = initPos;
val id = { ids = ids + 1; ids }
- var validForRun: CompilerRun = NoRun;
+ var validForRunId: RunId = NoRunId;
def pos = rawpos;
def setPos(pos: int): this.type = { this.rawpos = pos; this }
@@ -276,7 +276,7 @@ trait Symbols requires SymbolTable {
this != NoSymbol && (!owner.isPackageClass || { rawInfo.load(this); rawInfo != NoType });
final def isInitialized: boolean =
- validForRun == currentRun;
+ validForRunId == currentRunId;
final def isCovariant: boolean = isType && hasFlag(COVARIANT);
@@ -327,7 +327,7 @@ trait Symbols requires SymbolTable {
*/
final def info: Type = {
var cnt = 0;
- while (validForRun != currentRun) {
+ while (validForRunId != currentRunId) {
//if (settings.debug.value) System.out.println("completing " + this);//DEBUG
var ifs = infos;
assert(ifs != null, this.name);
@@ -345,7 +345,7 @@ trait Symbols requires SymbolTable {
try {
phase = phaseWithId(ifs.start);
tp.complete(this);
- // if (settings.debug.value && (validForRun == currentRun) System.out.println("completed " + this/* + ":" + info*/);//DEBUG
+ // if (settings.debug.value && (validForRunId == currentRunId) System.out.println("completed " + this/* + ":" + info*/);//DEBUG
rawflags = rawflags & ~LOCKED
} finally {
phase = current
@@ -371,10 +371,10 @@ trait Symbols requires SymbolTable {
limit = pid;
if (info.isComplete) {
rawflags = rawflags & ~LOCKED;
- validForRun = currentRun
+ validForRunId = currentRunId
} else {
rawflags = rawflags & ~LOCKED;
- validForRun = NoRun
+ validForRunId = NoRunId
}
this
}
@@ -390,7 +390,7 @@ trait Symbols requires SymbolTable {
/** Return info without checking for initialization or completing */
final def rawInfo: Type = {
if (limit < phase.id) {
- if (validForRun == currentRun) {
+ if (validForRunId == currentRunId) {
val current = phase;
var itr = infoTransformers.nextFrom(limit);
infoTransformers = itr; // caching optimization
@@ -915,7 +915,7 @@ trait Symbols requires SymbolTable {
override def isType = true;
privateWithin = NoSymbol;
private var tyconCache: Type = null;
- private var tyconRun: CompilerRun = null;
+ private var tyconRun: RunId = null;
private var tpeCache: Type = _;
private var tpePhase: Phase = null;
override def tpe: Type = {
@@ -936,9 +936,9 @@ trait Symbols requires SymbolTable {
}
override def typeConstructor: Type = {
- if (tyconCache == null || tyconRun != currentRun) {
+ if (tyconCache == null || tyconRun != currentRunId) {
tyconCache = typeRef(if (isTypeParameter) NoPrefix else owner.thisType, this, List());
- tyconRun = currentRun;
+ tyconRun = currentRunId;
}
assert(tyconCache != null);
tyconCache
diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala
index 5f0daee90c..da6c41a754 100644
--- a/src/compiler/scala/tools/nsc/symtab/Types.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Types.scala
@@ -335,10 +335,10 @@ trait Types requires SymbolTable {
/** If this is a lazy type, assign a new type to `sym'. */
def complete(sym: Symbol): unit = {
- if (sym == NoSymbol || sym.isPackageClass) sym.validForRun = currentRun
+ if (sym == NoSymbol || sym.isPackageClass) sym.validForRunId = currentRunId
else {
val this1 = adaptToNewRunMap(this)
- if (this1 eq this) sym.validForRun = currentRun
+ if (this1 eq this) sym.validForRunId = currentRunId
else {
//System.out.println("new type of " + sym + "=" + this1);//DEBUG
sym.setInfo(this1)
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
index 93ae48e131..29dd3df042 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
@@ -15,23 +15,23 @@
code(new) = code(meth)
*/
-package scala.tools.nsc.symtab.classfile;
+package scala.tools.nsc.symtab.classfile
-import scala.tools.nsc.util.Position;
-import scala.tools.nsc.io.{AbstractFile, AbstractFileReader};
-import scala.collection.mutable.ListBuffer;
-import scala.collection.immutable.{Map, ListMap};
+import scala.tools.nsc.util.Position
+import scala.tools.nsc.io.{AbstractFile, AbstractFileReader}
+import scala.collection.mutable.ListBuffer
+import scala.collection.immutable.{Map, ListMap}
-import java.io.IOException;
+import java.io.IOException
abstract class ClassfileParser {
- def sourcePath : AbstractFile = null;
+ def sourcePath : AbstractFile = null
- val global: Global;
- import global._;
+ val global: Global
+ import global._
- import ClassfileConstants._;
- import Flags._;
+ import ClassfileConstants._
+ import Flags._
private var in: AbstractFileReader = _; // the class file
private var clazz: Symbol = _; // the class symbol containing dynamic members
@@ -43,8 +43,8 @@ abstract class ClassfileParser {
private var hasMeta: boolean = _; // does class file contain jaco meta attribute?s
private var busy: boolean = false; // lock to detect recursive reads
private var classTParams: Map[Name,Symbol] =
- collection.immutable.ListMap.Empty[Name,Symbol];
- private val fresh = new scala.tools.nsc.util.FreshNameCreator;
+ collection.immutable.ListMap.Empty[Name,Symbol]
+ private val fresh = new scala.tools.nsc.util.FreshNameCreator
private object metaParser extends MetaParser {
val global: ClassfileParser.this.global.type = ClassfileParser.this.global
@@ -59,21 +59,21 @@ abstract class ClassfileParser {
if (settings.debug.value) e.printStackTrace();//debug
throw new IOException("class file '" + in.file + "' is broken\n(" + e.getMessage() + ")")
}
- assert(!busy);
- busy = true;
- this.in = new AbstractFileReader(file);
+ assert(!busy)
+ busy = true
+ this.in = new AbstractFileReader(file)
if (root.isModule) {
- this.clazz = root.linkedClass;
+ this.clazz = root.linkedClass
this.staticModule = root
} else {
- this.clazz = root;
+ this.clazz = root
this.staticModule = root.linkedModule
}
- this.isScala = false;
- this.hasMeta = false;
+ this.isScala = false
+ this.hasMeta = false
try {
- parseHeader;
- this.pool = new ConstantPool;
+ parseHeader
+ this.pool = new ConstantPool
parseClass()
} catch {
case e: FatalError => handleError(e)
@@ -82,16 +82,16 @@ abstract class ClassfileParser {
busy = false
}
- private def statics: Symbol = staticModule.moduleClass;
+ private def statics: Symbol = staticModule.moduleClass
private def parseHeader: unit = {
- val magic = in.nextInt;
+ val magic = in.nextInt
if (magic != JAVA_MAGIC)
throw new IOException("class file '" + in.file + "' "
+ "has wrong magic number 0x" + Integer.toHexString(magic)
- + ", should be 0x" + Integer.toHexString(JAVA_MAGIC));
- val minorVersion = in.nextChar;
- val majorVersion = in.nextChar;
+ + ", should be 0x" + Integer.toHexString(JAVA_MAGIC))
+ val minorVersion = in.nextChar
+ val majorVersion = in.nextChar
if ((majorVersion < JAVA_MAJOR_VERSION) ||
((majorVersion == JAVA_MAJOR_VERSION) &&
(minorVersion < JAVA_MINOR_VERSION)))
@@ -99,49 +99,49 @@ abstract class ClassfileParser {
+ "has unknown version "
+ majorVersion + "." + minorVersion
+ ", should be at least "
- + JAVA_MAJOR_VERSION + "." + JAVA_MINOR_VERSION);
+ + JAVA_MAJOR_VERSION + "." + JAVA_MINOR_VERSION)
}
class ConstantPool {
- private val len = in.nextChar;
- private val starts = new Array[int](len);
- private val values = new Array[Object](len);
- private val internalized = new Array[Name](len);
- { var i = 1;
+ private val len = in.nextChar
+ private val starts = new Array[int](len)
+ private val values = new Array[Object](len)
+ private val internalized = new Array[Name](len)
+ { var i = 1
while (i < starts.length) {
starts(i) = in.bp;
- i = i + 1;
+ i = i + 1
in.nextByte match {
case CONSTANT_UTF8 | CONSTANT_UNICODE =>
- in.skip(in.nextChar);
+ in.skip(in.nextChar)
case CONSTANT_CLASS | CONSTANT_STRING =>
- in.skip(2);
+ in.skip(2)
case CONSTANT_FIELDREF | CONSTANT_METHODREF | CONSTANT_INTFMETHODREF | CONSTANT_NAMEANDTYPE | CONSTANT_INTEGER | CONSTANT_FLOAT =>
- in.skip(4);
+ in.skip(4)
case CONSTANT_LONG | CONSTANT_DOUBLE =>
- in.skip(8);
+ in.skip(8)
i = i + 1
case _ =>
- errorBadTag(in.bp - 1);
+ errorBadTag(in.bp - 1)
}
}
}
def getName(index: int): Name = {
- if (index <= 0 || len <= index) errorBadIndex(index);
- var name = values(index).asInstanceOf[Name];
+ if (index <= 0 || len <= index) errorBadIndex(index)
+ var name = values(index).asInstanceOf[Name]
if (name == null) {
- val start = starts(index);
- if (in.buf(start) != CONSTANT_UTF8) errorBadTag(start);
- name = newTermName(in.buf, start + 3, in.getChar(start + 1));
+ val start = starts(index)
+ if (in.buf(start) != CONSTANT_UTF8) errorBadTag(start)
+ name = newTermName(in.buf, start + 3, in.getChar(start + 1))
values(index) = name;
}
name
}
def getExternalName(index: int): Name = {
- if (index <= 0 || len <= index) errorBadIndex(index);
+ if (index <= 0 || len <= index) errorBadIndex(index)
if (internalized(index) == null) {
internalized(index) = getName(index).replace('/', '.')
}
@@ -149,32 +149,32 @@ abstract class ClassfileParser {
}
def getClassSymbol(index: int): Symbol = {
- if (index <= 0 || len <= index) errorBadIndex(index);
- var c = values(index).asInstanceOf[Symbol];
+ if (index <= 0 || len <= index) errorBadIndex(index)
+ var c = values(index).asInstanceOf[Symbol]
if (c == null) {
- val start = starts(index);
- if (in.buf(start) != CONSTANT_CLASS) errorBadTag(start);
- val name = getExternalName(in.getChar(start + 1));
+ val start = starts(index)
+ if (in.buf(start) != CONSTANT_CLASS) errorBadTag(start)
+ val name = getExternalName(in.getChar(start + 1))
if (name.pos('.') == name.length)
c = definitions.getMember(definitions.EmptyPackageClass, name.toTypeName)
else
- c = definitions.getClass(name);
- values(index) = c;
+ c = definitions.getClass(name)
+ values(index) = c
}
c
}
def getType(index: int): Type =
- sigToType(getExternalName(index));
+ sigToType(getExternalName(index))
def getSuperClass(index: int): Symbol =
- if (index == 0) definitions.AnyClass else getClassSymbol(index);
+ if (index == 0) definitions.AnyClass else getClassSymbol(index)
def getConstant(index: int): Constant = {
- if (index <= 0 || len <= index) errorBadIndex(index);
- var value = values(index);
+ if (index <= 0 || len <= index) errorBadIndex(index)
+ var value = values(index)
if (value == null) {
- val start = starts(index);
+ val start = starts(index)
value = in.buf(start) match {
case CONSTANT_STRING =>
Constant(getName(in.getChar(start + 1)).toString())
@@ -187,16 +187,16 @@ abstract class ClassfileParser {
case CONSTANT_DOUBLE =>
Constant(in.getDouble(start + 1))
case _ =>
- errorBadTag(start);
+ errorBadTag(start)
}
- values(index) = value;
+ values(index) = value
}
value.asInstanceOf[Constant]
}
/** Throws an exception signaling a bad constant index. */
private def errorBadIndex(index: int) =
- throw new RuntimeException("bad constant pool index: " + index);
+ throw new RuntimeException("bad constant pool index: " + index)
/** Throws an exception signaling a bad tag at given address. */
private def errorBadTag(start: int) =
@@ -204,16 +204,16 @@ abstract class ClassfileParser {
}
private def sigToType(name: Name): Type = {
- var index = 0;
- val end = name.length;
+ var index = 0
+ val end = name.length
def objToAny(tp: Type): Type =
if (tp.symbol == definitions.ObjectClass) definitions.AnyClass.tpe
- else tp;
+ else tp
def paramsigs2types: List[Type] =
if (name(index) == ')') { index = index + 1; List() }
- else objToAny(sig2type) :: paramsigs2types;
+ else objToAny(sig2type) :: paramsigs2types
def sig2type: Type = {
- val tag = name(index); index = index + 1;
+ val tag = name(index); index = index + 1
tag match {
case BYTE_TAG => definitions.ByteClass.tpe
case CHAR_TAG => definitions.CharClass.tpe
@@ -225,13 +225,13 @@ abstract class ClassfileParser {
case VOID_TAG => definitions.UnitClass.tpe
case BOOL_TAG => definitions.BooleanClass.tpe
case 'L' =>
- val start = index;
+ val start = index
while (name(index) != ';') { index = index + 1 }
- val end = index;
- index = index + 1;
+ val end = index
+ index = index + 1
definitions.getClass(name.subName(start, end)).tpe
case ARRAY_TAG =>
- while ('0' <= name(index) && name(index) <= '9') index = index + 1;
+ while ('0' <= name(index) && name(index) <= '9') index = index + 1
appliedType(definitions.ArrayClass.tpe, List(sig2type))
case '(' =>
JavaMethodType(paramsigs2types, sig2type)
@@ -241,43 +241,43 @@ abstract class ClassfileParser {
}
def parseClass(): unit = {
- val jflags = in.nextChar;
- val isAttribute = (jflags & JAVA_ACC_ANNOTATION) != 0;
- var sflags = transFlags(jflags);
- if ((sflags & DEFERRED) != 0) sflags = sflags & ~DEFERRED | ABSTRACT;
- val c = pool.getClassSymbol(in.nextChar);
+ val jflags = in.nextChar
+ val isAttribute = (jflags & JAVA_ACC_ANNOTATION) != 0
+ var sflags = transFlags(jflags)
+ if ((sflags & DEFERRED) != 0) sflags = sflags & ~DEFERRED | ABSTRACT
+ val c = pool.getClassSymbol(in.nextChar)
if (c != clazz)
- throw new IOException("class file '" + in.file + "' contains wrong " + clazz);
+ throw new IOException("class file '" + in.file + "' contains wrong " + clazz)
val superType = if (isAttribute) { in.nextChar; definitions.AttributeClass.tpe }
- else pool.getSuperClass(in.nextChar).tpe;
- val ifaceCount = in.nextChar;
+ else pool.getSuperClass(in.nextChar).tpe
+ val ifaceCount = in.nextChar
val parents = (superType ::
(for (val i <- List.range(0, ifaceCount))
- yield pool.getSuperClass(in.nextChar).tpe));
- instanceDefs = new Scope();
- staticDefs = new Scope();
- val classInfo = ClassInfoType(parents, instanceDefs, clazz);
- val staticInfo = ClassInfoType(List(), staticDefs, statics);
+ yield pool.getSuperClass(in.nextChar).tpe))
+ instanceDefs = new Scope()
+ staticDefs = new Scope()
+ val classInfo = ClassInfoType(parents, instanceDefs, clazz)
+ val staticInfo = ClassInfoType(List(), staticDefs, statics)
- val curbp = in.bp;
+ val curbp = in.bp
skipMembers(); // fields
skipMembers(); // methods
- parseAttributes(clazz, classInfo);
+ parseAttributes(clazz, classInfo)
if (!isScala) {
- clazz.setFlag(sflags);
- setPrivateWithin(clazz, jflags);
+ clazz.setFlag(sflags)
+ setPrivateWithin(clazz, jflags)
if (!hasMeta) {
- clazz.setInfo(classInfo);
+ clazz.setInfo(classInfo)
}
- statics.setInfo(staticInfo);
- staticModule.setInfo(statics.tpe);
- staticModule.setFlag(JAVA);
- staticModule.moduleClass.setFlag(JAVA);
- in.bp = curbp;
- val fieldCount = in.nextChar;
- for (val i <- Iterator.range(0, fieldCount)) parseField();
- val methodCount = in.nextChar;
- for (val i <- Iterator.range(0, methodCount)) parseMethod();
+ statics.setInfo(staticInfo)
+ staticModule.setInfo(statics.tpe)
+ staticModule.setFlag(JAVA)
+ staticModule.moduleClass.setFlag(JAVA)
+ in.bp = curbp
+ val fieldCount = in.nextChar
+ for (val i <- 0 until fieldCount) parseField()
+ val methodCount = in.nextChar
+ for (val i <- 0 until methodCount) parseMethod()
if ((instanceDefs.lookup(nme.CONSTRUCTOR) == NoSymbol
&& (sflags & INTERFACE) == 0) ||
isAttribute)
@@ -294,49 +294,49 @@ abstract class ClassfileParser {
instanceDefs.enter(
clazz.newConstructor(Position.NOPOS)
.setFlag(clazz.flags & ConstrFlags)
- .setInfo(MethodType(constrParamTypes, clazz.tpe)));
+ .setInfo(MethodType(constrParamTypes, clazz.tpe)))
}
}
}
def parseField(): unit = {
- val jflags = in.nextChar;
- var sflags = transFlags(jflags);
- if ((sflags & FINAL) == 0) sflags = sflags | MUTABLE;
+ val jflags = in.nextChar
+ var sflags = transFlags(jflags)
+ if ((sflags & FINAL) == 0) sflags = sflags | MUTABLE
if ((sflags & PRIVATE) != 0) {
in.skip(4); skipAttributes();
} else {
- val name = pool.getName(in.nextChar);
- val info = pool.getType(in.nextChar);
+ val name = pool.getName(in.nextChar)
+ val info = pool.getType(in.nextChar)
val sym = getOwner(jflags)
- .newValue(Position.NOPOS, name).setFlag(sflags);
- sym.setInfo(if ((jflags & JAVA_ACC_ENUM) == 0) info else ConstantType(Constant(sym)));
- setPrivateWithin(sym, jflags);
- parseAttributes(sym, info);
- getScope(jflags).enter(sym);
+ .newValue(Position.NOPOS, name).setFlag(sflags)
+ sym.setInfo(if ((jflags & JAVA_ACC_ENUM) == 0) info else ConstantType(Constant(sym)))
+ setPrivateWithin(sym, jflags)
+ parseAttributes(sym, info)
+ getScope(jflags).enter(sym)
}
}
def parseMethod(): unit = {
- val jflags = in.nextChar;
- var sflags = transFlags(jflags);
- if ((jflags & JAVA_ACC_BRIDGE) != 0) sflags = sflags | PRIVATE;
+ val jflags = in.nextChar
+ var sflags = transFlags(jflags)
+ if ((jflags & JAVA_ACC_BRIDGE) != 0) sflags = sflags | PRIVATE
if ((sflags & PRIVATE) != 0) {
in.skip(4); skipAttributes();
} else {
- val name = pool.getName(in.nextChar);
- var info = pool.getType(in.nextChar);
+ val name = pool.getName(in.nextChar)
+ var info = pool.getType(in.nextChar)
if (name == nme.CONSTRUCTOR)
info match {
case MethodType(formals, restpe) =>
- assert(restpe.symbol == definitions.UnitClass);
+ assert(restpe.symbol == definitions.UnitClass)
info = MethodType(formals, clazz.tpe)
}
val sym = getOwner(jflags)
- .newMethod(Position.NOPOS, name).setFlag(sflags).setInfo(info);
- setPrivateWithin(sym, jflags);
- parseAttributes(sym, info);
- getScope(jflags).enter(sym);
+ .newMethod(Position.NOPOS, name).setFlag(sflags).setInfo(info)
+ setPrivateWithin(sym, jflags)
+ parseAttributes(sym, info)
+ getScope(jflags).enter(sym)
}
}
@@ -345,54 +345,54 @@ abstract class ClassfileParser {
private def polySigToType(sym: Symbol, sig: Name): Type =
try { polySigToType0(sym, sig) }
catch {
- case e: Throwable => System.err.println("" + sym + " - " + sig); throw e;
+ case e: Throwable => System.err.println("" + sym + " - " + sig); throw e
}
private def polySigToType0(sym: Symbol, sig: Name): Type = {
- var index = 0;
- val end = sig.length;
- val newTParams = new ListBuffer[Symbol]();
+ var index = 0
+ val end = sig.length
+ val newTParams = new ListBuffer[Symbol]()
def objToAny(tp: Type): Type =
if (tp.symbol == definitions.ObjectClass) definitions.AnyClass.tpe
- else tp;
+ else tp
def subName(isDelimiter: Char => Boolean): Name = {
- val start = index;
+ val start = index
while (!isDelimiter(sig(index))) { index = index + 1; }
sig.subName(start, index)
}
def typeParams(tparams: Map[Name,Symbol], covariant: Boolean): List[Type] = {
- assert(sig(index) == '<');
- index = index + 1;
- val xs = new ListBuffer[Type]();
+ assert(sig(index) == '<')
+ index = index + 1
+ val xs = new ListBuffer[Type]()
while (sig(index) != '>') {
sig(index) match {
case variance @ ('+' | '-' | '*') =>
- index = index + 1;
+ index = index + 1
val bounds = variance match {
case '+' => TypeBounds(definitions.AllRefClass.typeConstructor,
- sig2type(tparams, covariant));
+ sig2type(tparams, covariant))
case '-' => TypeBounds(sig2type(tparams, covariant),
- definitions.AnyRefClass.typeConstructor);
+ definitions.AnyRefClass.typeConstructor)
case '*' => TypeBounds(definitions.AllRefClass.typeConstructor,
definitions.AnyRefClass.typeConstructor)
}
- val name = fresh.newName("T_" + sym.name);
+ val name = fresh.newName("T_" + sym.name)
val newtparam =
- if (covariant) clazz.newAbstractType(Position.NOPOS, name);
+ if (covariant) clazz.newAbstractType(Position.NOPOS, name)
else {
- val s = sym.newTypeParameter(Position.NOPOS, name);
- newTParams += s;
+ val s = sym.newTypeParameter(Position.NOPOS, name)
+ newTParams += s
s
}
- newtparam.setInfo(bounds);
+ newtparam.setInfo(bounds)
xs += newtparam.tpe
- case _ => xs += sig2type(tparams, covariant);
+ case _ => xs += sig2type(tparams, covariant)
}
}
- index = index + 1;
+ index = index + 1
xs.toList
}
def sig2type(tparams: Map[Name,Symbol], covariant: Boolean): Type = {
- val tag = sig(index); index = index + 1;
+ val tag = sig(index); index = index + 1
tag match {
case BYTE_TAG => definitions.ByteClass.tpe
case CHAR_TAG => definitions.CharClass.tpe
@@ -404,65 +404,65 @@ abstract class ClassfileParser {
case VOID_TAG => definitions.UnitClass.tpe
case BOOL_TAG => definitions.BooleanClass.tpe
case 'L' =>
- var tpe = definitions.getClass(subName(c => ((c == ';') || (c == '<')))).tpe;
+ var tpe = definitions.getClass(subName(c => ((c == ';') || (c == '<')))).tpe
if (sig(index) == '<')
- tpe = appliedType(tpe, typeParams(tparams, covariant));
- index = index + 1;
+ tpe = appliedType(tpe, typeParams(tparams, covariant))
+ index = index + 1
tpe
case ARRAY_TAG =>
- while ('0' <= sig(index) && sig(index) <= '9') index = index + 1;
+ while ('0' <= sig(index) && sig(index) <= '9') index = index + 1
appliedType(definitions.ArrayClass.tpe, List(sig2type(tparams, covariant)))
case '(' =>
- val paramtypes = new ListBuffer[Type]();
+ val paramtypes = new ListBuffer[Type]()
while (sig(index) != ')') {
- paramtypes += objToAny(sig2type(tparams, false));
+ paramtypes += objToAny(sig2type(tparams, false))
}
- index = index + 1;
+ index = index + 1
val restype = if (sym.isConstructor) {
- assert(sig(index) == 'V');
- index = index + 1;
+ assert(sig(index) == 'V')
+ index = index + 1
clazz.tpe
} else
sig2type(tparams, true)
MethodType(paramtypes.toList, restype)
case 'T' =>
- val n = subName(';'.==).toTypeName;
- index = index + 1;
+ val n = subName(';'.==).toTypeName
+ index = index + 1
tparams(n).typeConstructor
}
}
- var tparams = classTParams;
+ var tparams = classTParams
if (sig(index) == '<') {
- index = index + 1;
+ index = index + 1
while (sig(index) != '>') {
- val tpname = subName(':'.==).toTypeName;
- val s = sym.newTypeParameter(Position.NOPOS, tpname);
- tparams = tparams + tpname -> s;
- val ts = new ListBuffer[Type];
+ val tpname = subName(':'.==).toTypeName
+ val s = sym.newTypeParameter(Position.NOPOS, tpname)
+ tparams = tparams + tpname -> s
+ val ts = new ListBuffer[Type]
while (sig(index) == ':') {
- index = index + 1;
+ index = index + 1
if (sig(index) != ':') // guard against empty class bound
- ts += sig2type(tparams, false);
+ ts += sig2type(tparams, false)
}
s.setInfo(TypeBounds(definitions.AllRefClass.typeConstructor,
- intersectionType(ts.toList, sym)));
- newTParams += s;
+ intersectionType(ts.toList, sym)))
+ newTParams += s
}
- index = index + 1;
+ index = index + 1
}
val tpe =
if (sym.isClass) {
- classTParams = tparams;
- val parents = new ListBuffer[Type]();
+ classTParams = tparams
+ val parents = new ListBuffer[Type]()
while (index < end) {
parents += sig2type(tparams, true); // here the variance doesnt'matter
}
- ClassInfoType(parents.toList, instanceDefs, sym);
+ ClassInfoType(parents.toList, instanceDefs, sym)
}
else
- sig2type(tparams, true);
+ sig2type(tparams, true)
if (newTParams.length == 0) tpe
- else PolyType(newTParams.toList, tpe);
+ else PolyType(newTParams.toList, tpe)
}
def parseAttributes(sym: Symbol, symtype: Type): unit = {
@@ -473,160 +473,160 @@ abstract class ClassfileParser {
c convertTo pt
}
def parseAttribute(): unit = {
- val attrName = pool.getName(in.nextChar);
- val attrLen = in.nextInt;
+ val attrName = pool.getName(in.nextChar)
+ val attrLen = in.nextInt
attrName match {
case nme.SignatureATTR =>
if (global.settings.Xgenerics.value) {
- val sig = pool.getExternalName(in.nextChar);
- val newType = polySigToType(sym, sig);
+ val sig = pool.getExternalName(in.nextChar)
+ val newType = polySigToType(sym, sig)
sym.setInfo(newType)
if (settings.debug.value)
- global.inform("" + sym + "; signatire = " + sig + " type = " + newType);
- hasMeta = true;
+ global.inform("" + sym + "; signatire = " + sig + " type = " + newType)
+ hasMeta = true
} else
- in.skip(attrLen);
+ in.skip(attrLen)
case nme.SyntheticATTR =>
- sym.setFlag(SYNTHETIC);
+ sym.setFlag(SYNTHETIC)
in.skip(attrLen)
case nme.BridgeATTR =>
- sym.setFlag(BRIDGE);
+ sym.setFlag(BRIDGE)
in.skip(attrLen)
case nme.DeprecatedATTR =>
- sym.setFlag(DEPRECATED);
+ sym.setFlag(DEPRECATED)
in.skip(attrLen)
case nme.ConstantValueATTR =>
- val c = pool.getConstant(in.nextChar);
- val c1 = convertTo(c, symtype);
- if (c1 != null) sym.setInfo(ConstantType(c1));
+ val c = pool.getConstant(in.nextChar)
+ val c1 = convertTo(c, symtype)
+ if (c1 != null) sym.setInfo(ConstantType(c1))
else System.out.println("failure to convert "+c+" to "+symtype);//debug
case nme.InnerClassesATTR =>
parseInnerClasses()
case nme.ScalaSignatureATTR =>
- unpickler.unpickle(in.buf, in.bp, clazz, staticModule, in.file.toString());
- this.isScala = true;
+ unpickler.unpickle(in.buf, in.bp, clazz, staticModule, in.file.toString())
+ this.isScala = true
case nme.JacoMetaATTR =>
- val meta = pool.getName(in.nextChar).toString().trim();
- metaParser.parse(meta, sym, symtype);
- this.hasMeta = true;
+ val meta = pool.getName(in.nextChar).toString().trim()
+ metaParser.parse(meta, sym, symtype)
+ this.hasMeta = true
case nme.SourceFileATTR =>
- assert(attrLen == 2);
- val source = pool.getName(in.nextChar);
+ assert(attrLen == 2)
+ val source = pool.getName(in.nextChar)
if (sourcePath != null) {
- val sourceFile0 = sourcePath.lookupPath(source.toString(), false);
+ val sourceFile0 = sourcePath.lookupPath(source.toString(), false)
if (sourceFile0 != null && clazz.sourceFile == null) {
- clazz.sourceFile = sourceFile0;
+ clazz.sourceFile = sourceFile0
}
staticModule.moduleClass.sourceFile = clazz.sourceFile
}
case nme.RuntimeAnnotationATTR =>
- //parseAnnotations(attrLen);
+ //parseAnnotations(attrLen)
in.skip(attrLen)
case _ =>
in.skip(attrLen)
}
}
def parseTaggedConstant(): Any = {
- val tag = in.nextByte;
- val index = in.nextChar;
+ val tag = in.nextByte
+ val index = in.nextChar
tag match {
- case STRING_TAG => pool.getName(index).toString();
- case BOOL_TAG => pool.getConstant(index).intValue != 0;
- case BYTE_TAG => pool.getConstant(index).byteValue;
- case CHAR_TAG => pool.getConstant(index).charValue;
- case SHORT_TAG => pool.getConstant(index).shortValue;
+ case STRING_TAG => pool.getName(index).toString()
+ case BOOL_TAG => pool.getConstant(index).intValue != 0
+ case BYTE_TAG => pool.getConstant(index).byteValue
+ case CHAR_TAG => pool.getConstant(index).charValue
+ case SHORT_TAG => pool.getConstant(index).shortValue
case INT_TAG => pool.getConstant(index).intValue
- case LONG_TAG => pool.getConstant(index).longValue;
- case FLOAT_TAG => pool.getConstant(index).floatValue;
- case DOUBLE_TAG => pool.getConstant(index).doubleValue;
- case CLASS_TAG => pool.getType(index).toString() + ".class";
+ case LONG_TAG => pool.getConstant(index).longValue
+ case FLOAT_TAG => pool.getConstant(index).floatValue
+ case DOUBLE_TAG => pool.getConstant(index).doubleValue
+ case CLASS_TAG => pool.getType(index).toString() + ".class"
case ENUM_TAG =>
- pool.getType(index).toString() + "." + pool.getName(in.nextChar);
+ pool.getType(index).toString() + "." + pool.getName(in.nextChar)
case ARRAY_TAG =>
- val arr = new ListBuffer[Any]();
- for (val i <- Iterator.range(0, index)) {
+ val arr = new ListBuffer[Any]()
+ for (val i <- 0 until index) {
arr += parseTaggedConstant()
}
- arr.toList.mkString("{", ",", "}");
+ arr.toList.mkString("{", ",", "}")
}
}
def parseAnnotations(len: Int): Unit = {
- val buf = new StringBuffer();
- val nAttr = in.nextChar;
- for (val n <- Iterator.range(0,nAttr)) {
- val attrNameIndex = in.nextChar;
- val attrType = pool.getType(attrNameIndex);
- buf.append("@").append(attrType.toString()).append("(");
+ val buf = new StringBuffer()
+ val nAttr = in.nextChar
+ for (val n <- 0 until nAttr) {
+ val attrNameIndex = in.nextChar
+ val attrType = pool.getType(attrNameIndex)
+ buf.append("@").append(attrType.toString()).append("(")
val nargs = in.nextChar
- for (val i <- Iterator.range(0, nargs)) {
- if (i > 0) buf.append(", ");
- val name = pool.getName(in.nextChar);
- buf.append(name).append(" = ");
- val value = parseTaggedConstant();
- buf.append(value);
+ for (val i <- 0 until nargs) {
+ if (i > 0) buf.append(", ")
+ val name = pool.getName(in.nextChar)
+ buf.append(name).append(" = ")
+ val value = parseTaggedConstant()
+ buf.append(value)
}
- buf.append(")");
+ buf.append(")")
}
- global.informProgress("parsed attribute " + buf);
+ global.informProgress("parsed attribute " + buf)
}
def parseInnerClasses(): unit = {
- for (val i <- Iterator.range(0, in.nextChar)) {
- val innerIndex = in.nextChar;
- val outerIndex = in.nextChar;
- val nameIndex = in.nextChar;
- val jflags = in.nextChar;
+ for (val i <- 0 until in.nextChar) {
+ val innerIndex = in.nextChar
+ val outerIndex = in.nextChar
+ val nameIndex = in.nextChar
+ val jflags = in.nextChar
if (innerIndex != 0 && outerIndex != 0 && nameIndex != 0 &&
(jflags & (JAVA_ACC_PUBLIC | JAVA_ACC_PROTECTED)) != 0 &&
pool.getClassSymbol(outerIndex) == sym) {
val innerAlias = getOwner(jflags)
.newAliasType(Position.NOPOS, pool.getName(nameIndex).toTypeName)
- .setInfo(pool.getClassSymbol(innerIndex).tpe);
- getScope(jflags).enter(innerAlias);
+ .setInfo(pool.getClassSymbol(innerIndex).tpe)
+ getScope(jflags).enter(innerAlias)
}
}
}
- val attrCount = in.nextChar;
- for (val i <- Iterator.range(0, attrCount)) parseAttribute()
+ val attrCount = in.nextChar
+ for (val i <- 0 until attrCount) parseAttribute()
}
def skipAttributes(): unit = {
- val attrCount = in.nextChar;
- for (val i <- Iterator.range(0, attrCount)) {
+ val attrCount = in.nextChar
+ for (val i <- 0 until attrCount) {
in.skip(2); in.skip(in.nextInt)
}
}
def skipMembers(): unit = {
- val memberCount = in.nextChar;
- for (val i <- Iterator.range(0, memberCount)) {
+ val memberCount = in.nextChar
+ for (val i <- 0 until memberCount) {
in.skip(6); skipAttributes()
}
}
private def getOwner(flags: int): Symbol =
- if ((flags & JAVA_ACC_STATIC) != 0) statics else clazz;
+ if ((flags & JAVA_ACC_STATIC) != 0) statics else clazz
private def getScope(flags: int): Scope =
- if ((flags & JAVA_ACC_STATIC) != 0) staticDefs else instanceDefs;
+ if ((flags & JAVA_ACC_STATIC) != 0) staticDefs else instanceDefs
private def transFlags(flags: int): long = {
- var res = 0l;
+ var res = 0l
if ((flags & JAVA_ACC_PRIVATE) != 0)
res = res | PRIVATE
else if ((flags & JAVA_ACC_PROTECTED) != 0)
res = res | PROTECTED
if ((flags & JAVA_ACC_ABSTRACT) != 0 && (flags & JAVA_ACC_ANNOTATION) == 0)
- res = res | DEFERRED;
+ res = res | DEFERRED
if ((flags & JAVA_ACC_FINAL) != 0)
- res = res | FINAL;
+ res = res | FINAL
if (((flags & JAVA_ACC_INTERFACE) != 0) &&
((flags & JAVA_ACC_ANNOTATION) == 0))
- res = res | TRAIT | INTERFACE | ABSTRACT;
+ res = res | TRAIT | INTERFACE | ABSTRACT
if ((flags & JAVA_ACC_SYNTHETIC) != 0)
- res = res | SYNTHETIC;
+ res = res | SYNTHETIC
if ((flags & JAVA_ACC_STATIC) != 0)
- res = res | STATIC;
- res | JAVA;
+ res = res | STATIC
+ res | JAVA
}
private def setPrivateWithin(sym: Symbol, jflags: int): unit =
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala
index 7f70bb4bf9..52cd9e768b 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala
@@ -253,7 +253,7 @@ abstract class Pickler extends SubComponent {
writeNat(MinorVersion);
writeNat(ep);
if (settings.debug.value) log("" + ep + " entries");//debug
- for (val i <- Iterator.range(0, ep)) writeEntry(entries(i));
+ for (val i <- 0 until ep) writeEntry(entries(i));
}
override def toString() = "" + rootName + " in " + rootOwner;
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala
index 7812163256..de8736f1e9 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala
@@ -35,7 +35,7 @@ abstract class UnPickler {
private val entries = new Array[AnyRef](index.length)
private val symScopes = new HashMap[Symbol, Scope]
- for (val i <- Iterator.range(0, index.length)) {
+ for (val i <- 0 until index.length) {
if (isSymbolEntry(i)) { at(i, readSymbol); () }
}
@@ -259,11 +259,11 @@ abstract class UnPickler {
throw new RuntimeException("malformed Scala signature of " + classRoot.name + " at " + readIndex + "; " + msg)
private class LazyTypeRef(i: int) extends LazyType {
- private val definedAtRun = currentRun
+ private val definedAtRunId = currentRunId
override def complete(sym: Symbol): unit = {
val tp = at(i, readType)
sym setInfo tp
- if (currentRun != definedAtRun) tp.complete(sym)
+ if (currentRunId != definedAtRunId) tp.complete(sym)
}
override def load(sym: Symbol): unit = complete(sym)
}
diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala
index bb8ebb8cd4..087f1a4d98 100644
--- a/src/compiler/scala/tools/nsc/transform/Erasure.scala
+++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala
@@ -254,16 +254,12 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer {
else gen.mkAttributedCast(tree, pt);
/** Is symbol a member of unboxed arrays (which will be expanded directly later)? */
- private def isUnboxedArrayMember(sym: Symbol) = (
+ private def isUnboxedArrayMember(sym: Symbol) =
sym.name == nme.apply || sym.name == nme.length || sym.name == nme.update ||
sym.owner == ObjectClass
- );
- /** Is symbol a member of a boxed value class (which will not be expanded later)? */
- def isBoxedValueMember(sym: Symbol) =
- (sym.name == nme.equals_ || sym.name == nme.hashCode_ || sym.name == nme.toString_ ||
- (sym.name == nme.EQ || sym.name == nme.NE) && sym.info.paramTypes.head.symbol == ObjectClass ||
- sym == Object_isInstanceOf || sym == Object_asInstanceOf);
+ private def isUnboxedValueMember(sym: Symbol) =
+ sym != NoSymbol && isValueClass(sym.owner)
/** Adapt `tree' to expected type `pt' */
private def adaptToType(tree: Tree, pt: Type): Tree = {
@@ -323,31 +319,28 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer {
else
tree
case Select(qual, name) if (name != nme.CONSTRUCTOR) =>
- if (tree.symbol == Any_asInstanceOf || tree.symbol == Any_asInstanceOfErased)
+ if (tree.symbol == NoSymbol)
+ tree
+ else if (tree.symbol == Any_asInstanceOf || tree.symbol == Any_asInstanceOfErased)
adaptMember(atPos(tree.pos)(Select(qual, Object_asInstanceOf)))
else if (tree.symbol == Any_isInstanceOf || tree.symbol == Any_isInstanceOfErased)
adaptMember(atPos(tree.pos)(Select(qual, Object_isInstanceOf)))
- else if (tree.symbol != NoSymbol && tree.symbol.owner == AnyClass)
+ else if (tree.symbol.owner == AnyClass)
adaptMember(atPos(tree.pos)(Select(qual, getMember(ObjectClass, name))))
else {
var qual1 = typedQualifier(qual);
- if ((isValueClass(qual1.tpe.symbol) && isBoxedValueMember(tree.symbol)) ||
- (qual1.tpe.symbol == ArrayClass && !isUnboxedArrayMember(tree.symbol))) {
+ if ((isValueClass(qual1.tpe.symbol) && !isUnboxedValueMember(tree.symbol)) ||
+ (qual1.tpe.symbol == ArrayClass && !isUnboxedArrayMember(tree.symbol)))
qual1 = box(qual1);
- } else if (!isValueClass(qual1.tpe.symbol) &&
- tree.symbol != NoSymbol &&
- isValueClass(tree.symbol.owner) &&
- !isBoxedValueMember(tree.symbol)) {
+ else if (!isValueClass(qual1.tpe.symbol) && isUnboxedValueMember(tree.symbol))
qual1 = unbox(qual1, tree.symbol.owner.tpe)
- }
- if (tree.symbol != NoSymbol)
- if (isUnboxedClass(tree.symbol.owner) && !isUnboxedClass(qual1.tpe.symbol))
- tree.symbol = NoSymbol
- else if (qual1.tpe.isInstanceOf[MethodType] && qual1.tpe.paramTypes.isEmpty) {
- assert(qual1.symbol.isStable);
- qual1 = Apply(qual1, List()) setPos qual1.pos setType qual1.tpe.resultType;
- } else if (!(qual1.isInstanceOf[Super] || (qual1.tpe.symbol isSubClass tree.symbol.owner)))
- qual1 = cast(qual1, tree.symbol.owner.tpe);
+ if (isUnboxedClass(tree.symbol.owner) && !isUnboxedClass(qual1.tpe.symbol))
+ tree.symbol = NoSymbol
+ else if (qual1.tpe.isInstanceOf[MethodType] && qual1.tpe.paramTypes.isEmpty) {
+ assert(qual1.symbol.isStable);
+ qual1 = Apply(qual1, List()) setPos qual1.pos setType qual1.tpe.resultType;
+ } else if (!(qual1.isInstanceOf[Super] || (qual1.tpe.symbol isSubClass tree.symbol.owner)))
+ qual1 = cast(qual1, tree.symbol.owner.tpe);
copy.Select(tree, qual1, name)
}
case _ =>
diff --git a/src/compiler/scala/tools/nsc/transform/LiftCode.scala b/src/compiler/scala/tools/nsc/transform/LiftCode.scala
index f3eb029040..9dd92af3af 100644
--- a/src/compiler/scala/tools/nsc/transform/LiftCode.scala
+++ b/src/compiler/scala/tools/nsc/transform/LiftCode.scala
@@ -206,7 +206,7 @@ abstract class LiftCode extends Transform {
val name = className(c);
if (name.length() == 0) throw new Error("don't know how to inject " + value);
val injectedArgs = new ListBuffer[Tree];
- for (val i <- Iterator.range(0, c.caseArity))
+ for (val i <- 0 until c.caseArity)
injectedArgs += inject(c.caseElement(i));
New(Ident(definitions.getClass(name)), List(injectedArgs.toList))
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
index 2903cfc6bb..a6ac327971 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
@@ -5,57 +5,58 @@
// $Id$
package scala.tools.nsc.typechecker;
-import symtab.Flags._;
-import scala.tools.nsc.util.Position;
+import symtab.RunId
+import symtab.Flags._
+import scala.tools.nsc.util.Position
trait Contexts requires Analyzer {
- import global._;
+ import global._
val NoContext = new Context {
- override def implicitss: List[List[ImplicitInfo]] = List();
+ override def implicitss: List[List[ImplicitInfo]] = List()
}
- NoContext.enclClass = NoContext;
- NoContext.enclMethod = NoContext;
+ NoContext.enclClass = NoContext
+ NoContext.enclMethod = NoContext
private val startContext = NoContext.make(
Template(List(), List()) setSymbol NoSymbol setType NoType,
definitions.RootClass,
- definitions.RootClass.info.decls);
+ definitions.RootClass.info.decls)
- def rootContext(unit: CompilationUnit): Context = rootContext(unit, EmptyTree, false);
+ def rootContext(unit: CompilationUnit): Context = rootContext(unit, EmptyTree, false)
def rootContext(unit: CompilationUnit, tree: Tree, erasedTypes: boolean): Context = {
- import definitions._;
- var sc = startContext;
+ import definitions._
+ var sc = startContext
def addImport(pkg: Symbol): unit = {
- assert(pkg != null);
- val qual = gen.mkAttributedStableRef(pkg);
+ assert(pkg != null)
+ val qual = gen.mkAttributedStableRef(pkg)
sc = sc.makeNewImport(
Import(qual, List(Pair(nme.WILDCARD, null)))
.setSymbol(NoSymbol.newImport(Position.NOPOS).setInfo(ImportType(qual)))
- .setType(NoType));
+ .setType(NoType))
sc.depth = sc.depth + 1
}
if (!settings.noimports.value) {
- assert(isDefinitionsInitialized);
- addImport(JavaLangPackage);
- assert(ScalaPackage != null, "Scala package is null");
- addImport(ScalaPackage);
+ assert(isDefinitionsInitialized)
+ addImport(JavaLangPackage)
+ assert(ScalaPackage != null, "Scala package is null")
+ addImport(ScalaPackage)
if (!settings.nopredefs.value/* || unit.source.file.name != "Predef.scala"*/)
- addImport(PredefModule);
+ addImport(PredefModule)
}
- val c = sc.make(unit, tree, sc.owner, sc.scope, sc.imports);
- c.reportAmbiguousErrors = !erasedTypes;
- c.reportGeneralErrors = !erasedTypes;
- c.implicitsEnabled = !erasedTypes;
+ val c = sc.make(unit, tree, sc.owner, sc.scope, sc.imports)
+ c.reportAmbiguousErrors = !erasedTypes
+ c.reportGeneralErrors = !erasedTypes
+ c.implicitsEnabled = !erasedTypes
c
}
def resetContexts: unit = {
- var sc = startContext;
+ var sc = startContext
while (sc != NoContext) {
sc.tree match {
- case Import(qual, _) => qual.tpe = singleType(qual.symbol.owner.thisType, qual.symbol);
+ case Import(qual, _) => qual.tpe = singleType(qual.symbol.owner.thisType, qual.symbol)
case _ =>
}
sc = sc.outer
@@ -63,7 +64,7 @@ trait Contexts requires Analyzer {
}
class Context {
- var unit: CompilationUnit = _;
+ var unit: CompilationUnit = _
var tree: Tree = _; // Tree associated with this context
var owner: Symbol = NoSymbol; // The current owner
var scope: Scope = _; // The current scope
@@ -73,40 +74,40 @@ trait Contexts requires Analyzer {
var enclMethod: Context = _; // The next outer context whose tree is a method
var variance: int = _; // Variance relative to enclosing class.
private var _undetparams: List[Symbol] = List(); // Undetermined type parameters
- var depth: int = 0;
- var imports: List[ImportInfo] = List();
+ var depth: int = 0
+ var imports: List[ImportInfo] = List()
- var prefix: Type = NoPrefix;
+ var prefix: Type = NoPrefix
var inConstructorSuffix = false; // are we in a secondary constructor
// after the this constructor call?
- var reportAmbiguousErrors = false;
- var reportGeneralErrors = false;
- var implicitsEnabled = false;
- var checking = false;
+ var reportAmbiguousErrors = false
+ var reportGeneralErrors = false
+ var implicitsEnabled = false
+ var checking = false
- var savedTypeBounds: List[Pair[Symbol, Type]] = List();
+ var savedTypeBounds: List[Pair[Symbol, Type]] = List()
- def undetparams = _undetparams;
+ def undetparams = _undetparams
def undetparams_=(ps: List[Symbol]) = {
//System.out.println("undetparams = " + ps);//debug
_undetparams = ps
}
def make(unit: CompilationUnit, tree: Tree, owner: Symbol, scope: Scope, imports: List[ImportInfo]): Context = {
- val c = new Context;
- c.unit = unit;
- c.tree = tree;
- c.owner = owner;
- c.scope = scope;
+ val c = new Context
+ c.unit = unit
+ c.tree = tree
+ c.owner = owner
+ c.scope = scope
tree match {
case Template(_, _) | PackageDef(_, _) =>
c.enclClass = c;
- c.prefix = skolemizedThisType(this.tree, this.prefix, c.owner);
- c.inConstructorSuffix = false;
+ c.prefix = skolemizedThisType(this.tree, this.prefix, c.owner)
+ c.inConstructorSuffix = false
case _ =>
- c.enclClass = this.enclClass;
- c.prefix = if (c.owner != this.owner && c.owner.isTerm) NoPrefix else this.prefix;
- c.inConstructorSuffix = this.inConstructorSuffix;
+ c.enclClass = this.enclClass
+ c.prefix = if (c.owner != this.owner && c.owner.isTerm) NoPrefix else this.prefix
+ c.inConstructorSuffix = this.inConstructorSuffix
}
tree match {
case DefDef(_, _, _, _, _, _) =>
@@ -114,100 +115,100 @@ trait Contexts requires Analyzer {
case _ =>
c.enclMethod = this.enclMethod
}
- c.variance = this.variance;
- c.depth = if (scope == this.scope) this.depth else this.depth + 1;
- c.imports = imports;
- c.reportAmbiguousErrors = this.reportAmbiguousErrors;
- c.reportGeneralErrors = this.reportGeneralErrors;
- c.implicitsEnabled = this.implicitsEnabled;
- c.checking = this.checking;
- c.outer = this;
+ c.variance = this.variance
+ c.depth = if (scope == this.scope) this.depth else this.depth + 1
+ c.imports = imports
+ c.reportAmbiguousErrors = this.reportAmbiguousErrors
+ c.reportGeneralErrors = this.reportGeneralErrors
+ c.implicitsEnabled = this.implicitsEnabled
+ c.checking = this.checking
+ c.outer = this
c
}
def make(unit: CompilationUnit): Context = {
- val c = make(unit, EmptyTree, owner, scope, imports);
- c.reportAmbiguousErrors = true;
- c.reportGeneralErrors = true;
- c.implicitsEnabled = true;
+ val c = make(unit, EmptyTree, owner, scope, imports)
+ c.reportAmbiguousErrors = true
+ c.reportGeneralErrors = true
+ c.implicitsEnabled = true
c
}
def makeNewImport(imp: Import): Context =
- make(unit, imp, owner, scope, new ImportInfo(imp, depth) :: imports);
+ make(unit, imp, owner, scope, new ImportInfo(imp, depth) :: imports)
def make(tree: Tree, owner: Symbol, scope: Scope): Context =
- make(unit, tree, owner, scope, imports);
+ make(unit, tree, owner, scope, imports)
def makeNewScope(tree: Tree, owner: Symbol): Context =
- make(tree, owner, new Scope(scope));
+ make(tree, owner, new Scope(scope))
def make(tree: Tree, owner: Symbol): Context =
- make(tree, owner, scope);
+ make(tree, owner, scope)
def make(tree: Tree): Context =
- make(tree, owner);
+ make(tree, owner)
def makeImplicit(reportAmbiguousErrors: boolean) = {
- val c = make(tree);
- c.reportAmbiguousErrors = reportAmbiguousErrors;
- c.reportGeneralErrors = false;
- c.implicitsEnabled = false;
+ val c = make(tree)
+ c.reportAmbiguousErrors = reportAmbiguousErrors
+ c.reportGeneralErrors = false
+ c.implicitsEnabled = false
c
}
def makeConstructorContext = {
- var baseContext = enclClass.outer;
+ var baseContext = enclClass.outer
//todo: find out why we need next line
- while (baseContext.tree.isInstanceOf[Template]) baseContext = baseContext.outer;
- val argContext = baseContext.makeNewScope(tree, owner);
- for (val sym <- scope.toList) argContext.scope enter sym;
+ while (baseContext.tree.isInstanceOf[Template]) baseContext = baseContext.outer
+ val argContext = baseContext.makeNewScope(tree, owner)
+ for (val sym <- scope.toList) argContext.scope enter sym
argContext
}
def makeConstructorSuffixContext = {
- val c = make(tree);
- c.inConstructorSuffix = true;
+ val c = make(tree)
+ c.inConstructorSuffix = true
c
}
def skolemizedThisType(encl: Tree, pre: Type, clazz: Symbol): Type = if (settings.Xgadt.value) {
encl match {
case ClassDef(_, _, tparamdefs, _, _) =>
- System.out.println("sktt " + clazz);
+ System.out.println("sktt " + clazz)
if (!tparamdefs.isEmpty || pre.isInstanceOf[SingleType]) {
- val tparams = clazz.unsafeTypeParams;
- val tskolems = tparamdefs map (.symbol);
- System.out.println("sktt2 " + tparams + " " + tskolems);
- val self = clazz.newThisSkolem setInfo clazz.typeOfThis.substSym(tparams, tskolems);
+ val tparams = clazz.unsafeTypeParams
+ val tskolems = tparamdefs map (.symbol)
+ System.out.println("sktt2 " + tparams + " " + tskolems)
+ val self = clazz.newThisSkolem setInfo clazz.typeOfThis.substSym(tparams, tskolems)
singleType(pre, self)
} else clazz.thisType
case _ =>
clazz.thisType
}
- } else clazz.thisType;
+ } else clazz.thisType
def error(pos: int, msg: String): unit =
if (reportGeneralErrors)
unit.error(pos, if (checking) "**** ERROR DURING INTERNAL CHECKING ****\n" + msg else msg)
else
- throw new TypeError(msg);
+ throw new TypeError(msg)
def ambiguousError(pos: int, pre: Type, sym1: Symbol, sym2: Symbol, rest: String): unit = {
val msg =
("ambiguous reference to overloaded definition,\n" +
"both " + sym1 + sym1.locationString + " of type " + pre.memberType(sym1) +
"\nand " + sym2 + sym2.locationString + " of type " + pre.memberType(sym2) +
- "\nmatch " + rest);
+ "\nmatch " + rest)
if (reportAmbiguousErrors) {
if (!pre.isErroneous && !sym1.isErroneous && !sym2.isErroneous)
unit.error(pos, msg)
- } else throw new TypeError(msg);
+ } else throw new TypeError(msg)
}
def outerContext(clazz: Symbol): Context = {
- var c = this;
- while (c != NoContext && c.owner != clazz) c = c.outer.enclClass;
+ var c = this
+ while (c != NoContext && c.owner != clazz) c = c.outer.enclClass
c
}
@@ -219,10 +220,10 @@ trait Contexts requires Analyzer {
}
def nextEnclosing(p: Context => boolean): Context =
- if (this == NoContext || p(this)) this else outer.nextEnclosing(p);
+ if (this == NoContext || p(this)) this else outer.nextEnclosing(p)
override def toString(): String = {
- if (this == NoContext) "NoContext";
+ if (this == NoContext) "NoContext"
else owner.toString() + " @ " + tree.getClass() + " " + tree.toString() + ", scope = " + scope.hashCode() + " " + scope.toList + "\n:: " + outer.toString()
}
@@ -232,20 +233,20 @@ trait Contexts requires Analyzer {
/** Are we inside definition of `owner'? */
def accessWithin(owner: Symbol): boolean = {
- var c = this;
+ var c = this
while (c != NoContext && c.owner != owner) {
if (c.outer == null) assert(false, "accessWithin(" + owner + ") " + c);//debug
if (c.outer.enclClass == null) assert(false, "accessWithin(" + owner + ") " + c);//debug
- c = c.outer.enclClass;
+ c = c.outer.enclClass
}
c != NoContext
}
/** Is `clazz' a subclass of an enclosing class? */
def isSubClassOfEnclosing(clazz: Symbol): boolean = {
- var c = this.enclClass;
- while (c != NoContext && !clazz.isSubClass(c.owner)) c = c.outer.enclClass;
- c != NoContext;
+ var c = this.enclClass
+ while (c != NoContext && !clazz.isSubClass(c.owner)) c = c.outer.enclClass
+ c != NoContext
}
( pre == NoPrefix
@@ -271,28 +272,28 @@ trait Contexts requires Analyzer {
def restoreTypeBounds: unit = {
for (val Pair(sym, info) <- savedTypeBounds) {
if (settings.debug.value) log("resetting " + sym + " to " + info);
- sym.setInfo(info);
+ sym.setInfo(info)
}
savedTypeBounds = List()
}
- private var implicitsCache: List[List[ImplicitInfo]] = null;
- private var implicitsRun: CompilerRun = NoRun;
+ private var implicitsCache: List[List[ImplicitInfo]] = null
+ private var implicitsRunId: RunId = NoRunId
private def collectImplicits(syms: List[Symbol], pre: Type): List[ImplicitInfo] =
for (val sym <- syms; sym.hasFlag(IMPLICIT) && isAccessible(sym, pre, false))
- yield new ImplicitInfo(sym.name, pre, sym);
+ yield new ImplicitInfo(sym.name, pre, sym)
private def collectImplicitImports(imp: ImportInfo): List[ImplicitInfo] = {
- val pre = imp.qual.tpe;
+ val pre = imp.qual.tpe
def collect(sels: List[Pair[Name, Name]]): List[ImplicitInfo] = sels match {
case List() => List()
case List(Pair(nme.WILDCARD, _)) => collectImplicits(pre.implicitMembers, pre)
case Pair(from, to) :: sels1 =>
- var impls = collect(sels1) filter (info => info.name != from);
+ var impls = collect(sels1) filter (info => info.name != from)
if (to != nme.WILDCARD) {
- val sym = imp.importedSymbol(to);
- if (sym.hasFlag(IMPLICIT)) impls = new ImplicitInfo(to, pre, sym) :: impls;
+ val sym = imp.importedSymbol(to)
+ if (sym.hasFlag(IMPLICIT)) impls = new ImplicitInfo(to, pre, sym) :: impls
}
impls
}
@@ -301,22 +302,22 @@ trait Contexts requires Analyzer {
}
def implicitss: List[List[ImplicitInfo]] = {
- if (implicitsRun != currentRun) {
- implicitsRun = currentRun;
+ if (implicitsRunId != currentRunId) {
+ implicitsRunId = currentRunId
val newImplicits: List[ImplicitInfo] =
if (owner != outer.owner && owner.isClass && !owner.isPackageClass) {
- if (!owner.isInitialized) return outer.implicitss;
+ if (!owner.isInitialized) return outer.implicitss
if (settings.debug.value) log("collect member implicits " + owner + ", implicit members = " + owner.thisType.implicitMembers);//debug
collectImplicits(owner.thisType.implicitMembers, owner.thisType)
} else if (scope != outer.scope && !owner.isPackageClass) {
if (settings.debug.value) log("collect local implicits " + scope.toList);//debug
collectImplicits(scope.toList, NoPrefix)
} else if (imports != outer.imports) {
- assert(imports.tail == outer.imports);
+ assert(imports.tail == outer.imports)
collectImplicitImports(imports.head)
- } else List();
+ } else List()
implicitsCache = if (newImplicits.isEmpty) outer.implicitss
- else newImplicits :: outer.implicitss;
+ else newImplicits :: outer.implicitss
}
implicitsCache
}
@@ -332,32 +333,32 @@ trait Contexts requires Analyzer {
/** Is name imported explicitly, not via wildcard? */
def isExplicitImport(name: Name): boolean =
- tree.selectors exists (._2.==(name.toTermName));
+ tree.selectors exists (._2.==(name.toTermName))
/** The symbol with name `name' imported from import clause `tree'.
*/
def importedSymbol(name: Name): Symbol = {
- var result: Symbol = NoSymbol;
- var renamed = false;
- var selectors = tree.selectors;
+ var result: Symbol = NoSymbol
+ var renamed = false
+ var selectors = tree.selectors
while (selectors != Nil && result == NoSymbol) {
if (selectors.head._2 == name.toTermName)
result = qual.tpe.member(
- if (name.isTypeName) selectors.head._1.toTypeName else selectors.head._1);
+ if (name.isTypeName) selectors.head._1.toTypeName else selectors.head._1)
else if (selectors.head._1 == name.toTermName)
renamed = true
else if (selectors.head._1 == nme.WILDCARD && !renamed)
- result = qual.tpe.member(name);
+ result = qual.tpe.member(name)
selectors = selectors.tail
}
result
}
- override def toString() = tree.toString();
+ override def toString() = tree.toString()
}
class ImplicitInfo(val name: Name, pre: Type, val sym: Symbol) {
- private var tpeCache: Type = null;
+ private var tpeCache: Type = null
def tpe: Type = {
if (tpeCache == null) tpeCache = pre.memberType(sym)
tpeCache
@@ -366,5 +367,5 @@ trait Contexts requires Analyzer {
val NoImplicitInfo = new ImplicitInfo(null, null, null)
- case class ImportType(expr: Tree) extends Type;
+ case class ImportType(expr: Tree) extends Type
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
index 8ce72b46ce..f09d971042 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
@@ -58,7 +58,7 @@ trait Namers requires Analyzer {
updatePosFlags(sym.moduleClass, pos, (flags & ModuleToClassFlags) | MODULE | FINAL);
if (sym.owner.isPackageClass &&
(sym.linkedSym.rawInfo.isInstanceOf[loaders.SymbolLoader] ||
- sym.linkedSym.rawInfo.isComplete && sym.validForRun != currentRun))
+ sym.linkedSym.rawInfo.isComplete && sym.validForRunId != currentRunId))
// pre-set linked symbol to NoType, in case it is not loaded together with this symbol.
sym.linkedSym.setInfo(NoType);
sym
diff --git a/src/compiler/scala/tools/nsc/util/ShowPickled.scala b/src/compiler/scala/tools/nsc/util/ShowPickled.scala
index c96a089217..63130e70a5 100644
--- a/src/compiler/scala/tools/nsc/util/ShowPickled.scala
+++ b/src/compiler/scala/tools/nsc/util/ShowPickled.scala
@@ -143,7 +143,7 @@ object ShowPickled extends Names {
out.println("BAD ENTRY END: , computed = " + end + ", factual = " + buf.readIndex);
}
- for (val i <- Iterator.range(0, index.length))
+ for (val i <- 0 until index.length)
printEntry(i);
}