1
0
mirror of https://github.com/stedolan/jq.git synced 2024-05-11 05:55:39 +00:00

Constant fold objects

This commit is contained in:
Nicolas Williams
2014-08-09 20:47:03 -05:00
parent f87521183f
commit c321c3b86b
3 changed files with 51 additions and 2 deletions

View File

@@ -631,7 +631,11 @@ FORMAT {
$$ = gen_const(jv_array());
} |
'{' MkDict '}' {
$$ = BLOCK(gen_subexp(gen_const(jv_object())), $2, gen_op_simple(POP));
block o = gen_const_object($2);
if (o.first != NULL)
$$ = o;
else
$$ = BLOCK(gen_subexp(gen_const(jv_object())), $2, gen_op_simple(POP));
} |
'$' IDENT {
$$ = gen_location(@$, locations, gen_op_unbound(LOADV, jv_string_value($2)));