changeset 972:733f67bb64e7

Functions working with interpretation
author Adam Chlipala <adamc@hcoop.net>
date Tue, 22 Sep 2009 13:27:47 -0400
parents c22e524a6dd3
children e30c2409c9d0
files src/c/urweb.c tests/jscomp.ur
diffstat 2 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/c/urweb.c	Tue Sep 22 13:23:27 2009 -0400
+++ b/src/c/urweb.c	Tue Sep 22 13:27:47 2009 -0400
@@ -1292,7 +1292,7 @@
   strcpy(ctx->script.front, s);
   ctx->script.front += s_len;
   strcpy(ctx->script.front, "));");
-  ctx->script.front += 2;
+  ctx->script.front += 3;
 
   return ctx->source_count++;
 }
@@ -1307,7 +1307,7 @@
   strcpy(ctx->script.front, s);
   ctx->script.front += s_len;
   strcpy(ctx->script.front, "));");
-  ctx->script.front += 2;
+  ctx->script.front += 3;
 
   return uw_unit_v;
 }
--- a/tests/jscomp.ur	Tue Sep 22 13:23:27 2009 -0400
+++ b/tests/jscomp.ur	Tue Sep 22 13:27:47 2009 -0400
@@ -1,10 +1,15 @@
 fun main () =
     s <- source "";
+    f <- source (plus 1); 
 
     return <xml><body>
-      <ctextbox source={s}/><br/>
+      <ctextbox source={s}/><br/><br/>
+
+      Function: <button value="+1" onclick={set f (plus 1)}/>
+      <button value="*3" onclick={set f (times 3)}/><br/><br/>
 
       <button value="Echo" onclick={s <- get s; alert s}/>
       <button value="+1" onclick={s <- get s; alert (show (readError s + 1))}/>
       <button value="*3" onclick={s <- get s; alert (show ((readError s) * 3))}/>
+      <button value="f" onclick={s <- get s; f <- get f; alert (show (f (readError s)))}/>
     </body></xml>