This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[gcjx] Patch: FYI: set function_end_locus
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: 12 Feb 2005 20:43:14 -0700
- Subject: [gcjx] Patch: FYI: set function_end_locus
- Reply-to: tromey at redhat dot com
I'm checking this in on the gcjx branch.
This adds special support so we can set the function_end_locus on a
generated tree. When parsing java sources we also keep track of the
end of the method to make this more correct.
Tom
#
# patch "gcc/gcc/java/ChangeLog"
# from [304655905418a1203ceb963b4cb711419e42c142]
# to [495b71ce4576d47fdced3f3413e4eb4321482883]
#
# patch "gcc/gcc/java/glue.hh"
# from [b2b7c41c35d83ac3b139910aefad0192daece6ae]
# to [4cce664ffff6beebbb4627f5ee938bb479719ddc]
#
# patch "gcc/gcc/java/treegen.cc"
# from [0163af64327e0e1bf0d7aeb3d63ccc4155e71696]
# to [b4113fa40fa42c72e3a22052cdcdab02cf173eae]
#
# patch "gcc/gcjx/ChangeLog"
# from [9434ac3319d0fe365086c15d45f64d87e1ec4f69]
# to [d7e70152cd5994bd311a70767589c147bc65c97e]
#
# patch "gcc/gcjx/bytecode/classreader.cc"
# from [9010eee1ffda8bb0377d9adb1f59b96cfc1fb5fa]
# to [033bb9dae8edaa9dfee45d9724a45767b613064f]
#
# patch "gcc/gcjx/model/method.cc"
# from [c86363febe6f86d6e6a3b011d93b4479331fffff]
# to [104686017af1f1f32194673b9568410a64d82bf3]
#
# patch "gcc/gcjx/model/method.hh"
# from [473cc928f32555b1ac184ae29e9c9b746b1df674]
# to [c2fd982159d5c8d24b0dabc1ad55318b4eb92ea7]
#
# patch "gcc/gcjx/source/parse.cc"
# from [c5eeaa1223c5014e016a7ecc33c8e9e7ef7a909c]
# to [cba6e8862b261d7efce1bc37b8ec63e7ce6bdb33]
#
--- gcc/gcc/java/ChangeLog
+++ gcc/gcc/java/ChangeLog
@@ -1,3 +1,9 @@
+2005-02-08 Tom Tromey <tromey@redhat.com>
+
+ * glue.hh: Include function.h.
+ * treegen.cc (generate): Call allocate_struct_function. Set
+ function_end_locus.
+
2005-02-07 Tom Tromey <tromey@redhat.com>
* glue.hh: Include tree-dump.h.
--- gcc/gcc/java/glue.hh
+++ gcc/gcc/java/glue.hh
@@ -73,6 +73,7 @@
// tree-iterator.h?
#include "tree-gimple.h"
#include "tree-dump.h"
+#include "function.h"
}
// gcc's system.h defines these unconditionally, but they make life
--- gcc/gcc/java/treegen.cc
+++ gcc/gcc/java/treegen.cc
@@ -59,6 +59,16 @@
tree_generator gen (builtins, wrapper);
tree method = gen.generate ((*i).get ());
+ current_function_decl = method;
+ allocate_struct_function (method);
+
+ location end_loc = (*i)->get_method_end ();
+ // FIXME: most likely bogus.
+ location_t gcc_loc;
+ LOCATION_FILE (gcc_loc) = end_loc.get_file ();
+ LOCATION_LINE (gcc_loc) = end_loc.get_line ();
+ cfun->function_end_locus = gcc_loc;
+
dump_function (TDI_original, method);
gimplify_function_tree (method);
dump_function (TDI_generic, method);
--- gcc/gcjx/ChangeLog
+++ gcc/gcjx/ChangeLog
@@ -1,8 +1,14 @@
-2005-02-06 Tom Tromey <tromey@redhat.com>
+2005-02-08 Tom Tromey <tromey@redhat.com>
- * unify.cc: New file.
- * unify.hh: New file.
+ * model/method.cc (model_method): Updated.
+ * source/parse.cc (any_method_declarator): Call set_method_end.
+ * model/method.hh (model_method::method_end): New field.
+ (model_method::set_method_end): New method.
+ (model_method::get_method_end): Likewise.
+ (model_method): Updated.
+2005-02-06 Tom Tromey <tromey@redhat.com>
+
* bytecode/generate.cc (write): Don't print note about
verification.
* model/bytecode.cc (resolve): Verify the method.
--- gcc/gcjx/bytecode/classreader.cc
+++ gcc/gcjx/bytecode/classreader.cc
@@ -750,6 +750,7 @@
current_method->set_modifiers (flags);
if ((flags & ACC_VARARGS) != 0)
current_method->set_varargs ();
+ // FIXME: call set_method_end here? Or ... ?
}
current_exceptions.clear ();
--- gcc/gcjx/model/method.cc
+++ gcc/gcjx/model/method.cc
@@ -43,7 +43,8 @@
IDeprecatable (other),
IAnnotatable (other),
IModifiable (other),
- IMember (enclosing)
+ IMember (enclosing),
+ method_end (other->method_end)
{
set_name (other->name);
--- gcc/gcjx/model/method.hh
+++ gcc/gcjx/model/method.hh
@@ -1,6 +1,6 @@
// Represent a method.
-// Copyright (C) 2004 Free Software Foundation, Inc.
+// Copyright (C) 2004, 2005 Free Software Foundation, Inc.
//
// This file is part of GCC.
//
@@ -77,8 +77,13 @@
// Meaningless for static methods and constructors.
bool overrides;
+ // True if this is an instance initializer method, aka 'finit$'.
bool is_instance_initializer;
+ // We keep track of the end of the method as well as the beginning;
+ // this is used by GCC for debugging information.
+ location method_end;
+
void massage_modifiers (const ref_modifier_list &);
bool return_type_substitutable_p (model_type *, model_type *) const;
@@ -98,7 +103,9 @@
varargs (false),
used (false),
overrides (false),
- is_instance_initializer (false)
+ is_instance_initializer (false),
+ // By default we set the end location to the start location.
+ method_end (w)
{
}
@@ -326,6 +333,16 @@
std::string get_signature ();
void check_definite_assignment ();
+
+ void set_method_end (const location &w)
+ {
+ method_end = w;
+ }
+
+ location get_method_end () const
+ {
+ return method_end;
+ }
};
const format &operator% (const format &, model_method *);
--- gcc/gcjx/source/parse.cc
+++ gcc/gcjx/source/parse.cc
@@ -2545,6 +2545,7 @@
result->set_body (constructor_body ());
else
result->set_body (method_body ());
+ result->set_method_end (peek ());
}
else if (t == TOKEN_SEMI)
assume (TOKEN_SEMI);