summaryrefslogtreecommitdiff
path: root/parse/stab.c
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin@c9x.me>2018-01-18 11:46:13 +0000
committerOri Bernstein <ori@eigenstate.org>2018-01-26 22:39:56 -0800
commit6fb0d750b296506f31cfd0871fdac82ee878834b (patch)
tree0d6bab181652f7859c6eef913285abfc41d1bc38 /parse/stab.c
parent24a566ff1751b246c8b6efd8adea3447975b9efa (diff)
downloadmc-6fb0d750b296506f31cfd0871fdac82ee878834b.tar.gz
New auto operator.
Summary: -------- During the Myrcon in September Ori suggested an 'auto' operator that would evaluate what it applies to, store the result in a temporary t, and call __dispose__(t) when the current block exits. This patch implements this idea under the form of a unary operator. This, for instance, allows to have: impl disposable regex# = __dispose__ = {r; regex.free(r)} ;; regex.exec(auto std.try(regex.compile("f..bar")), "foobar") Like before, it is guaranteed that __dispose__ is called in reverse order of auto appearance. Backward compatibility: ----------------------- Nope. Auto variables are now gone. This should not be a problem, simply rewrite: var auto x = foo() into: var x = auto foo() Implementation: --------------- It largely reuses the code I had written for 'auto' variables but needs a little finer grain tracking because we don't always want to call __dispose__ for *all* auto expression results when leaving a block (some might not be evaluated yet). For example: auto 1 if b -> void ;; auto 2 Only __dispose__(1) must be called when '-> void' is executed. If the block falls through, __dispose__(2) and __dispose__(1) will be called in sequence. TODO: ----- - Err when goto jumps in/out of a block that has auto expressions. - Support auto in patterns. match ... | `std.Some (auto x): ... is essentially rewritten to: match ... | `std.Some (auto x): auto x ... - Test edge cases (e.g., auto in loop condition) Actually, test. Cheers,
Diffstat (limited to 'parse/stab.c')
-rw-r--r--parse/stab.c4
1 files changed, 0 insertions, 4 deletions
diff --git a/parse/stab.c b/parse/stab.c
index 2d190d9..7e1b8c0 100644
--- a/parse/stab.c
+++ b/parse/stab.c
@@ -417,10 +417,6 @@ putdcl(Stab *st, Node *s)
st = findstab(st, s->decl.name);
old = htget(st->dcl, s->decl.name);
- if (s->decl.isauto) {
- assert(!old);
- lappend(&st->autodcl, &st->nautodcl, s);
- }
if (!old)
forcedcl(st, s);
else if (!mergedecl(old, s))