I removed dummy module [MBytes] an use [Hex] directly.

This commit is contained in:
Christian Rinderknecht 2019-03-20 16:31:33 +01:00
parent 495686bbd4
commit aa117ecfc2
No known key found for this signature in database
GPG Key ID: 9446816CFD267040
12 changed files with 23 additions and 36 deletions

6
AST.ml
View File

@ -453,7 +453,7 @@ and expr =
| MapExpr of map_expr | MapExpr of map_expr
| Var of Lexer.lexeme reg | Var of Lexer.lexeme reg
| FunCall of fun_call | FunCall of fun_call
| Bytes of (Lexer.lexeme * MBytes.t) reg | Bytes of (Lexer.lexeme * Hex.t) reg
| Unit of c_Unit | Unit of c_Unit
| Tuple of tuple | Tuple of tuple
| ParExpr of expr par reg | ParExpr of expr par reg
@ -590,7 +590,7 @@ and pattern =
| PVar of Lexer.lexeme reg | PVar of Lexer.lexeme reg
| PWild of wild | PWild of wild
| PInt of (Lexer.lexeme * Z.t) reg | PInt of (Lexer.lexeme * Z.t) reg
| PBytes of (Lexer.lexeme * MBytes.t) reg | PBytes of (Lexer.lexeme * Hex.t) reg
| PString of Lexer.lexeme reg | PString of Lexer.lexeme reg
| PUnit of c_Unit | PUnit of c_Unit
| PFalse of c_False | PFalse of c_False
@ -773,7 +773,7 @@ let print_string {region; value=lexeme} =
let print_bytes {region; value = lexeme, abstract} = let print_bytes {region; value = lexeme, abstract} =
printf "%s: Bytes (\"%s\", \"0x%s\")\n" printf "%s: Bytes (\"%s\", \"0x%s\")\n"
(compact region) lexeme (compact region) lexeme
(MBytes.to_hex abstract |> Hex.to_string) (Hex.to_string abstract)
let print_int {region; value = lexeme, abstract} = let print_int {region; value = lexeme, abstract} =
printf "%s: Int (\"%s\", %s)\n" printf "%s: Int (\"%s\", %s)\n"

View File

@ -437,7 +437,7 @@ and expr =
| MapExpr of map_expr | MapExpr of map_expr
| Var of Lexer.lexeme reg | Var of Lexer.lexeme reg
| FunCall of fun_call | FunCall of fun_call
| Bytes of (Lexer.lexeme * MBytes.t) reg | Bytes of (Lexer.lexeme * Hex.t) reg
| Unit of c_Unit | Unit of c_Unit
| Tuple of tuple | Tuple of tuple
| ParExpr of expr par reg | ParExpr of expr par reg
@ -574,7 +574,7 @@ and pattern =
| PVar of Lexer.lexeme reg | PVar of Lexer.lexeme reg
| PWild of wild | PWild of wild
| PInt of (Lexer.lexeme * Z.t) reg | PInt of (Lexer.lexeme * Z.t) reg
| PBytes of (Lexer.lexeme * MBytes.t) reg | PBytes of (Lexer.lexeme * Hex.t) reg
| PString of Lexer.lexeme reg | PString of Lexer.lexeme reg
| PUnit of c_Unit | PUnit of c_Unit
| PFalse of c_False | PFalse of c_False

View File

@ -18,7 +18,7 @@ module O = struct
PVar of var_name PVar of var_name
| PWild | PWild
| PInt of Z.t | PInt of Z.t
| PBytes of MBytes.t | PBytes of Hex.t
| PString of string | PString of string
| PUnit | PUnit
| PFalse | PFalse
@ -81,7 +81,7 @@ module O = struct
and constant = and constant =
Unit Unit
| Int of Z.t | String of string | Bytes of MBytes.t | Int of Z.t | String of string | Bytes of Hex.t
| False | True | False | True
| Null of type_expr | Null of type_expr
| EmptySet of type_expr | EmptySet of type_expr
@ -654,7 +654,7 @@ let s_ast (ast : I.ast) : O.ast =
(* and s_bytes {region; value = lexeme, abstract} = *) (* and s_bytes {region; value = lexeme, abstract} = *)
(* printf "%s: Bytes (\"%s\", \"0x%s\")\n" *) (* printf "%s: Bytes (\"%s\", \"0x%s\")\n" *)
(* (compact region) lexeme *) (* (compact region) lexeme *)
(* (MBytes.to_hex abstract |> Hex.to_string) *) (* (Hex.to_string abstract) *)
(* and s_int {region; value = lexeme, abstract} = *) (* and s_int {region; value = lexeme, abstract} = *)
(* printf "%s: Int (\"%s\", %s)\n" *) (* printf "%s: Int (\"%s\", %s)\n" *)

View File

@ -29,7 +29,7 @@ type t =
(* Literals *) (* Literals *)
String of lexeme Region.reg String of lexeme Region.reg
| Bytes of (lexeme * MBytes.t) Region.reg | Bytes of (lexeme * Hex.t) Region.reg
| Int of (lexeme * Z.t) Region.reg | Int of (lexeme * Z.t) Region.reg
| Ident of lexeme Region.reg | Ident of lexeme Region.reg
| Constr of lexeme Region.reg | Constr of lexeme Region.reg

View File

@ -28,7 +28,7 @@ type t =
(* Literals *) (* Literals *)
String of lexeme Region.reg String of lexeme Region.reg
| Bytes of (lexeme * MBytes.t) Region.reg | Bytes of (lexeme * Hex.t) Region.reg
| Int of (lexeme * Z.t) Region.reg | Int of (lexeme * Z.t) Region.reg
| Ident of lexeme Region.reg | Ident of lexeme Region.reg
| Constr of lexeme Region.reg | Constr of lexeme Region.reg
@ -142,7 +142,7 @@ let proj_token = function
| Bytes Region.{region; value = s,b} -> | Bytes Region.{region; value = s,b} ->
region, region,
sprintf "Bytes (\"%s\", \"0x%s\")" sprintf "Bytes (\"%s\", \"0x%s\")"
s (MBytes.to_hex b |> Hex.to_string) s (Hex.to_string b)
| Int Region.{region; value = s,n} -> | Int Region.{region; value = s,n} ->
region, sprintf "Int (\"%s\", %s)" s (Z.to_string n) region, sprintf "Int (\"%s\", %s)" s (Z.to_string n)
@ -470,7 +470,7 @@ let mk_string lexeme region = String Region.{region; value=lexeme}
let mk_bytes lexeme region = let mk_bytes lexeme region =
let norm = Str.(global_replace (regexp "_") "" lexeme) in let norm = Str.(global_replace (regexp "_") "" lexeme) in
let value = lexeme, MBytes.of_hex (Hex.of_string norm) let value = lexeme, Hex.of_string norm
in Bytes Region.{region; value} in Bytes Region.{region; value}
type int_err = Non_canonical_zero type int_err = Non_canonical_zero

View File

@ -1,6 +0,0 @@
(* TEMPORARY: SHOULD BE ERASED *)
type t = Hex.t
let of_hex x = x
let to_hex x = x

View File

@ -1,6 +0,0 @@
(* TEMPORARY: SHOULD BE ERASED *)
type t
val of_hex : Hex.t -> t
val to_hex : t -> Hex.t

View File

@ -6,7 +6,7 @@
(* Literals *) (* Literals *)
%token <LexToken.lexeme Region.reg> String %token <LexToken.lexeme Region.reg> String
%token <(LexToken.lexeme * MBytes.t) Region.reg> Bytes %token <(LexToken.lexeme * Hex.t) Region.reg> Bytes
%token <(LexToken.lexeme * Z.t) Region.reg> Int %token <(LexToken.lexeme * Z.t) Region.reg> Int
%token <LexToken.lexeme Region.reg> Ident %token <LexToken.lexeme Region.reg> Ident
%token <LexToken.lexeme Region.reg> Constr %token <LexToken.lexeme Region.reg> Constr

Binary file not shown.

View File

@ -19,7 +19,7 @@ entrypoint contribute (storage store : store;
else else
case store.backers[sender] of case store.backers[sender] of
None -> store.backers[sender] := Some (amount) None -> store.backers[sender] := Some (amount)
// patch store.backers with map sender -> amount end // None -> patch store.backers with map sender -> amount end
| _ -> skip | _ -> skip
end end
end with (store, operations) end with (store, operations)
@ -32,8 +32,8 @@ entrypoint withdraw (storage store : store; const sender : address)
if now >= store.deadline then if now >= store.deadline then
if balance >= store.goal then if balance >= store.goal then
begin begin
// patch store with record funded = True end;
store.funded := True; store.funded := True;
// patch store with record funded = True end;
operations := [Transfer (owner, balance)] operations := [Transfer (owner, balance)]
end end
else fail "Below target" else fail "Below target"

View File

@ -18,7 +18,7 @@ module O = struct
PVar of var_name PVar of var_name
| PWild | PWild
| PInt of Z.t | PInt of Z.t
| PBytes of MBytes.t | PBytes of Hex.t
| PString of string | PString of string
| PUnit | PUnit
| PFalse | PFalse
@ -85,7 +85,7 @@ module O = struct
and constant = and constant =
Unit Unit
| Int of Z.t | String of string | Bytes of MBytes.t | Int of Z.t | String of string | Bytes of Hex.t
| False | True | False | True
| Null | Null
| EmptySet | EmptySet
@ -272,4 +272,3 @@ let a_ast I.{types; storage_decl; declarations; orig} =
O.{types; storage_decl; declarations; orig} O.{types; storage_decl; declarations; orig}
let annotate : I.ast -> O.ast = a_ast let annotate : I.ast -> O.ast = a_ast

View File

@ -16,7 +16,7 @@ module O : sig
PVar of var_name PVar of var_name
| PWild | PWild
| PInt of Z.t | PInt of Z.t
| PBytes of MBytes.t | PBytes of Hex.t
| PString of string | PString of string
| PUnit | PUnit
| PFalse | PFalse
@ -83,7 +83,7 @@ module O : sig
and constant = and constant =
Unit Unit
| Int of Z.t | String of string | Bytes of MBytes.t | Int of Z.t | String of string | Bytes of Hex.t
| False | True | False | True
| Null | Null
| EmptySet | EmptySet