summaryrefslogtreecommitdiffstats
path: root/compile.c
diff options
context:
space:
mode:
authorNicolas Williams <nico@cryptonector.com>2014-07-13 02:04:27 -0500
committerNicolas Williams <nico@cryptonector.com>2014-07-13 02:04:27 -0500
commitcadf8c3cb000fd2c322f89689229dc94d7deddf4 (patch)
treea57df3361e646fec282da12fcd65ba8eb7fa66ed /compile.c
parent6b6e3f42627f360cbbad2287968b2a209ab43593 (diff)
Revert "Library defs don't bind to each other; fix #479"
This reverts commit 6b6e3f42627f360cbbad2287968b2a209ab43593. It was the wrong fix.
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c22
1 files changed, 4 insertions, 18 deletions
diff --git a/compile.c b/compile.c
index dc0c009d..64ff41d0 100644
--- a/compile.c
+++ b/compile.c
@@ -290,30 +290,16 @@ block block_bind(block binder, block body, int bindflags) {
block block_bind_referenced(block binder, block body, int bindflags) {
assert(block_has_only_binders(binder, bindflags));
bindflags |= OP_HAS_BINDING;
-
- // Repeatedly bind until there's no remaining references to any of the
- // binders in binder.
- block unrefd = gen_noop();
- int unref_count = 0, last = -1;
-loop:
+ block refd = gen_noop();
for (inst* curr; (curr = block_take(&binder));) {
block b = inst_block(curr);
if (block_bind_subblock(b, body, bindflags)) {
- body = BLOCK(b, body);
+ refd = BLOCK(refd, b);
} else {
- unrefd = BLOCK(unrefd, b);
- unref_count++;
+ block_free(b);
}
}
- if (unref_count == 0 || unref_count == last) {
- block_free(unrefd);
- return body;
- }
- last = unref_count;
- unref_count = 0;
- binder = unrefd;
- unrefd = gen_noop();
- goto loop;
+ return block_join(refd, body);
}
block gen_function(const char* name, block formals, block body) {