This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

PATCH for partial --enable-mapped-location in gcc/java


I checked this into mainline.  This is not useful in itself, but I
wanted to get these out of the way before the more interesting patch
(including the lexer rewrite), which will follow today or tomorrow.
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/

2004-09-29  Per Bothner  <per@bothner.com>

	* java-tree.h:  Redefine some macros and add soem declaration
	to handle the USE_MAPPED_LOCATION case.
	* parse.h (EXPR_WFL_QUALIFICATION):  Use operand 1, not 2.
	* java-tree.h (EXPR_WFL_FILENAME_NODE):  Use operand 2, not 1.
	* java-tree.def (EXPR_WITH_FILE_LOCATION): Only need two operands in
	USE_MAPPED_LOCATION case, since EXPR_WFL_FILENAME_NODE is gone.

	* check-init.c (check_init): Handle USE_MAPPED_LOCATION case.
	* decl.c (finish_method, java_add_stmt): Likewise.
	* java-gimplify.c (java-gimplify.c):  Likewise.
	* jcf-write.c (generate_bytecode_insns):  Likewise.
	* lang.c (java_post_options): Likewise - call linemap_add.

Index: check-init.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/check-init.c,v
retrieving revision 1.57
diff -u -p -r1.57 check-init.c
--- check-init.c	29 May 2004 05:11:41 -0000	1.57
+++ check-init.c	30 Sep 2004 01:29:12 -0000
@@ -879,8 +879,12 @@ check_init (tree exp, words before)
 	if (IS_EMPTY_STMT (body))
 	  break;
 	wfl = exp;
+#ifdef USE_MAPPED_LOCATION
+	input_location = EXPR_LOCATION (exp);
+#else
 	input_filename = EXPR_WFL_FILENAME (exp);
 	input_line = EXPR_WFL_LINENO (exp);
+#endif
 	check_init (body, before);
 	input_location = saved_location;
 	wfl = saved_wfl;
Index: decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/decl.c,v
retrieving revision 1.198
diff -u -p -r1.198 decl.c
--- decl.c	29 Sep 2004 14:13:17 -0000	1.198
+++ decl.c	30 Sep 2004 01:29:13 -0000
@@ -1954,8 +1954,12 @@ finish_method (tree fndecl)
     cfun = DECL_STRUCT_FUNCTION (fndecl);
   else
     allocate_struct_function (fndecl);
+#ifdef USE_MAPPED_LOCATION
+  cfun->function_end_locus = DECL_FUNCTION_LAST_LINE (fndecl);
+#else
   cfun->function_end_locus.file = DECL_SOURCE_FILE (fndecl);
   cfun->function_end_locus.line = DECL_FUNCTION_LAST_LINE (fndecl);
+#endif
 
   /* Defer inlining and expansion to the cgraph optimizers.  */
   cgraph_finalize_function (fndecl, false);
@@ -2023,7 +2027,7 @@ tree
 java_add_stmt (tree stmt)
 {
   if (input_filename)
-    annotate_with_locus (stmt, input_location);
+    SET_EXPR_LOCATION (stmt, input_location);
   
   return current_binding_level->stmts 
     = add_stmt_to_compound (current_binding_level->stmts, 
Index: java-gimplify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/java-gimplify.c,v
retrieving revision 1.15
diff -u -p -r1.15 java-gimplify.c
--- java-gimplify.c	23 Sep 2004 16:25:37 -0000	1.15
+++ java-gimplify.c	30 Sep 2004 01:29:13 -0000
@@ -69,10 +69,14 @@ java_gimplify_expr (tree *expr_p, tree *
       break;
 
     case EXPR_WITH_FILE_LOCATION:
+#ifdef USE_MAPPED_LOCATION
+      input_location = EXPR_LOCATION (*expr_p);
+#else
       input_location.file = EXPR_WFL_FILENAME (*expr_p);
       input_location.line = EXPR_WFL_LINENO (*expr_p);
+#endif
       *expr_p = EXPR_WFL_NODE (*expr_p);
-      annotate_with_locus (*expr_p, input_location);
+      SET_EXPR_LOCATION (*expr_p, input_location);
       break;
 
     case CASE_EXPR:
Index: java-tree.def
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/java-tree.def,v
retrieving revision 1.19
diff -u -p -r1.19 java-tree.def
--- java-tree.def	17 Sep 2004 21:54:58 -0000	1.19
+++ java-tree.def	30 Sep 2004 01:29:13 -0000
@@ -97,8 +97,13 @@ DEFTREECODE (JAVA_EXC_OBJ_EXPR, "java_ex
    (EXPR_WFL_LINENO); and column number (EXPR_WFL_COLNO).  It is
    expanded as the contained node (EXPR_WFL_NODE);  a line note should
    be emitted first if EXPR_WFL_EMIT_LINE_NOTE.  */
+#ifdef USE_MAPPED_LOCATION
+DEFTREECODE (EXPR_WITH_FILE_LOCATION, "expr_with_file_location",
+	     tcc_expression, 2)
+#else
 DEFTREECODE (EXPR_WITH_FILE_LOCATION, "expr_with_file_location",
 	     tcc_expression, 3)
+#endif
 
 /*
 Local variables:
Index: java-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/java-tree.h,v
retrieving revision 1.216
diff -u -p -r1.216 java-tree.h
--- java-tree.h	10 Aug 2004 04:29:16 -0000	1.216
+++ java-tree.h	30 Sep 2004 01:29:14 -0000
@@ -1824,19 +1824,29 @@ enum
 #undef EXPR_WFL_NODE
 #define EXPR_WFL_NODE(NODE) \
   TREE_OPERAND (EXPR_WITH_FILE_LOCATION_CHECK (NODE), 0)
+#ifdef USE_MAPPED_LOCATION
+#define EXPR_WFL_LINECOL(NODE) ((NODE)->exp.locus)
+#define EXPR_WFL_FILENAME(NODE) EXPR_FILENAME (NODE)
+#define EXPR_WFL_LINENO(NODE) EXPR_LINENO (NODE)
+extern tree build_expr_wfl              PARAMS ((tree, source_location));
+extern tree expr_add_location           PARAMS ((tree, source_location, bool));
+#define build_unknown_wfl(NODE) build_expr_wfl(NODE, UNKNOWN_LOCATION)
+#else
+#define EXPR_WFL_LINECOL(NODE) (EXPR_CHECK (NODE)->exp.complexity)
+#define EXPR_WFL_LINENO(NODE) (EXPR_WFL_LINECOL (NODE) >> 12)
+#define EXPR_WFL_COLNO(NODE) (EXPR_WFL_LINECOL (NODE) & 0xfff)
 #undef EXPR_WFL_FILENAME_NODE
 #define EXPR_WFL_FILENAME_NODE(NODE) \
-  TREE_OPERAND (EXPR_WITH_FILE_LOCATION_CHECK (NODE), 1)
+  TREE_OPERAND (EXPR_WITH_FILE_LOCATION_CHECK (NODE), 2)
 #define EXPR_WFL_FILENAME(NODE) \
   IDENTIFIER_POINTER (EXPR_WFL_FILENAME_NODE (NODE))
 /* ??? Java uses this in all expressions.  */
-#define EXPR_WFL_LINECOL(NODE) (EXPR_CHECK (NODE)->exp.complexity)
-#define EXPR_WFL_LINENO(NODE) (EXPR_WFL_LINECOL (NODE) >> 12)
-#define EXPR_WFL_COLNO(NODE) (EXPR_WFL_LINECOL (NODE) & 0xfff)
 #define EXPR_WFL_SET_LINECOL(NODE, LINE, COL) \
   (EXPR_WFL_LINECOL(NODE) = ((LINE) << 12) | ((COL) & 0xfff))
 
 extern tree build_expr_wfl              PARAMS ((tree, const char *, int, int));
+#define build_unknown_wfl(NODE) build_expr_wfl(NODE, NULL, 0, 0)
+#endif
 
 extern void java_genericize		PARAMS ((tree));
 extern int java_gimplify_expr		PARAMS ((tree *, tree *, tree *));
Index: jcf-write.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jcf-write.c,v
retrieving revision 1.156
diff -u -p -r1.156 jcf-write.c
--- jcf-write.c	17 Sep 2004 21:54:58 -0000	1.156
+++ jcf-write.c	30 Sep 2004 01:29:15 -0000
@@ -1479,8 +1479,12 @@ generate_bytecode_insns (tree exp, int t
 	tree body = EXPR_WFL_NODE (exp);
 	if (IS_EMPTY_STMT (body))
 	  break;
+#ifdef USE_MAPPED_LOCATION
+	input_location = EXPR_LOCATION (exp);
+#else
 	input_filename = EXPR_WFL_FILENAME (exp);
 	input_line = EXPR_WFL_LINENO (exp);
+#endif
 	if (EXPR_WFL_EMIT_LINE_NOTE (exp) && input_line > 0
 	    && debug_info_level > DINFO_LEVEL_NONE)
 	  put_linenumber (input_line, state);
Index: lang.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/lang.c,v
retrieving revision 1.159
diff -u -p -r1.159 lang.c
--- lang.c	17 Sep 2004 21:55:01 -0000	1.159
+++ lang.c	30 Sep 2004 01:29:15 -0000
@@ -668,6 +668,10 @@ java_post_options (const char **pfilenam
 	    }
 	}
     }
+#ifdef USE_MAPPED_LOCATION
+  linemap_add (&line_table, LC_ENTER, false, filename, 0);
+  linemap_add (&line_table, LC_RENAME, false, "<built-in>", 0);
+#endif
 
   /* Initialize the compiler back end.  */
   return false;
Index: parse.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.h,v
retrieving revision 1.100
diff -u -p -r1.100 parse.h
--- parse.h	19 Aug 2004 10:36:07 -0000	1.100
+++ parse.h	30 Sep 2004 01:29:15 -0000
@@ -625,7 +625,7 @@ typedef struct jdeplist_s jdeplist;
   build_expr_wfl ((NODE), input_filename, EXPR_WFL_LINENO ((WFL)), 	\
 		  EXPR_WFL_COLNO ((WFL)))
 
-#define EXPR_WFL_QUALIFICATION(WFL) TREE_OPERAND ((WFL), 2)
+#define EXPR_WFL_QUALIFICATION(WFL) TREE_OPERAND ((WFL), 1)
 #define QUAL_WFL(NODE) TREE_PURPOSE (NODE)
 #define QUAL_RESOLUTION(NODE) TREE_VALUE (NODE)
 #define QUAL_DECL_TYPE(NODE) GET_SKIP_TYPE (NODE)

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