]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
decl.c (init_decl_processing): Add `throws' field to method descriptor.
authorTom Tromey <tromey@redhat.com>
Fri, 24 Aug 2001 17:24:02 +0000 (17:24 +0000)
committerTom Tromey <tromey@gcc.gnu.org>
Fri, 24 Aug 2001 17:24:02 +0000 (17:24 +0000)
* decl.c (init_decl_processing): Add `throws' field to method
descriptor.
* class.c (make_method_value): Compute `throws' field for method.

From-SVN: r45152

gcc/java/ChangeLog
gcc/java/class.c
gcc/java/decl.c

index e763b18c132f6ae62a4ab45d03f855a2112ebad5..45b145ef7aecf8e0d4a1cdfb49b91e7186426b7b 100644 (file)
@@ -1,3 +1,9 @@
+2001-08-21  Tom Tromey  <tromey@redhat.com>
+
+       * decl.c (init_decl_processing): Add `throws' field to method
+       descriptor.
+       * class.c (make_method_value): Compute `throws' field for method.
+
 2001-08-22  Alexandre Petit-Bianco  <apbianco@redhat.com>
 
        * parse.y (resolve_inner_class): Keep local_enclosing to NULL if
index e8f7e6f312aaee569aa70452369fb0d6b73e0f6a..e0caeae71d712aaa678592d4033644aa0aab0161 100644 (file)
@@ -1151,6 +1151,7 @@ static tree
 make_method_value (mdecl)
      tree mdecl;
 {
+  static int method_name_count = 0;
   tree minit;
   tree code;
 #define ACC_TRANSLATED          0x4000
@@ -1173,6 +1174,44 @@ make_method_value (mdecl)
   }
   PUSH_FIELD_VALUE (minit, "accflags", build_int_2 (accflags, 0));
   PUSH_FIELD_VALUE (minit, "ncode", code);
+
+  {
+    /* Compute the `throws' information for the method.  */
+    tree table = integer_zero_node;
+    if (DECL_FUNCTION_THROWS (mdecl) != NULL_TREE)
+      {
+       int length = 1 + list_length (DECL_FUNCTION_THROWS (mdecl));
+       tree iter, type, array;
+       char buf[60];
+
+       table = tree_cons (NULL_TREE, table, NULL_TREE);
+       for (iter = DECL_FUNCTION_THROWS (mdecl);
+            iter != NULL_TREE;
+            iter = TREE_CHAIN (iter))
+         {
+           tree sig = build_java_signature (TREE_VALUE (iter));
+           tree utf8
+             = build_utf8_ref (unmangle_classname (IDENTIFIER_POINTER (sig),
+                                                   IDENTIFIER_LENGTH (sig)));
+           table = tree_cons (NULL_TREE, utf8, table);
+         }
+       type = build_prim_array_type (ptr_type_node, length);
+       table = build (CONSTRUCTOR, type, NULL_TREE, table);
+       /* Compute something unique enough.  */
+       sprintf (buf, "_methods%d", method_name_count++);
+       array = build_decl (VAR_DECL, get_identifier (buf), type);
+       DECL_INITIAL (array) = table;
+       TREE_STATIC (array) = 1;
+       DECL_ARTIFICIAL (array) = 1;
+       DECL_IGNORED_P (array) = 1;
+       rest_of_decl_compilation (array, (char*) 0, 1, 0);
+
+       table = build1 (ADDR_EXPR, ptr_type_node, array);
+      }
+
+    PUSH_FIELD_VALUE (minit, "throws", table);
+  }
+
   FINISH_RECORD_CONSTRUCTOR (minit);
   return minit;
 }
index ecfa9aa17bc5722995007c70b97d8b8d33a6e465..21cc3bde359e47ee169fd64407d19047f763b1e3 100644 (file)
@@ -715,6 +715,7 @@ init_decl_processing ()
   PUSH_FIELD (method_type_node, field, "signature", utf8const_ptr_type);
   PUSH_FIELD (method_type_node, field, "accflags", access_flags_type_node);
   PUSH_FIELD (method_type_node, field, "ncode", nativecode_ptr_type_node);
+  PUSH_FIELD (method_type_node, field, "throws", ptr_type_node);
   FINISH_RECORD (method_type_node);
   build_decl (TYPE_DECL, get_identifier ("Method"), method_type_node);