OSDN Git Service

2006-02-09 Andrew Haley <aph@redhat.com>
[pf3gnuchains/gcc-fork.git] / gcc / java / jcf-reader.c
index 1bd5299..219cf65 100644 (file)
@@ -1,7 +1,7 @@
 /* This file read a Java(TM) .class file.
    It is not stand-alone:  It depends on tons of macros, and the
    intent is you #include this file after you've defined the macros.
-   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
+   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005
    Free Software Foundation, Inc.
 
 This file is part of GCC.
@@ -18,8 +18,8 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING.  If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  
+the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA.  
 
 Java and all Java-based marks are trademarks or registered trademarks
 of Sun Microsystems, Inc. in the United States and other countries.
@@ -50,11 +50,8 @@ static void skip_attribute (JCF *, int);
 
 #ifdef NEED_PEEK_ATTRIBUTE     /* Not everyone uses this function */
 static int
-peek_attribute (jcf, attribute_number, peeked_name, peeked_name_length)
-      JCF *jcf;
-      int attribute_number;
-      const char *peeked_name;
-      int peeked_name_length;
+peek_attribute (JCF *jcf, int attribute_number, const char *peeked_name,
+               int peeked_name_length)
 {
   int to_return = 0;
   long absolute_offset = (long)JCF_TELL (jcf);
@@ -92,9 +89,7 @@ peek_attribute (jcf, attribute_number, peeked_name, peeked_name_length)
 
 #ifdef NEED_SKIP_ATTRIBUTE     /* Not everyone uses this function */
 static void
-skip_attribute (jcf, number_of_attribute)
-     JCF *jcf;
-     int number_of_attribute;
+skip_attribute (JCF *jcf, int number_of_attribute)
 {
   while (number_of_attribute--)
     {
@@ -226,6 +221,20 @@ get_attribute (JCF *jcf)
     }
   else
 #endif
+#ifdef HANDLE_DEPRECATED_ATTRIBUTE
+  if (MATCH_ATTRIBUTE ("Deprecated"))
+    {
+      HANDLE_DEPRECATED_ATTRIBUTE ();
+    }
+  else
+#endif
+#ifdef HANDLE_SOURCEDEBUGEXTENSION_ATTRIBUTE
+  if (MATCH_ATTRIBUTE ("SourceDebugExtension")) /* JSR 45 */
+    {
+      HANDLE_SOURCEDEBUGEXTENSION_ATTRIBUTE (attribute_length);
+    }
+  else
+#endif
     {
 #ifdef PROCESS_OTHER_ATTRIBUTE
       PROCESS_OTHER_ATTRIBUTE(jcf, attribute_name, attribute_length);
@@ -264,8 +273,8 @@ jcf_parse_constant_pool (JCF* jcf)
 {
   int i, n;
   JPOOL_SIZE (jcf) = (JCF_FILL (jcf, 2), JCF_readu2 (jcf));
-  jcf->cpool.tags = ALLOC (JPOOL_SIZE (jcf));
-  jcf->cpool.data = ALLOC (sizeof (jword) * JPOOL_SIZE (jcf));
+  jcf->cpool.tags = ggc_alloc (JPOOL_SIZE (jcf));
+  jcf->cpool.data = ggc_alloc (sizeof (jword) * JPOOL_SIZE (jcf));
   jcf->cpool.tags[0] = 0;
 #ifdef HANDLE_START_CONSTANT_POOL
   HANDLE_START_CONSTANT_POOL (JPOOL_SIZE (jcf));
@@ -285,25 +294,25 @@ jcf_parse_constant_pool (JCF* jcf)
        {
        case CONSTANT_String:
        case CONSTANT_Class:
-         jcf->cpool.data[i] = JCF_readu2 (jcf);
+         jcf->cpool.data[i].w = JCF_readu2 (jcf);
          break;
        case CONSTANT_Fieldref:
        case CONSTANT_Methodref:
        case CONSTANT_InterfaceMethodref:
        case CONSTANT_NameAndType:
-         jcf->cpool.data[i] = JCF_readu2 (jcf);
-         jcf->cpool.data[i] |= JCF_readu2 (jcf) << 16;
+         jcf->cpool.data[i].w = JCF_readu2 (jcf);
+         jcf->cpool.data[i].w |= JCF_readu2 (jcf) << 16;
          break;
        case CONSTANT_Integer:
        case CONSTANT_Float:
-         jcf->cpool.data[i] = JCF_readu4 (jcf);
+         jcf->cpool.data[i].w = JCF_readu4 (jcf);
          break;
        case CONSTANT_Long:
        case CONSTANT_Double:
-         jcf->cpool.data[i] = JCF_readu4 (jcf);
+         jcf->cpool.data[i].w = JCF_readu4 (jcf);
          i++; /* These take up two spots in the constant pool */
          jcf->cpool.tags[i] = 0;
-         jcf->cpool.data[i] = JCF_readu4 (jcf);
+         jcf->cpool.data[i].w = JCF_readu4 (jcf);
          break;
        case CONSTANT_Utf8:
          n = JCF_readu2 (jcf);
@@ -311,7 +320,7 @@ jcf_parse_constant_pool (JCF* jcf)
 #ifdef HANDLE_CONSTANT_Utf8
          HANDLE_CONSTANT_Utf8(jcf, i, n);
 #else
-         jcf->cpool.data[i] = JCF_TELL(jcf) - 2;
+         jcf->cpool.data[i].w = JCF_TELL(jcf) - 2;
          JCF_SKIP (jcf, n);
 #endif
          break;