This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Author: Olivier Chafik (http://ochafik.com) | |
| // Feel free to modify and reuse this for any purpose ("public domain / I don't care"). | |
| package scalaxy.pretyping.example | |
| import scala.reflect.internal._ | |
| import scala.tools.nsc.CompilerCommand | |
| import scala.tools.nsc.Global | |
| import scala.tools.nsc.Phase | |
| import scala.tools.nsc.plugins.Plugin | |
| import scala.tools.nsc.plugins.PluginComponent |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| assert x.getSize() == 2 : "Size of x is not 2"; // Java assert |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Only works with 2.10.0+ | |
| scalaVersion := "2.10.0" | |
| // Dependency at compilation-time only (not at runtime). | |
| libraryDependencies += "com.nativelibs4java" %% "scalaxy-debug" % "0.3-SNAPSHOT" % "provided" | |
| // Scalaxy/Debug snapshots are published on the Sonatype repository. | |
| resolvers += Resolver.sonatypeRepo("snapshots") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import scalaxy.debug._ | |
| val a = 10 | |
| val b = 12 | |
| assert(a == b) | |
| // this will throw: | |
| // "assertion failed: a == b (10 != 12)" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| assert(a == b, s"a == b ($a != $b)") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| assert(a == b, "a == b (" + a + " != " + b + ")") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import scalaxy.loops._ | |
| for (iteration <- 0 until iterations optimized) { | |
| for (i <- 0 until n optimized) { | |
| ... | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Only works with 2.10.0+ | |
| scalaVersion := "2.10.0" | |
| // Dependency at compilation-time only (not at runtime). | |
| libraryDependencies += "com.nativelibs4java" %% "scalaxy-loops" % "0.3-SNAPSHOT" % "provided" | |
| // Scalaxy/Loops snapshots are published on the Sonatype repository. | |
| resolvers += Resolver.sonatypeRepo("snapshots") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| var iteration = 0 | |
| while (iteration < iterations) { | |
| var i = 0 | |
| while (i < n) { | |
| ... | |
| i += 1 | |
| } | |
| iteration += 1 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (0 until iterations).foreach(iteration => { | |
| (0 until n).foreach(i => { | |
| ... | |
| }) | |
| }) |