new constant : add self (michelson SELF)

This commit is contained in:
Lesenechal Remi 2020-02-25 15:23:28 +01:00
parent 6a09ac866c
commit 550e6b084b
4 changed files with 13 additions and 2 deletions

View File

@ -66,7 +66,6 @@ module Simplify = struct
module Pascaligo = struct
let constants = function
(* Tezos module (ex-Michelson) *)
| "Tezos.chain_id" -> ok C_CHAIN_ID
| "chain_id" -> ok C_CHAIN_ID (* Deprecated *)
| "get_chain_id" -> ok C_CHAIN_ID (* Deprecated *)
@ -79,7 +78,8 @@ module Simplify = struct
| "Tezos.sender" -> ok C_SENDER
| "sender" -> ok C_SENDER (* Deprecated *)
| "Tezos.address" -> ok C_ADDRESS
| "address" -> ok C_ADDRESS (* Deprecated *)
| "address" -> ok C_ADDRESS (* Deprecated *)
| "Tezos.self" -> ok C_SELF
| "Tezos.self_address" -> ok C_SELF_ADDRESS
| "self_address" -> ok C_SELF_ADDRESS (* Deprecated *)
| "Tezos.implicit_account" -> ok C_IMPLICIT_ACCOUNT
@ -267,6 +267,7 @@ module Simplify = struct
| "sender" -> ok C_SENDER (* Deprecated *)
| "Tezos.address" -> ok C_ADDRESS
| "Current.address" -> ok C_ADDRESS (* Deprecated *)
| "Tezos.self" -> ok C_SELF
| "Tezos.self_address" -> ok C_SELF_ADDRESS
| "Current.self_address" -> ok C_SELF_ADDRESS (* Deprecated *)
| "Tezos.implicit_account" -> ok C_IMPLICIT_ACCOUNT
@ -791,6 +792,11 @@ module Typer = struct
let self_address = typer_0 "SELF_ADDRESS" @@ fun _ ->
ok @@ t_address ()
let self = typer_0 "SELF" @@ fun tv_opt ->
match tv_opt with
| None -> simple_fail "untyped SELF"
| Some t -> ok @@ t
let implicit_account = typer_1 "IMPLICIT_ACCOUNT" @@ fun key_hash ->
let%bind () = assert_t_key_hash key_hash in
ok @@ t_contract (t_unit () ) ()
@ -1228,6 +1234,7 @@ module Typer = struct
| C_SENDER -> ok @@ sender ;
| C_SOURCE -> ok @@ source ;
| C_ADDRESS -> ok @@ address ;
| C_SELF -> ok @@ self;
| C_SELF_ADDRESS -> ok @@ self_address;
| C_IMPLICIT_ACCOUNT -> ok @@ implicit_account;
| C_SET_DELEGATE -> ok @@ set_delegate ;
@ -1303,6 +1310,7 @@ module Compiler = struct
| C_AMOUNT -> ok @@ simple_constant @@ prim I_AMOUNT
| C_ADDRESS -> ok @@ simple_unary @@ prim I_ADDRESS
| C_SELF_ADDRESS -> ok @@ simple_constant @@ seq [prim I_SELF; prim I_ADDRESS]
| C_SELF -> ok @@ simple_constant @@ seq [prim I_SELF]
| C_IMPLICIT_ACCOUNT -> ok @@ simple_unary @@ prim I_IMPLICIT_ACCOUNT
| C_SET_DELEGATE -> ok @@ simple_unary @@ prim I_SET_DELEGATE
| C_NOW -> ok @@ simple_constant @@ prim I_NOW

View File

@ -143,6 +143,7 @@ let constant ppf : constant' -> unit = function
| C_SOURCE -> fprintf ppf "SOURCE"
| C_SENDER -> fprintf ppf "SENDER"
| C_ADDRESS -> fprintf ppf "ADDRESS"
| C_SELF -> fprintf ppf "SELF"
| C_SELF_ADDRESS -> fprintf ppf "SELF_ADDRESS"
| C_IMPLICIT_ACCOUNT -> fprintf ppf "IMPLICIT_ACCOUNT"
| C_SET_DELEGATE -> fprintf ppf "SET_DELEGATE"

View File

@ -285,6 +285,7 @@ and constant' =
| C_SOURCE
| C_SENDER
| C_ADDRESS
| C_SELF
| C_SELF_ADDRESS
| C_IMPLICIT_ACCOUNT
| C_SET_DELEGATE

View File

@ -237,6 +237,7 @@ and constant ppf : constant' -> unit = function
| C_SOURCE -> fprintf ppf "SOURCE"
| C_SENDER -> fprintf ppf "SENDER"
| C_ADDRESS -> fprintf ppf "ADDRESS"
| C_SELF -> fprintf ppf "SELF"
| C_SELF_ADDRESS -> fprintf ppf "SELF_ADDRESS"
| C_IMPLICIT_ACCOUNT -> fprintf ppf "IMPLICIT_ACCOUNT"
| C_SET_DELEGATE -> fprintf ppf "SET_DELEGATE"