Permalink
Browse files

updated self aliases, for-comprehension, += ops

  • Loading branch information...
michelou
michelou committed Apr 23, 2007
1 parent 97f2351 commit a9cc141f197da8741b395c4e2321c4f8b15e3c0c
Showing with 621 additions and 624 deletions.
  1. +0 −1 src/compiler/scala/tools/nsc/CompileClient.scala
  2. +5 −5 src/compiler/scala/tools/nsc/MainTokenMetric.scala
  3. +10 −16 src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala
  4. +7 −8 src/compiler/scala/tools/nsc/ast/TreeGen.scala
  5. +4 −4 src/compiler/scala/tools/nsc/ast/TreeInfo.scala
  6. +10 −11 src/compiler/scala/tools/nsc/ast/TreePrinters.scala
  7. +3 −3 src/compiler/scala/tools/nsc/ast/Trees.scala
  8. +12 −12 src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala
  9. +28 −25 src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
  10. +65 −59 src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
  11. +7 −7 src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala
  12. +6 −6 src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala
  13. +18 −18 src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala
  14. +40 −39 src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
  15. +37 −36 src/compiler/scala/tools/nsc/backend/opt/ClosureElimination.scala
  16. +31 −30 src/compiler/scala/tools/nsc/backend/opt/Inliners.scala
  17. +47 −42 src/compiler/scala/tools/nsc/doc/DocDriver.scala
  18. +2 −4 src/compiler/scala/tools/nsc/doc/DocGenerator.scala
  19. +2 −2 src/compiler/scala/tools/nsc/doc/DocUtil.scala
  20. +32 −32 src/compiler/scala/tools/nsc/doc/ModelExtractor.scala
  21. +17 −19 src/compiler/scala/tools/nsc/doc/ModelFrames.scala
  22. +9 −9 src/compiler/scala/tools/nsc/doc/ModelToXML.scala
  23. +30 −30 src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala
  24. +20 −20 src/compiler/scala/tools/nsc/symtab/Types.scala
  25. +37 −36 src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
  26. +91 −92 src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala
  27. +10 −10 src/compiler/scala/tools/nsc/symtab/classfile/PickleBuffer.scala
  28. +13 −13 src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala
  29. +10 −9 src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala
  30. +3 −3 src/compiler/scala/tools/nsc/transform/UnCurry.scala
  31. +5 −7 src/compiler/scala/tools/nsc/util/NameTransformer.scala
  32. +10 −16 src/compiler/scala/tools/nsc/util/SourceFile.scala
@@ -8,7 +8,6 @@ package scala.tools.nsc
import java.io.{BufferedReader, File, InputStreamReader, PrintWriter}
-import scala.compat.StringBuilder
import scala.tools.util.StringOps
/** The main class for NSC, a compiler for the programming
@@ -7,7 +7,7 @@
package scala.tools.nsc
import compat.Math.log
-import scala.tools.nsc.reporters.{Reporter, ConsoleReporter}
+import scala.tools.nsc.reporters.ConsoleReporter
/** The main class for NSC, a compiler for the programming
* language Scala.
@@ -21,10 +21,10 @@ object MainTokenMetric {
import compiler.syntaxAnalyzer.UnitScanner
import ast.parser.Tokens.EOF
var totale = 0
- for (val source <- fnames) {
+ for (source <- fnames) {
val s = new UnitScanner(new CompilationUnit(compiler.getSourceFile(source)))
var i = 0
- while(s.token != EOF) {
+ while (s.token != EOF) {
i += 1
s.nextToken
}
@@ -35,7 +35,7 @@ object MainTokenMetric {
Console.print(i.toString())
Console.print(" ")
Console.println(source.toString())
- totale = totale + i
+ totale += i
}
Console.println(totale.toString()+" total")
}
@@ -55,7 +55,7 @@ object MainTokenMetric {
}
}
- def main(args: Array[String]): unit = {
+ def main(args: Array[String]) {
process(args)
exit(if (reporter.hasErrors) 1 else 0)
}
@@ -1,28 +1,22 @@
/* NSC -- new Scala compiler
- * Copyright 2005-2006 LAMP/EPFL
+ * Copyright 2005-2007 LAMP/EPFL
* @author Martin Odersky
*/
// $Id$
package scala.tools.nsc.ast
-import compat.StringBuilder
-import scala.concurrent.Lock
-import symtab.Flags._
-
-import java.lang.Math
-import java.util.HashMap
+import java.awt.{List => awtList, _}
+import java.awt.event._
import java.io.StringWriter
-import javax.swing.tree._
-import javax.swing.event.TreeModelListener
import javax.swing._
+import javax.swing.event.TreeModelListener
+import javax.swing.tree._
-import java.awt.BorderLayout
-import java.awt.{List => awtList, _}
-import java.awt.event._
-
+import scala.concurrent.Lock
import scala.text._
+import symtab.Flags._
/**
* Tree browsers can show the AST in a graphical and interactive
@@ -77,7 +71,7 @@ abstract class TreeBrowsers {
val phase: Phase = globalPhase
var unitList: List[UnitTree] = Nil
- for (val i <- units)
+ for (i <- units)
unitList = UnitTree(i) :: unitList
val tm = new ASTTreeModel(ProgramTree(unitList))
@@ -230,8 +224,8 @@ abstract class TreeBrowsers {
str.append(buf.toString())
str.append("\nSymbol tpe: ")
if (t.symbol ne null) {
- str.append(t.symbol.tpe).append("\n");
- buf = new StringWriter();
+ str.append(t.symbol.tpe).append("\n")
+ buf = new StringWriter()
TypePrinter.toDocument(t.symbol.tpe).format(getWidth() / getColumnWidth(), buf)
str.append(buf.toString())
}
@@ -1,14 +1,13 @@
/* NSC -- new Scala compiler
- * Copyright 2005-2006 LAMP/EPFL
+ * Copyright 2005-2007 LAMP/EPFL
* @author Martin Odersky
*/
// $Id$
package scala.tools.nsc.ast
-import scala.tools.nsc.util.Position
-import symtab.Flags._
import scala.collection.mutable.ListBuffer
+import symtab.Flags._
abstract class TreeGen {
@@ -38,7 +37,7 @@ abstract class TreeGen {
if (sym.isRoot) {
mkAttributedThis(sym)
} else if (sym.isModuleClass) {
- val qual = mkAttributedRef(pre, sym.sourceModule);
+ val qual = mkAttributedRef(pre, sym.sourceModule)
qual.tpe match {
case MethodType(List(), restpe) =>
Apply(qual, List()) setType restpe
@@ -193,8 +192,8 @@ abstract class TreeGen {
.setInfo(accessor.tpe.finalResultType)
.setFlag(MODULEVAR);
if (mvar.owner.isClass) {
- mvar setFlag (PRIVATE | LOCAL | SYNTHETIC);
- mvar.owner.info.decls.enter(mvar);
+ mvar setFlag (PRIVATE | LOCAL | SYNTHETIC)
+ mvar.owner.info.decls.enter(mvar)
}
ValDef(mvar, if (mvar.owner.isClass) EmptyTree else Literal(Constant(null)))
}
@@ -204,7 +203,7 @@ abstract class TreeGen {
DefDef(accessor, vparamss =>
mkCached(mvar,
New(TypeTree(mvar.tpe),
- List(for (val pt <- mvar.tpe.symbol.primaryConstructor.info.paramTypes)
+ List(for (pt <- mvar.tpe.symbol.primaryConstructor.info.paramTypes)
yield This(accessor.owner.enclClass)))))
// def m: T;
@@ -228,7 +227,7 @@ abstract class TreeGen {
def evalOnceAll(exprs: List[Tree], owner: Symbol, unit: CompilationUnit)(within: (List[() => Tree]) => Tree): Tree = {
val vdefs = new ListBuffer[ValDef]
val exprs1 = new ListBuffer[() => Tree]
- for (val expr <- exprs) {
+ for (expr <- exprs) {
if (treeInfo.isPureExpr(expr)) {
exprs1 += (() => expr)
} else {
@@ -1,13 +1,13 @@
/* NSC -- new Scala compiler
- * Copyright 2005-2006 LAMP/EPFL
+ * Copyright 2005-2007 LAMP/EPFL
* @author Martin Odersky
*/
// $Id$
package scala.tools.nsc.ast
import symtab.Flags._
-import util.{Set, HashSet}
+import util.HashSet
/** This class ...
*
@@ -151,7 +151,7 @@ abstract class TreeInfo {
/** The value definitions marked PRESUPER in this statement sequence */
def preSuperFields(stats: List[Tree]): List[ValDef] =
- for (val vdef @ ValDef(mods, _, _, _) <- stats; mods hasFlag PRESUPER) yield vdef
+ for (vdef @ ValDef(mods, _, _, _) <- stats if mods hasFlag PRESUPER) yield vdef
def isPreSuper(tree: Tree) = tree match {
case ValDef(mods, _, _, _) => mods hasFlag PRESUPER
@@ -161,7 +161,7 @@ abstract class TreeInfo {
/** Is name a left-associative operator? */
def isLeftAssoc(operator: Name): boolean =
- operator.length > 0 && operator(operator.length - 1) != ':';
+ operator.length > 0 && operator(operator.length - 1) != ':'
private val reserved = new HashSet[Name]
reserved addEntry nme.false_
@@ -1,13 +1,12 @@
/* NSC -- new Scala compiler
- * Copyright 2005-2006 LAMP/EPFL
+ * Copyright 2005-2007 LAMP/EPFL
* @author Martin Odersky
*/
// $Id: TreePrinters.scala 9925 2007-02-07 18:30:46 +0000 (Wed, 07 Feb 2007) odersky $
package scala.tools.nsc.ast
import compat.Platform.{EOL => LINE_SEPARATOR}
-import compat.StringBuilder
import java.io.{OutputStream, PrintWriter, Writer}
import symtab.Flags._
@@ -23,13 +22,13 @@ abstract class TreePrinters {
def flush = out.flush()
- def indent = indentMargin = indentMargin + indentStep
- def undent = indentMargin = indentMargin - indentStep
+ def indent = indentMargin += indentStep
+ def undent = indentMargin -= indentStep
def println = {
out.println()
while (indentMargin > indentString.length())
- indentString = indentString + indentString
+ indentString += indentString
if (indentMargin > 0)
out.write(indentString, 0, indentMargin)
}
@@ -195,7 +194,7 @@ abstract class TreePrinters {
if (!args.isEmpty)
printRow(args, "(", ",", ")")
if (!elements.isEmpty)
- print((for (val Assign(name, value) <- elements) yield "val " + name + " = " + value).
+ print((for (Assign(name, value) <- elements) yield "val " + name + " = " + value).
mkString("{", ",", "}"))
case Template(parents, body) =>
@@ -308,7 +307,7 @@ abstract class TreePrinters {
if (!args.isEmpty)
printRow(args, "(", ",", ")")
if (!elements.isEmpty)
- print((for (val Assign(name, value) <- elements) yield "val " + name + " = " + value).
+ print((for (Assign(name, value) <- elements) yield "val " + name + " = " + value).
mkString("{", ",", "}"))
}
if (tree.isType) { printAnnot(); print(" "); print(tree) }
@@ -353,7 +352,7 @@ abstract class TreePrinters {
} else tree)
}
- def print(unit: CompilationUnit): unit = {
+ def print(unit: CompilationUnit) {
print("// Scala source: " + unit.source + LINE_SEPARATOR)
if (unit.body ne null) {
print(unit.body); println
@@ -363,10 +362,10 @@ abstract class TreePrinters {
println; flush
}
- def printAll(): unit = {
+ def printAll() {
print("[[syntax trees at end of " + phase + "]]")
atPhase(phase.next) {
- for (val unit <- global.currentRun.units) print(unit)
+ for (unit <- global.currentRun.units) print(unit)
}
}
}
@@ -381,7 +380,7 @@ abstract class TreePrinters {
object ConsoleWriter extends Writer {
override def write(str: String): unit = Console.print(str)
- def write(cbuf: Array[char], off: int, len: int): unit = {
+ def write(cbuf: Array[char], off: int, len: int) {
val str = new String(cbuf, off, len)
write(str)
}
@@ -120,14 +120,14 @@ trait Trees {
val that0 = that.asInstanceOf[List[Any]]
if (thiz.length != that0.length) false
else {
- val results0 = for (val i <- 0.until(thiz.length).toList)
+ val results0 = for (i <- 0.until(thiz.length).toList)
yield equals0(thiz(i), that0(i))
results0.foldLeft(true)((x,y) => x && y)
}
case thiz =>
thiz == that
}
- val results = for (val i <- 0.until(this0.productArity).toList) yield
+ val results = for (i <- 0.until(this0.productArity).toList) yield
equals0(this0.productElement(i), that0.productElement(i))
val b = results.foldLeft(true)((x,y) => x && y)
b && (if (tpe == null || tpe == NoType) that.tpe == null || that.tpe == NoType
@@ -1495,7 +1495,7 @@ trait Trees {
case Template(parents, body) =>
tree.symbol = NoSymbol
tree.tpe = null
- for (val stat <- body)
+ for (stat <- body)
if (stat.isDef) erasedSyms.addEntry(stat.symbol)
super.traverse(tree)
case _: DefTree =>
@@ -1,12 +1,11 @@
/* NSC -- new Scala compiler
- * Copyright 2005-2006 LAMP/EPFL
+ * Copyright 2005-2007 LAMP/EPFL
* @author Burak Emir
*/
// $Id$
package scala.tools.nsc.ast.parser
-import compat.StringBuilder
import scala.collection.immutable.ListMap
import scala.collection.mutable
import scala.tools.nsc.util.Position
@@ -17,7 +16,8 @@ import scala.xml.{Text, TextBuffer}
* @author Burak Emir
* @version 1.0
*/
-trait MarkupParsers requires SyntaxAnalyzer {
+trait MarkupParsers {
+ self: SyntaxAnalyzer =>
import global._
//import posAssigner.atPos
@@ -26,7 +26,7 @@ class MarkupParser(p: UnitParser, presWS: boolean) /*with scala.xml.parsing.Mark
import Tokens.{EMPTY, LBRACE, RBRACE}
- final val preserveWS = presWS;
+ final val preserveWS = presWS
import p.{symbXMLBuilder => handle}
def s = p.in
@@ -254,7 +254,7 @@ class MarkupParser(p: UnitParser, presWS: boolean) /*with scala.xml.parsing.Mark
xToken('-')
while (true) {
if( ch=='-' && { sb.append(ch); nextch; ch == '-' } ) {
- sb.setLength(sb.length() - 1);
+ sb.setLength(sb.length() - 1)
nextch
xToken('>')
return handle.comment(pos, sb.toString())
@@ -272,7 +272,7 @@ class MarkupParser(p: UnitParser, presWS: boolean) /*with scala.xml.parsing.Mark
/*[Duplicate]*/ def appendText(pos: Position, ts: mutable.Buffer[Tree],
txt: String): Unit =
if (!preserveWS) {
- for (val t <- TextBuffer.fromString(txt).toText) {
+ for (t <- TextBuffer.fromString(txt).toText) {
ts.append(handle.text(pos, t.text))
}
}
@@ -555,7 +555,7 @@ class MarkupParser(p: UnitParser, presWS: boolean) /*with scala.xml.parsing.Mark
def xLiteralPattern:Tree = try {
init; pushScannerState
val oldMode = handle.isPattern;
- handle.isPattern = true;
+ handle.isPattern = true
var tree = xPattern; xSpaceOpt;
handle.isPattern = oldMode;
s.next.token = Tokens.EMPTY;
@@ -571,12 +571,12 @@ class MarkupParser(p: UnitParser, presWS: boolean) /*with scala.xml.parsing.Mark
}
def xEmbeddedExpr: Tree = {
- sync;
+ sync
val b = p.block() //p.expr(true,false);
if(/*s.*/token != RBRACE) {
- reportSyntaxError(" expected end of Scala block");
+ reportSyntaxError(" expected end of Scala block")
}
- init;
+ init
return b
}
@@ -586,9 +586,9 @@ class MarkupParser(p: UnitParser, presWS: boolean) /*with scala.xml.parsing.Mark
sync;
val b = p.patterns(true);
if (/*s.*/token != RBRACE) {
- reportSyntaxError(" expected end of Scala patterns");
+ reportSyntaxError(" expected end of Scala patterns")
}
- init;
+ init
return b
}
Oops, something went wrong.

0 comments on commit a9cc141

Please sign in to comment.