int size, align;
void (*init)(struct type *type, struct value *val);
void (*prepare_type)(struct parse_context *c, struct type *type, int parse_time);
- void (*print)(struct type *type, struct value *val);
+ void (*print)(struct type *type, struct value *val, FILE *f);
void (*print_type)(struct type *type, FILE *f);
int (*cmp_order)(struct type *t1, struct type *t2,
struct value *v1, struct value *v2);
return -1; // NOTEST
}
- static void print_value(struct type *type, struct value *v)
+ static void print_value(struct type *type, struct value *v, FILE *f)
{
if (type && type->print)
- type->print(type, v);
+ type->print(type, v, f);
else
- printf("*Unknown*"); // NOTEST
+ fprintf(f, "*Unknown*"); // NOTEST
}
###### forward decls
struct value *vold, struct value *vnew);
static int value_cmp(struct type *tl, struct type *tr,
struct value *left, struct value *right);
- static void print_value(struct type *type, struct value *v);
+ static void print_value(struct type *type, struct value *v, FILE *f);
###### free context types
return cmp;
}
- static void _print_value(struct type *type, struct value *v)
+ static void _print_value(struct type *type, struct value *v, FILE *f)
{
switch (type->vtype) {
case Vnone: // NOTEST
- printf("*no-value*"); break; // NOTEST
+ fprintf(f, "*no-value*"); break; // NOTEST
case Vlabel: // NOTEST
- printf("*label-%p*", v->label); break; // NOTEST
+ fprintf(f, "*label-%p*", v->label); break; // NOTEST
case Vstr:
- printf("%.*s", v->str.len, v->str.txt); break;
+ fprintf(f, "%.*s", v->str.len, v->str.txt); break;
case Vbool:
- printf("%s", v->bool ? "True":"False"); break;
+ fprintf(f, "%s", v->bool ? "True":"False"); break;
case Vnum:
{
mpf_t fl;
mpf_init2(fl, 20);
mpf_set_q(fl, v->num);
- gmp_printf("%Fg", fl);
+ gmp_fprintf(f, "%Fg", fl);
mpf_clear(fl);
break;
}
fprintf(f, " = ");
if (fl->type == Tstr)
fprintf(f, "\""); // UNTESTED
- print_value(fl->type, fl->init);
+ print_value(fl->type, fl->init, f);
if (fl->type == Tstr)
fprintf(f, "\""); // UNTESTED
}
- printf("\n");
+ fprintf(f, "\n");
}
}
args, NULL, 0, NULL);
}
- static void function_print(struct type *type, struct value *val)
+ static void function_print(struct type *type, struct value *val, FILE *f)
{
print_exec(val->function, 1, 0);
}
struct val *v = cast(val, e);
if (v->vtype == Tstr)
printf("\"");
- print_value(v->vtype, &v->val);
+ print_value(v->vtype, &v->val, stdout);
if (v->vtype == Tstr)
printf("\"");
break;
b2 = cast(binode, b->right);
for (; b2; b2 = cast(binode, b2->right)) {
left = interp_exec(c, b2->left, <ype);
- print_value(ltype, &left);
+ print_value(ltype, &left, stdout);
free_value(ltype, &left);
if (b2->right)
putchar(' ');
printf(" = ");
if (v->type == Tstr)
printf("\"");
- print_value(v->type, val);
+ print_value(v->type, val, stdout);
if (v->type == Tstr)
printf("\"");
printf("\n");
if (brackets)
print_exec(val->function, 0, brackets);
else
- print_value(v->type, val);
+ print_value(v->type, val, stdout);
printf("/* frame size %d */\n", v->type->function.local_size);
target -= 1;
}