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

View File

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

View File

@ -18,7 +18,7 @@ module O = struct
PVar of var_name
| PWild
| PInt of Z.t
| PBytes of MBytes.t
| PBytes of Hex.t
| PString of string
| PUnit
| PFalse
@ -81,7 +81,7 @@ module O = struct
and constant =
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
| Null 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} = *)
(* printf "%s: Bytes (\"%s\", \"0x%s\")\n" *)
(* (compact region) lexeme *)
(* (MBytes.to_hex abstract |> Hex.to_string) *)
(* (Hex.to_string abstract) *)
(* and s_int {region; value = lexeme, abstract} = *)
(* printf "%s: Int (\"%s\", %s)\n" *)

View File

@ -29,7 +29,7 @@ type t =
(* Literals *)
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
| Ident of lexeme Region.reg
| Constr of lexeme Region.reg

View File

@ -28,7 +28,7 @@ type t =
(* Literals *)
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
| Ident of lexeme Region.reg
| Constr of lexeme Region.reg
@ -142,7 +142,7 @@ let proj_token = function
| Bytes Region.{region; value = s,b} ->
region,
sprintf "Bytes (\"%s\", \"0x%s\")"
s (MBytes.to_hex b |> Hex.to_string)
s (Hex.to_string b)
| Int Region.{region; value = s,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 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}
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 *)
%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 Region.reg> Ident
%token <LexToken.lexeme Region.reg> Constr

Binary file not shown.

View File

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

View File

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

View File

@ -16,7 +16,7 @@ module O : sig
PVar of var_name
| PWild
| PInt of Z.t
| PBytes of MBytes.t
| PBytes of Hex.t
| PString of string
| PUnit
| PFalse
@ -83,7 +83,7 @@ module O : sig
and constant =
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
| Null
| EmptySet