Permalink
Browse files

Modularize continuations plugin.

The continuations plugin and library will still ship with 2.11 (albeit unsupported).
They now reside at https://github.com/scala/scala-continuations.
  • Loading branch information...
1 parent 7e74aa6 commit 858a5d513779f4af6f12c0a530bdeceb7a7fd4d9 @adriaanm adriaanm committed Dec 3, 2013
Showing with 57 additions and 4,203 deletions.
  1. +0 −4 build-ant-macros.xml
  2. +39 −88 build.xml
  3. +0 −12 dbuild-meta.json
  4. +0 −5 src/build/bnd/continuations.bnd
  5. +5 −0 src/build/bnd/scala-continuations-library.bnd
  6. +5 −0 src/build/bnd/scala-continuations-plugin.bnd
  7. +1 −2 src/build/dbuild-meta-json-gen.scala
  8. +0 −1 src/build/maven/maven-deploy.xml
  9. +0 −59 src/build/maven/plugins/continuations-pom.xml
  10. +0 −249 src/continuations/library/scala/util/continuations/ControlContext.scala
  11. +0 −187 src/continuations/library/scala/util/continuations/package.scala
  12. +0 −520 src/continuations/plugin/scala/tools/selectivecps/CPSAnnotationChecker.scala
  13. +0 −137 src/continuations/plugin/scala/tools/selectivecps/CPSUtils.scala
  14. +0 −545 src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala
  15. +0 −56 src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSPlugin.scala
  16. +0 −383 src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSTransform.scala
  17. +0 −5 src/continuations/plugin/scalac-plugin.xml
  18. +0 −8 src/eclipse/continuations-library/.classpath
  19. +0 −30 src/eclipse/continuations-library/.project
  20. +0 −2 src/eclipse/continuations-library/.settings/org.scala-ide.sdt.core.prefs
  21. +0 −1 src/eclipse/reflect/.classpath
  22. +0 −1 src/eclipse/scala-compiler/.classpath
  23. +0 −1 src/eclipse/test-junit/.classpath
  24. +0 −23 src/intellij/continuations-library.iml.SAMPLE
  25. +0 −25 src/intellij/continuations-plugin.iml.SAMPLE
  26. +0 −2 src/intellij/scala-lang.ipr.SAMPLE
  27. +0 −4 test/disabled/continuations-neg/infer0.check
  28. +0 −12 test/disabled/continuations-neg/infer0.scala
  29. +0 −6 test/files/continuations-neg/function0.check
  30. +0 −16 test/files/continuations-neg/function0.scala
  31. +0 −6 test/files/continuations-neg/function2.check
  32. +0 −16 test/files/continuations-neg/function2.scala
  33. +0 −6 test/files/continuations-neg/function3.check
  34. +0 −15 test/files/continuations-neg/function3.scala
  35. +0 −4 test/files/continuations-neg/infer2.check
  36. +0 −19 test/files/continuations-neg/infer2.scala
  37. +0 −4 test/files/continuations-neg/lazy.check
  38. +0 −16 test/files/continuations-neg/lazy.scala
  39. +0 −6 test/files/continuations-neg/t1929.check
  40. +0 −17 test/files/continuations-neg/t1929.scala
  41. +0 −6 test/files/continuations-neg/t2285.check
  42. +0 −11 test/files/continuations-neg/t2285.scala
  43. +0 −6 test/files/continuations-neg/t2949.check
  44. +0 −15 test/files/continuations-neg/t2949.scala
  45. +0 −4 test/files/continuations-neg/t3628.check
  46. +0 −11 test/files/continuations-neg/t3628.scala
  47. +0 −4 test/files/continuations-neg/t3718.check
  48. +0 −3 test/files/continuations-neg/t3718.scala
  49. +0 −4 test/files/continuations-neg/t5314-missing-result-type.check
  50. +0 −13 test/files/continuations-neg/t5314-missing-result-type.scala
  51. +0 −4 test/files/continuations-neg/t5314-npe.check
  52. +0 −3 test/files/continuations-neg/t5314-npe.scala
  53. +0 −4 test/files/continuations-neg/t5314-return-reset.check
  54. +0 −21 test/files/continuations-neg/t5314-return-reset.scala
  55. +0 −6 test/files/continuations-neg/t5314-type-error.check
  56. +0 −17 test/files/continuations-neg/t5314-type-error.scala
  57. +0 −4 test/files/continuations-neg/t5445.check
  58. +0 −5 test/files/continuations-neg/t5445.scala
  59. +0 −7 test/files/continuations-neg/trycatch2.check
  60. +0 −33 test/files/continuations-neg/trycatch2.scala
  61. +0 −2 test/files/continuations-run/basics.check
  62. +0 −23 test/files/continuations-run/basics.scala
  63. +0 −1 test/files/continuations-run/function1.check
  64. +0 −16 test/files/continuations-run/function1.scala
  65. +0 −1 test/files/continuations-run/function4.check
  66. +0 −15 test/files/continuations-run/function4.scala
  67. +0 −1 test/files/continuations-run/function5.check
  68. +0 −15 test/files/continuations-run/function5.scala
  69. +0 −1 test/files/continuations-run/function6.check
  70. +0 −16 test/files/continuations-run/function6.scala
  71. +0 −2 test/files/continuations-run/ifelse0.check
  72. +0 −18 test/files/continuations-run/ifelse0.scala
  73. +0 −4 test/files/continuations-run/ifelse1.check
  74. +0 −25 test/files/continuations-run/ifelse1.scala
  75. +0 −4 test/files/continuations-run/ifelse2.check
  76. +0 −16 test/files/continuations-run/ifelse2.scala
  77. +0 −2 test/files/continuations-run/ifelse3.check
  78. +0 −21 test/files/continuations-run/ifelse3.scala
  79. +0 −4 test/files/continuations-run/ifelse4.check
  80. +0 −31 test/files/continuations-run/ifelse4.scala
  81. +0 −5 test/files/continuations-run/implicit-infer-annotations.check
  82. +0 −59 test/files/continuations-run/implicit-infer-annotations.scala
  83. +0 −33 test/files/continuations-run/infer1.scala
  84. +0 −2 test/files/continuations-run/match0.check
  85. +0 −18 test/files/continuations-run/match0.scala
  86. +0 −2 test/files/continuations-run/match1.check
  87. +0 −18 test/files/continuations-run/match1.scala
  88. +0 −2 test/files/continuations-run/match2.check
  89. +0 −26 test/files/continuations-run/match2.scala
  90. +0 −2 test/files/continuations-run/patvirt.check
  91. +0 −32 test/files/continuations-run/patvirt.scala
  92. +0 −25 test/files/continuations-run/shift-pct.check
  93. +0 −30 test/files/continuations-run/shift-pct.scala
  94. +0 −1 test/files/continuations-run/t1807.check
  95. +0 −14 test/files/continuations-run/t1807.scala
  96. +0 −10 test/files/continuations-run/t1808.scala
  97. +0 −14 test/files/continuations-run/t1820.scala
  98. +0 −4 test/files/continuations-run/t1821.check
  99. +0 −20 test/files/continuations-run/t1821.scala
  100. +0 −1 test/files/continuations-run/t2864.check
  101. +0 −30 test/files/continuations-run/t2864.scala
  102. +0 −1 test/files/continuations-run/t2934.check
  103. +0 −10 test/files/continuations-run/t2934.scala
  104. +0 −1 test/files/continuations-run/t3199.check
  105. +0 −20 test/files/continuations-run/t3199.scala
  106. +0 −1 test/files/continuations-run/t3223.check
  107. +0 −19 test/files/continuations-run/t3223.scala
  108. +0 −12 test/files/continuations-run/t3225.check
  109. +0 −56 test/files/continuations-run/t3225.scala
  110. +0 −5 test/files/continuations-run/t3501.check
  111. +0 −15 test/files/continuations-run/t3501.scala
  112. +0 −5 test/files/continuations-run/t5314-2.check
  113. +0 −44 test/files/continuations-run/t5314-2.scala
  114. +0 −4 test/files/continuations-run/t5314-3.check
  115. +0 −27 test/files/continuations-run/t5314-3.scala
  116. +0 −1 test/files/continuations-run/t5314-with-if.check
  117. +0 −17 test/files/continuations-run/t5314-with-if.scala
  118. +0 −14 test/files/continuations-run/t5314.check
  119. +0 −52 test/files/continuations-run/t5314.scala
  120. +0 −25 test/files/continuations-run/t5472.check
  121. +0 −91 test/files/continuations-run/t5472.scala
  122. +0 −7 test/files/continuations-run/t5506.check
  123. +0 −58 test/files/continuations-run/t5506.scala
  124. +0 −2 test/files/continuations-run/t5538.check
  125. +0 −52 test/files/continuations-run/t5538.scala
  126. +0 −2 test/files/continuations-run/trycatch0.check
  127. +0 −25 test/files/continuations-run/trycatch0.scala
  128. +0 −10 test/files/continuations-run/trycatch1.check
  129. +0 −48 test/files/continuations-run/trycatch1.scala
  130. +0 −1 test/files/continuations-run/while0.check
  131. +0 −22 test/files/continuations-run/while0.scala
  132. +0 −11 test/files/continuations-run/while1.check
  133. +0 −22 test/files/continuations-run/while1.scala
  134. +0 −19 test/files/continuations-run/while2.check
  135. +0 −23 test/files/continuations-run/while2.scala
  136. +0 −31 test/files/continuations-run/z1673.scala
  137. 0 test/files/{continuations-run → run}/t3199b.check
  138. 0 test/files/{continuations-run → run}/t3199b.scala
  139. +0 −73 test/pending/continuations-pos/t3620.scala
  140. +0 −9 test/pending/continuations-run/example0.scala
  141. +0 −9 test/pending/continuations-run/example1.scala
  142. +0 −9 test/pending/continuations-run/example16.scala
  143. +0 −9 test/pending/continuations-run/example2.scala
  144. +0 −9 test/pending/continuations-run/example3.scala
  145. +0 −9 test/pending/continuations-run/example4.scala
  146. +0 −9 test/pending/continuations-run/example5.scala
  147. +0 −9 test/pending/continuations-run/example6.scala
  148. +0 −9 test/pending/continuations-run/example7.scala
  149. +0 −9 test/pending/continuations-run/example8.scala
  150. +0 −9 test/pending/continuations-run/example9.scala
  151. +0 −4 test/pending/continuations-run/foreach.check
  152. +0 −33 test/pending/continuations-run/foreach.scala
  153. +7 −1 versions.properties
@@ -190,10 +190,6 @@
<and>
<available file="tools/zinc"/>
<equals arg1="@{stage}" arg2="quick"/>
- <not>
- <equals arg1="@{project}" arg2="continuations-plugins"/>
- </not>
- <!-- doesn't work in zinc because it requires the quick compiler, which isn't jarred up-->
</and>
<then>
<zinc taskname="Z.@{stage}.@{project}" compilerpathref="@{with}.compiler.path" destdir="${build-@{stage}.dir}/classes/@{destproject}" srcdir="${src.dir}/@{srcdir}" srcpath="@{srcpath}" buildpathref="@{stage}.@{project}.build.path" params="${scalac.args.@{stage}} @{args}" java-excludes="@{java-excludes}"/>
View
Oops, something went wrong.
View
@@ -113,18 +113,6 @@
],
"name": "scalap",
"organization": "org.scala-lang"
- },
- {
- "artifacts": [
- {
- "extension": "jar",
- "name": "continuations",
- "organization": "org.scala-lang.plugins"
- }
- ],
- "dependencies": [],
- "name": "continuations",
- "organization": "org.scala-lang.plugins"
}
]
}
@@ -1,5 +0,0 @@
-Bundle-Name: Scala Continuations Plugin
-Bundle-SymbolicName: org.scala-lang.plugins.continuations
-ver: @VERSION@
-Bundle-Version: ${ver}
-Export-Package: *;version=${ver}
@@ -0,0 +1,5 @@
+Bundle-Name: Scala Delimited Continuations Library
+Bundle-SymbolicName: org.scala-lang.plugins.continuations-library
+ver: @VERSION@
+Bundle-Version: ${ver}
+Export-Package: *;version=${ver}
@@ -0,0 +1,5 @@
+Bundle-Name: Scala Delimited Continuations Compiler Plugin
+Bundle-SymbolicName: org.scala-lang.plugins.continuations-plugin
+ver: @VERSION@
+Bundle-Version: ${ver}
+Export-Package: *;version=${ver}
@@ -44,9 +44,8 @@ val meta =
Project("scalap", "org.scala-lang",
Seq(ProjectRef("scalap", "org.scala-lang")),
- Seq(ProjectRef("scala-compiler", "org.scala-lang"))),
+ Seq(ProjectRef("scala-compiler", "org.scala-lang")))
- Project("continuations", "org.scala-lang.plugins", Seq(ProjectRef("continuations", "org.scala-lang.plugins")), Seq.empty)
))
println(Utils.writeValue(meta))
@@ -126,7 +126,6 @@
<deploy-one dir="@{dir}" name="scala-actors" local="@{local}" signed="@{signed}"/>
<deploy-one dir="@{dir}" name="scala-swing" local="@{local}" signed="@{signed}"/>
<deploy-one dir="@{dir}" name="scalap" local="@{local}" signed="@{signed}"/>
- <deploy-one dir="@{dir}plugins/" name="continuations" local="@{local}" signed="@{signed}"/>
</sequential>
</macrodef>
@@ -1,59 +0,0 @@
-<?xml version="1.0"?>
-<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.scala-lang.plugins</groupId>
- <artifactId>continuations</artifactId>
- <packaging>jar</packaging>
- <version>@VERSION@</version>
- <name>Scala Continuations Plugin</name>
- <description>Delimited continuations compilation for Scala</description>
- <url>http://www.scala-lang.org/</url>
- <inceptionYear>2010</inceptionYear>
- <organization>
- <name>LAMP/EPFL</name>
- <url>http://lamp.epfl.ch/</url>
- </organization>
- <licenses>
- <license>
- <name>BSD 3-Clause</name>
- <url>http://www.scala-lang.org/license.html</url>
- <distribution>repo</distribution>
- </license>
- </licenses>
- <scm>
- <connection>scm:git:git://github.com/scala/scala.git</connection>
- <url>https://github.com/scala/scala.git</url>
- </scm>
- <issueManagement>
- <system>JIRA</system>
- <url>https://issues.scala-lang.org/</url>
- </issueManagement>
- <dependencies>
- <dependency>
- <groupId>org.scala-lang</groupId>
- <artifactId>scala-compiler</artifactId>
- <version>@VERSION@</version>
- </dependency>
- </dependencies>
- <distributionManagement>
- <repository>
- <id>scala-tools.org</id>
- <url>@RELEASE_REPOSITORY@</url>
- </repository>
- <snapshotRepository>
- <id>scala-tools.org</id>
- <url>@SNAPSHOT_REPOSITORY@</url>
- <uniqueVersion>false</uniqueVersion>
- </snapshotRepository>
- </distributionManagement>
- <developers>
- <developer>
- <id>lamp</id>
- <name>EPFL LAMP</name>
- </developer>
- <developer>
- <id>Typesafe</id>
- <name>Typesafe, Inc.</name>
- </developer>
- </developers>
-</project>
@@ -1,249 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2010-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.util.continuations
-
-import scala.annotation.{ Annotation, StaticAnnotation, TypeConstraint }
-
-/** This annotation is used to mark a parameter as part of a continuation
- * context.
- *
- * The type `A @cpsParam[B,C]` is desugared to `ControlContext[A,B,C]` at compile
- * time.
- *
- * @tparam B The type of computation state after computation has executed, and
- * before control is returned to the shift.
- * @tparam C The eventual return type of this delimited compuation.
- * @see scala.util.continuations.ControlContext
- */
-class cpsParam[-B,+C] extends StaticAnnotation with TypeConstraint
-
-private class cpsSym[B] extends Annotation // implementation detail
-
-private class cpsSynth extends Annotation // implementation detail
-
-private class cpsPlus extends StaticAnnotation with TypeConstraint // implementation detail
-private class cpsMinus extends Annotation // implementation detail
-
-
-/**
- * This class represent a portion of computation that has a 'hole' in it. The
- * class has the ability to compute state up until a certain point where the
- * state has the `A` type. If this context is given a function of type
- * `A => B` to move the state to the `B` type, then the entire computation can
- * be completed resulting in a value of type `C`.
- *
- * An Example: {{{
- * val cc = new ControlContext[String, String, String](
- * fun = { (f: String=>String, err: Exception => String) =>
- * val updatedState =
- * try f("State")
- * catch {
- * case e: Exception => err(e)
- * }
- * updatedState + "-Complete!"
- * },
- * x = null.asIntanceOf[String]
- * }
- * cc.foreach(_ + "-Continued") // Results in "State-Continued-Complete!"
- * }}}
- *
- * This class is used to transform calls to `shift` in the `continuations`
- * package. Direct use and instantiation is possible, but usually reserved
- * for advanced cases.
- *
- *
- * A context may either be ''trivial'' or ''non-trivial''. A ''trivial''
- * context '''just''' has a state of type `A`. When completing the computation,
- * it's only necessary to use the function of type `A => B` directly against
- * the trivial value. A ''non-trivial'' value stores a computation '''around'''
- * the state transformation of type `A => B` and cannot be short-circuited.
- *
- * @param fun The captured computation so far. The type
- * `(A => B, Exception => B) => C` is a function where:
- * - The first parameter `A=>B` represents the computation defined against
- * the current state held in the ControlContext.
- * - The second parameter `Exception => B` represents a computation to
- * perform if an exception is thrown from the first parameter's computation.
- * - The return value is the result of the entire computation contained in this
- * `ControlContext`.
- * @param x The current state stored in this context. Allowed to be null if
- * the context is non-trivial.
- * @tparam A The type of the state currently held in the context.
- * @tparam B The type of the transformed state needed to complete this computation.
- * @tparam C The return type of the entire computation stored in this context.
- * @note `fun` and `x` are allowed to be `null`.
- * @see scala.util.continutations.shiftR
- */
-final class ControlContext[+A,-B,+C](val fun: (A => B, Exception => B) => C, val x: A) extends Serializable {
-
- /*
- final def map[A1](f: A => A1): ControlContext[A1,B,C] = {
- new ControlContext((k:(A1 => B)) => fun((x:A) => k(f(x))), null.asInstanceOf[A1])
- }
-
- final def flatMap[A1,B1<:B](f: (A => ControlContext[A1,B1,B])): ControlContext[A1,B1,C] = {
- new ControlContext((k:(A1 => B1)) => fun((x:A) => f(x).fun(k)))
- }
- */
-
- /**
- * Modifies the currently captured state in this `ControlContext`.
- * @tparam A1 The new type of state in this context.
- * @param f A transformation function on the current state of the `ControlContext`.
- * @return The new `ControlContext`.
- */
- @noinline final def map[A1](f: A => A1): ControlContext[A1,B,C] = {
- if (fun eq null)
- try {
- new ControlContext[A1,B,C](null, f(x)) // TODO: only alloc if f(x) != x
- } catch {
- case ex: Exception =>
- new ControlContext((k: A1 => B, thr: Exception => B) => thr(ex).asInstanceOf[C], null.asInstanceOf[A1])
- }
- else
- new ControlContext({ (k: A1 => B, thr: Exception => B) =>
- fun( { (x:A) =>
- var done = false
- try {
- val res = f(x)
- done = true
- k(res)
- } catch {
- case ex: Exception if !done =>
- thr(ex)
- }
- }, thr)
- }, null.asInstanceOf[A1])
- }
-
-
- // it would be nice if @inline would turn the trivial path into a tail call.
- // unfortunately it doesn't, so we do it ourselves in SelectiveCPSTransform
-
- /**
- * Maps and flattens this `ControlContext` with another `ControlContext` generated from the current state.
- * @note The resulting comuptation is still the type `C`.
- * @tparam A1 The new type of the contained state.
- * @tparam B1 The new type of the state after the stored continuation has executed.
- * @tparam C1 The result type of the nested `ControlContext`. Because the nested `ControlContext` is executed within
- * the outer `ControlContext`, this type must `>: B` so that the resulting nested computation can be fed through
- * the current continuation.
- * @param f A transformation function from the current state to a nested `ControlContext`.
- * @return The transformed `ControlContext`.
- */
- @noinline final def flatMap[A1,B1,C1<:B](f: (A => ControlContext[A1,B1,C1])): ControlContext[A1,B1,C] = {
- if (fun eq null)
- try {
- f(x).asInstanceOf[ControlContext[A1,B1,C]]
- } catch {
- case ex: Exception =>
- new ControlContext((k: A1 => B1, thr: Exception => B1) => thr(ex).asInstanceOf[C], null.asInstanceOf[A1])
- }
- else
- new ControlContext({ (k: A1 => B1, thr: Exception => B1) =>
- fun( { (x:A) =>
- var done = false
- try {
- val ctxR = f(x)
- done = true
- val res: C1 = ctxR.foreachFull(k, thr) // => B1
- res
- } catch {
- case ex: Exception if !done =>
- thr(ex).asInstanceOf[B] // => B NOTE: in general this is unsafe!
- } // However, the plugin will not generate offending code
- }, thr.asInstanceOf[Exception=>B]) // => B
- }, null.asInstanceOf[A1])
- }
-
- /**
- * Runs the computation against the state stored in this `ControlContext`.
- * @param f the computation that modifies the current state of the context.
- * @note This method could throw exceptions from the computations.
- */
- final def foreach(f: A => B) = foreachFull(f, throw _)
-
- def foreachFull(f: A => B, g: Exception => B): C = {
- if (fun eq null)
- f(x).asInstanceOf[C]
- else
- fun(f, g)
- }
-
- /** @return true if this context only stores a state value and not any deferred computation. */
- final def isTrivial = fun eq null
- /** @return The current state value. */
- final def getTrivialValue = x.asInstanceOf[A]
-
- // need filter or other functions?
-
- final def flatMapCatch[A1>:A,B1<:B,C1>:C<:B1](pf: PartialFunction[Exception, ControlContext[A1,B1,C1]]): ControlContext[A1,B1,C1] = { // called by codegen from SelectiveCPSTransform
- if (fun eq null)
- this
- else {
- val fun1 = (ret1: A1 => B1, thr1: Exception => B1) => {
- val thr: Exception => B1 = { t: Exception =>
- var captureExceptions = true
- try {
- if (pf.isDefinedAt(t)) {
- val cc1 = pf(t)
- captureExceptions = false
- cc1.foreachFull(ret1, thr1) // Throw => B
- } else {
- captureExceptions = false
- thr1(t) // Throw => B1
- }
- } catch {
- case t1: Exception if captureExceptions => thr1(t1) // => E2
- }
- }
- fun(ret1, thr)// fun(ret1, thr) // => B
- }
- new ControlContext(fun1, null.asInstanceOf[A1])
- }
- }
-
- final def mapFinally(f: () => Unit): ControlContext[A,B,C] = { // called in code generated by SelectiveCPSTransform
- if (fun eq null) {
- try {
- f()
- this
- } catch {
- case ex: Exception =>
- new ControlContext((k: A => B, thr: Exception => B) => thr(ex).asInstanceOf[C], null.asInstanceOf[A])
- }
- } else {
- val fun1 = (ret1: A => B, thr1: Exception => B) => {
- val ret: A => B = { x: A =>
- var captureExceptions = true
- try {
- f()
- captureExceptions = false
- ret1(x)
- } catch {
- case t1: Exception if captureExceptions => thr1(t1)
- }
- }
- val thr: Exception => B = { t: Exception =>
- var captureExceptions = true
- try {
- f()
- captureExceptions = false
- thr1(t)
- } catch {
- case t1: Exception if captureExceptions => thr1(t1)
- }
- }
- fun(ret, thr1)
- }
- new ControlContext(fun1, null.asInstanceOf[A])
- }
- }
-
-}
Oops, something went wrong.

0 comments on commit 858a5d5

Please sign in to comment.