diff options
author | Son Ho | 2022-11-14 14:14:38 +0100 |
---|---|---|
committer | Son HO | 2022-11-14 14:21:04 +0100 |
commit | 6f714017d71a512042b22d7d0e987f75b47a088f (patch) | |
tree | ed608a74538ff5a34a32a2aee9094e9f41979121 /compiler | |
parent | 6cfd60a0d75a1fcc3734aa9729c79acbfb30e546 (diff) |
Extract the Polonius examples in Coq
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/Extract.ml | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/compiler/Extract.ml b/compiler/Extract.ml index 6cd1462e..950e4026 100644 --- a/compiler/Extract.ml +++ b/compiler/Extract.ml @@ -674,23 +674,26 @@ let extract_type_decl_variant (ctx : extraction_ctx) (fmt : F.formatter) extraction_ctx = (* Open the field box *) F.pp_open_box fmt ctx.indent_incr; - (* Print the field names + (* Print the field names, if the backend accepts it. * [ x :] * Note that when printing fields, we register the field names as * *variables*: they don't need to be unique at the top level. *) let ctx = - match f.field_name with - | None -> ctx - | Some field_name -> - let var_id = VarId.of_int (FieldId.to_int fid) in - let field_name = - ctx.fmt.var_basename ctx.names_map.names_set (Some field_name) - f.field_ty - in - let ctx, field_name = ctx_add_var field_name var_id ctx in - F.pp_print_string fmt (field_name ^ " :"); - F.pp_print_space fmt (); - ctx + match !backend with + | FStar -> ( + match f.field_name with + | None -> ctx + | Some field_name -> + let var_id = VarId.of_int (FieldId.to_int fid) in + let field_name = + ctx.fmt.var_basename ctx.names_map.names_set (Some field_name) + f.field_ty + in + let ctx, field_name = ctx_add_var field_name var_id ctx in + F.pp_print_string fmt (field_name ^ " :"); + F.pp_print_space fmt (); + ctx) + | Coq -> ctx in (* Print the field type *) extract_ty ctx fmt false f.field_ty; |