summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2006-11-10 13:34:55 +0000
committermichelou <michelou@epfl.ch>2006-11-10 13:34:55 +0000
commit064217d20c8c5b41a1b282c837214f404314ab44 (patch)
treeba61400c15d242c942e462d385601f3bfb59e11e
parentaecb341d73076f699f94312c33268fbbfdb6d537 (diff)
downloadscala-064217d20c8c5b41a1b282c837214f404314ab44.tar.gz
scala-064217d20c8c5b41a1b282c837214f404314ab44.tar.bz2
scala-064217d20c8c5b41a1b282c837214f404314ab44.zip
completed descriptions of primitive types in Do...
completed descriptions of primitive types in DocGenerator added missing flags to AnyClass, AnyValClass, .. in Definitions
-rw-r--r--src/compiler/scala/tools/nsc/doc/DocGenerator.scala135
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Definitions.scala13
2 files changed, 105 insertions, 43 deletions
diff --git a/src/compiler/scala/tools/nsc/doc/DocGenerator.scala b/src/compiler/scala/tools/nsc/doc/DocGenerator.scala
index 1bf866e5e1..21ffdcff03 100644
--- a/src/compiler/scala/tools/nsc/doc/DocGenerator.scala
+++ b/src/compiler/scala/tools/nsc/doc/DocGenerator.scala
@@ -13,8 +13,7 @@ import java.util.regex.Pattern
import compat.Platform.{EOL => LINE_SEPARATOR}
import scala.collection.immutable._
import scala.collection.mutable.ListBuffer
-import scala.tools.nsc._
-import scala.tools.nsc.models._
+import scala.tools.nsc.models.Models
import scala.tools.nsc.symtab.Flags
import scala.xml._
@@ -147,7 +146,7 @@ abstract class DocGenerator extends Models {
else ""
case _ =>
//System.err.println("XXX: class or object " + orig + " not found in " + sym)
- "XXXXX"
+ "" //"XXXXX"
})
}
@@ -619,14 +618,23 @@ abstract class DocGenerator extends Models {
<hr/>
<div>in {aref(urlFor(sym.owner), "_self", sym.owner.fullNameString('.'))}</div>
<div class="entity">
- {Text(codeFor(kind))}
+ { Text(codeFor(kind)) }
<span class="entity">{Text(sym.nameString)}</span>
</div>
<hr/>
<dl>
- <dt><code>{
- Text("class " + sym.nameString)
- }</code></dt>
+ <dt>
+ <code>{Text(Flags.flagsToString(sym.flags) + " class ")}</code>
+ <em>{Text(sym.nameString)}</em>
+ </dt>
+ <dd>{
+ if (sym.info.parents.isEmpty) NodeSeq.Empty
+ else {
+ val parent = sym.info.parents.head
+ <code>{Text(" extends ")}</code>.concat(
+ aref(urlFor(parent.symbol), contentFrame, parent.toString()))
+ }
+ }</dd>
<dd>{comment(descr, true)}</dd>
</dl>
<hr/>.concat({
@@ -776,85 +784,138 @@ abstract class DocGenerator extends Models {
}
new PrimitiveContentFrame {
def sym = definitions.AnyClass
- def descr = "/** */"
+ def descr = """
+ /** <p>
+ * Class <code>Any</code> is the root of the <a href="http://scala.epfl.ch/">
+ * Scala</a> class hierarchy. Every class in a <a href="http://scala.epfl.ch/">
+ * Scala</a> execution environment inherits directly or
+ * indirectly from this class. Class <code>Any</code> has two direct
+ * subclasses: <a href="AnyRef.html"><code>AnyRef</code></a>
+ * and <a href="AnyVal.html"><code>AnyVal</code></a>.
+ * </p>
+ */"""
}
new PrimitiveContentFrame {
def sym = definitions.AnyRefClass
- def descr = "/** */"
+ def descr = """
+ /** <p>
+ * Class <code>AnyRef</code> is the root class of all reference
+ * types.
+ * </p>
+ */"""
+ }
+ new PrimitiveContentFrame {
+ def sym = definitions.AnyValClass
+ def descr = """
+ /** <p>
+ * Class <code>AnyVal</code> is the root class of all value types.
+ * </p>
+ * <p>
+ * <code>AnyVal</code> has a fixed number subclasses, which
+ * describe values which are not implemented as objects in the
+ * underlying host system.
+ * </p>
+ * <p>
+ * Classes <a href="Double.html"><code>Double</code></a>,
+ * <a href="Float.html"><code>Float</code></a>,
+ * <a href="Long.html"><code>Long</code></a>,
+ * <a href="Int.html"><code>Int</code></a>,
+ * <a href="Char.html"><code>Char</code></a>,
+ * <a href="Short.html"><code>Short</code></a>, and
+ * <a href="Byte.html"><code>Byte</code></a> are together called
+ * <em>numeric value types</em>.
+ * Classes <a href="Byte.html"><code>Byte</code></a>,
+ * <a href="Short.html"><code>Short</code></a>, or
+ * <a href="Char.html"><code>Char</code></a>
+ * are called <em>subrange types</em>. Subrange types, as well as
+ * <a href="Int.html"><code>Int</code></a> and
+ * <a href="Long.html"><code>Long</code></a> are called
+ * <em>integer types</em>, whereas
+ * <a href="Float.html"><code>Float</code></a> and
+ * <a href="Double.html"><code>Double</code></a> are called
+ * <em>floating point types</em>.
+ * </p>
+ */"""
}
new PrimitiveContentFrame {
def sym = definitions.BooleanClass
def descr = """
- /** Class <code>Boolean</code> has only two values: <code>true</code>
- * and <code>false</code>.
+ /** <p>
+ * Class <code>Boolean</code> has only two values: <code>true</code>
+ * and <code>false</code>.
+ * </p>
*/"""
}
- def numValuesDescr(sym: Symbol) = """
+ def numericValDescr(sym: Symbol) = """
/** <p>
- * Class <code>""" + sym.name + """ </code> belongs to the value classes whose
- * instances are not represented as objects by the underlying host system. All
- * value classes inherit from class <code>AnyVal</code>.
- * </p>
- * <p>
- * Classes <code>Double</code>, <code>Float</code>, <code>Long</code>,
- * <code>Int</code>, <code>Char</code>, <code>Short</code>, and
- * <code>Byte</code> are together called <em>numeric value types</em>.
- * Classes <code>Byte</code>, <code>Short</code>, or <code>Char</code>
- * are called <em>subrange types</em>. Subrange types, as well as
- * <code>Int</code> and <code>Long</code> are called <em>integer types</em>,
- * whereas <code>Float</code> and <code>Double</code> are called
- * <em>floating point types</em>.
+ * Class <code>""" + sym.name + """ </code> belongs to the value
+ * classes whose instances are not represented as objects by the
+ * underlying host system. All value classes inherit from class
+ * <a href="AnyVal.html"><code>AnyVal</code></a>.
* </p>
*/"""
new PrimitiveContentFrame {
def sym = definitions.ByteClass
- def descr = numValuesDescr(sym)
+ def descr = numericValDescr(sym)
}
new PrimitiveContentFrame {
def sym = definitions.CharClass
- def descr = numValuesDescr(sym)
+ def descr = numericValDescr(sym)
}
new PrimitiveContentFrame {
def sym = definitions.DoubleClass
- def descr = numValuesDescr(sym)
+ def descr = numericValDescr(sym)
}
new PrimitiveContentFrame {
def sym = definitions.FloatClass
- def descr = numValuesDescr(sym)
+ def descr = numericValDescr(sym)
}
new PrimitiveContentFrame {
def sym = definitions.IntClass
- def descr = numValuesDescr(sym)
+ def descr = numericValDescr(sym)
}
new PrimitiveContentFrame {
def sym = definitions.LongClass
- def descr = numValuesDescr(sym)
+ def descr = numericValDescr(sym)
}
new PrimitiveContentFrame {
def sym = definitions.ShortClass
- def descr = numValuesDescr(sym)
+ def descr = numericValDescr(sym)
}
new PrimitiveContentFrame {
def sym = definitions.UnitClass
def descr = """
- /** Class Unit has only one value: <code>()</code>.
+ /** <p>
+ * Class <code>Unit</code> has only one value: <code>()</code>.
+ * </p>
*/"""
}
+ def boxedValDescr(sym: Symbol) = """
+ /** <p>
+ * Class <code>""" + sym.name + """</code> implements the
+ * boxing/unboxing from/to value types.
+ * </p>
+ * <p>
+ * Boxing and unboxing enable value types to be treated as objects;
+ * they provide a unified view of the type system wherein a value
+ * of any type can ultimately be treated as an object.
+ * </p>
+ */"""
new PrimitiveContentFrame {
def sym = definitions.getClass("scala.runtime.BoxedFloat")
- def descr = "/** */"
+ def descr = boxedValDescr(sym)
}
new PrimitiveContentFrame {
def sym = definitions.getClass("scala.runtime.BoxedInt")
- def descr = "/** */"
+ def descr = boxedValDescr(sym)
}
new PrimitiveContentFrame {
def sym = definitions.getClass("scala.runtime.BoxedLong")
- def descr = "/** */"
+ def descr = boxedValDescr(sym)
}
new PrimitiveContentFrame {
def sym = definitions.getClass("scala.runtime.BoxedNumber")
- def descr = "/** */"
+ def descr = boxedValDescr(sym)
}
val rsrcdir = "scala/tools/nsc/doc/".replace('/', File.separatorChar)
for (val base <- List("style.css", "script.js")) {
diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala
index 88415407a0..7aa716dde3 100644
--- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala
@@ -150,7 +150,7 @@ trait Definitions requires SymbolTable {
val prod = tp.typeArgs.head
if (prod.symbol == UnitClass) List()
else prod.baseClasses.find { x => isProductType(x.tpe) } match {
- case Some(p) => prod.baseType(p).typeArgs
+ case Some(p) => prod.baseType(p).typeArgs
}
}
@@ -342,14 +342,15 @@ trait Definitions requires SymbolTable {
"scala.runtime.Boxed" + name
val clazz =
newClass(ScalaPackageClass, name, List(AnyValClass.typeConstructor))
+ .setFlag(ABSTRACT | SEALED)
boxedClass(clazz) = getClass(boxedName)
boxedArrayClass(clazz) = getClass("scala.runtime.Boxed" + name + "Array")
refClass(clazz) = getClass("scala.runtime." + name + "Ref")
abbrvTag(clazz) = tag
- val module = ScalaPackageClass.newModule(NoPos, name);
- ScalaPackageClass.info.decls.enter(module);
- val mclass = module.moduleClass;
+ val module = ScalaPackageClass.newModule(NoPos, name)
+ ScalaPackageClass.info.decls.enter(module)
+ val mclass = module.moduleClass
mclass.setInfo(ClassInfoType(List(), newScope, mclass))
module.setInfo(mclass.tpe)
val box = newMethod(mclass, nme.box, List(clazz.typeConstructor),
@@ -537,12 +538,12 @@ trait Definitions requires SymbolTable {
assert(ScalaPackage != null, "Scala package is null")
ScalaPackageClass = ScalaPackage.tpe.symbol
- AnyClass = newClass(ScalaPackageClass, nme.Any, List())
+ AnyClass = newClass(ScalaPackageClass, nme.Any, List()).setFlag(ABSTRACT)
val anyparam = List(AnyClass.typeConstructor)
AnyValClass = newClass(ScalaPackageClass, nme.AnyVal, anyparam)
- .setFlag(SEALED)
+ .setFlag(FINAL | SEALED)
ObjectClass = getClass("java.lang.Object")