From: ceriel Date: Fri, 16 Jan 1987 13:51:45 +0000 (+0000) Subject: Bug fixes X-Git-Tag: release-5-5~4992 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=0b941ef495535812ab4bc05ae87fe5fd11e8f37c;p=ack.git Bug fixes --- diff --git a/mach/proto/ncg/compute.c b/mach/proto/ncg/compute.c index a47c0655b..5c2d3d01a 100644 --- a/mach/proto/ncg/compute.c +++ b/mach/proto/ncg/compute.c @@ -145,10 +145,10 @@ result_t compute(node) register node_p node; { switch(node->ex_operator) { default: assert(FALSE); case EX_TOKFIELD: - if (node->ex_lnode!=0) - tp = &fakestack[stackheight-node->ex_lnode]; - else - tp = curtoken; + if (node->ex_lnode==0) + if (curtoken) tp = curtoken; + else tp = &fakestack[stackheight-1]; + else tp = &fakestack[stackheight-node->ex_lnode]; switch(result.e_typ = tokens[tp->t_token].t_type[node->ex_rnode-1]) { default: assert(FALSE); @@ -343,7 +343,10 @@ result_t compute(node) register node_p node; { return(result); case EX_SUBREG: result.e_typ = EV_REG; - tp= &fakestack[stackheight-node->ex_lnode]; + if (node->ex_lnode==0) + if (curtoken) tp = curtoken; + else tp = &fakestack[stackheight-1]; + else tp = &fakestack[stackheight-node->ex_lnode]; assert(tp->t_token == -1); tmpreg= tp->t_att[0].ar; #if MAXMEMBERS!=0 diff --git a/mach/proto/ncg/gencode.c b/mach/proto/ncg/gencode.c index 8e54e33ba..ca45bc008 100644 --- a/mach/proto/ncg/gencode.c +++ b/mach/proto/ncg/gencode.c @@ -96,12 +96,14 @@ string ad2str(ad) addr_t ad; { praddr(ad) addr_t ad; { - if (ad.ea_str==0) + if (ad.ea_str==0 || *(ad.ea_str) == '\0') fprintf(codefile,WRD_FMT,ad.ea_off); else { fprintf(codefile,"%s",ad.ea_str); - if (ad.ea_off<0) - fprintf(codefile,WRD_FMT,ad.ea_off); + if (ad.ea_off<0) { + fputc('-', codefile); + fprintf(codefile,WRD_FMT,-ad.ea_off); + } else if(ad.ea_off>0) { fputc('+',codefile); fprintf(codefile,WRD_FMT,ad.ea_off); diff --git a/mach/proto/ncg/subr.c b/mach/proto/ncg/subr.c index 825786a44..0805141f0 100644 --- a/mach/proto/ncg/subr.c +++ b/mach/proto/ncg/subr.c @@ -78,7 +78,10 @@ instance(instno,token) register token_p token; { default: assert(FALSE); case IN_COPY: - tp= &fakestack[stackheight-inp->in_info[0]]; + if (inp->in_info[0] == 0) + if (curtoken) tp = curtoken; + else tp = &fakestack[stackheight-1]; + else tp= &fakestack[stackheight-inp->in_info[0]]; if (inp->in_info[1]==0) { *token = *tp; } else { @@ -93,7 +96,10 @@ instance(instno,token) register token_p token; { } return; case IN_MEMB: - tp= &fakestack[stackheight-inp->in_info[0]]; + if (inp->in_info[0] == 0) + if (curtoken) tp = curtoken; + else tp = &fakestack[stackheight-1]; + else tp= &fakestack[stackheight-inp->in_info[0]]; assert(inp->in_info[1]!=0); assert(tp->t_token>0); token->t_token= -1; @@ -160,7 +166,7 @@ cinstance(instno,token,tp,regno) register token_p token,tp; { default: assert(FALSE); case IN_COPY: - assert(inp->in_info[0] == 1); + assert(inp->in_info[0] <= 1); if (inp->in_info[1]==0) { *token = *tp; } else { @@ -175,7 +181,7 @@ cinstance(instno,token,tp,regno) register token_p token,tp; { } return; case IN_MEMB: - assert(inp->in_info[0] == 1); + assert(inp->in_info[0] <= 1); token->t_token= -1; assert(tp->t_token>0); assert(tokens[tp->t_token].t_type[inp->in_info[1]-1] == EV_REG); @@ -197,14 +203,19 @@ cinstance(instno,token,tp,regno) register token_p token,tp; { #ifdef REGVARS case IN_S_DESCR: case IN_D_DESCR: - result=compute(&enodes[inp->in_info[1]]); - assert(result.e_typ==EV_INT); - if ((regno=isregvar(result.e_v.e_con)) > 0) { - token->t_token = -1; - token->t_att[0].ar = regno; - for(i=1;it_att[i].aw = 0; - return; + { token_p ct = curtoken; + + curtoken = tp; + result=compute(&enodes[inp->in_info[1]]); + curtoken = ct; + assert(result.e_typ==EV_INT); + if ((regno=isregvar(result.e_v.e_con)) > 0) { + token->t_token = -1; + token->t_att[0].ar = regno; + for(i=1;it_att[i].aw = 0; + return; + } } /* fall through */ #endif @@ -217,7 +228,11 @@ cinstance(instno,token,tp,regno) register token_p token,tp; { assert(tokens[token->t_token].t_type[i]==0); token->t_att[i].aw=0; } else { + token_p ct = curtoken; + + curtoken = tp; result=compute(&enodes[inp->in_info[i+1]]); + curtoken = ct; assert(tokens[token->t_token].t_type[i]==result.e_typ); if (result.e_typ==EV_INT) token->t_att[i].aw=result.e_v.e_con; @@ -605,12 +620,19 @@ itokcost() { error(s,a1,a2,a3,a4,a5,a6,a7,a8) char *s; { - fatal(s,a1,a2,a3,a4,a5,a6,a7,a8); + fprintf(stderr,"Error: "); + fprintf(stderr,s,a1,a2,a3,a4,a5,a6,a7,a8); + fprintf(stderr,"\n"); +#ifdef TABLEDEBUG + ruletrace(); +#endif + out_finish(); + exit(-1); } fatal(s,a1,a2,a3,a4,a5,a6,a7,a8) char *s; { - fprintf(stderr,"Error: "); + fprintf(stderr,"Fatal: "); fprintf(stderr,s,a1,a2,a3,a4,a5,a6,a7,a8); fprintf(stderr,"\n"); #ifdef TABLEDEBUG