summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
025b04b)
print_type receives a file, and a type can contain values, so
print_value() should take a file too.
Ideally print_exec() would as well, as the value of a function is an
exec. Maybe another day.
Signed-off-by: NeilBrown <neil@brown.name>
int size, align;
void (*init)(struct type *type, struct value *val);
void (*prepare_type)(struct parse_context *c, struct type *type, int parse_time);
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);
void (*print_type)(struct type *type, FILE *f);
int (*cmp_order)(struct type *t1, struct type *t2,
struct value *v1, struct value *v2);
- 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)
{
if (type && type->print)
+ type->print(type, v, f);
- printf("*Unknown*"); // NOTEST
+ fprintf(f, "*Unknown*"); // NOTEST
struct value *vold, struct value *vnew);
static int value_cmp(struct type *tl, struct type *tr,
struct value *left, struct value *right);
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
###### free context types
- 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
{
switch (type->vtype) {
case Vnone: // NOTEST
- printf("*no-value*"); break; // NOTEST
+ fprintf(f, "*no-value*"); break; // NOTEST
- printf("*label-%p*", v->label); break; // NOTEST
+ fprintf(f, "*label-%p*", v->label); break; // NOTEST
- printf("%.*s", v->str.len, v->str.txt); break;
+ fprintf(f, "%.*s", v->str.len, v->str.txt); break;
- 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);
case Vnum:
{
mpf_t fl;
mpf_init2(fl, 20);
mpf_set_q(fl, v->num);
+ gmp_fprintf(f, "%Fg", fl);
fprintf(f, " = ");
if (fl->type == Tstr)
fprintf(f, "\""); // UNTESTED
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
}
if (fl->type == Tstr)
fprintf(f, "\""); // UNTESTED
}
- 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);
}
{
print_exec(val->function, 1, 0);
}
struct val *v = cast(val, e);
if (v->vtype == Tstr)
printf("\"");
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;
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);
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(' ');
free_value(ltype, &left);
if (b2->right)
putchar(' ');
printf(" = ");
if (v->type == Tstr)
printf("\"");
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 (v->type == Tstr)
printf("\"");
printf("\n");
if (brackets)
print_exec(val->function, 0, brackets);
else
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;
}
printf("/* frame size %d */\n", v->type->function.local_size);
target -= 1;
}