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

📄 cfront.h

📁 c 语言编译器 源代码- c compiler
💻 H
📖 第 1 页 / 共 2 页
字号:
/* @(#) cfront.h 1.4 1/27/86 17:48:33 */ /*ident	"@(#)cfront:src/cfront.h	1.4" *//***********************************************************************	C++ source for cfront, the C++ compiler front-end	written in the computer science research center of Bell Labs	Copyright (c) 1984 AT&T, Inc. All Rights Reserved	THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T, INC.	When reading cfront code please remember that C++ was not available	when it was originally written. Out of necessity cfront is written	in a style that takes advantage of only few of C++'s more advanced	features.cfront.h:	Here is all the class definitions for cfront, and most of the externs***********************************************************************//*	WARNING:	This program relies on non-initialized class members being ZERO.	This will be true as long as they are allocated using the "new" operator*/#include "token.h"#include "typedef.h"extern char* prog_name;		/* compiler name and version */extern bit old_fct_accepted;	/* if set:					old style function definitions are legal,					implicit declarations are legal				*/extern bit fct_void;		/* if set:					int f(); ... f(1); gives a warning per file					undeclared(); gives a warning per file				   if not:					int f(); ... f(1); is an error					undeclared(); is an error								(currently only a warning)									*/extern int inline_restr;	/* inline expansion restrictions */ /*	free lists */extern Pname name_free;extern Pexpr expr_free;extern Pstmt stmt_free;extern int Nspy, Nn, Nbt, Nt, Ne, Ns, Nstr, Nc, Nl;extern TOK	lex();extern Pname	syn();extern bit	print_mode;	/* stage initializers: */extern void	init_print();extern void	init_lex();extern void	int_syn();extern void	ext(int);extern char* 	make_name(TOK);class loc	/* a source file location */{public:	short	file;	/* index into file_name[], or zero */	short	line;	void	put(FILE*);	void	putline();};extern Loc curloc;extern int curr_file;overload error;extern int error(int, loc*, char* ...);extern int error(int, char* ...);extern int error(loc*, char* ...);extern int error(char* ...);extern int error_count;extern bit debug;extern Ptype outlined;extern FILE* in_file;extern FILE* out_file;extern char scan_started;extern bit warn;extern int br_level;extern int bl_level;extern Ptable ktbl;		/* keywords and typedef names */extern char*	oper_name(TOK);extern Ptable gtbl;		/* global names */extern Pclass ccl;extern Pbase defa_type;extern Pbase moe_type;extern Pstmt Cstmt;	/* current statement, or 0 */extern Pname Cdcl;	/* name currently being declared, or 0 */extern void put_dcl_context();extern Ptable any_tbl;	/* table of undefined struct members */extern Pbase any_type;extern Pbase int_type;extern Pbase char_type;extern Pbase short_type;extern Pbase long_type;extern Pbase uchar_type;extern Pbase ushort_type;extern Pbase uint_type;extern Pbase ulong_type;extern Ptype Pchar_type;extern Ptype Pint_type;extern Ptype Pfctvec_type;extern Pbase float_type;extern Pbase double_type;extern Pbase void_type;extern Ptype Pvoid_type;extern Pbase zero_type;extern int byte_offset;extern int bit_offset;extern int max_align;extern int stack_size;extern int enum_count;extern int const_save;extern Pname class_name(Ptable,char*,bit);extern Pname gen_find(Pname,Pfct);extern char* gen_name(char*,char);extern Pexpr dummy;	/* the empty expression */extern Pexpr zero;extern Pexpr one;extern Pname sta_name;	/* qualifier for unary :: */#define DEL(p) if (p && (p->permanent==0)) p->del()#define PERM(p) p->permanent=1#define UNPERM(p) p->permanent=0struct node {	TOK	base;	TOK	n_key;	/* for names in table: class */	bit	permanent;};extern Pclass Ebase, Epriv;	/* lookc return values */class table : public node {/*	a table is a node only to give it a "base" for debugging */	short	size;	short	hashsize;	Pname*	entries;	short*	hashtbl;	short	free_slot;	/* next free slot in entries */public:	short	init_stat;	/* ==0 if block(s) of table not simplified,				   ==1 if simplified but had no initializers,				   ==2 if simplified and had initializers.				*/	Pstmt	real_block;	/* the last block the user wrote,				   not one of the ones cfront created				*/		table(short, Ptable, Pname);	Ptable	next;		/* table for enclosing scope */	Pname	t_name;		/* name of the table */	Pname	look(char*, TOK);	Pname	insert(Pname, TOK);	void	grow(int);	void	set_scope(Ptable t)	{ next = t; };	void	set_name(Pname n)	{ t_name = n; };	Pname	get_mem(int);		int	max()		{ return free_slot-1; };	void	dcl_print(TOK,TOK);	Pname	lookc(char*, TOK);	Pexpr	find_name(Pname, bit, Pexpr);	void	del();};extern bit Nold;extern bit vec_const;extern void restore();extern void set_scope(Pname);extern Plist modified_tn;extern Pbase start_cl(TOK, Pname, Pname);extern void end_cl();extern Pbase end_enum(Pname, Pname);/************ types : basic types, aggregates, declarators ************/extern bit new_type;extern Pname cl_obj_vec;extern Pname eobj;#define DEFINED 01	/* definition fed through .dcl() */#define SIMPLIFIED 02	/* in .simpl() */#define DEF_SEEN 04	/* definition seen, but not processed */			/*   used for class members in norm.c */#define IN_ERROR 010struct type : public node {	bit	defined;	/* flags DEF_SEEN, DEFINED, SIMPLIFIED, IN_ERROR					not used systematically yet				*/	void	print();	void	dcl_print(Pname);	void	base_print();	void	del();	Pname	is_cl_obj();	/* sets cl_obj_vec */	int	is_ref();	void	dcl(Ptable);	int	tsizeof();	bit	tconst();	TOK	set_const(bit);	int	align();	TOK	kind(TOK,TOK);	TOK	integral(TOK oo)	{ return kind(oo,I); };	TOK	numeric(TOK oo)		{ return kind(oo,N); };	TOK	num_ptr(TOK oo)		{ return kind(oo,P); };	bit	fct_type();	bit	vec_type();	bit	check(Ptype, TOK);	Ptype	deref();	inline Pptr addrof();	char*	signature(char*);};extern bit vrp_equiv;class enumdef : public type {	/* ENUM */public:	Pname	mem;	bit	e_body;	int	no_of_enumerators;		enumdef(Pname n)	{ base=ENUM; mem=n; };	void	print();	void	dcl_print(Pname);	void	dcl(Pname, Ptable);	void	simpl();};class classdef : public type {	/* CLASS */public:	Pname	clbase;	bit	pubbase;	bit	c_body;		/* print definition only once */	TOK	csu;		/* CLASS, STRUCT, UNION, or ANON */	char*	string;		/* name of class */	Pname	privmem;	Pname	pubmem;	Ptable	memtbl;	short	obj_size;	short	real_size;	/* obj_size - alignment waste */	char	obj_align;	char	bit_ass;	// 1 if no member has operator=()		classdef(TOK, Pname);	void	print();	void	dcl_print(Pname);	void	simpl();	Plist	friend_list;	Pname	pubdef;	Plist	tn_list;	// list of member names hiding type names	Pclass	in_class;	/* enclosing class, or 0 */	Ptype	this_type;	char	virt_count;	/* number of virtual functions					incl. virtuals in base classes				*/	Pname*	virt_init;	/* vector of jump table initializers */	Pname	itor;		/* constructor X(X&) */	Pname	conv;		/* operator T() chain */	void	print_members();	void	dcl(Pname, Ptable);	bit	has_friend(Pname);	TOK	is_simple()	{ return (csu==CLASS)?0:csu; };	Pname	has_oper(TOK);	Pname	has_ctor()	{ return memtbl->look("_ctor",0); }	Pname	has_dtor()	{ return memtbl->look("_dtor",0); }	Pname	has_itor()	{ return itor; }	Pname	has_ictor();};class basetype : public type	/*	ZTYPE CHAR SHORT INT LONG FLOAT DOUBLE		FIELD EOBJ COBJ TYPE ANY	*/	/*	used for gathering all the attributes		for a list of declarators		ZTYPE is the (generic) type of ZERO		ANY is the generic type of an undeclared name	*/{public:	bit	b_unsigned;	bit	b_const;	bit	b_typedef;	bit	b_inline;	bit	b_virtual;	bit	b_short;	bit	b_long;	char	b_offset;	TOK	b_sto;		/* AUTO STATIC EXTERN REGISTER 0 */	Pname	b_name;		/* name of non-basic type */	Pexpr	b_field; 	/* field size expression for a field */	char	b_bits;		/* number of bits in field */	Ptable	b_table;	/* memtbl for b_name, or 0 */	union {	Pname	b_xname;	/* extra name */	Ptype	b_fieldtype;	};		basetype(TOK, Pname);	Pbase	type_adj(TOK);	Pbase	base_adj(Pbase);	Pbase	name_adj(Pname);	Pbase	check(Pname);	Pname   aggr();	void	normalize();	void	dcl_print(); 	Pbase	arit_conv(Pbase);};struct fct : public type		/* FCT */{	Ptype	returns;	Pname	argtype;	Ptype	s_returns;	Pname	f_this;	Pblock	body;	Pname	f_init;		/* base/member initializers				   null name => base class init;				   ids => member classes (with ctors)				*/	Pexpr	b_init;		/* base class initializer				   ctor call after fct.dcl()				*/	short	frame_size;	TOK	nargs;	TOK	nargs_known;	/* KNOWN, ELLIPSIS, or 0 */	char	f_virtual;	/* 1+index in virtual table, or 0 */	char	f_inline;	/* 1 if inline, 2 if being expanded, else 0 */	Pexpr	f_expr;		/* body expanded into an expression */	Pexpr	last_expanded;		fct(Ptype, Pname, TOK);	void	argdcl(Pname,Pname);	Ptype	normalize(Ptype);	void	dcl_print();	void	dcl(Pname);	Pexpr	base_init(Pname, Pexpr, Ptable);	Pexpr	mem_init(Pname, Pexpr, Ptable);	bit	declared() { return nargs_known; };	void	simpl();	Pexpr	expand(Pname,Ptable,Pexpr);};struct name_list {	Pname	f;	Plist	l;		name_list(Pname ff, Plist ll) { f=ff; l=ll; };};struct gen: public type		/* OVERLOAD */{	Plist	fct_list;	char*	string;		gen(char*);	Pname	add(Pname, int);	Pname  	find(Pfct);};struct vec : public type		/* VEC */	/*	typ [ dim ] */{	Ptype	typ;

⌨️ 快捷键说明

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