Commit 68dcae1a authored by Alain Mebsout's avatar Alain Mebsout Committed by Benjamin Canou

Michelson: RENAME macro

parent 22bdea00
......@@ -487,6 +487,15 @@ let expand_if_right = function
error (Unexpected_macro_annotation "IF_RIGHT")
| _ -> ok @@ None
let expand_rename = function
| Prim (loc, "RENAME", [], annot) ->
ok @@ Some (Seq (loc, [
Prim (loc, "DUP", [], annot) ;
Prim (loc, "SWAP", [], []) ;
Prim (loc, "DROP", [], []) ;
]))
| _ -> ok @@ None
let expand original =
let rec try_expansions = function
| [] -> ok @@ original
......@@ -505,7 +514,9 @@ let expand original =
expand_compare ;
expand_asserts ;
expand_if_some ;
expand_if_right ]
expand_if_right ;
expand_rename ;
]
let expand_rec expr =
let rec error_map (expanded, errors) f = function
......@@ -842,6 +853,15 @@ let unexpand_if_right = function
Some (Prim (loc, "IF_RIGHT", [ right ; left ], []))
| _ -> None
let unexpand_rename = function
| Seq (loc, [
Prim (_, "DUP", [], annot) ;
Prim (_, "SWAP", [], []) ;
Prim (_, "DROP", [], []) ;
]) ->
Some (Prim (loc, "RENAME", [], annot))
| _ -> None
let unexpand original =
let try_unexpansions unexpanders =
match
......@@ -864,7 +884,8 @@ let unexpand original =
unexpand_duuuuup ;
unexpand_compare ;
unexpand_if_some ;
unexpand_if_right ]
unexpand_if_right ;
unexpand_rename ]
let rec unexpand_rec expr =
match unexpand expr with
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment