From e71cbc1665cc85241b7ebd5c1b8c6310f8401ae1 Mon Sep 17 00:00:00 2001
From: charguer <arthur@chargueraud.org>
Date: Tue, 1 Mar 2016 16:36:25 +0100
Subject: [PATCH] generation_ok

---
 generator/TODO                      | 10 +++++++---
 generator/js_of_ast.ml              |  5 ++++-
 generator/stdlib_ml/stdlib.js       |  4 ++++
 generator/tests/jsref/JsNumber.ml   |  2 +-
 generator/tests/jsref/LibReflect.ml |  2 +-
 5 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/generator/TODO b/generator/TODO
index a6abd71..7981a9b 100644
--- a/generator/TODO
+++ b/generator/TODO
@@ -1,4 +1,10 @@
 
+- clean up stdlib.ml
+
+- implement stdlib.js to match all functions of stdlib.ml
+
+- remove JsNumber by binding a set of operations in stdlib.js 
+  implemented using builtin JS primitives
 
 - reactivate
 	  default: throw "No matching case for switch";
@@ -15,13 +21,11 @@
   => TODO: look for code that already does this for esprima.
 
 
-
-
 - check in Shared.ml whether we need to take absolute values
 	let string_sub s n l =
 	  substring (int_abs n) (int_abs l) s
 
-- 
+- here:
    string_sub str (int_of_float k0) 1
    => TODO: check k0 is not negative 
 
diff --git a/generator/js_of_ast.ml b/generator/js_of_ast.ml
index 8acb5ff..5e8c9ac 100644
--- a/generator/js_of_ast.ml
+++ b/generator/js_of_ast.ml
@@ -678,7 +678,10 @@ and js_of_expression ctx dest e =
   | Texp_construct (p, cd, el) ->
     let cstr_fullname = string_of_longident p.txt in
     let cstr_name = cd.cstr_name in
-    let cstr_fullname = if cstr_fullname = "::" then "mk_cons" else cstr_fullname in  (* TODO: clean up this hack *)
+    let cstr_fullname = 
+      if cstr_fullname = "[]" then "mk_nil" 
+      else if cstr_fullname = "::" then "mk_cons" 
+      else cstr_fullname in  (* TODO: clean up this hack *)
     (*let styp = string_of_type_exp e.exp_type in*)
     let sexp =
       if is_sbool cstr_name then cstr_name else
diff --git a/generator/stdlib_ml/stdlib.js b/generator/stdlib_ml/stdlib.js
index e983dda..521b1c0 100644
--- a/generator/stdlib_ml/stdlib.js
+++ b/generator/stdlib_ml/stdlib.js
@@ -1,4 +1,8 @@
 
+
+var max_float = Number.MAX_VALUE; // TODO: find absolute value for this
+
+
 var mk_nil = function() {
    return { type: "list", tag: "[]" };
 };
diff --git a/generator/tests/jsref/JsNumber.ml b/generator/tests/jsref/JsNumber.ml
index 2b1b250..e4a10a6 100644
--- a/generator/tests/jsref/JsNumber.ml
+++ b/generator/tests/jsref/JsNumber.ml
@@ -1,7 +1,7 @@
 open Fappli_IEEE_bits
 open LibReflect
 
-let nat_eq = int_eq
+let nat_eq x y = int_eq x y 
 
 type number = binary64
 
diff --git a/generator/tests/jsref/LibReflect.ml b/generator/tests/jsref/LibReflect.ml
index 6a03ff9..f71de61 100644
--- a/generator/tests/jsref/LibReflect.ml
+++ b/generator/tests/jsref/LibReflect.ml
@@ -52,5 +52,5 @@ let bool_comparable x y =
 (** val prop_eq_decidable :
     coq_Decidable -> coq_Decidable -> coq_Decidable **)
 
-let prop_eq_decidable = bool_eq
+let prop_eq_decidable x y = bool_eq x y
 
-- 
GitLab