hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 6ce91d72cf90c1db70a8c8013375304bddb670f9
parent e52fa9692550aa5d4bb7436e60f1c4d2f9c3bb4d
Author: Sebastian <sebastian@sebsite.pw>
Date:   Thu, 21 Apr 2022 15:41:45 -0400

hare::ast: rename expr_free to expr_finish

Signed-off-by: Sebastian <sebastian@sebsite.pw>

Diffstat:
Mhare/ast/decl.ha | 6+++---
Mhare/ast/expr.ha | 112++++++++++++++++++++++++++++++++++++++++----------------------------------------
Mhare/ast/type.ha | 7+++----
Mhare/parse/+test/loc.ha | 4++--
Mhare/unit/process.ha | 20++++++++++----------
5 files changed, 74 insertions(+), 75 deletions(-)

diff --git a/hare/ast/decl.ha b/hare/ast/decl.ha @@ -71,7 +71,7 @@ export fn decl_finish(d: decl) void = { free(g[i].symbol); ident_free(g[i].ident); type_finish(g[i]._type); - expr_free(g[i].init); + expr_finish(g[i].init); }; free(g); case let t: []decl_type => @@ -84,12 +84,12 @@ export fn decl_finish(d: decl) void = { free(f.symbol); ident_free(f.ident); type_finish(f.prototype); - if (f.body is expr) expr_free(f.body as expr); + if (f.body is expr) expr_finish(f.body as expr); case let c: []decl_const => for (let i = 0z; i < len(c); i += 1) { ident_free(c[i].ident); type_finish(c[i]._type); - expr_free(c[i].init); + expr_finish(c[i].init); }; free(c); }; diff --git a/hare/ast/expr.ha b/hare/ast/expr.ha @@ -423,12 +423,12 @@ export type expr = struct { }; // Frees resources associated with a Hare [[expr]]ession. -export fn expr_free(e: (expr | nullable *expr)) void = match (e) { +export fn expr_finish(e: (expr | nullable *expr)) void = match (e) { case let e: nullable *expr => match (e) { case null => void; case let e: *expr => - expr_free(*e); + expr_finish(*e); free(e); }; case let e: expr => @@ -438,59 +438,59 @@ case let e: expr => case let i: access_identifier => ident_free(i); case let i: access_index => - expr_free(i.object); - expr_free(i.index); + expr_finish(i.object); + expr_finish(i.index); case let f: access_field => - expr_free(f.object); + expr_finish(f.object); free(f.field); case let t: access_tuple => - expr_free(t.object); - expr_free(t.value); + expr_finish(t.object); + expr_finish(t.value); }; case let a: alloc_expr => - expr_free(a.init); - expr_free(a.capacity); + expr_finish(a.init); + expr_finish(a.capacity); case let a: append_expr => - expr_free(a.object); + expr_finish(a.object); match (a.variadic) { case null => void; case let v: *expr => - expr_free(v); + expr_finish(v); }; for (let i = 0z; i < len(a.values); i += 1) { - expr_free(a.values[i]); + expr_finish(a.values[i]); }; free(a.values); case let a: assert_expr => - expr_free(a.cond); - expr_free(a.message); + expr_finish(a.cond); + expr_finish(a.message); case let a: assign_expr => - expr_free(a.object); - expr_free(a.value); + expr_finish(a.object); + expr_finish(a.value); case let b: binarithm_expr => - expr_free(b.lvalue); - expr_free(b.rvalue); + expr_finish(b.lvalue); + expr_finish(b.rvalue); case let b: binding_expr => for (let i = 0z; i < len(b.bindings); i += 1) { free(b.bindings[i].name); type_finish(b.bindings[i]._type); - expr_free(b.bindings[i].init); + expr_finish(b.bindings[i].init); }; free(b.bindings); case let b: break_expr => free(b); case let c: call_expr => - expr_free(c.lvalue); + expr_finish(c.lvalue); for (let i = 0z; i < len(c.args); i += 1) { - expr_free(c.args[i]); + expr_finish(c.args[i]); }; free(c.args); case let c: cast_expr => - expr_free(c.value); + expr_finish(c.value); type_finish(c._type); case let c: compound_expr => for (let i = 0z; i < len(c.exprs); i += 1) { - expr_free(c.exprs[i]); + expr_finish(c.exprs[i]); }; free(c.exprs); free(c.label); @@ -499,14 +499,14 @@ case let e: expr => case (void | _null | ...lex::value) => void; case let a: array_constant => for (let i = 0z; i < len(a.values); i += 1) { - expr_free(a.values[i]); + expr_finish(a.values[i]); }; free(a.values); case let s: struct_constant => struct_constant_free(s); case let t: tuple_constant => for (let i = 0z; i < len(t); i += 1) { - expr_free(t[i]); + expr_finish(t[i]); }; free(t); case number_constant => void; @@ -514,90 +514,90 @@ case let e: expr => case let c: continue_expr => free(c); case let d: defer_expr => - expr_free(d: *expr); + expr_finish(d: *expr); case let d: delete_expr => - expr_free(d.object); + expr_finish(d.object); case let f: for_expr => - expr_free(f.bindings); - expr_free(f.cond); - expr_free(f.afterthought); - expr_free(f.body); + expr_finish(f.bindings); + expr_finish(f.cond); + expr_finish(f.afterthought); + expr_finish(f.body); case let f: free_expr => - expr_free(f: *expr); + expr_finish(f: *expr); case let i: if_expr => - expr_free(i.cond); - expr_free(i.tbranch); - expr_free(i.fbranch); + expr_finish(i.cond); + expr_finish(i.tbranch); + expr_finish(i.fbranch); case let e: insert_expr => - expr_free(e.object); + expr_finish(e.object); match (e.variadic) { case null => void; case let v: *expr => - expr_free(v); + expr_finish(v); }; for (let i = 0z; i < len(e.values); i += 1) { - expr_free(e.values[i]); + expr_finish(e.values[i]); }; free(e.values); case let l: len_expr => - expr_free(l: *expr); + expr_finish(l: *expr); case let m: match_expr => - expr_free(m.value); + expr_finish(m.value); for (let i = 0z; i < len(m.cases); i += 1) { free(m.cases[i].name); type_finish(m.cases[i]._type); const exprs = m.cases[i].exprs; for (let i = 0z; i < len(exprs); i += 1) { - expr_free(exprs[i]); + expr_finish(exprs[i]); }; free(exprs); }; free(m.cases); for (let i = 0z; i < len(m.default); i += 1) { - expr_free(m.default[i]); + expr_finish(m.default[i]); }; free(m.default); case let o: offset_expr => - expr_free(o: *expr); + expr_finish(o: *expr); case let p: propagate_expr => - expr_free(p.expr); + expr_finish(p.expr); case let r: return_expr => - expr_free(r: *expr); + expr_finish(r: *expr); case let s: size_expr => type_finish(s: *_type); case let s: slice_expr => - expr_free(s.object); - expr_free(s.start); - expr_free(s.end); + expr_finish(s.object); + expr_finish(s.start); + expr_finish(s.end); case let s: switch_expr => - expr_free(s.value); + expr_finish(s.value); for (let i = 0z; i < len(s.cases); i += 1) { let opts = s.cases[i].options; for (let j = 0z; j < len(opts); j += 1) { - expr_free(opts[j]); + expr_finish(opts[j]); }; free(opts); let exprs = s.cases[i].exprs; for (let j = 0z; j < len(exprs); j += 1) { - expr_free(exprs[j]); + expr_finish(exprs[j]); }; free(exprs); }; free(s.cases); case let u: unarithm_expr => - expr_free(u.operand); + expr_finish(u.operand); case let v: variadic_expr => match (v) { case vastart_expr => void; case let v: vaarg_expr => - expr_free(v); + expr_finish(v); case let v: vaend_expr => - expr_free(v); + expr_finish(v); }; case let y: yield_expr => free(y.label); - expr_free(y.value); + expr_finish(y.value); }; }; @@ -608,7 +608,7 @@ fn struct_constant_free(s: struct_constant) void = { case let v: struct_value => free(v.name); type_finish(v._type); - expr_free(v.init); + expr_finish(v.init); case let c: *struct_constant => struct_constant_free(*c); free(c); diff --git a/hare/ast/type.ha b/hare/ast/type.ha @@ -147,7 +147,7 @@ fn struct_type_finish(t: (struct_type | union_type)) void = { match (membs[i]._offset) { case null => void; case let e: *expr => - expr_free(e); + expr_finish(e); }; match (membs[i].member) { case let f: struct_field => @@ -183,7 +183,7 @@ export fn type_finish(t: (_type | nullable *_type)) void = { match (e.values[i].value) { case null => void; case let v: *expr => - expr_free(v); + expr_finish(v); }; }; free(e.values); @@ -197,8 +197,7 @@ export fn type_finish(t: (_type | nullable *_type)) void = { case let l: list_type => match (l.length) { case let e: *expr => - expr_free(*e); - free(e); + expr_finish(e); case => void; }; type_finish(l.members); diff --git a/hare/parse/+test/loc.ha b/hare/parse/+test/loc.ha @@ -20,7 +20,7 @@ fn expr_testloc(srcs: str...) void = for (let i = 0z; i < len(srcs); i += 1) { case let err: error => fmt::fatal("{}: {}", srcs[i], strerror(err)); }; - defer ast::expr_free(exp); + defer ast::expr_finish(exp); let runes = 0z; let d = utf8::decode(srcs[i]); for (true) match (utf8::next(&d)!) { @@ -85,7 +85,7 @@ fn expr_testloc(srcs: str...) void = for (let i = 0z; i < len(srcs); i += 1) { fmt::errorln(strerror(err))!; abort(); }; - defer ast::expr_free(exp); + defer ast::expr_finish(exp); assert(exp.start.line == 1 && exp.start.col == 1); assert(exp.end.line == 1 && exp.end.col == 13); let c = exp.expr as ast::cast_expr; diff --git a/hare/unit/process.ha b/hare/unit/process.ha @@ -185,7 +185,7 @@ fn process_access(ctx: *context, aexpr: *ast::expr) (*expr | error) = { ... }); const aexpr = parse_expr("hello"); - defer ast::expr_free(aexpr); + defer ast::expr_finish(aexpr); const expr = process_access(&ctx, aexpr)!; const access = expr.expr as access; const ao = access as access_object; @@ -253,14 +253,14 @@ fn process_compound(ctx: *context, aexpr: *ast::expr) (*expr | error) = { const ctx = mktestctx(); defer freetestctx(&ctx); const aexpr = parse_expr("{ void; void; void; }"); - defer ast::expr_free(aexpr); + defer ast::expr_finish(aexpr); const expr = process_compound(&ctx, aexpr)!; assert(expr.result.repr as types::builtin == types::builtin::VOID); const compound = expr.expr as compound; assert(len(compound) == 3); const aexpr = parse_expr("{ return; }"); - defer ast::expr_free(aexpr); + defer ast::expr_finish(aexpr); const expr = process_compound(&ctx, aexpr)!; assert(expr.terminates); @@ -346,28 +346,28 @@ fn process_constant(ctx: *context, aexpr: *ast::expr) (*expr | error) = { const ctx = mktestctx(); defer freetestctx(&ctx); const aexpr = parse_expr("void"); - defer ast::expr_free(aexpr); + defer ast::expr_finish(aexpr); const expr = process_constant(&ctx, aexpr)!; assert(expr.result.repr as types::builtin == types::builtin::VOID); const constexpr = expr.expr as constant; assert(constexpr is void); const aexpr = parse_expr("true"); - defer ast::expr_free(aexpr); + defer ast::expr_finish(aexpr); const expr = process_constant(&ctx, aexpr)!; assert(expr.result.repr as types::builtin == types::builtin::BOOL); const constexpr = expr.expr as constant; assert(constexpr as bool == true); const aexpr = parse_expr("false"); - defer ast::expr_free(aexpr); + defer ast::expr_finish(aexpr); const expr = process_constant(&ctx, aexpr)!; assert(expr.result.repr as types::builtin == types::builtin::BOOL); const constexpr = expr.expr as constant; assert(constexpr as bool == false); const aexpr = parse_expr("null"); - defer ast::expr_free(aexpr); + defer ast::expr_finish(aexpr); const expr = process_constant(&ctx, aexpr)!; assert(expr.result.repr as types::builtin == types::builtin::NULL); assert(expr.expr is constant); @@ -382,7 +382,7 @@ fn process_constant(ctx: *context, aexpr: *ast::expr) (*expr | error) = { for (let i = 0z; i < len(cases); i += 1) { const _case = cases[i]; const aexpr = parse_expr(_case.0); - defer ast::expr_free(aexpr); + defer ast::expr_finish(aexpr); const expr = process_constant(&ctx, aexpr)!; assert(expr.result.repr as types::builtin == _case.1); const constexpr = expr.expr as constant; @@ -425,7 +425,7 @@ fn process_return(ctx: *context, aexpr: *ast::expr) (*expr | error) = { const ctx = mktestctx(); defer freetestctx(&ctx); const aexpr = parse_expr("return;"); - defer ast::expr_free(aexpr); + defer ast::expr_finish(aexpr); const ret_expr = process_return(&ctx, aexpr)!; assert(ret_expr.terminates); assert(ret_expr.result.repr as types::builtin == types::builtin::VOID); @@ -433,7 +433,7 @@ fn process_return(ctx: *context, aexpr: *ast::expr) (*expr | error) = { assert(rval == null); const aexpr = parse_expr("return 10;"); - defer ast::expr_free(aexpr); + defer ast::expr_finish(aexpr); const ret_expr = process_return(&ctx, aexpr)!; assert(ret_expr.terminates); assert(ret_expr.result.repr as types::builtin == types::builtin::VOID);