[frontend] Clean up method creation

Summary: the tittle

Reviewed By: ezgicicek

Differential Revision: D23472326

fbshipit-source-id: 13516e6ab
master
Daiva Naudziuniene 5 years ago committed by Facebook GitHub Bot
parent 44ff6df1d6
commit 20a8890fd5

@ -96,33 +96,25 @@ module CFrontend_decl_funct (T : CModule_type.CTranslation) : CModule_type.CFron
| Some body -> | Some body ->
let procname = ms.CMethodSignature.name in let procname = ms.CMethodSignature.name in
let return_param_typ_opt = ms.CMethodSignature.return_param_typ in let return_param_typ_opt = ms.CMethodSignature.return_param_typ in
let ms', procname' = let add_method_if_create_procdesc ms procname ~is_destructor_wrapper =
if is_destructor then (
(* For a destructor we create two procedures: a destructor wrapper and an inner destructor *)
(* A destructor wrapper is called from the outside, i.e. for destructing local variables and fields *)
(* The destructor wrapper calls the inner destructor which has the actual body *)
if if
CMethod_trans.create_local_procdesc ~set_objc_accessor_attr trans_unit_ctx cfg tenv CMethod_trans.create_local_procdesc ~set_objc_accessor_attr trans_unit_ctx cfg tenv ms
ms [body] [] [body] []
then then
add_method trans_unit_ctx tenv cfg curr_class procname body ms return_param_typ_opt add_method trans_unit_ctx tenv cfg curr_class procname body ms return_param_typ_opt
None extra_instrs ~is_destructor_wrapper:true ; None extra_instrs ~is_destructor_wrapper
in
ignore (add_method_if_create_procdesc ms procname ~is_destructor_wrapper:is_destructor) ;
if is_destructor then
(* For a destructor we create two procedures: a destructor wrapper and an inner destructor *)
(* A destructor wrapper is called from the outside, i.e. for destructing local variables and fields *)
(* The destructor wrapper calls the inner destructor which has the actual body *)
let new_method_name = let new_method_name =
Config.clang_inner_destructor_prefix ^ Procname.get_method procname Config.clang_inner_destructor_prefix ^ Procname.get_method procname
in in
let ms' = let new_procname = Procname.objc_cpp_replace_method_name procname new_method_name in
{ms with name= Procname.objc_cpp_replace_method_name procname new_method_name} let new_ms = {ms with name= new_procname} in
in add_method_if_create_procdesc new_ms new_procname ~is_destructor_wrapper:false
let procname' = ms'.CMethodSignature.name in
(ms', procname') )
else (ms, procname)
in
if
CMethod_trans.create_local_procdesc ~set_objc_accessor_attr trans_unit_ctx cfg tenv ms'
[body] []
then
add_method trans_unit_ctx tenv cfg curr_class procname' body ms' return_param_typ_opt
None extra_instrs ~is_destructor_wrapper:false
| None -> | None ->
if set_objc_accessor_attr then if set_objc_accessor_attr then
ignore ignore

Loading…
Cancel
Save