|
|
1.1 ! root 1: /*ident "@(#)ctrans:src/del.c 1.3" */ ! 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, Inc. All rights 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: ); ! 44: //fprintf(stderr,"DEL(type=%d %d)\n",this,base); ! 45: permanent = 3; /* do not delete twice */ ! 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: delete f; ! 54: break; ! 55: } ! 56: case VEC: ! 57: { Pvec v = (Pvec) this; ! 58: DEL(v->dim); ! 59: DEL(v->typ); ! 60: delete v; ! 61: break; ! 62: } ! 63: case PTR: ! 64: case RPTR: ! 65: { Pptr p = (Pptr) this; ! 66: DEL(p->typ); ! 67: delete p; ! 68: break; ! 69: } ! 70: } ! 71: } ! 72: ! 73: void expr::del() ! 74: { ! 75: DB( if(Adebug>=1) { ! 76: fprintf(stderr,"\n*** expr::del(): "); ! 77: display_expr(this,0,1); ! 78: if(Adebug>=2) display_expr(this); ! 79: }); ! 80: //fprintf(stderr,"DEL(expr=%d: %d %d %d)\n",this,base,e1,e2); fflush(stderr); ! 81: permanent = 3; ! 82: switch (base) { ! 83: case IVAL: ! 84: if (this == one) return; ! 85: //case FVAL: ! 86: case THIS: ! 87: case ICON: ! 88: case FCON: ! 89: case CCON: ! 90: case STRING: ! 91: case TEXT: ! 92: goto dd; ! 93: case DUMMY: ! 94: case ZERO: ! 95: case NAME: ! 96: return; ! 97: case CAST: ! 98: case SIZEOF: ! 99: case NEW: ! 100: case GNEW: ! 101: case VALUE: ! 102: DEL(tp2); ! 103: break; ! 104: case REF: ! 105: case DOT: ! 106: DEL(e1); ! 107: if (e2) DEL(e2); ! 108: case MDOT: ! 109: if (mem && mem->base!=NAME) DEL(mem); ! 110: if ( i1 == 5 ) delete string4; ! 111: goto dd; ! 112: case QUEST: ! 113: DEL(cond); ! 114: break; ! 115: case ICALL: ! 116: delete il->i_args; ! 117: delete il; ! 118: goto dd; ! 119: case ELIST: { // limit recursion ! 120: Pexpr tp = e2; ! 121: while ( tp && tp->e2 && tp->e2->base == ELIST ) { ! 122: Pexpr x = tp; ! 123: if ( x->permanent ) break; ! 124: x->permanent = 3; ! 125: tp = tp->e2; ! 126: if ( x->e1 ) DEL(x->e1); ! 127: delete x; ! 128: } ! 129: e2 = tp; ! 130: break; ! 131: } ! 132: } ! 133: ! 134: DEL(e1); ! 135: DEL(e2); ! 136: dd: ! 137: delete this; ! 138: } ! 139: ! 140: void stmt::del() ! 141: { ! 142: DB( if(Adebug>=1) { ! 143: fprintf(stderr,"\n*** stmt::del(): "); ! 144: display_stmt(this,0,1); ! 145: if(Adebug>=2) display_stmt(this); ! 146: }); ! 147: //fprintf(stderr,"DEL(stmt %d %s)\n",this,keys[base]); fflush(stderr); ! 148: permanent = 3; ! 149: switch (base) { ! 150: case SM: ! 151: case WHILE: ! 152: case DO: ! 153: case RETURN: ! 154: case CASE: ! 155: case SWITCH: ! 156: DEL(e); ! 157: break; ! 158: case PAIR: ! 159: DEL(s2); ! 160: break; ! 161: case BLOCK: ! 162: DEL(d); ! 163: DEL(s); ! 164: if (own_tbl) DEL(memtbl); ! 165: DEL(s_list); ! 166: goto dd; ! 167: case FOR: ! 168: DEL(e); ! 169: DEL(e2); ! 170: DEL(for_init); ! 171: break; ! 172: case IF: ! 173: DEL(e); ! 174: DEL(else_stmt); ! 175: break; ! 176: } ! 177: ! 178: DEL(s); ! 179: DEL(s_list); ! 180: dd: ! 181: delete this; ! 182: } ! 183: ! 184: void table::del() ! 185: { ! 186: // error('d',"\n*** %d::del() -- '%s'\n",this, t_name?t_name->string:"???"); ! 187: ! 188: for (register i=1; i<free_slot; i++) { ! 189: Pname n = entries[i]; ! 190: if (n==0) error('i',"table.del(0)"); ! 191: DB( if(Adebug>=2) { fprintf(stderr," name: '%s'",n->string); ! 192: display_type(n->tp); putc('\n',stderr); ! 193: }); ! 194: ! 195: // error( 'd',"\ntable::del: %s n_scope: %d, n_stclass: %d", n->string, n->n_scope, n->n_stclass ); ! 196: ! 197: if (n->n_stclass == STATIC) continue; ! 198: switch (n->n_scope) { ! 199: case ARG: ! 200: case ARGT: ! 201: break; ! 202: default: ! 203: { char* s = n->string; ! 204: if (s && (s[0]!='_' || s[1]!='_' || s[2]!='X')) delete s; ! 205: /* delete n; */ ! 206: n->del(); ! 207: } ! 208: } ! 209: } ! 210: //delete entries; ! 211: //delete hashtbl; ! 212: delete this; ! 213: } ! 214: ! 215: // local class ! 216: void delete_local() ! 217: { ! 218: DB( if(Adebug>=1) { ! 219: fprintf( stderr, "delete_local: vlist: %d", vlist ); ! 220: }); ! 221: // error( 'd', "delete_local: vlist: %d", vlist ); ! 222: do { ! 223: for (vl* v = vlist; v; v = v->next) v->cl->really_print(v->vt); ! 224: vlist = 0; ! 225: ! 226: for (Plist l=isf_list; l; l=l->l) { ! 227: Pname n = l->f; ! 228: Pfct f = Pfct(n->tp); ! 229: // error('d',"isf %n f %d",n,f); ! 230: if ( f == 0 ) { error('d', "delete_local: f == 0" );break;} ! 231: if (f->base == OVERLOAD) { ! 232: n = Pgen(f)->fct_list->f; // first fct ! 233: f = Pfct(n->tp); ! 234: } ! 235: ! 236: if (debug_opt==0 && n->n_addr_taken) { ! 237: f->f_inline = 0; ! 238: if (n->n_dcl_printed<2) { ! 239: if (warning_opt) ! 240: error('w',"out-of-line copy of %n created",n); ! 241: n->dcl_print(0); ! 242: } ! 243: } ! 244: } ! 245: //isf_list = 0; ! 246: } while (vlist); ! 247: ! 248: for ( Plist l = local_class; l; l = l->l ) ! 249: { ! 250: Pname n = l->f; ! 251: // error( 'd' , "delete_local() %d %n %t", n, n, n->tp ); ! 252: Pname nn = Pbase(n->tp)->b_name; ! 253: Pclass cl = Pclass(nn->tp); ! 254: for (Pname px, p=cl->mem_list; p; p=px) { ! 255: px = p->n_list; ! 256: if (p->tp) ! 257: switch (p->tp->base) { ! 258: case FCT: ! 259: { Pfct f = (Pfct)p->tp; ! 260: if (f->body) { ! 261: if (f->f_inline==0 ! 262: && f->f_imeasure==0) { ! 263: ! 264: if (ansi_opt && f->f_this) { ! 265: f->f_this->n_table = 0; ! 266: for (Pname n=f->f_this->n_list; n; n=n->n_list) ! 267: n->n_table = 0; ! 268: } ! 269: ! 270: DEL(f->body); ! 271: f->body = 0; ! 272: } ! 273: } ! 274: } ! 275: case COBJ: ! 276: case EOBJ: ! 277: DEL(p); ! 278: break; ! 279: case CLASS: ! 280: case ENUM: ! 281: break; ! 282: default: ! 283: delete p; ! 284: } // end switch ! 285: else delete p; ! 286: } // end for mem ! 287: DEL(cl->memtbl); ! 288: cl->mem_list = 0; ! 289: cl->permanent = 3; ! 290: nn->permanent = 0; ! 291: DEL(nn); ! 292: n->permanent = 0; ! 293: extern void table_delete( char*, TOK, int ); ! 294: table_delete( n->string, LOCAL, n->lex_level ); ! 295: DEL(n); ! 296: } ! 297: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.