- /* JDEP_{METHOD,METHOD_RETURN,METHOD_END} to be kept in order */
- JDEP_METHOD, /* Mark the beginning of the patching
- of a method declaration, including
- it's arguments */
- JDEP_METHOD_RETURN, /* Mark the beginning of the patching
- of a method declaration. Arguments
- aren't patched, only the returned
- type is */
- JDEP_METHOD_END, /* Mark the end of the patching of a
- method declaration. It indicates
- that it's time to compute and
- install a new signature */
-
- JDEP_INTERFACE, /* Patch the type of a Class/interface
- extension */
- JDEP_VARIABLE, /* Patch the type of a variable declaration */
- JDEP_PARM, /* Patch the type of a parm declaration */
- JDEP_TYPE, /* Patch a random tree node type,
- without the need for any specific
- actions */
- JDEP_EXCEPTION, /* Patch exceptions specified by `throws' */
-};
-
-typedef struct _jdep {
-#ifdef ONLY_INT_FIELDS
- int kind : 8; /* Type of patch */
-#else
- enum jdep_code kind : 8;
-#endif
-
- int flag0 : 1; /* Some flags */
- tree decl; /* Tied decl/or WFL */
- tree solv; /* What to solve */
- tree wfl; /* Where thing to resolve where found */
- tree misc; /* Miscellaneous info (optional). */
- tree *patch; /* Address of a location to patch */
- struct _jdep *next; /* Linked list */
-} jdep;
-
-
-#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_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) (TREE_PURPOSE ((J)->solv))
-#define JDEP_RESOLVED_DECL(J) ((J)->solv ? TREE_PURPOSE ((J)->solv):NULL_TREE)
-#define JDEP_RESOLVED(J, D) \
- { \
- TREE_PURPOSE ((J)->solv) = D; \
- TREE_VALUE ((J)->solv) = (J)->solv; \
- }
-#define JDEP_RESOLVED_P(J) (!(J)->solv || \
- TREE_VALUE ((J)->solv) == (J)->solv)
-
-typedef struct _jdeplist {
- jdep *first;
- jdep *last;
- struct _jdeplist *next;
-} jdeplist;
-static jdeplist *reverse_jdep_list ();
-
-#endif /* JC1_LITE */
-
-#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 (ctxp->current_parsed_class) == 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 \
- { \
- (SAVE) = (TYPE); \
- (TYPE) = obtain_incomplete_type (TYPE); \
- CHAIN = 1; \
- } \
- } \
- } \
- }
-/* 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 (DECL_FUNCTION_BODY (current_function_decl)); \
- BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl)) = (NODE); \
- }
-
-#define BLOCK_EXPR_DECLS(NODE) BLOCK_VARS(NODE)
-#define BLOCK_EXPR_BODY(NODE) BLOCK_SUBBLOCKS(NODE)
-
-/* 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)
-
-/* Build a WFL for expression nodes */
-#define BUILD_EXPR_WFL(NODE, WFL) \
- build_expr_wfl ((NODE), input_filename, EXPR_WFL_LINENO ((WFL)), \
- EXPR_WFL_COLNO ((WFL)))
-
-#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) \
- build_method_invocation (wfl_append, \
- (ARG ? build_tree_list (NULL, (ARG)): NULL_TREE))
-#define BUILD_STRING_BUFFER(ARG) \
- build_new_invocation (wfl_string_buffer, \
- (ARG ? build_tree_list (NULL, (ARG)) : NULL_TREE))
-
-/* For exception handling, build diverse function calls */
-#define BUILD_MONITOR_ENTER(WHERE, ARG) \
- { \
- (WHERE) = build (CALL_EXPR, int_type_node, \
- build_address_of (soft_monitorenter_node), \
- build_tree_list (NULL_TREE, (ARG)), \
- NULL_TREE); \
- TREE_SIDE_EFFECTS (WHERE) = 1; \
- }
-
-#define BUILD_MONITOR_EXIT(WHERE, ARG) \
- { \
- (WHERE) = build (CALL_EXPR, int_type_node, \
- build_address_of (soft_monitorexit_node), \
- build_tree_list (NULL_TREE, (ARG)), \
- NULL_TREE); \
- TREE_SIDE_EFFECTS (WHERE) = 1; \
- }
-
-#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), \
- build_tree_list (NULL_TREE, (WHAT)), NULL_TREE); \
- TREE_SIDE_EFFECTS ((WHERE)) = 1; \
- }
-
-/* Set wfl_operator for the most accurate error location */
-#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))
-
-#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)); \
- }
-
-/* Using and reseting the @deprecated tag flag */
-#define CHECK_DEPRECATED(DECL) \
- { \
- if (ctxp->deprecated) \
- DECL_DEPRECATED (DECL) = 1; \
- ctxp->deprecated = 0; \
- }
-
-/* Register an impor */
-#define REGISTER_IMPORT(WHOLE, NAME) \
-{ \
- IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P ((NAME)) = 1; \
- node = build_tree_list ((WHOLE), (NAME)); \
- TREE_CHAIN (node) = ctxp->import_list; \
- ctxp->import_list = node; \
-}
-
-/* Parser context data structure. */
-struct parser_ctxt {
-
- char *filename; /* Current filename */
- FILE *finput; /* Current file input stream */
- struct parser_ctxt *next;
-
- struct java_line *p_line, *c_line; /* Previous and current line */
- java_lc elc; /* Error's line column info */
- unicode_t unget_utf8_value; /* An unget utf8 value */
- int ccb_indent; /* Keep track of {} indent, lexer */
- int first_ccb_indent1; /* First { at ident level 1 */
- int last_ccb_indent1; /* Last } at ident level 1 */
- int parser_ccb_indent; /* Keep track of {} indent, parser */
- int osb_number; /* Keep track of ['s */
- int minus_seen; /* Integral literal overflow */
- int lineno; /* Current lineno */
- int java_error_flag; /* Report error when true */
- int deprecated; /* @deprecated tag seen */
-
- /* This section is defined only if we compile jc1 */
-#ifndef JC1_LITE
- tree modifier_ctx [11]; /* WFL of modifiers */
- tree current_class; /* Current class */
- tree current_function_decl; /* Current function decl, save/restore */
-
- JCF *current_jcf; /* CU jcf */
-
- int prevent_ese; /* Prevent expression statement error */
- int class_err; /* Flag to report certain errors */
-
- int formal_parameter_number; /* Number of parameters found */
- int interface_number; /* # itfs declared to extend an itf def */
-
- tree package; /* Defined package ID */
-
- /* Those tow list are saved accross file traversal */
- tree incomplete_class; /* List of non-complete classes */
- tree gclass_list; /* All classes seen from source code */
-
- /* 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 */
-
- 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 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; /* True when processing an explicit
- constructor. This flag is used to trap
- illegal argument usage during an
- explicit constructor invocation. */
-#endif /* JC1_LITE */
-};
-
-#ifndef JC1_LITE
-void safe_layout_class PROTO ((tree));
-void java_complete_class PROTO ((void));
-void java_check_circular_reference PROTO ((void));
-void java_check_final PROTO ((void));
-void java_layout_classes PROTO ((void));
-tree java_method_add_stmt PROTO ((tree, tree));
-char *java_get_line_col PROTO ((char *, int, int));
-void java_expand_switch PROTO ((tree));
-tree java_get_catch_block PROTO ((tree, int));
-int java_report_errors PROTO (());
-#endif