This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gcjx] Add -fdump-tree for dumping AST


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

  The attached patch is my attempt to add an "-fdump-tree" option
to the standalone compiler that uses the pretty-printer to
dump the AST of a file after compilation. The actual dumping
happens after semantic analysis in compiler::do_analyze_unit().

If nothing, this would help compiler newbies like me to
understand what AST GCJX builds from a given source file.
It might perhaps come handy in debugging the compiler too.

Note that even after this patch the compiler doesn't
seem to output anything when -fdump-tree is specified.
This is simply because pretty_printer::visit_unit_source()
is unimplemented as of now and I would implement it real
soon now.

Does this look acceptable?

Thanks,
Ranjit.

- --
Ranjit Mathew       Email: rmathew AT gmail DOT com

Bangalore, INDIA.     Web: http://ranjitmathew.hostingzero.com/




-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDTV5AYb1hx2wRS48RAnjdAJ9UyDXtzlFmzzoASZEbKgIIlyWC1gCeNb04
P4MJX+SyFAEv7BJc1RbYG+U=
=xTr6
-----END PGP SIGNATURE-----
Index: ChangeLog
from  Ranjit Mathew  <rmathew@gcc.gnu.org>

	Add a new -fdump-tree flag for printing out the AST.
	* compiler.hh (compiler::dump_tree): New compiler flag.
	* compiler.cc (compiler::dump_tree): Initialize to false.
	(compiler::do_analyze_unit): Dump AST at the end of semantic
	analysis, if requested.
	* main.cc (features): Add "dump-tree".

Index: compiler.hh
===================================================================
--- compiler.hh	2005-10-13 00:01:45.000000000 +0530
+++ compiler.hh	2005-10-13 00:02:01.000000000 +0530
@@ -291,6 +291,7 @@ public:
   compiler_flag pedantic;
   compiler_flag warnings_are_errors;
   compiler_flag dump_methods;
+  compiler_flag dump_tree;
 
   // These control whether a certain feature is recognized in the
   // source.
Index: compiler.cc
===================================================================
--- compiler.cc	2005-10-13 00:02:36.000000000 +0530
+++ compiler.cc	2005-10-13 00:20:15.000000000 +0530
@@ -24,6 +24,7 @@
 #include "bytecode/bytegen.hh"
 #include "reader/reader.hh"
 #include "buffer.hh"
+#include "dump.hh"
 
 compiler::compiler (const std::string &name)
   : work_monitor (),
@@ -130,6 +131,7 @@ compiler::compiler (const std::string &n
     pedantic (false),
     warnings_are_errors (false),
     dump_methods (false),
+    dump_tree (false),
     feature_assert (true),
     feature_enum (true),
     feature_static_import (true),
@@ -650,4 +652,8 @@ compiler::do_analyze_unit (model_unit *u
     }
 
   unit->check_imports ();
+
+  // Dump the AST to stdout now if it was requested.
+  if (dump_tree ())
+    ::dump_tree (unit);
 }
Index: main.cc
===================================================================
--- main.cc	2005-10-13 00:00:29.000000000 +0530
+++ main.cc	2005-10-13 00:16:13.000000000 +0530
@@ -59,6 +59,8 @@ static flag_and_name features[] =
     "verify bytecode after creating it" },
   { "dump-methods", &compiler::dump_methods,
     "print method bodies to stdout (for debugging)" },
+  { "dump-tree", &compiler::dump_tree,
+    "print abstract syntax tree to stdout (for debugging)" },
   { NULL, NULL, NULL }
 };
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]