diff options
author | michelou <michelou@epfl.ch> | 2007-07-12 17:05:58 +0000 |
---|---|---|
committer | michelou <michelou@epfl.ch> | 2007-07-12 17:05:58 +0000 |
commit | 4428dd2a4ea288b881ec342f1155419a227340a5 (patch) | |
tree | 53ce227ecb2ad4f9286f83944dd450ac361949d3 /src | |
parent | edacf9f4340f6eefe48852cbb2c9535d38275ac2 (diff) | |
download | scala-4428dd2a4ea288b881ec342f1155419a227340a5.tar.gz scala-4428dd2a4ea288b881ec342f1155419a227340a5.tar.bz2 scala-4428dd2a4ea288b881ec342f1155419a227340a5.zip |
removed type aliases, old for-syntax, ..
Diffstat (limited to 'src')
14 files changed, 187 insertions, 166 deletions
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index a7692147b7..93ad566984 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -205,7 +205,7 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable if (settings.verbose.value) { inform("[Classpath = " + classPath + "]") - inform("[AssemRefs = " + settings.assemrefs.value + "]") + if (forMSIL) inform("[AssemRefs = " + settings.assemrefs.value + "]") } def getSourceFile(f: AbstractFile): SourceFile = @@ -266,7 +266,7 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable class TerminalPhase(prev: Phase) extends GlobalPhase(prev) { def name = "terminal" - def apply(unit: CompilationUnit): Unit = () + def apply(unit: CompilationUnit) {} } object syntaxAnalyzer extends SyntaxAnalyzer { @@ -471,7 +471,7 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable def cancel { reporter.cancelled = true } // progress tracking - def progress(current: Int, total: Int): Unit = () + def progress(current: Int, total: Int) {} private var phasec: Int = 0 private var unitc: Int = 0 diff --git a/src/compiler/scala/tools/nsc/ast/NodePrinters.scala b/src/compiler/scala/tools/nsc/ast/NodePrinters.scala index 392ef54c11..6cbb39dc83 100644 --- a/src/compiler/scala/tools/nsc/ast/NodePrinters.scala +++ b/src/compiler/scala/tools/nsc/ast/NodePrinters.scala @@ -2,7 +2,7 @@ * Copyright 2005-2007 LAMP/EPFL * @author Martin Odersky */ -// $Id: $ +// $Id$ package scala.tools.nsc.ast @@ -188,6 +188,20 @@ abstract class NodePrinters { traverse(tparams(i), level + 2, i < n-1) println(" ),") } + if (vparamss.isEmpty) + println(" List(List()), // no parameter") + else { + val n = vparamss.length + println(" List(") + for (i <- 0 until n) { + val m = vparamss(i).length + println(" List( // " + m + " parameter(s)") + for (j <- 0 until m) + traverse(vparamss(i)(j), level + 3, j < m-1) + println(" )") + } + println(" ),") + } println(tpt+",") traverse(rhs, level + 1, false) printcln(")") diff --git a/src/compiler/scala/tools/nsc/ast/TreePrinters.scala b/src/compiler/scala/tools/nsc/ast/TreePrinters.scala index 52ca3156d9..45d26589c2 100644 --- a/src/compiler/scala/tools/nsc/ast/TreePrinters.scala +++ b/src/compiler/scala/tools/nsc/ast/TreePrinters.scala @@ -2,7 +2,7 @@ * Copyright 2005-2007 LAMP/EPFL * @author Martin Odersky */ -// $Id: TreePrinters.scala 9925 2007-02-07 18:30:46 +0000 (Wed, 07 Feb 2007) odersky $ +// $Id$ package scala.tools.nsc.ast @@ -105,8 +105,8 @@ abstract class TreePrinters { printFlags(tree.symbol.flags, tree.symbol.privateWithin.name.toString) } - def printFlags(flags: long, privateWithin: String) { - var mask: long = if (settings.debug.value) -1L else PrintableFlags + def printFlags(flags: Long, privateWithin: String) { + var mask: Long = if (settings.debug.value) -1L else PrintableFlags val s = flagsToString(flags & mask, privateWithin.toString) if (s.length() != 0) print(s + " ") } diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala index 6081bc568d..252e4d6ec1 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala @@ -88,7 +88,7 @@ trait Scanners { trait ScannerConfiguration { // Keywords ----------------------------------------------------------------- /** Keyword array; maps from name indices to tokens */ - private var key: Array[byte] = _ + private var key: Array[Byte] = _ private var maxKey = 0 private var tokenName = new Array[Name](128) @@ -97,7 +97,7 @@ trait Scanners { // Enter keywords - def enterKeyword(n: Name, tokenId: int) { + def enterKeyword(n: Name, tokenId: Int) { while (tokenId >= tokenName.length) { val newTokName = new Array[Name](tokenName.length * 2) Array.copy(tokenName, 0, newTokName, 0, newTokName.length) @@ -161,22 +161,22 @@ trait Scanners { enterKeyword(nme.ATkw, AT) // Build keyword array - key = new Array[byte](maxKey + 1) + key = new Array[Byte](maxKey + 1) for (i <- 0 to maxKey) key(i) = IDENTIFIER for (j <- 0 until tokenCount) if (tokenName(j) ne null) - key(tokenName(j).start) = j.asInstanceOf[byte] + key(tokenName(j).start) = j.asInstanceOf[Byte] } //Token representation ----------------------------------------------------- /** Convert name to token */ - def name2token(name: Name): int = + def name2token(name: Name): Int = if (name.start <= maxKey) key(name.start) else IDENTIFIER /** Returns the string representation of given token. */ - def token2string(token: int): String = token match { + def token2string(token: Int): String = token match { case IDENTIFIER | BACKQUOTED_IDENT => "identifier"/* + \""+name+"\""*/ case CHARLIT => @@ -242,7 +242,6 @@ trait Scanners { * @version 1.1 */ abstract class Scanner extends AbstractScanner with TokenData { - import java.lang.{Integer, Long, Float, Double, Character} // MAX_VALUE, valueOf override def intVal = super.intVal override def floatVal = super.floatVal override var errpos: Int = NoPos @@ -255,7 +254,7 @@ trait Scanners { /** append Unicode character to "lit" buffer */ - protected def putChar(c: char): unit = cbuf.append(c) + protected def putChar(c: Char) { cbuf.append(c) } /** Clear buffer and set name */ private def setName { @@ -273,15 +272,14 @@ trait Scanners { ret } - /** Process comments and strings in scanner */ protected def matchInScanner = true - /** add the given character to the documentation buffer */ - protected def putDocChar(c: char): unit = + protected def putDocChar(c: Char) { if (docBuffer ne null) docBuffer.append(c) + } private class TokenData0 extends TokenData @@ -290,10 +288,9 @@ trait Scanners { val next : TokenData = new TokenData0 val prev : TokenData = new TokenData0 - /** a stack which indicates whether line-ends can be statement separators */ - var sepRegions: List[int] = List() + var sepRegions: List[Int] = List() /** A new line was inserted where in version 1.0 it would not be. * Only significant if settings.migrate.value is set @@ -393,7 +390,7 @@ trait Scanners { /** read next token */ - private def fetchToken(): unit = { + private def fetchToken() { if (token == EOF) return lastPos = in.cpos - 1 // Position.encode(in.cline, in.ccol) //var index = bp @@ -634,7 +631,7 @@ trait Scanners { } } - private def skipComment(): boolean = { + private def skipComment(): Boolean = { assert(matchInScanner) if (in.ch == '/') { do { @@ -676,17 +673,17 @@ trait Scanners { } } - def inFirstOfStat(token: int) = token match { - case EOF | CASE | CATCH | ELSE | EXTENDS | FINALLY | FORSOME | MATCH | REQUIRES | WITH | YIELD | - COMMA | SEMI | NEWLINE | NEWLINES | DOT | USCORE | COLON | EQUALS | ARROW | - LARROW | SUBTYPE | VIEWBOUND | SUPERTYPE | HASH | // todo: add LBRACKET - RPAREN | RBRACKET | RBRACE => + def inFirstOfStat(token: Int) = token match { + case EOF | CASE | CATCH | ELSE | EXTENDS | FINALLY | FORSOME | MATCH | + REQUIRES | WITH | YIELD | COMMA | SEMI | NEWLINE | NEWLINES | DOT | + USCORE | COLON | EQUALS | ARROW | LARROW | SUBTYPE | VIEWBOUND | + SUPERTYPE | HASH | RPAREN | RBRACKET | RBRACE => // todo: add LBRACKET false case _ => true } - def inLastOfStat(token: int) = token match { + def inLastOfStat(token: Int) = token match { case CHARLIT | INTLIT | LONGLIT | FLOATLIT | DOUBLELIT | STRINGLIT | SYMBOLLIT | IDENTIFIER | BACKQUOTED_IDENT | THIS | NULL | TRUE | FALSE | RETURN | USCORE | TYPE | XMLSTART | RPAREN | RBRACKET | RBRACE => @@ -697,25 +694,25 @@ trait Scanners { // Identifiers --------------------------------------------------------------- - def isIdentStart(c: char): boolean = ( + def isIdentStart(c: Char): Boolean = ( ('A' <= c && c <= 'Z') || ('a' <= c && c <= 'a') || (c == '_') || (c == '$') || Character.isUnicodeIdentifierStart(c) ) - def isIdentPart(c: char) = ( + def isIdentPart(c: Char) = ( isIdentStart(c) || ('0' <= c && c <= '9') || Character.isUnicodeIdentifierPart(c) ) - def isSpecial(c: char) = { + def isSpecial(c: Char) = { val chtp = Character.getType(c) chtp == Character.MATH_SYMBOL || chtp == Character.OTHER_SYMBOL } - private def getIdentRest: unit = + private def getIdentRest { while (true) { in.ch match { case 'A' | 'B' | 'C' | 'D' | 'E' | @@ -754,8 +751,9 @@ trait Scanners { } } } + } - private def getOperatorRest: unit = + private def getOperatorRest { while (true) { in.ch match { case '~' | '!' | '@' | '#' | '%' | @@ -787,8 +785,9 @@ trait Scanners { } } } + } - private def getIdentOrOperatorRest: unit = + private def getIdentOrOperatorRest { if (isIdentPart(in.ch)) getIdentRest else in.ch match { @@ -804,8 +803,9 @@ trait Scanners { token = configuration.name2token(name) } } + } - private def getStringLit(delimiter: char, litType: int): Unit = { + private def getStringLit(delimiter: Char, litType: Int) { assert(matchInScanner) //assert((litType==STRINGLIT) || (litType==IDENTIFIER)) while (in.ch != delimiter && (in.isUnicode || in.ch != CR && in.ch != LF && in.ch != SU)) { @@ -821,7 +821,7 @@ trait Scanners { } } - private def getMultiLineStringLit: Unit = { + private def getMultiLineStringLit { assert(matchInScanner) if (in.ch == '\"') { in.next @@ -857,8 +857,8 @@ trait Scanners { if (in.ch == '\\') { in.next if ('0' <= in.ch && in.ch <= '7') { - val leadch: char = in.ch - var oct: int = in.digit2int(in.ch, 8) + val leadch: Char = in.ch + var oct: Int = in.digit2int(in.ch, 8) in.next if ('0' <= in.ch && in.ch <= '7') { oct = oct * 8 + in.digit2int(in.ch, 8) @@ -868,7 +868,7 @@ trait Scanners { in.next } } - putChar(oct.asInstanceOf[char]) + putChar(oct.asInstanceOf[Char]) } else { in.ch match { case 'b' => putChar('\b') @@ -893,7 +893,7 @@ trait Scanners { /** read fractional part and exponent of floating point number * if one is present. */ - protected def getFraction = { + protected def getFraction { token = DOUBLELIT while ('0' <= in.ch && in.ch <= '9') { putChar(in.ch) @@ -933,14 +933,14 @@ trait Scanners { /** convert name to long value */ - def intVal(negated: boolean): long = { + def intVal(negated: Boolean): Long = { if (token == CHARLIT && !negated) { if (name.length > 0) name(0) else 0 } else { - var value: long = 0 + var value: Long = 0 val divider = if (base == 10) 1 else 2 - val limit: long = - if (token == LONGLIT) Long.MAX_VALUE else Integer.MAX_VALUE + val limit: Long = + if (token == LONGLIT) Math.MAX_LONG else Math.MAX_INT var i = 0 val len = name.length while (i < len) { @@ -966,11 +966,11 @@ trait Scanners { /** convert name, base to double value */ - def floatVal(negated: boolean): double = { - val limit: double = - if (token == DOUBLELIT) Double.MAX_VALUE else Float.MAX_VALUE + def floatVal(negated: Boolean): Double = { + val limit: Double = + if (token == DOUBLELIT) Math.MAX_DOUBLE else Math.MAX_FLOAT try { - val value: double = Double.valueOf(name.toString()).doubleValue() + val value: Double = java.lang.Double.valueOf(name.toString()).doubleValue() if (value > limit) syntaxError("floating point number too large") if (negated) -value else value @@ -1029,7 +1029,7 @@ trait Scanners { /** generate an error at the given position */ - def syntaxError(pos: int, msg: String): unit = { + def syntaxError(pos: Int, msg: String) { error(pos, msg) token = ERROR errpos = pos @@ -1037,10 +1037,10 @@ trait Scanners { /** generate an error at the current token position */ - def syntaxError(msg: String): unit = syntaxError(pos, msg) + def syntaxError(msg: String) { syntaxError(pos, msg) } /** signal an error where the input ended in the middle of a token */ - def incompleteInputError(msg: String): unit = { + def incompleteInputError(msg: String) { incompleteInputError(pos, msg) token = EOF errpos = pos @@ -1075,7 +1075,7 @@ trait Scanners { /** INIT: read lookahead character and token. */ - def init = { + def init { in.next nextToken } diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala index 6569ec29af..4ab2883126 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala @@ -10,10 +10,11 @@ package scala.tools.nsc.backend.icode.analysis import scala.collection.mutable.{Map, HashMap} import scala.tools.nsc.symtab.Flags.DEFERRED -/** - * A modified copy-propagation like analysis. It +/** A modified copy-propagation like analysis. It * is augmented with a record-like value which is used * to represent closures. + * + * @author Iulian Dragos */ abstract class CopyPropagation { val global: Global @@ -33,8 +34,8 @@ abstract class CopyPropagation { case class Record(cls: Symbol, bindings: Map[Symbol, Value]) extends Value { override def isRecord = true } - case class Deref(l: Location) extends Value; - case class Boxed(l: Location) extends Value; + case class Deref(l: Location) extends Value + case class Boxed(l: Location) extends Value case object Unknown extends Value object AllRecords extends Record(NoSymbol, new HashMap[Symbol, Value]) @@ -159,7 +160,7 @@ abstract class CopyPropagation { */ val commonPairs = a.bindings.toList intersect (b.bindings.toList) val resBindings = new HashMap[Location, Value] - for (val Pair(k, v) <- commonPairs) + for ((k, v) <- commonPairs) resBindings += k -> v; new State(resBindings, resStack) } @@ -172,7 +173,7 @@ abstract class CopyPropagation { var method: IMethod = _ - def init(m: IMethod): Unit = { + def init(m: IMethod) { this.method = m init { @@ -193,7 +194,7 @@ abstract class CopyPropagation { } } - override def run: Unit = { + override def run { forwardAnalysis(blockTransfer) if (settings.debug.value) { linearizer.linearize(method).foreach(b => if (b != method.code.startBlock) @@ -293,8 +294,8 @@ abstract class CopyPropagation { if (method.isPrimaryConstructor/* && isClosureClass(method.owner)*/) { obj match { case Record(_, bindings) => - for (val v <- out.stack.take(method.info.paramTypes.length + 1); - v ne obj) { + for (v <- out.stack.take(method.info.paramTypes.length + 1) + if v ne obj) { bindings ++= getBindingsForPrimaryCtor(in, method); } case _ => () @@ -397,7 +398,7 @@ abstract class CopyPropagation { * and bindings. It is called when a new assignment destroys * previous copy-relations. */ - final def cleanReferencesTo(s: copyLattice.State, target: Location): Unit = { + final def cleanReferencesTo(s: copyLattice.State, target: Location) { def cleanRecord(r: Record): Record = { r.bindings retain { (loc, value) => value match { @@ -455,7 +456,7 @@ abstract class CopyPropagation { * * @param state ... */ - final def invalidateRecords(state: copyLattice.State): Unit = { + final def invalidateRecords(state: copyLattice.State) { state.stack = state.stack map { v => v match { case Record(cls, bindings) => Record(cls, new HashMap[Symbol, Value]) @@ -482,7 +483,7 @@ abstract class CopyPropagation { // this relies on having the same order in paramAccessors and // the arguments on the stack. It should be the same! - for (val (p, i) <- paramAccessors.zipWithIndex) { + for ((p, i) <- paramAccessors.zipWithIndex) { // assert(p.tpe == ctor.tpe.paramTypes(i), "In: " + ctor.fullNameString + " having: " + (paramAccessors map (_.tpe))+ " vs. " + ctor.tpe.paramTypes) if (p.tpe == ctor.tpe.paramTypes(i)) bindings += p -> values.head; @@ -514,7 +515,7 @@ abstract class CopyPropagation { final override def toString(): String = { var res = "" - for (val b <- this.method.code.blocks.toList) + for (b <- this.method.code.blocks.toList) res = (res + "\nIN(" + b.label + "):\t Bindings: " + in(b).bindings + "\nIN(" + b.label +"):\t Stack: " + in(b).stack) + "\n"; res diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala index 01167c2986..4a69746c71 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala @@ -9,7 +9,7 @@ package scala.tools.nsc.backend.icode.analysis import scala.collection.mutable.{Map, HashMap} -/** A data-flow analysis on types, that works on ICode. +/** A data-flow analysis on types, that works on <code>ICode</code>. * * @author Iulian Dragos */ @@ -61,8 +61,8 @@ abstract class TypeFlowAnalysis { /** A map which returns the bottom type for unfound elements */ class VarBinding extends HashMap[icodes.Local, icodes.TypeKind] { override def get(l: icodes.Local) = super.get(l) match { - case Some(t) => Some(t); - case None => Some(typeLattice.bottom); + case Some(t) => Some(t) + case None => Some(typeLattice.bottom) } def this(o: VarBinding) = { @@ -76,7 +76,7 @@ abstract class TypeFlowAnalysis { */ object typeFlowLattice extends CompleteLattice { import icodes._ - type Elem = Pair[VarBinding, icodes.TypeStack] + type Elem = (VarBinding, icodes.TypeStack) override val top = new Pair(new VarBinding, typeStackLattice.top) { override def equals(that: Any) = (this eq that.asInstanceOf[AnyRef]) @@ -86,22 +86,22 @@ abstract class TypeFlowAnalysis { } def lub2(a: Elem, b: Elem) = { - val Pair(env1, s1) = a - val Pair(env2, s2) = b + val (env1, s1) = a + val (env2, s2) = b val resultingLocals = new VarBinding - for (val binding1 <- env1.elements) { + for (binding1 <- env1.elements) { val tp2 = env2(binding1._1) resultingLocals += binding1._1 -> typeLattice.lub2(binding1._2, tp2) } - for (val binding2 <- env2.elements; resultingLocals(binding2._1) eq typeLattice.bottom) { + for (binding2 <- env2.elements if resultingLocals(binding2._1) eq typeLattice.bottom) { val tp1 = env1(binding2._1) resultingLocals += binding2._1 -> typeLattice.lub2(binding2._2, tp1) } - Pair(resultingLocals, typeStackLattice.lub2(a._2, b._2)) + (resultingLocals, typeStackLattice.lub2(a._2, b._2)) } } @@ -116,7 +116,7 @@ abstract class TypeFlowAnalysis { var method: IMethod = _ /** Initialize the in/out maps for the analysis of the given method. */ - def init(m: icodes.IMethod): Unit = { + def init(m: icodes.IMethod) { this.method = m init { @@ -132,7 +132,7 @@ abstract class TypeFlowAnalysis { } } - def this(m: icodes.IMethod) = { + def this(m: icodes.IMethod) { this() init(m) } diff --git a/src/compiler/scala/tools/nsc/models/Signatures.scala b/src/compiler/scala/tools/nsc/models/Signatures.scala index 284a7c2db5..c23c0e7241 100644 --- a/src/compiler/scala/tools/nsc/models/Signatures.scala +++ b/src/compiler/scala/tools/nsc/models/Signatures.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2006 LAMP/EPFL + * Copyright 2005-2007 LAMP/EPFL * @author Martin Odersky */ // $Id$ @@ -28,7 +28,7 @@ class Signatures(val compiler: Compiler) { def asString0(sigs: List[Signature]): String = { var ret = "" - for (val sig <- sort(sigs)) ret = ret + sig.asString + for (sig <- sort(sigs)) ret = ret + sig.asString ret } @@ -37,7 +37,7 @@ class Signatures(val compiler: Compiler) { def signature(trees: List[Tree]): List[Signature] = { var ret : List[Signature] = Nil - for (val tree <- trees) ret = signature(tree, ret) + for (tree <- trees) ret = signature(tree, ret) ret } @@ -70,7 +70,7 @@ class Signatures(val compiler: Compiler) { case ddef : DefDef => val tparams = new Signature("$$tparams", signature(ddef.tparams)) var vparamss : List[Signature] = Nil - for (val list <- ddef.vparamss) + for (list <- ddef.vparamss) vparamss = signature(list) ::: vparamss new Signature("$$ret", ret) :: tparams :: vparamss case _ => diff --git a/src/compiler/scala/tools/nsc/symtab/Names.scala b/src/compiler/scala/tools/nsc/symtab/Names.scala index 16d6a0f886..63754e56df 100644 --- a/src/compiler/scala/tools/nsc/symtab/Names.scala +++ b/src/compiler/scala/tools/nsc/symtab/Names.scala @@ -59,13 +59,13 @@ class Names { private def equals(index: Int, cs: Array[Char], offset: Int, len: Int): Boolean = { var i = 0 while ((i < len) && (chrs(index + i) == cs(offset + i))) - i = i + 1; + i += 1; i == len } /** enter characters into chrs array */ - private def enterChars(cs: Array[Char], offset: Int, len: Int): unit = { + private def enterChars(cs: Array[Char], offset: Int, len: Int) { var i = 0 while (i < len) { if (nc + i == chrs.length) { @@ -182,7 +182,7 @@ class Names { /** return the ascii representation of this name */ - final def toChars = { + final def toChars: Array[Char] = { val cs = new Array[Char](len) copyChars(cs, 0) cs diff --git a/src/compiler/scala/tools/nsc/symtab/Scopes.scala b/src/compiler/scala/tools/nsc/symtab/Scopes.scala index 791ae7e9d4..581bf102a5 100644 --- a/src/compiler/scala/tools/nsc/symtab/Scopes.scala +++ b/src/compiler/scala/tools/nsc/symtab/Scopes.scala @@ -157,7 +157,7 @@ trait Scopes { enter(sym) } - private def createHash(): unit = { + private def createHash() { hashtable = new Array[ScopeEntry](HASHSIZE) enterInHash(elems) } @@ -171,7 +171,7 @@ trait Scopes { } } - def rehash(sym: Symbol, newname: Name): unit = + def rehash(sym: Symbol, newname: Name) { if (hashtable ne null) { val index = sym.name.start & HASHMASK var e1 = hashtable(index) @@ -194,6 +194,7 @@ trait Scopes { hashtable(newindex) = e } } + } /** remove entry * @@ -304,8 +305,9 @@ trait Scopes { /** The empty scope (immutable). */ object EmptyScope extends Scope { - override def enter(e: ScopeEntry): unit = + override def enter(e: ScopeEntry) { throw new Error("EmptyScope.enter") + } } /** The error scope. diff --git a/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala b/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala index a82e398814..5f83206c36 100644 --- a/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala @@ -4,42 +4,45 @@ // $Id$ -package scala.tools.nsc.symtab.clr; +package scala.tools.nsc.symtab.clr -import scala.tools.nsc.util.{Position,NoPosition}; -import classfile.UnPickler; -import ch.epfl.lamp.compiler.msil.{Type => MSILType, Attribute => MSILAttribute, _}; +import java.io.IOException -import scala.collection.mutable.{HashMap, HashSet}; -import java.io.IOException; +import ch.epfl.lamp.compiler.msil.{Type => MSILType, Attribute => MSILAttribute, _} +import scala.collection.mutable.{HashMap, HashSet} +import scala.tools.nsc.util.{Position, NoPosition} +import classfile.UnPickler + +/** + * @author Nikolay Mihaylov + */ abstract class TypeParser { - val global: Global; + val global: Global - import global._; - import loaders.clrTypes; + import global._ + import loaders.clrTypes //########################################################################## - private var clazz: Symbol = _; - private var instanceDefs: Scope = _; // was members - private var staticModule: Symbol = _; // was staticsClass - private var staticDefs: Scope = _; // was statics + private var clazz: Symbol = _ + private var instanceDefs: Scope = _ // was members + private var staticModule: Symbol = _ // was staticsClass + private var staticDefs: Scope = _ // was statics protected def statics: Symbol = staticModule.moduleClass - protected var busy: boolean = false // lock to detect recursive reads + protected var busy: Boolean = false // lock to detect recursive reads private object unpickler extends UnPickler { val global: TypeParser.this.global.type = TypeParser.this.global } - - def parse(typ: MSILType, root: Symbol): Unit = { + def parse(typ: MSILType, root: Symbol) { def handleError(e: Exception) = { - if (settings.debug.value) e.printStackTrace(); //debug + if (settings.debug.value) e.printStackTrace() //debug throw new IOException("type '" + typ.FullName + "' is broken\n(" + e.getMessage() + ")") } assert(!busy) @@ -61,10 +64,10 @@ abstract class TypeParser { busy = false } - private def parseClass(typ: MSILType): Unit = { + private def parseClass(typ: MSILType) { - clrTypes.types(clazz) = typ; - clrTypes.sym2type(typ) = clazz; + clrTypes.types(clazz) = typ + clrTypes.sym2type(typ) = clazz if (typ.IsDefined(clrTypes.SCALA_SYMTAB_ATTR, false)) { val attrs = typ.GetCustomAttributes(clrTypes.SCALA_SYMTAB_ATTR, false); @@ -80,32 +83,32 @@ abstract class TypeParser { assert (moduleInstance != null, mClass); clrTypes.fields(statics) = moduleInstance; } - return; + return } - val flags = translateAttributes(typ); - val ifaces: Array[MSILType] = typ.getInterfaces(); + val flags = translateAttributes(typ) + val ifaces: Array[MSILType] = typ.getInterfaces() val superType = if (typ.BaseType() != null) getCLRType(typ.BaseType()) else if (typ.IsInterface()) definitions.ObjectClass.tpe else definitions.AnyClass.tpe; // this is System.Object - val parents = superType :: ifaces.map(getCLRType).toList; - instanceDefs = newScope; - staticDefs = newScope; + val parents = superType :: ifaces.map(getCLRType).toList + instanceDefs = newScope + staticDefs = newScope - val classInfo = ClassInfoType(parents, instanceDefs, clazz); - val staticInfo = ClassInfoType(List(), staticDefs, statics); + val classInfo = ClassInfoType(parents, instanceDefs, clazz) + val staticInfo = ClassInfoType(List(), staticDefs, statics) - clazz.setFlag(flags); - clazz.setInfo(classInfo); - statics.setFlag(Flags.JAVA); - statics.setInfo(staticInfo); - staticModule.setFlag(Flags.JAVA); - staticModule.setInfo(statics.tpe); + clazz.setFlag(flags) + clazz.setInfo(classInfo) + statics.setFlag(Flags.JAVA) + statics.setInfo(staticInfo) + staticModule.setFlag(Flags.JAVA) + staticModule.setInfo(statics.tpe) // import nested types - for (val ntype <- typ.getNestedTypes(); (!(ntype.IsNestedPrivate - || ntype.IsNestedAssembly - || ntype.IsNestedFamANDAssem) - || ntype.IsInterface) ) + for (ntype <- typ.getNestedTypes() if !(ntype.IsNestedPrivate + || ntype.IsNestedAssembly + || ntype.IsNestedFamANDAssem) + || ntype.IsInterface) { val loader = new loaders.MSILTypeLoader(ntype) val nclazz = statics.newClass(NoPosition, ntype.Name.toTypeName) @@ -115,12 +118,12 @@ abstract class TypeParser { staticDefs.enter(nclazz) staticDefs.enter(nmodule) - assert(nclazz.linkedModuleOfClass == nmodule, nmodule); - assert(nmodule.linkedClassOfModule == nclazz, nclazz); + assert(nclazz.linkedModuleOfClass == nmodule, nmodule) + assert(nmodule.linkedClassOfModule == nclazz, nclazz) } - val fields = typ.getFields(); - for (val field <- fields; !(field.IsPrivate() || field.IsAssembly() || field.IsFamilyAndAssembly)) { + val fields = typ.getFields() + for (field <- fields if !(field.IsPrivate() || field.IsAssembly() || field.IsFamilyAndAssembly)) { val flags = translateAttributes(field); val name = newTermName(field.Name); val fieldType = @@ -134,7 +137,7 @@ abstract class TypeParser { clrTypes.fields(sym) = field; } - for (val constr <- typ.getConstructors(); !constr.IsStatic() && !constr.IsPrivate() && + for (constr <- typ.getConstructors() if !constr.IsStatic() && !constr.IsPrivate() && !constr.IsAssembly() && !constr.IsFamilyAndAssembly()) createMethod(constr); @@ -142,7 +145,7 @@ abstract class TypeParser { val methodsSet = new HashSet[MethodInfo](); methodsSet ++= typ.getMethods(); - for (val prop <- typ.getProperties) { + for (prop <- typ.getProperties) { val propType: Type = getCLSType(prop.PropertyType); if (propType != null) { val getter: MethodInfo = prop.GetGetMethod(true); @@ -189,7 +192,7 @@ abstract class TypeParser { } } -/* for (val event <- typ.GetEvents) { +/* for (event <- typ.GetEvents) { // adding += and -= methods to add delegates to an event. // raising the event ist not possible from outside the class (this is so // generally in .net world) @@ -219,15 +222,14 @@ abstract class TypeParser { } } */ - for (val method <- methodsSet.elements) + for (method <- methodsSet.elements) if (!method.IsPrivate() && !method.IsAssembly() && !method.IsFamilyAndAssembly()) createMethod(method); - // Create methods and views for delegate support if (clrTypes.isDelegateType(typ)) { - createDelegateView(typ); - createDelegateChainers(typ); + createDelegateView(typ) + createDelegateChainers(typ) } // create the box/unbox methods for value types @@ -249,15 +251,15 @@ abstract class TypeParser { val ENUM_CMP_NAMES = List(nme.EQ, nme.NE, nme.LT, nme.LE, nme.GT, nme.GE); val ENUM_BIT_LOG_NAMES = List(nme.OR, nme.AND, nme.XOR); - val flags = Flags.JAVA | Flags.FINAL; - for (val cmpName <- ENUM_CMP_NAMES) { + val flags = Flags.JAVA | Flags.FINAL + for (cmpName <- ENUM_CMP_NAMES) { val enumCmpType: Type = JavaMethodType(List(clazz.tpe), definitions.BooleanClass.tpe); val enumCmp: Symbol = clazz.newMethod(NoPosition, cmpName); enumCmp.setFlag(flags).setInfo(enumCmpType) instanceDefs.enter(enumCmp); } - for (val bitLogName <- ENUM_BIT_LOG_NAMES) { + for (bitLogName <- ENUM_BIT_LOG_NAMES) { val enumBitLogType = JavaMethodType(List(clazz.tpe), classInfo); val enumBitLog = clazz.newMethod(NoPosition, bitLogName); enumBitLog.setFlag(flags).setInfo(enumBitLogType); @@ -267,7 +269,7 @@ abstract class TypeParser { } // parseClass - private def createMethod(method: MethodBase): Unit = { + private def createMethod(method: MethodBase) { val rettype = if (method.IsConstructor()) clazz.tpe else getCLSType(method.asInstanceOf[MethodInfo].ReturnType); if (rettype == null) return; @@ -320,8 +322,8 @@ abstract class TypeParser { } private def createDelegateChainers(typ: MSILType) = { - val flags: Long = Flags.JAVA | Flags.FINAL; - val args: Array[MSILType] = Array(typ); + val flags: Long = Flags.JAVA | Flags.FINAL + val args: Array[MSILType] = Array(typ) var s = createMethod(encode("+="), flags, args, clrTypes.VOID, clrTypes.DELEGATE_COMBINE, false); s = createMethod(encode("-="), flags, args, clrTypes.VOID, clrTypes.DELEGATE_REMOVE, false); diff --git a/src/compiler/scala/tools/nsc/transform/OverridingPairs.scala b/src/compiler/scala/tools/nsc/transform/OverridingPairs.scala index cf9f707611..e5d5e50a39 100644 --- a/src/compiler/scala/tools/nsc/transform/OverridingPairs.scala +++ b/src/compiler/scala/tools/nsc/transform/OverridingPairs.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2006 LAMP/EPFL + * Copyright 2005-2007 LAMP/EPFL * @author Martin Odersky */ // $Id$ @@ -24,34 +24,35 @@ abstract class OverridingPairs { private val self = base.thisType - protected def exclude(sym: Symbol): boolean = sym.isConstructor || sym.isPrivateLocal + protected def exclude(sym: Symbol): Boolean = sym.isConstructor || sym.isPrivateLocal protected def parents: List[Type] = base.info.parents - protected def matches(sym1: Symbol, sym2: Symbol): boolean = + protected def matches(sym1: Symbol, sym2: Symbol): Boolean = sym1.isType || (self.memberType(sym1) matches self.memberType(sym2)) - private type BitSet = Array[int] + private type BitSet = Array[Int] - private def newBitSet(size: int): BitSet = new Array((size + 31) >> 5) + private def newBitSet(size: Int): BitSet = new Array((size + 31) >> 5) - private def include(bs: BitSet, n: int): unit = { + private def include(bs: BitSet, n: Int) { val nshifted = n >> 5 val nmask = 1 << (n & 31) bs(nshifted) = bs(nshifted) | nmask } private def intersectionContainsElementLeq(bs1: BitSet, bs2: BitSet, - n: int): boolean = + n: Int): Boolean = { - val nshifted = n >> 5; + val nshifted = n >> 5 val nmask = 1 << (n & 31); ((List.range(0, nshifted) exists (i => (bs1(i) & bs2(i)) != 0)) || ((bs1(nshifted) & bs2(nshifted) & (nmask | nmask - 1)) != 0)) } - private val decls = newScope; - { def fillDecls(bcs: List[Symbol], deferredflag: int): unit = + private val decls = newScope + + { def fillDecls(bcs: List[Symbol], deferredflag: Int) { if (!bcs.isEmpty) { fillDecls(bcs.tail, deferredflag) var e = bcs.head.info.decls.elems; @@ -61,6 +62,7 @@ abstract class OverridingPairs { e = e.next } } + } fillDecls(base.info.baseClasses, DEFERRED) fillDecls(base.info.baseClasses, 0) } @@ -69,20 +71,20 @@ abstract class OverridingPairs { private val index = new HashMap[Symbol, int] - { var i = 0; - for (val bc <- base.info.baseClasses) { + { var i = 0 + for (bc <- base.info.baseClasses) { index(bc) = i - i = i + 1 + i += 1 } } private val subParents = new Array[BitSet](size) - { for (val i <- List.range(0, size)) + { for (i <- List.range(0, size)) subParents(i) = new BitSet(size); - for (val p <- parents) { + for (p <- parents) { val pIndex = index(p.typeSymbol) - for (val bc <- p.baseClasses) include(subParents(index(bc)), pIndex) + for (bc <- p.baseClasses) include(subParents(index(bc)), pIndex) } } @@ -104,7 +106,7 @@ abstract class OverridingPairs { var overridden: Symbol = _ //@M: note that next is called once during object initialisation - def hasNext: boolean = curEntry ne null + def hasNext: Boolean = curEntry ne null def next: unit = if (curEntry ne null) { diff --git a/src/compiler/scala/tools/nsc/transform/TailCalls.scala b/src/compiler/scala/tools/nsc/transform/TailCalls.scala index 142ae140fd..f59a509e33 100644 --- a/src/compiler/scala/tools/nsc/transform/TailCalls.scala +++ b/src/compiler/scala/tools/nsc/transform/TailCalls.scala @@ -32,13 +32,13 @@ abstract class TailCalls extends Transform /** The phase defined by this transform */ class Phase(prev: scala.tools.nsc.Phase) extends StdPhase(prev) { - def apply(unit: global.CompilationUnit): unit = + def apply(unit: global.CompilationUnit) { if (!(settings.debuginfo.value == "notc")) { newTransformer(unit).transformUnit(unit); } + } } - /** * A Tail Call Transformer * diff --git a/src/compiler/scala/tools/nsc/transform/Transform.scala b/src/compiler/scala/tools/nsc/transform/Transform.scala index b4ec94f269..b447aaca2d 100644 --- a/src/compiler/scala/tools/nsc/transform/Transform.scala +++ b/src/compiler/scala/tools/nsc/transform/Transform.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2006 LAMP/EPFL + * Copyright 2005-2007 LAMP/EPFL * @author Martin Odersky */ // $Id$ @@ -26,7 +26,7 @@ abstract class Transform extends SubComponent { /** The phase defined by this transform */ class Phase(prev: scala.tools.nsc.Phase) extends StdPhase(prev) { - def apply(unit: global.CompilationUnit): unit = { + def apply(unit: global.CompilationUnit) { newTransformer(unit).transformUnit(unit) } } diff --git a/src/library/scala/compat/Math.scala b/src/library/scala/compat/Math.scala index 5cd337901c..04a103d8df 100644 --- a/src/library/scala/compat/Math.scala +++ b/src/library/scala/compat/Math.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2006, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -9,10 +9,10 @@ // $Id$ -package scala.compat; +package scala.compat /** - * This class will be removed soon. Use scala.Math instead + * This class will be removed soon. Use <code>scala.Math</code> instead. */ @deprecated object Math { |