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 / t5230_manual.scala
Created December 1, 2011 16:28
compose the tree, equivalent to t5230, by hand
import scala.tools.nsc.reporters._
import scala.tools.nsc.Settings
import reflect.runtime.Mirror.ToolBox
object Test extends App {
// todo. compose the tree, equivalent to t5230, by hand
import scala.reflect.mirror._
import scala.reflect.api._
import scala.reflect.api.Modifier._
Func<String, String> x = name => {
var buf = new StringBuilder();
for (var i = 0; i < name.Length; ++i) {
var prev = i == 0 ? '\0' : name[i - 1];
var curr = name[i];
var next = i == name.Length - 1 ? '\0' : name[i + 1];
if (Char.IsLower(prev) && Char.IsUpper(curr) && !Char.IsUpper(next)) {
buf.Append("-");
buf.Append(Char.ToLower(curr));
} else {
error: recursive method factorial needs result type
Exception in thread "main" java.lang.Error: reflective compilation has failed
at scala.reflect.runtime.ToolBoxes$ToolBox$ToolBoxGlobal.runExpr(ToolBoxes.scala:95)
at scala.reflect.runtime.ToolBoxes$ToolBox.runExpr(ToolBoxes.scala:168)
at scala.reflect.runtime.ToolBoxes$ToolBox.runExpr(ToolBoxes.scala:171)
at Test$delayedInit$body.apply(t5274_0.scala:16)
at scala.Function0$class.apply$mcV$sp(Function0.scala:34)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App$$anonfun$main$1.apply(App.scala:61)
at scala.App$$anonfun$main$1.apply(App.scala:61)
@xeno-by
xeno-by / gist:1453440
Created December 9, 2011 21:46
lifted code that uses boundSyms: does not work
import scala.tools.nsc.reporters._
import scala.tools.nsc.Settings
import reflect.runtime.Mirror.ToolBox
object Test extends App {
val code = scala.reflect.Code.lift{
class C
println(List(new C()).map(x => x).length)
};
@xeno-by
xeno-by / gist:1453447
Created December 9, 2011 21:46
non-lifted code: works
object Foo extends App {
class C
println(List(new C()).map(x => x).length)
}
@xeno-by
xeno-by / gist:1453452
Created December 9, 2011 21:48
lifted code that uses non-bound syms: works
import scala.tools.nsc.reporters._
import scala.tools.nsc.Settings
import reflect.runtime.Mirror.ToolBox
object Test extends App {
val code = scala.reflect.Code.lift{
println(List(1).map(x => x).length)
};
val reporter = new ConsoleReporter(new Settings)
@xeno-by
xeno-by / gist:1523254
Created December 27, 2011 10:46
Manual compilation of scalac
=== launch-scalac.bat ===
@echo off
rem never ever use -Dscala.usejavacp=true here!!
java >con ^
-classpath >con ^
C:\Users\xeno.by\workspace\Kepler\lib\fjbg.jar;C:\Users\xeno.by\workspace\Kepler\lib\forkjoin.jar;C:\Users\xeno.by\workspace\Kepler\build\locker\classes\compiler;C:\Users\xeno.by\workspace\Kepler\build\locker\classes\library >con ^
scala.tools.nsc.Main >con ^
@d:\quicklib >con ^
-Ydebug
@xeno-by
xeno-by / .gitignore
Created December 27, 2011 13:29
.gitignore
/build
/build/
/target
/target/
target/
/dists/
/out/
/bin/
/project/boot/
/project/build/target/
@xeno-by
xeno-by / .test
Created December 27, 2011 13:29
.test
test\files\run\reify_anonymous.scala
test\files\run\reify_for1.scala
test\files\run\reify_generic1.scala
test\files\run\reify_generic2.scala
test\files\run\reify_getter.scala
test\files\run\reify_inheritance.scala
test\files\run\reify_printf.scala
test\files\run\reify_splices1.scala
test\files\run\reify_varargs.scala
test\files\run\t5230.scala
@xeno-by
xeno-by / .classpath
Created December 27, 2011 13:29
.classpath
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="build/locker/classes/library" path="src/library"/>
<classpathentry kind="src" output="build/locker/classes/compiler" path="src/compiler"/>
<classpathentry kind="lib" path="lib/ant/ant-contrib.jar"/>
<classpathentry kind="lib" path="lib/ant/ant-dotnet-1.0.jar"/>
<classpathentry kind="lib" path="lib/ant/ant.jar"/>
<classpathentry kind="lib" path="lib/ant/maven-ant-tasks-2.1.1.jar"/>
<classpathentry kind="lib" path="lib/ant/vizant.jar"/>
<classpathentry kind="lib" path="lib/fjbg.jar"/>