diff --git a/docs/examples/actors/Loop.scala b/docs/examples/actors/Loop.scala index 0799996d8..a70554a50 100644 --- a/docs/examples/actors/Loop.scala +++ b/docs/examples/actors/Loop.scala @@ -14,7 +14,7 @@ object Loop extends Application { } } - for (val i <- List.range(0, 10)) { + for (val i <- 0 until 10) { a ! A } } diff --git a/src/actors/scala/actors/Actor.scala b/src/actors/scala/actors/Actor.scala index 873835d17..e0e60dadd 100644 --- a/src/actors/scala/actors/Actor.scala +++ b/src/actors/scala/actors/Actor.scala @@ -1,23 +1,33 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2005-2006, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: $ + package scala.actors import scala.collection.mutable.HashSet /** - This object provides functions for the definition of actors and - reactors, as well as all actor operations, such as - receive, react, reply, - etc. - - @author Philipp Haller + * This object provides functions for the definition of actors and + * reactors, as well as all actor operations, such as + * receive, react, reply, + * etc. + * + * @author Philipp Haller */ object Actor { private[actors] val selfs = new java.util.WeakHashMap(16, 0.5f) /** - Returns the currently executing actor. Should be used instead - of this in all blocks of code executed by - actors. + * Returns the currently executing actor. Should be used instead + * of this in all blocks of code executed by + * actors. */ def self: Actor = synchronized { val t = Thread.currentThread() @@ -34,8 +44,8 @@ object Actor { } /** - Creates an instance of a thread-based actor executing body, - and starts it. + * Creates an instance of a thread-based actor executing body, + * and starts it. */ def actor(body: => Unit): ActorThread = synchronized { val actor = new ActorThread { @@ -46,9 +56,9 @@ object Actor { } /** - Creates an instance of a thread-based actor specifying a - channel which can be used for typed communication with other - actors. + * Creates an instance of a thread-based actor specifying a + * channel which can be used for typed communication with other + * actors. */ def actor[a](ch: Channel[a])(body: => Unit): ActorThread = synchronized { val actor = new ActorThread { @@ -60,8 +70,8 @@ object Actor { } /** - Creates an instance of an event-based reactor executing - body, and starts it. + * Creates an instance of an event-based reactor executing + * body, and starts it. */ def reactor(body: => Unit): Reactor = synchronized { val reactor = new Reactor { @@ -72,12 +82,12 @@ object Actor { } /** - Receives a message from the mailbox of - self. Blocks if no message matching any of the - cases of f can be received. - - Only (thread-based) actors may call this method. It fails at - runtime if executed by a reactor. + * Receives a message from the mailbox of + * self. Blocks if no message matching any of the + * cases of f can be received. + * + * Only (thread-based) actors may call this method. It fails at + * runtime if executed by a reactor. */ def receive[a](f: PartialFunction[Any, a]): a = self.in.receive(f) @@ -244,10 +254,10 @@ object Actor { } /** - This trait defines commonalities between thread-based and - event-based actors. - - @author Philipp Haller + * This trait defines commonalities between thread-based and + * event-based actors. + * + * @author Philipp Haller */ trait Actor { @@ -269,21 +279,21 @@ trait Actor { } /** - The behavior of an actor is specified by implementing this - abstract method. Note that the preferred way to create actors - is through the actor and reactor - methods defined in object Actor. + * The behavior of an actor is specified by implementing this + * abstract method. Note that the preferred way to create actors + * is through the actor and reactor + * methods defined in object Actor. */ def act(): Unit /** - Sends msg to this actor (asynchronous). + * Sends msg to this actor (asynchronous). */ def !(msg: Any): Unit = in ! msg /** - Sends msg to this actor and awaits reply - (synchronous). + * Sends msg to this actor and awaits reply + * (synchronous). */ def !?(msg: Any): Any = in !? msg @@ -397,25 +407,25 @@ trait Actor { } /** - Messages of this type are sent to each actor a - that is linked to an actor b whenever - b terminates and a has - trapExit set to true. - - @author Philipp Haller + * Messages of this type are sent to each actor a + * that is linked to an actor b whenever + * b terminates and a has + * trapExit set to true. + * + * @author Philipp Haller */ case class Exit(from: Actor, reason: String) /** - This class provides an implementation for actors based on - threads. To be able to create instances of this class, the - inherited abstract method act() has to be - implemented. Note that the preferred way of creating - thread-based actors is through the actor method - defined in object Actor. - - @author Philipp Haller + * This class provides an implementation for actors based on + * threads. To be able to create instances of this class, the + * inherited abstract method act() has to be + * implemented. Note that the preferred way of creating + * thread-based actors is through the actor method + * defined in object Actor. + * + * @author Philipp Haller */ abstract class ActorThread extends Thread with ThreadedActor { override def run(): Unit = { @@ -456,10 +466,10 @@ abstract class ActorThread extends Thread with ThreadedActor { } /** - This class provides a dynamic actor proxy for normal Java - threads. - - @author Philipp Haller + * This class provides a dynamic actor proxy for normal Java + * threads. + * + * @author Philipp Haller */ private[actors] class ActorProxy(t: Thread) extends ThreadedActor { def act(): Unit = {} @@ -502,7 +512,7 @@ private[actors] class ActorProxy(t: Thread) extends ThreadedActor {
  actor {
    // ...
-   val c = select(TcpNode("127.0.0.1", 9010), 'myName)
+   val c = select(TcpNode("127.0.0.1", 9010), 'myName)
    c ! msg
    // ...
  }
@@ -517,8 +527,8 @@ object RemoteActor {
   private val kernels = new scala.collection.mutable.HashMap[Actor, NetKernel]
 
   /**
-   Makes self remotely accessible on TCP port
-   port.
+   * Makes self remotely accessible on TCP port
+   * port.
    */
   def alive(port: int): Unit = {
     val serv = new TcpService(port)
@@ -527,8 +537,8 @@ object RemoteActor {
   }
 
   /**
-   Registers a under name on this
-   node.
+   * Registers a under name on this
+   * node.
    */
   def register(name: Symbol, a: Actor): Unit = {
     val kernel = kernels.get(Actor.self) match {
@@ -544,8 +554,8 @@ object RemoteActor {
   }
 
   /**
-   Returns (a proxy for) the actor registered under
-   name on node.
+   * Returns (a proxy for) the actor registered under
+   * name on node.
    */
   def select(node: Node, name: Symbol): Actor =
     new Reactor {
@@ -575,16 +585,24 @@ object RemoteActor {
 
 
 /**
- This class represents a machine node on a TCP network.
-
- @author Philipp Haller
+ * This class represents a machine node on a TCP network.
+ *
+ * @author Philipp Haller
  */
 case class Node(address: String, port: Int)
 
 
 /**
- This class is used by our efficient message queue
- implementation.
+ * 

+ * This class is used by our efficient message queue + * implementation. + *

+ *
+ *
Direct Known Subclasses:
+ *
+ * MessageQueue + *
+ *
*/ private[actors] abstract class MessageQueueResult[Msg] { def msg: Msg @@ -592,12 +610,12 @@ private[actors] abstract class MessageQueueResult[Msg] { } /** - The class MessageQueue provides an efficient - implementation of a message queue specialized for this actor - library. Classes in this package are supposed to be the only - clients of this class. - - @author Martin Odersky, Philipp Haller + * The class MessageQueue provides an efficient + * implementation of a message queue specialized for this actor + * library. Classes in this package are supposed to be the only + * clients of this class. + * + * @author Martin Odersky, Philipp Haller */ private[actors] class MessageQueue[Msg] extends MessageQueueResult[Msg] { var msg: Msg = _ diff --git a/src/actors/scala/actors/Channel.scala b/src/actors/scala/actors/Channel.scala index a7e723f72..0121b97ac 100644 --- a/src/actors/scala/actors/Channel.scala +++ b/src/actors/scala/actors/Channel.scala @@ -1,3 +1,13 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2005-2006, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: $ + package scala.actors import Actor._ @@ -6,8 +16,8 @@ case object TIMEOUT class SuspendActorException extends Throwable { /* - For efficiency reasons we do not fill in - the execution stack trace. + * For efficiency reasons we do not fill in + * the execution stack trace. */ override def fillInStackTrace(): Throwable = { this @@ -15,11 +25,11 @@ class SuspendActorException extends Throwable { } /** - This class provides a means for typed communication among - actors. Only the actor creating an instance of a - Channel may receive from it. - - @author Philipp Haller + * This class provides a means for typed communication among + * actors. Only the actor creating an instance of a + * Channel may receive from it. + * + * @author Philipp Haller */ class Channel[Msg] { @@ -65,13 +75,13 @@ class Channel[Msg] { } /** - Sends msg to this Channel. + * Sends msg to this Channel. */ def !(msg: Msg): unit = send(msg, self) /** - Sends msg to this Channel and - awaits reply. + * Sends msg to this Channel and + * awaits reply. */ def !?(msg: Msg): Any = { self.freshReply() @@ -82,13 +92,13 @@ class Channel[Msg] { } /** - Forwards msg to this keeping the - last sender as sender instead of self. + * Forwards msg to this keeping the + * last sender as sender instead of self. */ def forward(msg: Msg): unit = send(msg, receiver.sender) /** - Receives a message from this Channel. + * Receives a message from this Channel. */ def receive[R](f: PartialFunction[Msg, R]): R = { assert(self == receiver, "receive from channel belonging to other actor") @@ -137,10 +147,10 @@ class Channel[Msg] { } /** - Receives a message from this Channel. If no - message could be received before msec - milliseconds elapsed, the TIMEOUT action is - executed if specified. + * Receives a message from this Channel. If no + * message could be received before msec + * milliseconds elapsed, the TIMEOUT action is + * executed if specified. */ def receiveWithin[R](msec: long)(f: PartialFunction[Any, R]): R = { assert(self == receiver, "receive from channel belonging to other actor") @@ -172,7 +182,7 @@ class Channel[Msg] { } /** - receive for reactors. + * receive for reactors. */ def react(f: PartialFunction[Any, Unit]): Nothing = { assert(self == receiver, "react on channel belonging to other actor") @@ -193,7 +203,7 @@ class Channel[Msg] { } /** - receiveWithin for reactors. + * receiveWithin for reactors. */ def reactWithin(msec: long)(f: PartialFunction[Any, Unit]): Nothing = { assert(self == receiver, "react on channel belonging to other actor") diff --git a/src/actors/scala/actors/Reactor.scala b/src/actors/scala/actors/Reactor.scala index d8cb0d0bb..153220987 100644 --- a/src/actors/scala/actors/Reactor.scala +++ b/src/actors/scala/actors/Reactor.scala @@ -1,13 +1,23 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2005-2006, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: $ + package scala.actors /** - This class provides (together with Channel) an - implementation of event-based actors (aka reactors). - - The main ideas of our approach are explained in the paper
- Event-Based Programming without Inversion of Control, Philipp Haller, Martin Odersky Proc. JMLC 2006 - - @author Philipp Haller + * This class provides (together with Channel) an + * implementation of event-based actors (aka reactors). + * + * The main ideas of our approach are explained in the paper
+ * Event-Based Programming without Inversion of Control, Philipp Haller, Martin Odersky Proc. JMLC 2006 + * + * @author Philipp Haller */ trait Reactor extends Actor { private var lastSender: Actor = null @@ -20,7 +30,7 @@ trait Reactor extends Actor { private[actors] var continuation: PartialFunction[Any, Unit] = null private[actors] var timeoutPending = false - private[actors] def scheduleActor(f: PartialFunction[Any, Unit], msg: Any) = { + private[actors] def scheduleActor(f: PartialFunction[Any, Unit], msg: Any) = if (f == null && continuation == null) { // do nothing (timeout is handled instead) } @@ -30,7 +40,6 @@ trait Reactor extends Actor { msg) Scheduler.execute(task) } - } private[actors] def defaultDetachActor: PartialFunction[Any, Unit] => Unit = (f: PartialFunction[Any, Unit]) => { @@ -48,15 +57,14 @@ trait Reactor extends Actor { resetActor() /** - Starts this reactor. + * Starts this reactor. */ - def start(): Unit = { + def start(): Unit = Scheduler.execute(new StartTask(this)) - } /** - Terminates this reactor, thereby influencing linked actors - (see Actor.exit). + * Terminates this reactor, thereby influencing linked actors + * (see Actor.exit). */ def exit(reason: String): Unit = { exitReason = reason @@ -65,23 +73,23 @@ trait Reactor extends Actor { } /** - The abstract class Reaction associates an instance - of a Reactor with a - java.lang.Runnable. It is also the super class of - the different kinds of tasks used for the execution of - Reactors. - - @author Philipp Haller + * The abstract class Reaction associates an instance + * of a Reactor with a + * java.lang.Runnable. It is also the super class of + * the different kinds of tasks used for the execution of + * Reactors. + * + * @author Philipp Haller */ private[actors] abstract class Reaction extends Runnable { def actor: Reactor } /** - This class represents task items used to start the execution - of Reactors. - - @author Philipp Haller + * This class represents task items used to start the execution + * of Reactors. + * + * @author Philipp Haller */ private[actors] class StartTask(a: Reactor) extends Reaction { def actor = a @@ -100,15 +108,12 @@ private[actors] class StartTask(a: Reactor) extends Reaction { a.exit("normal") } catch { - case _: InterruptedException => { + case _: InterruptedException => a.exitLinked() - } - case d: SuspendActorException => { + case d: SuspendActorException => // do nothing (continuation is already saved) - } - case t: Throwable => { + case t: Throwable => a.exit(t.toString()) - } } finally { Actor.selfs.put(t, saved) @@ -117,11 +122,11 @@ private[actors] class StartTask(a: Reactor) extends Reaction { } /** - This class represents task items used to execute actions - specified in arguments of react and - reactWithin. - - @author Philipp Haller + * This class represents task items used to execute actions + * specified in arguments of react and + * reactWithin. + * + * @author Philipp Haller */ private[actors] class ActorTask(a: Reactor, f: PartialFunction[Any, Unit], @@ -142,13 +147,12 @@ private[actors] class ActorTask(a: Reactor, a.exit("normal") } catch { - case _: InterruptedException => a.exitLinked() - case d: SuspendActorException => { + case _: InterruptedException => + a.exitLinked() + case d: SuspendActorException => // do nothing (continuation is already saved) - } - case t: Throwable => { + case t: Throwable => a.exit(t.toString()) - } } finally { Actor.selfs.put(t, saved) diff --git a/src/actors/scala/actors/Scheduler.scala b/src/actors/scala/actors/Scheduler.scala index 429437a6c..57e04fa7c 100644 --- a/src/actors/scala/actors/Scheduler.scala +++ b/src/actors/scala/actors/Scheduler.scala @@ -1,13 +1,23 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2005-2006, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: $ + package scala.actors -import scala.collection.mutable.{Queue,Buffer,ArrayBuffer} +import scala.collection.mutable.{ArrayBuffer, Buffer, Queue} /** - The Scheduler object is used by - Reactor to execute tasks of an execution of a - reactor. - - @author Philipp Haller + * The Scheduler object is used by + * Reactor to execute tasks of an execution of a + * reactor. + * + * @author Philipp Haller */ object Scheduler { private var sched: IScheduler = @@ -22,18 +32,16 @@ object Scheduler { sched.execute(task) } - def tick(a: Reactor) = { - sched.tick(a) - } + def tick(a: Reactor) = sched.tick(a) def shutdown(): Unit = sched.shutdown() } /** - This abstract class provides a common interface for all - schedulers used to execute reactors. - - @author Philipp Haller + * This abstract class provides a common interface for all + * schedulers used to execute reactors. + * + * @author Philipp Haller */ abstract class IScheduler { def execute(task: Reaction): Unit @@ -50,10 +58,10 @@ abstract class IScheduler { } /** - This scheduler executes the tasks of a reactor on a single - thread (the current thread). - - @author Philipp Haller + * This scheduler executes the tasks of a reactor on a single + * thread (the current thread). + * + * @author Philipp Haller */ class SingleThreadedScheduler extends IScheduler { def execute(task: Reaction): Unit = { @@ -69,10 +77,10 @@ class SingleThreadedScheduler extends IScheduler { } /** - This scheduler creates additional threads whenever there is no - idle thread available. - - @author Philipp Haller + * This scheduler creates additional threads whenever there is no + * idle thread available. + * + * @author Philipp Haller */ class SpareWorkerScheduler extends IScheduler { private val tasks = new Queue[Reaction] @@ -82,7 +90,7 @@ class SpareWorkerScheduler extends IScheduler { private var maxWorkers = 2 def init() = { - for (val i <- List.range(0, 2)) { + for (val i <- 0 until 2) { val worker = new WorkerThread(this) workers += worker worker.start() @@ -121,7 +129,7 @@ class SpareWorkerScheduler extends IScheduler { def shutdown(): Unit = synchronized { terminating = true val numNonIdle = workers.length - idle.length - for (val i <- List.range(0, numNonIdle)) + for (val i <- 0 until numNonIdle) tasks += QUIT_TASK val idleThreads = idle.elements while (idleThreads.hasNext) { @@ -133,10 +141,10 @@ class SpareWorkerScheduler extends IScheduler { } /** - This class is used by schedulers to execute reactor tasks on - multiple threads. - - @author Philipp Haller + * This class is used by schedulers to execute reactor tasks on + * multiple threads. + * + * @author Philipp Haller */ class WorkerThread(sched: IScheduler) extends Thread { private var task: Runnable = null @@ -150,9 +158,7 @@ class WorkerThread(sched: IScheduler) extends Thread { override def run(): Unit = synchronized { try { while (running) { - if (task != null) { - task.run() - } + if (task != null) task.run() task = sched.getTask(this) if (task == sched.QUIT_TASK) { running = false diff --git a/src/actors/scala/actors/ThreadedActor.scala b/src/actors/scala/actors/ThreadedActor.scala index 2e3e8ecc2..3a0f49c82 100644 --- a/src/actors/scala/actors/ThreadedActor.scala +++ b/src/actors/scala/actors/ThreadedActor.scala @@ -1,3 +1,13 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2005-2006, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: $ + package scala.actors /** diff --git a/src/actors/scala/actors/TimerThread.scala b/src/actors/scala/actors/TimerThread.scala index 205789415..33b24ca74 100644 --- a/src/actors/scala/actors/TimerThread.scala +++ b/src/actors/scala/actors/TimerThread.scala @@ -1,9 +1,19 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2005-2006, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: $ + package scala.actors /** * This class allows the (local) sending of a message to an actor after - * a timeout. Used by the library to build receiveWithin(time: long). - * Note that the library deletes non-received TIMEOUT message if a + * a timeout. Used by the library to build receiveWithin(time: long). + * Note that the library deletes non-received TIMEOUT message if a * message is received before the time-out occurs. * * @author Sebastien Noir diff --git a/src/actors/scala/actors/remote/FreshNameCreator.scala b/src/actors/scala/actors/remote/FreshNameCreator.scala index 2e30c69f1..f832c23b7 100644 --- a/src/actors/scala/actors/remote/FreshNameCreator.scala +++ b/src/actors/scala/actors/remote/FreshNameCreator.scala @@ -1,3 +1,13 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2005-2006, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: $ + package scala.actors.remote object FreshNameCreator { diff --git a/src/actors/scala/actors/remote/JavaSerializer.scala b/src/actors/scala/actors/remote/JavaSerializer.scala index 94dabc3b4..7dd6f09c2 100644 --- a/src/actors/scala/actors/remote/JavaSerializer.scala +++ b/src/actors/scala/actors/remote/JavaSerializer.scala @@ -1,8 +1,20 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2005-2006, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: $ + package scala.actors.remote -import java.io.{ByteArrayInputStream,ByteArrayOutputStream,ObjectInputStream,ObjectOutputStream} +import java.io.{ByteArrayInputStream, ByteArrayOutputStream, + ObjectInputStream, ObjectOutputStream} class JavaSerializer(serv: Service) extends Serializer(serv) { + def serialize(o: AnyRef): Array[Byte] = { val bos = new ByteArrayOutputStream() val out = new ObjectOutputStream(bos) diff --git a/src/actors/scala/actors/remote/NetKernel.scala b/src/actors/scala/actors/remote/NetKernel.scala index 19d6f81f6..5209ae406 100644 --- a/src/actors/scala/actors/remote/NetKernel.scala +++ b/src/actors/scala/actors/remote/NetKernel.scala @@ -1,8 +1,16 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2005-2006, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: $ + package scala.actors.remote -import java.io.{IOException,StringReader,StringWriter} -import java.net.UnknownHostException -import scala.collection.mutable.{HashMap,HashSet} +import scala.collection.mutable.{HashMap, HashSet} case class NamedSend(senderName: Symbol, receiver: Symbol, data: Array[Byte]) @@ -25,7 +33,8 @@ class NetKernel(service: Service) { register(freshName, Actor.self) freshName } - case Some(name) => name + case Some(name) => + name } namedSend(node, senderName, name, msg) } @@ -40,9 +49,8 @@ class NetKernel(service: Service) { def act() = { a ! msg } override def !(msg: Any): Unit = { msg match { - case refmsg: AnyRef => { + case refmsg: AnyRef => namedSend(senderNode, receiver, senderName, refmsg) - } } } override def !?(msg: Any): Any = @@ -50,7 +58,8 @@ class NetKernel(service: Service) { } senderProxy.start() } - case None => // message is lost + case None => + // message is lost } } } diff --git a/src/actors/scala/actors/remote/Serializer.scala b/src/actors/scala/actors/remote/Serializer.scala index f68fdce26..c4f5dc680 100644 --- a/src/actors/scala/actors/remote/Serializer.scala +++ b/src/actors/scala/actors/remote/Serializer.scala @@ -1,6 +1,16 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2005-2006, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: $ + package scala.actors.remote -import java.io.{DataInputStream,DataOutputStream,EOFException,IOException} +import java.io.{DataInputStream, DataOutputStream, EOFException, IOException} abstract class Serializer(val service: Service) { def serialize(o: AnyRef): Array[byte] diff --git a/src/actors/scala/actors/remote/Service.scala b/src/actors/scala/actors/remote/Service.scala index a9ccb3240..6b32cd1d8 100644 --- a/src/actors/scala/actors/remote/Service.scala +++ b/src/actors/scala/actors/remote/Service.scala @@ -1,3 +1,13 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2005-2006, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: $ + package scala.actors.remote trait Service { diff --git a/src/actors/scala/actors/remote/TcpService.scala b/src/actors/scala/actors/remote/TcpService.scala index 0237cc0e9..715749dd9 100644 --- a/src/actors/scala/actors/remote/TcpService.scala +++ b/src/actors/scala/actors/remote/TcpService.scala @@ -1,8 +1,19 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2005-2006, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: $ + package scala.actors.remote -import java.io.{DataInputStream,DataOutputStream,BufferedReader,PrintWriter, - IOException,InputStreamReader,OutputStreamWriter} -import java.net.{InetAddress,ServerSocket,Socket,UnknownHostException} +import java.io.{BufferedReader, DataInputStream, DataOutputStream, + IOException, InputStreamReader, OutputStreamWriter, + PrintWriter} +import java.net.{InetAddress, ServerSocket, Socket, UnknownHostException} object TcpService { val random = new java.util.Random(System.currentTimeMillis()) diff --git a/src/compiler/scala/tools/nsc/SubComponent.scala b/src/compiler/scala/tools/nsc/SubComponent.scala index 28fb6c1be..6d0140d60 100644 --- a/src/compiler/scala/tools/nsc/SubComponent.scala +++ b/src/compiler/scala/tools/nsc/SubComponent.scala @@ -1,29 +1,40 @@ -/* NSC -- new scala compiler - * Copyright 2005 LAMP/EPFL +/* NSC -- new Scala compiler + * Copyright 2005-2006 LAMP/EPFL * @author Martin Odersky */ // $Id$ -package scala.tools.nsc; -/** An nsc sub-component. +package scala.tools.nsc + +/**

+ * An nsc sub-component. + *

+ *
+ *
Direct Known Subclasses:
+ *
+ * Transform + *
+ *
+ * + * @author Martin Odersky */ abstract class SubComponent { /** The global environment; overridden by instantiation in Global. */ - val global: Global; + val global: Global /** The name of the phase */ - val phaseName: String; + val phaseName: String /** New flags defined by the phase which are not valid before */ - def phaseNewFlags: long = 0; + def phaseNewFlags: long = 0 /** The phase factory */ - def newPhase(prev: Phase): Phase; + def newPhase(prev: Phase): Phase /** A standard phase template */ abstract class StdPhase(prev: Phase) extends global.GlobalPhase(prev) { - def name = phaseName; - override def newFlags = phaseNewFlags; + def name = phaseName + override def newFlags = phaseNewFlags } } diff --git a/src/compiler/scala/tools/nsc/ast/TreePrinters.scala b/src/compiler/scala/tools/nsc/ast/TreePrinters.scala index 3ea4546de..88eb0c51f 100644 --- a/src/compiler/scala/tools/nsc/ast/TreePrinters.scala +++ b/src/compiler/scala/tools/nsc/ast/TreePrinters.scala @@ -111,7 +111,7 @@ abstract class TreePrinters { case Triple(tp, args, nvPairs) => str.append(tp.toString()) if (!args.isEmpty) - str.append(args.mkString("(", ",", ")")) + str.append(args.map(.escapedStringValue).mkString("(", ",", ")")) if (!nvPairs.isEmpty) for (val Pair(Pair(name, value), index) <- nvPairs.zipWithIndex) { if (index > 0) diff --git a/src/compiler/scala/tools/nsc/ast/parser/Tokens.scala b/src/compiler/scala/tools/nsc/ast/parser/Tokens.scala index 648ef0461..7aaae5e07 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Tokens.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Tokens.scala @@ -1,98 +1,99 @@ -/* NSC -- new scala compiler - * Copyright 2005 LAMP/EPFL +/* NSC -- new Scala compiler + * Copyright 2005-2006 LAMP/EPFL * @author Martin Odersky */ // $Id$ -package scala.tools.nsc.ast.parser; + +package scala.tools.nsc.ast.parser object Tokens { /** special tokens */ - final val EMPTY = -3; - final val UNDEF = -2; - final val ERROR = -1; - final val EOF = 0; + final val EMPTY = -3 + final val UNDEF = -2 + final val ERROR = -1 + final val EOF = 0 /** literals */ - final val CHARLIT = 1; - final val INTLIT = 2; - final val LONGLIT = 3; - final val FLOATLIT = 4; - final val DOUBLELIT = 5; - final val STRINGLIT = 6; - final val SYMBOLLIT = 7; + final val CHARLIT = 1 + final val INTLIT = 2 + final val LONGLIT = 3 + final val FLOATLIT = 4 + final val DOUBLELIT = 5 + final val STRINGLIT = 6 + final val SYMBOLLIT = 7 /** identifiers */ - final val IDENTIFIER = 10; - final val BACKQUOTED_IDENT = 11; + final val IDENTIFIER = 10 + final val BACKQUOTED_IDENT = 11 /** keywords */ - final val IF = 20; - final val FOR = 21; - final val ELSE = 22; - final val THIS = 23; - final val NULL = 24; - final val NEW = 25; - final val WITH = 26; - final val SUPER = 27; - final val CASE = 28; - final val CASECLASS = 29; - final val CASEOBJECT = 30; - final val VAL = 31; - final val ABSTRACT = 32; - final val FINAL = 33; - final val PRIVATE = 34; - final val PROTECTED = 35; - final val OVERRIDE = 36; - final val IMPLICIT = 37; - final val VAR = 38; - final val DEF = 39; - final val TYPE = 40; - final val EXTENDS = 41; - final val TRUE = 42; - final val FALSE = 43; - final val OBJECT = 44; - final val CLASS = 45; + final val IF = 20 + final val FOR = 21 + final val ELSE = 22 + final val THIS = 23 + final val NULL = 24 + final val NEW = 25 + final val WITH = 26 + final val SUPER = 27 + final val CASE = 28 + final val CASECLASS = 29 + final val CASEOBJECT = 30 + final val VAL = 31 + final val ABSTRACT = 32 + final val FINAL = 33 + final val PRIVATE = 34 + final val PROTECTED = 35 + final val OVERRIDE = 36 + final val IMPLICIT = 37 + final val VAR = 38 + final val DEF = 39 + final val TYPE = 40 + final val EXTENDS = 41 + final val TRUE = 42 + final val FALSE = 43 + final val OBJECT = 44 + final val CLASS = 45 - final val IMPORT = 46; - final val PACKAGE = 47; - final val YIELD = 48; - final val DO = 49; - final val TRAIT = 50; - final val SEALED = 51; - final val THROW = 52; - final val TRY = 53; - final val CATCH = 54; - final val FINALLY = 55; - final val WHILE = 56; - final val RETURN = 57; - final val MATCH = 58; - final val REQUIRES = 59; + final val IMPORT = 46 + final val PACKAGE = 47 + final val YIELD = 48 + final val DO = 49 + final val TRAIT = 50 + final val SEALED = 51 + final val THROW = 52 + final val TRY = 53 + final val CATCH = 54 + final val FINALLY = 55 + final val WHILE = 56 + final val RETURN = 57 + final val MATCH = 58 + final val REQUIRES = 59 /** special symbols */ - final val COMMA = 61; - final val SEMI = 62; - final val DOT = 63; - final val USCORE = 64; - final val COLON = 65; - final val EQUALS = 66; - final val LARROW = 67; - final val ARROW = 68; - final val NEWLINE = 69; - final val SUBTYPE = 70; - final val SUPERTYPE = 71; - final val HASH = 72; - final val AT = 73; - final val VIEWBOUND = 74; + final val COMMA = 61 + final val SEMI = 62 + final val DOT = 63 + final val USCORE = 64 + final val COLON = 65 + final val EQUALS = 66 + final val LARROW = 67 + final val ARROW = 68 + final val NEWLINE = 69 + final val SUBTYPE = 70 + final val SUPERTYPE = 71 + final val HASH = 72 + final val AT = 73 + final val VIEWBOUND = 74 /** parenthesis */ - final val LPAREN = 90; - final val RPAREN = 91; - final val LBRACKET = 92; - final val RBRACKET = 93; - final val LBRACE = 94; - final val RBRACE = 95; + final val LPAREN = 90 + final val RPAREN = 91 + final val LBRACKET = 92 + final val RBRACKET = 93 + final val LBRACE = 94 + final val RBRACE = 95 /** XML mode */ - final val XMLSTART = 96; + final val XMLSTART = 96 } diff --git a/src/compiler/scala/tools/nsc/doc/DocGenerator.scala b/src/compiler/scala/tools/nsc/doc/DocGenerator.scala index 7d92887d8..10044f2a1 100644 --- a/src/compiler/scala/tools/nsc/doc/DocGenerator.scala +++ b/src/compiler/scala/tools/nsc/doc/DocGenerator.scala @@ -251,7 +251,7 @@ abstract class DocGenerator extends Models { val Triple(tpe, args, nvPairs) = attr val name = aref(urlFor(tpe.symbol), contentFrame, tpe.toString) if (!args.isEmpty) - buf.append(args.mkString("(", ",", ")")) + buf.append(args.map(.escapedStringValue).mkString("(", ",", ")")) if (!nvPairs.isEmpty) for (val Pair(Pair(name, value), index) <- nvPairs.zipWithIndex) { if (index > 0) @@ -263,7 +263,7 @@ abstract class DocGenerator extends Models { var res: NodeSeq = Text("[") val attrs = tree.symbol.attributes for (val i <- attrs.indices) { - if (i > 0) res = res.concat(Text(",")) + if (i > 0) res = res.concat(Text("," + LINE_SEPARATOR)) res = res.concat(attrFor(attrs(i))) } br(res.concat(Text("]"))) diff --git a/src/compiler/scala/tools/nsc/doc/style.css b/src/compiler/scala/tools/nsc/doc/style.css index 5fecb9014..b05acc5f5 100644 --- a/src/compiler/scala/tools/nsc/doc/style.css +++ b/src/compiler/scala/tools/nsc/doc/style.css @@ -40,6 +40,14 @@ div.page-title { text-align: center; } +dl.subclasses { + margin:0 0 0 -20px; +} + +dl.subclasses dd { + margin:0 0 0 20px; +} + span.entity { color: #ff6666; } diff --git a/src/compiler/scala/tools/nsc/symtab/Constants.scala b/src/compiler/scala/tools/nsc/symtab/Constants.scala index 28613d4a9..b708d922a 100644 --- a/src/compiler/scala/tools/nsc/symtab/Constants.scala +++ b/src/compiler/scala/tools/nsc/symtab/Constants.scala @@ -205,7 +205,7 @@ trait Constants requires SymbolTable { tag match { case NullTag => "null" case StringTag => "\"" + escape(stringValue) + "\"" - case ClassTag => signature(typeValue) + ".class" + case ClassTag => "classOf[" + signature(typeValue) + "]" case CharTag => escape("\'" + charValue + "\'") case LongTag => longValue.toString() + "L" case _ => value.toString() diff --git a/src/compiler/scala/tools/nsc/symtab/Names.scala b/src/compiler/scala/tools/nsc/symtab/Names.scala index 1a78f6aef..5e1687322 100644 --- a/src/compiler/scala/tools/nsc/symtab/Names.scala +++ b/src/compiler/scala/tools/nsc/symtab/Names.scala @@ -9,6 +9,16 @@ package scala.tools.nsc.symtab import scala.tools.nsc.util.NameTransformer import scala.tools.util.UTF8Codec +/**

+ * The class Names ... + *

+ *
+ *
Direct Known Subclasses:
+ *
+ * SymbolTable + *
+ *
+ */ class Names { // Operations ------------------------------------------------------------- @@ -119,7 +129,7 @@ class Names { // Classes ---------------------------------------------------------------------- - /** The name class */ + /** The name class. */ abstract class Name(index: int, len: int) extends Function1[int, char] { /** Index into name table */ diff --git a/src/compiler/scala/tools/nsc/transform/InfoTransform.scala b/src/compiler/scala/tools/nsc/transform/InfoTransform.scala index c2ed18cf4..3e30b2627 100644 --- a/src/compiler/scala/tools/nsc/transform/InfoTransform.scala +++ b/src/compiler/scala/tools/nsc/transform/InfoTransform.scala @@ -6,8 +6,21 @@ package scala.tools.nsc.transform -/** A base class for transforms. - * A transform contains a compiler phase which applies a tree transformer. +/**

+ * A base class for transforms. + * A transform contains a compiler phase which applies a tree transformer. + *

+ *
+ *
Direct Known Subclasses:
+ *
+ * AddInterfaces, + * ExplicitOuter, + * Flatten, + * LambdaLift, + * Mixin, + * UnCurry + *
+ *
*/ abstract class InfoTransform extends Transform { import global.{Symbol, Type, InfoTransformer, infoTransformers} diff --git a/src/compiler/scala/tools/nsc/transform/Transform.scala b/src/compiler/scala/tools/nsc/transform/Transform.scala index 517719f60..e74c03d3d 100644 --- a/src/compiler/scala/tools/nsc/transform/Transform.scala +++ b/src/compiler/scala/tools/nsc/transform/Transform.scala @@ -6,8 +6,21 @@ package scala.tools.nsc.transform; -/** A base class for transforms. - * A transform contains a compiler phase which applies a tree transformer. +/**

+ * A base class for transforms. + * A transform contains a compiler phase which applies a tree transformer. + *

+ *
+ *
Direct Known Subclasses:
+ *
+ * CleanUp, + * Constructors, + * InfoTransform, + * LiftCode, + * SampleTransform, + * TailCalls + *
+ *
* * @author Martin Odersky * @version 1.0 diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala index 363c2ebd7..b569fe3be 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala @@ -1,6 +1,6 @@ /* NSC -- new Scala compiler * Copyright 2005-2006 LAMP/EPFL - * @author + * @author Martin Odersky */ // $Id$ @@ -10,20 +10,34 @@ import symtab.Flags._ import util.FreshNameCreator import scala.collection.mutable.ListBuffer -/** - * - caseArity, caseElement implementations added to case classes - * - equals, and hashCode and toString methods are added to case classes, - * unless they are defined in the class or a baseclass - * different from java.lang.Object - * - toString method is added to case objects, - * unless they are defined in the class or a baseclass - * different from java.lang.Object -*/ +/** + */ trait SyntheticMethods requires Analyzer { import global._ // the global environment import definitions._ // standard classes and methods import typer.{typed} // methods to type trees + /** + * @param templ ... + * @param clazz ... + * @param unit ... + * @return ... + */ def addSyntheticMethods(templ: Template, clazz: Symbol, unit: CompilationUnit): Template = { def hasImplementation(name: Name): Boolean = { diff --git a/src/compiler/scala/tools/nsc/util/Set.scala b/src/compiler/scala/tools/nsc/util/Set.scala index 26305972d..618497e9c 100644 --- a/src/compiler/scala/tools/nsc/util/Set.scala +++ b/src/compiler/scala/tools/nsc/util/Set.scala @@ -6,7 +6,15 @@ package scala.tools.nsc.util -/** A common class for lightweight sets. +/**

+ * A common class for lightweight sets. + *

+ *
+ *
Direct Known Subclasses:
+ *
+ * HashSet + *
+ *
*/ abstract class Set[T <: AnyRef] { diff --git a/src/compiler/scala/tools/nsc/util/SourceFile.scala b/src/compiler/scala/tools/nsc/util/SourceFile.scala index 602fa5e5d..fb61e9068 100644 --- a/src/compiler/scala/tools/nsc/util/SourceFile.scala +++ b/src/compiler/scala/tools/nsc/util/SourceFile.scala @@ -13,11 +13,6 @@ package scala.tools.nsc.util import scala.tools.nsc.io.{AbstractFile, VirtualFile} -/** Uses positions that are offsets rather than line/column pairs. - * - * @author Sean McDirmid - * @version 1.0 - */ object SourceFile { val LF: Char = 0x0A val FF: Char = 0x0C @@ -26,7 +21,20 @@ object SourceFile { def isLineBreak(c: Char) = c == LF || c == FF || c == CR || c == SU } - +/**

+ * Uses positions that are offsets rather than line/column pairs. + *

+ *
+ *
Direct Known Subclasses:
+ *
+ * CompoundSourceFile, + * SourceFileFragment + *
+ *
+ * + * @author Sean McDirmid + * @version 1.0 + */ class SourceFile(val file: AbstractFile, _content: Array[Char]) { import SourceFile._ @@ -53,7 +61,8 @@ class SourceFile(val file: AbstractFile, _content: Array[Char]) { new Position(this, lineToOffset(line) + column) /** Map a position to a position in the underlying source file. - * For regular source files, simply return the argument. */ + * For regular source files, simply return the argument. + */ def positionInUltimateSource(position: Position) = position // constants @@ -141,7 +150,11 @@ class SourceFile(val file: AbstractFile, _content: Array[Char]) { } } -/** A source file composed of multiple other source files. */ +/** A source file composed of multiple other source files. + * + * @author Sean McDirmid + * @version 1.0 + */ class CompoundSourceFile( name: String, components: List[SourceFile], @@ -149,7 +162,11 @@ class CompoundSourceFile( extends SourceFile(name, contents) { /** The usual constructor. Specify a name for the compound file and - * a list of component sources */ + * a list of component sources. + * + * @param name ... + * @param components ... + */ def this(name: String, components: SourceFile*) = { /* Note that the contents leaves off the final SU character * of all components */ diff --git a/src/library/scala/collection/BitSet.scala b/src/library/scala/collection/BitSet.scala index 701af8d9a..7feb84c0b 100644 --- a/src/library/scala/collection/BitSet.scala +++ b/src/library/scala/collection/BitSet.scala @@ -12,10 +12,17 @@ package scala.collection -/** - * The class BitSet provides the interface for a space-efficient - * implementation of dense integer sets represented as bits in array of - * integers. Bit indices are between 0..(capacity-1) inclusive. +/**

+ * The class BitSet provides the interface for a space-efficient + * implementation of dense integer sets represented as bits in array of + * integers. Bit indices are between 0..(capacity-1) inclusive. + *

+ *
+ *
Direct Known Subclasses:
+ *
+ * BitSet + *
+ *
* * @author Burak Emir, Stephane Micheloud, Nikolay Mihaylov * @version 1.1 diff --git a/src/library/scala/collection/immutable/BitSet.scala b/src/library/scala/collection/immutable/BitSet.scala index f9c3f1f49..2e16c6832 100644 --- a/src/library/scala/collection/immutable/BitSet.scala +++ b/src/library/scala/collection/immutable/BitSet.scala @@ -16,10 +16,12 @@ package scala.collection.immutable * int array. Instances can conveniently be created from instances of * Bit indices are between 0..(capacity-1) inclusive * - * @param size represents the number of relevant bits - * @param ba array of ints of length n>>>5 - * @param copy if yes, then ba is copied and updates will - * not affect this bitset + * @param size size represents the number of relevant bits + * @param capacity ... + * @param ba ba array of ints of length + * n>>>5 + * @param copy copy if yes, then ba is copied + * and updates will not affect this bitset * * @author Burak Emir, Nikolay Mihaylov * @version 1.0 diff --git a/src/library/scala/io/Position.scala b/src/library/scala/io/Position.scala index cd08fee7d..bcbd65e67 100644 --- a/src/library/scala/io/Position.scala +++ b/src/library/scala/io/Position.scala @@ -13,23 +13,36 @@ package scala.io import compat.StringBuilder -/** convenience methods to encode line and column number in one - * single integer. The encode line (column) - * numbers range from 0 to LINE_MASK (COLUMN_MASK), where 0 indicates - * that the line (column) is the undefined and 1 represents the first - * line (column). Line (Column) numbers greater than LINE_MASK - * (COLUMN_MASK) are replaced by LINE_MASK (COLUMN_MASK). Furthermore, - * if the encoded line number is LINE_MASK, the column number is - * always set to 0. - - * The following properties hold: - * - the undefined position is 0: encode(0,0) == 0 - * - encodings are non-negative : encode(line,column) >= 0 - * - position order is preserved: - * (line1 < line2) || (line1 == line2 && column1 < column2) - * implies - * encode(line1,column1) <= encode(line2,column2) - * @author Burak Emir (translated from work by Matthias Zengers and others) +/**

+ * The object Position provides convenience methods to encode + * line and column number in one single integer. The encode line (column) + * numbers range from 0 to LINE_MASK + * (COLUMN_MASK), where 0 indicates that the line (column) is + * the undefined and 1 represents the first line (column). Line (Column) + * numbers greater than LINE_MASK + * (COLUMN_MASK) are replaced by LINE_MASK + * (COLUMN_MASK). Furthermore, if the encoded line number is + * LINE_MASK, the column number is always set to 0. + *

+ *

+ * The following properties hold: + *

+ * + * + * @author Burak Emir (translated from work by Matthias Zenger and others) */ object Position {