Commit 5e942c50 by Alexandre Petit-Bianco Committed by Alexandre Petit-Bianco

class.c (is_compiled_class): Call safe_layout_class for class compiled from source.

Tue Nov 10 12:34:03 1998  Alexandre Petit-Bianco  <apbianco@cygnus.com>
	* class.c (is_compiled_class): Call safe_layout_class for class
 	compiled from source.
	* conver.h (convert_to_integer, convert_to_real,
 	convert_to_pointer): Added prototypes.
	* decl.c (init_decl_processing): Non longer push the decls of
 	`methodtable', `constants', `Class', `Field', `dispatchTable'
 	`jexception' and `Method'.
	* expr.c (build_invokeinterface): New function.
	(expand_invoke): static variable CLASS_IDENT now in
 	build_invokeinterface. Use build_invokeinterface.
	(expand_java_field_op): Moved code to inline
 	java.lang.PRIMTYPE.TYPE into a function.
	(build_primtype_type_ref): New function.
	* java-tree.def (INSTANCEOF_EXPR): New tree code.
	* java-tree.h (CLASS_METHOD_CHECKED_P, METHOD_DEPRECATED,
 	FIELD_DEPRECATED, CLASS_DEPRECATED): New flag macros.
	(DECL_CONSTRUCTOR_P): Fixed typo in comment.
	(DECL_LOCAL_STATIC_VALUE): New macro.
	(build_invokeinterface, build_primtype_type_ref): New function
 	prototypes.
	(java_parse_abort_on_error): Macro rewritten.
	* jcf-parse.c (current_method): Add comment to declaration.
	(parse_zip_file_entries, process_zip_dir, void parse_source_file):
 	Function prototypes fixed.
	(jcf_parse_source): push/pop parser context. save/restore global.
	(parse_source_file): Fixed leading comment. Now take a
 	IDENTIFIER_NODE as an argument. Doesn't check methods, layout
 	classes and pop the parser context anymore.
	(yyparse): Push parser context, save globals, parse the source
 	file, restore globals and pop the parser context when processing a
 	source file.
	* jcf.h (VERBOSE_SKELETON): Replaces SOURCE_FRONTEND_DEBUG define.
	* lex.c (java_parse_doc_section): New function.
	(java_lex): Call java_parse_doc_section when appropriate. Build an
 	operator around INSTANCEOF_TK.
	* lex.h (java_lineterminator, java_sprint_unicode,
 	java_unicode_2_utf8, java_lex_error, java_store_unicode):
 	Prototypes rewritten.
	(java_parse_escape_sequence, java_letter_or_digit_p,
 	java_parse_doc_section, java_parse_end_comment, java_get_unicode,
 	java_read_unicode, java_store_unicode, java_read_char,
 	java_allocate_new_line, java_unget_unicode, java_sneak_unicode):
 	Added function prototypes.
	* parse.h (VERBOSE_SKELETON): Replaces SOURCE_FRONTEND_DEBUG
 	define.
	(JNULLP_TYPE_P, CHECK_METHODS, CHECK_DEPRECATED, REGISTER_IMPORT):
 	New macros
	(struct parser_ctxt): New fields: deprecated,
 	current_parsed_class_un, gclass_list.
	(fix_method_argument_names, issue_warning_error_from_context,
 	resolve_package, lookup_package_type): New function prototypes.
	(resolve_expression_name): Fixed function prototype.
	(find_applicable_accessible_methods_list): Fixed indentation, added
	extra argument in prototype.
	(check_final_assignment, build_null_of_type, check_deprecation,
 	check_method_redefinition, reset_method_name,
 	java_check_regular_methods, java_check_abstract_methods,
 	maybe_build_primttype_type_ref): New function prototype.
	* parse.y (conver.h): Include.
	(INSTANCEOF_TK): Tagged <operator>.
	(single_type_import_declaration): Use REGISTER_IMPORT macro.
	(relational_expression:): Build binop for instanceof.
	(java_push_parser_context): Remember ctxp->gclass_list across
 	contexts.
	(java_pop_parser_context): Simply return if no context
 	exists. Remember gclass_list across contexts.
	(issue_warning_error_from_context): New function.
	(parse_error_context): Don't setup ctxp->elc here. Call
 	issue_warning_error_from_context instead.
	(parse_warning_context): Likewise.
	(maybe_create_class_interface_decl): Removed DECL_ARTIFICIAL
 	setup. Link new class/interface to ctxp->gclass_list.
	(add_superinterfaces): Register interface as incomplete if not
 	loaded.
	(create_class): Remember class unqualified name in
 	ctxp->current_parsed_class_un. Check class deprecation.
	(register_fields): Check field deprecation. Remember static final
 	field value in DECL_LOCAL_STATIC_VALUE. Changed comment in part
 	processing INIT.
	(method_header): New local variable ORIG_ARG. Use unqualified
 	current class name for check on constructor errors. Promote return
 	type if of record type. Argument list fix moved in
 	fix_method_argument_names, called here. Check method deprecation.
	(fix_method_argument_names): New function.
	(method_declarator): Promote record typed arguments.
	(safe_layout_class): Check class methods before layout.
	(java_complete_class): Compute field layout when patched.
	(do_resolve_class): Try to load class after having it renamed
 	after the package name.
	(get_printable_method_name): Use DECL_CONTEXT.
	(reset_method_name): New function.
	(check_method_redefinition): Use reset_method_name.
	(java_check_regular_methods): New local variable
 	SAVED_FOUND_WFL. Temporarily reinstall overriding/hiding method
 	names for error report. Check for compile-time error when method
 	found has default (package) access.
	(java_check_abstract_methods): Now takes an interface DECL node as
 	an argument. Also reinstall real name on unchecked
 	overriding/hiding methods for error report.
	(java_check_methods): Fixed leading comment. Get classes to verify
 	from ctxp->gclass_list. Use CHECK_METHODS macro and set
 	CLASS_METHOD_CHECKED_P on class verification.
	(lookup_java_method2): Get real method name if necessary.
	(find_in_imports): Don't check package class access here.
	(resolve_package, lookup_package_type): New functions.
	(java_layout_classes): Fixed leading comment. Take classes to be
 	laid out from ctxp->gclass_list.
	(java_complete_expand_methods): Don't expand native and abstract
 	methods.
	(java_expand_classes): New function.
	(resolve_expression_name): Use additional argument ORIG.  Retrieve
 	values of static final field of primitive types.
	(resolve_field_access): Handles static final field of promotive
 	type.
	(resolve_qualified_expression_name): Handle STRING_CST as
 	primaries and package name resolution. Check deprecation on found
 	decls. Set where_found and type_found on non static field resolved
 	during qualification. Layout non primitive field decl types.
	(check_deprecation): New function.
	(maybe_access_field): Simplified.
	(patch_method_invocation_stmt): Local variable CLASS_TYPE
 	removed. Reverse method's argument when primary is a type. Don't
 	use CLASS_TYPE to report problems, use IDENTIFIER_WFL
 	instead. Include abstract class in the list of class searchable
 	for constructors. Use DECL_CONTEXT of found method for access
 	checks. Check method deprecation.
	(patch_invoke): Pay extra care to NEW_CLASS_EXPR type call when
 	converting arguments. Handle INVOKE_INTERFACE.
	(lookup_method_invoke): Search constructor using existing
 	infrastructure (don't rely on lookup_java_constructor anymore).
	(find_applicable_accessible_methods_list): Extra argument flag
 	LC. Now include constructor in the search.
	(qualify_ambiguous_name): Conditional expression are primaries.
	(not_initialized_as_it_should_p): static final are always
 	initialized.
	(java_complete_tree): Pass extra NULL argument to
 	resolve_expression_name. Stricter test to carry on patching
 	assignments. New case for INSTANCEOF_EXPR.
	(complete_function_arguments): Inline PRIMTYPE.TYPE read access.
	(check_final_assignment, maybe_build_primttype_type_ref): New
 	functions.
	(patch_assignment): Detect resolved static finals and carry normal
 	assignment error check on them. Inline PRIMTYPE.TYPE read access.
	(try_builtin_assignconv): Access constant 0 on all primitive
 	types.
	(valid_builtin_assignconv_identity_widening_p): Accept identical
 	types. Accept all promoted type on int type.
	(valid_ref_assignconv_cast_p): Accept a null pointer to be
 	assigned to a reference.
	(valid_method_invocation_conversion_p): Accept to check null
 	pointers.
	(build_binop): Merge declaration and initialization of local
 	variable BINOP.
	(patch_binop): New case for INSTANCEOF_EXPR. NE_EXPR to accept all
 	numeric types. Improved validity test for qualify operators on
 	references.
	(patch_unaryop): Broadened rejection test for PREDECREMENT_EXPR
 	and PREINCREMENT_EXPR. Also detect resolved static finals of a
 	primitive type and issue the appropriate error message.
	(resolve_type_during_patch): Mark class loaded when resolved.
	(patch_cast): Allow null to be cased to reference types.
	(build_null_of_type): New function.
	(patch_array_ref): Handle array on references correctly.
	(patch_return): Removed unused local variable MODIFY. Force
 	boolean to be returned as integers. Allows null to be returned by
 	a function returning a reference.
	* typeck.c (convert_to_integer, convert_to_real,
 	convert_to_pointer): Prototypes moved to convert.h
	(lookup_argument_method): Use method real name, if necessary.
This improves method checking, gets rid of a cross file type
dependency bug and does a more robust job at laying out classes when
necessary. It unifies the regular methods and constructors lookup. It
implements the `instanceof' operator and interface method
invocations. It also fixes random bugs.

From-SVN: r23599
parent fbd2bdda
Tue Nov 10 12:34:03 1998 Alexandre Petit-Bianco <apbianco@cygnus.com>
* class.c (is_compiled_class): Call safe_layout_class for class
compiled from source.
* conver.h (convert_to_integer, convert_to_real,
convert_to_pointer): Added prototypes.
* decl.c (init_decl_processing): Non longer push the decls of
`methodtable', `constants', `Class', `Field', `dispatchTable'
`jexception' and `Method'.
* expr.c (build_invokeinterface): New function.
(expand_invoke): static variable CLASS_IDENT now in
build_invokeinterface. Use build_invokeinterface.
(expand_java_field_op): Moved code to inline
java.lang.PRIMTYPE.TYPE into a function.
(build_primtype_type_ref): New function.
* java-tree.def (INSTANCEOF_EXPR): New tree code.
* java-tree.h (CLASS_METHOD_CHECKED_P, METHOD_DEPRECATED,
FIELD_DEPRECATED, CLASS_DEPRECATED): New flag macros.
(DECL_CONSTRUCTOR_P): Fixed typo in comment.
(DECL_LOCAL_STATIC_VALUE): New macro.
(build_invokeinterface, build_primtype_type_ref): New function
prototypes.
(java_parse_abort_on_error): Macro rewritten.
* jcf-parse.c (current_method): Add comment to declaration.
(parse_zip_file_entries, process_zip_dir, void parse_source_file):
Function prototypes fixed.
(jcf_parse_source): push/pop parser context. save/restore global.
(parse_source_file): Fixed leading comment. Now take a
IDENTIFIER_NODE as an argument. Doesn't check methods, layout
classes and pop the parser context anymore.
(yyparse): Push parser context, save globals, parse the source
file, restore globals and pop the parser context when processing a
source file.
* jcf.h (VERBOSE_SKELETON): Replaces SOURCE_FRONTEND_DEBUG define.
* lex.c (java_parse_doc_section): New function.
(java_lex): Call java_parse_doc_section when appropriate. Build an
operator around INSTANCEOF_TK.
* lex.h (java_lineterminator, java_sprint_unicode,
java_unicode_2_utf8, java_lex_error, java_store_unicode):
Prototypes rewritten.
(java_parse_escape_sequence, java_letter_or_digit_p,
java_parse_doc_section, java_parse_end_comment, java_get_unicode,
java_read_unicode, java_store_unicode, java_read_char,
java_allocate_new_line, java_unget_unicode, java_sneak_unicode):
Added function prototypes.
* parse.h (VERBOSE_SKELETON): Replaces SOURCE_FRONTEND_DEBUG
define.
(JNULLP_TYPE_P, CHECK_METHODS, CHECK_DEPRECATED, REGISTER_IMPORT):
New macros
(struct parser_ctxt): New fields: deprecated,
current_parsed_class_un, gclass_list.
(fix_method_argument_names, issue_warning_error_from_context,
resolve_package, lookup_package_type): New function prototypes.
(resolve_expression_name): Fixed function prototype.
(find_applicable_accessible_methods_list): Fixed indentation, added
extra argument in prototype.
(check_final_assignment, build_null_of_type, check_deprecation,
check_method_redefinition, reset_method_name,
java_check_regular_methods, java_check_abstract_methods,
maybe_build_primttype_type_ref): New function prototype.
* parse.y (conver.h): Include.
(INSTANCEOF_TK): Tagged <operator>.
(single_type_import_declaration): Use REGISTER_IMPORT macro.
(relational_expression:): Build binop for instanceof.
(java_push_parser_context): Remember ctxp->gclass_list across
contexts.
(java_pop_parser_context): Simply return if no context
exists. Remember gclass_list across contexts.
(issue_warning_error_from_context): New function.
(parse_error_context): Don't setup ctxp->elc here. Call
issue_warning_error_from_context instead.
(parse_warning_context): Likewise.
(maybe_create_class_interface_decl): Removed DECL_ARTIFICIAL
setup. Link new class/interface to ctxp->gclass_list.
(add_superinterfaces): Register interface as incomplete if not
loaded.
(create_class): Remember class unqualified name in
ctxp->current_parsed_class_un. Check class deprecation.
(register_fields): Check field deprecation. Remember static final
field value in DECL_LOCAL_STATIC_VALUE. Changed comment in part
processing INIT.
(method_header): New local variable ORIG_ARG. Use unqualified
current class name for check on constructor errors. Promote return
type if of record type. Argument list fix moved in
fix_method_argument_names, called here. Check method deprecation.
(fix_method_argument_names): New function.
(method_declarator): Promote record typed arguments.
(safe_layout_class): Check class methods before layout.
(java_complete_class): Compute field layout when patched.
(do_resolve_class): Try to load class after having it renamed
after the package name.
(get_printable_method_name): Use DECL_CONTEXT.
(reset_method_name): New function.
(check_method_redefinition): Use reset_method_name.
(java_check_regular_methods): New local variable
SAVED_FOUND_WFL. Temporarily reinstall overriding/hiding method
names for error report. Check for compile-time error when method
found has default (package) access.
(java_check_abstract_methods): Now takes an interface DECL node as
an argument. Also reinstall real name on unchecked
overriding/hiding methods for error report.
(java_check_methods): Fixed leading comment. Get classes to verify
from ctxp->gclass_list. Use CHECK_METHODS macro and set
CLASS_METHOD_CHECKED_P on class verification.
(lookup_java_method2): Get real method name if necessary.
(find_in_imports): Don't check package class access here.
(resolve_package, lookup_package_type): New functions.
(java_layout_classes): Fixed leading comment. Take classes to be
laid out from ctxp->gclass_list.
(java_complete_expand_methods): Don't expand native and abstract
methods.
(java_expand_classes): New function.
(resolve_expression_name): Use additional argument ORIG. Retrieve
values of static final field of primitive types.
(resolve_field_access): Handles static final field of promotive
type.
(resolve_qualified_expression_name): Handle STRING_CST as
primaries and package name resolution. Check deprecation on found
decls. Set where_found and type_found on non static field resolved
during qualification. Layout non primitive field decl types.
(check_deprecation): New function.
(maybe_access_field): Simplified.
(patch_method_invocation_stmt): Local variable CLASS_TYPE
removed. Reverse method's argument when primary is a type. Don't
use CLASS_TYPE to report problems, use IDENTIFIER_WFL
instead. Include abstract class in the list of class searchable
for constructors. Use DECL_CONTEXT of found method for access
checks. Check method deprecation.
(patch_invoke): Pay extra care to NEW_CLASS_EXPR type call when
converting arguments. Handle INVOKE_INTERFACE.
(lookup_method_invoke): Search constructor using existing
infrastructure (don't rely on lookup_java_constructor anymore).
(find_applicable_accessible_methods_list): Extra argument flag
LC. Now include constructor in the search.
(qualify_ambiguous_name): Conditional expression are primaries.
(not_initialized_as_it_should_p): static final are always
initialized.
(java_complete_tree): Pass extra NULL argument to
resolve_expression_name. Stricter test to carry on patching
assignments. New case for INSTANCEOF_EXPR.
(complete_function_arguments): Inline PRIMTYPE.TYPE read access.
(check_final_assignment, maybe_build_primttype_type_ref): New
functions.
(patch_assignment): Detect resolved static finals and carry normal
assignment error check on them. Inline PRIMTYPE.TYPE read access.
(try_builtin_assignconv): Access constant 0 on all primitive
types.
(valid_builtin_assignconv_identity_widening_p): Accept identical
types. Accept all promoted type on int type.
(valid_ref_assignconv_cast_p): Accept a null pointer to be
assigned to a reference.
(valid_method_invocation_conversion_p): Accept to check null
pointers.
(build_binop): Merge declaration and initialization of local
variable BINOP.
(patch_binop): New case for INSTANCEOF_EXPR. NE_EXPR to accept all
numeric types. Improved validity test for qualify operators on
references.
(patch_unaryop): Broadened rejection test for PREDECREMENT_EXPR
and PREINCREMENT_EXPR. Also detect resolved static finals of a
primitive type and issue the appropriate error message.
(resolve_type_during_patch): Mark class loaded when resolved.
(patch_cast): Allow null to be cased to reference types.
(build_null_of_type): New function.
(patch_array_ref): Handle array on references correctly.
(patch_return): Removed unused local variable MODIFY. Force
boolean to be returned as integers. Allows null to be returned by
a function returning a reference.
* typeck.c (convert_to_integer, convert_to_real,
convert_to_pointer): Prototypes moved to convert.h
(lookup_argument_method): Use method real name, if necessary.
1998-10-30 Tom Tromey <tromey@cygnus.com> 1998-10-30 Tom Tromey <tromey@cygnus.com>
* class.c (build_class_ref): Changed name of primitive classes to * class.c (build_class_ref): Changed name of primitive classes to
......
...@@ -1153,7 +1153,12 @@ is_compiled_class (class) ...@@ -1153,7 +1153,12 @@ is_compiled_class (class)
if (flag_assume_compiled) if (flag_assume_compiled)
{ {
if (!CLASS_LOADED_P (class)) if (!CLASS_LOADED_P (class))
load_class (class, 1); {
if (CLASS_FROM_SOURCE_P (class))
safe_layout_class (class);
else
load_class (class, 1);
}
return 1; return 1;
} }
......
/* Definition of conversion functions. /* Definition of conversion functions.
Copyright (C) 1993 Free Software Foundation, Inc. Copyright (C) 1993 Free Software Foundation, Inc.
...@@ -22,3 +23,6 @@ Boston, MA 02111-1307, USA. */ ...@@ -22,3 +23,6 @@ Boston, MA 02111-1307, USA. */
extern tree convert_to_boolean PROTO ((tree, tree)); extern tree convert_to_boolean PROTO ((tree, tree));
extern tree convert_to_char PROTO ((tree, tree)); extern tree convert_to_char PROTO ((tree, tree));
extern tree convert_to_integer PROTO ((tree type, tree expr));
extern tree convert_to_real PROTO ((tree type, tree expr));
extern tree convert_to_pointer PROTO ((tree type, tree expr));
...@@ -527,8 +527,7 @@ init_decl_processing () ...@@ -527,8 +527,7 @@ init_decl_processing ()
methodtable_type = make_node (RECORD_TYPE); methodtable_type = make_node (RECORD_TYPE);
layout_type (methodtable_type); layout_type (methodtable_type);
pushdecl (build_decl (TYPE_DECL, get_identifier ("methodtable"), build_decl (TYPE_DECL, get_identifier ("methodtable"), methodtable_type);
methodtable_type));
methodtable_ptr_type = build_pointer_type (methodtable_type); methodtable_ptr_type = build_pointer_type (methodtable_type);
TYPE_identifier_node = get_identifier ("TYPE"); TYPE_identifier_node = get_identifier ("TYPE");
...@@ -554,8 +553,7 @@ init_decl_processing () ...@@ -554,8 +553,7 @@ init_decl_processing ()
PUSH_FIELD (constants_type_node, field, "tags", ptr_type_node); PUSH_FIELD (constants_type_node, field, "tags", ptr_type_node);
PUSH_FIELD (constants_type_node, field, "data", ptr_type_node); PUSH_FIELD (constants_type_node, field, "data", ptr_type_node);
FINISH_RECORD (constants_type_node); FINISH_RECORD (constants_type_node);
pushdecl (build_decl (TYPE_DECL, get_identifier ("constants"), build_decl (TYPE_DECL, get_identifier ("constants"), constants_type_node);
constants_type_node));
access_flags_type_node = unsigned_short_type_node; access_flags_type_node = unsigned_short_type_node;
...@@ -606,7 +604,7 @@ init_decl_processing () ...@@ -606,7 +604,7 @@ init_decl_processing ()
FIELD_PRIVATE (t) = 1; FIELD_PRIVATE (t) = 1;
push_super_field (class_type_node, object_type_node); push_super_field (class_type_node, object_type_node);
FINISH_RECORD (class_type_node); FINISH_RECORD (class_type_node);
pushdecl (build_decl (TYPE_DECL, get_identifier ("Class"), class_type_node)); build_decl (TYPE_DECL, get_identifier ("Class"), class_type_node);
field_info_union_node = make_node (UNION_TYPE); field_info_union_node = make_node (UNION_TYPE);
PUSH_FIELD (field_info_union_node, field, "boffset", int_type_node); PUSH_FIELD (field_info_union_node, field, "boffset", int_type_node);
...@@ -623,7 +621,7 @@ init_decl_processing () ...@@ -623,7 +621,7 @@ init_decl_processing ()
PUSH_FIELD (field_type_node, field, "info", field_info_union_node); PUSH_FIELD (field_type_node, field, "info", field_info_union_node);
FINISH_RECORD (field_type_node); FINISH_RECORD (field_type_node);
CLASS_LOADED_P (field_type_node) = 1; CLASS_LOADED_P (field_type_node) = 1;
pushdecl (build_decl (TYPE_DECL, get_identifier ("Field"), field_type_node)); build_decl (TYPE_DECL, get_identifier ("Field"), field_type_node);
one_elt_array_domain_type = build_index_type (integer_one_node); one_elt_array_domain_type = build_index_type (integer_one_node);
nativecode_ptr_array_type_node nativecode_ptr_array_type_node
...@@ -632,7 +630,7 @@ init_decl_processing () ...@@ -632,7 +630,7 @@ init_decl_processing ()
PUSH_FIELD (dtable_type, field, "class", class_ptr_type); PUSH_FIELD (dtable_type, field, "class", class_ptr_type);
PUSH_FIELD (dtable_type, field, "methods", nativecode_ptr_array_type_node); PUSH_FIELD (dtable_type, field, "methods", nativecode_ptr_array_type_node);
FINISH_RECORD (dtable_type); FINISH_RECORD (dtable_type);
pushdecl (build_decl (TYPE_DECL, get_identifier ("dispatchTable"), dtable_type)); build_decl (TYPE_DECL, get_identifier ("dispatchTable"), dtable_type);
#define jint_type int_type_node #define jint_type int_type_node
#define jint_ptr_type ptr_type_node #define jint_ptr_type ptr_type_node
...@@ -643,7 +641,7 @@ init_decl_processing () ...@@ -643,7 +641,7 @@ init_decl_processing ()
PUSH_FIELD (jexception_type, field, "handler_pc", ptr_type_node); PUSH_FIELD (jexception_type, field, "handler_pc", ptr_type_node);
PUSH_FIELD (jexception_type, field, "catch_type", class_ptr_type); PUSH_FIELD (jexception_type, field, "catch_type", class_ptr_type);
FINISH_RECORD (jexception_type); FINISH_RECORD (jexception_type);
pushdecl (build_decl (TYPE_DECL, get_identifier ("jexception"), field_type_node)); build_decl (TYPE_DECL, get_identifier ("jexception"), field_type_node);
jexception_ptr_type = build_pointer_type (jexception_type); jexception_ptr_type = build_pointer_type (jexception_type);
lineNumberEntry_type = make_node (RECORD_TYPE); lineNumberEntry_type = make_node (RECORD_TYPE);
...@@ -665,7 +663,7 @@ init_decl_processing () ...@@ -665,7 +663,7 @@ init_decl_processing ()
PUSH_FIELD (method_type_node, field, "ncode", nativecode_ptr_type_node); PUSH_FIELD (method_type_node, field, "ncode", nativecode_ptr_type_node);
FINISH_RECORD (method_type_node); FINISH_RECORD (method_type_node);
CLASS_LOADED_P (method_type_node) = 1; CLASS_LOADED_P (method_type_node) = 1;
pushdecl (build_decl (TYPE_DECL, get_identifier ("Method"), method_type_node)); build_decl (TYPE_DECL, get_identifier ("Method"), method_type_node);
t = tree_cons (NULL_TREE, class_ptr_type, t = tree_cons (NULL_TREE, class_ptr_type,
build_tree_list (NULL_TREE, int_type_node)); build_tree_list (NULL_TREE, int_type_node));
......
...@@ -1431,6 +1431,32 @@ build_invokevirtual (dtable, method) ...@@ -1431,6 +1431,32 @@ build_invokevirtual (dtable, method)
return func; return func;
} }
tree
build_invokeinterface (dtable, method_name, method_signature)
tree dtable, method_name, method_signature;
{
static tree class_ident = NULL_TREE;
tree lookup_arg;
/* We expand invokeinterface here. _Jv_LookupInterfaceMethod() will
ensure that the selected method exists, is public and not
abstract nor static. */
if (class_ident == NULL_TREE)
class_ident = get_identifier ("class");
dtable = build1 (INDIRECT_REF, dtable_type, dtable);
dtable = build (COMPONENT_REF, class_ptr_type, dtable,
lookup_field (&dtable_type, class_ident));
lookup_arg = build_tree_list (NULL_TREE, build_utf8_ref (method_signature));
lookup_arg = tree_cons (NULL_TREE, dtable,
tree_cons (NULL_TREE, build_utf8_ref (method_name),
lookup_arg));
return build (CALL_EXPR, ptr_type_node,
build_address_of (soft_lookupinterfacemethod_node),
lookup_arg, NULL_TREE);
}
/* Expand one of the invoke_* opcodes. /* Expand one of the invoke_* opcodes.
OCPODE is the specific opcode. OCPODE is the specific opcode.
METHOD_REF_INDEX is an index into the constant pool. METHOD_REF_INDEX is an index into the constant pool.
...@@ -1449,8 +1475,6 @@ expand_invoke (opcode, method_ref_index, nargs) ...@@ -1449,8 +1475,6 @@ expand_invoke (opcode, method_ref_index, nargs)
char *self_name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (self_type))); char *self_name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (self_type)));
tree call, func, method, arg_list, method_type; tree call, func, method, arg_list, method_type;
static tree class_ident = NULL_TREE;
if (! CLASS_LOADED_P (self_type)) if (! CLASS_LOADED_P (self_type))
{ {
load_class (self_type, 1); load_class (self_type, 1);
...@@ -1522,30 +1546,7 @@ expand_invoke (opcode, method_ref_index, nargs) ...@@ -1522,30 +1546,7 @@ expand_invoke (opcode, method_ref_index, nargs)
if (opcode == OPCODE_invokevirtual) if (opcode == OPCODE_invokevirtual)
func = build_invokevirtual (dtable, method); func = build_invokevirtual (dtable, method);
else else
{ func = build_invokeinterface (dtable, method_name, method_signature);
/* We expand invokeinterface here.
_Jv_LookupInterfaceMethod() will ensure that the selected
method exists, is public and not abstract nor static. */
tree lookup_arg;
if (class_ident == NULL_TREE)
class_ident = get_identifier ("class");
dtable = build1 (INDIRECT_REF, dtable_type, dtable);
dtable = build (COMPONENT_REF, class_ptr_type, dtable,
lookup_field (&dtable_type, class_ident));
lookup_arg = build_tree_list (NULL_TREE,
build_utf8_ref (method_signature));
lookup_arg = tree_cons (NULL_TREE, dtable,
tree_cons (NULL_TREE,
build_utf8_ref (method_name),
lookup_arg));
func = build (CALL_EXPR,
ptr_type_node,
build_address_of (soft_lookupinterfacemethod_node),
lookup_arg, NULL_TREE);
}
} }
func = build1 (NOP_EXPR, build_pointer_type (method_type), func); func = build1 (NOP_EXPR, build_pointer_type (method_type), func);
call = build (CALL_EXPR, TREE_TYPE (method_type), func, arg_list, NULL_TREE); call = build (CALL_EXPR, TREE_TYPE (method_type), func, arg_list, NULL_TREE);
...@@ -1615,29 +1616,10 @@ expand_java_field_op (is_static, is_putting, field_ref_index) ...@@ -1615,29 +1616,10 @@ expand_java_field_op (is_static, is_putting, field_ref_index)
&& field_type == class_ptr_type && field_type == class_ptr_type
&& strncmp (self_name, "java.lang.", 10) == 0) && strncmp (self_name, "java.lang.", 10) == 0)
{ {
char *class_name = self_name+10; tree typ = build_primtype_type_ref (self_name);
tree typ; if (typ)
if (strcmp(class_name, "Byte") == 0)
typ = byte_type_node;
else if (strcmp(class_name, "Short") == 0)
typ = short_type_node;
else if (strcmp(class_name, "Integer") == 0)
typ = int_type_node;
else if (strcmp(class_name, "Long") == 0)
typ = long_type_node;
else if (strcmp(class_name, "Float") == 0)
typ = float_type_node;
else if (strcmp(class_name, "Boolean") == 0)
typ = boolean_type_node;
else if (strcmp(class_name, "Char") == 0)
typ = char_type_node;
else if (strcmp(class_name, "Void") == 0)
typ = void_type_node;
else
typ = NULL_TREE;
if (typ != NULL_TREE)
{ {
push_value (build_class_ref (typ)); push_value (typ);
return; return;
} }
} }
...@@ -1672,6 +1654,36 @@ expand_java_field_op (is_static, is_putting, field_ref_index) ...@@ -1672,6 +1654,36 @@ expand_java_field_op (is_static, is_putting, field_ref_index)
push_value (field_ref); push_value (field_ref);
} }
tree
build_primtype_type_ref (self_name)
char *self_name;
{
char *class_name = self_name+10;
tree typ;
if (strncmp(class_name, "Byte", 4) == 0)
typ = byte_type_node;
else if (strncmp(class_name, "Short", 5) == 0)
typ = short_type_node;
else if (strncmp(class_name, "Integer", 7) == 0)
typ = int_type_node;
else if (strncmp(class_name, "Long", 4) == 0)
typ = long_type_node;
else if (strncmp(class_name, "Float", 5) == 0)
typ = float_type_node;
else if (strncmp(class_name, "Boolean", 7) == 0)
typ = boolean_type_node;
else if (strncmp(class_name, "Char", 4) == 0)
typ = char_type_node;
else if (strncmp(class_name, "Void", 4) == 0)
typ = void_type_node;
else
typ = NULL_TREE;
if (typ != NULL_TREE)
return build_class_ref (typ);
else
return NULL_TREE;
}
void void
load_type_state (label) load_type_state (label)
tree label; tree label;
......
...@@ -70,3 +70,10 @@ DEFTREECODE (THROW_EXPR, "throw", '1', 1) ...@@ -70,3 +70,10 @@ DEFTREECODE (THROW_EXPR, "throw", '1', 1)
Operand 1 is the then-value Operand 1 is the then-value
Operand 2 is the else-value. */ Operand 2 is the else-value. */
DEFTREECODE (CONDITIONAL_EXPR, "?:", 'e', 3) DEFTREECODE (CONDITIONAL_EXPR, "?:", 'e', 3)
/* instanceof operator.
Operand 0 is the expression that is getting tested
Operand 1 is the class used for the test. */
DEFTREECODE (INSTANCEOF_EXPR, "instanceof", 'e', 2)
...@@ -56,6 +56,7 @@ struct JCF; ...@@ -56,6 +56,7 @@ struct JCF;
IS_CRAFTED_STRING_BUFFER_P (in CALL_EXPR) IS_CRAFTED_STRING_BUFFER_P (in CALL_EXPR)
Usage of TYPE_LANG_FLAG_?: Usage of TYPE_LANG_FLAG_?:
0: CLASS_METHOD_CHECKED_P (in RECORD_TYPE)
1: TYPE_ARRAY_P (in RECORD_TYPE). 1: TYPE_ARRAY_P (in RECORD_TYPE).
2: CLASS_LOADED_P (in RECORD_TYPE). 2: CLASS_LOADED_P (in RECORD_TYPE).
3: CLASS_FROM_SOURCE_P (in RECORD_TYPE). 3: CLASS_FROM_SOURCE_P (in RECORD_TYPE).
...@@ -64,6 +65,9 @@ struct JCF; ...@@ -64,6 +65,9 @@ struct JCF;
6: CLASS_HAS_FINIT_P (in RECORD_TYPE) 6: CLASS_HAS_FINIT_P (in RECORD_TYPE)
Usage of DECL_LANG_FLAG_?: Usage of DECL_LANG_FLAG_?:
0: METHOD_DEPRECATED (in FUNCTION_DECL).
FIELD_DEPRECATED (in FIELD_DECL).
CLASS_DEPRECATED (in TYPE_DECL).
1: METHOD_PUBLIC (in FUNCTION_DECL). 1: METHOD_PUBLIC (in FUNCTION_DECL).
FIELD_PUBLIC (in FIELD_DECL). FIELD_PUBLIC (in FIELD_DECL).
CLASS_PUBLIC (in TYPE_DECL). CLASS_PUBLIC (in TYPE_DECL).
...@@ -85,7 +89,7 @@ struct JCF; ...@@ -85,7 +89,7 @@ struct JCF;
LABEL_CHANGED (in LABEL_DECL) LABEL_CHANGED (in LABEL_DECL)
CLASS_SUPER (in TYPE_DECL, ACC_SUPER flag) CLASS_SUPER (in TYPE_DECL, ACC_SUPER flag)
INITIALIZED_P (in FIELD_DECL, VAR_DECL, PARM_DECL) INITIALIZED_P (in FIELD_DECL, VAR_DECL, PARM_DECL)
7: DECL_CONSTRUCTOR_P (in FUNCTION_DECL) 7: DECL_CONSTRUCTOR_P (in FUNCTION_DECL).
*/ */
/* True if the class whose TYPE_BINFO this is has a superclass. /* True if the class whose TYPE_BINFO this is has a superclass.
...@@ -396,6 +400,9 @@ struct lang_identifier ...@@ -396,6 +400,9 @@ struct lang_identifier
slot_number in decl_map. */ slot_number in decl_map. */
#define DECL_LOCAL_SLOT_CHAIN(NODE) \ #define DECL_LOCAL_SLOT_CHAIN(NODE) \
(((struct lang_decl_var*)DECL_LANG_SPECIFIC(NODE))->slot_chain) (((struct lang_decl_var*)DECL_LANG_SPECIFIC(NODE))->slot_chain)
/* For a static field seen from the parser, it holds its associated
value, the one returned when the field is looked up. */
#define DECL_LOCAL_STATIC_VALUE(NODE) DECL_LOCAL_SLOT_CHAIN (NODE)
/* DECL_LANG_SPECIFIC for FUNCTION_DECLs. */ /* DECL_LANG_SPECIFIC for FUNCTION_DECLs. */
struct lang_decl struct lang_decl
...@@ -501,6 +508,7 @@ extern tree lookup_name PROTO ((tree)); ...@@ -501,6 +508,7 @@ extern tree lookup_name PROTO ((tree));
extern tree build_known_method_ref PROTO ((tree, tree, tree, tree, tree)); extern tree build_known_method_ref PROTO ((tree, tree, tree, tree, tree));
extern tree build_class_init PROTO ((tree, tree)); extern tree build_class_init PROTO ((tree, tree));
extern tree build_invokevirtual PROTO ((tree, tree)); extern tree build_invokevirtual PROTO ((tree, tree));
extern tree build_invokeinterface PROTO ((tree, tree, tree));
extern tree invoke_build_dtable PROTO ((int, tree)); extern tree invoke_build_dtable PROTO ((int, tree));
extern tree build_field_ref PROTO ((tree, tree, tree)); extern tree build_field_ref PROTO ((tree, tree, tree));
extern void pushdecl_force_head PROTO ((tree)); extern void pushdecl_force_head PROTO ((tree));
...@@ -533,6 +541,7 @@ extern int alloc_name_constant PROTO ((int, tree)); ...@@ -533,6 +541,7 @@ extern int alloc_name_constant PROTO ((int, tree));
extern void emit_register_classes PROTO (()); extern void emit_register_classes PROTO (());
extern void lang_init_source PROTO ((int)); extern void lang_init_source PROTO ((int));
extern void write_classfile PROTO ((tree)); extern void write_classfile PROTO ((tree));
extern tree build_primtype_type_ref PROTO ((char *));
/* Access flags etc for a method (a FUNCTION_DECL): */ /* Access flags etc for a method (a FUNCTION_DECL): */
...@@ -570,6 +579,13 @@ extern void write_classfile PROTO ((tree)); ...@@ -570,6 +579,13 @@ extern void write_classfile PROTO ((tree));
#define CLASS_ABSTRACT(DECL) DECL_LANG_FLAG_5 (DECL) #define CLASS_ABSTRACT(DECL) DECL_LANG_FLAG_5 (DECL)
#define CLASS_SUPER(DECL) DECL_LANG_FLAG_6 (DECL) #define CLASS_SUPER(DECL) DECL_LANG_FLAG_6 (DECL)
/* @deprecated marker flag on methods, fields and classes */
#define METHOD_DEPRECATED(DECL) DECL_LANG_FLAG_0 (DECL)
#define FIELD_DEPRECATED(DECL) DECL_LANG_FLAG_0 (DECL)
#define CLASS_DEPRECATED(DECL) DECL_LANG_FLAG_0 (DECL)
#define DECL_DEPRECATED(DECL) DECL_LANG_FLAG_0 (DECL)
/* The number of virtual methods in this class's dispatch table. /* The number of virtual methods in this class's dispatch table.
Does not include initial two dummy entries (one points to the Does not include initial two dummy entries (one points to the
Class object, and the other is for G++ -fvtable-thunks compatibility). */ Class object, and the other is for G++ -fvtable-thunks compatibility). */
...@@ -657,6 +673,9 @@ extern tree *type_map; ...@@ -657,6 +673,9 @@ extern tree *type_map;
/* FIXME this use of TREE_TYPE conflicts with something or other. */ /* FIXME this use of TREE_TYPE conflicts with something or other. */
#define TYPE_ARRAY_ELEMENT(ATYPE) TREE_TYPE(ATYPE) #define TYPE_ARRAY_ELEMENT(ATYPE) TREE_TYPE(ATYPE)
/* True if methods in class TYPE have been checked. */
#define CLASS_METHOD_CHECKED_P(TYPE) TYPE_LANG_FLAG_0 (TYPE)
/* True if class TYPE has been loaded. */ /* True if class TYPE has been loaded. */
#define CLASS_LOADED_P(TYPE) TYPE_LANG_FLAG_2 (TYPE) #define CLASS_LOADED_P(TYPE) TYPE_LANG_FLAG_2 (TYPE)
...@@ -795,13 +814,12 @@ extern tree *type_map; ...@@ -795,13 +814,12 @@ extern tree *type_map;
/* Make the current function where this macro is invoked report error /* Make the current function where this macro is invoked report error
messages and and return, if any */ messages and and return, if any */
#define java_parse_abort_on_error() \ #define java_parse_abort_on_error() \
{ \ { \
extern int java_error_count; \ extern int java_error_count; \
if (java_error_count) \ if (java_error_count) \
{ \ { \
java_report_errors (); \ java_report_errors (); \
java_pop_parser_context (0); \ return; \
return; \ } \
} \
} }
...@@ -64,15 +64,14 @@ tree main_class = NULL_TREE; ...@@ -64,15 +64,14 @@ tree main_class = NULL_TREE;
/* The FIELD_DECL for the current field. */ /* The FIELD_DECL for the current field. */
static tree current_field = NULL_TREE; static tree current_field = NULL_TREE;
/* The METHOD_DECL for the current method. */
static tree current_method = NULL_TREE; static tree current_method = NULL_TREE;
/* Declarations of some functions used here. */
static tree give_name_to_class PROTO ((JCF *jcf, int index)); static tree give_name_to_class PROTO ((JCF *jcf, int index));
void parse_zip_file_entries PROTO (());
void parse_zip_file_entries (void); void process_zip_dir PROTO (());
void process_zip_dir(); static void parse_source_file PROTO ((tree));
/* Source file compilation declarations */
static void parse_source_file ();
/* Handle "SourceFile" attribute. */ /* Handle "SourceFile" attribute. */
...@@ -506,14 +505,17 @@ int ...@@ -506,14 +505,17 @@ int
jcf_parse_source (jcf) jcf_parse_source (jcf)
JCF *jcf; JCF *jcf;
{ {
tree filename = get_identifier (input_filename); tree file;
java_parser_context_save_global ();
java_parser_context_save_global ();
java_push_parser_context ();
input_filename = current_jcf->filename; input_filename = current_jcf->filename;
file = get_identifier (input_filename);
if (!(finput = fopen (input_filename, "r"))) if (!(finput = fopen (input_filename, "r")))
fatal ("input file `%s' just disappeared - jcf_parse_source", fatal ("input file `%s' just disappeared - jcf_parse_source",
input_filename); input_filename);
parse_source_file (IS_A_COMMAND_LINE_FILENAME_P (filename)); parse_source_file (file);
java_pop_parser_context (IS_A_COMMAND_LINE_FILENAME_P (file));
java_parser_context_restore_global (); java_parser_context_restore_global ();
} }
...@@ -658,22 +660,16 @@ parse_class_file () ...@@ -658,22 +660,16 @@ parse_class_file ()
lineno = save_lineno; lineno = save_lineno;
} }
/* Parse a source file, as pointed by the current JCF. If PARSE_ONLY /* Parse a source file, as pointed by the current value of INPUT_FILENAME. */
is non zero, we're not parsing a file found on the command line and
we skip things related to code generation. */
static void static void
parse_source_file (parse_only) parse_source_file (file)
int parse_only; tree file;
{ {
int remember_for_generation;
tree filename = get_identifier (input_filename);
/* Mark the file as parsed */ /* Mark the file as parsed */
HAS_BEEN_ALREADY_PARSED_P (filename) = 1; HAS_BEEN_ALREADY_PARSED_P (file) = 1;
lang_init_source (1); /* Error msgs have no method prototypes */ lang_init_source (1); /* Error msgs have no method prototypes */
java_push_parser_context ();
java_init_lex (); /* Initialize the parser */ java_init_lex (); /* Initialize the parser */
java_parse_abort_on_error (); java_parse_abort_on_error ();
java_parse (); /* Parse and build partial tree nodes. */ java_parse (); /* Parse and build partial tree nodes. */
...@@ -682,17 +678,6 @@ parse_source_file (parse_only) ...@@ -682,17 +678,6 @@ parse_source_file (parse_only)
java_parse_abort_on_error (); java_parse_abort_on_error ();
java_check_circular_reference (); /* Check on circular references */ java_check_circular_reference (); /* Check on circular references */
java_parse_abort_on_error (); java_parse_abort_on_error ();
java_check_methods (); /* Check the methods */
java_parse_abort_on_error ();
java_layout_classes ();
java_parse_abort_on_error ();
/* If only parsing, make sure that the currently parsed file isn't
also present in the argument list. If it's the case, remember
that we should generate it. */
remember_for_generation = !parse_only
|| IS_A_COMMAND_LINE_FILENAME_P (filename);
java_pop_parser_context (remember_for_generation);
} }
int int
...@@ -775,7 +760,11 @@ yyparse () ...@@ -775,7 +760,11 @@ yyparse ()
parse_class_file (); parse_class_file ();
break; break;
case JCF_SOURCE: case JCF_SOURCE:
parse_source_file (0); /* Parse and generate */ java_push_parser_context ();
java_parser_context_save_global ();
parse_source_file (name);
java_parser_context_restore_global ();
java_pop_parser_context (1);
break; break;
} }
} }
......
...@@ -706,7 +706,6 @@ emit_iinc (var, value, state) ...@@ -706,7 +706,6 @@ emit_iinc (var, value, state)
static void static void
emit_load_or_store (var, opcode, state) emit_load_or_store (var, opcode, state)
tree var; tree var;
int opcode;
struct jcf_partial *state; struct jcf_partial *state;
{ {
tree type = TREE_TYPE (var); tree type = TREE_TYPE (var);
......
...@@ -248,7 +248,7 @@ extern int jcf_unexpected_eof PROTO ((JCF*, int)); ...@@ -248,7 +248,7 @@ extern int jcf_unexpected_eof PROTO ((JCF*, int));
/* Debug macros, for the front end */ /* Debug macros, for the front end */
extern int quiet_flag; extern int quiet_flag;
#ifdef SOURCE_FRONTEND_DEBUG #ifdef VERBOSE_SKELETON
#undef SOURCE_FRONTEND_DEBUG #undef SOURCE_FRONTEND_DEBUG
#define SOURCE_FRONTEND_DEBUG(X) \ #define SOURCE_FRONTEND_DEBUG(X) \
{if (!quiet_flag) {printf ("* "); printf X; putchar ('\n');} } {if (!quiet_flag) {printf ("* "); printf X; putchar ('\n');} }
......
...@@ -22,11 +22,14 @@ Java and all Java-based marks are trademarks or registered trademarks ...@@ -22,11 +22,14 @@ Java and all Java-based marks are trademarks or registered trademarks
of Sun Microsystems, Inc. in the United States and other countries. of Sun Microsystems, Inc. in the United States and other countries.
The Free Software Foundation is independent of Sun Microsystems, Inc. */ The Free Software Foundation is independent of Sun Microsystems, Inc. */
DEFINE_LANG_NAME ("Java")
/* This is the contribution to the `lang_options' array in gcc.c for /* This is the contribution to the `lang_options' array in gcc.c for
java. */ java. */
/* CYGNUS LOCAL - the format of this file has been changed to
allow cc1 to implement --help. nickc/--help */
DEFINE_LANG_NAME ("Java")
{ "-fbounds-check", "" }, { "-fbounds-check", "" },
{ "-fno-bounds-check", "Disable automatic array bounds checking" }, { "-fno-bounds-check", "Disable automatic array bounds checking" },
{ "-fassume-compiled", "Make is_compiled_class return 1"}, { "-fassume-compiled", "Make is_compiled_class return 1"},
......
...@@ -368,6 +368,62 @@ java_parse_end_comment () ...@@ -368,6 +368,62 @@ java_parse_end_comment ()
} }
} }
/* Parse the documentation section. Keywords must be at the beginning
of a documentation comment line (ignoring white space and any `*'
character). Parsed keyword(s): @DEPRECATED. */
static int
java_parse_doc_section (c)
unicode_t c;
{
int valid_tag = 0, seen_star;
while (JAVA_WHITE_SPACE_P (c) || (c == '*') || c == '\n')
{
switch (c)
{
case '*':
seen_star = 1;
break;
case '\n': /* ULT */
valid_tag = 1;
break;
default:
seen_star = 0;
}
c = java_get_unicode();
}
if (c == UEOF)
java_lex_error ("Comment not terminated at end of input", 0);
if (seen_star && (c == '/'))
return 1; /* Goto step1 in caller */
/* We're parsing @deprecated */
if (valid_tag && (c == '@'))
{
char tag [10];
int tag_index = 0;
while (tag_index < 10 && c != UEOF && c != ' ' && c != '\n')
{
c = java_get_unicode ();
tag [tag_index++] = c;
}
if (c == UEOF)
java_lex_error ("Comment not terminated at end of input", 0);
java_unget_unicode ();
tag [tag_index] = '\0';
if (!strcmp (tag, "deprecated"))
ctxp->deprecated = 1;
}
return 0;
}
/* This function to be used only by JAVA_ID_CHAR_P (), otherwise it /* This function to be used only by JAVA_ID_CHAR_P (), otherwise it
will return a wrong result. */ will return a wrong result. */
static int static int
...@@ -494,62 +550,8 @@ java_lex (java_lval) ...@@ -494,62 +550,8 @@ java_lex (java_lval)
{ {
if ((c = java_get_unicode ()) == '/') if ((c = java_get_unicode ()) == '/')
goto step1; /* Empy documentation comment */ goto step1; /* Empy documentation comment */
else if (java_parse_doc_section (c))
else goto step1;
/* Parsing the documentation section. We're looking
for the @depracated pseudo keyword. the @deprecated
tag must be at the beginning of a doc comment line
(ignoring white space and any * character) */
{
int valid_tag = 0, seen_star;
while (JAVA_WHITE_SPACE_P (c) || (c == '*') || c == '\n')
{
switch (c)
{
case '*':
seen_star = 1;
break;
case '\n': /* ULT */
valid_tag = 1;
break;
default:
seen_star = 0;
}
c = java_get_unicode();
}
if (c == UEOF)
java_lex_error
("Comment not terminated at end of input", 0);
if (seen_star && (c == '/'))
goto step1; /* End of documentation */
if (valid_tag && (c == '@'))
{
char deprecated [10];
int deprecated_index = 0;
for (deprecated_index = 0, c = java_get_unicode ();
deprecated_index < 10 && c != UEOF;
c = java_get_unicode ())
deprecated [deprecated_index++] = c;
if (c == UEOF)
java_lex_error
("Comment not terminated at end of input", 0);
java_unget_unicode ();
deprecated [deprecated_index] = '\0';
if (!strcmp (deprecated, "deprecated"))
{
/* Set global flag to be checked by class. FIXME */
warning ("deprecated implementation found");
}
}
}
} }
else else
java_unget_unicode (); java_unget_unicode ();
...@@ -1206,6 +1208,7 @@ java_lex (java_lval) ...@@ -1206,6 +1208,7 @@ java_lex (java_lval)
case TRY_TK: case TRY_TK:
case CATCH_TK: case CATCH_TK:
case THROW_TK: case THROW_TK:
case INSTANCEOF_TK:
BUILD_OPERATOR (kw->token); BUILD_OPERATOR (kw->token);
default: default:
......
...@@ -35,13 +35,6 @@ extern int lineno; ...@@ -35,13 +35,6 @@ extern int lineno;
/* A Unicode character, as read from the input file */ /* A Unicode character, as read from the input file */
typedef unsigned short unicode_t; typedef unsigned short unicode_t;
/* Function declaration */
static int java_lineterminator ();
static char *java_sprint_unicode ();
static void java_unicode_2_utf8 ();
static void java_lex_error ();
static void java_store_unicode ();
/* Debug macro to print-out what we match */ /* Debug macro to print-out what we match */
#ifdef JAVA_LEX_DEBUG #ifdef JAVA_LEX_DEBUG
#ifdef JAVA_LEX_DEBUG_CHAR #ifdef JAVA_LEX_DEBUG_CHAR
...@@ -511,4 +504,23 @@ static tree build_wfl_node (); ...@@ -511,4 +504,23 @@ static tree build_wfl_node ();
#define JAVA_READ_BUFFER 256 #define JAVA_READ_BUFFER 256
#define UEOF (unicode_t)0xffff #define UEOF (unicode_t)0xffff
/* Function declaration */
static int java_lineterminator PROTO ((unicode_t));
static char *java_sprint_unicode PROTO ((struct java_line *, int));
static void java_unicode_2_utf8 PROTO ((unicode_t));
static void java_lex_error PROTO ((char *, int));
static int java_is_eol PROTO ((FILE *, int));
static void java_store_unicode PROTO ((struct java_line *, unicode_t, int));
static unicode_t java_parse_escape_sequence PROTO (());
static int java_letter_or_digit_p PROTO ((unicode_t));
static int java_parse_doc_section PROTO ((unicode_t));
static void java_parse_end_comment PROTO (());
static unicode_t java_get_unicode PROTO (());
static unicode_t java_read_unicode PROTO ((int, int *));
static void java_store_unicode PROTO ((struct java_line *, unicode_t, int));
static unicode_t java_read_char PROTO (());
static void java_allocate_new_line PROTO (());
static void java_unget_unicode PROTO (());
static unicode_t java_sneak_unicode PROTO (());
#endif #endif
...@@ -70,7 +70,6 @@ void ...@@ -70,7 +70,6 @@ void
emit_unicode_mangled_name (obstack, name, len) emit_unicode_mangled_name (obstack, name, len)
struct obstack *obstack; struct obstack *obstack;
char *name; char *name;
int len;
{ {
unsigned char *ptr; unsigned char *ptr;
unsigned char *limit = (unsigned char *)name + len; unsigned char *limit = (unsigned char *)name + len;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -47,7 +47,7 @@ extern tree stabilize_reference PROTO ((tree)); ...@@ -47,7 +47,7 @@ extern tree stabilize_reference PROTO ((tree));
#define RULE( rule ) #define RULE( rule )
#endif #endif
#ifdef SOURCE_FRONTEND_DEBUG #ifdef VERBOSE_SKELETON
#undef SOURCE_FRONTEND_DEBUG #undef SOURCE_FRONTEND_DEBUG
#define SOURCE_FRONTEND_DEBUG(X) \ #define SOURCE_FRONTEND_DEBUG(X) \
{if (!quiet_flag) {printf ("* "); printf X; putchar ('\n');} } {if (!quiet_flag) {printf ("* "); printf X; putchar ('\n');} }
...@@ -182,6 +182,8 @@ extern tree stabilize_reference PROTO ((tree)); ...@@ -182,6 +182,8 @@ extern tree stabilize_reference PROTO ((tree));
|| (TREE_CODE (TYPE) == POINTER_TYPE \ || (TREE_CODE (TYPE) == POINTER_TYPE \
&& TREE_CODE (TREE_TYPE (TYPE)) == \ && TREE_CODE (TREE_TYPE (TYPE)) == \
RECORD_TYPE))) RECORD_TYPE)))
#define JNULLP_TYPE_P(TYPE) ((TYPE) && (TREE_CODE (TYPE) == POINTER_TYPE) \
&& (TYPE) == TREE_TYPE (null_pointer_node))
/* Other predicate */ /* Other predicate */
#define DECL_P(NODE) (NODE && (TREE_CODE (NODE) == PARM_DECL \ #define DECL_P(NODE) (NODE && (TREE_CODE (NODE) == PARM_DECL \
...@@ -523,6 +525,32 @@ static jdeplist *reverse_jdep_list (); ...@@ -523,6 +525,32 @@ static jdeplist *reverse_jdep_list ();
*ret_decl = NULL_TREE; \ *ret_decl = NULL_TREE; \
return error_mark_node; \ return error_mark_node; \
} }
/* Convenient macro to check. Assumes that CLASS is a CLASS_DECL. */
#define CHECK_METHODS(CLASS) \
{ \
if (CLASS_INTERFACE ((CLASS))) \
java_check_abstract_methods ((CLASS)); \
else \
java_check_regular_methods ((CLASS)); \
}
/* Using and reseting the @deprecated tag flag */
#define CHECK_DEPRECATED(DECL) \
{ \
if (ctxp->deprecated) \
DECL_DEPRECATED (DECL) = 1; \
ctxp->deprecated = 0; \
}
/* Register an impor */
#define REGISTER_IMPORT(WHOLE, NAME) \
{ \
IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P ((NAME)) = 1; \
node = build_tree_list ((WHOLE), (NAME)); \
TREE_CHAIN (node) = ctxp->import_list; \
ctxp->import_list = node; \
}
/* Parser context data structure. */ /* Parser context data structure. */
struct parser_ctxt { struct parser_ctxt {
...@@ -542,6 +570,7 @@ struct parser_ctxt { ...@@ -542,6 +570,7 @@ struct parser_ctxt {
int minus_seen; /* Integral literal overflow */ int minus_seen; /* Integral literal overflow */
int lineno; /* Current lineno */ int lineno; /* Current lineno */
int java_error_flag; /* Report error when true */ int java_error_flag; /* Report error when true */
int deprecated; /* @deprecated tag seen */
/* This section is defined only if we compile jc1 */ /* This section is defined only if we compile jc1 */
#ifndef JC1_LITE #ifndef JC1_LITE
...@@ -561,7 +590,9 @@ struct parser_ctxt { ...@@ -561,7 +590,9 @@ struct parser_ctxt {
tree incomplete_class; /* List of non-complete classes */ tree incomplete_class; /* List of non-complete classes */
tree current_parsed_class; /* Class currently parsed */ tree current_parsed_class; /* Class currently parsed */
tree current_parsed_class_un; /* Curr. parsed class unqualified name */
tree class_list; /* List of classes in a CU */ tree class_list; /* List of classes in a CU */
tree gclass_list; /* All classes seen so far. */
jdeplist *classd_list; /* Classe dependencies in a CU */ jdeplist *classd_list; /* Classe dependencies in a CU */
tree non_static_initialized; /* List of non static initialized fields */ tree non_static_initialized; /* List of non static initialized fields */
...@@ -604,9 +635,11 @@ static void check_modifiers_consistency PROTO ((int)); ...@@ -604,9 +635,11 @@ static void check_modifiers_consistency PROTO ((int));
static tree lookup_cl PROTO ((tree)); static tree lookup_cl PROTO ((tree));
static tree lookup_java_method2 PROTO ((tree, tree, int)); static tree lookup_java_method2 PROTO ((tree, tree, int));
static tree method_header PROTO ((int, tree, tree, tree)); static tree method_header PROTO ((int, tree, tree, tree));
static void fix_method_argument_names PROTO ((tree ,tree));
static tree method_declarator PROTO ((tree, tree)); static tree method_declarator PROTO ((tree, tree));
static void parse_error_context VPROTO ((tree cl, char *msg, ...)); static void parse_error_context VPROTO ((tree cl, char *msg, ...));
static void parse_warning_context VPROTO ((tree cl, char *msg, ...)); static void parse_warning_context VPROTO ((tree cl, char *msg, ...));
static void issue_warning_error_from_context PROTO ((tree, char *msg));
static tree parse_jdk1_1_error PROTO ((char *)); static tree parse_jdk1_1_error PROTO ((char *));
static void complete_class_report_errors PROTO ((jdep *)); static void complete_class_report_errors PROTO ((jdep *));
static int process_imports PROTO ((void)); static int process_imports PROTO ((void));
...@@ -614,6 +647,8 @@ static void read_import_dir PROTO ((tree)); ...@@ -614,6 +647,8 @@ static void read_import_dir PROTO ((tree));
static int find_in_imports_on_demand PROTO ((tree)); static int find_in_imports_on_demand PROTO ((tree));
static int find_in_imports PROTO ((tree)); static int find_in_imports PROTO ((tree));
static int check_pkg_class_access PROTO ((tree, tree)); static int check_pkg_class_access PROTO ((tree, tree));
static tree resolve_package PROTO ((tree, tree *));
static tree lookup_package_type PROTO ((char *, int));
static tree resolve_class PROTO ((tree, tree, tree)); static tree resolve_class PROTO ((tree, tree, tree));
static tree do_resolve_class PROTO ((tree, tree, tree)); static tree do_resolve_class PROTO ((tree, tree, tree));
static void declare_local_variables PROTO ((int, tree, tree)); static void declare_local_variables PROTO ((int, tree, tree));
...@@ -623,7 +658,7 @@ static void expand_start_java_method PROTO ((tree)); ...@@ -623,7 +658,7 @@ static void expand_start_java_method PROTO ((tree));
static tree find_name_in_single_imports PROTO ((tree)); static tree find_name_in_single_imports PROTO ((tree));
static void check_abstract_method_header PROTO ((tree)); static void check_abstract_method_header PROTO ((tree));
static tree lookup_java_interface_method2 PROTO ((tree, tree)); static tree lookup_java_interface_method2 PROTO ((tree, tree));
static tree resolve_expression_name PROTO ((tree)); static tree resolve_expression_name PROTO ((tree, tree *));
static tree maybe_create_class_interface_decl PROTO ((tree, tree, tree)); static tree maybe_create_class_interface_decl PROTO ((tree, tree, tree));
static int check_class_interface_creation PROTO ((int, int, tree, static int check_class_interface_creation PROTO ((int, int, tree,
tree, tree, tree)); tree, tree, tree));
...@@ -633,7 +668,8 @@ static int breakdown_qualified PROTO ((tree *, tree *, tree)); ...@@ -633,7 +668,8 @@ static int breakdown_qualified PROTO ((tree *, tree *, tree));
static tree resolve_and_layout PROTO ((tree, tree)); static tree resolve_and_layout PROTO ((tree, tree));
static tree resolve_no_layout PROTO ((tree, tree)); static tree resolve_no_layout PROTO ((tree, tree));
static int invocation_mode PROTO ((tree, int)); static int invocation_mode PROTO ((tree, int));
static tree find_applicable_accessible_methods_list PROTO ((tree, tree, tree)); static tree find_applicable_accessible_methods_list PROTO ((int, tree,
tree, tree));
static tree find_most_specific_methods_list PROTO ((tree)); static tree find_most_specific_methods_list PROTO ((tree));
static int argument_types_convertible PROTO ((tree, tree)); static int argument_types_convertible PROTO ((tree, tree));
static tree patch_invoke PROTO ((tree, tree, tree, int)); static tree patch_invoke PROTO ((tree, tree, tree, int));
...@@ -654,12 +690,14 @@ static tree build_method_invocation PROTO ((tree, tree)); ...@@ -654,12 +690,14 @@ static tree build_method_invocation PROTO ((tree, tree));
static tree build_new_invocation PROTO ((tree, tree)); static tree build_new_invocation PROTO ((tree, tree));
static tree build_assignment PROTO ((int, int, tree, tree)); static tree build_assignment PROTO ((int, int, tree, tree));
static tree build_binop PROTO ((enum tree_code, int, tree, tree)); static tree build_binop PROTO ((enum tree_code, int, tree, tree));
static int check_final_assignment PROTO ((tree ,tree));
static tree patch_assignment PROTO ((tree, tree, tree )); static tree patch_assignment PROTO ((tree, tree, tree ));
static tree patch_binop PROTO ((tree, tree, tree)); static tree patch_binop PROTO ((tree, tree, tree));
static tree build_unaryop PROTO ((int, int, tree)); static tree build_unaryop PROTO ((int, int, tree));
static tree build_incdec PROTO ((int, int, tree, int)); static tree build_incdec PROTO ((int, int, tree, int));
static tree patch_unaryop PROTO ((tree, tree)); static tree patch_unaryop PROTO ((tree, tree));
static tree build_cast PROTO ((int, tree, tree)); static tree build_cast PROTO ((int, tree, tree));
static tree build_null_of_type PROTO ((tree));
static tree patch_cast PROTO ((tree, tree)); static tree patch_cast PROTO ((tree, tree));
static int valid_ref_assignconv_cast_p PROTO ((tree, tree, int)); static int valid_ref_assignconv_cast_p PROTO ((tree, tree, int));
static int valid_builtin_assignconv_identity_widening_p PROTO ((tree, tree)); static int valid_builtin_assignconv_identity_widening_p PROTO ((tree, tree));
...@@ -689,6 +727,7 @@ static tree maybe_access_field PROTO ((tree, tree, tree)); ...@@ -689,6 +727,7 @@ static tree maybe_access_field PROTO ((tree, tree, tree));
static int complete_function_arguments PROTO ((tree)); static int complete_function_arguments PROTO ((tree));
static int check_for_static_method_reference PROTO ((tree, tree, tree, tree, tree)); static int check_for_static_method_reference PROTO ((tree, tree, tree, tree, tree));
static int not_accessible_p PROTO ((tree, tree, int)); static int not_accessible_p PROTO ((tree, tree, int));
static void check_deprecation PROTO ((tree, tree));
static int class_in_current_package PROTO ((tree)); static int class_in_current_package PROTO ((tree));
static tree build_if_else_statement PROTO ((int, tree, tree, tree)); static tree build_if_else_statement PROTO ((int, tree, tree, tree));
static tree patch_if_else_statement PROTO ((tree)); static tree patch_if_else_statement PROTO ((tree));
...@@ -735,6 +774,11 @@ static tree create_artificial_method PROTO ((tree, int, tree, tree, tree)); ...@@ -735,6 +774,11 @@ static tree create_artificial_method PROTO ((tree, int, tree, tree, tree));
static void start_artificial_method_body PROTO ((tree)); static void start_artificial_method_body PROTO ((tree));
static void end_artificial_method_body PROTO ((tree)); static void end_artificial_method_body PROTO ((tree));
static tree generate_field_initialization_code PROTO ((tree)); static tree generate_field_initialization_code PROTO ((tree));
static int check_method_redefinition PROTO ((tree, tree));
static int reset_method_name PROTO ((tree));
static void java_check_regular_methods PROTO ((tree));
static void java_check_abstract_methods PROTO ((tree));
static tree maybe_build_primttype_type_ref PROTO ((tree, tree));
void safe_layout_class PROTO ((tree)); void safe_layout_class PROTO ((tree));
void java_complete_class PROTO ((void)); void java_complete_class PROTO ((void));
......
...@@ -52,10 +52,6 @@ set_local_type (slot, type) ...@@ -52,10 +52,6 @@ set_local_type (slot, type)
type_map[++slot] = void_type_node; type_map[++slot] = void_type_node;
} }
extern tree convert_to_integer (tree type, tree expr);
extern tree convert_to_real (tree type, tree expr);
extern tree convert_to_pointer (tree type, tree expr);
/* Create an expression whose value is that of EXPR, /* Create an expression whose value is that of EXPR,
converted to type TYPE. The TREE_TYPE of the value converted to type TYPE. The TREE_TYPE of the value
is always TYPE. This function implements all reasonable is always TYPE. This function implements all reasonable
...@@ -663,7 +659,7 @@ lookup_argument_method (clas, method_name, method_signature) ...@@ -663,7 +659,7 @@ lookup_argument_method (clas, method_name, method_signature)
tree method_sig = build_java_argument_signature (TREE_TYPE (method)); tree method_sig = build_java_argument_signature (TREE_TYPE (method));
tree name = DECL_NAME (method); tree name = DECL_NAME (method);
if ((TREE_CODE (name) == EXPR_WITH_FILE_LOCATION ? if ((TREE_CODE (name) == EXPR_WITH_FILE_LOCATION ?
EXPR_WFL_NODE (DECL_NAME (method)) : name) == method_name EXPR_WFL_NODE (name) : name) == method_name
&& method_sig == method_signature) && method_sig == method_signature)
return method; return method;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment