Fix range(value;stream) (fix #886)
This commit is contained in:
1 parent
d66fbd218b
commit
a47b32999b
2 files changed
+16
-2
No files matched your search
@@ -1339,9 +1339,15 @@ static block bind_bytecoded_builtins(block b) {
|
|||||||
{
|
{
|
||||||
// Note that we can now define `range` as a jq-coded function
|
// Note that we can now define `range` as a jq-coded function
|
||||||
block rangevar = gen_op_var_fresh(STOREV, "rangevar");
|
block rangevar = gen_op_var_fresh(STOREV, "rangevar");
|
||||||
block init = BLOCK(gen_op_simple(DUP), gen_call("start", gen_noop()), rangevar);
|
block rangestart = gen_op_var_fresh(STOREV, "rangestart");
|
||||||
block range = BLOCK(init,
|
block range = BLOCK(gen_op_simple(DUP),
|
||||||
|
gen_call("start", gen_noop()),
|
||||||
|
rangestart,
|
||||||
gen_call("end", gen_noop()),
|
gen_call("end", gen_noop()),
|
||||||
|
gen_op_simple(DUP),
|
||||||
|
gen_op_bound(LOADV, rangestart),
|
||||||
|
// Reset rangevar for every value generated by "end"
|
||||||
|
rangevar,
|
||||||
gen_op_bound(RANGE, rangevar));
|
gen_op_bound(RANGE, rangevar));
|
||||||
builtins = BLOCK(builtins, gen_function("range",
|
builtins = BLOCK(builtins, gen_function("range",
|
||||||
BLOCK(gen_param("start"), gen_param("end")),
|
BLOCK(gen_param("start"), gen_param("end")),
|
||||||
|
|||||||
@@ -231,6 +231,10 @@ null
|
|||||||
null
|
null
|
||||||
[0,1,2,3,4,5,6,7,8,9]
|
[0,1,2,3,4,5,6,7,8,9]
|
||||||
|
|
||||||
|
[range(0,1;3,4)]
|
||||||
|
null
|
||||||
|
[0,1,2, 0,1,2,3, 1,2, 1,2,3]
|
||||||
|
|
||||||
[range(0;10;3)]
|
[range(0;10;3)]
|
||||||
null
|
null
|
||||||
[0,3,6,9]
|
[0,3,6,9]
|
||||||
@@ -243,6 +247,10 @@ null
|
|||||||
null
|
null
|
||||||
[0,-1,-2,-3,-4]
|
[0,-1,-2,-3,-4]
|
||||||
|
|
||||||
|
[range(0,1;4,5;1,2)]
|
||||||
|
null
|
||||||
|
[0,1,2,3,0,2, 0,1,2,3,4,0,2,4, 1,2,3,1,3, 1,2,3,4,1,3]
|
||||||
|
|
||||||
[while(.<100; .*2)]
|
[while(.<100; .*2)]
|
||||||
1
|
1
|
||||||
[1,2,4,8,16,32,64]
|
[1,2,4,8,16,32,64]
|
||||||
|
|||||||
Reference in new issue
Block a user