-
-#define JDEP_DECL(J) ((J)->decl)
-#define JDEP_DECL_WFL(J) ((J)->decl)
-#define JDEP_KIND(J) ((J)->kind)
-#define JDEP_WFL(J) ((J)->wfl)
-#define JDEP_MISC(J) ((J)->misc)
-#define JDEP_ENCLOSING(J) ((J)->enclosing)
-#define JDEP_CLASS(J) ((J)->class)
-#define JDEP_APPLY_PATCH(J,P) (*(J)->patch = (P))
-#define JDEP_GET_PATCH(J) ((J)->patch)
-#define JDEP_CHAIN(J) ((J)->next)
-#define JDEP_TO_RESOLVE(J) ((J)->solv)
-#define JDEP_RESOLVED_DECL(J) ((J)->solv)
-#define JDEP_RESOLVED(J, D) ((J)->solv = D)
-#define JDEP_RESOLVED_P(J) \
- (!(J)->solv || TREE_CODE ((J)->solv) != POINTER_TYPE)
-
-struct jdeplist_s {
- jdep *first;
- jdep *last;
- struct jdeplist_s *next;
-};
-typedef struct jdeplist_s jdeplist;
-
-#define CLASSD_FIRST(CD) ((CD)->first)
-#define CLASSD_LAST(CD) ((CD)->last)
-#define CLASSD_CHAIN(CD) ((CD)->next)
-
-#define JDEP_INSERT(L,J) \
- { \
- if (!(L)->first) \
- (L)->last = (L)->first = (J); \
- else \
- { \
- JDEP_CHAIN ((L)->last) = (J); \
- (L)->last = (J); \
- } \
- }
-
-/* if TYPE can't be resolved, obtain something suitable for its
- resolution (TYPE is saved in SAVE before being changed). and set
- CHAIN to 1. Otherwise, type is set to something usable. CHAIN is
- usually used to determine that a new DEP must be installed on TYPE.
- Note that when compiling java.lang.Object, references to Object are
- java.lang.Object. */
-#define SET_TYPE_FOR_RESOLUTION(TYPE, SAVE, CHAIN) \
- { \
- tree _returned_type; \
- (CHAIN) = 0; \
- if (TREE_TYPE (GET_CPC ()) == object_type_node \
- && TREE_CODE (TYPE) == EXPR_WITH_FILE_LOCATION \
- && EXPR_WFL_NODE (TYPE) == unqualified_object_id_node) \
- (TYPE) = object_type_node; \
- else \
- { \
- if (unresolved_type_p (type, &_returned_type)) \
- { \
- if (_returned_type) \
- (TYPE) = _returned_type; \
- else \
- { \
- tree _type; \
- WFL_STRIP_BRACKET (_type, TYPE); \
- (SAVE) = (_type); \
- (TYPE) = obtain_incomplete_type (TYPE); \
- CHAIN = 1; \
- } \
- } \
- } \
- }
-
-#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 PROMOTE_RECORD_IF_COMPLETE(TYPE, IS_INCOMPLETE) \
- { \
- if (!(IS_INCOMPLETE) && TREE_CODE (TYPE) == RECORD_TYPE) \
- (TYPE) = promote_type (TYPE); \
- }
-
-/* Insert a DECL in the current block */
-#define BLOCK_CHAIN_DECL(NODE) \
- { \
- TREE_CHAIN ((NODE)) = \
- BLOCK_EXPR_DECLS (GET_CURRENT_BLOCK (current_function_decl)); \
- BLOCK_EXPR_DECLS (GET_CURRENT_BLOCK (current_function_decl)) = (NODE); \
- }
-
-/* Return the current block, either found in the body of the currently
- declared function or in the current static block being defined. */
-#define GET_CURRENT_BLOCK(F) ((F) ? DECL_FUNCTION_BODY ((F)) : \
- current_static_block)
-
-#ifndef USE_MAPPED_LOCATION
-/* Retrieve line/column from a WFL. */
-#define EXPR_WFL_GET_LINECOL(V,LINE,COL) \
- { \
- (LINE) = (V) >> 12; \
- (COL) = (V) & 0xfff; \
- }
-#endif
-
-#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)
-
-#define GET_SKIP_TYPE(NODE) \
- (TREE_CODE (TREE_TYPE (NODE)) == POINTER_TYPE ? \
- TREE_TYPE (TREE_TYPE (NODE)): TREE_TYPE (NODE))
-
-/* Handy macros for the walk operation */
-#define COMPLETE_CHECK_OP(NODE, N) \
-{ \
- TREE_OPERAND ((NODE), (N)) = \
- java_complete_tree (TREE_OPERAND ((NODE), (N))); \
- if (TREE_OPERAND ((NODE), (N)) == error_mark_node) \
- return error_mark_node; \
-}
-#define COMPLETE_CHECK_OP_0(NODE) COMPLETE_CHECK_OP(NODE, 0)
-#define COMPLETE_CHECK_OP_1(NODE) COMPLETE_CHECK_OP(NODE, 1)
-#define COMPLETE_CHECK_OP_2(NODE) COMPLETE_CHECK_OP(NODE, 2)
-
-/* Building invocations: append(ARG) and StringBuffer(ARG) */
-#define BUILD_APPEND(ARG) \
- ((JSTRING_TYPE_P (TREE_TYPE (ARG)) || JPRIMITIVE_TYPE_P (TREE_TYPE (ARG))) \
- ? build_method_invocation (wfl_append, \
- ARG ? build_tree_list (NULL, (ARG)) : NULL_TREE)\
- : build_method_invocation (wfl_append, \
- ARG ? build_tree_list (NULL, \
- build1 (CONVERT_EXPR, \
- object_type_node,\
- (ARG))) \
- : NULL_TREE))
-#define BUILD_STRING_BUFFER(ARG) \
- build_new_invocation (wfl_string_buffer, \
- (ARG ? build_tree_list (NULL, (ARG)) : NULL_TREE))
-
-#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 */
-#ifdef USE_MAPPED_LOCATION
-#define SET_WFL_OPERATOR(WHICH, NODE, WFL) \
- SET_EXPR_LOCATION (WHICH, \
- (TREE_CODE (WFL) == EXPR_WITH_FILE_LOCATION ? \
- EXPR_LOCATION (WFL) : EXPR_LOCATION (NODE)))
-#else
-#define SET_WFL_OPERATOR(WHICH, NODE, WFL) \
- EXPR_WFL_LINECOL (WHICH) = \
- (TREE_CODE (WFL) == EXPR_WITH_FILE_LOCATION ? \
- EXPR_WFL_LINECOL (WFL) : EXPR_WFL_LINECOL (NODE))
-#endif
-
-#define PATCH_METHOD_RETURN_ERROR() \
- { \
- if (ret_decl) \
- *ret_decl = NULL_TREE; \
- return error_mark_node; \
- }
-
-/* Convenient macro to check. Assumes that CLASS is a CLASS_DECL. */
-#define CHECK_METHODS(CLASS) \
- { \
- if (CLASS_INTERFACE ((CLASS))) \
- java_check_abstract_methods ((CLASS)); \
- else \
- 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) \
- { \
- if (ctxp->deprecated) \
- DECL_DEPRECATED (DECL) = 1; \
- ctxp->deprecated = 0; \
- }
-
-/* Register an import */
-#define REGISTER_IMPORT(WHOLE, NAME) \
-{ \
- IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P ((NAME)) = 1; \
- 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_CHECK (DECL)->decl.u1.i)
-#define DECL_INHERITED_SOURCE_LINE(DECL) (DECL_CHECK (DECL)->decl.u2.i)
-
-/* Parser context data structure. */
-struct parser_ctxt GTY(()) {
- const char *filename; /* Current filename */
- location_t file_start_location;
- location_t save_location;
- struct parser_ctxt *next;
-
- java_lexer * GTY((skip)) lexer; /* Current lexer state */
- char marker_begining; /* Marker. Should be a sub-struct */
- int ccb_indent; /* Number of unmatched { seen. */
- /* The next two fields are only source_location if USE_MAPPED_LOCATION.
- Otherwise, they are integer line number, but we can't have #ifdefs
- in GTY structures. */
- source_location first_ccb_indent1; /* First { at ident level 1 */
- source_location last_ccb_indent1; /* Last } 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 * GTY ((skip)) osb_number; /* Keep track of ['s */
- char marker_end; /* End marker. Should be a sub-struct */
-
- /* The flags section */
-
- /* Indicates a context used for saving the parser status. The
- context must be popped when the status is restored. */
- unsigned saved_data_ctx:1;
- /* 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;
- /* Report error when true */
- unsigned java_error_flag:1;
- /* @deprecated tag seen */
- unsigned deprecated:1;
- /* Flag to report certain errors (fix this documentation. FIXME) */
- unsigned class_err:1;
-
- /* 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 */
-
- int prevent_ese; /* Prevent expression statement error */
-
- int formal_parameter_number; /* Number of parameters found */
- int interface_number; /* # itfs declared to extend an itf def */
-
- tree package; /* Defined package ID */
-
- /* These two lists won't survive file traversal */
- tree class_list; /* List of classes 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 instance initializers stmts */
-
- tree import_list; /* List of import */
- tree import_demand_list; /* List of import on demand */
-
- tree current_loop; /* List of the currently nested
- loops/switches */
- tree current_labeled_block; /* List of currently nested
- labeled blocks. */
-
- int pending_block; /* Pending block to close */
-
- int explicit_constructor_p; /* >0 when processing an explicit
- constructor. This flag is used to trap
- illegal argument usage during an
- explicit constructor invocation. */
-};
-
-/* A set of macros to push/pop/access the currently parsed class. */
-#define GET_CPC_LIST() ctxp->current_parsed_class
-
-/* Currently class being parsed is an inner class if an enclosing
- class has been already pushed. This truth value is only valid prior
- an inner class is pushed. After, use FIXME. */
-#define CPC_INNER_P() GET_CPC_LIST ()
-
-/* 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. */
-#define GET_CPC_UN() TREE_PURPOSE (GET_CPC_LIST ())
-
-/* Get a parsed class unqualified IDENTIFIER_NODE from its CPC node. */
-#define GET_CPC_UN_NODE(N) TREE_PURPOSE (N)
-
-/* Get the currently parsed class DECL_TYPE from its CPC node. */
-#define GET_CPC_DECL_NODE(N) TREE_VALUE (N)
-
-/* The currently parsed enclosing currently parsed TREE_LIST node. */
-#define GET_ENCLOSING_CPC() TREE_CHAIN (GET_CPC_LIST ())
-
-/* Get the next enclosing context. */
-#define GET_NEXT_ENCLOSING_CPC(C) TREE_CHAIN (C)
-
-/* The DECL_TYPE node of the enclosing currently parsed
- class. NULL_TREE if the currently parsed class isn't an inner
- class. */
-#define GET_ENCLOSING_CPC_CONTEXT() (GET_ENCLOSING_CPC () ? \
- TREE_VALUE (GET_ENCLOSING_CPC ()) : \
- NULL_TREE)
-
-/* Make sure that innerclass T sits in an appropriate enclosing
- context. */
-#define INNER_ENCLOSING_SCOPE_CHECK(T) \
- (INNER_CLASS_TYPE_P ((T)) && !ANONYMOUS_CLASS_P ((T)) \
- && ((current_this \
- /* We have a this and it's not the right one */ \
- && (DECL_CONTEXT (TYPE_NAME ((T))) \
- != 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_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, 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. */
-#define PUSH_CPC(C,R) { \
- ctxp->current_parsed_class = \
- tree_cons ((R), (C), GET_CPC_LIST ()); \
- }
-
-/* In case of an error, push an error. */
-#define PUSH_ERROR() PUSH_CPC (error_mark_node, error_mark_node)
-
-/* Pop macro. Before we pop, we link the current inner class decl (if any)
- to its enclosing class. */
-#define POP_CPC() { \
- link_nested_class_to_enclosing (); \
- ctxp->current_parsed_class = \
- TREE_CHAIN (GET_CPC_LIST ()); \
- }
-
-#define DEBUG_CPC() \
- do \
- { \
- tree tmp = ctxp->current_parsed_class; \
- while (tmp) \
- { \
- fprintf (stderr, "%s ", \
- IDENTIFIER_POINTER (TREE_PURPOSE (tmp))); \
- tmp = TREE_CHAIN (tmp); \
- } \
- } \
- while (0);
-
-/* Access to the various initializer statement lists */
-#define CPC_INITIALIZER_LIST(C) ((C)->non_static_initialized)
-#define CPC_STATIC_INITIALIZER_LIST(C) ((C)->static_initialized)
-#define CPC_INSTANCE_INITIALIZER_LIST(C) ((C)->instance_initializers)
-
-/* Access to the various initializer statements */
-#define CPC_INITIALIZER_STMT(C) (TREE_PURPOSE (CPC_INITIALIZER_LIST (C)))
-#define CPC_STATIC_INITIALIZER_STMT(C) \
- (TREE_PURPOSE (CPC_STATIC_INITIALIZER_LIST (C)))
-#define CPC_INSTANCE_INITIALIZER_STMT(C) \
- (TREE_PURPOSE (CPC_INSTANCE_INITIALIZER_LIST (C)))
-
-/* Set various initializer statements */
-#define SET_CPC_INITIALIZER_STMT(C,S) \
- if (CPC_INITIALIZER_LIST (C)) \
- TREE_PURPOSE (CPC_INITIALIZER_LIST (C)) = (S);
-#define SET_CPC_STATIC_INITIALIZER_STMT(C,S) \
- if (CPC_STATIC_INITIALIZER_LIST (C)) \
- TREE_PURPOSE (CPC_STATIC_INITIALIZER_LIST (C)) = (S);
-#define SET_CPC_INSTANCE_INITIALIZER_STMT(C,S) \
- 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 (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);