OSDN Git Service

Backported from mainline
[pf3gnuchains/gcc-fork.git] / gcc / java / jcf-parse.c
index e6dc44c..04c04f5 100644 (file)
@@ -1,6 +1,6 @@
 /* Parser for Java(TM) .class files.
    Copyright (C) 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-   2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+   2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -35,14 +35,13 @@ The Free Software Foundation is independent of Sun Microsystems, Inc.  */
 #include "javaop.h"
 #include "java-tree.h"
 #include "diagnostic-core.h"
-#include "toplev.h"
 #include "parse.h"
 #include "ggc.h"
 #include "debug.h"
-#include "assert.h"
 #include "cgraph.h"
 #include "vecprim.h"
 #include "bitmap.h"
+#include "target.h"
 
 #ifdef HAVE_LOCALE_H
 #include <locale.h>
@@ -177,9 +176,9 @@ java_read_sourcefilenames (const char *fsource_filename)
   if (fsource_filename 
       && filenames == 0
       && strlen (fsource_filename) > strlen (".java")
-      && strcmp ((fsource_filename 
-                 + strlen (fsource_filename)
-                 - strlen (".java")),
+      && filename_cmp ((fsource_filename
+                      + strlen (fsource_filename)
+                      - strlen (".java")),
                 ".java") != 0)
     {
 /*       fsource_filename isn't a .java file but a list of filenames
@@ -323,7 +322,7 @@ set_source_filename (JCF *jcf, int index)
       /* Use the current input_filename (derived from the class name)
         if it has a directory prefix, but otherwise matches sfname. */
       if (old_len > new_len
-         && strcmp (sfname, old_filename + old_len - new_len) == 0
+         && filename_cmp (sfname, old_filename + old_len - new_len) == 0
          && (old_filename[old_len - new_len - 1] == '/'
              || old_filename[old_len - new_len - 1] == '\\'))
        return;
@@ -356,7 +355,7 @@ set_source_filename (JCF *jcf, int index)
     }
       
   sfname = find_sourcefile (sfname);
-  line_table->maps[line_table->used-1].to_file = sfname;
+  ORDINARY_MAP_FILE_NAME (LINEMAPS_LAST_ORDINARY_MAP (line_table)) = sfname;
   if (current_class == main_class) main_input_filename = sfname;
 }
 
@@ -369,7 +368,7 @@ set_source_filename (JCF *jcf, int index)
    from the input class file into the output file.  We don't decode the
    data at all, merely rewriting constant indexes whenever we come
    across them: this is necessary because the constant pool in the
-   output file isn't the same as the constant pool in in the input.
+   output file isn't the same as the constant pool in the input.
 
    The main advantage of this technique is that the resulting
    annotation data is pointer-free, so it doesn't have to be relocated
@@ -555,12 +554,12 @@ handle_constant (JCF *jcf, int index, enum cpool_tag purpose)
 
     case CONSTANT_Long:
       index = handle_long_constant (jcf, cpool, CONSTANT_Long, index,
-                                   WORDS_BIG_ENDIAN);
+                                   targetm.words_big_endian ());
       break;
       
     case CONSTANT_Double:
       index = handle_long_constant (jcf, cpool, CONSTANT_Double, index,
-                                   FLOAT_WORDS_BIG_ENDIAN);
+                                   targetm.float_words_big_endian ());
       break;
 
     case CONSTANT_Float:
@@ -1071,7 +1070,7 @@ get_constant (JCF *jcf, int index)
        hi = JPOOL_UINT (jcf, index);
        lo = JPOOL_UINT (jcf, index+1);
 
-       if (FLOAT_WORDS_BIG_ENDIAN)
+       if (targetm.float_words_big_endian ())
          buf[0] = hi, buf[1] = lo;
        else
          buf[0] = lo, buf[1] = hi;
@@ -1731,7 +1730,7 @@ java_emit_static_constructor (void)
 
 
 void
-java_parse_file (int set_yydebug ATTRIBUTE_UNUSED)
+java_parse_file (void)
 {
   int filename_count = 0;
   location_t save_location = input_location;
@@ -1749,7 +1748,7 @@ java_parse_file (int set_yydebug ATTRIBUTE_UNUSED)
       int avail = 2000;
       finput = fopen (main_input_filename, "r");
       if (finput == NULL)
-       fatal_error ("can't open %s: %m", input_filename);
+       fatal_error ("can%'t open %s: %m", input_filename);
       list = XNEWVEC (char, avail);
       next = list;
       for (;;)
@@ -1763,7 +1762,7 @@ java_parse_file (int set_yydebug ATTRIBUTE_UNUSED)
              next = list + count;
              avail = avail - count;
            }
-         /* Subtract to to guarantee space for final '\0'. */
+         /* Subtract one to guarantee space for final '\0'. */
          count = fread (next, 1, avail - 1, finput);
          if (count == 0)
            {
@@ -1844,8 +1843,7 @@ java_parse_file (int set_yydebug ATTRIBUTE_UNUSED)
       list = next;
     }
 
-  if (file_list != NULL)
-    free (file_list);
+  free (file_list);
 
   if (filename_count == 0)
     warning (0, "no input file specified");
@@ -1855,7 +1853,7 @@ java_parse_file (int set_yydebug ATTRIBUTE_UNUSED)
       const char *resource_filename;
       
       /* Only one resource file may be compiled at a time.  */
-      assert (VEC_length (tree, all_translation_units) == 1);
+      gcc_assert (VEC_length (tree, all_translation_units) == 1);
 
       resource_filename
        = IDENTIFIER_POINTER
@@ -1884,11 +1882,11 @@ java_parse_file (int set_yydebug ATTRIBUTE_UNUSED)
 
       /* Close previous descriptor, if any */
       if (finput && fclose (finput))
-       fatal_error ("can't close input file %s: %m", main_input_filename);
+       fatal_error ("can%'t close input file %s: %m", main_input_filename);
       
       finput = fopen (filename, "rb");
       if (finput == NULL)
-       fatal_error ("can't open %s: %m", filename);
+       fatal_error ("can%'t open %s: %m", filename);
 
 #ifdef IO_BUFFER_SIZE
       setvbuf (finput, xmalloc (IO_BUFFER_SIZE),