diff options
author | Muh Muhten <muh.muhten@gmail.com> | 2019-02-20 23:05:29 -0500 |
---|---|---|
committer | Nico Williams <nico@cryptonector.com> | 2019-02-26 21:57:08 -0600 |
commit | abed751e9669ee716b04a8923413c4bc2734185d (patch) | |
tree | bb8740582ffe3e221c0a103390bcd15614fa2efd /src | |
parent | 141bb78e967f0d088b9fda134bb75e23405bd844 (diff) |
Bind libraries backward for consistent shadowing
Diffstat (limited to 'src')
-rw-r--r-- | src/compile.c | 2 | ||||
-rw-r--r-- | src/linker.c | 6 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/compile.c b/src/compile.c index ad632258..dfac30d8 100644 --- a/src/compile.c +++ b/src/compile.c @@ -400,7 +400,7 @@ block block_bind_library(block binder, block body, int bindflags, const char *li matchlen += 2; } assert(block_has_only_binders(binder, bindflags)); - for (inst *curr = binder.first; curr; curr = curr->next) { + for (inst *curr = binder.last; curr; curr = curr->prev) { int bindflags2 = bindflags; char* cname = curr->symbol; char* tname = jv_mem_alloc(strlen(curr->symbol)+matchlen+1); diff --git a/src/linker.c b/src/linker.c index 5611d512..962bdc14 100644 --- a/src/linker.c +++ b/src/linker.c @@ -240,7 +240,11 @@ static int process_dependencies(jq_state *jq, jv jq_origin, jv lib_origin, block block bk = *src_block; int nerrors = 0; - jv_array_foreach(deps, i, dep) { + // XXX This is a backward jv_array_foreach because bindings go in reverse + for (int i = jv_array_length(jv_copy(deps)); i > 0; ) { + i--; + jv dep = jv_array_get(jv_copy(deps), i); + const char *as_str = NULL; int is_data = jv_get_kind(jv_object_get(jv_copy(dep), jv_string("is_data"))) == JV_KIND_TRUE; int raw = 0; |