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

📄 pftn.c

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 C
📖 第 1 页 / 共 4 页
字号:
 			SETOFF( argoff, ALSTACK );	/* slr001 restore alignment */		}	cendarg();	locctr(PROG);	defalign(ALINT);	ftnno = getlab();	bfcode( paramstk, paramno );	paramno = 0;	}NODE *rstruct( idn, soru, typattr ){ /* reference to a structure or union, 				  with no definition */	register struct symtab *p;	register NODE *q;	p = &stab[idn];	switch( p->stype ){	case UNDEF:	def:		q = block( FREE, NIL, NIL, 0, 0, 0 );		q->tn.rval = idn;		q->in.type = (soru&INSTRUCT) ? STRTY : ( (soru&INUNION) ? UNIONTY : ENUMTY );		q->in.typattr = typattr;		defid( q, (soru&INSTRUCT) ? STNAME : ( (soru&INUNION) ? UNAME : ENAME ) );		break;	case STRTY:		if( soru & INSTRUCT ) break;		goto def;	case UNIONTY:		if( soru & INUNION ) break;		goto def;	case ENUMTY:		if( !(soru&(INUNION|INSTRUCT)) ) break;		goto def;		}	stwart = instruct;	return( mkty( p->stype, 0, p->sizoff ) );	}moedef( idn ){	register NODE *q;	q = block( FREE, NIL, NIL, MOETY, 0, 0 );	q->tn.rval = idn;	if( idn>=0 ) defid( q, MOE );	}bstruct( idn, soru, typattr ){ /* begining of structure/union declaration */	register NODE *q;	psave( instruct );	psave( typattr );	psave( curclass );	psave( strucoff );	strucoff = 0;	instruct = soru;	q = block( FREE, NIL, NIL, 0, 0, 0 );	q->tn.rval = idn;	if( instruct==INSTRUCT ){		curclass = MOS;		q->in.type = STRTY;		if( idn >= 0 ) defid( q, STNAME );		}	else if( instruct == INUNION ) {		curclass = MOU;		q->in.type = UNIONTY;		if( idn >= 0 ) defid( q, UNAME );		}	else { /* enum */		curclass = MOE;		q->in.type = ENUMTY;		if( idn >= 0 ) defid( q, ENAME );		}	psave( idn = q->tn.rval );	/* the "real" definition is where the members are seen */	if ( idn >= 0 ) {	    stab[idn].suse = lineno;	    stab[idn].stypattr = typattr;	}	return( paramno-5 );	}NODE *dclstruct( oparam ){	register struct symtab *p;	register i, al, sa, j, sz, szindex;	register TWORD temp, typattr;	register high, low;	/* paramstack contains:		paramstack[ oparam ] = previous instruct		paramstack[ oparam+1 ] = type attributes		paramstack[ oparam+2 ] = previous class		paramstk[ oparam+3 ] = previous strucoff		paramstk[ oparam+4 ] = structure name		paramstk[ oparam+5, ... ]  = member stab indices		*/	if( (i=paramstk[oparam+4]) < 0 ){		szindex = curdim;		dstash( 0 );  /* size */		dstash( -1 );  /* index to member names */		dstash( ALSTRUCT );  /* alignment */		dstash( -lineno );	/* name of structure */		}	else {		szindex = stab[i].sizoff;		}# ifndef BUG1	if( ddebug ){#ifndef FLEXNAMES		printf( "dclstruct( %.8s ), szindex = %d\n", (i>=0)? stab[i].sname : "??", szindex );#else		printf( "dclstruct( %s ), szindex = %d\n", (i>=0)? stab[i].sname : "??", szindex );#endif		}# endif	temp = (instruct&INSTRUCT)?STRTY:((instruct&INUNION)?UNIONTY:ENUMTY);	stwart = instruct = paramstk[ oparam ];	typattr = paramstk[oparam+1];	curclass = paramstk[ oparam+2 ];	dimtab[ szindex+1 ] = curdim;	al = ALSTRUCT;	high = low = 0;	for( i = oparam+5;  i< paramno; ++i ){		dstash( j=paramstk[i] );		if( j<0 || j>= SYMTSZ ) cerror( "gummy structure member" );		p = &stab[j];		p->stypattr |= typattr;		if( temp == ENUMTY ){			if( p->offset < low ) low = p->offset;			if( p->offset > high ) high = p->offset;			p->sizoff = szindex;			continue;			}		sa = talign( p->stype, p->sizoff );		if( p->sclass & FIELD ){			sz = p->sclass&FLDSIZ;			}		else {			sz = tsize( p->stype, p->dimoff, p->sizoff );			}		if( sz == 0 ){#ifndef FLEXNAMES			werror( "illegal zero sized structure member: %.8s", p->sname );#else			werror( "illegal zero sized structure member: %s", p->sname );#endif			}		if( sz > strucoff ) strucoff = sz;  /* for use with unions */		SETOFF( al, sa );		/* set al, the alignment, to the lcm of the alignments of the members */		}	dstash( -1 );  /* endmarker */	SETOFF( strucoff, al );	if( temp == ENUMTY ){		register TWORD ty;# ifdef ENUMSIZE		ty = ENUMSIZE(high,low);# else		if( (char)high == high && (char)low == low ) ty = ctype( CHAR );		else if( (short)high == high && (short)low == low ) ty = ctype( SHORT );		else ty = ctype(INT);#endif		strucoff = tsize( ty, 0, (int)ty );		dimtab[ szindex+2 ] = al = talign( ty, (int)ty );		}	if( strucoff == 0 ) uerror( "zero sized structure" );	dimtab[ szindex ] = strucoff;	dimtab[ szindex+2 ] = al;	dimtab[ szindex+3 ] = paramstk[ oparam+4 ];  /* name index */	FIXSTRUCT( szindex, oparam ); /* local hook, eg. for sym debugger */# ifndef BUG1	if( ddebug>1 ){		printf( "\tdimtab[%d,%d,%d] = %d,%d,%d\n", szindex,szindex+1,szindex+2,				dimtab[szindex],dimtab[szindex+1],dimtab[szindex+2] );		for( i = dimtab[szindex+1]; dimtab[i] >= 0; ++i ){#ifndef FLEXNAMES			printf( "\tmember %.8s(%d)\n", stab[dimtab[i]].sname, dimtab[i] );#else			printf( "\tmember %s(%d)\n", stab[dimtab[i]].sname, dimtab[i] );#endif			}		}# endif	strucoff = paramstk[ oparam+3 ];	paramno = oparam;	return( mkty( temp, 0, szindex ) );	}	/* VARARGS */yyerror( s ) char *s; { /* error printing routine in parser */	uerror( s );	}yyaccpt(){	ftnend();	}ftnarg( idn ) {	switch( stab[idn].stype ){	case UNDEF:		/* this parameter, entered at scan */		break;	case FARG:#ifndef FLEXNAMES		uerror("redeclaration of formal parameter, %.8s",#else		uerror("redeclaration of formal parameter, %s",#endif			stab[idn].sname);		/* fall thru */	case FTN:		/* the name of this function matches parm */		/* fall thru */	default:		idn = hide( &stab[idn]);		break;	case TNULL:		/* unused entry, fill it */		;		}	stab[idn].stype = FARG;	stab[idn].sclass = PARAM;	psave( idn );	}talign( ty, s) register unsigned ty; register s; {	/* compute the alignment of an object with type ty, sizeoff index s */	register i;	if( s<0 && ty!=INT && ty!=CHAR && ty!=SHORT && ty!=UNSIGNED && ty!=UCHAR && ty!=USHORT #ifdef LONGFIELDS		&& ty!=LONG && ty!=ULONG#endif					){		return( fldal( ty ) );		}	for( i=0; i<=(SZINT-BTSHIFT-1); i+=TSHIFT ){		switch( (ty>>i)&TMASK ){		case FTN:			cerror( "compiler takes alignment of function");		case PTR:			return( ALPOINT );		case ARY:			continue;		case 0:			break;			}		}	switch( BTYPE(ty) ){	case UNIONTY:	case ENUMTY:	case STRTY:		return( (unsigned int) dimtab[ s+2 ] );	case CHAR:	case UCHAR:		return( ALCHAR );	case FLOAT:		return( ALFLOAT );	case DOUBLE:		return( ALDOUBLE );	case LONG:	case ULONG:		return( ALLONG );	case SHORT:	case USHORT:		return( ALSHORT );	default:		return( ALINT );		}	}OFFSZtsize( ty, d, s )  TWORD ty; {	/* compute the size associated with type ty,	    dimoff d, and sizoff s */	/* BETTER NOT BE CALLED WHEN t, d, and s REFER TO A BIT FIELD... */	int i;	OFFSZ mult;	mult = 1;	for( i=0; i<=(SZINT-BTSHIFT-1); i+=TSHIFT ){		switch( (ty>>i)&TMASK ){		case FTN:			cerror( "compiler takes size of function");		case PTR:			return( SZPOINT * mult );		case ARY:			mult *= (unsigned int) dimtab[ d++ ];			continue;		case 0:			break;			}		}	if( dimtab[s]==0 ) {		uerror( "unknown size");		return( SZINT );		}	return( (unsigned int) dimtab[ s ] * mult );	}inforce( n ) OFFSZ n; {  /* force inoff to have the value n */	/* inoff is updated to have the value n */	OFFSZ wb;	register rest;	/* rest is used to do a lot of conversion to ints... */	if( inoff == n ) return;	if( inoff > n )	{		inoff = n;							/* make it object only once */		werror( "attempt to initialize past end of object" );		return;/* was:	cerror( "initialization alignment error"); /* fix qar 4654 & 4556 */		}	wb = inoff;	SETOFF( wb, SZINT );	/* wb now has the next higher word boundary */	if( wb >= n ){ /* in the same word */		rest = n - inoff;		vfdzero( rest );		return;		}	/* otherwise, extend inoff to be word aligned */	rest = wb - inoff;	vfdzero( rest );	/* now, skip full words until near to n */	rest = (n-inoff)/SZINT;	zecode( rest );	/* now, the remainder of the last word */	rest = n-inoff;	vfdzero( rest );	if( inoff != n ) cerror( "inoff error");	}vfdalign( n ){ /* make inoff have the offset the next alignment of n */	OFFSZ m;	m = inoff;	SETOFF( m, n );	inforce( m );	}int idebug = 0;int ibseen = 0;  /* the number of } constructions which have been filled */int iclass;  /* storage class of thing being initialized */int ilocctr = 0;  /* location counter for current initialization */beginit(curid){	/* beginning of initilization; set location ctr and set type */	register struct symtab *p;# ifndef BUG1	if( idebug >= 3 ) printf( "beginit(), curid = %d\n", curid );# endif	p = &stab[curid];	iclass = p->sclass;	if( curclass == EXTERN || curclass == FORTRAN ) iclass = EXTERN;	switch( iclass ){	case UNAME:	case EXTERN:		return;	case AUTO:	case REGISTER:		break;	case EXTDEF:	case STATIC:		if (ISRODATA(p->stypattr, p->stype)) {		    ilocctr = RODATA;		} else {		    ilocctr = ISARY(p->stype)?ADATA:DATA;		}		locctr( ilocctr );		defalign( talign( p->stype, p->sizoff ) );		defnam( p );		}	inoff = 0;	ibseen = 0;	pstk = 0;	instk( curid, p->stype, p->dimoff, p->sizoff, inoff );	}instk( id, t, d, s, off ) OFFSZ off; TWORD t; {	/* make a new entry on the parameter stack to initialize id */	register struct symtab *p;	for(;;){# ifndef BUG1		if( idebug ) printf( "instk((%d, %o,%d,%d, %d)\n", id, t, d, s, off );# endif		/* save information on the stack */		if( !pstk ) pstk = instack;		else ++pstk;		pstk->in_fl = 0;	/* { flag */		pstk->in_id =  id ;		pstk->in_t =  t ;		pstk->in_d =  d ;		pstk->in_s =  s ;		pstk->in_n = 0;  /* number seen */		pstk->in_x =  t==STRTY ?dimtab[s+1] : 0 ;		pstk->in_off =  off;   /* offset at the beginning of this element */		/* if t is an array, DECREF(t) can't be a field */		/* INS_sz has size of array elements, and -size for fields */		if( ISARY(t) ){			pstk->in_sz = tsize( DECREF(t), d+1, s );			}		else if( stab[id].sclass & FIELD ){			pstk->in_sz = - ( stab[id].sclass & FLDSIZ );			}		else {			pstk->in_sz = 0;			}		if( (iclass==AUTO || iclass == REGISTER ) &&			(ISARY(t) || t==STRTY) ) uerror( "no automatic aggregate initialization" );		/* now, if this is not a scalar, put on another element */		if( ISARY(t) ){			t = DECREF(t);			++d;			continue;			}		else if( t == STRTY ){			id = dimtab[pstk->in_x];			p = &stab[id];			if( p->sclass != MOS && !(p->sclass&FIELD) ) cerror( "insane structure member list" );			t = p->stype;			d = p->dimoff;			s = p->sizoff;			off += p->offset;			continue;			}		else return;		}	}NODE *getstr(){ /* decide if the string is external or an initializer, and get the contents accordingly */	register l, temp;	register NODE *p;	if( (iclass==EXTDEF||iclass==STATIC) && (pstk->in_t == CHAR || pstk->in_t == UCHAR) &&			pstk!=instack && ISARY( pstk[-1].in_t ) ){		/* treat "abc" as { 'a', 'b', 'c', 0 } */		strflg = 1;		ilbrace();  /* simulate { */		inforce( pstk->in_off );		/* if the array is inflexible (not top level), pass in the size and			be prepared to throw away unwanted initializers */		lxstr((pstk-1)!=instack?dimtab[(pstk-1)->in_d]:0);  /* get the contents */		irbrace();  /* simulate } */		return( NIL );		}	else { /* make a label, and get the contents and stash them away */		if( iclass != SNULL ){ /* initializing */			/* fill out previous word, to permit pointer */			vfdalign( ALPOINT );			}		temp = locctr( blevel==0?ISTRNG:STRNG ); /* set up location counter */		deflab( l = getlab() );		strflg = 0;		lxstr(0); /* get the contents */		locctr( blevel==0?ilocctr:temp );		p = buildtree( STRING, NIL, NIL );		p->tn.rval = -l;		return(p);		}	}putbyte( v ){ /* simulate byte v appearing in a list of integer values */	register NODE *p;	p = bcon(v);	incode( p, SZCHAR );	tfree( p );	gotscal();	}endinit(){	register TWORD t;	register d, s, n, d1;# ifndef BUG1	if( idebug ) printf( "endinit(), inoff = %d\n", inoff );# endif	switch( iclass ){	case EXTERN:	case AUTO:	case REGISTER:		return;		}

⌨️ 快捷键说明

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