aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2022-08-20 06:35:05 +0200
committerlemon <lsof@mailbox.org>2022-08-20 06:47:17 +0200
commitdf41a4512932f1312e4725d0409757a683b091ed (patch)
tree5a87b358529fb2fe92eefa6d4f47e0ac78b4d131 /src
parent19acdd751963e88b6e75693f947b1b1fd2912f11 (diff)
defer fix
Diffstat (limited to 'src')
-rw-r--r--src/parse.cff12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/parse.cff b/src/parse.cff
index c3831ef..f2bbb41 100644
--- a/src/parse.cff
+++ b/src/parse.cff
@@ -922,6 +922,7 @@ fn parseexpandtepl(P *Parser, tepl *Tepl) *const Type {
return cache.ty;
}
let env = mkenv(tepl.env, P.tlalloc);
+ defer envfree(env);
with_tmpchange(P.curenv, env) {
let decl *Decl #?;
let expan Expan = {
@@ -932,7 +933,6 @@ fn parseexpandtepl(P *Parser, tepl *Tepl) *const Type {
ty = parseagg(P, loc, tepl.kind, tname, &decl);
}
P.peektok = :None;
- envfree(env);
(as(*Type)ty).u.Agg.tpargs = tpargs;
cache = P.tlalloc->alloc(sizeof(*cache), alignof(*cache));
cache.next = tepl.cache;
@@ -2039,13 +2039,13 @@ fn pstwhile(P *Parser, loc Loc, label *const u8) Stmt {
let body [#]Stmt #?;
with_tmpchange(P.curloop, ++P.loopid) {
let env = mkenv(P.curenv, P.alloc);
+ defer envfree(env);
pushenv(P, env);
if label {
putdecl(P, loc, { label, loc, .u: :Label(P.loopid) });
}
body = parseblock(P);
popenv(P);
- envfree(env);
}
return { loc, :While { test, body, P.loopid }};
}
@@ -2088,13 +2088,13 @@ fn pstfor(P *Parser, loc Loc, label *const u8) Stmt {
let body [#]Stmt #?;
with_tmpchange(P.curloop, ++P.loopid) {
let env = mkenv(P.curenv, P.alloc);
+ defer envfree(env);
pushenv(P, env);
if label {
putdecl(P, loc, { label, loc, .u: :Label(P.loopid) });
}
body = parseblock(P);
popenv(P);
- envfree(env);
}
return { loc, :For { ini, test, next, body, P.loopid }};
}
@@ -2169,6 +2169,7 @@ fn psteuswitch(P *Parser, loc Loc, test Expr) Stmt {
}
}
let env = mkenv(P.curenv, P.alloc);
+ defer envfree(env);
if c.fld.ty != #null and lexmatch(P, &tok, :ident) {
let ty = c.fld.ty;
c.capt = tok.u.ident;
@@ -2185,7 +2186,6 @@ fn psteuswitch(P *Parser, loc Loc, test Expr) Stmt {
if c.capt {
popenv(P);
}
- envfree(env);
}
@@ -2320,6 +2320,7 @@ fn parseblock0(P *Parser) [#]Stmt {
let sts Vec<Stmt> = {};
let tok Tok = {};
let env = mkenv(P.curenv, P.alloc);
+ defer envfree(env);
pushenv(P, env);
while (tok = lexpeek(P)).t != '}' and tok.t != :kw_case and tok.t != ')' {
if lexmatch(P, #null, ';') { continue; }
@@ -2330,7 +2331,6 @@ fn parseblock0(P *Parser) [#]Stmt {
parsestmts(P, &pushstmt, &sts);
}
popenv(P);
- envfree(env);
return sts->move(P.alloc);
}
@@ -2433,6 +2433,7 @@ fn parsefn(P *Parser, loc Loc, externp bool, name *const u8) *Decl {
with_tmpchange(P.alloc, &Allocator { &Arena {}, &Arena:allocf }) {
with_tmpchange(P.curfn, Fn) {
let env = mkenv(P.curenv, P.alloc);
+ defer envfree(env);
pushenv(P, env);
foreach(name, i, Fn.paramnames) {
if name {
@@ -2443,7 +2444,6 @@ fn parsefn(P *Parser, loc Loc, externp bool, name *const u8) *Decl {
}
Fn.body = :Some(parseblock(P));
popenv(P);
- envfree(env);
(as(*Arena)P.alloc.a)->destroy();
}
}