Annotation of researchv10no/cmd/ccom/vax/pftn.i, revision 1.1

1.1     ! root        1: 
        !             2: 
        !             3: 
        !             4: 
        !             5: 
        !             6: 
        !             7: 
        !             8: 
        !             9: 
        !            10: 
        !            11: 
        !            12: 
        !            13: 
        !            14: 
        !            15: 
        !            16: 
        !            17: 
        !            18: 
        !            19: 
        !            20: 
        !            21: 
        !            22: 
        !            23: 
        !            24: 
        !            25: 
        !            26: 
        !            27:        
        !            28: 
        !            29: 
        !            30: 
        !            31: 
        !            32: 
        !            33: 
        !            34: 
        !            35:        
        !            36: 
        !            37:        
        !            38: 
        !            39:        
        !            40: 
        !            41: 
        !            42: 
        !            43: 
        !            44: 
        !            45:        
        !            46: 
        !            47:        
        !            48: 
        !            49:        
        !            50: 
        !            51:        
        !            52: 
        !            53: 
        !            54: 
        !            55: 
        !            56: 
        !            57: 
        !            58: 
        !            59:        
        !            60: 
        !            61: 
        !            62: 
        !            63: 
        !            64: 
        !            65: 
        !            66: 
        !            67: 
        !            68: 
        !            69: 
        !            70: 
        !            71: 
        !            72: 
        !            73: 
        !            74: 
        !            75: 
        !            76: 
        !            77: 
        !            78: 
        !            79: extern struct  _iobuf {
        !            80:        int     _cnt;
        !            81:        unsigned char   *_ptr;
        !            82:        unsigned char   *_base;
        !            83:        short   _flag;
        !            84:        char    _file;
        !            85: } _iob[120];
        !            86: 
        !            87: 
        !            88: 
        !            89: 
        !            90: 
        !            91: 
        !            92: 
        !            93: 
        !            94: 
        !            95: 
        !            96: 
        !            97: 
        !            98: 
        !            99: 
        !           100: 
        !           101: 
        !           102: 
        !           103: 
        !           104: 
        !           105: 
        !           106: 
        !           107: 
        !           108: 
        !           109: 
        !           110: 
        !           111: 
        !           112: struct _iobuf  *fopen();
        !           113: struct _iobuf  *fdopen();
        !           114: struct _iobuf  *freopen();
        !           115: struct _iobuf  *popen();
        !           116: long   ftell();
        !           117: char   *fgets();
        !           118: 
        !           119: 
        !           120: 
        !           121: 
        !           122: 
        !           123: 
        !           124:        
        !           125: 
        !           126: 
        !           127: 
        !           128: 
        !           129: 
        !           130: 
        !           131: 
        !           132: 
        !           133: 
        !           134: 
        !           135: 
        !           136: 
        !           137: 
        !           138: 
        !           139: 
        !           140: 
        !           141: 
        !           142: 
        !           143: 
        !           144: 
        !           145: 
        !           146: 
        !           147: 
        !           148: 
        !           149: 
        !           150: 
        !           151: 
        !           152: 
        !           153: 
        !           154: 
        !           155: 
        !           156: 
        !           157: 
        !           158: 
        !           159: 
        !           160: 
        !           161: 
        !           162: 
        !           163: 
        !           164: 
        !           165: 
        !           166: 
        !           167: 
        !           168: 
        !           169: 
        !           170: 
        !           171: 
        !           172: 
        !           173: 
        !           174: 
        !           175: 
        !           176: 
        !           177: 
        !           178: 
        !           179: 
        !           180: 
        !           181: 
        !           182: 
        !           183: 
        !           184: 
        !           185: 
        !           186: 
        !           187: 
        !           188: 
        !           189: 
        !           190: 
        !           191: 
        !           192: 
        !           193: 
        !           194: 
        !           195: 
        !           196: 
        !           197: 
        !           198: 
        !           199: 
        !           200: 
        !           201: 
        !           202: 
        !           203: 
        !           204: 
        !           205: 
        !           206: 
        !           207: 
        !           208: 
        !           209: 
        !           210: 
        !           211: 
        !           212: 
        !           213: 
        !           214: 
        !           215: 
        !           216: 
        !           217: 
        !           218: 
        !           219: 
        !           220: 
        !           221: 
        !           222: 
        !           223: 
        !           224: 
        !           225: 
        !           226: 
        !           227:        
        !           228: 
        !           229: 
        !           230: 
        !           231: 
        !           232: 
        !           233: 
        !           234: 
        !           235: 
        !           236: 
        !           237: 
        !           238: 
        !           239: 
        !           240: 
        !           241: 
        !           242: 
        !           243: 
        !           244: 
        !           245: 
        !           246: 
        !           247: 
        !           248: 
        !           249: 
        !           250: 
        !           251: 
        !           252: 
        !           253: 
        !           254: 
        !           255: 
        !           256: 
        !           257: 
        !           258: 
        !           259: 
        !           260: 
        !           261: 
        !           262: 
        !           263: 
        !           264: 
        !           265: 
        !           266: 
        !           267: 
        !           268: 
        !           269: 
        !           270: 
        !           271: 
        !           272: 
        !           273: 
        !           274: 
        !           275: 
        !           276: 
        !           277: 
        !           278: 
        !           279: 
        !           280: 
        !           281: 
        !           282: 
        !           283: 
        !           284: 
        !           285: 
        !           286: 
        !           287: 
        !           288: 
        !           289: 
        !           290: 
        !           291: 
        !           292: 
        !           293: 
        !           294: 
        !           295: 
        !           296: 
        !           297: 
        !           298: 
        !           299: 
        !           300: 
        !           301: 
        !           302: 
        !           303: 
        !           304: 
        !           305: 
        !           306: 
        !           307: 
        !           308: 
        !           309: 
        !           310: 
        !           311: 
        !           312: 
        !           313: 
        !           314: 
        !           315:        
        !           316: 
        !           317: 
        !           318: 
        !           319: 
        !           320: 
        !           321: 
        !           322: 
        !           323: 
        !           324: 
        !           325: 
        !           326: 
        !           327: 
        !           328: 
        !           329: 
        !           330: 
        !           331: 
        !           332: 
        !           333: 
        !           334: 
        !           335: 
        !           336: 
        !           337: 
        !           338: 
        !           339: 
        !           340: 
        !           341: 
        !           342: 
        !           343: 
        !           344: 
        !           345: 
        !           346: 
        !           347: 
        !           348: 
        !           349: 
        !           350: 
        !           351: 
        !           352: 
        !           353: 
        !           354: 
        !           355: 
        !           356: 
        !           357: 
        !           358: 
        !           359: 
        !           360: 
        !           361: 
        !           362: 
        !           363: 
        !           364: 
        !           365:        
        !           366: 
        !           367: 
        !           368: 
        !           369: 
        !           370: 
        !           371: 
        !           372: 
        !           373: 
        !           374: 
        !           375: 
        !           376: 
        !           377: 
        !           378: 
        !           379: 
        !           380: 
        !           381:                
        !           382: 
        !           383:        
        !           384:        
        !           385: 
        !           386: 
        !           387: 
        !           388: 
        !           389: 
        !           390: 
        !           391: 
        !           392: 
        !           393: 
        !           394: 
        !           395: 
        !           396: 
        !           397: 
        !           398: 
        !           399: 
        !           400: 
        !           401: 
        !           402: 
        !           403: 
        !           404: 
        !           405: 
        !           406: 
        !           407: 
        !           408: 
        !           409: 
        !           410: 
        !           411: 
        !           412: 
        !           413: 
        !           414: 
        !           415: 
        !           416: 
        !           417: 
        !           418: 
        !           419: 
        !           420: 
        !           421: 
        !           422: 
        !           423: 
        !           424: 
        !           425: 
        !           426: 
        !           427: 
        !           428: 
        !           429: 
        !           430: 
        !           431: 
        !           432:        char            *hash();
        !           433:        char            *savestr();
        !           434:        char            *tstr();
        !           435:        extern int      tstrused;
        !           436:        extern char     *tstrbuf[];
        !           437:        extern char     **curtstr;
        !           438: 
        !           439: 
        !           440: 
        !           441: 
        !           442: 
        !           443: 
        !           444: extern int nerrors;  
        !           445: 
        !           446: typedef union ndu NODE;
        !           447: typedef unsigned int TWORD;
        !           448: typedef long CONSZ;  
        !           449: 
        !           450:        
        !           451:        
        !           452: 
        !           453: 
        !           454: 
        !           455: 
        !           456: 
        !           457: 
        !           458: 
        !           459: 
        !           460: extern int dope[];  
        !           461: extern char *opst[];  
        !           462: 
        !           463: 
        !           464: 
        !           465:        
        !           466: 
        !           467: union ndu {
        !           468: 
        !           469:        struct {
        !           470:                int op;
        !           471:                int goal;
        !           472:                TWORD type;
        !           473:                int cst[(6+4)];
        !           474:                char * name;
        !           475:                char pad[8-sizeof(char *)];     
        !           476:                NODE *left;
        !           477:                NODE *right;
        !           478:        }in;    
        !           479:        struct {
        !           480:                int op;
        !           481:                int goal;
        !           482:                TWORD type;
        !           483:                int cst[(6+4)];
        !           484:                char * name;
        !           485:                char pad[8-sizeof(char *)];     
        !           486:                NODE *left;
        !           487:                NODE *right;
        !           488:                int lineno;
        !           489:        }ln;    
        !           490:        
        !           491:        struct {
        !           492:                int op;
        !           493:                int goal;
        !           494:                TWORD type;
        !           495:                int cst[(6+4)];
        !           496:                char * name;
        !           497:                char pad[8-sizeof(char *)];     
        !           498:                CONSZ lval;
        !           499:                int rval;
        !           500:        }tn;    
        !           501:        
        !           502:        struct {
        !           503:                int op;
        !           504:                int goal;
        !           505:                TWORD type;
        !           506:                int cst[(6+4)];
        !           507:                int label;  
        !           508:                int lop;  
        !           509:        }bn;    
        !           510: 
        !           511:        struct {
        !           512:                int op;
        !           513:                int goal;
        !           514:                TWORD type;
        !           515:                int cst[(6+4)];
        !           516:                int stsize;  
        !           517:                short stalign;  
        !           518:                short argsize;  
        !           519:        }stn;   
        !           520: 
        !           521:        struct {
        !           522:                int op;
        !           523:                int goal;
        !           524:                TWORD type;
        !           525:                int cdim;
        !           526:                int csiz;
        !           527:        }fn;    
        !           528:        
        !           529:        struct {
        !           530:                
        !           531: 
        !           532:                int op;
        !           533:                int goal;
        !           534:                TWORD type;
        !           535:                int cdim;
        !           536:                int csiz;
        !           537:                double dval;
        !           538:        }fpn;   
        !           539: 
        !           540: };
        !           541: 
        !           542: 
        !           543: 
        !           544: 
        !           545: 
        !           546: 
        !           547: 
        !           548: 
        !           549: 
        !           550: 
        !           551: 
        !           552: 
        !           553: 
        !           554: 
        !           555: 
        !           556: 
        !           557: 
        !           558: 
        !           559: 
        !           560: 
        !           561: 
        !           562:        
        !           563: 
        !           564: 
        !           565: 
        !           566: extern char *scnames();
        !           567: 
        !           568: 
        !           569: 
        !           570: 
        !           571: 
        !           572: 
        !           573: 
        !           574: 
        !           575: 
        !           576: 
        !           577: 
        !           578: 
        !           579: 
        !           580: 
        !           581: 
        !           582: 
        !           583: 
        !           584: 
        !           585: 
        !           586: typedef long OFFSZ;
        !           587: 
        !           588: struct symtab {
        !           589:        char *sname;
        !           590:        TWORD stype;  
        !           591: 
        !           592:        char sclass;  
        !           593:        char slevel;  
        !           594:        char sflags;  
        !           595:        int offset;  
        !           596:        short dimoff; 
        !           597:        short sizoff; 
        !           598:        short suse;  
        !           599:        struct symtab *scopelink;       
        !           600: };
        !           601: 
        !           602: 
        !           603: struct sw {
        !           604:        CONSZ sval;
        !           605:        int slab;
        !           606: };
        !           607: 
        !           608: extern struct sw swtab[];
        !           609: extern struct sw *swp;
        !           610: extern int swx;
        !           611: 
        !           612: extern int ftnno;
        !           613: extern int blevel;
        !           614: extern int instruct, stwart;
        !           615: 
        !           616: extern int lineno, slineno, nerrors;
        !           617: typedef struct {
        !           618:                union {
        !           619:                int u_intval;
        !           620:                NODE *u_nodep;
        !           621:        } YY_un;
        !           622:        int lineno;
        !           623: } YYSTYPE;
        !           624: 
        !           625: 
        !           626: extern YYSTYPE yylval;
        !           627: 
        !           628: extern CONSZ lastcon;
        !           629: extern CONSZ ccast();
        !           630: extern double dcon;
        !           631: 
        !           632: extern char ftitle[];
        !           633: extern struct symtab stab[];
        !           634: extern int curftn;
        !           635: extern int strftn;
        !           636: extern char *locnames[];
        !           637: extern int curloc;
        !           638: extern int curclass;
        !           639: extern int curdim;
        !           640: extern int *dimtab;
        !           641: extern int paramstk[];
        !           642: extern int paramno;
        !           643: extern int argstk[];
        !           644: extern int argsoff[];
        !           645: extern TWORD argty[];
        !           646: extern int argno;
        !           647: extern int autooff, argoff, strucoff;
        !           648: extern int regvar;
        !           649: extern int nextrvar;
        !           650: extern int brkflag;
        !           651: extern char yytext[];
        !           652: 
        !           653: extern int strflg;
        !           654: 
        !           655: extern OFFSZ inoff;
        !           656: 
        !           657: extern int reached;
        !           658: 
        !           659: 
        !           660: 
        !           661: extern int idname;
        !           662: 
        !           663: extern NODE node[];
        !           664: extern NODE *lastfree;
        !           665: 
        !           666: extern int cflag, hflag, pflag;
        !           667: 
        !           668: 
        !           669: extern int brklab;
        !           670: extern int contlab;
        !           671: 
        !           672: extern int flostat;
        !           673: extern int retlab;
        !           674: extern int retstat;
        !           675: extern int asavbc[], *psavbc;
        !           676: 
        !           677: 
        !           678: 
        !           679: 
        !           680: 
        !           681: 
        !           682: 
        !           683: 
        !           684: 
        !           685: 
        !           686: 
        !           687: 
        !           688: 
        !           689: 
        !           690: 
        !           691: 
        !           692: 
        !           693: 
        !           694: 
        !           695: 
        !           696: 
        !           697: 
        !           698: 
        !           699: 
        !           700: 
        !           701: 
        !           702: 
        !           703: 
        !           704: 
        !           705: 
        !           706: 
        !           707: 
        !           708: 
        !           709: 
        !           710: 
        !           711:        
        !           712: 
        !           713: 
        !           714: 
        !           715: 
        !           716: 
        !           717: extern NODE
        !           718:        *aadjust(),
        !           719:        *bcon(),
        !           720:        *bdty(),
        !           721:        *block(),
        !           722:        *bpsize(),
        !           723:        *buildtree(),
        !           724: 
        !           725:        *clocal(),
        !           726:        *conval(),
        !           727:        *convert(),
        !           728:        *dclstruct(),
        !           729:        *doszof(),
        !           730:        *getstr(),
        !           731:        *makety(),
        !           732:        *mkty(),
        !           733:        *oconvert(),
        !           734:        *offcon(),
        !           735:        *optim(),
        !           736:        *pconvert(),
        !           737:        *ptmatch(),
        !           738:        *pvconvert(),
        !           739:        *rstruct(),
        !           740:        *sconvert(),
        !           741:        *strargs(),
        !           742:        *stref(),
        !           743:        *talloc(),
        !           744:        *tymatch(),
        !           745:        *tymerge(),
        !           746:        *unconvert(),
        !           747:        *xicolon();
        !           748: 
        !           749: OFFSZ  tsize(),
        !           750:        psize();
        !           751: 
        !           752: TWORD  types(),
        !           753:        ctype();
        !           754: 
        !           755: char *exname(), *exdcon();
        !           756: 
        !           757: 
        !           758: 
        !           759: 
        !           760: 
        !           761: 
        !           762: 
        !           763: 
        !           764: unsigned int maxoffset;
        !           765: 
        !           766: struct instk 
        !           767: {
        !           768:        int in_sz;   
        !           769:        int in_x;    
        !           770:        int in_n;    
        !           771:        int in_s;    
        !           772:        int in_d;    
        !           773:        TWORD in_t;    
        !           774:        int in_id;   
        !           775:        int in_fl;   
        !           776:        OFFSZ in_off;  
        !           777: }instack[10],*pstk;
        !           778: 
        !           779: struct symtab *relook();
        !           780: 
        !           781: int ddebug = 0;
        !           782: 
        !           783: struct symtab * mknonuniq();
        !           784: 
        !           785: defid( q, class )
        !           786: register NODE *q; 
        !           787: {
        !           788:        register struct symtab *p;
        !           789:        extern struct symtab *scopestack[];
        !           790:        int idp;
        !           791:        register TWORD type;
        !           792:        register TWORD stp;
        !           793:        register scl;
        !           794:        register dsym, ddef;
        !           795:        register slev, temp;
        !           796: 
        !           797:        if( q == (NODE *)0 ) return;  
        !           798:        if( q < node || q >= &node[1500] ) cerror( "defid call" );
        !           799:        idp = q->tn.rval;
        !           800:        if( idp < 0 ) cerror( "tyreduce" );
        !           801:        p = &stab[idp];
        !           802: 
        !           803:        if( ddebug )
        !           804:        {
        !           805:                printf( "defid( %s (%d), ", p->sname, idp );
        !           806:                tprint( q->in.type );
        !           807:                printf( ", %s, (%d,%d) ), level %d\n", scnames(class),
        !           808:                q->fn.cdim, q->fn.csiz, blevel );
        !           809:        }
        !           810: 
        !           811:        fixtype( q, class );
        !           812:        type = q->in.type;
        !           813:        class = fixclass( class, type );
        !           814:        stp = p->stype;
        !           815:        slev = p->slevel;
        !           816: 
        !           817:        if( ddebug )
        !           818:        {
        !           819:                printf( "       modified to " );
        !           820:                tprint( type );
        !           821:                printf( ", %s\n", scnames(class) );
        !           822:                printf( "       previous def'n: " );
        !           823:                tprint( stp );
        !           824:                printf( ", %s, (%d,%d) ), level %d\n", scnames(p->sclass),
        !           825:                p->dimoff, p->sizoff, slev );
        !           826:        }
        !           827: 
        !           828:        if( stp == 0100 && p->sclass == 0 )goto enter;
        !           829:        
        !           830:        
        !           831:        if( stp == 17|| stp == 1 )
        !           832:        {
        !           833:                if( blevel==1 && stp!=1 ) switch( class )
        !           834:                {
        !           835:                default:
        !           836:                        if(!(class&0100))
        !           837:                                uerror("declared argument %s is missing", p->sname);
        !           838:                case 8:
        !           839:                case 10:
        !           840:                case 11:
        !           841:                case 12:
        !           842:                case 16:
        !           843:                case 15:
        !           844:                case 13:
        !           845:                        ;
        !           846:                }
        !           847:                goto enter;
        !           848:        }
        !           849:        if( type != stp ) goto mismatch;
        !           850:        
        !           851:        dsym = p->dimoff;
        !           852:        ddef = q->fn.cdim;
        !           853:        for( temp=type; temp&(03<<5); temp = (((temp>>2)&~037)|(temp&037)) )
        !           854:        {
        !           855:                if( ((temp&(03<<5))==0140) )
        !           856:                {
        !           857:                        if( dimtab[dsym] == 0 ) dimtab[dsym] = dimtab[ddef];
        !           858:                        else if( dimtab[ddef]!=0 && dimtab[dsym] != dimtab[ddef] )
        !           859:                        {
        !           860:                                goto mismatch;
        !           861:                        }
        !           862:                        ++dsym;
        !           863:                        ++ddef;
        !           864:                }
        !           865:        }
        !           866:        
        !           867:        if( (temp==8||temp==9||temp==10) && p->sizoff != q->fn.csiz
        !           868:            && class!=10 && class!=12 && class!=15 )
        !           869:        {
        !           870:                goto mismatch;
        !           871:        }
        !           872:        scl = ( p->sclass );
        !           873: 
        !           874:        if( ddebug )
        !           875:        {
        !           876:                printf( "       previous class: %s\n", scnames(scl) );
        !           877:        }
        !           878: 
        !           879:        if( class&0100 )
        !           880:        {
        !           881:                
        !           882:                if( !falloc( p, class&077, 1, (NODE *)0 ) ) 
        !           883:                {
        !           884:                        
        !           885:                        psave( idp );
        !           886:                        return;
        !           887:                }
        !           888:                
        !           889:        }
        !           890:        else switch( class )
        !           891:        {
        !           892:        case 2:
        !           893:                switch( scl )
        !           894:                {
        !           895:                case 3:
        !           896:                case 18:
        !           897:                        if( slev==0 ) return;
        !           898:                        break;
        !           899:                case 5:
        !           900:                case 2:
        !           901:                case 14:
        !           902:                case 17:
        !           903:                        return;
        !           904:                }
        !           905:                break;
        !           906:        case 3:
        !           907:                if( scl==18 || (scl==2 && blevel==0) )
        !           908:                {
        !           909:                        p->sclass = 3;
        !           910:                        if( ((type&(03<<5))==0100) ) curftn = idp;
        !           911:                        return;
        !           912:                }
        !           913:                break;
        !           914:        case 18:
        !           915:                if( scl==3 || scl==18 ) return;
        !           916:                break;
        !           917:        case 6:
        !           918:                if( scl == 7 )
        !           919:                {
        !           920:                        p->sclass = 6;
        !           921:                        deflab( p->offset );
        !           922:                        return;
        !           923:                }
        !           924:                break;
        !           925:        case 13:
        !           926:                if( scl == class ) return;
        !           927:                break;
        !           928:        case 17:
        !           929:                if( scl == 17 || scl == 14 ) return;
        !           930:                break;
        !           931:        case 14:
        !           932:                if( scl == 17 )
        !           933:                {
        !           934:                        p->sclass = 14;
        !           935:                        if( ((type&(03<<5))==0100) ) curftn = idp;
        !           936:                        return;
        !           937:                }
        !           938:                break;
        !           939:        case 11:
        !           940:        case 8:
        !           941:                if( scl == class ) 
        !           942:                {
        !           943:                        if( oalloc( p, &strucoff ) ) break;
        !           944:                        if( class == 11 ) strucoff = 0;
        !           945:                        psave( idp );
        !           946:                        return;
        !           947:                }
        !           948:                break;
        !           949:        case 16:
        !           950:                if( scl == class )
        !           951:                {
        !           952:                        if( p->offset!= strucoff++ ) break;
        !           953:                        psave( idp );
        !           954:                }
        !           955:                break;
        !           956:        case 5:
        !           957:                if( scl == 2 ) 
        !           958:                {
        !           959:                        p->sclass = 5;
        !           960:                        if( ((type&(03<<5))==0100) ) curftn = idp;
        !           961:                        return;
        !           962:                }
        !           963:                break;
        !           964:        case 10:
        !           965:        case 12:
        !           966:        case 15:
        !           967:                if( scl != class ) break;
        !           968:                if( dimtab[p->sizoff] == 0 )
        !           969:                        return;  
        !           970:                break;
        !           971:        case 7:
        !           972:                if( scl == 6 || scl == 7 ) return;
        !           973:        case 9:
        !           974:        case 1:
        !           975:        case 4:
        !           976:                ;  
        !           977:        }
        !           978: mismatch:
        !           979:        
        !           980:        if( class==11 || class==8 || class & 0100 )
        !           981:        {
        !           982:                
        !           983:                register * memp;
        !           984:                p->sflags |= 040;  
        !           985:                
        !           986:                for( memp = &paramstk[paramno-1];
        !           987:                         *memp>=0 && stab[*memp].sclass != 10
        !           988:                                && stab[*memp].sclass != 12;
        !           989:                         --memp)
        !           990:                {
        !           991:                        if( stab[*memp].sflags & 040 )
        !           992:                        {       int i;
        !           993:                                if ( p->sname != stab[*memp].sname )
        !           994:                                        continue;
        !           995:                                i = stab[*memp].suse;
        !           996:                                if(i < 0)
        !           997:                                        i = -i;
        !           998:                                uerror("redeclaration of: %s from line %d",
        !           999:                                        p->sname, i);
        !          1000:                                break;
        !          1001:                        }
        !          1002:                }
        !          1003:                p = mknonuniq( &idp ); 
        !          1004:                goto enter;
        !          1005:        }
        !          1006:        if( blevel > slev && class != 2 && class != 14 &&
        !          1007:            class != 17 && !( class == 6 && slev >= 2 ) )
        !          1008:        {
        !          1009:                q->tn.rval = idp = hide( p );
        !          1010:                p = &stab[idp];
        !          1011:                goto enter;
        !          1012:        }
        !          1013:        uerror( "redeclaration of %s from some line %d", p->sname, p->suse);
        !          1014:        if( class==5 && ((type&(03<<5))==0100) ) curftn = idp;
        !          1015:        return;
        !          1016: enter:  
        !          1017: 
        !          1018:        if( ddebug ) printf( "  new entry made\n" );
        !          1019: 
        !          1020:        if( type == 17 ) uerror("void type for %s",p->sname);
        !          1021:        p->stype = type;
        !          1022:        p->sclass = class;
        !          1023:        p->slevel = (class == 6 || class == 7) ? 2 : blevel;
        !          1024:        p->offset = (-10201);
        !          1025:        p->suse = lineno;
        !          1026:        if( class == 10 || class == 12 || class == 15 ) 
        !          1027:        {
        !          1028:                p->sizoff = curdim;
        !          1029:                dstash( 0 );  
        !          1030:                dstash( -1 ); 
        !          1031:                dstash( 8 );  
        !          1032:                dstash( idp );  
        !          1033:        }
        !          1034:        else 
        !          1035:        {
        !          1036:                switch( (type&037) )
        !          1037:                {
        !          1038:                case 8:
        !          1039:                case 9:
        !          1040:                case 10:
        !          1041:                        p->sizoff = q->fn.csiz;
        !          1042:                        break;
        !          1043:                default:
        !          1044:                        p->sizoff = (type&037);
        !          1045:                }
        !          1046:        }
        !          1047:        
        !          1048:        p->dimoff = q->fn.cdim;
        !          1049:        
        !          1050:        if( class&0100 )
        !          1051:        {
        !          1052:                falloc( p, class&077, 0, (NODE *)0 );  
        !          1053:                psave( idp );
        !          1054:        }
        !          1055:        else switch( class )
        !          1056:        {
        !          1057:        case 1:
        !          1058:                oalloc( p, &autooff );
        !          1059:                break;
        !          1060:        case 3:
        !          1061:        case 5:
        !          1062:                p->offset = getlab();
        !          1063:                if( ((type&(03<<5))==0100) ) curftn = idp;
        !          1064:                break;
        !          1065:        case 7:
        !          1066:        case 6:
        !          1067:                p->offset = getlab();
        !          1068:                if( class == 6 )
        !          1069:                {
        !          1070:                        locctr( 0 );
        !          1071:                        deflab( p->offset );
        !          1072:                }
        !          1073:                break;
        !          1074:        case 2:
        !          1075:        case 17:
        !          1076:        case 14:
        !          1077:                p->offset = getlab();
        !          1078:                break;
        !          1079:        case 11:
        !          1080:        case 8:
        !          1081:                oalloc( p, &strucoff );
        !          1082:                if( class == 11 ) strucoff = 0;
        !          1083:                psave( idp );
        !          1084:                break;
        !          1085:        case 16:
        !          1086:                p->offset = strucoff++;
        !          1087:                psave( idp );
        !          1088:                break;
        !          1089:        case 4:
        !          1090:                
        !          1091:                p->offset = nextrvar;
        !          1092:                if( blevel == 1 ) p->sflags |= 010;
        !          1093:                break;
        !          1094:        }
        !          1095:        
        !          1096: 
        !          1097: 
        !          1098:        if (blevel >= 100)
        !          1099:        {
        !          1100:                cerror("too many nesting levels (%d>=%d)", blevel, 100);
        !          1101:                
        !          1102:        }
        !          1103:        p->scopelink = scopestack[slev = p->slevel];
        !          1104:        scopestack[slev] = p;
        !          1105:        
        !          1106: 
        !          1107: 
        !          1108:        switch( class )
        !          1109:        {
        !          1110:                case 7:
        !          1111:                case 6:
        !          1112:                        p->slevel = 2;
        !          1113:                        break;
        !          1114:                case 2:
        !          1115:                case 17:
        !          1116:                case 14:
        !          1117:                        p->slevel = 0;
        !          1118:                        break;
        !          1119:        }
        !          1120: 
        !          1121:        if( ddebug )
        !          1122:                printf( "       dimoff, sizoff, offset: %d, %d, %d\n",
        !          1123:                        p->dimoff, p->sizoff, p->offset );
        !          1124: 
        !          1125: }
        !          1126: 
        !          1127: asave( i )
        !          1128: {
        !          1129:        if( argno >= 50 )
        !          1130:        {
        !          1131:                cerror( "too many arguments (%d>=%d)", argno, 50);
        !          1132:        }
        !          1133:        argstk[ argno++ ] = i;
        !          1134: }
        !          1135: 
        !          1136: psave( i )
        !          1137: {
        !          1138:        if( paramno >= 650 )
        !          1139:        {
        !          1140:                cerror( "parameter stack overflow (%d>=%d)", paramno, 650);
        !          1141:        }
        !          1142:        paramstk[ paramno++ ] = i;
        !          1143: }
        !          1144: 
        !          1145: 
        !          1146: int maxarg;
        !          1147: 
        !          1148: ftnend()
        !          1149: {
        !          1150:         
        !          1151:        if( retlab != (-1) )
        !          1152:        {
        !          1153:                
        !          1154: 
        !          1155:                efcode();
        !          1156: 
        !          1157:                p2bend();
        !          1158: 
        !          1159:        }
        !          1160:        ;
        !          1161:        retstat = 0;
        !          1162:        tcheck();
        !          1163:        curclass = 0;
        !          1164:        brklab = contlab = retlab = (-1);
        !          1165:        flostat = 0;
        !          1166:        strftn = 0;
        !          1167:        argno = 0;
        !          1168:        if( nerrors == 0 )
        !          1169:        {
        !          1170:                if( psavbc != & asavbc[0] ) cerror("bcsave error");
        !          1171:                if( paramno != 0 ) cerror("parameter reset error");
        !          1172:                if( swx != 0 ) cerror( "switch error");
        !          1173:        }
        !          1174:        psavbc = &asavbc[0];
        !          1175:        paramno = 0;
        !          1176:        autooff = 0;
        !          1177:        maxarg = 0;
        !          1178:        reached = 1;
        !          1179:        swx = 0;
        !          1180:        swp = swtab;
        !          1181:        locctr(2);
        !          1182: }
        !          1183: 
        !          1184: dclargs()
        !          1185: {
        !          1186:        register i, j;
        !          1187:        register struct symtab *p;
        !          1188:        register NODE *q;
        !          1189:        register TWORD temp;
        !          1190:        extern TWORD simpstr();
        !          1191: 
        !          1192:        argoff = 32;
        !          1193: 
        !          1194: 
        !          1195:        if( ddebug > 2) printf("dclargs()\n");
        !          1196: 
        !          1197:        for( i=0; i<argno; ++i )
        !          1198:        {
        !          1199:                if( (j = argstk[i]) < 0 ) continue;
        !          1200:                p = &stab[j];
        !          1201: 
        !          1202:                if( ddebug > 2 )
        !          1203:                {
        !          1204:                        printf("\t%s (%d) ",p->sname, j);
        !          1205:                        tprint(p->stype);
        !          1206:                        printf("\n");
        !          1207:                }
        !          1208: 
        !          1209:                if( p->stype == 1 ) 
        !          1210:                {
        !          1211:                        q = block(97,(NODE *)0,(NODE *)0,4,0,4);
        !          1212:                        q->tn.rval = j;
        !          1213:                        defid( q, 9 );
        !          1214:                }
        !          1215:                if( p->sclass == 4 )
        !          1216:                {
        !          1217:                        
        !          1218:                        int tmp = p->offset;
        !          1219:                        p->offset = (-10201);
        !          1220:                        p->sclass = 9;
        !          1221:                        oalloc( p, &argoff );
        !          1222:                        argsoff[i] = p->offset;
        !          1223:                        argty[i] = p->stype;
        !          1224:                        p->sclass = 4;
        !          1225:                        p->offset = tmp;
        !          1226:                }
        !          1227:                else 
        !          1228:                {
        !          1229:                        oalloc( p, &argoff );  
        !          1230:                        argsoff[i] = p->offset;
        !          1231:                        argty[i] = p->stype;
        !          1232:                }
        !          1233:        }
        !          1234:        autooff = 0;
        !          1235: 
        !          1236:        locctr(0);
        !          1237:        defalign(32);
        !          1238:        ++ftnno;
        !          1239:        p = &stab[curftn];
        !          1240: 
        !          1241:        if( p->slevel>1 && p->sclass == 3 ) deflab( p->offset );
        !          1242:        else defnam( p );
        !          1243:        temp = p->stype;
        !          1244:        temp = ((( temp >>2)&~037)|( temp &037));
        !          1245: 
        !          1246:        
        !          1247:        
        !          1248:        strftn = (temp==8) || (temp==9);
        !          1249:        if( strftn && simpstr( p->dimoff, p->sizoff ) != 8 )
        !          1250:                strftn = 0;
        !          1251: 
        !          1252:        bfcode(argstk, argno, p->sname);
        !          1253: 
        !          1254:        regargs();
        !          1255: 
        !          1256:        
        !          1257:        if( strftn ) 
        !          1258:        {
        !          1259: 
        !          1260:                  
        !          1261:                
        !          1262:                i = tsize( temp, p->dimoff, p->sizoff);
        !          1263: 
        !          1264:                sretname(i);
        !          1265: 
        !          1266: 
        !          1267: 
        !          1268:        }
        !          1269: }
        !          1270: 
        !          1271: 
        !          1272: regargs()
        !          1273: {
        !          1274:        register i;
        !          1275:        register NODE *p, *q;
        !          1276:        register struct symtab *s;
        !          1277:        
        !          1278:        for( i=0; i<argno; ++i )
        !          1279:        {
        !          1280:                s = &stab[argstk[i]];
        !          1281:                if( s->sclass == 4 )
        !          1282:                {
        !          1283:                        int temp;
        !          1284:                        idname = argstk[i];
        !          1285:                        p = buildtree( 2, (NODE *)0, (NODE *)0 );
        !          1286:                        temp = s->offset;
        !          1287:                        s->offset = argsoff[i];
        !          1288:                        s->sclass = 9;
        !          1289:                        q = buildtree( 2, (NODE *)0, (NODE *)0 );
        !          1290:                        p = buildtree( 58, p, q );
        !          1291:                        ecomp( p );
        !          1292:                        s->offset = temp;
        !          1293:                        s->sclass = 4;
        !          1294:                }
        !          1295:        }
        !          1296: }
        !          1297: 
        !          1298: 
        !          1299: NODE *
        !          1300: rstruct( idn, soru )
        !          1301: register idn,soru;
        !          1302: {
        !          1303:         
        !          1304:        register struct symtab *p;
        !          1305:        register NODE *q;
        !          1306:        p = &stab[idn];
        !          1307:        switch( p->stype )
        !          1308:        {
        !          1309:        case 17:
        !          1310: def:
        !          1311:                q = block( 97, (NODE *)0, (NODE *)0, 0, 0, 0 );
        !          1312:                q->tn.rval = idn;
        !          1313:                q->in.type = (soru&02) ? 8 : ( (soru&04) ? 9 : 10 );
        !          1314:                defid( q, (soru&02) ? 10 : ( (soru&04) ? 12 : 15 ) );
        !          1315:                break;
        !          1316:        case 8:
        !          1317:                if( soru & 02 ) break;
        !          1318:                goto def;
        !          1319:        case 9:
        !          1320:                if( soru & 04 ) break;
        !          1321:                goto def;
        !          1322:        case 10:
        !          1323:                if( !(soru&(04|02)) ) break;
        !          1324:                goto def;
        !          1325:        }
        !          1326:        stwart = instruct;
        !          1327:        return( mkty( p->stype, 0, p->sizoff ) );
        !          1328: }
        !          1329: 
        !          1330: moedef( idn )
        !          1331: register idn;
        !          1332: {
        !          1333:        register NODE *q;
        !          1334: 
        !          1335:        q = block( 97, (NODE *)0, (NODE *)0, 11, 0, 0 );
        !          1336:        q->tn.rval = idn;
        !          1337:        if( idn>=0 ) defid( q, 16 );
        !          1338: }
        !          1339: 
        !          1340: extern char *hash(), *index(), *rindex();
        !          1341: static int fakeprev, fakenum;
        !          1342: static char fakestub[32], fakename[64];
        !          1343: 
        !          1344: bstruct( idn, soru )
        !          1345: register idn,soru;
        !          1346: {
        !          1347:         
        !          1348:        register NODE *q;
        !          1349: 
        !          1350:        if (idn < 0) {
        !          1351:                char *p;
        !          1352:                if ((p = rindex(ftitle, '/')) == 0)
        !          1353:                        p = ftitle;
        !          1354:                strcpy(fakestub, ++p);
        !          1355:                if (p = index(fakestub, '"'))
        !          1356:                        *p = '\0';
        !          1357:                sprintf(fakename, "%s$%d.%d", fakestub, lineno, ++fakenum);
        !          1358:                idn = lookup(hash(fakename), 0100);
        !          1359:        }
        !          1360:        psave( instruct );
        !          1361:        psave( curclass );
        !          1362:        psave( strucoff );
        !          1363:        strucoff = 0;
        !          1364:        instruct = soru;
        !          1365:        q = block( 97, (NODE *)0, (NODE *)0, 0, 0, 0 );
        !          1366:        q->tn.rval = idn;
        !          1367:        if( instruct==02 )
        !          1368:        {
        !          1369:                curclass = 8;
        !          1370:                q->in.type = 8;
        !          1371:                defid( q, 10 );
        !          1372:        }
        !          1373:        else if( instruct == 04 ) 
        !          1374:        {
        !          1375:                curclass = 11;
        !          1376:                q->in.type = 9;
        !          1377:                defid( q, 12 );
        !          1378:        }
        !          1379:        else 
        !          1380:        {
        !          1381:                 
        !          1382:                curclass = 16;
        !          1383:                q->in.type = 10;
        !          1384:                defid( q, 15 );
        !          1385:        }
        !          1386:        psave( idn = q->tn.rval );
        !          1387:        
        !          1388:        if( idn >= 0 ) stab[idn].suse = lineno;
        !          1389:        return( paramno-4 );
        !          1390: }
        !          1391: 
        !          1392: 
        !          1393: 
        !          1394: 
        !          1395: 
        !          1396: NODE *
        !          1397: dclstruct( oparam )
        !          1398: register oparam;
        !          1399: {
        !          1400:        register struct symtab *p;
        !          1401:        register i, al, sa, j, sz, szindex;
        !          1402:        register TWORD temp;
        !          1403:        register high, low;
        !          1404: 
        !          1405:        
        !          1406: 
        !          1407: 
        !          1408: 
        !          1409: 
        !          1410: 
        !          1411: 
        !          1412: 
        !          1413: 
        !          1414: 
        !          1415: 
        !          1416:        if( (i=paramstk[oparam+3]) < 0 )
        !          1417:        {
        !          1418:                szindex = curdim;
        !          1419:                dstash( 0 );  
        !          1420:                dstash( -1 );  
        !          1421:                dstash( 8 );  
        !          1422:                dstash( -lineno );  
        !          1423:        }
        !          1424:        else 
        !          1425:        {
        !          1426:                szindex = stab[i].sizoff;
        !          1427:        }
        !          1428: 
        !          1429: 
        !          1430: 
        !          1431:        if( ddebug )
        !          1432:        {
        !          1433:                printf( "dclstruct( %szindex = %d\n",
        !          1434:                        (i>=0)? stab[i].sname : "??", szindex );
        !          1435:        }
        !          1436: 
        !          1437:        temp = (instruct&02)?8:((instruct&04)?9:10);
        !          1438:        stwart = instruct = paramstk[ oparam ];
        !          1439:        curclass = paramstk[ oparam+1 ];
        !          1440:        dimtab[ szindex+1 ] = curdim;
        !          1441:        al = 8;
        !          1442: 
        !          1443:        high = low = 0;
        !          1444: 
        !          1445:        for( i = oparam+4;  i< paramno; ++i )
        !          1446:        {
        !          1447:                dstash( j=paramstk[i] );
        !          1448:                if( j<0 || j>= 6000 ) cerror( "gummy structure member" );
        !          1449:                p = &stab[j];
        !          1450:                if( temp == 10 )
        !          1451:                {
        !          1452:                        if( p->offset < low ) low = p->offset;
        !          1453:                        if( p->offset > high ) high = p->offset;
        !          1454:                        p->sizoff = szindex;
        !          1455:                        continue;
        !          1456:                }
        !          1457:                sa = talign( p->stype, p->sizoff );
        !          1458:                if( p->sclass & 0100 )
        !          1459:                {
        !          1460:                        sz = p->sclass&077;
        !          1461:                }
        !          1462:                else 
        !          1463:                {
        !          1464:                        sz = tsize( p->stype, p->dimoff, p->sizoff );
        !          1465:                }
        !          1466:                if( sz == 0 )
        !          1467:                {
        !          1468:                        werror( "structure member has size 0: %s", p->sname );
        !          1469:                }
        !          1470:                if( sz > strucoff ) strucoff = sz;  
        !          1471:                if( ( al)%( sa ) != 0 )  al = ( (( al)/( sa ) + 1) * ( sa ));
        !          1472:                
        !          1473:        }
        !          1474:        dstash( -1 );  
        !          1475:        if( ( strucoff)%( al ) != 0 )  strucoff = ( (( strucoff)/( al ) + 1) * ( al ));
        !          1476: 
        !          1477:        if( temp == 10 )
        !          1478:        {
        !          1479:                register TWORD ty;
        !          1480: 
        !          1481:                ty = 4;
        !          1482:                strucoff = tsize( ty, 0, (int)ty );
        !          1483:                dimtab[ szindex+2 ] = al = talign( ty, (int)ty );
        !          1484:        }
        !          1485: 
        !          1486:        if( strucoff == 0 ) uerror( "zero sized structure" );
        !          1487:        dimtab[ szindex ] = strucoff;
        !          1488:        dimtab[ szindex+2 ] = al;
        !          1489:        dimtab[ szindex+3 ] = paramstk[ oparam+3 ];  
        !          1490: 
        !          1491: 
        !          1492: 
        !          1493: 
        !          1494:        if( ddebug>1 )
        !          1495:        {
        !          1496:                printf( "\tdimtab[%d,%d,%d,%d] = %d,%d,%d,%d\n",
        !          1497:                szindex,szindex+1,szindex+2,szindex+3,
        !          1498:                dimtab[szindex],dimtab[szindex+1],dimtab[szindex+2],
        !          1499:                dimtab[szindex+3] );
        !          1500:                for( i = dimtab[szindex+1]; dimtab[i] >= 0; ++i )
        !          1501:                {
        !          1502:                        printf( "\tmember %s(%d)\n", stab[dimtab[i]].sname, dimtab[i] );
        !          1503:                }
        !          1504:        }
        !          1505: 
        !          1506: 
        !          1507:        strucoff = paramstk[ oparam+2 ];
        !          1508:        paramno = oparam;
        !          1509: 
        !          1510:        return( mkty( temp, 0, szindex ) );
        !          1511: }
        !          1512: 
        !          1513: 
        !          1514: yyerror( s, a, b, c, d, e, f, g ) char *s; 
        !          1515: 
        !          1516: {
        !          1517:         
        !          1518:        uerror( s, a, b, c, d, e, f, g );
        !          1519: 
        !          1520: }
        !          1521: 
        !          1522: yyaccpt()
        !          1523: {
        !          1524:        ftnend();
        !          1525: }
        !          1526: 
        !          1527: ftnarg( idn ) 
        !          1528: register idn;
        !          1529: {
        !          1530:        register struct symtab *p;
        !          1531:        p = &stab[idn];
        !          1532:        switch( p->stype )
        !          1533:        {
        !          1534: 
        !          1535:        case 17:
        !          1536:                
        !          1537:                break;
        !          1538:        case 1:
        !          1539:                uerror("redeclaration of formal parameter, %s",p->sname);
        !          1540:                
        !          1541:        case 0100:
        !          1542:                
        !          1543:                
        !          1544:        default:
        !          1545:                idn = hide(p);
        !          1546:                p = &stab[idn];
        !          1547:                break;
        !          1548:        case 0:
        !          1549:                
        !          1550:                ;
        !          1551:        }
        !          1552:        p->stype = 1;
        !          1553:        p->sclass = 9;
        !          1554:        asave( idn );
        !          1555: }
        !          1556: 
        !          1557: talign( ty, s)
        !          1558: register unsigned ty; 
        !          1559: register s; 
        !          1560: {
        !          1561:        
        !          1562: 
        !          1563:        register i;
        !          1564: 
        !          1565: 
        !          1566:        for( i=0; i<=(32-5-1); i+=2 )
        !          1567:        {
        !          1568:                switch( (ty>>i)&(03<<5) )
        !          1569:                {
        !          1570: 
        !          1571:                case 0100:
        !          1572:                        cerror( "compiler takes alignment of function");
        !          1573:                case 040:
        !          1574:                        return( 32 );
        !          1575:                case 0140:
        !          1576:                        continue;
        !          1577:                case 0:
        !          1578:                        break;
        !          1579:                }
        !          1580:        }
        !          1581: 
        !          1582:        switch( (ty&037) )
        !          1583:        {
        !          1584: 
        !          1585:        case 9:
        !          1586:        case 10:
        !          1587:        case 8:
        !          1588:                return( dimtab[ s+2 ] );
        !          1589:        case 2:
        !          1590:        case 12:
        !          1591:                return( 8 );
        !          1592:        case 6:
        !          1593:                return( 32 );
        !          1594:        case 7:
        !          1595:                return( 32 );
        !          1596:        case 5:
        !          1597:        case 15:
        !          1598:                return( 32 );
        !          1599:        case 3:
        !          1600:        case 13:
        !          1601:                return( 16 );
        !          1602:        default:
        !          1603:                return( 32 );
        !          1604:        }
        !          1605: }
        !          1606: 
        !          1607: OFFSZ
        !          1608: tsize( ty, d, s )
        !          1609: register TWORD ty; 
        !          1610: {
        !          1611:        
        !          1612: 
        !          1613: 
        !          1614:        
        !          1615: 
        !          1616:        register i;
        !          1617:        register OFFSZ mult;
        !          1618: 
        !          1619:        mult = 1;
        !          1620: 
        !          1621:        for( i=0; i<=(32-5-1); i+=2 )
        !          1622:        {
        !          1623:                switch( (ty>>i)&(03<<5) )
        !          1624:                {
        !          1625: 
        !          1626:                case 0100:
        !          1627:                        uerror("illegal use of function pointer");
        !          1628:                case 040:
        !          1629:                        return( 32 * mult );
        !          1630:                case 0140:
        !          1631:                        mult *= dimtab[ d++ ];
        !          1632:                        continue;
        !          1633:                case 0:
        !          1634:                        break;
        !          1635: 
        !          1636:                }
        !          1637:        }
        !          1638:        if(ty == 10)
        !          1639:                return(32);
        !          1640:        if(ty == 16)
        !          1641:                uerror("using a void value");
        !          1642:        if( dimtab[s]==0 ) {
        !          1643:                uerror( "unknown size");
        !          1644:                return( 32 );
        !          1645:        }
        !          1646:        return( dimtab[ s ] * mult );
        !          1647: }
        !          1648: 
        !          1649: inforce( n )
        !          1650: register OFFSZ n; 
        !          1651: {
        !          1652:          
        !          1653:        
        !          1654:        register OFFSZ wb;
        !          1655:        register rest;
        !          1656:        
        !          1657: 
        !          1658:        if( inoff == n ) return;
        !          1659:        if( inoff > n ) 
        !          1660:        {
        !          1661:                uerror("too many initializers (%d>%d)", inoff, n);
        !          1662:                inoff = n;
        !          1663:                return;
        !          1664:        }
        !          1665: 
        !          1666:        wb = inoff;
        !          1667:        if( ( wb)%( 32 ) != 0 )  wb = ( (( wb)/( 32 ) + 1) * ( 32 ));
        !          1668: 
        !          1669:        
        !          1670:        if( wb >= n )
        !          1671:        {
        !          1672:                 
        !          1673:                rest = n - inoff;
        !          1674:                vfdzero( rest );
        !          1675:                return;
        !          1676:        }
        !          1677: 
        !          1678:        
        !          1679: 
        !          1680:        rest = wb - inoff;
        !          1681:        vfdzero( rest );
        !          1682: 
        !          1683:        
        !          1684: 
        !          1685:        rest = (n-inoff)/32;
        !          1686:        zecode( rest );
        !          1687: 
        !          1688:        
        !          1689: 
        !          1690:        rest = n-inoff;
        !          1691:        vfdzero( rest );
        !          1692:        if( inoff != n ) cerror( "inoff error");
        !          1693: 
        !          1694: }
        !          1695: 
        !          1696: vfdalign( n )
        !          1697: {
        !          1698:         
        !          1699:        register OFFSZ m;
        !          1700: 
        !          1701:        m = inoff;
        !          1702:        if( ( m)%( n ) != 0 )  m = ( (( m)/( n ) + 1) * ( n ));
        !          1703:        inforce( m );
        !          1704: }
        !          1705: 
        !          1706: 
        !          1707: 
        !          1708: extern int idebug;
        !          1709: 
        !          1710: 
        !          1711: int ibseen = 0;  
        !          1712: 
        !          1713: int iclass;  
        !          1714: 
        !          1715: int ilocctr = 0;  
        !          1716: 
        !          1717: beginit(curid)
        !          1718: {
        !          1719:        
        !          1720:        register struct symtab *p;
        !          1721: 
        !          1722: 
        !          1723:        if( idebug >= 3 ) printf( "beginit(), curid = %d\n", curid );
        !          1724: 
        !          1725: 
        !          1726:        p = &stab[curid];
        !          1727: 
        !          1728:        iclass = p->sclass;
        !          1729:        if( curclass == 2 || curclass == 14 ) iclass = 2;
        !          1730:        switch( iclass )
        !          1731:        {
        !          1732: 
        !          1733:        case 12:
        !          1734:        case 2:
        !          1735:                return;
        !          1736:        case 1:
        !          1737:        case 4:
        !          1738:                break;
        !          1739:        case 5:
        !          1740:        case 3:
        !          1741:                ilocctr = ((p->stype&(03<<5))==0140)?1:2;
        !          1742:                locctr( ilocctr );
        !          1743:                defalign( talign( p->stype, p->sizoff ) );
        !          1744:                if( p->slevel>1 && p->sclass == 3 ) deflab( p->offset );
        !          1745:                else defnam( p );
        !          1746: 
        !          1747:        }
        !          1748: 
        !          1749:        inoff = 0;
        !          1750:        ibseen = 0;
        !          1751: 
        !          1752:        pstk = 0;
        !          1753: 
        !          1754:        instk( curid, p->stype, p->dimoff, p->sizoff, inoff );
        !          1755: 
        !          1756: }
        !          1757: 
        !          1758: instk( id, t, d, s, off )
        !          1759: register OFFSZ off; 
        !          1760: register TWORD t; 
        !          1761: 
        !          1762: {
        !          1763:        
        !          1764: 
        !          1765:        register struct symtab *p;
        !          1766: 
        !          1767:        for(;;)
        !          1768:        {
        !          1769: 
        !          1770:                if( idebug ) printf( "instk((%d, %o,%d,%d, %d)\n", id, t, d, s, off );
        !          1771: 
        !          1772: 
        !          1773:                
        !          1774: 
        !          1775:                if( !pstk ) pstk = instack;
        !          1776:                else ++pstk;
        !          1777: 
        !          1778:                pstk->in_fl = 0;        
        !          1779:                pstk->in_id =  id ;
        !          1780:                pstk->in_t =  t ;
        !          1781:                pstk->in_d =  d ;
        !          1782:                pstk->in_s =  s ;
        !          1783:                pstk->in_n = 0;  
        !          1784:                pstk->in_x =  t==8 ?dimtab[s+1] : 0 ;
        !          1785:                pstk->in_off = off;  
        !          1786:                
        !          1787:                
        !          1788:                if( ((t&(03<<5))==0140) )
        !          1789:                {
        !          1790:                        pstk->in_sz = tsize( (((t>>2)&~037)|(t&037)), d+1, s );
        !          1791:                }
        !          1792:                else if( stab[id].sclass & 0100 )
        !          1793:                {
        !          1794:                        pstk->in_sz = - ( stab[id].sclass & 077 );
        !          1795:                }
        !          1796:                else 
        !          1797:                {
        !          1798:                        pstk->in_sz = 0;
        !          1799:                }
        !          1800: 
        !          1801:                if( (iclass==1 || iclass == 4 ) &&
        !          1802:                    (((t&(03<<5))==0140) || t==8) )
        !          1803:                        uerror( "no automatic aggregate initialization" );
        !          1804: 
        !          1805:                
        !          1806: 
        !          1807:                if( ((t&(03<<5))==0140) )
        !          1808:                {
        !          1809:                        t = (((t>>2)&~037)|(t&037));
        !          1810:                        ++d;
        !          1811:                        continue;
        !          1812:                }
        !          1813:                else if( t == 8 )
        !          1814:                {
        !          1815:                        id = dimtab[pstk->in_x];
        !          1816:                        p = &stab[id];
        !          1817:                        if( p->sclass != 8 && !(p->sclass&0100) )
        !          1818:                                cerror( "insane structure member list" );
        !          1819:                        t = p->stype;
        !          1820:                        d = p->dimoff;
        !          1821:                        s = p->sizoff;
        !          1822:                        off += p->offset;
        !          1823:                        continue;
        !          1824:                }
        !          1825:                else return;
        !          1826:        }
        !          1827: }
        !          1828: 
        !          1829: NODE *
        !          1830: getstr()
        !          1831: {
        !          1832:         
        !          1833: 
        !          1834:        register l, temp;
        !          1835:        register NODE *p;
        !          1836: 
        !          1837:        if( (iclass==5||iclass==3) &&
        !          1838:            (pstk->in_t == 2 || pstk->in_t == 12) &&
        !          1839:            pstk!=instack && (( pstk[-1].in_t &(03<<5))==0140) )
        !          1840:        {
        !          1841:                
        !          1842:                strflg = 1;
        !          1843:                ilbrace();  
        !          1844:                inforce( pstk->in_off );
        !          1845: 
        !          1846:                
        !          1847: 
        !          1848: 
        !          1849: 
        !          1850:                
        !          1851:                lxstr((pstk-1)!=instack?dimtab[(pstk-1)->in_d]:0);
        !          1852:                irbrace();  
        !          1853:                return( (NODE *)0 );
        !          1854:        }
        !          1855:        else 
        !          1856:        {
        !          1857:                 
        !          1858:                if( iclass != 0 )
        !          1859:                {
        !          1860:                         
        !          1861:                        
        !          1862:                        vfdalign( 32 );
        !          1863:                }
        !          1864:                
        !          1865:                temp = locctr( blevel==0?3:4 );
        !          1866:                deflab( l = getlab() );
        !          1867:                strflg = 0;
        !          1868:                lxstr(0)        !          1869:                locctr( blevel==0?ilocctr:temp );
        !          1870:                p = buildtree( 3, (NODE *)0, (NODE *)0 );
        !          1871:                p->tn.rval = -l;
        !          1872:                return(p);
        !          1873:        }
        !          1874: }
        !          1875: 
        !          1876: putbyte( v )
        !          1877: {
        !          1878:         
        !          1879:        register NODE *p;
        !          1880:        p = bcon(v);
        !          1881:        incode( p, 8 );
        !          1882:        tfree( p );
        !          1883:        gotscal();
        !          1884: }
        !          1885: 
        !          1886: endinit()
        !          1887: {
        !          1888:        register TWORD t;
        !          1889:        register d, s, n, d1;
        !          1890: 
        !          1891: 
        !          1892:        if( idebug ) printf( "endinit(), inoff = %d\n", inoff );
        !          1893: 
        !          1894: 
        !          1895:        switch( iclass )
        !          1896:        {
        !          1897: 
        !          1898:        case 2:
        !          1899:        case 1:
        !          1900:        case 4:
        !          1901:                iclass = 0;
        !          1902:                return;
        !          1903:        }
        !          1904: 
        !          1905:        pstk = instack;
        !          1906: 
        !          1907:        t = pstk->in_t;
        !          1908:        d = pstk->in_d;
        !          1909:        s = pstk->in_s;
        !          1910:        n = pstk->in_n;
        !          1911: 
        !          1912:        if( ((t&(03<<5))==0140) )
        !          1913:        {
        !          1914:                d1 = dimtab[d];
        !          1915: 
        !          1916:                
        !          1917:                vfdalign( pstk->in_sz );
        !          1918: 
        !          1919:                n = inoff/pstk->in_sz;  
        !          1920:                if( d1 >= n )
        !          1921:                {
        !          1922:                        
        !          1923:                        inforce( tsize( t, d, s ) );
        !          1924:                        n = d1;
        !          1925:                }
        !          1926:                if( d1!=0 && d1!=n ) uerror( "too many initializers (%d>%d)",
        !          1927:                        n, d1);
        !          1928:                if( n==0 ) werror( "empty array declaration");
        !          1929:                dimtab[d] = n;
        !          1930:        }
        !          1931: 
        !          1932:        else if( t == 8 || t == 9 )
        !          1933:        {
        !          1934:                
        !          1935:                inforce( tsize( t, d, s ) );
        !          1936:        }
        !          1937:        else if( n > 1 ) uerror("%d initializers for a scalar", n);
        !          1938:        
        !          1939:        else inforce( tsize(t,d,s) );
        !          1940: 
        !          1941:        paramno = 0;
        !          1942:        vfdalign( 32 );
        !          1943:        inoff = 0;
        !          1944:        iclass = 0;
        !          1945: 
        !          1946: }
        !          1947: 
        !          1948: doinit( p )
        !          1949: register NODE *p; 
        !          1950: 
        !          1951: {
        !          1952: 
        !          1953:        
        !          1954:        
        !          1955: 
        !          1956: 
        !          1957: 
        !          1958:        register sz, d, s;
        !          1959:        register TWORD t;
        !          1960: 
        !          1961:        
        !          1962: 
        !          1963:        if(nerrors)
        !          1964:                goto leave;
        !          1965:        if( iclass < 0 ) goto leave;
        !          1966:        if( iclass == 2 || iclass == 12 )
        !          1967:        {
        !          1968:                uerror( "cannot initialize extern or union" );
        !          1969:                iclass = -1;
        !          1970:                goto leave;
        !          1971:        }
        !          1972: 
        !          1973:        if( iclass == 1 || iclass == 4 )
        !          1974:        {
        !          1975:                
        !          1976: 
        !          1977: 
        !          1978:                bccode();
        !          1979:                idname = pstk->in_id;
        !          1980:                p = buildtree( 58, buildtree( 2, (NODE *)0, (NODE *)0 ), p );
        !          1981:                ecomp(p);
        !          1982:                return;
        !          1983:        }
        !          1984: 
        !          1985:        if( p == (NODE *)0 ) return;  
        !          1986: 
        !          1987:        if( ibseen )
        !          1988:        {
        !          1989:                uerror( "} expected");
        !          1990:                goto leave;
        !          1991:        }
        !          1992: 
        !          1993: 
        !          1994:        if( idebug > 1 ) printf( "doinit(%o)\n", p );
        !          1995: 
        !          1996: 
        !          1997:        t = pstk->in_t;  
        !          1998:        d = pstk->in_d;
        !          1999:        s = pstk->in_s;
        !          2000:        if( pstk->in_sz < 0 )
        !          2001:        {
        !          2002:                  
        !          2003:                sz = -pstk->in_sz;
        !          2004:        }
        !          2005:        else 
        !          2006:        {
        !          2007:                sz = tsize( t, d, s );
        !          2008:        }
        !          2009: 
        !          2010:        inforce( pstk->in_off );
        !          2011: 
        !          2012:        p = buildtree( 58, block( 2, (NODE *)0,(NODE *)0, t, d, s ), p );
        !          2013:        p->in.left->in.op = 97;
        !          2014:        p->in.left = p->in.right;
        !          2015:        p->in.right = (NODE *)0;
        !          2016:        p->in.left = optim( p->in.left );
        !          2017:        if( p->in.left->in.op == 2+ 14 )
        !          2018:        {
        !          2019:                p->in.left->in.op = 97;
        !          2020:                p->in.left = p->in.left->in.left;
        !          2021:        }
        !          2022:        p->in.op = 113;
        !          2023:        p = optim(p);
        !          2024: 
        !          2025: 
        !          2026:        if( p->in.left->in.op == 5 )
        !          2027:        {
        !          2028:                fincode( p->in.left->fpn.dval, sz );
        !          2029:        }
        !          2030:        else
        !          2031: 
        !          2032:                if( p->in.left->in.op != 4 )
        !          2033:                {
        !          2034:                        uerror( "initialization by non-constant" );
        !          2035:                        inoff += sz;
        !          2036:                }
        !          2037:                else 
        !          2038:                {
        !          2039:                        
        !          2040:                        if( sz < 32 )
        !          2041:                        {
        !          2042:                                 
        !          2043:                        incode( p->in.left, sz );
        !          2044:                        }
        !          2045:                        else 
        !          2046:                        {
        !          2047: 
        !          2048:                                ecode( optim(p) );
        !          2049:                                inoff += sz;
        !          2050: 
        !          2051:                        }
        !          2052:                }
        !          2053: 
        !          2054:        gotscal();
        !          2055: 
        !          2056: leave:
        !          2057:        tfree(p);
        !          2058: }
        !          2059: 
        !          2060: gotscal()
        !          2061: {
        !          2062:        register t, ix;
        !          2063:        register n, id;
        !          2064:        register struct symtab *p;
        !          2065:        register OFFSZ temp;
        !          2066: 
        !          2067:        for( ; pstk > instack; ) 
        !          2068:        {
        !          2069: 
        !          2070:                if( pstk->in_fl ) ++ibseen;
        !          2071: 
        !          2072:                --pstk;
        !          2073: 
        !          2074:                t = pstk->in_t;
        !          2075: 
        !          2076:                if( t == 8 )
        !          2077:                {
        !          2078:                        ix = ++pstk->in_x;
        !          2079:                        if( (id=dimtab[ix]) < 0 ) continue;
        !          2080: 
        !          2081:                        
        !          2082: 
        !          2083:                        p = &stab[id];
        !          2084:                        instk( id, p->stype, p->dimoff, p->sizoff, p->offset+pstk->in_off );
        !          2085:                        return;
        !          2086:                }
        !          2087:                else if( ((t&(03<<5))==0140) )
        !          2088:                {
        !          2089:                        n = ++pstk->in_n;
        !          2090:                        if( n >= dimtab[pstk->in_d] && pstk > instack ) continue;
        !          2091: 
        !          2092:                        
        !          2093: 
        !          2094:                        temp = pstk->in_sz;
        !          2095:                        instk( pstk->in_id, (TWORD)(((pstk->in_t>>2)&~037)|(pstk->in_t&037)), pstk->in_d+1, pstk->in_s,
        !          2096:                        pstk->in_off+n*temp );
        !          2097:                        return;
        !          2098:                }
        !          2099: 
        !          2100:        }
        !          2101: 
        !          2102: }
        !          2103: 
        !          2104: ilbrace()
        !          2105: {
        !          2106:         
        !          2107:        register t;
        !          2108:        register struct instk *temp;
        !          2109: 
        !          2110:        temp = pstk;
        !          2111: 
        !          2112:        for( ; pstk > instack; --pstk )
        !          2113:        {
        !          2114: 
        !          2115:                t = pstk->in_t;
        !          2116:                if( t != 8 && !((t&(03<<5))==0140) ) continue; 
        !          2117:                if( pstk->in_fl )
        !          2118:                {
        !          2119:                         
        !          2120:                        if( pstk->in_n ) uerror( "illegal {");
        !          2121:                        continue;
        !          2122:                }
        !          2123: 
        !          2124:                
        !          2125:                pstk->in_fl = 1;
        !          2126:                break;
        !          2127:        }
        !          2128: 
        !          2129:        
        !          2130:        
        !          2131: 
        !          2132:        pstk = temp;
        !          2133: }
        !          2134: 
        !          2135: irbrace()
        !          2136: {
        !          2137:        
        !          2138: 
        !          2139: 
        !          2140:        if( idebug ) printf( "irbrace(): paramno = %d on entry\n", paramno );
        !          2141: 
        !          2142: 
        !          2143:        if( ibseen ) 
        !          2144:        {
        !          2145:                --ibseen;
        !          2146:                return;
        !          2147:        }
        !          2148: 
        !          2149:        for( ; pstk > instack; --pstk )
        !          2150:        {
        !          2151:                if( !pstk->in_fl ) continue;
        !          2152: 
        !          2153:                
        !          2154: 
        !          2155:                pstk->in_fl = 0;  
        !          2156:                gotscal();  
        !          2157:                return;
        !          2158:        }
        !          2159: 
        !          2160:        
        !          2161: 
        !          2162: }
        !          2163: 
        !          2164: upoff( size, alignment, poff )
        !          2165: register alignment, *poff; 
        !          2166: {
        !          2167:        
        !          2168: 
        !          2169: 
        !          2170: 
        !          2171: 
        !          2172:        register off;
        !          2173: 
        !          2174:        off = *poff;
        !          2175:        if( ( off)%( alignment ) != 0 )  off = ( (( off)/( alignment ) + 1) * ( alignment ));
        !          2176:        if( (maxoffset-off) < size )
        !          2177:        {
        !          2178:                if( instruct!=02 )cerror("local variables fill memory");
        !          2179:                else cerror("structure larger than address space");
        !          2180:        }
        !          2181:        *poff = off+size;
        !          2182:        return( off );
        !          2183: }
        !          2184: 
        !          2185: oalloc( p, poff )
        !          2186: register struct symtab *p; 
        !          2187: register *poff; 
        !          2188: {
        !          2189:        
        !          2190:        register al, off, tsz;
        !          2191:        int noff;
        !          2192: 
        !          2193:        al = talign( p->stype, p->sizoff );
        !          2194:        noff = off = *poff;
        !          2195:        tsz = tsize( p->stype, p->dimoff, p->sizoff );
        !          2196: 
        !          2197:        if( p->sclass == 1 )
        !          2198:        {
        !          2199:                if( (maxoffset-off) < tsz ) cerror("local variables fill memory");
        !          2200:                noff = off + tsz;
        !          2201:                if( ( noff)%( al ) != 0 )  noff = ( (( noff)/( al ) + 1) * ( al ));
        !          2202:                off = -noff;
        !          2203:        }
        !          2204:        else
        !          2205: 
        !          2206: 
        !          2207:                        if( p->sclass == 9 && ( tsz % 32 ) )
        !          2208:                        {       
        !          2209: 
        !          2210:                                tsz = (tsz+32-1)/32;
        !          2211:                                off = upoff(tsz*32, 32, &noff );
        !          2212: 
        !          2213:                        }
        !          2214:                        else
        !          2215:                        {
        !          2216:                                off = upoff( tsz, al, &noff );
        !          2217:                        }
        !          2218: 
        !          2219:        if( p->sclass != 4 )
        !          2220:        {
        !          2221:                 
        !          2222:                if( p->offset == (-10201) ) p->offset = off;
        !          2223:                        else if( off != p->offset ) return(1);
        !          2224:        }
        !          2225: 
        !          2226:        *poff = noff;
        !          2227:        return(0);
        !          2228: }
        !          2229: 
        !          2230: falloc( p, w, new, pty )
        !          2231: register struct symtab *p; 
        !          2232: register NODE *pty; 
        !          2233: {
        !          2234:        
        !          2235:        
        !          2236: 
        !          2237:        register al,sz,type;
        !          2238: 
        !          2239:        type = (new<0)? pty->in.type : p->stype;
        !          2240: 
        !          2241:        
        !          2242:        switch( new<0?pty->in.type:p->stype )
        !          2243:        {
        !          2244: 
        !          2245:        case 10:
        !          2246:                {
        !          2247:                        register s;
        !          2248:                        s = new<0 ? pty->fn.csiz : p->sizoff;
        !          2249:                        al = dimtab[s+2];
        !          2250:                        sz = dimtab[s];
        !          2251:                        break;
        !          2252:                }
        !          2253: 
        !          2254:        case 2:
        !          2255:        case 12:
        !          2256:                al = 8;
        !          2257:                sz = 8;
        !          2258:                break;
        !          2259: 
        !          2260:        case 3:
        !          2261:        case 13:
        !          2262:                al = 16;
        !          2263:                sz = 16;
        !          2264:                break;
        !          2265: 
        !          2266:        case 4:
        !          2267:        case 14:
        !          2268:                al = 32;
        !          2269:                sz = 32;
        !          2270:                break;
        !          2271: 
        !          2272: 
        !          2273:        default:
        !          2274: 
        !          2275:                        uerror( "illegal field type" );
        !          2276:                        al = 32;
        !          2277: 
        !          2278:        }
        !          2279: 
        !          2280:        if( w > sz ) 
        !          2281:        {
        !          2282:                uerror( "field too big (%d>%d)", w, sz);
        !          2283:                w = sz;
        !          2284:        }
        !          2285: 
        !          2286:        if( w == 0 )
        !          2287:        {
        !          2288:                 
        !          2289:                if( ( strucoff)%( al ) != 0 )  strucoff = ( (( strucoff)/( al ) + 1) * ( al ));
        !          2290:                if( new >= 0 ) uerror( "zero size field");
        !          2291:                return(0);
        !          2292:        }
        !          2293: 
        !          2294:        if( strucoff%al + w > sz ) if( ( strucoff)%( al ) != 0 )  strucoff = ( (( strucoff)/( al ) + 1) * ( al ));
        !          2295:        if( new < 0 ) 
        !          2296:        {
        !          2297:                if( (maxoffset-strucoff) < w )
        !          2298:                        cerror("structure fills memory");
        !          2299:                strucoff += w;  
        !          2300:                return(0);
        !          2301:        }
        !          2302: 
        !          2303:        
        !          2304: 
        !          2305:        if( new == 1 ) 
        !          2306:        {
        !          2307:                 
        !          2308:                if( p->offset != strucoff || p->sclass != (0100|w) ) return(1);
        !          2309:        }
        !          2310:        p->offset = strucoff;
        !          2311:        if( (maxoffset-strucoff) < w ) cerror("structure overflows memory");
        !          2312:        strucoff += w;
        !          2313:        p->stype = type;
        !          2314:        return(0);
        !          2315: }
        !          2316: 
        !          2317: 
        !          2318: 
        !          2319: 
        !          2320: 
        !          2321: nidcl( p )
        !          2322: register NODE *p; 
        !          2323: {
        !          2324:         
        !          2325:        
        !          2326:        register class;
        !          2327:        register commflag;  
        !          2328: 
        !          2329:        commflag = 0;
        !          2330: 
        !          2331:        
        !          2332:        if( (class=curclass) == 0 )
        !          2333:        {
        !          2334:                if( blevel > 1 ) class = 1;
        !          2335:                else if( blevel != 0 || instruct ) cerror( "nidcl error" );
        !          2336:                else 
        !          2337:                {
        !          2338:                         
        !          2339:                        if( (class = 2) == 2 ) commflag = 1;
        !          2340:                }
        !          2341:        }
        !          2342: 
        !          2343:        defid( p, class );
        !          2344: 
        !          2345:        if( class==5 || class==3 ) 
        !          2346:        {
        !          2347: 
        !          2348: 
        !          2349:                commflag = 1;
        !          2350: 
        !          2351: 
        !          2352:        }
        !          2353:        if( commflag ) commdec( p->tn.rval );
        !          2354: }
        !          2355: 
        !          2356: TWORD
        !          2357: types( t1, t2, t3 )
        !          2358: register TWORD t1, t2, t3; 
        !          2359: {
        !          2360:        
        !          2361: 
        !          2362:        TWORD t[3];
        !          2363:        register TWORD  noun, adj, unsg;
        !          2364:        register i;
        !          2365: 
        !          2366:        t[0] = t1;
        !          2367:        t[1] = t2;
        !          2368:        t[2] = t3;
        !          2369: 
        !          2370:        unsg = 4;  
        !          2371:        noun = 17;  
        !          2372:        adj = 4;  
        !          2373: 
        !          2374:        for( i=0; i<3; ++i )
        !          2375:        {
        !          2376:                switch( t[i] )
        !          2377:                {
        !          2378: 
        !          2379:                default:
        !          2380: bad:
        !          2381:                        uerror( "illegal type combination" );
        !          2382:                        return( 4 );
        !          2383: 
        !          2384:                case 17:
        !          2385:                        continue;
        !          2386: 
        !          2387:                case 14:
        !          2388:                        if( unsg != 4 ) goto bad;
        !          2389:                        unsg = 14;
        !          2390:                        continue;
        !          2391: 
        !          2392:                case 5:
        !          2393:                case 3:
        !          2394:                        if( adj != 4 ) goto bad;
        !          2395:                        adj = t[i];
        !          2396:                        continue;
        !          2397: 
        !          2398:                case 4:
        !          2399:                case 2:
        !          2400:                case 6:
        !          2401:                        if( noun != 17 ) goto bad;
        !          2402:                        noun = t[i];
        !          2403:                        continue;
        !          2404:                }
        !          2405:        }
        !          2406: 
        !          2407:        
        !          2408:        if( noun == 17 ) noun = 4;
        !          2409:        else if( noun == 6 )
        !          2410:        {
        !          2411:                if( unsg != 4 || adj == 3 ) goto bad;
        !          2412:                return( adj==5 ? 7 : 6 );
        !          2413:        }
        !          2414:        else if( noun == 2 && adj != 4 ) goto bad;
        !          2415: 
        !          2416:        
        !          2417:        if( adj != 4 ) noun = adj;
        !          2418:        if( unsg == 14 ) return( noun + (14-4) );
        !          2419:        else return( noun );
        !          2420: }
        !          2421: 
        !          2422: NODE *
        !          2423: tymerge( typ, idp )
        !          2424: register NODE *typ, *idp; 
        !          2425: 
        !          2426: {
        !          2427:        
        !          2428: 
        !          2429:        register unsigned t;
        !          2430:        register i;
        !          2431: 
        !          2432:        if( typ->in.op != 33 ) cerror( "tymerge: arg 1" );
        !          2433:        if(idp == (NODE *)0 ) return( (NODE *)0 );
        !          2434: 
        !          2435: 
        !          2436:        if( ddebug > 2 ) eprint(idp);
        !          2437: 
        !          2438: 
        !          2439:        idp->in.type = typ->in.type;
        !          2440:        idp->fn.cdim = curdim;
        !          2441:        tyreduce( idp );
        !          2442:        idp->fn.csiz = typ->fn.csiz;
        !          2443: 
        !          2444:        for( t=typ->in.type, i=typ->fn.cdim; t&(03<<5); t = (((t>>2)&~037)|(t&037)) )
        !          2445:        {
        !          2446:                if( ((t&(03<<5))==0140) ) dstash( dimtab[i++] );
        !          2447:        }
        !          2448: 
        !          2449:        
        !          2450: 
        !          2451:        idp->in.type = ctype( idp->in.type );
        !          2452: 
        !          2453:        if( (t = (idp->in.type&037)) != 8 && t != 9 && t != 10 )
        !          2454:        {
        !          2455:                idp->fn.csiz = t;  
        !          2456:        }
        !          2457: 
        !          2458:        return( idp );
        !          2459: }
        !          2460: 
        !          2461: tyreduce( p )
        !          2462: register NODE *p; 
        !          2463: 
        !          2464: {
        !          2465: 
        !          2466:        
        !          2467:        
        !          2468: 
        !          2469:        register o, temp;
        !          2470:        register unsigned t;
        !          2471: 
        !          2472:        o = p->in.op;
        !          2473:        p->in.op = 97;
        !          2474: 
        !          2475:        if( o == 2 ) return;
        !          2476: 
        !          2477:        t = ((( p->in.type &~037)<<2)|040|( p->in.type &037));
        !          2478:        if( o == 2+ 70 ) t += (0100-040);
        !          2479:        else if( o == 54 )
        !          2480:        {
        !          2481:                t += (0140-040);
        !          2482:                temp = p->in.right->tn.lval;
        !          2483:                p->in.right->in.op = 97;
        !          2484:        }
        !          2485: 
        !          2486:        p->in.left->in.type = t;
        !          2487:        tyreduce( p->in.left );
        !          2488: 
        !          2489:        if( o == 54 ) dstash( temp );
        !          2490: 
        !          2491:        p->tn.rval = p->in.left->tn.rval;
        !          2492:        p->in.type = p->in.left->in.type;
        !          2493: 
        !          2494: }
        !          2495: 
        !          2496: fixtype( p, class )
        !          2497: register NODE *p; 
        !          2498: register class;
        !          2499: {
        !          2500:        register unsigned t, type;
        !          2501:        register mod1, mod2;
        !          2502:        
        !          2503: 
        !          2504:        if( (type = p->in.type) == 17 ) return;
        !          2505:        if( mod2 = (type&(03<<5)) )
        !          2506:        {
        !          2507:                t = (((type>>2)&~037)|(type&037));
        !          2508:                while( mod1=mod2, mod2 = (t&(03<<5)) )
        !          2509:                {
        !          2510:                        if( mod1 == 0140 && mod2 == 0100 )
        !          2511:                        {
        !          2512:                                uerror( "array of functions is illegal" );
        !          2513:                                type = 0;
        !          2514:                        }
        !          2515:                        else if( mod1==0100 && ( mod2==0140 || mod2==0100 ) )
        !          2516:                        {
        !          2517:                                uerror( "function returns array or function" );
        !          2518:                                type = 0;
        !          2519:                        }
        !          2520:                        t = (((t>>2)&~037)|(t&037));
        !          2521:                }
        !          2522:        }
        !          2523: 
        !          2524:        
        !          2525:        
        !          2526:        
        !          2527: 
        !          2528:        if( class==0 && blevel==1 && !(instruct&(02|04)) )
        !          2529:                class = 9;
        !          2530:        if( class == 9 || ( class==4 && blevel==1 ) )
        !          2531:        {
        !          2532:                if( type == 6 ) type = 7;
        !          2533:                else if( ((type&(03<<5))==0140) )
        !          2534:                {
        !          2535:                        ++p->fn.cdim;
        !          2536:                        type += (040-0140);
        !          2537:                }
        !          2538:                else if( ((type&(03<<5))==0100) )
        !          2539:                {
        !          2540:                        werror( "a function is declared as an argument" );
        !          2541:                        type = (((type&~037)<<2)|040|(type&037));
        !          2542:                }
        !          2543:        }
        !          2544: 
        !          2545:        if( instruct && ((type&(03<<5))==0100) )
        !          2546:        {
        !          2547:                uerror( "function illegal in structure or union" );
        !          2548:                type = (((type&~037)<<2)|040|(type&037));
        !          2549:        }
        !          2550:        p->in.type = type;
        !          2551: }
        !          2552: 
        !          2553: 
        !          2554: TWORD
        !          2555: ctype( t )
        !          2556: register TWORD t; 
        !          2557: {
        !          2558:        register TWORD bt;
        !          2559:        bt = (t&037);
        !          2560: 
        !          2561: 
        !          2562: 
        !          2563: 
        !          2564: 
        !          2565: 
        !          2566: 
        !          2567:        if( bt==5 ) t = (t&(~037))|4;
        !          2568:        else if( bt==15) t = (t&(~037))|14;
        !          2569: 
        !          2570: 
        !          2571: 
        !          2572: 
        !          2573:        return( t );
        !          2574: }
        !          2575: 
        !          2576: 
        !          2577: uclass( class ) 
        !          2578: register class; 
        !          2579: {
        !          2580:        
        !          2581:        if( class == 0 ) return( 2 );
        !          2582:        else if( class == 3 ) return( 18 );
        !          2583:        else if( class == 14 ) return( 17 );
        !          2584:        else return( class );
        !          2585: }
        !          2586: 
        !          2587: fixclass( class, type )
        !          2588: register TWORD type; 
        !          2589: register class;
        !          2590: 
        !          2591: {
        !          2592: 
        !          2593:        
        !          2594: 
        !          2595:        if( class == 0 )
        !          2596:        {
        !          2597:                if( instruct&02 ) class = 8;
        !          2598:                else if( instruct&04 ) class = 11;
        !          2599:                else if( blevel == 0 ) class = 5;
        !          2600:                else if( blevel == 1 ) class = 9;
        !          2601:                else class = 1;
        !          2602: 
        !          2603:        }
        !          2604: 
        !          2605:        
        !          2606:        if(blevel == 1 && (class == 3 || class == 2))
        !          2607:                uerror("parameter declared with weird storage classs");
        !          2608:        if( (( type &(03<<5))==0100) )
        !          2609:        {
        !          2610:                switch( class ) 
        !          2611:                {
        !          2612:                default:
        !          2613:                        uerror( "function has illegal storage class" );
        !          2614:                case 1:
        !          2615:                        class = 2;
        !          2616:                case 2:
        !          2617:                case 5:
        !          2618:                case 14:
        !          2619:                case 13:
        !          2620:                case 3:
        !          2621:                case 17:
        !          2622:                case 18:
        !          2623:                        ;
        !          2624:                }
        !          2625:        }
        !          2626: 
        !          2627:        if( class&0100 )
        !          2628:        {
        !          2629:                if( !(instruct&02) ) uerror( "field not in structure" );
        !          2630:                return( class );
        !          2631:        }
        !          2632: 
        !          2633:        switch( class )
        !          2634:        {
        !          2635: 
        !          2636:        case 11:
        !          2637:                if( !(instruct&04) ) uerror( "illegal class" );
        !          2638:                return( class );
        !          2639: 
        !          2640:        case 8:
        !          2641:                if( !(instruct&02) ) uerror( "illegal class" );
        !          2642:                return( class );
        !          2643: 
        !          2644:        case 16:
        !          2645:                if( instruct & (02|04) ) uerror( "illegal class" );
        !          2646:                return( class );
        !          2647: 
        !          2648:        case 4:
        !          2649:                if( blevel == 0 ) uerror( "register declaration outside a fncn" );
        !          2650:                
        !          2651:                else if( cisreg( type ) ) return( class );
        !          2652:                if( blevel == 1 ) return( 9 );
        !          2653:                else return( 1 );
        !          2654: 
        !          2655:        case 1:
        !          2656:        case 6:
        !          2657:        case 7:
        !          2658:                if( blevel < 2 ) uerror( "auto outside function" );
        !          2659:                return( class );
        !          2660: 
        !          2661:        case 9:
        !          2662:                if( blevel != 1 ) uerror( "illegal class" );
        !          2663:                return( class );
        !          2664: 
        !          2665:        case 17:
        !          2666:        case 14:
        !          2667: 
        !          2668:                if( !((type&(03<<5))==0100) ) uerror( "fortran declaration must apply to function" );
        !          2669:                else 
        !          2670:                {
        !          2671:                        type = (((type>>2)&~037)|(type&037));
        !          2672:                        if( ((type&(03<<5))==0100) || ((type&(03<<5))==0140) || ((type&(03<<5))==040) ) 
        !          2673:                        {
        !          2674:                                uerror( "fortran function has wrong type" );
        !          2675:                        }
        !          2676:                }
        !          2677:        case 10:
        !          2678:        case 12:
        !          2679:        case 15:
        !          2680:        case 2:
        !          2681:        case 3:
        !          2682:        case 5:
        !          2683:        case 13:
        !          2684:        case 18:
        !          2685:                return( class );
        !          2686: 
        !          2687:        default:
        !          2688:                cerror( "illegal class: %d", class );
        !          2689:                
        !          2690:        }
        !          2691: }
        !          2692: 
        !          2693: struct symtab *
        !          2694: mknonuniq(idindex)
        !          2695: register *idindex; 
        !          2696: {
        !          2697:        
        !          2698:        
        !          2699:        
        !          2700:        register i;
        !          2701:        register struct symtab * sp;
        !          2702: 
        !          2703:        sp = & stab[ i= *idindex ]; 
        !          2704:        while( sp->stype != 0 )
        !          2705:        {
        !          2706:                 
        !          2707:                if( ++i >= 6000 )
        !          2708:                {
        !          2709:                        
        !          2710:                        i = 0;
        !          2711:                        sp = stab;
        !          2712:                }
        !          2713:                else ++sp;
        !          2714:                if( i == *idindex ) cerror("Symbol table full");
        !          2715:        }
        !          2716:        sp->sflags = 040 | 01;
        !          2717:        sp->sname = stab[*idindex].sname; 
        !          2718:        *idindex = i;
        !          2719: 
        !          2720:        if( ddebug )
        !          2721:        {
        !          2722:                printf( "\tnonunique entry for %s from %d to %d\n",
        !          2723:                sp->sname, *idindex, i );
        !          2724:        }
        !          2725: 
        !          2726:        return ( sp );
        !          2727: }
        !          2728: 
        !          2729: 
        !          2730: 
        !          2731: struct symtab *
        !          2732: relook(p)
        !          2733: register struct symtab *p; 
        !          2734: 
        !          2735: {
        !          2736:          
        !          2737:        register struct symtab *q;
        !          2738: 
        !          2739:        
        !          2740:        q = &stab[lookup( p->sname, p->sflags&(0100|01|02) )];
        !          2741:        
        !          2742:        if( q->stype == 17 )
        !          2743:        {
        !          2744:                q->stype = 0;
        !          2745:                return(q);
        !          2746:        }
        !          2747:        while( q != p )
        !          2748:        {
        !          2749:                if( q->stype == 0 ) break;
        !          2750:                if( ++q >= &stab[6000] ) q=stab;
        !          2751:        }
        !          2752:        return(q);
        !          2753: }
        !          2754: 
        !          2755: uplevel()
        !          2756: {
        !          2757:        ++blevel;
        !          2758: 
        !          2759:        dblbrac();
        !          2760: 
        !          2761: }
        !          2762: 
        !          2763: clearst( lev )
        !          2764: {
        !          2765:         
        !          2766:        extern struct symtab *scopestack[];
        !          2767:        register struct symtab *p, *q, *r;
        !          2768: 
        !          2769: 
        !          2770:        
        !          2771: 
        !          2772: 
        !          2773:        aobeg();
        !          2774:        p = scopestack[blevel];
        !          2775:        while (p)
        !          2776:        {
        !          2777:                aocode(p);
        !          2778:                p = p->scopelink;
        !          2779:        }
        !          2780:        aoend();
        !          2781:        if (lev != 1)   
        !          2782:                dbrbrac();
        !          2783: 
        !          2784: 
        !          2785:        
        !          2786: 
        !          2787:        q = (struct symtab *) 0;
        !          2788:        
        !          2789: 
        !          2790: 
        !          2791: 
        !          2792:        p = scopestack[lev];
        !          2793:        while (p)
        !          2794:        {
        !          2795: 
        !          2796:                if (ddebug)
        !          2797:                        printf("removing %s = stab[ %d], flags %o level %d\n",
        !          2798:                            p->sname,p-stab,p->sflags,p->slevel);
        !          2799: 
        !          2800:                
        !          2801:                if (p->stype == 17 ||
        !          2802:                                ( p->sclass == 7 && lev <=2) )  {
        !          2803:                        uerror("%s undefined", p->sname);
        !          2804:                }
        !          2805:                if( p->sflags & 04 )
        !          2806:                        unhide(p);
        !          2807:                if( (r=relook(p)) != p )
        !          2808:                        *r = *p;
        !          2809:                if ( lev > p->slevel ) {
        !          2810:                
        !          2811: 
        !          2812:                        r = p;
        !          2813:                        p = p->scopelink;
        !          2814:                        r->scopelink = q;
        !          2815:                        q = r;
        !          2816:                } else {
        !          2817:                        p->stype = 0;
        !          2818:                        p = p->scopelink;
        !          2819:                }
        !          2820:        }
        !          2821:        scopestack[lev] = (struct symtab *) 0;
        !          2822:        
        !          2823:        while( q )
        !          2824:        {
        !          2825:            r = &stab[ lookup( q->sname, q->sflags ) ];
        !          2826:            if ( r != q )
        !          2827:            {
        !          2828:                *r = *q;
        !          2829:                q->stype = 0;
        !          2830:            }
        !          2831:            q = q->scopelink;
        !          2832:            r->scopelink = scopestack[ lev-1 ];
        !          2833:            scopestack[ lev-1 ] = r;
        !          2834:        }
        !          2835: }
        !          2836: 
        !          2837: hide( p )
        !          2838: register struct symtab *p; 
        !          2839: {
        !          2840:        register struct symtab *q;
        !          2841:        for( q=p+1; ; ++q )
        !          2842:        {
        !          2843:                if( q >= &stab[6000] ) q = stab;
        !          2844:                if( q == p ) cerror( "symbol table full" );
        !          2845:                if( q->stype == 0 ) break;
        !          2846:        }
        !          2847:        *q = *p;
        !          2848:        p->sflags |= 02;
        !          2849:        q->sflags = (p->sflags&(01|0100)) | 04;
        !          2850:        if( hflag ) werror( "%s redefinition hides earlier one", p->sname );
        !          2851: 
        !          2852:        if( ddebug ) printf( "  %d hidden in %d\n", p-stab, q-stab );
        !          2853: 
        !          2854:        return( idname = q-stab );
        !          2855: }
        !          2856: 
        !          2857: unhide( p )
        !          2858: register struct symtab *p; 
        !          2859: {
        !          2860:        register struct symtab *q;
        !          2861:        register s;
        !          2862: 
        !          2863:        s = p->sflags & (01|0100);
        !          2864:        q = p;
        !          2865: 
        !          2866:        for(;;)
        !          2867:        {
        !          2868: 
        !          2869:                if( q == stab ) q = &stab[6000-1];
        !          2870:                else --q;
        !          2871: 
        !          2872:                if( q == p ) break;
        !          2873: 
        !          2874:                if( (q->sflags&(01|0100)) == s )
        !          2875:                {
        !          2876:                        if ( p->sname == q->sname )
        !          2877:                        {
        !          2878:                                 
        !          2879:                                q->sflags &= ~02;
        !          2880: 
        !          2881:                                if( ddebug ) printf( "unhide uncovered %d from %d\n", q-stab,p-stab);
        !          2882: 
        !          2883:                                return;
        !          2884:                        }
        !          2885:                }
        !          2886: 
        !          2887:        }
        !          2888:        cerror( "unhide fails" );
        !          2889: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.