Bug fixes

This commit is contained in:
ceriel 1987-01-16 13:51:45 +00:00
parent 45238eea0f
commit 0b941ef495
3 changed files with 49 additions and 22 deletions

View file

@ -145,10 +145,10 @@ result_t compute(node) register node_p node; {
switch(node->ex_operator) { switch(node->ex_operator) {
default: assert(FALSE); default: assert(FALSE);
case EX_TOKFIELD: case EX_TOKFIELD:
if (node->ex_lnode!=0) if (node->ex_lnode==0)
tp = &fakestack[stackheight-node->ex_lnode]; if (curtoken) tp = curtoken;
else else tp = &fakestack[stackheight-1];
tp = curtoken; else tp = &fakestack[stackheight-node->ex_lnode];
switch(result.e_typ = tokens[tp->t_token].t_type[node->ex_rnode-1]) { switch(result.e_typ = tokens[tp->t_token].t_type[node->ex_rnode-1]) {
default: default:
assert(FALSE); assert(FALSE);
@ -343,7 +343,10 @@ result_t compute(node) register node_p node; {
return(result); return(result);
case EX_SUBREG: case EX_SUBREG:
result.e_typ = EV_REG; 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); assert(tp->t_token == -1);
tmpreg= tp->t_att[0].ar; tmpreg= tp->t_att[0].ar;
#if MAXMEMBERS!=0 #if MAXMEMBERS!=0

View file

@ -96,12 +96,14 @@ string ad2str(ad) addr_t ad; {
praddr(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); fprintf(codefile,WRD_FMT,ad.ea_off);
else { else {
fprintf(codefile,"%s",ad.ea_str); fprintf(codefile,"%s",ad.ea_str);
if (ad.ea_off<0) if (ad.ea_off<0) {
fprintf(codefile,WRD_FMT,ad.ea_off); fputc('-', codefile);
fprintf(codefile,WRD_FMT,-ad.ea_off);
}
else if(ad.ea_off>0) { else if(ad.ea_off>0) {
fputc('+',codefile); fputc('+',codefile);
fprintf(codefile,WRD_FMT,ad.ea_off); fprintf(codefile,WRD_FMT,ad.ea_off);

View file

@ -78,7 +78,10 @@ instance(instno,token) register token_p token; {
default: default:
assert(FALSE); assert(FALSE);
case IN_COPY: 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) { if (inp->in_info[1]==0) {
*token = *tp; *token = *tp;
} else { } else {
@ -93,7 +96,10 @@ instance(instno,token) register token_p token; {
} }
return; return;
case IN_MEMB: 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(inp->in_info[1]!=0);
assert(tp->t_token>0); assert(tp->t_token>0);
token->t_token= -1; token->t_token= -1;
@ -160,7 +166,7 @@ cinstance(instno,token,tp,regno) register token_p token,tp; {
default: default:
assert(FALSE); assert(FALSE);
case IN_COPY: case IN_COPY:
assert(inp->in_info[0] == 1); assert(inp->in_info[0] <= 1);
if (inp->in_info[1]==0) { if (inp->in_info[1]==0) {
*token = *tp; *token = *tp;
} else { } else {
@ -175,7 +181,7 @@ cinstance(instno,token,tp,regno) register token_p token,tp; {
} }
return; return;
case IN_MEMB: case IN_MEMB:
assert(inp->in_info[0] == 1); assert(inp->in_info[0] <= 1);
token->t_token= -1; token->t_token= -1;
assert(tp->t_token>0); assert(tp->t_token>0);
assert(tokens[tp->t_token].t_type[inp->in_info[1]-1] == EV_REG); assert(tokens[tp->t_token].t_type[inp->in_info[1]-1] == EV_REG);
@ -197,7 +203,11 @@ cinstance(instno,token,tp,regno) register token_p token,tp; {
#ifdef REGVARS #ifdef REGVARS
case IN_S_DESCR: case IN_S_DESCR:
case IN_D_DESCR: case IN_D_DESCR:
{ token_p ct = curtoken;
curtoken = tp;
result=compute(&enodes[inp->in_info[1]]); result=compute(&enodes[inp->in_info[1]]);
curtoken = ct;
assert(result.e_typ==EV_INT); assert(result.e_typ==EV_INT);
if ((regno=isregvar(result.e_v.e_con)) > 0) { if ((regno=isregvar(result.e_v.e_con)) > 0) {
token->t_token = -1; token->t_token = -1;
@ -206,6 +216,7 @@ cinstance(instno,token,tp,regno) register token_p token,tp; {
token->t_att[i].aw = 0; token->t_att[i].aw = 0;
return; return;
} }
}
/* fall through */ /* fall through */
#endif #endif
case IN_DESCR: case IN_DESCR:
@ -217,7 +228,11 @@ cinstance(instno,token,tp,regno) register token_p token,tp; {
assert(tokens[token->t_token].t_type[i]==0); assert(tokens[token->t_token].t_type[i]==0);
token->t_att[i].aw=0; token->t_att[i].aw=0;
} else { } else {
token_p ct = curtoken;
curtoken = tp;
result=compute(&enodes[inp->in_info[i+1]]); result=compute(&enodes[inp->in_info[i+1]]);
curtoken = ct;
assert(tokens[token->t_token].t_type[i]==result.e_typ); assert(tokens[token->t_token].t_type[i]==result.e_typ);
if (result.e_typ==EV_INT) if (result.e_typ==EV_INT)
token->t_att[i].aw=result.e_v.e_con; 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; { 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; { 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,s,a1,a2,a3,a4,a5,a6,a7,a8);
fprintf(stderr,"\n"); fprintf(stderr,"\n");
#ifdef TABLEDEBUG #ifdef TABLEDEBUG