add -P,--progs-src so you can specify the name of the progs.src file
rest:
	add/use print_type
This commit is contained in:
Bill Currie 2002-01-17 08:19:53 +00:00
parent 55bb282b24
commit 7227ab4363
4 changed files with 50 additions and 2 deletions

View file

@ -33,5 +33,6 @@
#define __type_h #define __type_h
struct type_s *pointer_type (struct type_s *aux); struct type_s *pointer_type (struct type_s *aux);
void print_type (struct type_s *type);
#endif//__type_h #endif//__type_h

View file

@ -1431,9 +1431,12 @@ function_expr (expr_t *e1, expr_t *e2)
t = ftype->parm_types[i - 1]; t = ftype->parm_types[i - 1];
e->type = expr_types[t->type]; e->type = expr_types[t->type];
} }
if (t != ftype->parm_types[i - 1]) if (t != ftype->parm_types[i - 1]) {
print_type (ftype->parm_types[i - 1]); puts("");
print_type (t); puts("");
err = error (e, "type mismatch for parameter %d of %s", err = error (e, "type mismatch for parameter %d of %s",
i, e1->e.def->name); i, e1->e.def->name);
}
} else { } else {
if (e->type == ex_integer && options.warnings.vararg_integer) if (e->type == ex_integer && options.warnings.vararg_integer)
warning (e, "passing integer consant into ... function"); warning (e, "passing integer consant into ... function");

View file

@ -66,10 +66,12 @@ static const char rcsid[] =
options_t options; options_t options;
char *sourcedir; char *sourcedir;
char *progs_src;
const char *this_program; const char *this_program;
static struct option const long_options[] = { static struct option const long_options[] = {
{"source", required_argument, 0, 's'}, {"source", required_argument, 0, 's'},
{"progs-src", required_argument, 0, 'P'},
{"save-temps", no_argument, 0, 'S'}, {"save-temps", no_argument, 0, 'S'},
{"quiet", no_argument, 0, 'q'}, {"quiet", no_argument, 0, 'q'},
{"verbose", no_argument, 0, 'v'}, {"verbose", no_argument, 0, 'v'},
@ -730,8 +732,10 @@ DecodeArgs (int argc, char **argv)
options.verbosity = 0; options.verbosity = 0;
sourcedir = "."; sourcedir = ".";
progs_src = "progs.src";
while ((c = getopt_long (argc, argv, "s:" // source dir while ((c = getopt_long (argc, argv, "s:" // source dir
"P:" // progs.src name
"q" // quiet "q" // quiet
"v" // verbose "v" // verbose
"g" // debug "g" // debug
@ -757,6 +761,9 @@ DecodeArgs (int argc, char **argv)
case 's': // src dir case 's': // src dir
sourcedir = strdup (optarg); sourcedir = strdup (optarg);
break; break;
case 'P': // progs-src
progs_src = strdup (optarg);
break;
case 'q': // quiet case 'q': // quiet
options.verbosity -= 1; options.verbosity -= 1;
break; break;
@ -921,12 +928,15 @@ main (int argc, char **argv)
if (strcmp (sourcedir, ".")) { if (strcmp (sourcedir, ".")) {
printf ("Source directory: %s\n", sourcedir); printf ("Source directory: %s\n", sourcedir);
} }
if (strcmp (progs_src, "progs.src")) {
printf ("progs.src: %s\n", progs_src);
}
PR_Opcode_Init_Tables (); PR_Opcode_Init_Tables ();
InitData (); InitData ();
snprintf (filename, sizeof (filename), "%s/progs.src", sourcedir); snprintf (filename, sizeof (filename), "%s/%s", sourcedir, progs_src);
LoadFile (filename, (void *) &src); LoadFile (filename, (void *) &src);
if (!(src = Parse (src))) if (!(src = Parse (src)))

View file

@ -45,3 +45,37 @@ pointer_type (type_t *aux)
new.aux_type = aux; new.aux_type = aux;
return PR_FindType (&new); return PR_FindType (&new);
} }
void
print_type (type_t *type)
{
if (!type)
printf (" (null)");
switch (type->type) {
case ev_func:
print_type (type->aux_type);
if (type->num_parms < 0) {
printf ("(...)");
} else {
int i;
printf ("(");
for (i = 0; i < type->num_parms; i++) {
if (i)
printf (", ");
print_type (type->parm_types[i]);
}
printf (")");
}
break;
case ev_pointer:
print_type (type->aux_type);
if (type->num_parms)
printf ("[%d]", type->num_parms);
else
printf ("[]");
break;
default:
printf(" %s", pr_type_name[type->type]);
break;
}
}