From 12cfb4fc729b05891d1c811787132bf112e0cb5f Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Tue, 1 Jan 2002 01:42:15 +0000 Subject: [PATCH] parse.y (dump_java_tree): New function. * parse.y (dump_java_tree): New function. (source_end_java_method): Call it. (end_class_declaration): Likewise. * lang.c (java_decode_option): Call dump_switch_p. From-SVN: r48439 --- gcc/java/ChangeLog | 7 +++++++ gcc/java/lang.c | 6 ++++-- gcc/java/parse.y | 26 ++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 74bffb6e6ac..e3ba451ad4a 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,10 @@ +2001-12-31 Tom Tromey + + * parse.y (dump_java_tree): New function. + (source_end_java_method): Call it. + (end_class_declaration): Likewise. + * lang.c (java_decode_option): Call dump_switch_p. + 2001-12-28 Tom Tromey * gen-table.pl: Don't process characters after \uffff. Added diff --git a/gcc/java/lang.c b/gcc/java/lang.c index 0486abd08f0..0f62594baa5 100644 --- a/gcc/java/lang.c +++ b/gcc/java/lang.c @@ -340,8 +340,10 @@ java_decode_option (argc, argv) P's value is the option sans `-f'. Search for it in the table of options. */ p += 2; - return process_option_with_no (p, lang_f_options, - ARRAY_SIZE (lang_f_options)); + if (process_option_with_no (p, lang_f_options, + ARRAY_SIZE (lang_f_options))) + return 1; + return dump_switch_p (p); } if (strcmp (p, "-Wall") == 0) diff --git a/gcc/java/parse.y b/gcc/java/parse.y index acf00d9f8d5..e1981431fd5 100644 --- a/gcc/java/parse.y +++ b/gcc/java/parse.y @@ -108,6 +108,7 @@ static tree resolve_package PARAMS ((tree, tree *)); static tree lookup_package_type PARAMS ((const char *, int)); static tree resolve_class PARAMS ((tree, tree, tree, tree)); static void declare_local_variables PARAMS ((int, tree, tree)); +static void dump_java_tree PARAMS ((enum tree_dump_index, tree)); static void source_start_java_method PARAMS ((tree)); static void source_end_java_method PARAMS ((void)); static tree find_name_in_single_imports PARAMS ((tree)); @@ -4060,6 +4061,9 @@ end_class_declaration (resume) popped by a resume. */ int no_error_occurred = ctxp->next && GET_CPC () != error_mark_node; + if (GET_CPC () != error_mark_node) + dump_java_tree (TDI_class, GET_CPC ()); + java_parser_context_pop_initialized_field (); POP_CPC (); if (resume && no_error_occurred) @@ -7391,6 +7395,24 @@ end_artificial_method_body (mdecl) exit_block (); } +/* Dump a tree of some kind. This is a convenience wrapper for the + dump_* functions in tree-dump.c. */ +static void +dump_java_tree (phase, t) + enum tree_dump_index phase; + tree t; +{ + FILE *stream; + int flags; + + stream = dump_begin (phase, &flags); + if (stream) + { + dump_node (t, flags, stream); + dump_end (phase, stream); + } +} + /* Terminate a function and expand its body. */ static void @@ -7410,6 +7432,10 @@ source_end_java_method () if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)) == empty_stmt_node) BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)) = NULL_TREE; + /* We've generated all the trees for this function, and it has been + patched. Dump it to a file if the user requested it. */ + dump_java_tree (TDI_original, fndecl); + /* Generate function's code */ if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)) && ! flag_emit_class_files -- 2.30.2