aboutsummaryrefslogtreecommitdiff
path: root/gcc/java/lex.c
diff options
context:
space:
mode:
authorAlexandre Petit-Bianco <apbianco@cygnus.com>2001-01-15 08:01:22 +0000
committerAlexandre Petit-Bianco <apbianco@gcc.gnu.org>2001-01-15 00:01:22 -0800
commitdc08e603899b1ac1ea91a9ee641853b20521d61e (patch)
tree978174af2eae55529af123d6d167212203a572ad /gcc/java/lex.c
parentb9333bff58209a5669342bfcbb974cf92081f1e1 (diff)
downloadgcc-dc08e603899b1ac1ea91a9ee641853b20521d61e.zip
gcc-dc08e603899b1ac1ea91a9ee641853b20521d61e.tar.gz
gcc-dc08e603899b1ac1ea91a9ee641853b20521d61e.tar.bz2
All files with updated copyright when applicable.
2001-01-07 Alexandre Petit-Bianco <apbianco@cygnus.com> All files with updated copyright when applicable. * Make-lang.in (JVGENMAIN_OBS): Removed java/mangle.o. * class.c (mangle_class_field): Function removed. (append_gpp_mangled_type, mangle_static_field, mangle_field): Likewise. (utf8_cmp, cxx_keyword_p): Moved to lex.c. (build_class_ref): Call `java_mangle_class_field' instead of `mangle_class_field.' (build_dtable_decl): Rewritten to call `java_mangle_vtable.' (layout_class): Call `java_mangle_decl' instead of `mangle_static_field.' (cxx_keywords): Initialized static array moved to `lex.c.' (layout_class_method): Changed leading comment. Simplified to call `java_mangle_decl.' Local `ptr' moved in for loop body. * decl.c (lang_mark_tree): Mark field `package_list.' * java-tree.h (TYPE_PACKAGE_LIST): New macro. (struct lang_type): New field `package_list.' (unicode_mangling_length): Prototype removed. (append_gpp_mangled_name, append_gpp_mangled_classtype, emit_unicode_mangled_name): Likewise. (cxx_keyword_p): New prototype. (java_mangle_decl, java_mangle_class_field, java_mangle_class_field_from_string, java_mangle_vtable): Likewise. * jcf-parse.c (jcf_parse_source): Constify `file' argument to `build_expr_wfl.' * jvgenmain.c (main_method_prefix): Global variable removed. (main_method_suffix): Likewise. (do_mangle_classname): New function. (main): Call it. Format changed to accomodate new mangling scheme. * lex.c: (utf8_cmp): Conditionally prototyped. (cxx_keywords): Moved from class.c, conditionally defined. (utf8_cmp, cxx_keyword_p): Likewise. * mangle.c (obstack.h, ggc.h): Included. (mangle_field_decl): New function. (mangle_method_decl, mangle_type, mangle_pointer_type, mangle_array_type, mangle_record_type, find_compression_pointer_match, find_compression_array_match, find_compression_record_match, find_compression_array_template_match, set_type_package_list, entry_match_pointer_p, emit_compression_string, init_mangling, finish_mangling, compression_table_add, mangle_member_name): Likewise. (mangle_obstack): New global. (MANGLE_RAW_STRING): New macro. (unicode_mangling_length): Turned static. (append_unicode_mangled_name): Renamed from `emit_unicode_mangled_name.' Turned static. `mangle_obstack' replaces `obstack', removed from the parameter list. (append_gpp_mangled_name): Turned static. `mangle_obstack' replaces parameter `obstack', removed from the parameter list. Call `append_unicode_mangled_name' instead of `emit_unicode_mangled_name. (append_gpp_mangled_classtype): Removed. (compression_table, compression_next): New static variables. * parse.y (temporary_obstack): Extern declaration removed. (This is the new C++ ABI compatibility patch: http://gcc.gnu.org/ml/gcc-patches/2001-01/msg01225.html) From-SVN: r39031
Diffstat (limited to 'gcc/java/lex.c')
-rw-r--r--gcc/java/lex.c104
1 files changed, 103 insertions, 1 deletions
diff --git a/gcc/java/lex.c b/gcc/java/lex.c
index 338f3d5..32c104e 100644
--- a/gcc/java/lex.c
+++ b/gcc/java/lex.c
@@ -1,5 +1,5 @@
/* Language lexer for the GNU compiler for the Java(TM) language.
- Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
Contributed by Alexandre Petit-Bianco (apbianco@cygnus.com)
This file is part of GNU CC.
@@ -61,6 +61,10 @@ static int java_read_char PARAMS ((java_lexer *));
static void java_allocate_new_line PARAMS ((void));
static void java_unget_unicode PARAMS ((void));
static unicode_t java_sneak_unicode PARAMS ((void));
+#ifndef JC1_LITE
+static int utf8_cmp PARAMS ((const unsigned char *, int, const char *));
+#endif
+
java_lexer *java_new_lexer PARAMS ((FILE *, const char *));
/* This is nonzero if we have initialized `need_byteswap'. */
@@ -1763,3 +1767,101 @@ java_get_line_col (filename, line, col)
return obstack_finish (&temporary_obstack);
#endif
}
+
+#ifndef JC1_LITE
+static int
+utf8_cmp (str, length, name)
+ const unsigned char *str;
+ int length;
+ const char *name;
+{
+ const unsigned char *limit = str + length;
+ int i;
+
+ for (i = 0; name[i]; ++i)
+ {
+ int ch = UTF8_GET (str, limit);
+ if (ch != name[i])
+ return ch - name[i];
+ }
+
+ return str == limit ? 0 : 1;
+}
+
+/* A sorted list of all C++ keywords. */
+
+static const char *cxx_keywords[] =
+{
+ "asm",
+ "auto",
+ "bool",
+ "const_cast",
+ "delete",
+ "dynamic_cast",
+ "enum",
+ "explicit",
+ "extern",
+ "friend",
+ "inline",
+ "mutable",
+ "namespace",
+ "overload",
+ "register",
+ "reinterpret_cast",
+ "signed",
+ "sizeof",
+ "static_cast",
+ "struct",
+ "template",
+ "typedef",
+ "typeid",
+ "typename",
+ "typenameopt",
+ "union",
+ "unsigned",
+ "using",
+ "virtual",
+ "volatile",
+ "wchar_t"
+};
+
+/* Return true if NAME is a C++ keyword. */
+
+int
+cxx_keyword_p (name, length)
+ const char *name;
+ int length;
+{
+ int last = ARRAY_SIZE (cxx_keywords);
+ int first = 0;
+ int mid = (last + first) / 2;
+ int old = -1;
+
+ for (mid = (last + first) / 2;
+ mid != old;
+ old = mid, mid = (last + first) / 2)
+ {
+ int kwl = strlen (cxx_keywords[mid]);
+ int min_length = kwl > length ? length : kwl;
+ int r = utf8_cmp (name, min_length, cxx_keywords[mid]);
+
+ if (r == 0)
+ {
+ int i;
+ /* We've found a match if all the remaining characters are
+ `$'. */
+ for (i = min_length; i < length && name[i] == '$'; ++i)
+ ;
+ if (i == length)
+ return 1;
+ r = 1;
+ }
+
+ if (r < 0)
+ last = mid;
+ else
+ first = mid;
+ }
+ return 0;
+}
+#endif /* JC1_LITE */