Library defs don't bind to each other; fix #479
This commit is contained in:
1 parent
6e88d419ba
commit
6b6e3f4262
1 file changed
+18
-4
@@ -290,16 +290,30 @@ block block_bind(block binder, block body, int bindflags) {
|
|||||||
block block_bind_referenced(block binder, block body, int bindflags) {
|
block block_bind_referenced(block binder, block body, int bindflags) {
|
||||||
assert(block_has_only_binders(binder, bindflags));
|
assert(block_has_only_binders(binder, bindflags));
|
||||||
bindflags |= OP_HAS_BINDING;
|
bindflags |= OP_HAS_BINDING;
|
||||||
block refd = gen_noop();
|
|
||||||
|
// 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:
|
||||||
for (inst* curr; (curr = block_take(&binder));) {
|
for (inst* curr; (curr = block_take(&binder));) {
|
||||||
block b = inst_block(curr);
|
block b = inst_block(curr);
|
||||||
if (block_bind_subblock(b, body, bindflags)) {
|
if (block_bind_subblock(b, body, bindflags)) {
|
||||||
refd = BLOCK(refd, b);
|
body = BLOCK(b, body);
|
||||||
} else {
|
} else {
|
||||||
block_free(b);
|
unrefd = BLOCK(unrefd, b);
|
||||||
|
unref_count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return block_join(refd, body);
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
block gen_function(const char* name, block formals, block body) {
|
block gen_function(const char* name, block formals, block body) {
|
||||||
|
|||||||
Reference in new issue
Block a user