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

📄 cfront.h

📁 c 语言编译器 源代码- c compiler
💻 H
📖 第 1 页 / 共 2 页
字号:
	Pexpr	dim;	int	size;			vec(Ptype t, Pexpr e) { Nt++; base=VEC; typ=t; dim=e; };	Ptype	normalize(Ptype);	void	print();};struct ptr : public type		/* PTR RPTR*/{	Ptype	typ;	bit	rdo;	// for "*const"		ptr(TOK b, Ptype t, bit r = 0) { Nt++; base=b; typ=t; rdo=r; };	Ptype	normalize(Ptype);};inline Pptr type.addrof() { return new ptr(PTR,this,0); }/****************************** constants ********************************/		/* STRING ZERO ICON FCON CCON ID */		/* IVAL FVAL LVAL *//***************************** expressions ********************************/extern Pexpr next_elem();extern void new_list(Pexpr);extern void list_check(Pname, Ptype, Pexpr);extern Pexpr ref_init(Pptr,Pexpr,Ptable);extern Pexpr class_init(Pexpr,Ptype,Pexpr,Ptable);extern Pexpr check_cond(Pexpr, TOK, Ptable);	class expr : public node	/* PLUS, MINUS, etc. */		/* IMPORTANT:	all expressions are of sizeof(expr) */		/*	DEREF		=>	*e1 (e2==0) OR e1[e2]	   		UMINUS		=>	-e2	   		INCR (e1==0)	=>	++e2	   		INCR (e2==0)	=>	e1++	   		CM		=>	e1 , e2	   		ILIST		=>	LC e1 RC   (an initializer list)	   		a Pexpr may denote a name		*/	{	public:		union {		Ptype	tp;		int	syn_class;		};		union {		Pexpr e1;		char* string;		};		union {		Pexpr	e2;		Pexpr	n_initializer;		char* string2;		};		union {			/* used by the derived classes */		Ptype	tp2;		Pname	fct_name;		Pexpr	cond;		Pname	mem;		Ptype	as_type;		Ptable	n_table;		Pin	il;		};			expr(TOK, Pexpr, Pexpr);			~expr();		void	del();		void	print();		Pexpr	typ(Ptable);		int	eval();		int	lval(TOK);		Ptype	fct_call(Ptable);		Pexpr	address();		Pexpr	contents();		void	simpl();		Pexpr	expand();		bit	not_simple();	};	extern char* Neval;	struct typed_obj : expr {		typed_obj(TOK t, char* s) : (t,(Pexpr)s,0) { this=0; }	};	struct texpr : expr		// NEW CAST VALUE	{		texpr(TOK bb, Ptype tt, Pexpr ee) : (bb,ee,0) {this=0; tp2=tt;}	};	struct call : expr		// CALL	{		call(Pexpr aa, Pexpr bb) : (CALL,aa,bb) { this=0; }		void	simpl();		Pexpr	expand(Ptable);	};	struct qexpr : expr		// QUEST	/* cond ? e1 : e2 */	{		qexpr(Pexpr ee, Pexpr ee1, Pexpr ee2) : (QUEST,ee1,ee2) { this=0; cond=ee; }	};	struct ref : expr		// REF DOT	/* e1->mem OR e1.mem */	{		ref(TOK ba, Pexpr a, Pname b) : (ba,a,0) { this=0; mem=b; }	};	struct text_expr : expr		// TEXT	{		text_expr(char* a, char* b) : (TEXT,0,0) { string=a; string2=b; }	};/************************* names (are expressions) ****************************/	class name : public expr {		/* NAME TNAME and the keywords in the ktbl */	public:	/*	Pexpr	n_initializer;	*/		int	n_val;		/* the value of n_initializer */		TOK	n_oper;		/* name of operator or 0 */		TOK	n_sto;		/* STO keyword: EXTERN, STATIC, AUTO, REGISTER, ENUM */		TOK	n_stclass;	/* STATIC AUTO REGISTER 0 */		TOK	n_scope;	/* EXTERN STATIC FCT ARG PUBLIC 0 */		short	n_offset;	/* byte offset in frame or struct */		Pname	n_list;		Pname	n_tbl_list;	/*	Ptable	n_table;	*/		short	n_used;		short	n_addr_taken;		short	n_assigned_to;		char	n_union;	/* 0 or union index */		bit	n_evaluated;	/* 0 or n_val holds the value */		short	lex_level;		Loc	where;		union {		Pname	n_qualifier;	/* name of containing class */		Ptable	n_realscope;	/* for labels (always entered in					   function table) the table for the					   actual scope in which label occurred.					*/		};			name(char* =0);			~name();		void	del();		void	print();		void	dcl_print(TOK);		Pname	normalize(Pbase, Pblock, bit);		Pname	tdef();		Pname	tname(TOK);		Pname	dcl(Ptable,TOK);		int	no_of_names();		void	hide();		void	unhide()	{ n_key=0; n_list=0; };		void	use()		{ n_used++; };		void	assign();		void	call()		{ n_used++; };		void	take_addr()	{ n_addr_taken++; };		void	check_oper(Pname);		void	simpl();	};/******************** statements *********************************/	class stmt : public node {	/* BREAK CONTINUE DEFAULT */	/*	IMPORTANT: all statement nodes have sizeof(stmt) */	public:		Pstmt	s;		Pstmt	s_list;		Loc	where;		union {		Pname	d;		Pexpr	e2;		Pstmt	has_default;		int	case_value;		};		union {		Pexpr	e;		bit	own_tbl;		Pstmt	s2;		};		Ptable	memtbl;		union {		Pstmt	for_init;		Pstmt	else_stmt;		Pstmt	case_list;		bit	empty;		};			stmt(TOK, loc, Pstmt);			~stmt();		void	del();		void	print();		void	dcl();		void	reached();		Pstmt	simpl();		Pstmt	expand();		Pstmt	copy();	};extern Pname dcl_temp(Ptable, Pname);extern char* temp(char*, char*, char*);extern Ptable scope;extern Ptable expand_tbl;extern Pname expand_fn;	struct estmt : public stmt	/* SM WHILE DO SWITCH RETURN CASE */		/* SM (e!=0)	=>	e;	   	in particular assignments and function calls	   	SM (e==0)	=>	;	(the null statement)	   	CASE		=>	case e : s ;		*/	{		estmt(TOK t, loc ll, Pexpr ee, Pstmt ss) : (t,ll,ss) { this=0; e=ee; }	};	struct ifstmt : public stmt	/* IF */		// else_stme==0 =>	if (e) s	   	// else_stmt!=0 =>	if (e) s else else_stmt	{		ifstmt(loc ll, Pexpr ee, Pstmt ss1, Pstmt ss2)			: (IF,ll,ss1) { this=0; e=ee; else_stmt=ss2; };	};	struct lstmt : public stmt	/* LABEL GOTO */		/*			d : s			goto d		*/	{		lstmt(TOK bb, loc ll, Pname nn, Pstmt ss) : (bb,ll,ss) { this=0; d=nn; }	};	struct forstmt : public stmt	/* FOR */	{		forstmt(loc ll, Pstmt fss, Pexpr ee1, Pexpr ee2, Pstmt ss)			: (FOR,ll,ss) { this=0; for_init=fss; e=ee1; e2=ee2; }	};	struct block : public stmt 	/* BLOCK */		/* { d s } */	{		block(loc ll, Pname nn, Pstmt ss) : (BLOCK,ll,ss) { this=0; d=nn; }		void	dcl(Ptable);		Pstmt	simpl();	};	struct pair : public stmt	/* PAIR */	{		pair(loc ll, Pstmt a, Pstmt b) : (PAIR,ll,a) { this=0; s2 = b; }	};class nlist {public:	Pname	head;	Pname	tail;		nlist(Pname);	void	add(Pname n)	{ tail->n_list = n; tail = n; };	void	add_list(Pname);};extern Pname name_unlist(nlist*);class slist {public:	Pstmt	head;	Pstmt	tail;		slist(Pstmt s)	{ Nl++; head = tail = s; };	void	add(Pstmt s)	{ tail->s_list = s; tail = s; };};extern Pstmt stmt_unlist(slist*);class elist {public:	Pexpr	head;	Pexpr	tail;		elist(Pexpr e)	{ Nl++; head = tail = e; };	void	add(Pexpr e)	{ tail->e2 = e; tail = e; };};extern Pexpr expr_unlist(elist*);extern class dcl_context * cc;class dcl_context {public:	Pname	c_this;	/* current fct's "this" */	Ptype	tot;	/* type of "this" or 0 */	Pname	not;	/* name of "this"'s class or 0 */	Pclass	cot;	/* the definition of "this"'s class */	Ptable	ftbl;	/* current fct's symbol table */	Pname	nof;	/* current fct's name */	void	stack()		{ cc++; *cc = *(cc-1); };	void	unstack()	{ cc--; };};#define MAXCONT	20extern dcl_context ccvec[MAXCONT];extern bit can_coerce(Ptype, Ptype);extern void yyerror(char*);extern TOK back;		/* "spy" counters: */extern int Nspy;extern int Nfile, Nline, Ntoken, Nname, Nfree_store, Nalloc, Nfree;extern int NFn, NFtn, NFpv, NFbt, NFf, NFs, NFc, NFe, NFl;extern char* line_format;extern Plist isf_list;extern Pstmt st_ilist;extern Pstmt st_dlist;extern Ptable sti_tbl;extern Ptable std_tbl;extern Ptype np_promote(TOK, TOK, TOK, Ptype, Ptype, TOK);extern void new_key(char*, TOK, TOK);extern Pname dcl_list;extern int over_call(Pname, Pexpr);extern Pname Nover;extern Pname Ncoerce;extern Nover_coerce;const MIA = 8;struct iline {	Pname	fct_name;	/* fct called */	Pin	i_next;	Ptable	i_table;	Pname	local[MIA];	/* local variable for arguments */	Pexpr	arg[MIA];	/* actual arguments for call */	Ptype	tp[MIA];	/* type of formal arguments */};extern Pexpr curr_expr;extern Pin curr_icall;#define FUDGE111 111extern Pstmt curr_loop;extern Pblock curr_block;extern Pstmt curr_switch;extern bit arg_err_suppress;extern loc last_line;extern no_of_undcl;extern no_of_badcall;extern Pname undcl, badcall;extern int strlen(char*);extern int strcpy(char*,char*);extern int strcmp(char*,char*);extern int str_to_int(char*);extern int c_strlen(char* s);extern Pname vec_new_fct;extern Pname vec_del_fct;#ifdef DEBUGextern fprintf(FILE*, char* ...);#define DB(a) fprintf a#else#define DB(a) /**/#endifextern Pname find_hidden(Pname);extern TOK lalex();extern int Nstd; // standard coercion used (derived* =>base* or int=>long or ...)extern int stcount;	// number of names generated using make_name()/* end */

⌨️ 快捷键说明

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