Skip to content

Commit 94eab5e

Browse files
committed
Fixes for mini version and *.size in ocaml generation
1 parent dd5816d commit 94eab5e

4 files changed

Lines changed: 12 additions & 32 deletions

File tree

tools/liquidity/env/liquidityEnv.ml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ module Map : sig
155155
val remove : 'key -> ('key, 'value) map -> ('key, 'value) map
156156

157157
val mem : 'key -> ('key, 'value) map -> bool (* NOT TESTED *)
158-
val size : ('key, 'value) map -> int
158+
val size : ('key, 'value) map -> nat
159159

160160
end = struct
161161

@@ -236,7 +236,7 @@ end = struct
236236
let map = (Obj.magic map : 'value ObjMap.t) in
237237
ObjMap.mem key map
238238

239-
let size map = ObjMap.cardinal (Obj.magic map)
239+
let size map = Int (Z.of_int (ObjMap.cardinal (Obj.magic map)))
240240

241241
end
242242
include Array (* Remove ? *)
@@ -257,7 +257,7 @@ module Set : sig
257257
val fold : ( 'key * 'acc -> 'acc) -> 'key set -> 'acc -> 'acc
258258
val iter : ( 'key -> unit) -> 'key set -> unit
259259
val map : ('key -> 'res) -> 'key set -> 'res set
260-
val size : 'key set -> int
260+
val size : 'key set -> nat
261261

262262
end = struct
263263

@@ -325,7 +325,7 @@ end = struct
325325
let set = (Obj.magic set : ObjSet.t) in
326326
ObjSet.iter (fun x -> f x) set
327327

328-
let size set = ObjSet.cardinal (Obj.magic set)
328+
let size set = Int (Z.of_int (ObjSet.cardinal (Obj.magic set)))
329329

330330
end
331331

@@ -468,7 +468,7 @@ module List : sig
468468
val iter : ('a -> unit) -> 'a list -> unit
469469
val map : ('a -> 'b) -> 'a list -> 'b list
470470
val rev : 'a list -> 'a list
471-
val size : 'a list -> integer
471+
val size : 'a list -> nat
472472

473473
end = struct
474474

tools/liquidity/liquidMain.ml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -73,31 +73,11 @@ let compile_liquid_file filename =
7373
Printf.eprintf "Constant initial storage generated in %S\n%!" output
7474
| LiquidInit.Init_code (_, pre_init) ->
7575
let mic_init = LiquidToTezos.convert_contract ~expand:true pre_init in
76-
let js = LiquidToTezos.json_of_contract mic_init in
77-
Printf.eprintf "%s\n%!" js;
7876
let s = LiquidToTezos.line_of_contract mic_init in
7977
let output = env.filename ^ ".initializer.tz" in
8078
FileString.write_file output s;
8179
Printf.eprintf "Storage initializer generated in %S\n%!" output
8280
end;
83-
(* Printf.eprintf "ici0\n%!"; *)
84-
85-
(* begin *)
86-
(* let read_tezos_const filename = *)
87-
(* let s = FileString.read_file filename in *)
88-
(* match LiquidFromTezos.const_of_string filename s with *)
89-
(* | Some (c, loc_table) -> c, loc_table *)
90-
(* | _ -> *)
91-
(* Printf.eprintf "Errors parsing in %S\n%!" filename; *)
92-
(* exit 2 *)
93-
(* in *)
94-
(* let filename = filename ^ ".init.tz" in *)
95-
(* Printf.eprintf "ici1\n%!"; *)
96-
(* let c, env = read_tezos_const filename in *)
97-
(* Printf.eprintf "ici\n%!"; *)
98-
(* let c = LiquidFromTezos.convert_const_type env c syntax_ast.storage in *)
99-
(* Printf.eprintf "Input: %s\n%!" (LiquidPrinter.Liquid.string_of_const c); *)
100-
(* end; *)
10181

10282
let output = filename ^ ".tz" in
10383
let c = LiquidToTezos.convert_contract ~expand:false pre_michelson in

tools/liquidity/ocaml/liquidOCamlTranslate.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ let clean_ast =
3131

3232
| { pstr_desc =
3333
Pstr_extension
34-
(({ Asttypes.txt = "entry" },
34+
(({ Asttypes.txt = "entry" | "init" },
3535
PStr [entry]),[])
3636
} ->
3737
mapper.structure_item mapper entry

tools/liquidity/without-tezos/liquidToTezos.ml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,22 @@ let convert_contract ~expand (c : noloc_michelson contract) =
1919
LiquidEmit.emit_contract ~expand c
2020

2121
let convert_const (c : const) =
22-
failwith "mini version cannot do it"
22+
failwith "mini version cannot convert const"
2323

2424
let json_of_contract (c : michelson_exp contract) =
25-
failwith "mini version cannot do it"
25+
failwith "mini version cannot generate json contract"
2626

2727
let contract_of_json _ =
28-
failwith "mini version cannot do it"
28+
failwith "mini version cannot parse json contract"
2929

3030
let json_of_const _ =
31-
failwith "mini version cannot do it"
31+
failwith "mini version cannot generate json constant"
3232

3333
let const_of_json _ =
34-
failwith "mini version cannot do it"
34+
failwith "mini version cannot parse json constant"
3535

3636
let const_of_ezjson _ =
37-
failwith "mini version cannot do it"
37+
failwith "mini version cannot parse ezjson constant"
3838

3939
let read_tezos_file (_filename : string) =
4040
failwith "mini version cannot decompile"

0 commit comments

Comments
 (0)