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
Provenance
- Commit
abed751- Tree
bb87405- Author
Muh Muhten <muh.muhten@gmail.com>- Committer
Nico Williams <nico@cryptonector.com>- Parent
141bb78
9 files changed+32 added−4 removed
modified:src/compile.c+1 added-1 removed
398 unmodified lines399 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 linesmodified:src/linker.c+5 added-1 removed
238 unmodified lines239 jv deps = block_take_imports(src_block);240 block bk = *src_block;241 int nerrors = 0;242 243- 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);247+248 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 linesadded:tests/modules/shadow1.jq+2 added
1+def e: 1;2+def e: 2;added:tests/modules/shadow2.jq+1 added
1+def e: 3;modified:tests/modules/test_bind_order0.jq+1 added
1 def sym0: 0;2+def sym1: 0;modified:tests/modules/test_bind_order1.jq+1 added-1 removed
1-def sym0: 1;1 def sym1: 1;2+def sym2: 1;modified:tests/modules/test_bind_order2.jq-1 removed
1-def sym1: 2;1 def sym2: 2;modified:tests/jq.test+20 added
602 unmodified lines603 def 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]606 607+def 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]608+null609+[4,1,2,3,3,5,4,1,2,3,3]610+611 # Test precedence of 'def' vs '|'612 def a: 0; . | a613 null614 0852 unmodified lines1467 import "data" as $e; import "data" as $d; [$d[].this,$e[].that,$d::d[].this,$e::e[].that]|join(";")1468 null1469 "is a test;is too;is a test;is too"1470 1471+include "shadow1"; e1472+null1473+21474+1475+include "shadow1"; include "shadow2"; e1476+null1477+31478+1479+import "shadow1" as f; import "shadow2" as f; import "shadow1" as e; [e::e, f::e]1480+null1481+[2,3]1482+1483 %%FAIL1484 module (.+1); 01485 jq: error: Module metadata must be constant at <top-level>, line 1:1486 16 unmodified lines1503 modulemeta1504 "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"}]}1506 1507+modulemeta | .deps |= length1508+"c"1509+{"whatever":null,"deps":6}1510+1511 %%FAIL IGNORE MSG1512 import "syntaxerror" as e; .1513 jq: 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 linesmodified:Makefile.am+1 added
174 unmodified lines175 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