summaryrefslogtreecommitdiff
path: root/src/InterpreterExpressions.ml
diff options
context:
space:
mode:
authorSon Ho2022-05-15 16:49:24 +0200
committerSon Ho2022-05-15 16:49:24 +0200
commitdbd5af0c6c56ad95eb3654c588fa227737c645ad (patch)
tree9adc1d08a88241af7b9d842d694d4485ddc70123 /src/InterpreterExpressions.ml
parent3cd74ec699e8c7eb2089b57c0a6768717c65d285 (diff)
Add AggregatedOption
Diffstat (limited to 'src/InterpreterExpressions.ml')
-rw-r--r--src/InterpreterExpressions.ml14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/InterpreterExpressions.ml b/src/InterpreterExpressions.ml
index f4d97b9d..e46ca721 100644
--- a/src/InterpreterExpressions.ml
+++ b/src/InterpreterExpressions.ml
@@ -608,6 +608,20 @@ let eval_rvalue_aggregate (config : C.config)
let aggregated : V.typed_value = { V.value = v; ty } in
(* Call the continuation *)
cf aggregated ctx
+ | E.AggregatedOption (variant_id, ty) ->
+ (* Sanity check *)
+ if variant_id == T.option_none_id then assert (values == [])
+ else if variant_id == T.option_some_id then
+ assert (List.length values == 1)
+ else raise (Failure "Unreachable");
+ (* Construt the value *)
+ let aty = T.Adt (T.Assumed T.Option, [], [ ty ]) in
+ let av : V.adt_value =
+ { V.variant_id = Some variant_id; V.field_values = values }
+ in
+ let aggregated : V.typed_value = { V.value = Adt av; ty = aty } in
+ (* Call the continuation *)
+ cf aggregated ctx
| E.AggregatedAdt (def_id, opt_variant_id, regions, types) ->
(* Sanity checks *)
let type_decl = C.ctx_lookup_type_decl ctx def_id in