Michelson: SOURCE now returns an address

This commit is contained in:
Benjamin Canou 2018-04-11 00:22:03 +02:00 committed by Grégoire Henry
parent 5579d3cc97
commit 86c18bcd9d
3 changed files with 10 additions and 11 deletions

View File

@ -731,9 +731,9 @@ let rec interp
| Limited { remaining } -> remaining | Limited { remaining } -> remaining
| Unaccounted -> Z.of_string "99999999" in | Unaccounted -> Z.of_string "99999999" in
logged_return (Item (Script_int.(abs (of_zint steps)), rest), ctxt) logged_return (Item (Script_int.(abs (of_zint steps)), rest), ctxt)
| Source t, rest -> | Source, rest ->
Lwt.return (Gas.consume ctxt Interp_costs.source) >>=? fun ctxt -> Lwt.return (Gas.consume ctxt Interp_costs.source) >>=? fun ctxt ->
logged_return (Item ((t, source), rest), ctxt) logged_return (Item (source, rest), ctxt)
| Self t, rest -> | Self t, rest ->
Lwt.return (Gas.consume ctxt Interp_costs.self) >>=? fun ctxt -> Lwt.return (Gas.consume ctxt Interp_costs.self) >>=? fun ctxt ->
logged_return (Item ((t,self), rest), ctxt) logged_return (Item ((t,self), rest), ctxt)

View File

@ -206,7 +206,7 @@ let number_of_generated_growing_types : type b a. (b, a) instr -> int = function
| Hash_key -> 0 | Hash_key -> 0
| H _ -> 0 | H _ -> 0
| Steps_to_quota -> 0 | Steps_to_quota -> 0
| Source _ -> 1 | Source -> 0
| Self _ -> 1 | Self _ -> 1
| Amount -> 0 | Amount -> 0
@ -2125,11 +2125,10 @@ and parse_instr
stack -> stack ->
typed ctxt loc Steps_to_quota typed ctxt loc Steps_to_quota
(Item_t (Nat_t, stack, instr_annot)) (Item_t (Nat_t, stack, instr_annot))
| Prim (loc, I_SOURCE, [ ta ], instr_annot), | Prim (loc, I_SOURCE, [], instr_annot),
stack -> stack ->
(Lwt.return (parse_ty false ta)) >>=? fun (Ex_ty ta, _) -> typed ctxt loc Source
typed ctxt loc (Source ta) (Item_t (Address_t, stack, instr_annot))
(Item_t (Contract_t ta, stack, instr_annot))
| Prim (loc, I_SELF, [], instr_annot), | Prim (loc, I_SELF, [], instr_annot),
stack -> stack ->
let rec get_toplevel_type : tc_context -> (bef judgement * context) tzresult Lwt.t = function let rec get_toplevel_type : tc_context -> (bef judgement * context) tzresult Lwt.t = function
@ -2153,7 +2152,7 @@ and parse_instr
| I_MANAGER | I_TRANSFER_TOKENS | I_CREATE_ACCOUNT | I_MANAGER | I_TRANSFER_TOKENS | I_CREATE_ACCOUNT
| I_CREATE_CONTRACT | I_NOW | I_CREATE_CONTRACT | I_NOW
| I_IMPLICIT_ACCOUNT | I_AMOUNT | I_BALANCE | I_IMPLICIT_ACCOUNT | I_AMOUNT | I_BALANCE
| I_CHECK_SIGNATURE | I_HASH_KEY | I_CHECK_SIGNATURE | I_HASH_KEY | I_SOURCE
| I_H | I_STEPS_TO_QUOTA | I_ADDRESS | I_H | I_STEPS_TO_QUOTA | I_ADDRESS
as name), (_ :: _ as l), _), _ -> as name), (_ :: _ as l), _), _ ->
fail (Invalid_arity (loc, name, 0, List.length l)) fail (Invalid_arity (loc, name, 0, List.length l))
@ -2163,7 +2162,7 @@ and parse_instr
| _ :: _ :: _ as l), _), _ -> | _ :: _ :: _ as l), _), _ ->
fail (Invalid_arity (loc, name, 1, List.length l)) fail (Invalid_arity (loc, name, 1, List.length l))
| Prim (loc, (I_PUSH | I_IF_NONE | I_IF_LEFT | I_IF_CONS | Prim (loc, (I_PUSH | I_IF_NONE | I_IF_LEFT | I_IF_CONS
| I_EMPTY_MAP | I_IF | I_SOURCE | I_EMPTY_MAP | I_IF
as name), ([] | [ _ ] as name), ([] | [ _ ]
| _ :: _ :: _ :: _ as l), _), _ -> | _ :: _ :: _ :: _ as l), _), _ ->
fail (Invalid_arity (loc, name, 2, List.length l)) fail (Invalid_arity (loc, name, 2, List.length l))

View File

@ -352,8 +352,8 @@ and ('bef, 'aft) instr =
('a * 'rest, string * 'rest) instr ('a * 'rest, string * 'rest) instr
| Steps_to_quota : (* TODO: check that it always returns a nat *) | Steps_to_quota : (* TODO: check that it always returns a nat *)
('rest, n num * 'rest) instr ('rest, n num * 'rest) instr
| Source : 'p ty -> | Source :
('rest, 'p typed_contract * 'rest) instr ('rest, Contract.t * 'rest) instr
| Self : 'p ty -> | Self : 'p ty ->
('rest, 'p typed_contract * 'rest) instr ('rest, 'p typed_contract * 'rest) instr
| Amount : | Amount :