Skip to content
Myr

Bind libraries backward for consistent shadowing

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Muh Muhten · committed by Nico Williams · parent 141bb78 · Browse files · 9 files+32 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

9 files+32 added−4 removed

  • tests:+25 added−2 removed
  • other:+7 added−2 removed

9 files+32 added−4 removed

modified:src/compile.c+1 added-1 removed
398 unmodified lines
399 strcpy(matchname+matchlen, "::");400 matchlen += 2;401 }402 assert(block_has_only_binders(binder, bindflags));403 for (inst *curr = binder.first; curr; curr = curr->next) {403 for (inst *curr = binder.last; curr; curr = curr->prev) {404 int bindflags2 = bindflags;405 char* cname = curr->symbol;406 char* tname = jv_mem_alloc(strlen(curr->symbol)+matchlen+1);407 strcpy(tname, matchname);
1006 unmodified lines
modified:src/linker.c+5 added-1 removed
238 unmodified lines
239 jv deps = block_take_imports(src_block);240 block bk = *src_block;241 int nerrors = 0;242243 jv_array_foreach(deps, i, dep) {243 // XXX This is a backward jv_array_foreach because bindings go in reverse244 for (int i = jv_array_length(jv_copy(deps)); i > 0; ) {245 i--;246 jv dep = jv_array_get(jv_copy(deps), i);247248 const char *as_str = NULL;249 int is_data = jv_get_kind(jv_object_get(jv_copy(dep), jv_string("is_data"))) == JV_KIND_TRUE;250 int raw = 0;251 jv v = jv_object_get(jv_copy(dep), jv_string("raw"));
186 unmodified lines
added:tests/modules/shadow1.jq+2 added
1def e: 1;2def e: 2;
added:tests/modules/shadow2.jq+1 added
1def e: 3;
modified:tests/modules/test_bind_order0.jq+1 added
1def sym0: 0;2def sym1: 0;
modified:tests/modules/test_bind_order1.jq+1 added-1 removed
1def sym0: 1;1def sym1: 1;2def sym2: 1;
modified:tests/modules/test_bind_order2.jq-1 removed
1def sym1: 2;1def sym2: 2;
modified:tests/jq.test+20 added
602 unmodified lines
603def f(a;b;c;d;e;f): [a+1,b,c,d,e,f]; f(.[0];.[1];.[0];.[0];.[0];.[0])604[1,2]605[2,2,1,1,1,1]606607def f: 1; def g: f, def f: 2; def g: 3; f, def f: g; f, g; def f: 4; [f, def f: g; def g: 5; f, g]+[f,g]608null609[4,1,2,3,3,5,4,1,2,3,3]610611# Test precedence of 'def' vs '|'612def a: 0; . | a613null6140
852 unmodified lines
1467import "data" as $e; import "data" as $d; [$d[].this,$e[].that,$d::d[].this,$e::e[].that]|join(";")1468null1469"is a test;is too;is a test;is too"14701471include "shadow1"; e1472null1473214741475include "shadow1"; include "shadow2"; e1476null1477314781479import "shadow1" as f; import "shadow2" as f; import "shadow1" as e; [e::e, f::e]1480null1481[2,3]14821483%%FAIL1484module (.+1); 01485jq: error: Module metadata must be constant at <top-level>, line 1:1486
16 unmodified lines
1503modulemeta1504"c"1505{"whatever":null,"deps":[{"as":"foo","is_data":false,"relpath":"a"},{"search":"./","as":"d","is_data":false,"relpath":"d"},{"search":"./","as":"d2","is_data":false,"relpath":"d"},{"search":"./../lib/jq","as":"e","is_data":false,"relpath":"e"},{"search":"./../lib/jq","as":"f","is_data":false,"relpath":"f"},{"as":"d","is_data":true,"relpath":"data"}]}15061507modulemeta | .deps |= length1508"c"1509{"whatever":null,"deps":6}15101511%%FAIL IGNORE MSG1512import "syntaxerror" as e; .1513jq: error: syntax error, unexpected ';', expecting $end (Unix shell quoting issues?) at /home/nico/ws/jq/tests/modules/syntaxerror/syntaxerror.jq, line 1:1514
135 unmodified lines
modified:Makefile.am+1 added
174 unmodified lines
175 tests/modules/a.jq tests/modules/b/b.jq tests/modules/c/c.jq \176 tests/modules/c/d.jq tests/modules/data.json \177 tests/modules/home1/.jq tests/modules/home2/.jq/g.jq \178 tests/modules/lib/jq/e/e.jq tests/modules/lib/jq/f.jq \179 tests/modules/shadow1.jq tests/modules/shadow2.jq \180 tests/modules/syntaxerror/syntaxerror.jq \181 tests/modules/test_bind_order.jq \182 tests/modules/test_bind_order0.jq \183 tests/modules/test_bind_order1.jq \
36 unmodified lines