This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Still more ObjC cosmetic improvement


Another session in the Augean stables of objc-act.c...

Stan

2001-12-29  Stan Shebs  <shebs@apple.com>

        * objc/objc-act.c: Apply various cosmetic and formatting changes.

Index: objc-act.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/objc/objc-act.c,v
retrieving revision 1.118
diff -c -3 -p -r1.118 objc-act.c
*** objc-act.c  2001/12/28 23:22:05     1.118
--- objc-act.c  2001/12/29 14:47:20
*************** static const char *TAG_MSGSEND;
*** 382,388 ****
  static const char *TAG_MSGSENDSUPER;
  static const char *TAG_EXECCLASS;
  
! /* The OCTI_... enumeration itself in in objc/objc-act.h.  */
  tree objc_global_trees[OCTI_MAX];
  
  int objc_receiver_context;
--- 382,388 ----
  static const char *TAG_MSGSENDSUPER;
  static const char *TAG_EXECCLASS;
  
! /* The OCTI_... enumeration itself is in objc/objc-act.h.  */
  tree objc_global_trees[OCTI_MAX];
  
  int objc_receiver_context;
*************** int flag_warn_protocol = 1;
*** 437,456 ****
  /* Tells "encode_pointer/encode_aggregate" whether we are generating
     type descriptors for instance variables (as opposed to methods).
     Type descriptors for instance variables contain more information
!    than methods (for static typing and embedded structures). This
!    was added to support features being planned for dbkit2.  */
  
  static int generating_instance_variables = 0;
  
! /* Tells the compiler that this is a special run.  Do not perform
!    any compiling, instead we are to test some platform dependent
!    features and output a C header file with appropriate definitions. */
  
  static int print_struct_values = 0;
  
! /* Some platforms pass small structures through registers versus through
!    an invisible pointer.  Determine at what size structure is the 
!    transition point between the two possibilities. */
  
  static void
  generate_struct_by_value_array ()
--- 437,455 ----
  /* Tells "encode_pointer/encode_aggregate" whether we are generating
     type descriptors for instance variables (as opposed to methods).
     Type descriptors for instance variables contain more information
!    than methods (for static typing and embedded structures).  */
  
  static int generating_instance_variables = 0;
  
! /* Tells the compiler that this is a special run.  Do not perform any
!    compiling, instead we are to test some platform dependent features
!    and output a C header file with appropriate definitions.  */
  
  static int print_struct_values = 0;
  
! /* Some platforms pass small structures through registers versus
!    through an invisible pointer.  Determine at what size structure is
!    the transition point between the two possibilities.  */
  
  static void
  generate_struct_by_value_array ()
*************** generate_struct_by_value_array ()
*** 461,467 ****
    int aggregate_in_mem[32];
    int found = 0;
  
!   /* Presumably no platform passes 32 byte structures in a register. */
    for (i = 1; i < 32; i++)
      {
        char buffer[5];
--- 460,466 ----
    int aggregate_in_mem[32];
    int found = 0;
  
!   /* Presumably no platform passes 32 byte structures in a register.  */
    for (i = 1; i < 32; i++)
      {
        char buffer[5];
*************** generate_struct_by_value_array ()
*** 491,497 ****
      }
   
    /* We found some structures that are returned in registers instead of memory
!      so output the necessary data. */
    if (found)
      {
        for (i = 31; i >= 0;  i--)
--- 490,496 ----
      }
   
    /* We found some structures that are returned in registers instead of memory
!      so output the necessary data.  */
    if (found)
      {
        for (i = 31; i >= 0;  i--)
*************** lookup_method_in_protocol_list (rproto_l
*** 684,721 ****
  
  static tree
  lookup_protocol_in_reflist (rproto_list, lproto)
!    tree rproto_list;
!    tree lproto;
  {
!    tree rproto, p;
  
!    /* Make sure the protocol is supported by the object on the rhs.  */
!    if (TREE_CODE (lproto) == PROTOCOL_INTERFACE_TYPE)
!      {
!        tree fnd = 0;
!        for (rproto = rproto_list; rproto; rproto = TREE_CHAIN (rproto))
!        {
!          p = TREE_VALUE (rproto);
  
!          if (TREE_CODE (p) == PROTOCOL_INTERFACE_TYPE)
!            {
!              if (lproto == p)
!                fnd = lproto;
  
!              else if (PROTOCOL_LIST (p))
!                fnd = lookup_protocol_in_reflist (PROTOCOL_LIST (p), lproto);
!            }
  
!          if (fnd)
!            return fnd;
!        }
!      }
!    else
!      {
!        ; /* An identifier...if we could not find a protocol.  */
!      }
  
!    return 0;
  }
  
  /* Return 1 if LHS and RHS are compatible types for assignment
--- 683,720 ----
  
  static tree
  lookup_protocol_in_reflist (rproto_list, lproto)
!      tree rproto_list;
!      tree lproto;
  {
!   tree rproto, p;
  
!   /* Make sure the protocol is supported by the object on the rhs.  */
!   if (TREE_CODE (lproto) == PROTOCOL_INTERFACE_TYPE)
!     {
!       tree fnd = 0;
!       for (rproto = rproto_list; rproto; rproto = TREE_CHAIN (rproto))
!       {
!         p = TREE_VALUE (rproto);
  
!         if (TREE_CODE (p) == PROTOCOL_INTERFACE_TYPE)
!           {
!             if (lproto == p)
!               fnd = lproto;
  
!             else if (PROTOCOL_LIST (p))
!               fnd = lookup_protocol_in_reflist (PROTOCOL_LIST (p), lproto);
!           }
  
!         if (fnd)
!           return fnd;
!       }
!     }
!   else
!     {
!       ; /* An identifier...if we could not find a protocol.  */
!     }
  
!   return 0;
  }
  
  /* Return 1 if LHS and RHS are compatible types for assignment
*************** init_objc_symtab (type)
*** 1563,1570 ****
    return build_constructor (type, nreverse (initlist));
  }
  
! /* Push forward-declarations of all the categories
!    so that init_def_list can use them in a CONSTRUCTOR.  */
  
  static void
  forward_declare_categories ()
--- 1562,1569 ----
    return build_constructor (type, nreverse (initlist));
  }
  
! /* Push forward-declarations of all the categories so that
!    init_def_list can use them in a CONSTRUCTOR.  */
  
  static void
  forward_declare_categories ()
*************** add_class_reference (ident)
*** 2204,2210 ****
  
  tree
  get_class_reference (ident)
!     tree ident;
  {
    if (flag_next_runtime)
      {
--- 2203,2209 ----
  
  tree
  get_class_reference (ident)
!      tree ident;
  {
    if (flag_next_runtime)
      {
*************** generate_descriptor_table (type, name, s
*** 2829,2845 ****
  }
  
  static void
! generate_method_descriptors (protocol)        /* generate_dispatch_tables */
!   tree protocol;
  {
    tree initlist, chain, method_list_template;
    tree cast, variable_length_type;
    int size;
  
    if (!objc_method_prototype_template)
!     {
!       objc_method_prototype_template = build_method_prototype_template ();
!     }
  
    cast = build_tree_list (build_tree_list (NULL_TREE, xref_tag (RECORD_TYPE,
                                get_identifier (UTAG_METHOD_PROTOTYPE_LIST))),
--- 2828,2842 ----
  }
  
  static void
! generate_method_descriptors (protocol)
!      tree protocol;
  {
    tree initlist, chain, method_list_template;
    tree cast, variable_length_type;
    int size;
  
    if (!objc_method_prototype_template)
!     objc_method_prototype_template = build_method_prototype_template ();
  
    cast = build_tree_list (build_tree_list (NULL_TREE, xref_tag (RECORD_TYPE,
                                get_identifier (UTAG_METHOD_PROTOTYPE_LIST))),
*************** build_ivar_list_initializer (type, field
*** 3750,3756 ****
           ivar);
        obstack_free (&util_obstack, util_firstobj);
  
!       /* Set offset. */
        ivar = tree_cons (NULL_TREE, byte_position (field_decl), ivar);
        initlist = tree_cons (NULL_TREE, 
                            build_constructor (type, nreverse (ivar)),
--- 3747,3753 ----
           ivar);
        obstack_free (&util_obstack, util_firstobj);
  
!       /* Set offset.  */
        ivar = tree_cons (NULL_TREE, byte_position (field_decl), ivar);
        initlist = tree_cons (NULL_TREE, 
                            build_constructor (type, nreverse (ivar)),
*************** finish_message_expr (receiver, sel_name,
*** 4855,4861 ****
    tree selector, self_object, retval;
    int statically_typed = 0, statically_allocated = 0;
    
!   /* Determine receiver type. */
    tree rtype = TREE_TYPE (receiver);
    int super = IS_SUPER (rtype);
  
--- 4852,4858 ----
    tree selector, self_object, retval;
    int statically_typed = 0, statically_allocated = 0;
    
!   /* Determine receiver type.  */
    tree rtype = TREE_TYPE (receiver);
    int super = IS_SUPER (rtype);
  
*************** finish_message_expr (receiver, sel_name,
*** 4880,4886 ****
        if (statically_allocated)
        receiver = build_unary_op (ADDR_EXPR, receiver, 0);
  
!       /* Don't evaluate the receiver twice. */
        receiver = save_expr (receiver);
        self_object = receiver;
      }
--- 4877,4883 ----
        if (statically_allocated)
        receiver = build_unary_op (ADDR_EXPR, receiver, 0);
  
!       /* Don't evaluate the receiver twice.  */
        receiver = save_expr (receiver);
        self_object = receiver;
      }
*************** check_methods_accessible (chain, context
*** 5923,5929 ****
  
        chain = TREE_CHAIN (chain); /* next method...  */
      }
!     return first;
  }
  
  /* Check whether the current interface (accessible via
--- 5920,5926 ----
  
        chain = TREE_CHAIN (chain); /* next method...  */
      }
!   return first;
  }
  
  /* Check whether the current interface (accessible via
*************** check_protocol (p, type, name)
*** 5971,5976 ****
--- 5968,5974 ----
        tree subs = PROTOCOL_LIST (p);
        tree super_class =
        lookup_interface (CLASS_SUPER_NAME (implementation_template));
+ 
        while (subs) 
        {
          tree sub = TREE_VALUE (subs);
*************** lookup_protocol (ident)
*** 6315,6324 ****
    tree chain;
  
    for (chain = protocol_chain; chain; chain = TREE_CHAIN (chain))
!     {
!       if (ident == PROTOCOL_NAME (chain))
!       return chain;
!     }
  
    return NULL_TREE;
  }
--- 6313,6320 ----
    tree chain;
  
    for (chain = protocol_chain; chain; chain = TREE_CHAIN (chain))
!     if (ident == PROTOCOL_NAME (chain))
!       return chain;
  
    return NULL_TREE;
  }
*************** start_protocol (code, name, list)
*** 6395,6401 ****
  
  void
  finish_protocol (protocol)
!       tree protocol ATTRIBUTE_UNUSED;
  {
  }
  
--- 6391,6397 ----
  
  void
  finish_protocol (protocol)
!      tree protocol ATTRIBUTE_UNUSED;
  {
  }
  
*************** encode_aggregate_within (type, curtype, 
*** 6537,6548 ****
      {
        tree name = TYPE_NAME (type);
  
!       /* we have a reference; this is a NeXT extension. */
  
        if (obstack_object_size (&util_obstack) - curtype == 1
          && format == OBJC_ENCODE_INLINE_DEFS)
        {
!         /* Output format of struct for first level only. */
          tree fields = TYPE_FIELDS (type);
  
          if (name && TREE_CODE (name) == IDENTIFIER_NODE)
--- 6533,6544 ----
      {
        tree name = TYPE_NAME (type);
  
!       /* we have a reference; this is a NeXT extension.  */
  
        if (obstack_object_size (&util_obstack) - curtype == 1
          && format == OBJC_ENCODE_INLINE_DEFS)
        {
!         /* Output format of struct for first level only.  */
          tree fields = TYPE_FIELDS (type);
  
          if (name && TREE_CODE (name) == IDENTIFIER_NODE)
*************** encode_aggregate_within (type, curtype, 
*** 6576,6582 ****
  
        else
        {
!         /* We have an untagged structure or a typedef. */
          obstack_1grow (&util_obstack, left);
          obstack_1grow (&util_obstack, '?');
          obstack_1grow (&util_obstack, right);
--- 6572,6578 ----
  
        else
        {
!         /* We have an untagged structure or a typedef.  */
          obstack_1grow (&util_obstack, left);
          obstack_1grow (&util_obstack, '?');
          obstack_1grow (&util_obstack, right);
*************** encode_aggregate_within (type, curtype, 
*** 6632,6638 ****
                            IDENTIFIER_POINTER (name),
                            strlen (IDENTIFIER_POINTER (name)));
          else
!             /* We have an untagged structure or a typedef. */
              obstack_1grow (&util_obstack, '?');
  
          obstack_1grow (&util_obstack, right);
--- 6628,6634 ----
                            IDENTIFIER_POINTER (name),
                            strlen (IDENTIFIER_POINTER (name)));
          else
!             /* We have an untagged structure or a typedef.  */
              obstack_1grow (&util_obstack, '?');
  
          obstack_1grow (&util_obstack, right);
*************** get_super_receiver ()
*** 7193,7199 ****
          tree super_name = CLASS_SUPER_NAME (implementation_template);
          tree super_class;
  
!         /* Barf if super used in a category of Object. */
          if (!super_name)
            {
              error ("no super class declared in interface for `%s'",
--- 7189,7195 ----
          tree super_name = CLASS_SUPER_NAME (implementation_template);
          tree super_class;
  
!         /* Barf if super used in a category of Object.  */
          if (!super_name)
            {
              error ("no super class declared in interface for `%s'",
*************** dump_interface (fp, chain)
*** 7970,7976 ****
       FILE *fp;
       tree chain;
  {
!   char *buf = (char *)xmalloc (256);
    const char *my_name = IDENTIFIER_POINTER (CLASS_NAME (chain));
    tree ivar_decls = CLASS_RAW_IVARS (chain);
    tree nst_methods = CLASS_NST_METHODS (chain);
--- 7966,7972 ----
       FILE *fp;
       tree chain;
  {
!   char *buf = (char *) xmalloc (256);
    const char *my_name = IDENTIFIER_POINTER (CLASS_NAME (chain));
    tree ivar_decls = CLASS_RAW_IVARS (chain);
    tree nst_methods = CLASS_NST_METHODS (chain);
*************** init_objc ()
*** 8099,8105 ****
    gcc_obstack_init (&util_obstack);
    util_firstobj = (char *) obstack_finish (&util_obstack);
  
!   errbuf = (char *)xmalloc (BUFSIZE);
    hash_init ();
    synth_module_prologue ();
  }
--- 8095,8101 ----
    gcc_obstack_init (&util_obstack);
    util_firstobj = (char *) obstack_finish (&util_obstack);
  
!   errbuf = (char *) xmalloc (BUFSIZE);
    hash_init ();
    synth_module_prologue ();
  }
*************** finish_objc ()
*** 8130,8136 ****
  #endif
  
    /* Process the static instances here because initialization of objc_symtab
!      depends on them. */
    if (objc_static_instances)
      generate_static_references ();
  
--- 8126,8132 ----
  #endif
  
    /* Process the static instances here because initialization of objc_symtab
!      depends on them.  */
    if (objc_static_instances)
      generate_static_references ();
  
*************** finish_objc ()
*** 8171,8177 ****
    if (objc_implementation_context || class_names_chain || objc_static_instances
        || meth_var_names_chain || meth_var_types_chain || sel_ref_chain)
      {
!       /* Arrange for Objc data structures to be initialized at run time.  */
        rtx init_sym = build_module_descriptor ();
        if (init_sym && targetm.have_ctors_dtors)
        (* targetm.asm_out.constructor) (init_sym, DEFAULT_INIT_PRIORITY);
--- 8167,8173 ----
    if (objc_implementation_context || class_names_chain || objc_static_instances
        || meth_var_names_chain || meth_var_types_chain || sel_ref_chain)
      {
!       /* Arrange for ObjC data structures to be initialized at run time.  */
        rtx init_sym = build_module_descriptor ();
        if (init_sym && targetm.have_ctors_dtors)
        (* targetm.asm_out.constructor) (init_sym, DEFAULT_INIT_PRIORITY);
*************** finish_objc ()
*** 8250,8256 ****
  
  static void
  generate_classref_translation_entry (chain)
!     tree chain;
  {
    tree expr, name, decl_specs, decl, sc_spec;
    tree type;
--- 8246,8252 ----
  
  static void
  generate_classref_translation_entry (chain)
!      tree chain;
  {
    tree expr, name, decl_specs, decl, sc_spec;
    tree type;
*************** handle_impent (impent)
*** 8346,8352 ****
  
        /* Do the same for categories.  Even though no references to
           these symbols are generated automatically by the compiler, it
!          gives you a handle to pull them into an archive by hand. */
        sprintf (string, "*%sobjc_category_name_%s_%s",
                 (flag_next_runtime ? "." : "__"), class_name, class_super_name);
      }
--- 8342,8348 ----
  
        /* Do the same for categories.  Even though no references to
           these symbols are generated automatically by the compiler, it
!          gives you a handle to pull them into an archive by hand.  */
        sprintf (string, "*%sobjc_category_name_%s_%s",
                 (flag_next_runtime ? "." : "__"), class_name, class_super_name);
      }
*************** handle_impent (impent)
*** 8371,8377 ****
  ^L
  static void
  ggc_mark_imp_list (arg)
!     void *arg;
  {
    struct imp_entry *impent;
  
--- 8367,8373 ----
  ^L
  static void
  ggc_mark_imp_list (arg)
!      void *arg;
  {
    struct imp_entry *impent;
  
*************** ggc_mark_imp_list (arg)
*** 8386,8392 ****
  
  static void
  ggc_mark_hash_table (arg)
!     void *arg;
  {
    hash *hash_table = *(hash **)arg;
    hash hst;
--- 8382,8388 ----
  
  static void
  ggc_mark_hash_table (arg)
!      void *arg;
  {
    hash *hash_table = *(hash **)arg;
    hash hst;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]