summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles.Forsyth <devnull@localhost>2008-02-01 18:46:35 +0000
committerCharles.Forsyth <devnull@localhost>2008-02-01 18:46:35 +0000
commit04f9470ee130b6877edcaa202c0a143c9a48fced (patch)
tree2917c267fefe64b1cf3efcc6a6281115d46e2d8e
parentacf16bbe632adbae6f2caf3210136c47ecee6a62 (diff)
20080201-1852
-rw-r--r--appl/cmd/limbo/com.b8
-rw-r--r--appl/cmd/limbo/gen.b2
-rw-r--r--dis/limbo.disbin343192 -> 343278 bytes
-rw-r--r--limbo/com.c12
-rw-r--r--limbo/gen.c2
5 files changed, 15 insertions, 9 deletions
diff --git a/appl/cmd/limbo/com.b b/appl/cmd/limbo/com.b
index c14cd923..320d209c 100644
--- a/appl/cmd/limbo/com.b
+++ b/appl/cmd/limbo/com.b
@@ -388,10 +388,14 @@ fncom(decl: ref Decl)
scom(n.left);
}
pushblock();
- in := genrawop(src, IRET, nil, nil, nil);
+ valued := decl.ty.tof != tnone;
+ if(valued)
+ in := genrawop(src, IRAISE, nil, nil, nil);
+ else
+ in = genrawop(src, IRET, nil, nil, nil);
popblock();
reach(decl.pc);
- if(in.reach != byte 0 && decl.ty.tof != tnone)
+ if(valued && in.reach != byte 0)
error(src.start, "no return at end of function " + dotconv(decl));
# decl.endpc = lastinst;
if(labdep != 0)
diff --git a/appl/cmd/limbo/gen.b b/appl/cmd/limbo/gen.b
index 10988f48..ab4bb6af 100644
--- a/appl/cmd/limbo/gen.b
+++ b/appl/cmd/limbo/gen.b
@@ -562,8 +562,6 @@ foldbranch(in: ref Inst)
next := in.next;
*in = *b;
in.next = next;
- if(b.op == IRET)
- b.reach = byte 1; # might be default return (TO DO)
continue;
}
foldbranch(in.branch);
diff --git a/dis/limbo.dis b/dis/limbo.dis
index 445c1d3a..e455128c 100644
--- a/dis/limbo.dis
+++ b/dis/limbo.dis
Binary files differ
diff --git a/limbo/com.c b/limbo/com.c
index 1bc070a4..967d17b0 100644
--- a/limbo/com.c
+++ b/limbo/com.c
@@ -368,6 +368,7 @@ fncom(Decl *decl)
Node *n;
Decl *loc, *last;
Inst *in;
+ int valued;
curfn = decl;
if(ispoly(decl))
@@ -410,10 +411,11 @@ fncom(Decl *decl)
scom(n->left);
}
pushblock();
- in = genrawop(&src, IRET, nil, nil, nil);
+ valued = decl->ty->tof != tnone;
+ in = genrawop(&src, valued? IRAISE: IRET, nil, nil, nil);
popblock();
reach(decl->pc);
- if(in->reach && decl->ty->tof != tnone)
+ if(valued && in->reach)
error(src.start, "no return at end of function %D", decl);
/* decl->endpc = lastinst; */
if(labdep != 0)
@@ -1435,6 +1437,9 @@ ret(Node *n, int nilret)
return n->op == Oret && n->left == nil;
}
+/*
+ * tail-recursive call
+ */
static int
trcom(Node *e, Node *ne, int nilret)
{
@@ -1442,7 +1447,8 @@ trcom(Node *e, Node *ne, int nilret)
Node *as, *a, *f, *n;
Inst *p;
-return 0; // TBS
+ if(1)
+ return 0; /* TO DO: should we enable this? */
if(e->op != Ocall || e->left->op != Oname)
return 0;
d = e->left->decl;
diff --git a/limbo/gen.c b/limbo/gen.c
index 64dce6e5..fe77dc80 100644
--- a/limbo/gen.c
+++ b/limbo/gen.c
@@ -590,8 +590,6 @@ foldbranch(Inst *in)
next = in->next;
*in = *b;
in->next = next;
- if(b->op == IRET)
- b->reach = 1; /* might be default return (TO DO) */
continue;
}
foldbranch(b);