now removes the entry-point declaration from the program before aggregation
This commit is contained in:
parent
316ea3bd9a
commit
7e05b7d276
@ -25,9 +25,10 @@ let aggregate_and_compile = fun program form ->
|
|||||||
| ContractForm _ -> compile_contract aggregated'
|
| ContractForm _ -> compile_contract aggregated'
|
||||||
| ExpressionForm _ -> compile_expression aggregated'
|
| ExpressionForm _ -> compile_expression aggregated'
|
||||||
|
|
||||||
let aggregate_and_compile_contract = fun program name ->
|
let aggregate_and_compile_contract = fun (program : Types.program) name ->
|
||||||
let%bind (exp, _) = get_entry program name in
|
let%bind (exp, idx) = get_entry program name in
|
||||||
aggregate_and_compile program (ContractForm exp)
|
let program' = List.remove_from idx program in
|
||||||
|
aggregate_and_compile program' (ContractForm exp)
|
||||||
|
|
||||||
let aggregate_and_compile_expression = fun program exp ->
|
let aggregate_and_compile_expression = fun program exp ->
|
||||||
aggregate_and_compile program (ExpressionForm exp)
|
aggregate_and_compile program (ExpressionForm exp)
|
||||||
|
@ -129,14 +129,14 @@ let get_entry (lst : program) (name : string) : (expression * int) result =
|
|||||||
then Some decl_expr
|
then Some decl_expr
|
||||||
else None
|
else None
|
||||||
in
|
in
|
||||||
List.find_map aux lst
|
List.find_map aux (List.rev lst)
|
||||||
in
|
in
|
||||||
let entry_index =
|
let entry_index =
|
||||||
let aux x =
|
let aux x =
|
||||||
let (((decl_name , _) , _)) = x in
|
let (((decl_name , _) , _)) = x in
|
||||||
Var.equal decl_name (Var.of_name name)
|
Var.equal decl_name (Var.of_name name)
|
||||||
in
|
in
|
||||||
List.find_index aux lst
|
(List.length lst) - (List.find_index aux (List.rev lst)) - 1
|
||||||
in
|
in
|
||||||
ok (entry_expression , entry_index)
|
ok (entry_expression , entry_index)
|
||||||
|
|
||||||
|
5
vendors/ligo-utils/simple-utils/x_list.ml
vendored
5
vendors/ligo-utils/simple-utils/x_list.ml
vendored
@ -5,6 +5,11 @@ let rec remove n = function
|
|||||||
| _ :: tl when n = 0 -> tl
|
| _ :: tl when n = 0 -> tl
|
||||||
| hd :: tl -> hd :: remove (n - 1) tl
|
| hd :: tl -> hd :: remove (n - 1) tl
|
||||||
|
|
||||||
|
let rec remove_from n = function
|
||||||
|
| [] -> raise (Failure "List.remove_from")
|
||||||
|
| _ when n = 0 -> []
|
||||||
|
| hd :: tl -> hd :: remove_from (n - 1) tl
|
||||||
|
|
||||||
let map ?(acc = []) f lst =
|
let map ?(acc = []) f lst =
|
||||||
let rec aux acc f = function
|
let rec aux acc f = function
|
||||||
| [] -> acc
|
| [] -> acc
|
||||||
|
Loading…
Reference in New Issue
Block a user