diff src/jscomp.sml @ 1848:e15234fbb163

Basis.tryRpc
author Adam Chlipala <adam@chlipala.net>
date Tue, 16 Apr 2013 10:55:48 -0400
parents 8958b580d026
children 98895243b5b6
line wrap: on
line diff
--- a/src/jscomp.sml	Mon Apr 01 10:13:49 2013 -0400
+++ b/src/jscomp.sml	Tue Apr 16 10:55:48 2013 -0400
@@ -1,4 +1,4 @@
-(* Copyright (c) 2008-2012, Adam Chlipala
+(* Copyright (c) 2008-2013, Adam Chlipala
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -930,10 +930,21 @@
                                  st)
                             end
 
-                          | EServerCall (e, t, eff) =>
+                          | EServerCall (e, t, eff, fm) =>
                             let
                                 val (e, st) = jsE inner (e, st)
                                 val (unurl, st) = unurlifyExp loc (t, st)
+                                val lastArg = case fm of
+                                                  None => "null"
+                                                | Error =>
+                                                  let
+                                                      val isN = if isNullable t then
+                                                                    "true"
+                                                                else
+                                                                    "false"
+                                                  in
+                                                    "cons({c:\"c\",v:" ^ isN ^ "},null)"
+                                                  end
                             in
                                 (strcat [str ("{c:\"f\",f:rc,a:cons({c:\"c\",v:\""
                                               ^ Settings.getUrlPrefix ()
@@ -944,7 +955,7 @@
                                               ^ (case eff of
                                                      ReadCookieWrite => "true"
                                                    | _ => "false")
-                                              ^ "},null)))))}")],
+                                              ^ "}," ^ lastArg ^ ")))))}")],
                                  st)
                             end
 
@@ -1231,11 +1242,11 @@
                      ((ESignalSource e, loc), st)
                  end
                  
-               | EServerCall (e1, t, ef) =>
+               | EServerCall (e1, t, ef, fm) =>
                  let
                      val (e1, st) = exp outer (e1, st)
                  in
-                     ((EServerCall (e1, t, ef), loc), st)
+                     ((EServerCall (e1, t, ef, fm), loc), st)
                  end
                | ERecv (e1, t) =>
                  let