From 94eab5e712c7e75052b5c29a567b145bf090a0f0 Mon Sep 17 00:00:00 2001 From: Alain Mebsout Date: Tue, 23 Jan 2018 15:16:09 +0100 Subject: [PATCH] Fixes for mini version and *.size in ocaml generation --- tools/liquidity/env/liquidityEnv.ml | 10 +++++----- tools/liquidity/liquidMain.ml | 20 ------------------- tools/liquidity/ocaml/liquidOCamlTranslate.ml | 2 +- .../liquidity/without-tezos/liquidToTezos.ml | 12 +++++------ 4 files changed, 12 insertions(+), 32 deletions(-) diff --git a/tools/liquidity/env/liquidityEnv.ml b/tools/liquidity/env/liquidityEnv.ml index 23ad0a70..5ce16543 100644 --- a/tools/liquidity/env/liquidityEnv.ml +++ b/tools/liquidity/env/liquidityEnv.ml @@ -155,7 +155,7 @@ module Map : sig val remove : 'key -> ('key, 'value) map -> ('key, 'value) map val mem : 'key -> ('key, 'value) map -> bool (* NOT TESTED *) - val size : ('key, 'value) map -> int + val size : ('key, 'value) map -> nat end = struct @@ -236,7 +236,7 @@ end = struct let map = (Obj.magic map : 'value ObjMap.t) in ObjMap.mem key map - let size map = ObjMap.cardinal (Obj.magic map) + let size map = Int (Z.of_int (ObjMap.cardinal (Obj.magic map))) end include Array (* Remove ? *) @@ -257,7 +257,7 @@ module Set : sig val fold : ( 'key * 'acc -> 'acc) -> 'key set -> 'acc -> 'acc val iter : ( 'key -> unit) -> 'key set -> unit val map : ('key -> 'res) -> 'key set -> 'res set - val size : 'key set -> int + val size : 'key set -> nat end = struct @@ -325,7 +325,7 @@ end = struct let set = (Obj.magic set : ObjSet.t) in ObjSet.iter (fun x -> f x) set - let size set = ObjSet.cardinal (Obj.magic set) + let size set = Int (Z.of_int (ObjSet.cardinal (Obj.magic set))) end @@ -468,7 +468,7 @@ module List : sig val iter : ('a -> unit) -> 'a list -> unit val map : ('a -> 'b) -> 'a list -> 'b list val rev : 'a list -> 'a list - val size : 'a list -> integer + val size : 'a list -> nat end = struct diff --git a/tools/liquidity/liquidMain.ml b/tools/liquidity/liquidMain.ml index 6ede4728..1793820b 100644 --- a/tools/liquidity/liquidMain.ml +++ b/tools/liquidity/liquidMain.ml @@ -73,31 +73,11 @@ let compile_liquid_file filename = Printf.eprintf "Constant initial storage generated in %S\n%!" output | LiquidInit.Init_code (_, pre_init) -> let mic_init = LiquidToTezos.convert_contract ~expand:true pre_init in - let js = LiquidToTezos.json_of_contract mic_init in - Printf.eprintf "%s\n%!" js; let s = LiquidToTezos.line_of_contract mic_init in let output = env.filename ^ ".initializer.tz" in FileString.write_file output s; Printf.eprintf "Storage initializer generated in %S\n%!" output end; - (* Printf.eprintf "ici0\n%!"; *) - - (* begin *) - (* let read_tezos_const filename = *) - (* let s = FileString.read_file filename in *) - (* match LiquidFromTezos.const_of_string filename s with *) - (* | Some (c, loc_table) -> c, loc_table *) - (* | _ -> *) - (* Printf.eprintf "Errors parsing in %S\n%!" filename; *) - (* exit 2 *) - (* in *) - (* let filename = filename ^ ".init.tz" in *) - (* Printf.eprintf "ici1\n%!"; *) - (* let c, env = read_tezos_const filename in *) - (* Printf.eprintf "ici\n%!"; *) - (* let c = LiquidFromTezos.convert_const_type env c syntax_ast.storage in *) - (* Printf.eprintf "Input: %s\n%!" (LiquidPrinter.Liquid.string_of_const c); *) - (* end; *) let output = filename ^ ".tz" in let c = LiquidToTezos.convert_contract ~expand:false pre_michelson in diff --git a/tools/liquidity/ocaml/liquidOCamlTranslate.ml b/tools/liquidity/ocaml/liquidOCamlTranslate.ml index 031847b6..55740f76 100644 --- a/tools/liquidity/ocaml/liquidOCamlTranslate.ml +++ b/tools/liquidity/ocaml/liquidOCamlTranslate.ml @@ -31,7 +31,7 @@ let clean_ast = | { pstr_desc = Pstr_extension - (({ Asttypes.txt = "entry" }, + (({ Asttypes.txt = "entry" | "init" }, PStr [entry]),[]) } -> mapper.structure_item mapper entry diff --git a/tools/liquidity/without-tezos/liquidToTezos.ml b/tools/liquidity/without-tezos/liquidToTezos.ml index 34172c0c..409264a3 100644 --- a/tools/liquidity/without-tezos/liquidToTezos.ml +++ b/tools/liquidity/without-tezos/liquidToTezos.ml @@ -19,22 +19,22 @@ let convert_contract ~expand (c : noloc_michelson contract) = LiquidEmit.emit_contract ~expand c let convert_const (c : const) = - failwith "mini version cannot do it" + failwith "mini version cannot convert const" let json_of_contract (c : michelson_exp contract) = - failwith "mini version cannot do it" + failwith "mini version cannot generate json contract" let contract_of_json _ = - failwith "mini version cannot do it" + failwith "mini version cannot parse json contract" let json_of_const _ = - failwith "mini version cannot do it" + failwith "mini version cannot generate json constant" let const_of_json _ = - failwith "mini version cannot do it" + failwith "mini version cannot parse json constant" let const_of_ezjson _ = - failwith "mini version cannot do it" + failwith "mini version cannot parse ezjson constant" let read_tezos_file (_filename : string) = failwith "mini version cannot decompile"