emit/__emit: Allow the use of constant expressions as opcode arguments

This commit is contained in:
Daniel_Cortez 2017-12-03 21:23:36 +07:00
parent 873060e7e8
commit fab8c53db0

View File

@ -5907,18 +5907,21 @@ static void emit_param_any(ucell *p,int size)
} /* if */ } /* if */
p[curp]=(neg!=0) ? -sym->addr : sym->addr; p[curp]=(neg!=0) ? -sym->addr : sym->addr;
break; break;
default: case '(':
if (tok==(int)'-') { constexpr(&val,NULL,NULL);
if (neg==0) { needtoken(')');
neg=1; p[curp]=val;
goto fetchtok; break;
} else { case '-':
char ival[sNAMEMAX+2]="-"; if (neg==0) {
strcpy(ival+1,str); neg=1;
error(1,sc_tokens[tSYMBOL-tFIRST],ival); goto fetchtok;
break;
} /* if */
} /* if */ } /* if */
char ival[sNAMEMAX+2]="-";
strcpy(ival+1,str);
error(1,sc_tokens[tSYMBOL-tFIRST],ival);
break;
default:
emit_invalid_token(teNUMBER,tok); emit_invalid_token(teNUMBER,tok);
} /* switch */ } /* switch */
} while (++curp<size); } while (++curp<size);
@ -6048,11 +6051,13 @@ fetchtok:
markusage(sym,uREAD); markusage(sym,uREAD);
val=(neg!=0) ? -sym->addr : sym->addr; val=(neg!=0) ? -sym->addr : sym->addr;
break; break;
default: case '-':
if (tok==(int)'-' && neg==0) { if (neg==0) {
neg=1; neg=1;
goto fetchtok; goto fetchtok;
} /* if */ } /* if */
/* drop through */
default:
emit_invalid_token(teNUMBER,tok); emit_invalid_token(teNUMBER,tok);
return; return;
} /* switch */ } /* switch */