⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 parse.h

📁 gcc-2.95.3 Linux下最常用的C编译器
💻 H
📖 第 1 页 / 共 2 页
字号:
/* Language parser definitions for the GNU compiler for the Java(TM) language.   Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.   Contributed by Alexandre Petit-Bianco (apbianco@cygnus.com)This file is part of GNU CC.GNU CC is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe 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,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with GNU CC; see the file COPYING.  If not, write tothe Free Software Foundation, 59 Temple Place - Suite 330,Boston, MA 02111-1307, USA.Java and all Java-based marks are trademarks or registered trademarksof 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#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 PROTO ((tree, tree));extern tree stabilize_reference PROTO ((tree));#endif/* Macros for verbose debug info  */#ifdef  VERBOSE_SKELETON#define RULE( rule ) printf ( "jv_yacc:%d: rule %s\n", lineno, rule )#else#define RULE( rule )#endif#ifdef VERBOSE_SKELETON#undef SOURCE_FRONTEND_DEBUG#define SOURCE_FRONTEND_DEBUG(X)				\  {if (!quiet_flag) {printf ("* "); printf X; putchar ('\n');} }#else#define SOURCE_FRONTEND_DEBUG(X)#endif/* Macro for error recovering  */#ifdef YYDEBUG#define RECOVERED     					\  { if (!quiet_flag) {printf ("** Recovered\n");} }#define DRECOVERED(s) 						\  { if (!quiet_flag) {printf ("** Recovered (%s)\n", #s);}}#else#define RECOVERED#define DRECOVERED(s)#endif#define DRECOVER(s) {yyerrok; DRECOVERED(s)}#define RECOVER     {yyerrok; RECOVERED}#define YYERROR_NOW ctxp->java_error_flag = 1#define YYNOT_TWICE if (ctxp->prevent_ese != lineno)/* Accepted modifiers */#define CLASS_MODIFIERS ACC_PUBLIC|ACC_ABSTRACT|ACC_FINAL#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_METHOD_MODIFIERS ACC_PUBLIC|ACC_ABSTRACT#define INTERFACE_FIELD_MODIFIERS ACC_PUBLIC|ACC_STATIC|ACC_FINAL/* Getting a modifier WFL */#define MODIFIER_WFL(M)   (ctxp->modifier_ctx [(M) - PUBLIC_TK])/* Check on modifiers */#define THIS_MODIFIER_ONLY(f, m, v, count, l)				\  if ((f) & (m))							\    {									\      tree node = ctxp->modifier_ctx [v];				\      if ((l)								\	  && ((EXPR_WFL_COLNO (node) > EXPR_WFL_COLNO (l))		\	      || (EXPR_WFL_LINENO (node) > EXPR_WFL_LINENO (l))))	\        l = node;							\      else if (!(l))							\        l = node;							\      count++;								\    }#define ABSTRACT_CHECK(FLAG, V, CL, S)				\  if ((FLAG) & (V))						\    parse_error_context ((CL), S " method can't be abstract");#define JCONSTRUCTOR_CHECK(FLAG, V, CL, S)			\  if ((FLAG) & (V))						\    parse_error_context ((CL), "Constructor can't be %s", (S));	\      /* Misc. */#define exit_java_complete_class()		\  {						\    pop_obstacks ();				\    return;					\  }#define CLASS_OR_INTERFACE(decl, s1, s2)			\   (decl ?							\    ((get_access_flags_from_decl (TYPE_NAME (TREE_TYPE (decl)))	\      & ACC_INTERFACE) ?					\     s2 : s1) : ((s1 [0]=='S'|| s1 [0]=='s') ?			\		 (s1 [0]=='S' ? "Supertype" : "supertype") :	\		 (s1 [0] > 'A' ? "Type" : "type")))#define GET_REAL_TYPE(TYPE) 					\  (TREE_CODE (TYPE) == TREE_LIST ? TREE_PURPOSE (TYPE) : TYPE)#define GET_METHOD_NAME(METHOD)					\  (TREE_CODE (DECL_NAME (METHOD)) == EXPR_WITH_FILE_LOCATION ?	\   EXPR_WFL_NODE (DECL_NAME (METHOD)) : DECL_NAME (METHOD))/* Get TYPE name string, regardless whether TYPE is a class or an   array. */#define GET_TYPE_NAME(TYPE)				\  (TREE_CODE (TYPE_NAME (TYPE)) == IDENTIFIER_NODE ?	\   IDENTIFIER_POINTER (TYPE_NAME (TYPE)) :		\   IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (TYPE))))/* Pedantic warning on obsolete modifiers. Note: when cl is NULL,   flags was set artificially, such as for a interface method */#define OBSOLETE_MODIFIER_WARNING(cl, flags, modifier, format, arg)          \  {                                                                          \    if (flag_redundant && (cl) && ((flags) & (modifier)))		     \      parse_warning_context (cl,                                             \			     "Discouraged redundant use of `%s' modifier "   \			     "in declaration of " format,                    \			     java_accstring_lookup (modifier), arg);         \  }/* Quickly build a temporary pointer on hypothetical type NAME. */#define BUILD_PTR_FROM_NAME(ptr, name)		\  {						\    ptr = build (POINTER_TYPE, NULL_TREE);	\    TYPE_NAME (ptr) = name;			\  }#define INCOMPLETE_TYPE_P(NODE)				\  ((TREE_CODE (NODE) == POINTER_TYPE)			\   && !TREE_TYPE (NODE) 				\   && TREE_CODE (TYPE_NAME (NODE)) == IDENTIFIER_NODE)/* Set the EMIT_LINE_NOTE flag of a EXPR_WLF to 1 if debug information   are requested. Works in the context of a parser rule. */#define JAVA_MAYBE_GENERATE_DEBUG_INFO(node)		\  (debug_info_level != DINFO_LEVEL_NONE ? 		\    EXPR_WFL_EMIT_LINE_NOTE (node) = 1, node : node)/* Types classification, according to the JLS, section 4.2 */#define JFLOAT_TYPE_P(TYPE)      (TYPE && TREE_CODE ((TYPE)) == REAL_TYPE)#define JINTEGRAL_TYPE_P(TYPE)   ((TYPE) 				   \				  && (TREE_CODE ((TYPE)) == INTEGER_TYPE   \				      || TREE_CODE ((TYPE)) == CHAR_TYPE))#define JNUMERIC_TYPE_P(TYPE)    ((TYPE)				\				  && (JFLOAT_TYPE_P ((TYPE))		\				      || JINTEGRAL_TYPE_P ((TYPE))))#define JPRIMITIVE_TYPE_P(TYPE)  ((TYPE) 				  \				  && (JNUMERIC_TYPE_P ((TYPE))		  \				  || TREE_CODE ((TYPE)) == BOOLEAN_TYPE))#define JBSC_TYPE_P(TYPE) ((TYPE) && (((TYPE) == byte_type_node)	\				      || ((TYPE) == short_type_node)	\				      || ((TYPE) == char_type_node)))/* Not defined in the LRM */#define JSTRING_TYPE_P(TYPE) ((TYPE) 					   \			      && ((TYPE) == string_type_node ||		   \				  (TREE_CODE (TYPE) == POINTER_TYPE &&	   \				   TREE_TYPE (TYPE) == string_type_node)))#define JSTRING_P(NODE) ((NODE)						\			 && (TREE_CODE (NODE) == STRING_CST		\			     || IS_CRAFTED_STRING_BUFFER_P (NODE)	\			     || JSTRING_TYPE_P (TREE_TYPE (NODE))))#define JREFERENCE_TYPE_P(TYPE) ((TYPE)					      \				 && (TREE_CODE (TYPE) == RECORD_TYPE 	      \				     ||	(TREE_CODE (TYPE) == POINTER_TYPE     \					 &&  TREE_CODE (TREE_TYPE (TYPE)) ==  \					 RECORD_TYPE)))#define JNULLP_TYPE_P(TYPE) ((TYPE) && (TREE_CODE (TYPE) == POINTER_TYPE) \			     && (TYPE) == TREE_TYPE (null_pointer_node))/* Other predicate */#define JDECL_P(NODE) (NODE && (TREE_CODE (NODE) == PARM_DECL		\				|| TREE_CODE (NODE) == VAR_DECL		\				|| TREE_CODE (NODE) == FIELD_DECL))#define TYPE_INTERFACE_P(TYPE) 					\  (CLASS_P (TYPE) && CLASS_INTERFACE (TYPE_NAME (TYPE)))#define TYPE_CLASS_P(TYPE) (CLASS_P (TYPE) 				\			    && !CLASS_INTERFACE (TYPE_NAME (TYPE)))/* Standard error messages */#define ERROR_CANT_CONVERT_TO_BOOLEAN(OPERATOR, NODE, TYPE)		\  parse_error_context							\    ((OPERATOR), "Incompatible type for `%s'. Can't convert `%s' to "	\     "boolean", operator_string ((NODE)), lang_printable_name ((TYPE),0))#define ERROR_CANT_CONVERT_TO_NUMERIC(OPERATOR, NODE, TYPE)		\  parse_error_context							\    ((OPERATOR), "Incompatible type for `%s'. Can't convert `%s' to "	\     "numeric type", operator_string ((NODE)), lang_printable_name ((TYPE), 0))#define ERROR_CAST_NEEDED_TO_INTEGRAL(OPERATOR, NODE, TYPE)		\  parse_error_context							\    ((OPERATOR), (JPRIMITIVE_TYPE_P (TYPE) ?				\     "Incompatible type for `%s'. Explicit cast needed to convert "	\      "`%s' to integral" : "Incompatible type for `%s'. Can't convert "	\      "`%s' to integral"), operator_string ((NODE)),			\      lang_printable_name ((TYPE), 0))#define ERROR_VARIABLE_NOT_INITIALIZED(WFL, V)			\  parse_error_context						\    ((WFL), "Variable `%s' may not have been initialized",	\     IDENTIFIER_POINTER (V))/* Definition for loop handling. This is Java's own definition of a   loop body. See parse.y for documentation. It's valid once you hold   a loop's body (LOOP_EXPR_BODY) *//* The loop main block is the one hold the condition and the loop body */#define LOOP_EXPR_BODY_MAIN_BLOCK(NODE) TREE_OPERAND (NODE, 0)/* And then there is the loop update block */#define LOOP_EXPR_BODY_UPDATE_BLOCK(NODE) TREE_OPERAND (NODE, 1)/* Inside the loop main block, there is the loop condition and the   loop body. They may be reversed if the loop being described is a   do-while loop. NOTE: if you use a WFL around the EXIT_EXPR so you   can issue debug info for it, the EXIT_EXPR will be one operand   further. */#define LOOP_EXPR_BODY_CONDITION_EXPR(NODE, R) 			\  TREE_OPERAND (LOOP_EXPR_BODY_MAIN_BLOCK (NODE), (R ? 1 : 0))/* Here is the labeled block the loop real body is encapsulated in */#define LOOP_EXPR_BODY_LABELED_BODY(NODE, R)			\  TREE_OPERAND (LOOP_EXPR_BODY_MAIN_BLOCK (NODE), (R ? 0 : 1))/* And here is the loop's real body */#define LOOP_EXPR_BODY_BODY_EXPR(NODE, R)			\  LABELED_BLOCK_BODY (LOOP_EXPR_BODY_LABELED_BODY(NODE, R))#define PUSH_LABELED_BLOCK(B)				\  {							\    TREE_CHAIN (B) = ctxp->current_labeled_block;	\    ctxp->current_labeled_block = (B);			\  }#define POP_LABELED_BLOCK() 						\  ctxp->current_labeled_block = TREE_CHAIN (ctxp->current_labeled_block)#define PUSH_LOOP(L)				\  {						\    TREE_CHAIN (L) = ctxp->current_loop;	\    ctxp->current_loop = (L);			\  }#define POP_LOOP() ctxp->current_loop = TREE_CHAIN (ctxp->current_loop)#define PUSH_EXCEPTIONS(E)					\  currently_caught_type_list =					\    tree_cons (NULL_TREE, (E), currently_caught_type_list);#define POP_EXCEPTIONS()						\  currently_caught_type_list = TREE_CHAIN (currently_caught_type_list)/* Check that we're inside a try block.  */#define IN_TRY_BLOCK_P()				\  (currently_caught_type_list 				\   && ((TREE_VALUE (currently_caught_type_list) !=	\	DECL_FUNCTION_THROWS (current_function_decl))	\       || TREE_CHAIN (currently_caught_type_list)))/* Check that we have exceptions in E.  */#define EXCEPTIONS_P(E) ((E) ? TREE_VALUE (E) : NULL_TREE)/* Invocation modes, as returned by invocation_mode (). */enum {  INVOKE_STATIC,  INVOKE_NONVIRTUAL,  INVOKE_SUPER,  INVOKE_INTERFACE,  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   and used, we record in a struct jdep element what the incomplete   type is and what it should patch. Later, java_complete_class will   process all classes known to have unresolved type   dependencies. Within each of these classes, this routine will   process unresolved type dependencies (JDEP_TO_RESOLVE), patch what   needs to be patched in the dependent tree node (JDEP_GET_PATCH,   JDEP_APPLY_PATCH) and perform other actions dictated by the context   of the patch (JDEP_KIND). The ideas are: we patch only what needs   to be patched, and with java_complete_class called at the right   time, we will start processing incomplete function bodies tree   nodes with everything external to function's bodies already   completed, it makes things much simpler. */enum jdep_code {  JDEP_NO_PATCH,		/* Must be first */  JDEP_SUPER,			/* Patch the type of one type				   supertype. Requires some check				   before it's done */  JDEP_FIELD,			/* Patch the type of a class field */  /* 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 */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -