summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@epfl.ch>2008-06-09 13:32:38 +0000
committerLukas Rytz <lukas.rytz@epfl.ch>2008-06-09 13:32:38 +0000
commitdf9ba15338984e35a3280990e19eaaf48a909e6a (patch)
treec6a0ce92d72386c503f2d6698011a7726c5fcc9b /src/compiler
parentabe9ec9859709f93a3258d0769a4b3e3c52d0cb5 (diff)
downloadscala-df9ba15338984e35a3280990e19eaaf48a909e6a.tar.gz
scala-df9ba15338984e35a3280990e19eaaf48a909e6a.tar.bz2
scala-df9ba15338984e35a3280990e19eaaf48a909e6a.zip
rolling back the faulty checkin
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/ant/Scalac.scala8
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala7
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala3
-rw-r--r--src/compiler/scala/tools/nsc/symtab/AnnotationInfos.scala26
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Constants.scala16
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Symbols.scala1
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala31
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala15
-rw-r--r--src/compiler/scala/tools/nsc/transform/InfoTransform.scala1
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala2
10 files changed, 25 insertions, 85 deletions
diff --git a/src/compiler/scala/tools/ant/Scalac.scala b/src/compiler/scala/tools/ant/Scalac.scala
index 267ddaed74..4965071581 100644
--- a/src/compiler/scala/tools/ant/Scalac.scala
+++ b/src/compiler/scala/tools/ant/Scalac.scala
@@ -451,10 +451,6 @@ class Scalac extends MatchingTask {
\*============================================================================*/
protected val sourceEnding = ".scala"
- protected def binaryEnding = backend match {
- case Some("msil") => ".msil"
- case _ => ".class"
- }
protected def newSettings(error: String=>Unit): Settings =
new Settings(error)
protected def newGlobal(settings: Settings, reporter: Reporter) =
@@ -474,10 +470,8 @@ class Scalac extends MatchingTask {
error("Attribute 'destdir' does not refer to an existing directory.")
if (destination.isEmpty) destination = Some(getOrigin.head)
- // TODO msil: map packages (will be in filename for .msil files). Use
- // RegexppatternMapper (?)
val mapper = new GlobPatternMapper()
- mapper.setTo("*" + binaryEnding)
+ mapper.setTo("*.class")
mapper.setFrom("*" + sourceEnding)
// Scans source directories to build up a compile lists.
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
index 6c67ec2973..c2e1bd1e7e 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -1595,12 +1595,7 @@ trait Parsers extends NewScanners with MarkupParsers {
accept(VAL)
val aname = ident()
accept(EQUALS)
- val rhs =
- if (inToken == AT) {
- inNextToken
- annotationExpr()
- } else
- stripParens(prefixExpr())
+ val rhs = stripParens(prefixExpr())
atPos(pos) { ValDef(NoMods, aname, TypeTree(), rhs) }
}
val pos = inCurrentPos
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala
index 0d56743603..06106c6d03 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala
@@ -362,9 +362,6 @@ abstract class GenJVM extends SubComponent {
val arr = const.arrayValue
buf.putShort(arr.length.toShort)
for (val elem <- arr) emitElement(elem)
- case AnnotationTag =>
- // TODO: implement
- ()
}
var nattr = 0
diff --git a/src/compiler/scala/tools/nsc/symtab/AnnotationInfos.scala b/src/compiler/scala/tools/nsc/symtab/AnnotationInfos.scala
index a0c8ec73c7..5f9d67dfae 100644
--- a/src/compiler/scala/tools/nsc/symtab/AnnotationInfos.scala
+++ b/src/compiler/scala/tools/nsc/symtab/AnnotationInfos.scala
@@ -33,14 +33,6 @@ trait AnnotationInfos {
case Typed(t, _) => tree2cons(t)
- case Annotation(constr, elements) =>
-/* val annotInfo = typer.tpyedAnnotation(tree)
- if (annotInfo isConstant)
- Some(new AnnotationConstant(annotInfo))
- else */
- println("getting annotation: "+ tree)
- None
-
case tree =>
//println("could not convert: " + tree);
None
@@ -64,25 +56,9 @@ trait AnnotationInfos {
* and it includes a compile-time constant for the tree if possible.
*/
class AnnotationArgument(val intTree: Tree) {
-
- /** This constructor is also used to create an AnnotationArgument
- * containing a ArrayConstant, when an array of constants is seen
- * in a parsed classfile (ClassfileParser.parseTaggedConstant).
- * I.E. for Arrays of constants, intTree looks like:
- * <ul>
- * <li> Apply(ArrayModule_apply, members) if the AnnotationArgument
- * is part of an Annotation in Scala source </li>
- * <li> Literal(ArrayConstant(constants, tpe)) if the the argument
- * was created when parsing a java annotation in a classfile</li>
- * </ul>
- */
- def this(cons: Constant) {
- this(
+ def this(cons: Constant) = this(
Literal(cons).setType(cons.tpe))
- println("AnnotationArgument constructor with constant: "+ cons)
- }
- //def this(annTree: Annotation, annConst: AnnotationConstant)
@deprecated
lazy val tree = {
diff --git a/src/compiler/scala/tools/nsc/symtab/Constants.scala b/src/compiler/scala/tools/nsc/symtab/Constants.scala
index 3fea633b38..ec6f5dbc8c 100644
--- a/src/compiler/scala/tools/nsc/symtab/Constants.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Constants.scala
@@ -51,7 +51,6 @@ trait Constants {
else if (value.isInstanceOf[Type]) ClassTag
else if (value.isInstanceOf[Symbol]) EnumTag
else if (value.isInstanceOf[Array[Constant]]) ArrayTag
- else if (value.isInstanceOf[AnnotationInfo]) AnnotationTag
else if (value == null) NullTag
else throw new Error("bad constant value: " + value)
@@ -69,9 +68,7 @@ trait Constants {
case NullTag => AllRefClass.tpe
case ClassTag => Predef_classOfType(value.asInstanceOf[Type])
case EnumTag => symbolValue.owner.linkedClassOfClass.tpe
- // ArrayTag not required; method tpe is overwritten in ArrayConstant
- case AnnotationTag => annotationInfoValue.atp
- //AnnotationClass.tpe // what should it be?
+ case AnnotationTag => AnnotationClass.tpe // what should it be?
}
/** We need the equals method to take account of tags as well as values.
@@ -225,9 +222,6 @@ trait Constants {
def symbolValue: Symbol = value.asInstanceOf[Symbol]
- def annotationInfoValue: AnnotationInfo =
- throw new Error("value " + value + " is not an array")
-
def arrayValue: Array[Constant] =
throw new Error("value " + value + " is not an array")
@@ -241,8 +235,10 @@ trait Constants {
override def toString() = arrayValue.mkString("Constant(", "," , ")")
}
- class AnnotationConstant(override val annotationInfoValue: AnnotationInfo)
- extends Constant(annotationInfoValue) {
- assert(annotationInfoValue.isConstant, annotationInfoValue)
+ /** A place-holder for annotation constants. The contents of
+ * the constant are not read. */
+ class AnnotationConstant()
+ extends Constant(null) {
+ override val tag = AnnotationTag
}
}
diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
index 4775554ea5..d72a484a35 100644
--- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
@@ -573,7 +573,6 @@ trait Symbols {
if (validTo < curPeriod) {
var itr = infoTransformers.nextFrom(phaseId(validTo))
infoTransformers = itr; // caching optimization
- //println("running info transformer: "+ itr)
while (itr.pid != NoPhase.id && itr.pid < current.id) {
phase = phaseWithId(itr.pid)
val info1 = itr.transform(this, infos.info)
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
index 33f6f0d974..3cf8b8f25a 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
@@ -663,16 +663,10 @@ abstract class ClassfileParser {
staticModule.moduleClass.sourceFile = clazz.sourceFile
}
}
- // Methods of a java annotation class wear this annotation when they
- // provide a default value. The actual value does not need to be known
- // in order to compile other classes
case nme.AnnotationDefaultATTR =>
sym.attributes =
AnnotationInfo(definitions.AnnotationDefaultAttr.tpe, List(), List()) :: sym.attributes
in.skip(attrLen)
- // Java annotatinos present in classfiles (when the java annotation class is
- // itself annotated with @Renention(RetentionPolicy.RUNTIME) or .CLASS) are
- // stored in a "RuntimeVisibleAnnotation" (i.e. nme.RuntimeAnnotationATTR)
case nme.RuntimeAnnotationATTR =>
parseAnnotations(attrLen)
if (settings.debug.value)
@@ -710,8 +704,8 @@ abstract class ClassfileParser {
new ArrayConstant(arr.toArray,
appliedType(definitions.ArrayClass.typeConstructor, List(arr(0).tpe)))
case ANNOTATION_TAG =>
- val info = parseAnnotation(index)
- new AnnotationConstant(info)
+ parseAnnotation(index) // skip it
+ new AnnotationConstant()
}
}
@@ -719,7 +713,7 @@ abstract class ClassfileParser {
* throw an exception. If it contains a nested annotation,
* return None.
*/
- def parseAnnotation(attrNameIndex: Char): /* Option[ */ AnnotationInfo /*]*/ = {
+ def parseAnnotation(attrNameIndex: Char): Option[AnnotationInfo] = {
val attrType = pool.getType(attrNameIndex)
val nargs = in.nextChar
val nvpairs = new ListBuffer[(Name,AnnotationArgument)]
@@ -728,16 +722,16 @@ abstract class ClassfileParser {
for (i <- 0 until nargs) {
val name = pool.getName(in.nextChar)
val argConst = parseTaggedConstant
- //if (argConst.tag == AnnotationTag)
- //nestedAnnot = true
- //else
+ if (argConst.tag == AnnotationTag)
+ nestedAnnot = true
+ else
nvpairs += ((name, new AnnotationArgument(argConst)))
}
- //if (nestedAnnot)
- //None
- //else
- AnnotationInfo(attrType, List(), nvpairs.toList)
+ if (nestedAnnot)
+ None
+ else
+ Some(AnnotationInfo(attrType, List(), nvpairs.toList))
}
/** Parse a sequence of annotations and attach them to the
@@ -746,7 +740,7 @@ abstract class ClassfileParser {
def parseAnnotations(len: Int) {
val nAttr = in.nextChar
for (n <- 0 until nAttr)
-/* parseAnnotation(in.nextChar) match {
+ parseAnnotation(in.nextChar) match {
case None =>
if (settings.debug.value)
global.inform("dropping annotation on " +
@@ -754,8 +748,7 @@ abstract class ClassfileParser {
" that has a nested annotation")
case Some(annot) =>
sym.attributes = annot :: sym.attributes
- }*/
- sym.attributes = parseAnnotation(in.nextChar) :: sym.attributes
+ }
}
def makeInnerAlias(outer: Symbol, name: Name, iclazz: Symbol, scope: Scope): Symbol = {
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala
index 8a319228bb..09799d4412 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala
@@ -138,7 +138,6 @@ abstract class Pickler extends SubComponent {
putChildren(sym, children.sort((x, y) => x isLess y))
}
for (attr <- sym.attributes.reverse) {
- println("put annot? "+ attr +", "+ (attr.atp.typeSymbol isNonBottomSubClass definitions.StaticAnnotationClass))
if (attr.atp.typeSymbol isNonBottomSubClass definitions.StaticAnnotationClass)
putAnnotation(sym, attr)
}
@@ -291,7 +290,6 @@ abstract class Pickler extends SubComponent {
putTrees(args)
case ArrayValue(elemtpt, trees) =>
- println("putting array value: "+ trees)
putTree(elemtpt)
putTrees(trees)
@@ -399,19 +397,17 @@ abstract class Pickler extends SubComponent {
private def putMods(mods: Modifiers) = if (putEntry(mods)) {
val Modifiers(flags, privateWithin, annotations) = mods
putEntry(privateWithin)
- println("putting annotation trees: "+ annotations)
putTrees(annotations)
}
/** Store a constant in map <code>index</code> along with
* anything it references.
*/
- private def putConstant(c: Constant) = {
+ private def putConstant(c: Constant) =
if (putEntry(c)) {
if (c.tag == StringTag) putEntry(newTermName(c.stringValue))
else if (c.tag == ClassTag) putEntry(c.typeValue)
}
- }
private def putChildren(sym: Symbol, children: List[Symbol]) {
assert(putEntry((sym, children)))
@@ -419,7 +415,6 @@ abstract class Pickler extends SubComponent {
}
private def putAnnotation(sym: Symbol, annot: AnnotationInfo) {
- println("putting annotation: "+ annot)
assert(putEntry((sym, annot)))
val AnnotationInfo(atp, args, assocs) = annot
putType(atp)
@@ -437,11 +432,10 @@ abstract class Pickler extends SubComponent {
}
private def putAnnotationArg(arg: AnnotationArgument) {
- println("putting annotation arg: "+ arg)
if (putEntry(arg)) {
arg.constant match {
- case Some(c) => println(" const: "+ c); putConstant(c)
- case _ => println(" tree: "+ arg.intTree); putTree(arg.intTree)
+ case Some(c) => putConstant(c)
+ case _ => putTree(arg.intTree)
}
}
}
@@ -540,7 +534,6 @@ abstract class Pickler extends SubComponent {
case DeBruijnIndex(l, i) =>
writeNat(l); writeNat(i); DEBRUIJNINDEXtpe
case c @ Constant(_) =>
- println("putting constant with tag: "+ c.tag)
if (c.tag == BooleanTag) writeLong(if (c.booleanValue) 1 else 0)
else if (ByteTag <= c.tag && c.tag <= LongTag) writeLong(c.longValue)
else if (c.tag == FloatTag) writeLong(Float.floatToIntBits(c.floatValue))
@@ -736,7 +729,6 @@ abstract class Pickler extends SubComponent {
TREE
case tree@ArrayValue(elemtpt, trees) =>
- println("arrayValue tree: "+ trees)
writeNat(ARRAYVALUEtree)
writeRef(tree.tpe)
writeRef(elemtpt)
@@ -937,7 +929,6 @@ abstract class Pickler extends SubComponent {
ANNOTINFO
case arg:AnnotationArgument =>
- println("writing AnnotationArgument: "+ arg)
arg.constant match {
case Some(c) => writeBody(c)
case None => writeBody(arg.intTree)
diff --git a/src/compiler/scala/tools/nsc/transform/InfoTransform.scala b/src/compiler/scala/tools/nsc/transform/InfoTransform.scala
index e5b3e87458..d130abb336 100644
--- a/src/compiler/scala/tools/nsc/transform/InfoTransform.scala
+++ b/src/compiler/scala/tools/nsc/transform/InfoTransform.scala
@@ -30,7 +30,6 @@ trait InfoTransform extends Transform {
val pid = id
val changesBaseClasses = InfoTransform.this.changesBaseClasses
def transform(sym: Symbol, tpe: Type): Type = transformInfo(sym, tpe)
- override def toString() = InfoTransform.this.toString()
}
infoTransformers.insert(infoTransformer)
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 5d9c131571..dbcc130e03 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -1987,7 +1987,7 @@ trait Typers { self: Analyzer =>
} else {
names -= sym
val annArg =
- annotArg( // also checks that rhs is constant
+ annotArg(
typed(rhs, EXPRmode, sym.tpe.resultType))
(sym.name, annArg)
}