changeset 1836:276fa06428ba

Ignore polymorphism in JavaScript calls to custom FFI functions, allowing a kind of simple dynamic typing (unsafe, of course)
author Adam Chlipala <adam@chlipala.net>
date Tue, 11 Dec 2012 15:58:23 -0500
parents a8b273f1f7e3
children 7cf34f8b7b93
files src/monoize.sml tests/polyjs.ur tests/polyjs.urp tests/polyjsFfi.urs
diffstat 4 files changed, 21 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/monoize.sml	Fri Nov 30 10:02:13 2012 -0500
+++ b/src/monoize.sml	Tue Dec 11 15:58:23 2012 -0500
@@ -4087,7 +4087,15 @@
             in
                 ((L'.EAbs (x, monoType env dom, monoType env ran, e), loc), fm)
             end
-          | L.ECApp _ => poly ()
+
+          | L.ECApp (e, _) =>
+            let
+                val (e, fm) = monoExp (env, st, fm) e
+            in
+                case #1 e of
+                    L'.EFfi _ => (e, fm)
+                  | _ => poly ()
+            end
           | L.ECAbs _ => poly ()
 
           | L.EFfi mx => ((L'.EFfi mx, loc), fm)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/polyjs.ur	Tue Dec 11 15:58:23 2012 -0500
@@ -0,0 +1,5 @@
+open PolyjsFfi
+
+fun main () : transaction page = return <xml><body>
+  <button onclick={fn _ => alert (one "hi" ^ two "bye")}/>
+</body></xml>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/polyjs.urp	Tue Dec 11 15:58:23 2012 -0500
@@ -0,0 +1,5 @@
+ffi polyjsFfi
+jsFunc PolyjsFfi.one=one
+jsFunc PolyjsFfi.two=two
+
+polyjs
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/polyjsFfi.urs	Tue Dec 11 15:58:23 2012 -0500
@@ -0,0 +1,2 @@
+val one : a ::: Type -> a -> a
+val two : a ::: Type -> b ::: Type -> a -> b