This commit is contained in:
ceriel 1987-08-06 14:21:01 +00:00
parent 912e362f11
commit 5f6b6651e1
6 changed files with 28 additions and 19 deletions

View file

@ -12,5 +12,5 @@ char *EM_error;
char *EM_filename; char *EM_filename;
unsigned int EM_lineno; unsigned int EM_lineno;
int EM_wordsize, EM_pointersize; int EM_wordsize, EM_pointersize;
arith EM_holsize, EM_bsssize; arith EM_holsize;
int EM_holinit, EM_bssinit; int EM_holinit;

View file

@ -43,9 +43,11 @@ struct e_instr {
}; };
extern arith extern arith
EM_holsize, EM_bsssize; EM_holsize;
#define EM_bsssize EM_holsize
extern int extern int
EM_holinit, EM_bssinit; EM_holinit;
#define EM_bssinit EM_holinit
#define em_ilb em_arg.ema_ilb #define em_ilb em_arg.ema_ilb
#define em_dlb em_arg.ema_dlb #define em_dlb em_arg.ema_dlb

View file

@ -44,16 +44,18 @@ checkarg(arg, typset)
an argument expected, but there is none an argument expected, but there is none
*/ */
EM_error = "Illegal number of parameters"; EM_error = "Illegal number of parameters";
return; return 0;
} }
if (!(arg->ema_argtype & typset)) { if (!(arg->ema_argtype & typset)) {
/* Type error */ /* Type error */
EM_error = "Illegal parameter type"; EM_error = "Illegal parameter type";
return 0;
} }
return 1;
} }
#else not CHECKING #else not CHECKING
#define checkarg(arg, x) #define checkarg(arg, x) 1
#endif CHECKING #endif CHECKING
/* EM_doinstr: An EM instruction /* EM_doinstr: An EM instruction
@ -77,11 +79,13 @@ EM_doinstr(p)
case PAR_NO: case PAR_NO:
break; break;
default: default:
checkarg(&(p->em_arg), em_ptyp[parametertype]); if (! checkarg(&(p->em_arg), em_ptyp[parametertype])) {
return;
}
break; break;
case PAR_W: case PAR_W:
if (p->em_argtype != 0) { if (p->em_argtype != 0) {
checkarg(&(p->em_arg), cst_ptyp); if (! checkarg(&(p->em_arg), cst_ptyp)) return;
} }
else { else {
#include "C_mnem_narg" #include "C_mnem_narg"
@ -103,7 +107,7 @@ EM_dopseudo(p)
break; break;
} }
case ps_hol: { case ps_hol: {
checkarg(&(p->em_arg), par_ptyp); if (! checkarg(&(p->em_arg), par_ptyp)) break;
switch(p->em_argtype) { switch(p->em_argtype) {
case cst_ptyp: case cst_ptyp:
C_hol_cst(EM_holsize, C_hol_cst(EM_holsize,
@ -157,7 +161,7 @@ EM_dopseudo(p)
break; break;
} }
case ps_bss: { case ps_bss: {
checkarg(&(p->em_arg), par_ptyp); if (! checkarg(&(p->em_arg), par_ptyp)) break;
switch(p->em_argtype) { switch(p->em_argtype) {
case cst_ptyp: case cst_ptyp:
C_bss_cst(EM_bsssize, C_bss_cst(EM_bsssize,
@ -212,7 +216,7 @@ EM_dopseudo(p)
} }
case ps_end: case ps_end:
if (p->em_argtype != 0) { if (p->em_argtype != 0) {
checkarg(&(p->em_arg), cst_ptyp); if (! checkarg(&(p->em_arg), cst_ptyp)) break;
C_end(p->em_cst); C_end(p->em_cst);
break; break;
} }
@ -220,7 +224,7 @@ EM_dopseudo(p)
break; break;
case ps_exa: case ps_exa:
case ps_ina: case ps_ina:
checkarg(&(p->em_arg), lab_ptyp); if (! checkarg(&(p->em_arg), lab_ptyp)) break;
if (p->em_argtype == nof_ptyp) { if (p->em_argtype == nof_ptyp) {
if (p->em_opcode == ps_exa) { if (p->em_opcode == ps_exa) {
C_exa_dlb(p->em_dlb); C_exa_dlb(p->em_dlb);
@ -234,22 +238,22 @@ EM_dopseudo(p)
else C_ina_dnam(p->em_dnam); else C_ina_dnam(p->em_dnam);
break; break;
case ps_exp: case ps_exp:
checkarg(&(p->em_arg), pro_ptyp); if (! checkarg(&(p->em_arg), pro_ptyp)) break;
C_exp(p->em_pnam); C_exp(p->em_pnam);
break; break;
case ps_inp: case ps_inp:
checkarg(&(p->em_arg), pro_ptyp); if (! checkarg(&(p->em_arg), pro_ptyp)) break;
C_inp(p->em_pnam); C_inp(p->em_pnam);
break; break;
case ps_pro: case ps_pro:
checkarg(&(p->em_arg), pro_ptyp); if (! checkarg(&(p->em_arg), pro_ptyp)) break;
if (p->em_nlocals >= 0) { if (p->em_nlocals >= 0) {
C_pro(p->em_pnam, p->em_nlocals); C_pro(p->em_pnam, p->em_nlocals);
} }
else C_pro_narg(p->em_pnam); else C_pro_narg(p->em_pnam);
break; break;
case ps_con: case ps_con:
checkarg(&(p->em_arg), val_ptyp); if (! checkarg(&(p->em_arg), val_ptyp)) break;
switch(p->em_argtype) { switch(p->em_argtype) {
case ilb_ptyp: case ilb_ptyp:
C_con_ilb(p->em_ilb); C_con_ilb(p->em_ilb);
@ -284,7 +288,7 @@ EM_dopseudo(p)
} }
break; break;
case ps_rom: case ps_rom:
checkarg(&(p->em_arg), val_ptyp); if (! checkarg(&(p->em_arg), val_ptyp)) break;
switch(p->em_argtype) { switch(p->em_argtype) {
case ilb_ptyp: case ilb_ptyp:
C_rom_ilb(p->em_ilb); C_rom_ilb(p->em_ilb);
@ -372,7 +376,7 @@ EM_dostartmes(p)
EM_error = "Message not ended"; EM_error = "Message not ended";
return; return;
} }
checkarg(&(p->em_arg), cst_ptyp); if (! checkarg(&(p->em_arg), cst_ptyp)) return;
C_mes_begin((int) (p->em_cst)); C_mes_begin((int) (p->em_cst));
listtype = ps_mes; listtype = ps_mes;
} }

View file

@ -221,6 +221,7 @@ EM_getinstr(p)
return 1; return 1;
} }
emhead = p; emhead = p;
p->em_type = 0;
#ifdef CHECKING #ifdef CHECKING
if (!EM_initialized) { if (!EM_initialized) {
EM_error = "Initialization not done"; EM_error = "Initialization not done";

View file

@ -616,7 +616,7 @@ getlabel(c, p)
PRIVATE PRIVATE
gethead(p) gethead(p)
struct e_instr *p; register struct e_instr *p;
{ {
register int c; register int c;
@ -647,6 +647,7 @@ gethead(p)
return; return;
} }
checkeol(); checkeol();
if (p->em_type == EM_ERROR || p->em_type == EM_FATAL) return;
} }
/*NOTREACHED*/ /*NOTREACHED*/
} }

View file

@ -50,6 +50,7 @@ getarg(typset, ap)
int argtyp; int argtyp;
#endif CHECKING #endif CHECKING
ap->ema_argtype = 0;
switch(i) { switch(i) {
default: default:
if (i < sp_fcst0+sp_ncst0 && i >= sp_fcst0) { /* A cst */ if (i < sp_fcst0+sp_ncst0 && i >= sp_fcst0) { /* A cst */