Skip to content

Commit

Permalink
feat(lltz_michelson): draft of match
Browse files Browse the repository at this point in the history
  • Loading branch information
alanmarkoTrilitech committed Aug 24, 2024
1 parent 34e0a0a commit 75cc2ec
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/lltz_ir/expr.ml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ module T = struct
}
(* sums *)
| Inj of Type.t Row.Context.t * t
| Match of t * (var * t) Row.t
| Match of t * ((var * Type.t) * Type.t * t) Row.t
(* tezos specific *)
| Raw_michelson of (micheline[@sexp.opaque] [@equal.ignore] [@compare.ignore])
| Create_contract of
Expand Down
9 changes: 9 additions & 0 deletions lib/lltz_michelson/lltz_michelson.ml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module LLTZ = struct
module T = Lltz_ir.Type
module R = Lltz_ir.Row
module P = Lltz_ir.Primitive
module Dsl = Lltz_ir.Dsl
end

module Michelson = struct
Expand Down Expand Up @@ -563,3 +564,11 @@ and compile_inj context expr =
push (Michelson.T.int) (Michelson.Ast.int (List.length right_instrs_types));
])
)
and compile_row_of_lambdas row =
match row with
| LLTZ.R.Node nodes ->
let compiled_nodes = List.map nodes ~f:compile_row_of_lambdas in
Instruction.seq (compiled_nodes @ [ Instruction.pair_n (List.length compiled_nodes) ])
| LLTZ.R.Leaf (_, ((var, var_type), return_type, body)) ->
compile (LLTZ.Dsl.T.lambda ~var:(var, var_type) ~return_type ~body)

0 comments on commit 75cc2ec

Please sign in to comment.