/* Language parser definitions for the GNU compiler for the Java(TM) language.
- Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
+ Free Software Foundation, Inc.
Contributed by Alexandre Petit-Bianco (apbianco@cygnus.com)
-This file is part of GNU CC.
+This file is part of GCC.
-GNU CC is free software; you can redistribute it and/or modify
+GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
-GNU CC is distributed in the hope that it will be useful,
+GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
+along with GCC; see the file COPYING. If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
of Sun Microsystems, Inc. in the United States and other countries.
The Free Software Foundation is independent of Sun Microsystems, Inc. */
-#ifndef JV_LANG_H
-#define JV_LANG_H
+#ifndef GCC_JAVA_PARSE_H
+#define GCC_JAVA_PARSE_H
#include "lex.h"
/* Extern global variable declarations */
extern int java_error_count;
extern struct obstack temporary_obstack;
-extern struct obstack permanent_obstack;
extern int quiet_flag;
#ifndef JC1_LITE
/* Function extern to java/ */
-extern int int_fits_type_p PARAMS ((tree, tree));
-extern tree stabilize_reference PARAMS ((tree));
+extern int int_fits_type_p (tree, tree);
+extern tree stabilize_reference (tree);
#endif
/* Macros for verbose debug info */
#define RECOVER {yyerrok; RECOVERED;}
#define YYERROR_NOW ctxp->java_error_flag = 1
-#define YYNOT_TWICE if (ctxp->prevent_ese != lineno)
+#define YYNOT_TWICE if (ctxp->prevent_ese != input_line)
/* Accepted modifiers */
-#define CLASS_MODIFIERS ACC_PUBLIC|ACC_ABSTRACT|ACC_FINAL
+#define CLASS_MODIFIERS ACC_PUBLIC|ACC_ABSTRACT|ACC_FINAL|ACC_STRICT
#define FIELD_MODIFIERS ACC_PUBLIC|ACC_PROTECTED|ACC_PRIVATE|ACC_FINAL| \
ACC_STATIC|ACC_TRANSIENT|ACC_VOLATILE
#define METHOD_MODIFIERS ACC_PUBLIC|ACC_PROTECTED|ACC_PRIVATE|ACC_ABSTRACT| \
- ACC_STATIC|ACC_FINAL|ACC_SYNCHRONIZED|ACC_NATIVE
-#define INTERFACE_MODIFIERS ACC_PUBLIC|ACC_ABSTRACT
-#define INTERFACE_INNER_MODIFIERS ACC_PUBLIC|ACC_PROTECTED|ACC_PRIVATE|ACC_ABSTRACT|ACC_STATIC
+ ACC_STATIC|ACC_FINAL|ACC_SYNCHRONIZED|ACC_NATIVE| \
+ ACC_STRICT
+#define INTERFACE_MODIFIERS ACC_PUBLIC|ACC_ABSTRACT|ACC_STRICT
+#define INTERFACE_INNER_MODIFIERS ACC_PUBLIC|ACC_PROTECTED|ACC_ABSTRACT| \
+ ACC_STATIC|ACC_PRIVATE
#define INTERFACE_METHOD_MODIFIERS ACC_PUBLIC|ACC_ABSTRACT
#define INTERFACE_FIELD_MODIFIERS ACC_PUBLIC|ACC_STATIC|ACC_FINAL
/* Quickly build a temporary pointer on hypothetical type NAME. */
#define BUILD_PTR_FROM_NAME(ptr, name) \
do { \
- ptr = build (POINTER_TYPE, NULL_TREE); \
+ ptr = make_node (POINTER_TYPE); \
TYPE_NAME (ptr) = name; \
} while (0)
}
/* Build the string parm$<O> and store in into the identifier N. This
- is used to contruct the name of hidden parameters used to
+ is used to construct the name of hidden parameters used to
initialize outer scope aliases. */
#define MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_ID(N, O) \
{ \
INVOKE_VIRTUAL
};
-/* We need the resolution stuff only if we compile jc1 */
-#ifndef JC1_LITE
-
/* Unresolved type identifiers handling. When we process the source
code, we blindly accept an unknown type identifier and try to
resolve it later. When an unknown type identifier is encountered
typedef struct _jdep {
ENUM_BITFIELD(jdep_code) kind : 8; /* Type of patch */
- int flag0 : 1; /* Some flags */
+ unsigned int flag0 : 1; /* Some flags */
tree decl; /* Tied decl/or WFL */
tree solv; /* What to solve */
tree wfl; /* Where thing to resolve where found */
#define JDEP_DECL(J) ((J)->decl)
#define JDEP_DECL_WFL(J) ((J)->decl)
#define JDEP_KIND(J) ((J)->kind)
-#define JDEP_SOLV(J) ((J)->solv)
#define JDEP_WFL(J) ((J)->wfl)
#define JDEP_MISC(J) ((J)->misc)
#define JDEP_ENCLOSING(J) ((J)->enclosing)
#define JDEP_RESOLVED_P(J) \
(!(J)->solv || TREE_CODE ((J)->solv) != POINTER_TYPE)
-typedef struct _jdeplist {
+struct jdeplist_s {
jdep *first;
jdep *last;
- struct _jdeplist *next;
-} jdeplist;
-
-#endif /* JC1_LITE */
+ struct jdeplist_s *next;
+};
+typedef struct jdeplist_s jdeplist;
#define CLASSD_FIRST(CD) ((CD)->first)
#define CLASSD_LAST(CD) ((CD)->last)
} \
}
-#define WFL_STRIP_BRACKET(TARGET, TYPE) \
-{ \
- tree __type = (TYPE); \
- if (TYPE && TREE_CODE (TYPE) == EXPR_WITH_FILE_LOCATION) \
- { \
- tree _node = EXPR_WFL_NODE (TYPE); \
- const char *_ptr = IDENTIFIER_POINTER (_node); \
- const char *_ref = _ptr; \
- while (_ptr[0] == '[') \
- _ptr++; \
- if (_ref != _ptr) \
- { \
- tree _new = copy_node (TYPE); \
- EXPR_WFL_NODE (_new) = get_identifier (_ptr); \
- __type = _new; \
- } \
- } \
- (TARGET) = __type; \
+#define WFL_STRIP_BRACKET(TARGET, TYPE) \
+{ \
+ tree __type = (TYPE); \
+ if (TYPE && TREE_CODE (TYPE) == EXPR_WITH_FILE_LOCATION) \
+ { \
+ tree _node; \
+ if (build_type_name_from_array_name (EXPR_WFL_NODE (TYPE), &_node)) \
+ { \
+ tree _new = copy_node (TYPE); \
+ EXPR_WFL_NODE (_new) = _node; \
+ __type = _new; \
+ } \
+ } \
+ (TARGET) = __type; \
+}
+
+/* If NAME contains one or more trailing []s, NAMELEN will be the
+ adjusted to be the index of the last non bracket character in
+ NAME. ARRAY_DIMS will contain the number of []s found. */
+
+#define STRING_STRIP_BRACKETS(NAME, NAMELEN, ARRAY_DIMS) \
+{ \
+ ARRAY_DIMS = 0; \
+ while (NAMELEN >= 2 && (NAME)[NAMELEN - 1] == ']') \
+ { \
+ NAMELEN -= 2; \
+ (ARRAY_DIMS)++; \
+ } \
}
/* Promote a type if it won't be registered as a patch */
#define GET_CURRENT_BLOCK(F) ((F) ? DECL_FUNCTION_BODY ((F)) : \
current_static_block)
-/* For an artificial BLOCK (created to house a local variable declaration not
- at the start of an existing block), the parent block; otherwise NULL. */
-#define BLOCK_EXPR_ORIGIN(NODE) BLOCK_ABSTRACT_ORIGIN(NODE)
-
-/* Merge an other line to the source line number of a decl. Used to
- remember function's end. */
-#define DECL_SOURCE_LINE_MERGE(DECL,NO) DECL_SOURCE_LINE(DECL) |= (NO << 16)
-
-/* Retrieve those two info separately. */
-#define DECL_SOURCE_LINE_FIRST(DECL) (DECL_SOURCE_LINE(DECL) & 0x0000ffff)
-#define DECL_SOURCE_LINE_LAST(DECL) (DECL_SOURCE_LINE(DECL) >> 16)
-
/* Retrieve line/column from a WFL. */
#define EXPR_WFL_GET_LINECOL(V,LINE,COL) \
{ \
build_new_invocation (wfl_string_buffer, \
(ARG ? build_tree_list (NULL, (ARG)) : NULL_TREE))
-/* For exception handling, build diverse function calls */
-#define BUILD_ASSIGN_EXCEPTION_INFO(WHERE, TO) \
- { \
- (WHERE) = build (MODIFY_EXPR, void_type_node, (TO), \
- soft_exceptioninfo_call_node); \
- TREE_SIDE_EFFECTS (WHERE) = 1; \
- }
-
-#define BUILD_THROW(WHERE, WHAT) \
- { \
- (WHERE) = \
- build (CALL_EXPR, void_type_node, \
- build_address_of (throw_node[exceptions_via_longjmp ? 1 : 0]), \
- build_tree_list (NULL_TREE, (WHAT)), NULL_TREE); \
- TREE_SIDE_EFFECTS ((WHERE)) = 1; \
+#define BUILD_THROW(WHERE, WHAT) \
+ { \
+ (WHERE) = \
+ build3 (CALL_EXPR, void_type_node, \
+ build_address_of (throw_node), \
+ build_tree_list (NULL_TREE, (WHAT)), NULL_TREE); \
+ TREE_SIDE_EFFECTS ((WHERE)) = 1; \
}
/* Set wfl_operator for the most accurate error location */
java_check_regular_methods ((CLASS)); \
}
+#define CLEAR_DEPRECATED ctxp->deprecated = 0
+
+#define CHECK_DEPRECATED_NO_RESET(DECL) \
+ { \
+ if (ctxp->deprecated) \
+ DECL_DEPRECATED (DECL) = 1; \
+ }
+
/* Using and reseting the @deprecated tag flag */
#define CHECK_DEPRECATED(DECL) \
{ \
#define REGISTER_IMPORT(WHOLE, NAME) \
{ \
IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P ((NAME)) = 1; \
- ctxp->import_list = chainon (ctxp->import_list, \
- build_tree_list ((WHOLE), (NAME))); \
+ ctxp->import_list = tree_cons ((WHOLE), (NAME), ctxp->import_list); \
}
/* Macro to access the osb (opening square bracket) count */
#define CURRENT_OSB(C) (C)->osb_number [(C)->osb_depth]
/* Macro for the xreferencer */
-#define DECL_END_SOURCE_LINE(DECL) DECL_FRAME_SIZE (DECL)
+#define DECL_END_SOURCE_LINE(DECL) (DECL_CHECK (DECL)->decl.u1.i)
#define DECL_INHERITED_SOURCE_LINE(DECL) (DECL_CHECK (DECL)->decl.u2.i)
/* Parser context data structure. */
-struct parser_ctxt {
+struct parser_ctxt GTY(()) {
const char *filename; /* Current filename */
struct parser_ctxt *next;
- java_lexer *lexer; /* Current lexer state */
+ java_lexer * GTY((skip)) lexer; /* Current lexer state */
char marker_begining; /* Marker. Should be a sub-struct */
- struct java_line *p_line, *c_line; /* Previous and current line */
+ struct java_line * GTY ((skip)) p_line; /* Previous line */
+ struct java_line * GTY ((skip)) c_line; /* Current line */
java_lc elc; /* Error's line column info */
int ccb_indent; /* Keep track of {} indent, lexer */
int first_ccb_indent1; /* First { at ident level 1 */
int parser_ccb_indent; /* Keep track of {} indent, parser */
int osb_depth; /* Current depth of [ in an expression */
int osb_limit; /* Limit of this depth */
- int *osb_number; /* Keep track of ['s */
+ int * GTY ((skip)) osb_number; /* Keep track of ['s */
int lineno; /* Current lineno */
char marker_end; /* End marker. Should be a sub-struct */
/* Indicates that a context already contains saved data and that the
next save operation will require a new context to be created. */
unsigned saved_data:1;
- /* Integral literal overflow */
- unsigned minus_seen:1;
/* Report error when true */
unsigned java_error_flag:1;
/* @deprecated tag seen */
/* Flag to report certain errors (fix this documentation. FIXME) */
unsigned class_err:1;
- /* This section is defined only if we compile jc1 */
-#ifndef JC1_LITE
- tree modifier_ctx [11]; /* WFL of modifiers */
+ /* This section is used only if we compile jc1 */
+ tree modifier_ctx [12]; /* WFL of modifiers */
tree class_type; /* Current class */
tree function_decl; /* Current function decl, save/restore */
- struct JCF *current_jcf; /* CU jcf */
+ struct JCF * current_jcf; /* CU jcf */
int prevent_ese; /* Prevent expression statement error */
/* These two lists won't survive file traversal */
tree class_list; /* List of classes in a CU */
- jdeplist *classd_list; /* Classe dependencies in a CU */
+ jdeplist * GTY((skip)) classd_list; /* Classe dependencies in a CU */
tree current_parsed_class; /* Class currently parsed */
tree current_parsed_class_un; /* Curr. parsed class unqualified name */
tree non_static_initialized; /* List of non static initialized fields */
tree static_initialized; /* List of static non final initialized */
- tree instance_initializers; /* List of instancei initializers stmts */
+ tree instance_initializers; /* List of instance initializers stmts */
tree import_list; /* List of import */
tree import_demand_list; /* List of import on demand */
constructor. This flag is used to trap
illegal argument usage during an
explicit constructor invocation. */
-#endif /* JC1_LITE */
};
/* A set of macros to push/pop/access the currently parsed class. */
an inner class is pushed. After, use FIXME. */
#define CPC_INNER_P() GET_CPC_LIST ()
-/* Get the currently parsed class DECL_TYPE node. */
+/* The TYPE_DECL node of the class currently being parsed. */
#define GET_CPC() TREE_VALUE (GET_CPC_LIST ())
/* Get the currently parsed class unqualified IDENTIFIER_NODE. */
!= TYPE_NAME (TREE_TYPE (TREE_TYPE (current_this)))) \
&& !inherits_from_p (TREE_TYPE (TREE_TYPE (current_this)), \
TREE_TYPE (DECL_CONTEXT (TYPE_NAME (T)))) \
- && !common_enclosing_context_p (TREE_TYPE (TREE_TYPE (current_this)), \
+ && !common_enclosing_instance_p (TREE_TYPE (TREE_TYPE (current_this)),\
(T)) \
&& INNER_CLASS_TYPE_P (TREE_TYPE (TREE_TYPE (current_this))) \
&& !inherits_from_p \
(TREE_TYPE (DECL_CONTEXT \
(TYPE_NAME (TREE_TYPE (TREE_TYPE (current_this))))),\
TREE_TYPE (DECL_CONTEXT (TYPE_NAME (T))))) \
- /* We don't have a this. */ \
- || !current_this))
+ /* We don't have a this, which is OK if the current function is \
+ static. */ \
+ || (!current_this \
+ && current_function_decl \
+ && ! METHOD_STATIC (current_function_decl))))
/* Push macro. First argument to PUSH_CPC is a DECL_TYPE, second
argument is the unqualified currently parsed class name. */
if (CPC_INSTANCE_INITIALIZER_LIST(C)) \
TREE_PURPOSE (CPC_INSTANCE_INITIALIZER_LIST (C)) = (S);
+/* This is used by the lexer to communicate with the parser. It is
+ set on an integer constant if the radix is NOT 10, so that the parser
+ can correctly diagnose a numeric overflow. */
+#define JAVA_NOT_RADIX10_FLAG(NODE) TREE_LANG_FLAG_0(NODE)
+
#ifndef JC1_LITE
-void java_complete_class PARAMS ((void));
-void java_check_circular_reference PARAMS ((void));
-void java_fix_constructors PARAMS ((void));
-void java_layout_classes PARAMS ((void));
-void java_reorder_fields PARAMS ((void));
-tree java_method_add_stmt PARAMS ((tree, tree));
-void java_expand_switch PARAMS ((tree));
-int java_report_errors PARAMS ((void));
-extern tree do_resolve_class PARAMS ((tree, tree, tree, tree));
+void java_complete_class (void);
+void java_check_circular_reference (void);
+void java_fix_constructors (void);
+void java_layout_classes (void);
+void java_reorder_fields (void);
+tree java_method_add_stmt (tree, tree);
+int java_report_errors (void);
+extern tree do_resolve_class (tree, tree, tree, tree);
#endif
-char *java_get_line_col PARAMS ((const char *, int, int));
-extern void reset_report PARAMS ((void));
+char *java_get_line_col (const char *, int, int);
+extern void reset_report (void);
/* Always in use, no matter what you compile */
-void java_push_parser_context PARAMS ((void));
-void java_pop_parser_context PARAMS ((int));
-void java_init_lex PARAMS ((FILE *, const char *));
-extern void java_parser_context_save_global PARAMS ((void));
-extern void java_parser_context_restore_global PARAMS ((void));
-int yyparse PARAMS ((void));
-extern int java_parse PARAMS ((void));
-extern void yyerror PARAMS ((const char *))
+void java_push_parser_context (void);
+void java_pop_parser_context (int);
+void java_init_lex (FILE *, const char *);
+extern void java_parser_context_save_global (void);
+extern void java_parser_context_restore_global (void);
+int yyparse (void);
+extern int java_parse (void);
+extern void yyerror (const char *)
#ifdef JC1_LITE
ATTRIBUTE_NORETURN
#endif
;
-extern void java_expand_classes PARAMS ((void));
+extern void java_expand_classes (void);
+extern void java_finish_classes (void);
-extern struct parser_ctxt *ctxp;
-struct parser_ctxt *ctxp_for_generation;
-#endif
+extern GTY(()) struct parser_ctxt *ctxp;
+extern GTY(()) struct parser_ctxt *ctxp_for_generation;
+
+#endif /* ! GCC_JAVA_PARSE_H */