void build_module_descriptor (long vers, tree attr) { tree decls, *chain = NULL; #ifdef OBJCPLUS push_lang_context (lang_name_c); /* extern "C" */ #endif objc_module_template = objc_start_struct (get_identifier (UTAG_MODULE)); /* long version; */ decls = add_field_decl (long_integer_type_node, "version", &chain); /* long size; */ add_field_decl (long_integer_type_node, "size", &chain); /* char *name; */ add_field_decl (string_type_node, "name", &chain); /* struct _objc_symtab *symtab; */ add_field_decl (build_pointer_type (xref_tag (RECORD_TYPE, get_identifier (UTAG_SYMTAB))), "symtab", &chain); objc_finish_struct (objc_module_template, decls); /* Create an instance of "_objc_module". */ UOBJC_MODULES_decl = start_var_decl (objc_module_template, /* FIXME - why the conditional if the symbol is the same. */ flag_next_runtime ? "_OBJC_Module" : "_OBJC_Module"); /* This is the root of the metadata for defined classes and categories, it is referenced by the runtime and, therefore, needed. */ DECL_PRESERVE_P (UOBJC_MODULES_decl) = 1; /* Squash `defined but not used' warning. */ TREE_USED (UOBJC_MODULES_decl) = 1; /* Allow the runtime to mark meta-data such that it can be assigned to target specific sections by the back-end. */ if (attr) DECL_ATTRIBUTES (UOBJC_MODULES_decl) = attr; finish_var_decl (UOBJC_MODULES_decl, init_module_descriptor (TREE_TYPE (UOBJC_MODULES_decl), vers)); #ifdef OBJCPLUS pop_lang_context (); #endif }
void build_super_template (void) { tree decls, *chain = NULL; objc_super_template = objc_start_struct (get_identifier (UTAG_SUPER)); /* struct _objc_object *self; */ decls = add_field_decl (objc_object_type, "self", &chain); /* struct _objc_class *super_class; */ add_field_decl (build_pointer_type (objc_class_template), "super_class", &chain); objc_finish_struct (objc_super_template, decls); }
tree build_method_prototype_template (void) { tree proto_record; tree decls, *chain = NULL; proto_record = objc_start_struct (get_identifier (UTAG_METHOD_PROTOTYPE)); /* SEL _cmd; */ decls = add_field_decl (objc_selector_type, "_cmd", &chain); /* char *method_types; */ add_field_decl (string_type_node, "method_types", &chain); objc_finish_struct (proto_record, decls); return proto_record; }
tree build_ivar_list_template (tree list_type, int size) { tree objc_ivar_list_record; tree array_type, decls, *chain = NULL; objc_ivar_list_record = objc_start_struct (NULL_TREE); /* int ivar_count; */ decls = add_field_decl (integer_type_node, "ivar_count", &chain); /* struct objc_ivar ivar_list[]; */ array_type = build_sized_array_type (list_type, size); add_field_decl (array_type, "ivar_list", &chain); objc_finish_struct (objc_ivar_list_record, decls); return objc_ivar_list_record; }
tree build_method_prototype_list_template (tree list_type, int size) { tree objc_ivar_list_record; tree array_type, decls, *chain = NULL; /* Generate an unnamed struct definition. */ objc_ivar_list_record = objc_start_struct (NULL_TREE); /* int method_count; */ decls = add_field_decl (integer_type_node, "method_count", &chain); /* struct objc_method method_list[]; */ array_type = build_sized_array_type (list_type, size); add_field_decl (array_type, "method_list", &chain); objc_finish_struct (objc_ivar_list_record, decls); return objc_ivar_list_record; }
tree build_method_template (void) { tree _SLT_record; tree decls, *chain = NULL; _SLT_record = objc_start_struct (get_identifier (UTAG_METHOD)); /* SEL _cmd; */ decls = add_field_decl (objc_selector_type, "_cmd", &chain); /* char *method_types; */ add_field_decl (string_type_node, "method_types", &chain); /* void *_imp; */ add_field_decl (build_pointer_type (void_type_node), "_imp", &chain); objc_finish_struct (_SLT_record, decls); return _SLT_record; }
tree build_ivar_template (void) { tree objc_ivar_id, objc_ivar_record; tree decls, *chain = NULL; objc_ivar_id = get_identifier (UTAG_IVAR); objc_ivar_record = objc_start_struct (objc_ivar_id); /* char *ivar_name; */ decls = add_field_decl (string_type_node, "ivar_name", &chain); /* char *ivar_type; */ add_field_decl (string_type_node, "ivar_type", &chain); /* int ivar_offset; */ add_field_decl (integer_type_node, "ivar_offset", &chain); objc_finish_struct (objc_ivar_record, decls); return objc_ivar_record; }