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