aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/dotc25
-rw-r--r--project/Build.scala3
-rw-r--r--test/test/DottyRepl.scala25
-rw-r--r--test/test/DottyTypeStealer.scala32
4 files changed, 75 insertions, 10 deletions
diff --git a/bin/dotc b/bin/dotc
index ffe11d070..6d0bf72ce 100755
--- a/bin/dotc
+++ b/bin/dotc
@@ -4,10 +4,11 @@
# Configuration
-SCALA_VERSION=2.11.4
+SCALA_VERSION=2.11.5
SCALA_BINARY_VERSION=2.11
SCALA_COMPILER_VERSION=2.11.5-20141212-151631-beaa78b033
DOTTY_VERSION=0.1
+JLINE_VERSION=2.12
bootcp=true
default_java_opts="-Xmx768m -Xms768m"
programName=$(basename "$0")
@@ -21,6 +22,7 @@ unset verbose quiet cygwin toolcp colors saved_stty CDPATH
CompilerMain=dotty.tools.dotc.Main
+ReplMain=test.DottyRepl
# Try to autodetect real location of the script
@@ -32,7 +34,7 @@ DOTTY_ROOT="`dirname \"$DOTTY_ROOT\"`"
DOTTY_ROOT="`( cd \"$DOTTY_ROOT\" && pwd )`/.." # absolute
# autodetecting the compiler jar. this is location where sbt 'packages' it
MAIN_JAR=$DOTTY_ROOT/target/scala-$SCALA_BINARY_VERSION/dotty_$SCALA_BINARY_VERSION-$DOTTY_VERSION-SNAPSHOT.jar
-
+TEST_JAR=$DOTTY_ROOT/target/scala-$SCALA_BINARY_VERSION/dotty_$SCALA_BINARY_VERSION-$DOTTY_VERSION-SNAPSHOT-tests.jar
function checkjar {
if [ ! -f "$1" ]
then
@@ -51,6 +53,7 @@ function checkjar {
}
checkjar $MAIN_JAR package
+checkjar $TEST_JAR test:package
# Autodetecting the scala-library location, in case it wasn't provided by an environment variable
if [ "$SCALA_LIBRARY_JAR" == "" ]
@@ -68,13 +71,18 @@ then
SCALA_COMPILER_JAR=$HOME/.ivy2/cache/me.d-d/scala-compiler/jars/scala-compiler-$SCALA_COMPILER_VERSION.jar
fi
-if [ ! -f "$SCALA_LIBRARY_JAR" -o ! -f "$SCALA_REFLECT_JAR" -o ! -f "$SCALA_COMPILER_JAR" ]
+if [ "$JLINE_JAR" == "" ]
+then
+ JLINE_JAR=$HOME/.ivy2//cache/jline/jline/jars/jline-$JLINE_VERSION.jar
+fi
+
+if [ ! -f "$SCALA_LIBRARY_JAR" -o ! -f "$SCALA_REFLECT_JAR" -o ! -f "$SCALA_COMPILER_JAR" -o ! -f "$JLINE_JAR" ]
then
echo To use this script please set
echo SCALA_LIBRARY_JAR to point to scala-library-$SCALA_VERSION.jar "(currently $SCALA_LIBRARY_JAR)"
echo SCALA_REFLECT_JAR to point to scala-reflect-$SCALA_VERSION.jar "(currently $SCALA_REFLECT_JAR)"
echo SCALA_COMPILER_JAR to point to scala-compiler-$SCALA_VERSION.jar with bcode patches "(currently $SCALA_COMPILER_JAR)"
-
+ echo JLINE_JAR to point to jline-$JLINE_VERSION.jar "(currently $JLINE_JAR)"
fi
ifdebug () {
@@ -163,9 +171,9 @@ trap onExit INT
# to java to suppress "." from materializing.
classpathArgs () {
if [[ -n $bootcp ]]; then
-echo "-Xbootclasspath/a:$SCALA_LIBRARY_JAR:$SCALA_REFLECT_JAR:$SCALA_COMPILER_JAR:$MAIN_JAR -classpath $MAIN_JAR"
+echo "-Xbootclasspath/a:$SCALA_LIBRARY_JAR:$SCALA_REFLECT_JAR:$SCALA_COMPILER_JAR:$JLINE_JAR:$MAIN_JAR -classpath $MAIN_JAR:$TEST_JAR"
else
-echo "-classpath $SCALA_LIBRARY_JAR:$SCALA_REFLECT_JAR:$MAIN_JAR"
+echo "-classpath $SCALA_LIBRARY_JAR:$SCALA_REFLECT_JAR:$SCALA_COMPILER_JAR:$JLINE_JAR:$MAIN_JAR:$TEST_JAR"
fi
}
@@ -181,8 +189,7 @@ require_arg () {
}
-
-
+main_class=$CompilerMain
while [[ $# -gt 0 ]]; do
case "$1" in
@@ -230,7 +237,7 @@ execCommand \
"${java_args[@]}" \
"$(classpathArgs)" \
-Dscala.usejavacp=true \
- "${CompilerMain}" \
+ "${main_class}" \
"${scala_args[@]}" \
"${residual_args[@]}"
diff --git a/project/Build.scala b/project/Build.scala
index f7053573f..e6725bb26 100644
--- a/project/Build.scala
+++ b/project/Build.scala
@@ -31,7 +31,8 @@ object DottyBuild extends Build {
// get reflect and xml onboard
libraryDependencies ++= Seq("org.scala-lang" % "scala-reflect" % scalaVersion.value,
"org.scala-lang.modules" %% "scala-xml" % "1.0.1",
- "me.d-d" % "scala-compiler" % "2.11.5-20141212-151631-beaa78b033"),
+ "me.d-d" % "scala-compiler" % "2.11.5-20141212-151631-beaa78b033",
+ "jline" % "jline" % "2.12"),
// get junit onboard
libraryDependencies += "com.novocode" % "junit-interface" % "0.11-RC1" % "test",
diff --git a/test/test/DottyRepl.scala b/test/test/DottyRepl.scala
new file mode 100644
index 000000000..74f6ee248
--- /dev/null
+++ b/test/test/DottyRepl.scala
@@ -0,0 +1,25 @@
+package test
+import scala.tools.nsc.interpreter._
+import scala.tools.nsc.Settings
+
+/**
+ * Dotty requires a mangled bootclasspath to start. It means that `console` mode of sbt doesn't work for us.
+ * At least I(Dmitry) wasn't able to make sbt fork in console
+ */
+object DottyRepl {
+ def main(args: Array[String]): Unit = {
+ def repl = new ILoop {}
+
+ val settings = new Settings
+ settings.Yreplsync.value = true
+
+
+ //use when launching normally outside SBT
+ settings.usejavacp.value = true
+
+ //an alternative to 'usejavacp' setting, when launching from within SBT
+ //settings.embeddedDefaults[Repl.type]
+
+ repl.process(settings)
+ }
+}
diff --git a/test/test/DottyTypeStealer.scala b/test/test/DottyTypeStealer.scala
new file mode 100644
index 000000000..3b7137dcc
--- /dev/null
+++ b/test/test/DottyTypeStealer.scala
@@ -0,0 +1,32 @@
+package test
+
+import dotty.tools.dotc.ast.tpd
+import dotty.tools.dotc.core.Names._
+import dotty.tools.dotc.ast.tpd._
+import dotty.tools.dotc.core.Contexts.Context
+import dotty.tools.dotc.core.Decorators._
+import dotty.tools.dotc.core.Types.Type
+
+object DottyTypeStealer {
+ def stealType(source: String, typeStrings: String*): (Context, List[Type]) = {
+ val dummyName = "x_x_x"
+ val vals = typeStrings.zipWithIndex.map{case (s, x)=> s"val ${dummyName}$x: $s = ???"}.mkString("\n")
+ val gatheredSource = s" ${source}\n object A$dummyName {$vals}"
+ var scontext : Context = null
+ var tp: List[Type] = null
+ new DottyTest().checkCompile("frontend",gatheredSource) {
+ (tree, context) =>
+ implicit val ctx = context
+ val findValDef: (List[ValDef], tpd.Tree) => List[ValDef] =
+ (acc , tree) => { tree match {
+ case t: ValDef if t.name.startsWith(dummyName.toTermName) => t :: acc
+ case _ => acc
+ }
+ }
+ val d = new DeepFolder[List[ValDef]](findValDef).foldOver(Nil, tree)
+ tp = d.map(_.tpe.widen)
+ scontext = context
+ }
+ (scontext, tp)
+ }
+}