Skip to content

Commit 8dd4e79

Browse files
Generate consistent accessor names
1 parent 7d874bf commit 8dd4e79

File tree

1 file changed

+17
-25
lines changed

1 file changed

+17
-25
lines changed

engine/backends/proverif/proverif_backend.ml

+17-25
Original file line numberDiff line numberDiff line change
@@ -98,17 +98,9 @@ module ProVerifNamePolicy = struct
9898

9999
[@@@ocamlformat "disable"]
100100

101-
let anonymous_field_transform index = Fn.id index
102-
103101
let reserved_words = Hash_set.of_list (module String) [
104102
"among"; "axiom"; "channel"; "choice"; "clauses"; "const"; "def"; "diff"; "do"; "elimtrue"; "else"; "equation"; "equivalence"; "event"; "expand"; "fail"; "for"; "forall"; "foreach"; "free"; "fun"; "get"; "if"; "implementation"; "in"; "inj-event"; "insert"; "lemma"; "let"; "letfun"; "letproba"; "new"; "noninterf"; "noselect"; "not"; "nounif"; "or"; "otherwise"; "out"; "param"; "phase"; "pred"; "proba"; "process"; "proof"; "public vars"; "putbegin"; "query"; "reduc"; "restriction"; "secret"; "select"; "set"; "suchthat"; "sync"; "table"; "then"; "type"; "weaksecret"; "yield"
105103
]
106-
107-
let field_name_transform ~struct_name field_name = struct_name ^ "_" ^ field_name
108-
109-
let enum_constructor_name_transform ~enum_name constructor_name = enum_name ^ "_" ^ constructor_name ^ "_c"
110-
111-
let struct_constructor_name_transform constructor_name = constructor_name ^ "_c"
112104
end
113105

114106
module U = Ast_utils.Make (InputLanguage)
@@ -229,7 +221,8 @@ module Make (Options : OPTS) : MAKE = struct
229221
method error_letfun_name type_name = type_name ^^ string "_err"
230222

231223
method field_accessor_prefix field_name prefix =
232-
string "accessori" ^^ underscore ^^ prefix ^^ underscore ^^ print#concrete_ident field_name
224+
string "accessor" ^^ underscore ^^ prefix ^^ underscore
225+
^^ print#concrete_ident field_name
233226

234227
method match_arm scrutinee { arm_pat; body } =
235228
let body_typ = print#ty AlreadyPar body.typ in
@@ -414,18 +407,20 @@ module Make (Options : OPTS) : MAKE = struct
414407
| Some (name, translation) -> translation args
415408
| None -> (
416409
match name with
417-
| `Projector (`Concrete name) ->
418-
let arg = (Option.value_exn (List.hd args)) in
419-
match arg.typ with
420-
| TApp { ident = `Concrete concrete_ident; _} -> (
421-
let base_name = print#concrete_ident concrete_ident in
422-
print#field_accessor_prefix name base_name
423-
^^ iblock parens
424-
(separate_map
425-
(comma ^^ break 1)
426-
(fun arg -> print#expr AlreadyPar arg)
427-
args))
428-
| _ -> super#expr' ctx e
410+
| `Projector (`Concrete name) -> (
411+
let arg = Option.value_exn (List.hd args) in
412+
match arg.typ with
413+
| TApp { ident = `Concrete concrete_ident; _ } ->
414+
let base_name =
415+
print#concrete_ident concrete_ident
416+
in
417+
print#field_accessor_prefix name base_name
418+
^^ iblock parens
419+
(separate_map
420+
(comma ^^ break 1)
421+
(fun arg -> print#expr AlreadyPar arg)
422+
args)
423+
| _ -> super#expr' ctx e)
429424
| _ -> super#expr' ctx e)))
430425
| Construct { constructor; fields; _ }
431426
when Global_ident.eq_name Core__option__Option__None constructor
@@ -488,10 +483,7 @@ module Make (Options : OPTS) : MAKE = struct
488483
in
489484
let fun_and_reduc base_name constructor =
490485
let constructor_name = print#concrete_ident constructor.name in
491-
let field_prefix =
492-
if constructor.is_record then empty
493-
else print#concrete_ident base_name ^^ underscore ^^ print#concrete_ident constructor.name
494-
in
486+
let field_prefix = print#concrete_ident base_name in
495487
let fun_args = constructor.arguments in
496488
let fun_args_full =
497489
separate_map

0 commit comments

Comments
 (0)