/* @(#) norm2.c 1.3 1/27/86 17:49:18 */ /*ident "@(#)cfront:src/norm2.c 1.3" */ /************************************************************************ C++ source for cfront, the C++ compiler front-end written in the computer science research center of Bell Labs Copyright (c) 1984 AT&T, Inc. All Rights Reserved THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T, INC. norm2.c: "normalization" handles problems which could have been handled by the syntax analyser; but has not been done. The idea is to simplify the grammar and the actions accociated with it, and to get a more robust error handling ****************************************************************************/ #include "cfront.h" #include "size.h" extern char* malloc(int); fct.fct(Ptype t, Pname arg, TOK known) { Nt++; base = FCT; nargs_known = known; returns = t; argtype = arg; /*fprintf(stderr,"fct t %d %d arg %d %d -> %d\n",t, t?t->base:0, arg, arg?arg->base:0, this);*/ if (arg==0 || arg->base==ELIST) return; register Pname n; for (n=arg; n; n=n->n_list) { switch (n->tp->base) { case VOID: argtype = 0; nargs = 0; nargs_known = 1; if (n->string) error("voidFA%n",n); else if (nargs || n->n_list) { error("voidFA"); nargs_known = 0; } break; case CLASS: case ENUM: break; default: nargs++; } } } Pexpr expr_free; #define EBITE 250 expr.expr(TOK ba, Pexpr a, Pexpr b) { register Pexpr p; if (this) goto ret; if ( (p=expr_free) == 0 ) { register Pexpr q = (Pexpr) malloc(EBITE*sizeof(class expr)); for (p=expr_free=&q[EBITE-1]; q
e1 = p-1;
(p+1)->e1 = 0;
/*fprintf(stderr, "malloc %d expr_free=%d p+1=%d\n", EBITE*sizeof(class expr), expr_free, p+1);*/
}
else
expr_free = p->e1;
/* beware of alignment differences */
if ( sizeof(expr)&1 ) {
register char* pp = (char*)(p+1);
while ( (char*)p s_list = p-1;
(p+1)->s_list = 0;
}
else
stmt_free = p->s_list;
/* beware of alignment differences */
if ( sizeof(stmt)&1 ) {
register char* pp = (char*)(p+1);
while ( (char*)p n_tbl_list = p-1;
(p+1)->n_tbl_list = 0;
/*fprintf(stderr, "malloc %d name_free=%d p+1=%d\n", NBITE*sizeof(class name), name_free, p+1); */
}
else
name_free = p->n_tbl_list;
/* beware of alignment differences */
if ( sizeof(name)&1 ) {
register char* pp = (char*)(p+1);
while ( (char*)p