}
}
-static void check_label_read_ref(struct parsed_op *po, const char *name)
+static const char *check_label_read_ref(struct parsed_op *po,
+ const char *name)
{
const struct parsed_proto *pp;
if (pp->is_func)
check_func_pp(po, pp, "ref");
+
+ return pp->name;
}
static char *out_src_opr(char *buf, size_t buf_size,
{
char tmp1[256], tmp2[256];
char expr[256];
+ const char *name;
char *p;
int ret;
break;
case OPT_LABEL:
- check_label_read_ref(po, popr->name);
+ name = check_label_read_ref(po, popr->name);
if (cast[0] == 0 && popr->is_ptr)
cast = "(u32)";
if (is_lea)
- snprintf(buf, buf_size, "(u32)&%s", popr->name);
+ snprintf(buf, buf_size, "(u32)&%s", name);
else if (popr->size_lt)
snprintf(buf, buf_size, "%s%s%s%s", cast,
lmod_cast_u_ptr(po, popr->lmod),
- popr->is_array ? "" : "&",
- popr->name);
+ popr->is_array ? "" : "&", name);
else
- snprintf(buf, buf_size, "%s%s%s", cast, popr->name,
+ snprintf(buf, buf_size, "%s%s%s", cast, name,
popr->is_array ? "[0]" : "");
break;
case OPT_OFFSET:
- check_label_read_ref(po, popr->name);
+ name = check_label_read_ref(po, popr->name);
if (cast[0] == 0)
cast = "(u32)";
if (is_lea)
ferr(po, "lea an offset?\n");
- snprintf(buf, buf_size, "%s&%s", cast, popr->name);
+ snprintf(buf, buf_size, "%s&%s", cast, name);
break;
case OPT_CONST:
ferr(ops, "nested fptr\n");
fprintf(fout, "%s", pp->arg[j].type.name);
}
+ if (pp->is_vararg) {
+ if (j > 0)
+ fprintf(fout, ", ");
+ fprintf(fout, "...");
+ }
fprintf(fout, ")");
}
else {
}
}
- if (pp->is_fptr) {
+ // declare indirect funcs
+ if (pp->is_fptr && !(pp->name[0] != 0 && pp->is_arg)) {
if (pp->name[0] != 0) {
memmove(pp->name + 2, pp->name, strlen(pp->name) + 1);
memcpy(pp->name, "i_", 2);
pp = po->datap;
my_assert_not(pp, NULL);
- if (pp->is_fptr)
+ if (pp->is_fptr && !pp->is_arg)
fprintf(fout, " %s = %s;\n", pp->name,
out_src_opr(buf1, sizeof(buf1), po, &po->operand[0],
"(void *)", 0));