Skip to content

Instantly share code, notes, and snippets.

View xeno-by's full-sized avatar

Eugene Burmako xeno-by

View GitHub Profile
@xeno-by
xeno-by / gist:2559714
Created April 30, 2012 16:19
Mixing in a trait dynamically
Answers http://stackoverflow.com/questions/10373318/mixing-in-a-trait-dynamically.
Compile as follows:
scalac Common_1.scala Macros_2.scala
scalac Common_1.scala Test_3.scala -cp <path to the result of the previous compilation>
Tested in 2.10.0-M3, will most likely not compile by the time 2.10.0 final is released, because we're actively rehashing the API.
However the principles will remain the same in the final release, so the concept itself is okay.
upd. Code updated for 2.10.0-M7.
upd. Code updated for 2.10.0-RC1.
@xeno-by
xeno-by / gist:2568772
Created May 1, 2012 15:22
2012-05-01-16-07-04-perf_bad-rebuild-alt-compiler
myke rebuild-alt-compiler C:\Projects\Perf_Bad
psi: filename = cmd.exe, arguments = /C ant build -buildfile build.xml, home = C:\Projects\Perf_Bad
Buildfile: C:\Projects\Perf_Bad\build.xml
init.jars.check:
init.jars:
init:
[echo] build time: 1 May 2012, 16:07:05
@xeno-by
xeno-by / gist:2568775
Created May 1, 2012 15:22
2012-05-01-16-09-43-perf_good-rebuild-alt-compiler
myke rebuild-alt-compiler C:\Projects\Perf_Good
psi: filename = cmd.exe, arguments = /C ant build -buildfile build.xml, home = C:\Projects\Perf_Good
Buildfile: C:\Projects\Perf_Good\build.xml
init.jars.check:
init.jars:
init:
[echo] build time: 1 May 2012, 16:09:44
@xeno-by
xeno-by / gist:2578102
Created May 2, 2012 16:45
macro materializers enabled
myke run-test C:\Projects\Perf_Bad\build.xml
psi: filename = cmd.exe, arguments = /C ant -Djavac.args=-Dmyke.comments=macro_materializers_enabled quick.comp -buildfile build.xml, home = C:\Projects\Perf_Bad
Buildfile: C:\Projects\Perf_Bad\build.xml
init.jars.check:
init.jars:
init:
[echo] build time: 2 May 2012, 18:39:36
@xeno-by
xeno-by / gist:2578103
Created May 2, 2012 16:45
macro materializers disabled
myke run-test C:\Projects\Perf_Bad\src\compiler\scala\tools\nsc\typechecker\Implicits.scala
psi: filename = cmd.exe, arguments = /C ant -Djavac.args=-Dmyke.comments=macro_materializers_disabled quick.comp -buildfile build.xml, home = C:\Projects\Perf_Bad
Buildfile: C:\Projects\Perf_Bad\build.xml
init.jars.check:
init.jars:
init:
[echo] build time: 2 May 2012, 18:42:39
trait StuffBase {
type Base
type Foo <: Base
val Foo: FooExtractor
implicit val FooTag: ClassTag[Foo]
abstract class FooExtractor {
def apply(x: Int): Foo
def unapply(foo: Foo): Option[Int]
trait StuffBase {
type Foo
implicit val FooTag: ClassManifest[Foo]
}
object Stuff extends StuffBase {
class Foo
implicit val FooTag = classManifest[Foo]
}
package scala.reflect.runtime
package object eval {
implicit class PimpedExpr[T](expr: scala.reflect.api.JavaUniverse # Expr[T]) {
def runtimeEval: T = {
import scala.tools.reflect._
val u0 = expr.mirror.universe
val expr0 = expr.asInstanceOf[u0.Expr[T]]
val factory = universe2ToolBoxFactory(expr0.mirror)(u0)
val toolbox = factory.mkToolBox()
This file has been truncated, but you can view the full file.
myke run-all-tests C:\Projects\KeplerUnderRefactoring
git: branch = topic/reflection, commit = 0ce5eeebeaf11dbd27e163c1da0121aad83fa14f
psi: filename = cmd.exe, arguments = /C ant -Dscalac.args="""""" build -buildfile build.xml, home = C:\Projects\KeplerUnderRefactoring
Buildfile: C:\Projects\KeplerUnderRefactoring\build.xml
init.jars.check:
init.jars:
[echo] Updating bootstrap libs. (To do this by hand, run ./pull-binary-libs.sh)
/** The class for all symbols */
abstract class Symbol protected[Symbols] (initOwner: Symbol, initPos: Position, initName: Name)
extends SymbolContextApiImpl
with HasFlags
with SymbolFlagLogic
with SymbolCreator
// with FlagVerifier // DEBUG
with Annotatable[Symbol] {
if (initName.toString == "scala") {