Annotation of researchv10no/cmd/cfront/ocfront/del.c, revision 1.1

1.1     ! root        1: /*ident        "@(#)ctrans:src/del.c   1.1.3.8" */
        !             2: /************************************************************
        !             3: 
        !             4:        C++ source for cfront, the C++ compiler front-end
        !             5:        written in the computer science research center of Bell Labs
        !             6: 
        !             7:        Copyright (c) 1984 AT&T Technologies, Inc. All rigths Reserved
        !             8:        THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T, INC.
        !             9: 
        !            10: del.c:
        !            11: 
        !            12:        walk the trees to reclaim storage
        !            13: 
        !            14: **************************************************************/
        !            15: 
        !            16: #include "cfront.h"
        !            17: 
        !            18: void name::del()
        !            19: {
        !            20:        DB( if(Adebug>=1) {
        !            21:                fprintf(stderr,"\n*** '%s'->del()",string?string:"???");
        !            22:                display_type(tp); putc(' ',stderr);
        !            23:                where.put(stderr); putc('\n',stderr);
        !            24:            }
        !            25:            if ( base!=NAME && base!=TNAME ) error('i',"name::del() of%k -- id==%ld",base,node::id);
        !            26:        );
        !            27:        Pexpr i = n_initializer;
        !            28: 
        !            29: // error('d', "\nname::del: %d %s", this, string?string:"no name" );
        !            30: //     NFn++;
        !            31:        DEL(tp);
        !            32:        if(i && i!=(Pexpr)1) DEL(i);
        !            33:        delete this;
        !            34: }
        !            35: 
        !            36: void type::del()
        !            37: {
        !            38:        DB( if(Adebug>=1) {
        !            39:                fprintf(stderr,"\n*** '");
        !            40:                display_type(this);
        !            41:                fprintf(stderr," '->del()\n");
        !            42:            }
        !            43:            if(!node::allocated) error('i',"deleting unallocated type node! %t -- id==%ld",this,node::id);
        !            44:            node::allocated = 0;
        !            45:        );
        !            46: //fprintf(stderr,"DEL(type=%d %d)\n",this,base);
        !            47:        permanent = 3;  /* do not delete twice */
        !            48:        switch (base) {
        !            49:        case TNAME:
        !            50:        case NAME:
        !            51:                error('i',"%d->T::del():N %s %d",this,Pname(this)->string,base);
        !            52:        case FCT:
        !            53:        {       Pfct f = (Pfct) this;
        !            54:                DEL(f->returns);
        !            55:                break;
        !            56:        }
        !            57:        case VEC:
        !            58:        {       Pvec v = (Pvec) this;
        !            59:                DEL(v->dim);
        !            60:                DEL(v->typ);
        !            61:                break;
        !            62:        }
        !            63:        case PTR:
        !            64:        case RPTR:
        !            65:        {       Pptr p = (Pptr) this;
        !            66:                DEL(p->typ);
        !            67:                break;
        !            68:        }
        !            69:        }
        !            70: 
        !            71:        delete this;
        !            72: }
        !            73: 
        !            74: void expr::del()
        !            75: {
        !            76:        DB( if(Adebug>=1) {
        !            77:                fprintf(stderr,"\n*** expr::del():  ");
        !            78:                display_expr(this,0,1);
        !            79:                if(Adebug>=2) display_expr(this);
        !            80:        });
        !            81: //fprintf(stderr,"DEL(expr=%d: %d %d %d)\n",this,base,e1,e2); fflush(stderr);
        !            82:        permanent = 3;
        !            83:        switch (base) {
        !            84:        case IVAL:
        !            85:                if (this == one) return;
        !            86:        //case FVAL:
        !            87:        case THIS:
        !            88:        case ICON:
        !            89:        case FCON:
        !            90:        case CCON:
        !            91:        case STRING:
        !            92:        case TEXT:
        !            93:                goto dd;
        !            94:        case DUMMY:
        !            95:        case ZERO:
        !            96:        case NAME:
        !            97:                return;
        !            98:        case CAST:
        !            99:        case SIZEOF:
        !           100:        case NEW:
        !           101:        case GNEW:
        !           102:        case VALUE:
        !           103:                DEL(tp2);
        !           104:                break;
        !           105:        case REF:
        !           106:        case DOT:
        !           107:                DEL(e1);
        !           108:                if (e2) DEL(e2);
        !           109:        case MDOT:
        !           110:                if (mem && mem->base!=NAME) DEL(mem);
        !           111:                if ( i1 == 5 ) delete string4;
        !           112:                goto dd;
        !           113:        case QUEST:
        !           114:                DEL(cond);
        !           115:                break;
        !           116:        case ICALL:
        !           117:                delete il->i_args;
        !           118:                delete il;
        !           119:                goto dd;
        !           120:        case ELIST: { // limit recursion
        !           121:                Pexpr tp = e2;
        !           122:                while ( tp && tp->e2 && tp->e2->base == ELIST ) {
        !           123:                        Pexpr x = tp;
        !           124:                        if ( x->permanent ) break;
        !           125:                        x->permanent = 3;
        !           126:                        tp = tp->e2;
        !           127:                        if ( x->e1 ) DEL(x->e1);
        !           128:                        delete x;
        !           129:                }
        !           130:                e2 = tp;
        !           131:                break;
        !           132:                }
        !           133:        }
        !           134: 
        !           135:        DEL(e1);
        !           136:        DEL(e2);
        !           137: dd:
        !           138:        delete this;
        !           139: }
        !           140: 
        !           141: void stmt::del()
        !           142: {
        !           143:        DB( if(Adebug>=1) {
        !           144:                fprintf(stderr,"\n*** stmt::del():  ");
        !           145:                display_stmt(this,0,1);
        !           146:                if(Adebug>=2) display_stmt(this);
        !           147:        });
        !           148: //fprintf(stderr,"DEL(stmt %d %s)\n",this,keys[base]); fflush(stderr);
        !           149:        permanent = 3;
        !           150:        switch (base) {
        !           151:        case SM:
        !           152:        case WHILE:
        !           153:        case DO:
        !           154:        case RETURN:
        !           155:        case CASE:
        !           156:        case SWITCH:
        !           157:                DEL(e);
        !           158:                break;
        !           159:        case PAIR:
        !           160:                DEL(s2);
        !           161:                break;
        !           162:        case BLOCK:
        !           163:                DEL(d);
        !           164:                DEL(s);
        !           165:                if (own_tbl) DEL(memtbl);
        !           166:                DEL(s_list);
        !           167:                goto dd;
        !           168:        case FOR:
        !           169:                DEL(e);
        !           170:                DEL(e2);
        !           171:                DEL(for_init);
        !           172:                break;
        !           173:        case IF:
        !           174:                DEL(e);
        !           175:                DEL(else_stmt);
        !           176:                break;
        !           177:        }
        !           178: 
        !           179:        DEL(s);
        !           180:        DEL(s_list);
        !           181: dd:
        !           182:        delete this;
        !           183: }
        !           184: 
        !           185: void table::del()
        !           186: {
        !           187: // error('d',"\n*** %d::del() -- '%s'\n",this, t_name?t_name->string:"???");
        !           188:        DB( if(Adebug>=1) {
        !           189:                fprintf(stderr,"\n*** table:;del() -- '%s'\n",t_name?t_name->string:"???");
        !           190:            }
        !           191:            if(!node::allocated) error('i',"deleting unallocated table %s! -- id==%ld", t_name?t_name->string:"???",node::id);
        !           192:            node::allocated = 0;
        !           193:        );
        !           194:        for (register i=1; i<free_slot; i++) {
        !           195:                Pname n = entries[i];
        !           196:                if (n==0) error('i',"table.del(0)");
        !           197:                DB( if(Adebug>=2) { fprintf(stderr,"  name: '%s'",n->string);
        !           198:                        display_type(n->tp); putc('\n',stderr);
        !           199:                });
        !           200: // error( 'd',"\ntable::del: %s n_scope: %d, n_stclass: %d", n->string, n->n_scope, n->n_stclass );
        !           201:                if (n->n_stclass == STATIC) continue;
        !           202:                switch (n->n_scope) {
        !           203:                case ARG:
        !           204:                case ARGT:
        !           205:                        break;
        !           206:                default:
        !           207:                {       char* s = n->string;
        !           208:                        if (s && (s[0]!='_' || s[1]!='_' || s[2]!='X')) delete s;
        !           209:                        /* delete n; */
        !           210:                        n->del();
        !           211:                }
        !           212:                }
        !           213:        }
        !           214:        delete entries;
        !           215:        delete hashtbl;
        !           216:        delete this;
        !           217: }
        !           218: 
        !           219: // local class
        !           220: void delete_local() 
        !           221: {
        !           222:        DB( if(Adebug>=1) {
        !           223:                fprintf( stderr, "delete_local: vlist: %d", vlist );
        !           224:        });
        !           225: // error( 'd', "delete_local: vlist: %d", vlist );
        !           226:     do {
        !           227:        for (vl* v = vlist; v; v = v->next) v->cl->really_print(v->vt);
        !           228:        vlist = 0;
        !           229: 
        !           230:        for (Plist l=isf_list; l; l=l->l) {
        !           231:                Pname n = l->f;
        !           232:                Pfct f = Pfct(n->tp);
        !           233: // error('d',"isf %n f %d",n,f);
        !           234:                if ( f == 0 ) { error('d', "delete_local: f == 0" );break;} 
        !           235:                if (f->base == OVERLOAD) {
        !           236:                        n = Pgen(f)->fct_list->f;       // first fct
        !           237:                        f = Pfct(n->tp);
        !           238:                }
        !           239: 
        !           240:                if (debug_opt==0 && n->n_addr_taken) {
        !           241:                        f->f_inline = 0;
        !           242:                        if (n->n_dcl_printed<2) {
        !           243:                                if (warning_opt)
        !           244:                                        error('w',"out-of-line copy of %n created",n);
        !           245:                                n->dcl_print(0);
        !           246:                        }
        !           247:                }
        !           248:        }
        !           249:        //isf_list = 0;
        !           250:     } while (vlist);
        !           251: 
        !           252:     for ( Plist l = local_class; l; l = l->l )
        !           253:     {
        !           254:           Pname n = l->f;
        !           255: // error( 'd' , "delete_local() %d %n %t", n, n, n->tp );
        !           256: // printf( "\ndelete_local: %d %s", n, n->string );
        !           257:     Pname nn = Pbase(n->tp)->b_name;
        !           258:     Pclass cl = Pclass(nn->tp);
        !           259:        for (Pname px, p=cl->mem_list; p; p=px) {
        !           260:                px = p->n_list;
        !           261:                if (p->tp)
        !           262:                switch (p->tp->base) {
        !           263:                        case FCT:
        !           264:                        {       Pfct f = (Pfct)p->tp;
        !           265:                                if (f->body) {
        !           266:                                    if (f->f_inline==0
        !           267:                                    && f->f_imeasure==0) {
        !           268:                                        if (f->f_this) f->f_this->n_table = 0;
        !           269:                                        DEL(f->body);
        !           270:                                        f->body = 0;
        !           271:                                        }
        !           272:                                }
        !           273:                        }
        !           274:                        case COBJ:
        !           275:                        case EOBJ:
        !           276:                                DEL(p);
        !           277:                                break;
        !           278:                        case CLASS:
        !           279:                        case ENUM:
        !           280:                                break;
        !           281:                        default:
        !           282:                                delete p;
        !           283:                        } // end switch
        !           284:                else delete p;
        !           285:        } // end for mem
        !           286:         DEL(cl->memtbl);
        !           287:        cl->mem_list = 0;
        !           288:        cl->permanent = 3;
        !           289:         nn->permanent = 0;
        !           290:        DEL(nn);
        !           291:        n->permanent = 0;
        !           292:        extern void table_delete( char*, TOK, int );
        !           293: // error( 'd', "local delete: n_key: %k lex_level: %d", n->n_key, n->lex_level );
        !           294:        table_delete( n->string, LOCAL, n->lex_level );
        !           295:        DEL(n);
        !           296:     }
        !           297: }

unix.superglobalmegacorp.com

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