changeset 276:ed4af33681d8

Switch base types to 64-bit versions
author Adam Chlipala <adamc@hcoop.net>
date Tue, 02 Sep 2008 14:59:27 -0400 (2008-09-02)
parents 73456bfde988
children 286f734db702
files include/types.h src/c/urweb.c src/cjr_print.sml src/prim.sig src/prim.sml
diffstat 5 files changed, 31 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/include/types.h	Tue Sep 02 14:40:57 2008 -0400
+++ b/include/types.h	Tue Sep 02 14:59:27 2008 -0400
@@ -1,5 +1,5 @@
-typedef int lw_Basis_int;
-typedef float lw_Basis_float;
+typedef long long lw_Basis_int;
+typedef double lw_Basis_float;
 typedef char* lw_Basis_string;
 
 struct __lws_0 {
--- a/src/c/urweb.c	Tue Sep 02 14:40:57 2008 -0400
+++ b/src/c/urweb.c	Tue Sep 02 14:59:27 2008 -0400
@@ -233,7 +233,7 @@
   int len;
   lw_check_heap(ctx, INTS_MAX);
   result = ctx->heap_front;
-  sprintf(result, "%d%n", n, &len);
+  sprintf(result, "%lld%n", n, &len);
   ctx->heap_front += len+1;
   return result;
 }
@@ -282,7 +282,7 @@
 static void lw_Basis_attrifyInt_w_unsafe(lw_context ctx, lw_Basis_int n) {
   int len;
 
-  sprintf(ctx->page_front, "%d%n", n, &len);
+  sprintf(ctx->page_front, "%lld%n", n, &len);
   ctx->page_front += len;
 }
 
@@ -326,7 +326,7 @@
 
   lw_check_heap(ctx, INTS_MAX);
   r = ctx->heap_front;
-  sprintf(r, "%d%n", n, &len);
+  sprintf(r, "%lld%n", n, &len);
   ctx->heap_front += len+1;
   return r;
 }
@@ -375,7 +375,7 @@
 static void lw_Basis_urlifyInt_w_unsafe(lw_context ctx, lw_Basis_int n) {
   int len;
 
-  sprintf(ctx->page_front, "%d%n", n, &len);
+  sprintf(ctx->page_front, "%lld%n", n, &len);
   ctx->page_front += len;
 }
 
@@ -430,16 +430,16 @@
 
 lw_Basis_int lw_Basis_unurlifyInt(lw_context ctx, char **s) {
   char *new_s = lw_unurlify_advance(*s);
-  int r;
+  lw_Basis_int r;
 
-  r = atoi(*s);
+  r = atoll(*s);
   *s = new_s;
   return r;
 }
 
 lw_Basis_float lw_Basis_unurlifyFloat(lw_context ctx, char **s) {
   char *new_s = lw_unurlify_advance(*s);
-  int r;
+  lw_Basis_float r;
 
   r = atof(*s);
   *s = new_s;
--- a/src/cjr_print.sml	Tue Sep 02 14:40:57 2008 -0400
+++ b/src/cjr_print.sml	Tue Sep 02 14:59:27 2008 -0400
@@ -157,7 +157,7 @@
               space,
               string "!=",
               space,
-              Prim.p_t (Prim.Int n),
+              Prim.p_t_GCC (Prim.Int n),
               string ")",
               space,
               exit],
@@ -169,7 +169,7 @@
               string (Int.toString depth),
               string ",",
               space,
-              Prim.p_t (Prim.String s),
+              Prim.p_t_GCC (Prim.String s),
               string "))",
               space,
               exit],
@@ -323,7 +323,7 @@
 
 fun p_exp' par env (e, loc) =
     case e of
-        EPrim p => Prim.p_t p
+        EPrim p => Prim.p_t_GCC p
       | ERel n => p_rel env n
       | ENamed n => p_enamed env n
       | ECon (Enum, pc, _) => p_patCon env pc
--- a/src/prim.sig	Tue Sep 02 14:40:57 2008 -0400
+++ b/src/prim.sig	Tue Sep 02 14:59:27 2008 -0400
@@ -33,6 +33,7 @@
            | String of string
 
     val p_t : t Print.printer
+    val p_t_GCC : t Print.printer
 
     val equal : t * t -> bool
 
--- a/src/prim.sml	Tue Sep 02 14:40:57 2008 -0400
+++ b/src/prim.sml	Tue Sep 02 14:59:27 2008 -0400
@@ -41,6 +41,24 @@
       | Float n => string (Real64.toString n)
       | String s => box [string "\"", string (String.toString s), string "\""]
 
+fun int2s n =
+    if Int64.compare (n, Int64.fromInt 0) = LESS then
+        "-" ^ Int64.toString (Int64.~ n) ^ "LL"
+    else
+        Int64.toString n ^ "LL"
+
+fun float2s n =
+    if Real64.compare (n, Real64.fromInt 0) = LESS then
+        "-" ^ Real64.toString (Real64.~ n) ^ "L"
+    else
+        Real64.toString n ^ "L"
+
+fun p_t_GCC t =
+    case t of
+        Int n => string (int2s n)
+      | Float n => string (float2s n)
+      | String s => box [string "\"", string (String.toString s), string "\""]
+
 fun equal x =
     case x of
         (Int n1, Int n2) => n1 = n2