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

1.1     ! root        1: /*ident        "@(#)ctrans:src/del.c   1.1.3.6" */
        !             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: extern int catch_delete_bugs;
        !            19: 
        !            20: void name::del()
        !            21: {
        !            22:        Pexpr i = n_initializer;
        !            23: 
        !            24:        if(permanent == 3 && catch_delete_bugs>1) 
        !            25:            error ('i', "Deleting a name node twice.");
        !            26: 
        !            27:        permanent = 3;
        !            28:        if(catch_delete_bugs>1)base = XDELETED_NODE; 
        !            29: 
        !            30: // printf( "\nname::del: %d %s", this, string?string:"no name" );
        !            31: //     NFn++;
        !            32:        DEL(tp);
        !            33:        if(i && i!=(Pexpr)1) DEL(i);
        !            34:        delete this;
        !            35: }
        !            36: 
        !            37: void type::del()
        !            38: {
        !            39: //fprintf(stderr,"DEL(type=%d %d)\n",this,base);
        !            40:        if(permanent == 3 && catch_delete_bugs>1) 
        !            41:            error ('i', "Deleting a type node twice.");
        !            42: 
        !            43:        permanent = 3;  /* do not delete twice */
        !            44:        if(catch_delete_bugs>1)base = XDELETED_NODE; 
        !            45: 
        !            46:        switch (base) {
        !            47:        case TNAME:
        !            48:        case NAME:
        !            49:                error('i',"%d->T::del():N %s %d",this,Pname(this)->string,base);
        !            50:        case FCT:
        !            51:        {       Pfct f = (Pfct) this;
        !            52:                DEL(f->returns);
        !            53:                break;
        !            54:        }
        !            55:        case VEC:
        !            56:        {       Pvec v = (Pvec) this;
        !            57:                DEL(v->dim);
        !            58:                DEL(v->typ);
        !            59:                break;
        !            60:        }
        !            61:        case PTR:
        !            62:        case RPTR:
        !            63:        {       Pptr p = (Pptr) this;
        !            64:                DEL(p->typ);
        !            65:                break;
        !            66:        }
        !            67:        }
        !            68: 
        !            69:        delete this;
        !            70: }
        !            71: 
        !            72: void expr::del()
        !            73: {
        !            74: //fprintf(stderr,"DEL(expr=%d: %d %d %d)\n",this,base,e1,e2); fflush(stderr);
        !            75:        if(permanent == 3 && catch_delete_bugs>1) 
        !            76:            error ('i', "Deleting a expr node twice.");
        !            77:        permanent = 3;
        !            78:        if(catch_delete_bugs>1)base = XDELETED_NODE; 
        !            79: 
        !            80:        switch (base) {
        !            81:        case IVAL:
        !            82:                if (this == one) return;
        !            83:        case FVAL:
        !            84:        case THIS:
        !            85:        case ICON:
        !            86:        case FCON:
        !            87:        case CCON:
        !            88:        case STRING:
        !            89:        case TEXT:
        !            90:                goto dd;
        !            91:        case DUMMY:
        !            92:        case ZERO:
        !            93:        case NAME:
        !            94:                return;
        !            95:        case CAST:
        !            96:        case SIZEOF:
        !            97:        case NEW:
        !            98:        case GNEW:
        !            99:        case VALUE:
        !           100:                DEL(tp2);
        !           101:                break;
        !           102:        case REF:
        !           103:        case DOT:
        !           104:                DEL(e1);
        !           105:                if (e2) DEL(e2);
        !           106:        case MDOT:
        !           107:                if (mem && mem->base!=NAME) DEL(mem);
        !           108:                goto dd;
        !           109:        case QUEST:
        !           110:                DEL(cond);
        !           111:                break;
        !           112:        case ICALL:
        !           113:                delete il->i_args;
        !           114:                delete il;
        !           115:                goto dd;
        !           116:        }
        !           117: 
        !           118:        DEL(e1);
        !           119:        DEL(e2);
        !           120: /*     DEL(tp);*/
        !           121: dd:
        !           122:        delete this;
        !           123: //     NFe++;
        !           124: }
        !           125: 
        !           126: void stmt::del()
        !           127: {
        !           128: //fprintf(stderr,"DEL(stmt %d %s)\n",this,keys[base]); fflush(stderr);
        !           129:        if(permanent == 3 && catch_delete_bugs>1) 
        !           130:            error ('i', "Deleting a stmt node twice.");
        !           131:        permanent = 3;
        !           132:        if(catch_delete_bugs>1)base = XDELETED_NODE; 
        !           133:        switch (base) {
        !           134:        case SM:
        !           135:        case WHILE:
        !           136:        case DO:
        !           137:        case RETURN:
        !           138:        case CASE:
        !           139:        case SWITCH:
        !           140:                DEL(e);
        !           141:                break;
        !           142:        case PAIR:
        !           143:                DEL(s2);
        !           144:                break;
        !           145:        case BLOCK:
        !           146:                DEL(d);
        !           147:                DEL(s);
        !           148:                if (own_tbl) DEL(memtbl);
        !           149:                DEL(s_list);
        !           150:                goto dd;
        !           151:        case FOR:
        !           152:                DEL(e);
        !           153:                DEL(e2);
        !           154:                DEL(for_init);
        !           155:                break;
        !           156:        case IF:
        !           157:                DEL(e);
        !           158:                DEL(else_stmt);
        !           159:                break;
        !           160:        }
        !           161: 
        !           162:        DEL(s);
        !           163:        DEL(s_list);
        !           164: dd:
        !           165:        delete this;
        !           166: //     NFs++;
        !           167: }
        !           168: 
        !           169: void table::del()
        !           170: {
        !           171:        for (register i=1; i<free_slot; i++) {
        !           172:                Pname n = entries[i];
        !           173:                if (n==0) error('i',"table.del(0)");
        !           174: 
        !           175: //printf( "\ntable::del: %s n_scope: %d, n_stclass: %d", n->string, n->n_scope, n->n_stclass );
        !           176: 
        !           177:                /* No matter what, remove the name from the table. */
        !           178:                n->n_table = 0;
        !           179:                n->n_tbl_list = 0;
        !           180: 
        !           181:                if (n->n_stclass == STATIC) continue;
        !           182:                switch (n->n_scope) {
        !           183:                case ARG:
        !           184:                case ARGT:
        !           185:                        break;
        !           186:                default:
        !           187:                        {       
        !           188:                            if(n->permanent == 0) {
        !           189:                                char* s = n->string;
        !           190:                                if (s && (s[0]!='_' || s[1]!='_' || s[2]!='X')) delete s;
        !           191:                                /* delete n; */
        !           192:                                n->del();
        !           193:                            } 
        !           194:                        }
        !           195:                }
        !           196:        }
        !           197:        delete entries;
        !           198:        delete hashtbl;
        !           199:        delete this;
        !           200: }
        !           201: 
        !           202: // local class
        !           203: void delete_local() 
        !           204: {
        !           205: // error( 'd', "delete_local: vlist: %d", vlist );
        !           206:     do {
        !           207:        for (vl* v = vlist; v; v = v->next) v->cl->really_print(v->vt);
        !           208:        vlist = 0;
        !           209: 
        !           210:        for (Plist l=isf_list; l; l=l->l) {
        !           211:                Pname n = l->f;
        !           212:                Pfct f = Pfct(n->tp);
        !           213: // error('d',"isf %n f %d",n,f);
        !           214:                if ( f == 0 ) { error('d', "delete_local: f == 0" );break;} 
        !           215:                if (f->base == OVERLOAD) {
        !           216:                        n = Pgen(f)->fct_list->f;       // first fct
        !           217:                        f = Pfct(n->tp);
        !           218:                }
        !           219: 
        !           220:                if (debug_opt==0 && n->n_addr_taken) {
        !           221:                        f->f_inline = 0;
        !           222:                        if (n->n_dcl_printed<2) n->dcl_print(0);
        !           223:                }
        !           224:        }
        !           225:        isf_list = 0;
        !           226:     } while (vlist);
        !           227: 
        !           228:     for ( Plist l = local_class; l; l = l->l )
        !           229:     {
        !           230:           Pname n = l->f;
        !           231: // error( 'd' , "delete_local() %d %n %t", n, n, n->tp );
        !           232: // printf( "\ndelete_local: %d %s", n, n->string );
        !           233:     Pname nn = Pbase(n->tp)->b_name;
        !           234:     Pclass cl = Pclass(nn->tp);
        !           235:        for (Pname px, p=cl->mem_list; p; p=px) {
        !           236:                px = p->n_list;
        !           237:                if (p->tp)
        !           238:                switch (p->tp->base) {
        !           239:                        case FCT:
        !           240:                        {       Pfct f = (Pfct)p->tp;
        !           241:                                if (f->body) {
        !           242:                                    if (f->f_inline==0
        !           243:                                    && f->f_imeasure==0) {
        !           244:                                        DEL(f->body);
        !           245:                                        f->body = 0;
        !           246:                                        }
        !           247:                                }
        !           248:                        }
        !           249:                        case COBJ:
        !           250:                        case EOBJ:
        !           251:                                DEL(p);
        !           252:                                break;
        !           253:                        case CLASS:
        !           254:                        case ENUM:
        !           255:                                break;
        !           256:                        default:
        !           257:                                delete p;
        !           258:                        } // end switch
        !           259:                else delete p;
        !           260:        } // end for mem
        !           261:         DEL(cl->memtbl);
        !           262:        cl->mem_list = 0;
        !           263:        cl->permanent = 3;
        !           264:        if(catch_delete_bugs>1)cl->base = XDELETED_NODE; 
        !           265:         nn->permanent = 0;
        !           266:        DEL(nn);
        !           267:        n->permanent = 0;
        !           268:        extern void table_delete( char*, TOK, int );
        !           269: // error( 'd', "local delete: n_key: %k lex_level: %d", n->n_key, n->lex_level );
        !           270:        table_delete( n->string, LOCAL, n->lex_level );
        !           271:        DEL(n);
        !           272:     }
        !           273: }
        !           274: 
        !           275: /* ODI notes
        !           276:    fix logic bugs in deleting tables, names
        !           277:    have to have n_table zeroed if not deleted.
        !           278: 
        !           279:    catch delete bugs.
        !           280: 
        !           281:    free lists moved to operator new/delete in alloc.c
        !           282: */

unix.superglobalmegacorp.com

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