Make sure that printing with --bracket is still parseable, and
double-printing doesn't change from single.
Signed-off-by: NeilBrown <neil@brown.name>
./oceani --noexec --print .tmp.code1a >> .tmp.code2a || exit 1;\
if ! cmp -s .tmp.code1 .tmp.code2a; then \
echo " Failed"; diff -u .tmp.code1 .tmp.code2a; exit 1; fi ; \
./oceani --noexec --print .tmp.code1a >> .tmp.code2a || exit 1;\
if ! cmp -s .tmp.code1 .tmp.code2a; then \
echo " Failed"; diff -u .tmp.code1 .tmp.code2a; exit 1; fi ; \
+ echo -n "brackets.. "; \
+ echo '``````' > .tmp.code2b ; echo '``````' > .tmp.code2c ;\
+ ./oceani --noexec --print --brackets .tmp.code1 >> .tmp.code2b || exit 1; \
+ ./oceani -npb .tmp.code2b >> .tmp.code2c || exit 1 ; \
+ if ! cmp -s .tmp.code2b .tmp.code2c; then \
+ echo " Failed"; diff -u .tmp.code2b .tmp.code2c; exit 1; fi; \
echo -n "exec-after-print.. "; \
./oceani .tmp.code1 $${1+"$$@"} > .tmp.have ; \
if ! cmp -s .tmp.want .tmp.have; then \
echo -n "exec-after-print.. "; \
./oceani .tmp.code1 $${1+"$$@"} > .tmp.have ; \
if ! cmp -s .tmp.want .tmp.have; then \
static void function_print(struct type *type, struct value *val, FILE *f)
{
static void function_print(struct type *type, struct value *val, FILE *f)
{
print_exec(val->function, 1, 0);
}
print_exec(val->function, 1, 0);
}
} else
type_print(type->function.return_type, f);
}
} else
type_print(type->function.return_type, f);
}
}
static void function_free_type(struct type *t)
}
static void function_free_type(struct type *t)
if (bracket) printf(")");
break;
case Bracket:
if (bracket) printf(")");
break;
case Bracket:
+ /* Avoid double brackets... */
+ if (!bracket) printf("(");
print_exec(b->right, indent, bracket);
print_exec(b->right, indent, bracket);
+ if (!bracket) printf(")");
break;
###### propagate binode cases
break;
###### propagate binode cases
struct value *val = var_value(&context, v);
printf("func %.*s", v->name->name.len, v->name->name.txt);
v->type->print_type_decl(v->type, stdout);
struct value *val = var_value(&context, v);
printf("func %.*s", v->name->name.len, v->name->name.txt);
v->type->print_type_decl(v->type, stdout);
- if (brackets)
- print_exec(val->function, 0, brackets);
- else
+ if (brackets) {
+ printf(" {\n");
+ print_exec(val->function, 1, brackets);
+ printf("}\n");
+ } else {
print_value(v->type, val, stdout);
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;
}