changeset 314:a07f476d9b61

Termination checking allows anything in links and actions
author Adam Chlipala <adamc@hcoop.net>
date Tue, 09 Sep 2008 12:36:13 -0400
parents e0ed0d4dabc9
children e21d0dddda09
files src/cjr_print.sml src/monoize.sml src/termination.sml tests/rec.ur tests/rec.urp
diffstat 5 files changed, 48 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/cjr_print.sml	Tue Sep 09 11:46:33 2008 -0400
+++ b/src/cjr_print.sml	Tue Sep 09 12:36:13 2008 -0400
@@ -1529,7 +1529,7 @@
             let
                 val (ts, defInputs, inputsVar) =
                     case ek of
-                        Core.Link => (ts, string "", string "")
+                        Core.Link => (List.take (ts, length ts - 1), string "", string "")
                       | Core.Action =>
                         case List.nth (ts, length ts - 2) of
                             (TRecord i, _) =>
--- a/src/monoize.sml	Tue Sep 09 11:46:33 2008 -0400
+++ b/src/monoize.sml	Tue Sep 09 12:36:13 2008 -0400
@@ -1594,6 +1594,8 @@
                 fun unwind (t, _) =
                     case t of
                         L.TFun (dom, ran) => dom :: unwind ran
+                      | L.CApp ((L.CFfi ("Basis", "transaction"), _), t) =>
+                        (L.TRecord (L.CRecord ((L.KType, loc), []), loc), loc) :: unwind t
                       | _ => []
 
                 val ts = map (monoType env) (unwind t)
--- a/src/termination.sml	Tue Sep 09 11:46:33 2008 -0400
+++ b/src/termination.sml	Tue Sep 09 12:36:13 2008 -0400
@@ -126,7 +126,43 @@
                         let
                             fun combiner calls e =
                                 case #1 e of
-                                    EApp (e1, e2) =>
+                                    EApp ((ECApp (
+                                           (ECApp (
+                                            (ECApp (
+                                             (ECApp (
+                                              (ECApp (
+                                               (ECApp (
+                                                (ECApp (
+                                                 (ECApp (
+                                                  (EModProj (m, [], "tag"), _),
+                                                  _), _),
+                                                 _), _),
+                                                _), _),
+                                               _), _),
+                                              _), _),
+                                             _), _),
+                                            _), _),
+                                           _), _),
+                                          (ERecord xets, _)) =>
+                                    let
+                                        val checkName =
+                                            case E.lookupStrNamed env m of
+                                                  ("Basis", _) => (fn x : con => case #1 x of
+                                                                                     CName s => s = "Link"
+                                                                                                orelse s = "Action"
+                                                                                   | _ => false)
+                                                | _ => (fn _ => false)
+
+                                        val calls = foldl (fn ((x, e, _), calls) =>
+                                                              if checkName x then
+                                                                  calls
+                                                              else
+                                                                  #2 (exp (penv, calls) e)) calls xets
+                                    in
+                                        (Rabble, [Rabble], calls)
+                                    end
+
+                                  | EApp (e1, e2) =>
                                     let
                                         val (p1, ps, calls) = combiner calls e1
                                         val (p2, calls) = exp (penv, calls) e2
@@ -187,6 +223,7 @@
                             (p, calls)
                         end
                       | EModProj _ => default
+
                       | EApp _ => apps ()
                       | EAbs (_, _, _, e) => 
                         let
--- a/tests/rec.ur	Tue Sep 09 11:46:33 2008 -0400
+++ b/tests/rec.ur	Tue Sep 09 12:36:13 2008 -0400
@@ -1,3 +1,4 @@
-val rec main = fn () => <html><body>
+
+fun main () : transaction page = return <html><body>
         <a link={main ()}>Ride again!</a>
 </body></html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/rec.urp	Tue Sep 09 12:36:13 2008 -0400
@@ -0,0 +1,5 @@
+debug
+database dbname=test
+exe /tmp/webapp
+
+rec