[ios] Remove methods from the tenv as they are not used in the backend

Reviewed By: akotulski

Differential Revision: D4620532

fbshipit-source-id: 1e8da09
master
Dulma Churchill 8 years ago committed by Facebook Github Bot
parent 95725e4dd0
commit 04d96cb84b

@ -40,9 +40,6 @@ let rec append_no_duplicates eq list1 list2 =
let append_no_duplicates_csu list1 list2 =
append_no_duplicates Typename.equal list1 list2
let append_no_duplicates_methods list1 list2 =
append_no_duplicates Procname.equal list1 list2
let append_no_duplicates_annotations list1 list2 =
let eq (annot1, _) (annot2, _) = String.equal annot1.Annot.class_name annot2.Annot.class_name in
append_no_duplicates eq list1 list2

@ -23,8 +23,6 @@ val append_no_duplicates_fields : (Ident.fieldname * Typ.t * Annot.Item.t) list
val append_no_duplicates_csu :
Typename.t list -> Typename.t list -> Typename.t list
val append_no_duplicates_methods : Procname.t list -> Procname.t list -> Procname.t list
val sort_fields :
(Ident.fieldname * Typ.t * Annot.Item.t) list ->
(Ident.fieldname * Typ.t * Annot.Item.t) list

@ -69,19 +69,17 @@ let get_base_class_name_from_category decl =
(* to the corresponding class. Update the tenv accordingly.*)
let process_category type_ptr_to_sil_type tenv curr_class decl_info decl_list =
let decl_fields = CField_decl.get_fields type_ptr_to_sil_type tenv curr_class decl_list in
let decl_methods = ObjcProperty_decl.get_methods curr_class decl_list in
let class_name = CContext.get_curr_class_name curr_class in
let mang_name = Mangled.from_string class_name in
let class_tn_name = Typename.TN_csu (Csu.Class Csu.Objc, mang_name) in
let decl_key = `DeclPtr decl_info.Clang_ast_t.di_pointer in
CAst_utils.update_sil_types_map decl_key (Typ.Tstruct class_tn_name);
(match Tenv.lookup tenv class_tn_name with
| Some ({ fields; methods } as struct_typ) ->
| Some ({ fields } as struct_typ) ->
let new_fields = CGeneral_utils.append_no_duplicates_fields decl_fields fields in
let new_methods = CGeneral_utils.append_no_duplicates_methods decl_methods methods in
ignore(
Tenv.mk_struct tenv
~default:struct_typ ~fields:new_fields ~statics:[] ~methods:new_methods class_tn_name );
~default:struct_typ ~fields:new_fields ~statics:[] ~methods:[] class_tn_name );
Logging.out_debug " Updating info for class '%s' in tenv\n" class_name
| _ -> ());
Typ.Tstruct class_tn_name

@ -102,20 +102,18 @@ let add_class_to_tenv type_ptr_to_sil_type tenv curr_class decl_info name_info d
create_supers_fields type_ptr_to_sil_type tenv curr_class decl_list
ocidi.Clang_ast_t.otdi_super
ocidi.Clang_ast_t.otdi_protocols in
let decl_methods = ObjcProperty_decl.get_methods curr_class decl_list in
let fields_sc = CField_decl.fields_superclass tenv ocidi Csu.Objc in
List.iter ~f:(fun (fn, ft, _) ->
Logging.out_debug "----->SuperClass field: '%s' " (Ident.fieldname_to_string fn);
Logging.out_debug "type: '%s'\n" (Typ.to_string ft)) fields_sc;
(*In case we found categories, or partial definition of this class earlier and they are already in the tenv *)
let fields, (supers : Typename.t list), methods =
let fields, (supers : Typename.t list) =
match Tenv.lookup tenv interface_name with
| Some { fields; supers; methods } ->
| Some { fields; supers} ->
CGeneral_utils.append_no_duplicates_fields decl_fields fields,
CGeneral_utils.append_no_duplicates_csu decl_supers supers,
CGeneral_utils.append_no_duplicates_methods decl_methods methods
CGeneral_utils.append_no_duplicates_csu decl_supers supers
| _ ->
decl_fields, decl_supers, decl_methods in
decl_fields, decl_supers in
let fields = CGeneral_utils.append_no_duplicates_fields fields fields_sc in
(* We add the special hidden counter_field for implementing reference counting *)
let modelled_fields = Typ.Struct.objc_ref_counter_field :: CField_decl.modelled_field name_info in
@ -125,7 +123,7 @@ let add_class_to_tenv type_ptr_to_sil_type tenv curr_class decl_info name_info d
Logging.out_debug "-----> field: '%s'\n" (Ident.fieldname_to_string fn)) all_fields;
ignore(
Tenv.mk_struct tenv
~fields: all_fields ~supers ~methods ~annots:Annot.Class.objc interface_name );
~fields: all_fields ~supers ~methods:[] ~annots:Annot.Class.objc interface_name );
Logging.out_debug
" >>>Verifying that Typename '%s' is in tenv\n" (Typename.to_string interface_name);
(match Tenv.lookup tenv interface_name with
@ -135,20 +133,6 @@ let add_class_to_tenv type_ptr_to_sil_type tenv curr_class decl_info name_info d
| None -> Logging.out_debug " >>>NOT Found!!\n");
Typ.Tstruct interface_name
let add_missing_methods tenv class_name ck decl_info decl_list curr_class =
let decl_methods = ObjcProperty_decl.get_methods curr_class decl_list in
let class_tn_name = Typename.TN_csu (Csu.Class ck, (Mangled.from_string class_name)) in
let decl_key = `DeclPtr decl_info.Clang_ast_t.di_pointer in
CAst_utils.update_sil_types_map decl_key (Typ.Tstruct class_tn_name);
begin
match class_tn_name, Tenv.lookup tenv class_tn_name with
| TN_csu (Class _, _), Some ({ statics = []; methods; } as struct_typ) ->
let methods = CGeneral_utils.append_no_duplicates_methods methods decl_methods in
ignore( Tenv.mk_struct tenv ~default:struct_typ ~methods class_tn_name )
| _ -> ()
end;
Typ.Tstruct class_tn_name
(* Interface_type_info has the name of instance variables and the name of methods. *)
let interface_declaration type_ptr_to_sil_type tenv decl =
let open Clang_ast_t in
@ -177,6 +161,9 @@ let interface_impl_declaration type_ptr_to_sil_type tenv decl =
let curr_class = get_curr_class_impl idi in
let fields = CField_decl.get_fields type_ptr_to_sil_type tenv curr_class decl_list in
CField_decl.add_missing_fields tenv class_name Csu.Objc fields;
let typ = add_missing_methods tenv class_name Csu.Objc decl_info decl_list curr_class in
typ
let class_tn_name = Typename.TN_csu (Csu.Class Csu.Objc, (Mangled.from_string class_name)) in
let decl_key = `DeclPtr decl_info.Clang_ast_t.di_pointer in
let class_typ = Typ.Tstruct class_tn_name in
CAst_utils.update_sil_types_map decl_key class_typ;
class_typ
| _ -> assert false

@ -28,19 +28,3 @@ let is_assign_property obj_c_property_decl_info =
List.exists ~f:(fun a -> match a with
| `Assign -> true
| _ -> false) attrs
(* Given a list of declarations in an interface returns list of methods *)
let get_methods curr_class decl_list =
let class_name = CContext.get_curr_class_name curr_class in
let get_method decl list_methods =
match decl with
| Clang_ast_t.ObjCMethodDecl (_, name_info, method_decl_info) ->
let is_instance = method_decl_info.Clang_ast_t.omdi_is_instance_method in
let method_kind = Procname.objc_method_kind_of_bool is_instance in
let method_name = name_info.Clang_ast_t.ni_name in
Logging.out_debug " ...Adding Method '%s' \n" (class_name^"_"^method_name);
let meth_name =
CGeneral_utils.mk_procname_from_objc_method class_name method_name method_kind in
meth_name:: list_methods
| _ -> list_methods in
List.fold_right ~f:get_method decl_list ~init:[]

@ -12,8 +12,6 @@ open! IStd
(** Process properties by creating their getters and setters in the case that they need to be syntethized *)
(** or in the case of dynamic. *)
val get_methods : CContext.curr_class -> Clang_ast_t.decl list -> Procname.t list
(* Given a property type returns whether the property is strong *)
val is_strong_property : Clang_ast_t.obj_c_property_decl_info -> bool

@ -18,9 +18,8 @@ let add_protocol_super type_ptr_to_sil_type tenv obj_c_protocol_decl_info =
let protocol_decl type_ptr_to_sil_type tenv decl =
let open Clang_ast_t in
match decl with
| ObjCProtocolDecl(decl_info, name_info, decl_list, _, obj_c_protocol_decl_info) ->
| ObjCProtocolDecl(decl_info, name_info, _, _, obj_c_protocol_decl_info) ->
let name = CAst_utils.get_qualified_name name_info in
let curr_class = CContext.ContextProtocol name in
(* Adds pairs (protocol name, protocol_type_info) to the global environment. *)
(* Protocol_type_info contains the methods composing the protocol. *)
(* Here we are giving a similar treatment as interfaces (see above)*)
@ -30,8 +29,7 @@ let protocol_decl type_ptr_to_sil_type tenv decl =
let protocol_name = Typename.TN_csu (Csu.Protocol, mang_name) in
let decl_key = `DeclPtr decl_info.Clang_ast_t.di_pointer in
CAst_utils.update_sil_types_map decl_key (Typ.Tstruct protocol_name);
let methods = ObjcProperty_decl.get_methods curr_class decl_list in
ignore( Tenv.mk_struct tenv ~methods protocol_name );
ignore( Tenv.mk_struct tenv ~methods:[] protocol_name );
add_protocol_super type_ptr_to_sil_type tenv obj_c_protocol_decl_info;
Typ.Tstruct protocol_name
| _ -> assert false

Loading…
Cancel
Save