From ecd35b2653d4eaf13ad389449d9746d3e9185260 Mon Sep 17 00:00:00 2001
From: Philippe Suter <philippe.suter@gmail.com>
Date: Tue, 22 Jun 2010 13:05:11 +0000
Subject: [PATCH] stub for ordered sets

---
 project/build/funcheck.scala | 37 +++++++++++++++++++++++++-----------
 src/orderedsets/Main.scala   | 14 ++++++++++++++
 src/purescala/Trees.scala    |  2 ++
 3 files changed, 42 insertions(+), 11 deletions(-)
 create mode 100644 src/orderedsets/Main.scala

diff --git a/project/build/funcheck.scala b/project/build/funcheck.scala
index df1b11317..d649b73b5 100644
--- a/project/build/funcheck.scala
+++ b/project/build/funcheck.scala
@@ -5,9 +5,12 @@ class FunCheckProject(info: ProjectInfo) extends DefaultProject(info) with FileT
   override def dependencyPath      = "lib"
   override def shouldCheckOutputDirectories = false
 
-  lazy val purescala = project(".", "PureScala Definitions", new PureScalaProject(_))
-  lazy val plugin    = project(".", "FunCheck Plugin", new PluginProject(_), purescala)
-  lazy val multisets = project(".", "Multiset Solver", new MultisetsProject(_), plugin, purescala)
+  lazy val purescala  = project(".", "PureScala Definitions", new PureScalaProject(_))
+  lazy val plugin     = project(".", "FunCheck Plugin", new PluginProject(_), purescala)
+  lazy val multisets  = project(".", "Multiset Solver", new MultisetsProject(_), plugin, purescala)
+  lazy val orderedsets = project(".", "Ordered Sets Solver", new OrderedSetsProject(_), plugin, purescala)
+
+  lazy val extensionJars : List[Path] = multisets.jarPath :: orderedsets.jarPath :: Nil
 
   val scriptPath: Path = "." / "scalac-funcheck"
 
@@ -22,7 +25,20 @@ class FunCheckProject(info: ProjectInfo) extends DefaultProject(info) with FileT
       val nl = System.getProperty("line.separator")
       val f = scriptPath.asFile
       val fw = new java.io.FileWriter(f)
-      fw.write("#!/bin/sh" + nl)
+      fw.write("#!/bin/bash" + nl)
+      fw.write("FUNCHECKCLASSPATH=")
+      fw.write(buildLibraryJar.absolutePath + ":")
+      fw.write(buildCompilerJar.absolutePath + ":")
+      fw.write(purescala.jarPath.absolutePath + ":")
+      fw.write(plugin.jarPath.absolutePath + ":")
+      fw.write(("lib" / "z3.jar").absolutePath)
+      fw.write(nl + nl)
+      fw.write("for f in " + extensionJars.map(_.absolutePath).map(n => "\"" + n + "\"").mkString(" ") + "; do" + nl)
+      fw.write("  if [ -e ${f} ]" + nl)
+      fw.write("  then" + nl)
+      fw.write("    FUNCHECKCLASSPATH=${FUNCHECKCLASSPATH}:${f}" + nl)
+      fw.write("  fi" + nl)
+      fw.write("done" + nl + nl)
       fw.write("LD_LIBRARY_PATH=" + ("." / "lib-bin").absolutePath + " \\" + nl)
       fw.write("java \\" + nl)
 
@@ -30,12 +46,7 @@ class FunCheckProject(info: ProjectInfo) extends DefaultProject(info) with FileT
       val libStr = (buildLibraryJar.absolutePath).toString
       fw.write("    -Dscala.home=" + libStr.substring(0, libStr.length-21) + " \\" + nl)
 
-      fw.write("    -classpath \\" + nl)
-      fw.write("    " + buildLibraryJar.absolutePath + ":")
-      fw.write(buildCompilerJar.absolutePath + ":")
-      fw.write(purescala.jarPath.absolutePath + ":")
-      fw.write(plugin.jarPath.absolutePath + ":")
-      fw.write(("lib" / "z3.jar").absolutePath + " \\" + nl)
+      fw.write("    -classpath ${FUNCHECKCLASSPATH} \\" + nl)
       fw.write("  scala.tools.nsc.Main -Xplugin:" + plugin.jarPath.absolutePath + " $@" + nl)
       fw.close
       f.setExecutable(true)
@@ -73,5 +84,9 @@ class FunCheckProject(info: ProjectInfo) extends DefaultProject(info) with FileT
     override def mainScalaSourcePath = "src" / "multisets"
     override def unmanagedClasspath = super.unmanagedClasspath +++ purescala.jarPath
   }
-  
+  class OrderedSetsProject(info: ProjectInfo) extends PersonalizedProject(info) {
+    override def outputPath = "bin" / "orderedsets"
+    override def mainScalaSourcePath = "src" / "orderedsets"
+    override def unmanagedClasspath = super.unmanagedClasspath +++ purescala.jarPath
+  }
 }
diff --git a/src/orderedsets/Main.scala b/src/orderedsets/Main.scala
new file mode 100644
index 000000000..7cc8895a8
--- /dev/null
+++ b/src/orderedsets/Main.scala
@@ -0,0 +1,14 @@
+package orderedsets
+
+import purescala.Reporter
+import purescala.Extensions._
+import purescala.Trees._
+
+class Main(reporter: Reporter) extends Solver(reporter) {
+  val description = "Solver for constraints on ordered sets"
+
+  def solve(expr: Expr) : Option[Boolean] = {
+    reporter.info(expr, "I have no idea how to solve this :(")
+    None
+  }
+}
diff --git a/src/purescala/Trees.scala b/src/purescala/Trees.scala
index 8d617a834..1306ed75e 100644
--- a/src/purescala/Trees.scala
+++ b/src/purescala/Trees.scala
@@ -139,6 +139,8 @@ object Trees {
   case class SetIntersection(set1: Expr, set2: Expr) extends Expr 
   case class SetUnion(set1: Expr, set2: Expr) extends Expr 
   case class SetDifference(set1: Expr, set2: Expr) extends Expr 
+  case class SetMin(set: Expr) extends Expr
+  case class SetMax(set: Expr) extends Expr
 
   /* Multiset expressions */
   // case class EmptyMultiset(baseType: TypeTree) extends Expr 
-- 
GitLab