Skip to content

Instantly share code, notes, and snippets.

@xuwei-k
Created August 6, 2014 04:43
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save xuwei-k/b5719c601df3f6a8dbb9 to your computer and use it in GitHub Desktop.
libraryDependencies += "com.typesafe.akka" %% "akka-actor" % "2.3.4"
scalaVersion := "2.11.2"
scalacOptions += "-Xprint:jvm"
import akka.actor._
case class Foo(a: Int => Int) extends Actor{
override def receive = ???
}
class Bar extends Actor{
val b = util.Random.nextInt
override def receive = {
case message =>
val child = context.actorOf(Props(classOf[Foo], { c: Int => c + b }))
}
}
[[syntax trees at end of jvm]] // Main.scala
package <empty> {
case class Foo extends Object with akka.actor.Actor with Product with Serializable {
implicit <stable> <accessor> def context(): akka.actor.ActorContext = Foo.this.context;
private[this] val context: akka.actor.ActorContext = _;
final implicit <stable> <accessor> def self(): akka.actor.ActorRef = Foo.this.self;
private[this] val self: akka.actor.ActorRef = _;
<accessor> def akka$actor$Actor$_setter_$context_=(x$1: akka.actor.ActorContext): Unit = {
Foo.this.context = x$1;
()
};
final <accessor> def akka$actor$Actor$_setter_$self_=(x$1: akka.actor.ActorRef): Unit = {
Foo.this.self = x$1;
()
};
final def sender(): akka.actor.ActorRef = akka.actor.Actor$class.sender(Foo.this);
private[akka] def aroundReceive(receive: PartialFunction, msg: Object): Unit = akka.actor.Actor$class.aroundReceive(Foo.this, receive, msg);
private[akka] def aroundPreStart(): Unit = akka.actor.Actor$class.aroundPreStart(Foo.this);
private[akka] def aroundPostStop(): Unit = akka.actor.Actor$class.aroundPostStop(Foo.this);
private[akka] def aroundPreRestart(reason: Throwable, message: Option): Unit = akka.actor.Actor$class.aroundPreRestart(Foo.this, reason, message);
private[akka] def aroundPostRestart(reason: Throwable): Unit = akka.actor.Actor$class.aroundPostRestart(Foo.this, reason);
def supervisorStrategy(): akka.actor.SupervisorStrategy = akka.actor.Actor$class.supervisorStrategy(Foo.this);
@throws[Exception](classOf[java.lang.Exception]) def preStart(): Unit = akka.actor.Actor$class.preStart(Foo.this);
@throws[Exception](classOf[java.lang.Exception]) def postStop(): Unit = akka.actor.Actor$class.postStop(Foo.this);
@throws[Exception](classOf[java.lang.Exception]) def preRestart(reason: Throwable, message: Option): Unit = akka.actor.Actor$class.preRestart(Foo.this, reason, message);
@throws[Exception](classOf[java.lang.Exception]) def postRestart(reason: Throwable): Unit = akka.actor.Actor$class.postRestart(Foo.this, reason);
def unhandled(message: Object): Unit = akka.actor.Actor$class.unhandled(Foo.this, message);
<caseaccessor> <paramaccessor> private[this] val a: Function1 = _;
<stable> <caseaccessor> <accessor> <paramaccessor> def a(): Function1 = Foo.this.a;
override def receive(): Nothing = scala.this.Predef.???();
<synthetic> def copy(a: Function1): Foo = new Foo(a);
<synthetic> def copy$default$1(): Function1 = Foo.this.a();
override <synthetic> def productPrefix(): String = "Foo";
<synthetic> def productArity(): Int = 1;
<synthetic> def productElement(x$1: Int): Object = {
case <synthetic> val x1: Int = x$1;
(x1: Int) match {
case 0 => Foo.this.a()
case _ => throw new IndexOutOfBoundsException(scala.Int.box(x$1).toString())
}
};
override <synthetic> def productIterator(): Iterator = runtime.this.ScalaRunTime.typedProductIterator(Foo.this);
<synthetic> def canEqual(x$1: Object): Boolean = x$1.$isInstanceOf[Foo]();
override <synthetic> def hashCode(): Int = ScalaRunTime.this._hashCode(Foo.this);
override <synthetic> def toString(): String = ScalaRunTime.this._toString(Foo.this);
override <synthetic> def equals(x$1: Object): Boolean = Foo.this.eq(x$1).||({
case <synthetic> val x1: Object = x$1;
case5(){
if (x1.$isInstanceOf[Foo]())
matchEnd4(true)
else
case6()
};
case6(){
matchEnd4(false)
};
matchEnd4(x: Boolean){
x
}
}.&&({
<synthetic> val Foo$1: Foo = x$1.$asInstanceOf[Foo]();
Foo.this.a().==(Foo$1.a()).&&(Foo$1.canEqual(Foo.this))
}));
override <bridge> <artifact> def receive(): PartialFunction = Foo.this.receive();
def <init>(a: Function1): Foo = {
Foo.this.a = a;
Foo.super.<init>();
akka.actor.Actor$class./*Actor$class*/$init$(Foo.this);
scala.Product$class./*Product$class*/$init$(Foo.this);
()
}
};
<synthetic> object Foo extends scala.runtime.AbstractFunction1 with Serializable {
final override <synthetic> def toString(): String = "Foo";
case <synthetic> def apply(a: Function1): Foo = new Foo(a);
case <synthetic> def unapply(x$0: Foo): Option = if (x$0.==(null))
scala.this.None
else
new Some(x$0.a());
<synthetic> private def readResolve(): Object = Foo;
case <synthetic> <bridge> <artifact> def apply(v1: Object): Object = Foo.this.apply(v1.$asInstanceOf[Function1]());
def <init>(): Foo.type = {
Foo.super.<init>();
()
}
};
class Bar extends Object with akka.actor.Actor {
implicit <stable> <accessor> def context(): akka.actor.ActorContext = Bar.this.context;
private[this] val context: akka.actor.ActorContext = _;
final implicit <stable> <accessor> def self(): akka.actor.ActorRef = Bar.this.self;
private[this] val self: akka.actor.ActorRef = _;
<accessor> def akka$actor$Actor$_setter_$context_=(x$1: akka.actor.ActorContext): Unit = {
Bar.this.context = x$1;
()
};
final <accessor> def akka$actor$Actor$_setter_$self_=(x$1: akka.actor.ActorRef): Unit = {
Bar.this.self = x$1;
()
};
final def sender(): akka.actor.ActorRef = akka.actor.Actor$class.sender(Bar.this);
private[akka] def aroundReceive(receive: PartialFunction, msg: Object): Unit = akka.actor.Actor$class.aroundReceive(Bar.this, receive, msg);
private[akka] def aroundPreStart(): Unit = akka.actor.Actor$class.aroundPreStart(Bar.this);
private[akka] def aroundPostStop(): Unit = akka.actor.Actor$class.aroundPostStop(Bar.this);
private[akka] def aroundPreRestart(reason: Throwable, message: Option): Unit = akka.actor.Actor$class.aroundPreRestart(Bar.this, reason, message);
private[akka] def aroundPostRestart(reason: Throwable): Unit = akka.actor.Actor$class.aroundPostRestart(Bar.this, reason);
def supervisorStrategy(): akka.actor.SupervisorStrategy = akka.actor.Actor$class.supervisorStrategy(Bar.this);
@throws[Exception](classOf[java.lang.Exception]) def preStart(): Unit = akka.actor.Actor$class.preStart(Bar.this);
@throws[Exception](classOf[java.lang.Exception]) def postStop(): Unit = akka.actor.Actor$class.postStop(Bar.this);
@throws[Exception](classOf[java.lang.Exception]) def preRestart(reason: Throwable, message: Option): Unit = akka.actor.Actor$class.preRestart(Bar.this, reason, message);
@throws[Exception](classOf[java.lang.Exception]) def postRestart(reason: Throwable): Unit = akka.actor.Actor$class.postRestart(Bar.this, reason);
def unhandled(message: Object): Unit = akka.actor.Actor$class.unhandled(Bar.this, message);
private[this] val b: Int = _;
<stable> <accessor> def b(): Int = Bar.this.b;
override def receive(): PartialFunction = ({
new <$anon: Function1>(Bar.this)
}: PartialFunction);
def <init>(): Bar = {
Bar.super.<init>();
akka.actor.Actor$class./*Actor$class*/$init$(Bar.this);
Bar.this.b = scala.util.Random.nextInt();
()
}
};
@SerialVersionUID(0) final <synthetic> class $anonfun$receive$1 extends scala.runtime.AbstractPartialFunction with Serializable {
final override def applyOrElse(x1: Object, default: Function1): Object = {
case <synthetic> val x1: Object = (((x1: Object): Object): Object);
case4(){
matchEnd3({
val child: akka.actor.ActorRef = $anonfun$receive$1.this.$outer.context().actorOf(akka.actor.Props.apply(classOf[Foo], scala.this.Predef.genericWrapArray(Array[Object]{{
(new <$anon: Function1>($anonfun$receive$1.this): Function1)
}})));
scala.runtime.BoxedUnit.UNIT
})
};
matchEnd3(x: Object){
x
}
};
final def isDefinedAt(x1: Object): Boolean = {
case <synthetic> val x1: Object = (((x1: Object): Object): Object);
case4(){
matchEnd3(true)
};
matchEnd3(x: Boolean){
x
}
};
<synthetic> <paramaccessor> <artifact> private[this] val $outer: Bar = _;
<synthetic> <stable> <artifact> def $outer(): Bar = $anonfun$receive$1.this.$outer;
def <init>($outer: Bar): <$anon: Function1> = {
if ($outer.eq(null))
throw null
else
$anonfun$receive$1.this.$outer = $outer;
$anonfun$receive$1.super.<init>();
()
}
};
@SerialVersionUID(0) final <synthetic> class $anonfun$1 extends scala.runtime.AbstractFunction1$mcII$sp with Serializable {
final def apply(c: Int): Int = $anonfun$1.this.apply$mcII$sp(c);
<specialized> def apply$mcII$sp(c: Int): Int = c.+($anonfun$1.this.$outer.$outer().b());
<synthetic> <paramaccessor> <artifact> private[this] val $outer: <$anon: Function1> = _;
final <bridge> <artifact> def apply(v1: Object): Object = scala.Int.box($anonfun$1.this.apply(scala.Int.unbox(v1)));
def <init>($outer: <$anon: Function1>): <$anon: Function1> = {
if ($outer.eq(null))
throw null
else
$anonfun$1.this.$outer = $outer;
$anonfun$1.super.<init>();
()
}
}
}
[success] Total time: 5 s, completed 2014/08/06 13:42:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment