Commit Graph

6 Commits

Author SHA1 Message Date
Alexandre Petit-Bianco
5e942c5066 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
1998-11-10 10:04:25 -08:00
Alexandre Petit-Bianco
22eed1e678 class.c (layout_class): Don't mangle <finit>, produce __finit<class> instead.
Wed Oct 28 08:03:31 1998  Alexandre Petit-Bianco  <apbianco@cygnus.com>
	* class.c (layout_class): Don't mangle <finit>, produce
 	__finit<class> instead. Don't verify artificial methods.
	* decl.c (finit_identifier_node): New declared global.
	(init_decl_processing): finit_identifier_node initialized.
	* java-tree.def (CONDITIONAL_EXPR): New Java tree code.
	* java-tree.h (finit_identifier_node): Declared as extern.
	(struct lang_decl): New field called_constructor.
	(DECL_CONSTRUCTOR_CALLS): Access macro to called_constructor.
	(CLASS_HAS_FINIT_P): New macro.
	(CALL_CONSTRUCTOR_P): Leading comment changed. Macro now checks
 	explicit constructor invocation.
	(CALL_EXPLICIT_CONSTRUCTOR_P, CALL_THIS_CONSTRUCTOR_P,
 	CALL_SUPER_CONSTRUCTOR_P): New macros.
	(write_classfile): Added prototype.
	* jcf-parse.c (jcf_parse_source): Parse and remember for
 	generation if the file was seen on the command line.
	(parse_source_file): Don't write the class file here.
	(yyparse): Loop on files rewritten. Set current_jcf.
	(parse_zip_file_entries): Parse class file only if it was found.
	* lang.c (init_parse): Don't open command line provided filename
 	here.
	(lang_parse): Don't set main_jcf anymore.
	* parse.h (ABSTRAC_CHECK): Capitalized arguments.
	(JCONSTRUCTOR_CHECK): New macro.
	(JBSC_TYPE_P): New macro.
	(IN_TRY_BLOCK_P, EXCEPTIONS_P): Fixed leading comment.
	(COMPLETE_CHECK_OP_2): New macro.
	(struct parse_ctxt): New field explicit_constructor_p.
	(check_class_interface_creation): Fixed prototype indentation.
	(patch_method_invocation_stmt): Prototype reflects added argument.
	(patch_invoke): Likewise.
	(complete_method_declaration, build_super_invocation,
 	verify_constructor_circularity,
 	build_this_super_qualified_invocation, get_printable_method_name,
 	patch_conditional_expr, maybe_generate_finit, fix_constructors,
 	verify_constructor_super, create_artificial_method,
 	start_artificial_method_body, end_artificial_method_body,
 	generate_field_initialization_code): New function prototypes.
	* parse.y: Fixed leading comment
	(constructor_header:, constructor_body:, block_end:): Rules tagged
 	<node>.
	(type_declaration:): Call maybe_generate_finit.
	(method_declaration:): Action for method_body: placed in new
 	function complete_method_declaration, called here.
	(constructor_declaration:): Defined actions. Removed leading
 	FIXME.
	(constructor_header:): New rule with action.
	(constructor_body:): Rule rewritten using block_begin: and
 	block_end:. Defined actions.
	(constructor_declarator:, explicit_constructor_invocation:):
 	Defined actions.
	(block:): Use new rules block_begin: block_end:.
	(block_begin:, block_end:): New rules and actions.
	(block_statements:): Fixed error message for explicit
 	constructors.
	(method_invocation:): Call build_this_super_qualified_invocation
 	if primary is `this' or `super' was seen.
	(conditional_expression:): Action defined.
	(extra_ctxp_pushed_p): New static global flag.
	(java_parser_context_save_global): Create parser context if
 	necessary. Use extra_ctxp_pushed_p to remember it.
	(java_parser_context_restore_global): Pop extra parser context if
 	one exists.
	(build_array_from_name): Array on primitive types are marked
 	loaded.
	(register_fields): Restore new name in field initializer
 	expression if type was altered. Non static fields initialized upon
 	declaration marked initialized.
	(maybe_generate_finit): New function.
	(maybe_generate_clinit): Use create_artificial_method,
 	start_artificial_method_body, end_artificial_method_body. Generate
 	debug info for enclosed initialization statements.
	(method_header): Fixed leading comment. Check constructor
 	flags. Detect constructor declarations and set DECL_CONSTRUCTOR_P
 	accordingly.
	(complete_method_declaration, constructor_circularity_msg,
 	verify_constructor_circularity): New functions.
	(get_printable_method_name): New function.
	(check_method_redefinition): Don't rename <finit> methods. Fix
 	declared constructor names. Error message for
 	constructors modified.
	(java_check_regular_methods): Local variable seen_constructor
 	renamed saw_constructor. Skip verification on constructors. Create
 	default constructor with create_artificial_method.
	(java_check_methods): Removed unnecessary empty line.
	(create_artificial_method, start_artificial_method_body,
 	end_artificial_method_body): New functions.
	(java_layout_classes): Changed leading comment. Reverse fields
 	list if necessary. Always layout java.lang.Object if being
 	defined.
	(java_complete_expand_methods): Verify constructor circularity.
	(java_complete_expand_method): Call fix_constructor on
 	constructors.  Local variable no_ac_found removed. Restore
 	bindings if method body expansion failed.
	(fix_constructors, verify_constructor_super,
 	generate_field_initialization_code): New function.
	(java_expand_classes): Fixed leading comment. Write class file
 	here.
	(resolve_expression_name): Check for illegal instance variable
 	usage within the argument scope of an explicit constructor
 	invocation.
	(resolve_qualified_expression_name): Pass extra from_super flag
 	when invoking patch_method_invocation_stmt. New case for
 	conditional expression when used as a primary. Check for error
 	when acquiring super.
	(patch_method_invocation_stmt): Added extra argument super. New
 	local variable is_static_flag. Set class_to_search according to
 	the nature of the constructor invocation. Don't add `this'
 	argument when expanding NEW_CLASS_EXPR. Check for illegal method
 	invocation within the argument scope of explicit constructor
 	invocation. Set is_static according to is_static_flag. Provide
 	extra `super' argument to patch_invoke invocation.
	(patch_invoke): New argument from_super. Loop on arguments
 	indentation fixed. Pass from_super to invocation_mode. New switch
 	case INVOKE_SUPER. Fixed error message in switch default case.
  	Don't use CALL_CONSTRUCTOR_P but rather a test on the tree node
 	value.
	(invocation_mode): Return INVOKE_SUPER mode when appropriate.
	(lookup_method_invoke): Fixed prototypes in candidates list. Error
 	message takes constructors into account.
	(find_applicable_accessible_methods_list): Fixed indentation.
	(qualify_ambiguous_name): Take explicit constructor invocation
 	into account. Deal with a conditional expression as a primary to
 	a method call.
	(java_complete_tree): Added local wfl_op3. New CONDITIONAL_EXPR
 	case. Added extra argument to patch_method_invocation_stmt.
 	Register calls made to explicit constructor `this'. Don't call
 	save_expr in ARRAY_REF case when emitting class files. Check for
 	illegal use of this when expanding explicit constructor invocation
 	arguments.
	(complete_function_arguments): Set and reset parser context
 	explicit_constructor_p field value when appropriate.
	(build_super_invocation, build_this_super_qualified_invocation):
 	New functions.
	(patch_assignment): Fixed typo.
	(patch_unaryop): Check on final fields occurs only when a decl
 	exits.
	(patch_return): Take constructors into account.
	(patch_conditional_expr): New function.
	* typeck.c (build_java_signature): Removed unnecessary empty line.
This patch implements the conditional operator, fixes the super
invokation mode, implements most of what is required for constructors
and changes the way source files are handled by the front-end.

From-SVN: r23403
1998-10-28 05:06:17 -08:00
Alexandre Petit-Bianco
b9f7e36ca1 decl.c (runtime_exception_type_node, [...]): New global variables.
Tue Oct 13 03:50:28 1998  Alexandre Petit-Bianco  <apbianco@cygnus.com>
	* decl.c (runtime_exception_type_node, error_exception_type_node):
 	New global variables.
	(init_decl_processing): Initialized.
	* expr.c (java_lang_expand_expr): Set caught exception type to
 	null if catch handler argument doesn't exit.
	* java-tree.def (SYNCHRONIZED_EXPR, THROW_EXPR): New Java specific
 	tree codes.
	* java-tree.h (runtime_exception_type_node,
 	error_exception_type_node): Global variables declared.
	(DECL_FUNCTION_THROWS): New macro.
	(DECL_FUNCTION_BODY): Modified comment.
	(DECL_SPECIFIC_COUNT): Likewise.
	(struct lang_decl): New field throws_list.
	(IS_UNCHECKED_EXPRESSION_P): New macro.
	* lex.c (java_lex): Generate location information for THROW_TK.
	* parse.h (PUSH_EXCEPTIONS, POP_EXCEPTIONS, IN_TRY_BLOCK_P,
 	EXCEPTIONS_P): New macros.
	(enum jdep_code): New value JDEP_EXCEPTION.
	(BUILD_MONITOR_ENTER, BUILD_MONITOR_EXIT,
 	BUILD_ASSIGN_EXCEPTION_INFO, BUILD_THROW, SET_WFL_OPERATOR,
 	PATCH_METHOD_RETURN_ERROR): New macros.
	(patch_method_invocation_stmt): Added new argument to prototype.
	(patch_synchronized_statement, patch_throw_statement,
 	check_thrown_exceptions, check_thrown_exceptions_do,
 	purge_unchecked_exceptions, check_throws_clauses): New function
 	prototypes.
	* parse.y Fixed typo in keyword section.
	(throw:): Rule tagged <node>.
	(THROW_TK): Keyword tagged <operator>.
	(method_header:): Last argument to call to method_header passed
 	from throws: rule.
	(throws:, class_type_list:, throw_statement:,
 	synchronized_statement:, synchronized:): Defined actions.
	(method_header): New local variable current. Register exceptions
 	from throws clause.
	(java_complete_tree): Complete and verify exceptions from throws
 	clause.
	(complete_class_report_errors): Error message on exceptions not
 	found
	(java_check_regular_methods): Fixed typo. Shortcut on private
 	overriding methods. Changed error message on method
 	redefinition. Check for throws clause compatibility.
	(check_throws_clauses): New function.
	(java_check_abstract_methods): Use DECL_NAME for wfl or current
 	method. Changed error message on method redefinition.
	(currently_caught_type_list): New static variable.
	(java_complete_expand_methods): Purge unchecked exceptions from
 	throws clause list. Call PUSH_EXCEPTIONS before walk and
 	POP_EXCEPTIONS after.
	(resolve_qualified_expression_name): Pass new argument as NULL to
 	patch_method_invocation_stmt.
	(patch_method_invocation_stmt): New argument ref_decl. Invoke
 	PATCH_METHOD_RETURN_ERROR when returning with error. Reverse
 	argument list when appropriate. Use new argument if non null to
 	store selected method decl.
	(patch_invoke): Convert if necessary args of builtin types before
 	forming CALL_EXPR. Argument list no longer reversed here.
	(invocation_mode): Treat final methods as static methods.
	(java_complete_tree): New cases for THROW_EXPR: and
 	SYNCHRONIZED_EXPR:. Check thrown exceptions when completing
 	function call.
	(complete_function_arguments): No more RECORD_TYPE
 	conversion. Function parameter nodes no longer saved.
	(valid_ref_assignconv_cast_p): Avoid handling null type.
	(patch_binop): Fixed null constant reference handling.
	(build_try_statement): Use BUILD_ASSIGN_EXCEPTION_INFO and
 	BUILD_THROW macros.
	(patch_try_statement): Fixed comments. Record caught types in
 	list, push the list, expand try block and pop the list.
	(patch_synchronized_statement, patch_throw_statement,
 	check_thrown_exceptions, check_thrown_exceptions_do,
 	purge_unchecked_exceptions): New functions.
	* typeck.c (lookup_argument_method): Allow WFL in place of method
 	DECL_NAME during method definition check
Implements the `synchronized' statement, the `throw' statements and
the `throws' clause. Fixes method invocation bugs.

From-SVN: r23087
1998-10-14 08:11:04 -07:00
Jeff Law
f096ce6675 java-tree.def: Add missing newline at EOF.
8
        * java-tree.def: Add missing newline at EOF.

From-SVN: r23064
1998-10-13 16:35:34 -06:00
Per Bothner
8376a32eb1
Merge from Cygnus internal source tree.

From-SVN: r23024
1998-10-12 05:43:52 -07:00
Anthony Green
e04a16fbee Initial revision
From-SVN: r22299
1998-09-06 15:36:06 +00:00