changeset 180:c7a5c8e0a0e0

Cjrize EStrcat
author Adam Chlipala <adamc@hcoop.net>
date Sun, 03 Aug 2008 11:03:35 -0400
parents 3bbed533fbd2
children 31dfab1d4050
files include/lacweb.h src/c/lacweb.c src/cjrize.sml
diffstat 3 files changed, 24 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/include/lacweb.h	Sun Aug 03 10:48:36 2008 -0400
+++ b/include/lacweb.h	Sun Aug 03 11:03:35 2008 -0400
@@ -48,3 +48,5 @@
 lw_Basis_int lw_unurlifyInt(char **);
 lw_Basis_float lw_unurlifyFloat(char **);
 lw_Basis_string lw_unurlifyString(lw_context, char **);
+
+lw_Basis_string lw_Basis_strcat(lw_context, lw_Basis_string, lw_Basis_string);
--- a/src/c/lacweb.c	Sun Aug 03 10:48:36 2008 -0400
+++ b/src/c/lacweb.c	Sun Aug 03 11:03:35 2008 -0400
@@ -505,3 +505,18 @@
     }
   }
 }
+
+lw_Basis_string lw_Basis_strcat(lw_context ctx, lw_Basis_string s1, lw_Basis_string s2) {
+  int len = strlen(s1) + strlen(s2) + 1;
+  char *s;
+
+  lw_check(ctx, len);
+
+  s = ctx->heap_front;
+
+  strcpy(s, s1);
+  strcat(s, s2);
+  ctx->heap_front += len;
+
+  return s;
+}
--- a/src/cjrize.sml	Sun Aug 03 10:48:36 2008 -0400
+++ b/src/cjrize.sml	Sun Aug 03 11:03:35 2008 -0400
@@ -155,7 +155,13 @@
 
       | L.ECase _ => raise Fail "Cjrize ECase"
 
-      | L.EStrcat _ => raise Fail "Cjrize EStrcat"
+      | L.EStrcat (e1, e2) =>
+        let
+            val (e1, sm) = cifyExp (e1, sm)
+            val (e2, sm) = cifyExp (e2, sm)
+        in
+            ((L'.EFfiApp ("Basis", "strcat", [e1, e2]), loc), sm)
+        end
 
       | L.EWrite e =>
         let