summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Langford <wlangfor@gmail.com>2014-08-05 13:41:59 -0400
committerWilliam Langford <wlangfor@gmail.com>2014-08-05 13:41:59 -0400
commitef5bd5a6de10657430a438955a83a7bb99a8468a (patch)
tree991319294488bebdcb6109f095c9dec4a9669348
parent2159f9f5e06cd701f58a3ea6709d42a574cc280b (diff)
parenta25950a58c4f16692df98695eb870c414726e363 (diff)
Merge pull request #532 from wtlangford/top-removal
Remove duplicate TOP insertions, drop unused defs.
-rw-r--r--compile.c8
-rw-r--r--parser.y5
2 files changed, 7 insertions, 6 deletions
diff --git a/compile.c b/compile.c
index 03d03c3e..cc5a8d09 100644
--- a/compile.c
+++ b/compile.c
@@ -399,7 +399,7 @@ block block_drop_unreferenced(block body) {
int drop;
do {
drop = 0;
- while((curr = block_take(&body)) && curr->op != TOP) {
+ while ((curr = block_take(&body)) && curr->op != TOP) {
block b = inst_block(curr);
if (block_count_refs(b,refd) + block_count_refs(b,body) == 0) {
unrefd = BLOCK(unrefd, b);
@@ -593,7 +593,11 @@ block gen_definedor(block a, block b) {
}
int block_has_main(block top) {
- return top.first && top.first->op == TOP;
+ for (inst *c = top.first; c; c = c->next) {
+ if (c->op == TOP)
+ return 1;
+ }
+ return 0;
}
int block_is_funcdef(block b) {
diff --git a/parser.y b/parser.y
index 0117e1a2..72e2b28f 100644
--- a/parser.y
+++ b/parser.y
@@ -278,10 +278,7 @@ FuncDef FuncDefs {
Exp:
FuncDef Exp %prec ';' {
- if (block_is_funcdef($2))
- $$ = block_bind($1, $2, OP_IS_CALL_PSEUDO);
- else
- $$ = block_bind($1, BLOCK(gen_op_simple(TOP), $2), OP_IS_CALL_PSEUDO);
+ $$ = block_bind_referenced($1, $2, OP_IS_CALL_PSEUDO);
} |
Term "as" '$' IDENT '|' Exp {