1 /* $Id: mkcalls.c,v 1.17 1994/06/24 11:21:18 ceriel Exp $ */
3 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
4 * See the copyright notice in the ACK home directory, in the file "Copyright".
6 /* makecalls: expand a datastructure as delivered by "EM_getline"
7 into calls to the procedural interface.
21 extern char em_flag[]; /* One per EM instruction: indicates parameter kind */
22 extern short em_ptyp[]; /* One per parameter kind: indicates parameter type */
24 static int listtype = 0; /* indicates pseudo when generating code for
25 variable length argument lists
30 /* c_getarg: Check the argument indicated by "args".
31 The argument must be of a type allowed by "typset".
32 Return a pointer to the next argument.
36 register struct e_arg *arg;
39 if (((!typset) && arg->ema_argtype) ||
40 ((!arg->ema_argtype) && typset)) {
41 /* End of arguments expected, but there are more, or
42 an argument expected, but there is none
44 EM_error = "Illegal number of parameters";
48 if (!(arg->ema_argtype & typset)) {
50 EM_error = "Illegal parameter type";
55 #else /* not CHECKING */
56 #define checkarg(arg, x) 1
59 /* EM_doinstr: An EM instruction
63 register struct e_instr *p;
65 register int parametertype; /* parametertype of the instruction */
67 parametertype = em_flag[p->em_opcode-sp_fmnem] & EM_PAR;
69 if (parametertype != PAR_NO && parametertype != PAR_W) {
70 if (p->em_argtype == 0) {
71 EM_error = "Illegal number of parameters";
76 switch(parametertype) {
80 if (! checkarg(&(p->em_arg), em_ptyp[parametertype])) {
85 if (p->em_argtype != 0) {
86 if (! checkarg(&(p->em_arg), cst_ptyp)) return;
89 #include "C_mnem_narg"
99 register struct e_instr *p;
102 switch(p->em_opcode) {
104 C_exc(p->em_exc1, p->em_exc2);
108 if (! checkarg(&(p->em_arg), par_ptyp)) break;
109 switch(p->em_argtype) {
111 C_hol_cst(EM_holsize,
116 C_hol_icon(EM_holsize,
122 C_hol_ucon(EM_holsize,
128 C_hol_fcon(EM_holsize,
134 C_hol_dnam(EM_holsize,
140 C_hol_dlb(EM_holsize,
146 C_hol_ilb(EM_holsize,
151 C_hol_pnam(EM_holsize,
156 EM_error = "Illegal parameter type";
162 if (! checkarg(&(p->em_arg), par_ptyp)) break;
163 switch(p->em_argtype) {
165 C_bss_cst(EM_bsssize,
170 C_bss_icon(EM_bsssize,
176 C_bss_ucon(EM_bsssize,
182 C_bss_fcon(EM_bsssize,
188 C_bss_dnam(EM_bsssize,
194 C_bss_dlb(EM_bsssize,
200 C_bss_ilb(EM_bsssize,
205 C_bss_pnam(EM_bsssize,
210 EM_error = "Illegal parameter type";
216 if (p->em_argtype != 0) {
217 if (! checkarg(&(p->em_arg), cst_ptyp)) break;
225 if (! checkarg(&(p->em_arg), lab_ptyp)) break;
226 if (p->em_argtype == nof_ptyp) {
227 if (p->em_opcode == ps_exa) {
228 C_exa_dlb(p->em_dlb);
230 else C_ina_dlb(p->em_dlb);
233 if (p->em_opcode == ps_exa) {
234 C_exa_dnam(p->em_dnam);
236 else C_ina_dnam(p->em_dnam);
239 if (! checkarg(&(p->em_arg), pro_ptyp)) break;
243 if (! checkarg(&(p->em_arg), pro_ptyp)) break;
247 if (! checkarg(&(p->em_arg), pro_ptyp)) break;
248 if (p->em_nlocals >= 0) {
249 C_pro(p->em_pnam, p->em_nlocals);
251 else C_pro_narg(p->em_pnam);
254 if (! checkarg(&(p->em_arg), val_ptyp)) break;
255 switch(p->em_argtype) {
257 C_con_ilb(p->em_ilb);
260 C_con_dlb(p->em_dlb, p->em_off);
263 C_con_dnam(p->em_dnam, p->em_off);
266 C_con_cst(p->em_cst);
269 C_con_pnam(p->em_pnam);
272 C_con_scon(p->em_string, p->em_size);
275 C_con_icon(p->em_string, p->em_size);
278 C_con_ucon(p->em_string, p->em_size);
281 C_con_fcon(p->em_string, p->em_size);
284 EM_error = "Illegal argument type";
289 if (! checkarg(&(p->em_arg), val_ptyp)) break;
290 switch(p->em_argtype) {
292 C_rom_ilb(p->em_ilb);
295 C_rom_dlb(p->em_dlb, p->em_off);
298 C_rom_dnam(p->em_dnam, p->em_off);
301 C_rom_cst(p->em_cst);
304 C_rom_pnam(p->em_pnam);
307 C_rom_scon(p->em_string, p->em_size);
310 C_rom_icon(p->em_string, p->em_size);
313 C_rom_ucon(p->em_string, p->em_size);
316 C_rom_fcon(p->em_string, p->em_size);
319 EM_error = "Illegal argument type";
324 EM_error = "Illegal pseudo instruction";
331 register struct e_instr *p;
333 checkarg(&(p->em_arg), val_ptyp);
334 switch(p->em_argtype) {
339 C_dlb(p->em_dlb, p->em_off);
342 C_dnam(p->em_dnam, p->em_off);
351 C_scon(p->em_string, p->em_size);
354 C_icon(p->em_string, p->em_size);
357 C_ucon(p->em_string, p->em_size);
360 C_fcon(p->em_string, p->em_size);
363 EM_error = "Illegal argument type";
370 register struct e_instr *p;
374 EM_error = "Message not ended";
377 if (! checkarg(&(p->em_arg), cst_ptyp)) return;
378 C_mes_begin((int) (p->em_cst));
384 register struct e_instr *line;
388 if (listtype && line->em_type != EM_MESARG && line->em_type != EM_ENDMES) {
389 EM_error = "Message not ended";
392 #endif /* CHECKING */
394 switch(line->em_type) {
396 EM_error = "Illegal EM line";
399 /* normal instruction */
403 /* defining occurrence of an instruction label */
404 C_df_ilb(line->em_ilb);
407 /* defining occurrence of a global data label */
408 C_df_dlb(line->em_dlb);
411 /* defining occurrence of a non-numeric data label */
412 C_df_dnam(line->em_dnam);
419 /* start of a MES pseudo */
426 EM_error = "Message not started";
430 if (line->em_type == EM_MESARG) {
438 if (EM_error) return 0;