📄 fend.c
字号:
break; }# endif PC if ((p->nl_flags & NMOD) == 0) { warning(); nerror("%s %s is used but never set", classes[p->class], p->symbol); break; } case LABEL: case FVAR: case BADUSE: break; } switch (p->class) { case BADUSE: cp = "s"; /* This used to say ud_next that is not a member of nl so i changed it to nl_next, which may be wrong */ if (p->chain->nl_next == NIL) cp++; eholdnl(); if (p->value[NL_KINDS] & ISUNDEF) nerror("%s undefined on line%s", p->symbol, cp); else nerror("%s improperly used on line%s", p->symbol, cp); pnumcnt = 10; pnums((struct udinfo *) p->chain); pchr('\n'); break; case FUNC: case PROC:# ifdef OBJ if ((p->nl_flags & NFORWD)) nerror("Unresolved forward declaration of %s %s", classes[p->class], p->symbol);# endif OBJ# ifdef PC if ((p->nl_flags & NFORWD) && ((p->extra_flags & NEXTERN) == 0)) nerror("Unresolved forward declaration of %s %s", classes[p->class], p->symbol);# endif PC break; case LABEL: if (p->nl_flags & NFORWD) nerror("label %s was declared but not defined", p->symbol); break; case FVAR: if ((p->nl_flags & NMOD) == 0) nerror("No assignment to the function variable"); break; } } /* * Pop this symbol * table slot */ disptab[i] = p; }# ifdef OBJ (void) put(1, O_END);# endif OBJ# ifdef PC fp_exitcode(&eecookie); stabrbrac(cbn); putrbracket(ftnno); fp_epilogue(&eecookie); if (fp -> class != PROG) { fp_formalentry(&eecookie); } /* * declare pcp counters, if any */ if ( monflg && fp -> class == PROG ) { putprintf( " .data" , 0 ); aligndot(PCCT_INT); putprintf( " .comm " , 1 ); putprintf( PCPCOUNT , 1 ); putprintf( ",%d" , 0 , ( cnts + 1 ) * sizeof (long) ); putprintf( " .text" , 0 ); }# endif PC#ifdef DEBUG dumpnl(fp->ptr[2], (int) fp->symbol);#endif#ifdef OBJ /* * save the namelist for the debugger pdx */ savenl(fp->ptr[2], (int) fp->symbol);#endif /* * Restore the * (virtual) name list * position */ nlfree(fp->ptr[2]); /* * Proc/func has been * resolved */ fp->nl_flags &= ~NFORWD; /* * Patch the beg * of the proc/func to * the proper variable size */ if (Fp == NIL) elineon();# ifdef OBJ patchfil((PTR_DCL) var, roundup(-sizes[cbn].om_max, (long) A_STACK), 2);# endif OBJ cbn--; if (inpflist(fp->symbol)) { opop('l'); }}#ifdef PC /* * construct the long name of a function based on it's static nesting. * into a caller-supplied buffer (that should be about BUFSIZ big). */sextname( buffer , name , level ) char buffer[]; char *name; int level;{ char *starthere; int i; starthere = &buffer[0]; for ( i = 1 ; i < level ; i++ ) { sprintf( starthere , EXTFORMAT , enclosing[ i ] ); starthere += strlen( enclosing[ i ] ) + 1; } sprintf( starthere , EXTFORMAT , name ); starthere += strlen( name ) + 1; if ( starthere >= &buffer[ BUFSIZ ] ) { panic( "sextname" ); }} /* * code for main() */#ifdef vaxcodeformain(){ putprintf(" .text" , 0 ); putprintf(" .align 1" , 0 ); putprintf(" .globl _main" , 0 ); putprintf("_main:" , 0 ); putprintf(" .word 0" , 0 ); if ( opt ( 't' ) ) { putprintf(" pushl $1" , 0 ); } else { putprintf(" pushl $0" , 0 ); } putprintf(" calls $1,_PCSTART" , 0 ); putprintf(" movl 4(ap),__argc" , 0 ); putprintf(" movl 8(ap),__argv" , 0 ); putprintf(" calls $0,_program" , 0 ); putprintf(" pushl $0" , 0 ); putprintf(" calls $1,_PCEXIT" , 0 );}#endif vax#ifdef tahoecodeformain(){ putprintf(" .text" , 0 ); putprintf(" .align 1" , 0 ); putprintf(" .globl _main" , 0 ); putprintf("_main:" , 0 ); putprintf(" .word 0" , 0 ); if ( opt ( 't' ) ) { putprintf(" pushl $1" , 0 ); } else { putprintf(" pushl $0" , 0 ); } putprintf(" callf $8,_PCSTART" , 0 ); putprintf(" movl 4(fp),__argc" , 0 ); putprintf(" movl 8(fp),__argv" , 0 ); putprintf(" callf $4,_program" , 0 ); putprintf(" pushl $0" , 0 ); putprintf(" callf $8,_PCEXIT" , 0 );}#endif tahoe /* * prologue for the program. * different because it * doesn't have formal entry point */#if defined(vax) || defined(tahoe) prog_prologue(eecookiep) struct entry_exit_cookie *eecookiep;{ putprintf(" .text" , 0 ); putprintf(" .align 1" , 0 ); putprintf(" .globl _program" , 0 ); putprintf("_program:" , 0 ); /* * register save mask */ eecookiep -> savlabel = (int) getlab(); putprintf(" .word %s%d", 0, (int) SAVE_MASK_LABEL , eecookiep -> savlabel );}fp_prologue(eecookiep) struct entry_exit_cookie *eecookiep;{ sextname( eecookiep -> extname, eecookiep -> nlp -> symbol , cbn - 1 ); putprintf( " .text" , 0 ); putprintf( " .align 1" , 0 ); putprintf( " .globl %s%s", 0, (int) FORMALPREFIX, (int) eecookiep -> extname ); putprintf( " .globl %s" , 0 , (int) eecookiep -> extname ); putprintf( "%s:" , 0 , (int) eecookiep -> extname ); /* * register save mask */ eecookiep -> savlabel = (int) getlab(); putprintf(" .word %s%d", 0, (int) SAVE_MASK_LABEL , eecookiep -> savlabel );}#endif vax || tahoe /* * code before any user code. * or code that is machine dependent. */#ifdef vaxfp_entrycode(eecookiep) struct entry_exit_cookie *eecookiep;{ int ftnno = eecookiep -> nlp -> value[NL_ENTLOC]; int proflabel = (int) getlab(); int setjmp0 = (int) getlab(); /* * top of code; destination of jump from formal entry code. */ eecookiep -> toplabel = (int) getlab(); (void) putlab( (char *) eecookiep -> toplabel ); putprintf(" subl2 $%s%d,sp" , 0 , (int) FRAME_SIZE_LABEL, ftnno ); if ( profflag ) { /* * call mcount for profiling */ putprintf( " moval " , 1 ); putprintf( PREFIXFORMAT , 1 , (int) LABELPREFIX , proflabel ); putprintf( ",r0" , 0 ); putprintf( " jsb mcount" , 0 ); putprintf( " .data" , 0 ); putprintf( " .align 2" , 0 ); (void) putlab( (char *) proflabel ); putprintf( " .long 0" , 0 ); putprintf( " .text" , 0 ); } /* * if there are nested procedures that access our variables * we must save the display. */ if ( parts[ cbn ] & NONLOCALVAR ) { /* * save old display */ putprintf( " movq %s+%d,%d(%s)" , 0 , (int) DISPLAYNAME , cbn * sizeof(struct dispsave) , DSAVEOFFSET , (int) P2FPNAME ); /* * set up new display by saving AP and FP in appropriate * slot in display structure. */ putprintf( " movq %s,%s+%d" , 0 , (int) P2APNAME , (int) DISPLAYNAME , cbn * sizeof(struct dispsave) ); } /* * set underflow checking if runtime tests */ if ( opt( 't' ) ) { putprintf( " bispsw $0xe0" , 0 ); } /* * zero local variables if checking is on * by calling blkclr( bytes of locals , starting local address ); */ if ( opt( 't' ) && ( -sizes[ cbn ].om_max ) > DPOFF1 ) { putleaf( PCC_ICON , 0 , 0 , PCCM_ADDTYPE( PCCTM_FTN | PCCT_INT , PCCTM_PTR ) , "_blkclr" ); putLV((char *) 0 , cbn , (int) sizes[ cbn ].om_max , NLOCAL , PCCT_CHAR ); putleaf( PCC_ICON , (int) (( -sizes[ cbn ].om_max ) - DPOFF1) , 0 , PCCT_INT ,(char *) 0 ); putop( PCC_CM , PCCT_INT ); putop( PCC_CALL , PCCT_INT ); putdot( filename , line ); } /* * set up goto vector if non-local goto to this frame */ if ( parts[ cbn ] & NONLOCALGOTO ) { putleaf( PCC_ICON , 0 , 0 , PCCM_ADDTYPE( PCCTM_FTN | PCCT_INT , PCCTM_PTR ) , "_setjmp" ); putLV( (char *) 0 , cbn , GOTOENVOFFSET , NLOCAL , PCCTM_PTR|PCCT_STRTY ); putop( PCC_CALL , PCCT_INT ); putleaf( PCC_ICON , 0 , 0 , PCCT_INT , (char *) 0 ); putop( PCC_NE , PCCT_INT ); putleaf( PCC_ICON , setjmp0 , 0 , PCCT_INT , (char *) 0 ); putop( PCC_CBRANCH , PCCT_INT ); putdot( filename , line ); /* * on non-local goto, setjmp returns with address to * be branched to. */ putprintf( " jmp (r0)" , 0 ); (void) putlab((char *) setjmp0); }}#endif vax#ifdef tahoefp_entrycode(eecookiep) struct entry_exit_cookie *eecookiep;{ int ftnno = eecookiep -> nlp -> value[NL_ENTLOC]; int proflabel = (int) getlab(); int setjmp0 = (int) getlab(); /* * top of code; destination of jump from formal entry code. */ eecookiep -> toplabel = (int) getlab(); (void) putlab( (char *) eecookiep -> toplabel ); putprintf(" subl3 $%s%d,fp,sp" , 0 , (int) FRAME_SIZE_LABEL, ftnno ); if ( profflag ) { /* * call mcount for profiling */ putprintf( " pushal " , 1 ); putprintf( PREFIXFORMAT , 0 , (int) LABELPREFIX , proflabel ); putprintf( " callf $8,mcount" , 0 ); putprintf( " .data" , 0 ); putprintf( " .align 2" , 0 ); (void) putlab( (char *) proflabel ); putprintf( " .long 0" , 0 ); putprintf( " .text" , 0 ); } /* * if there are nested procedures that access our variables * we must save the display. */ if ( parts[ cbn ] & NONLOCALVAR ) { /* * save old display */ putprintf( " movl %s+%d,%d(%s)" , 0 , (int) DISPLAYNAME , cbn * sizeof(struct dispsave) , DSAVEOFFSET , (int) P2FPNAME ); /* * set up new display by saving FP in appropriate * slot in display structure. */ putprintf( " movl %s,%s+%d" , 0 , (int) P2FPNAME , (int) DISPLAYNAME , cbn * sizeof(struct dispsave) ); } /* * set underflow checking if runtime tests */ if ( opt( 't' ) ) { putprintf( " bicpsw $0x20" , 0 ); } /* * zero local variables if checking is on * by calling blkclr( bytes of locals , starting local address ); */ if ( opt( 't' ) && ( -sizes[ cbn ].om_max ) > DPOFF1 ) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -