commit e52fa9692550aa5d4bb7436e60f1c4d2f9c3bb4d
parent 93da116682d09ab1b3fd5da2aee26cd177b046dc
Author: Sebastian <sebastian@sebsite.pw>
Date: Thu, 21 Apr 2022 15:41:43 -0400
hare::ast: rename type_free to type_finish
Signed-off-by: Sebastian <sebastian@sebsite.pw>
Diffstat:
6 files changed, 43 insertions(+), 43 deletions(-)
diff --git a/cmd/haretype/main.ha b/cmd/haretype/main.ha
@@ -26,7 +26,7 @@ fn typeinfo(
defer io::close(stream);
const lexer = lex::init(stream, "-");
const atype = parse::_type(&lexer)?;
- defer ast::type_free(atype);
+ defer ast::type_finish(atype);
const typ = types::lookup(store, &atype)?;
unparse::_type(os::stdout, 0, atype)?;
fmt::println()?;
diff --git a/hare/ast/decl.ha b/hare/ast/decl.ha
@@ -70,25 +70,25 @@ export fn decl_finish(d: decl) void = {
for (let i = 0z; i < len(g); i += 1) {
free(g[i].symbol);
ident_free(g[i].ident);
- type_free(g[i]._type);
+ type_finish(g[i]._type);
expr_free(g[i].init);
};
free(g);
case let t: []decl_type =>
for (let i = 0z; i < len(t); i += 1) {
ident_free(t[i].ident);
- type_free(t[i]._type);
+ type_finish(t[i]._type);
};
free(t);
case let f: decl_func =>
free(f.symbol);
ident_free(f.ident);
- type_free(f.prototype);
+ type_finish(f.prototype);
if (f.body is expr) expr_free(f.body as expr);
case let c: []decl_const =>
for (let i = 0z; i < len(c); i += 1) {
ident_free(c[i].ident);
- type_free(c[i]._type);
+ type_finish(c[i]._type);
expr_free(c[i].init);
};
free(c);
diff --git a/hare/ast/expr.ha b/hare/ast/expr.ha
@@ -473,7 +473,7 @@ case let e: expr =>
case let b: binding_expr =>
for (let i = 0z; i < len(b.bindings); i += 1) {
free(b.bindings[i].name);
- type_free(b.bindings[i]._type);
+ type_finish(b.bindings[i]._type);
expr_free(b.bindings[i].init);
};
free(b.bindings);
@@ -487,7 +487,7 @@ case let e: expr =>
free(c.args);
case let c: cast_expr =>
expr_free(c.value);
- type_free(c._type);
+ type_finish(c._type);
case let c: compound_expr =>
for (let i = 0z; i < len(c.exprs); i += 1) {
expr_free(c.exprs[i]);
@@ -545,7 +545,7 @@ case let e: expr =>
expr_free(m.value);
for (let i = 0z; i < len(m.cases); i += 1) {
free(m.cases[i].name);
- type_free(m.cases[i]._type);
+ 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]);
@@ -564,7 +564,7 @@ case let e: expr =>
case let r: return_expr =>
expr_free(r: *expr);
case let s: size_expr =>
- type_free(s: *_type);
+ type_finish(s: *_type);
case let s: slice_expr =>
expr_free(s.object);
expr_free(s.start);
@@ -607,7 +607,7 @@ fn struct_constant_free(s: struct_constant) void = {
match (s.fields[i]) {
case let v: struct_value =>
free(v.name);
- type_free(v._type);
+ type_finish(v._type);
expr_free(v.init);
case let c: *struct_constant =>
struct_constant_free(*c);
diff --git a/hare/ast/type.ha b/hare/ast/type.ha
@@ -135,7 +135,7 @@ export type _type = struct {
tagged_type | tuple_type),
};
-fn struct_type_free(t: (struct_type | union_type)) void = {
+fn struct_type_finish(t: (struct_type | union_type)) void = {
let membs = match (t) {
case let s: struct_type =>
yield s: []struct_member;
@@ -152,9 +152,9 @@ fn struct_type_free(t: (struct_type | union_type)) void = {
match (membs[i].member) {
case let f: struct_field =>
free(f.name);
- type_free(f._type);
+ type_finish(f._type);
case let e: struct_embedded =>
- type_free(e: *_type);
+ type_finish(e: *_type);
case let a: struct_alias =>
ident_free(a);
};
@@ -163,13 +163,13 @@ fn struct_type_free(t: (struct_type | union_type)) void = {
};
// Frees resources associated with a [[_type]].
-export fn type_free(t: (_type | nullable *_type)) void = {
+export fn type_finish(t: (_type | nullable *_type)) void = {
match (t) {
case let t: nullable *_type =>
match (t) {
case null => void;
case let t: *_type =>
- type_free(*t);
+ type_finish(*t);
free(t);
};
case let t: _type =>
@@ -188,10 +188,10 @@ export fn type_free(t: (_type | nullable *_type)) void = {
};
free(e.values);
case let f: func_type =>
- type_free(f.result);
+ type_finish(f.result);
for (let i = 0z; i < len(f.params); i += 1) {
free(f.params[i].name);
- type_free(f.params[i]._type);
+ type_finish(f.params[i]._type);
};
free(f.params);
case let l: list_type =>
@@ -201,19 +201,19 @@ export fn type_free(t: (_type | nullable *_type)) void = {
free(e);
case => void;
};
- type_free(l.members);
+ type_finish(l.members);
case let p: pointer_type =>
- type_free(p.referent);
+ type_finish(p.referent);
case let s: (struct_type | union_type) =>
- struct_type_free(s);
+ struct_type_finish(s);
case let t: tagged_type =>
for (let i = 0z; i < len(t); i += 1) {
- type_free(t[i]);
+ type_finish(t[i]);
};
free(t);
case let t: tuple_type =>
for (let i = 0z; i < len(t); i += 1) {
- type_free(t[i]);
+ type_finish(t[i]);
};
free(t);
};
diff --git a/hare/parse/+test/loc.ha b/hare/parse/+test/loc.ha
@@ -108,7 +108,7 @@ fn type_testloc(srcs: str...) void = for (let i = 0z; i < len(srcs); i += 1) {
fmt::errorln(strerror(err))!;
abort();
};
- defer ast::type_free(typ);
+ defer ast::type_finish(typ);
let runes = 0z;
let d = utf8::decode(srcs[i]);
for (true) match (utf8::next(&d)!) {
diff --git a/hare/types/+test.ha b/hare/types/+test.ha
@@ -24,7 +24,7 @@ fn parse_type(in: str) ast::_type = {
defer store_free(st);
let atype = parse_type("int");
- defer ast::type_free(atype);
+ defer ast::type_finish(atype);
let htype = lookup(st, &atype)!;
assert(htype.repr as builtin == builtin::INT);
assert(htype.sz == x86_64._int && htype.align == x86_64._int);
@@ -33,7 +33,7 @@ fn parse_type(in: str) ast::_type = {
assert(htype == type2, "types should be singletons");
let atype = parse_type("*int");
- defer ast::type_free(atype);
+ defer ast::type_finish(atype);
let htype = lookup(st, &atype)!;
assert(htype.sz == x86_64._pointer && htype.align == x86_64._pointer);
let htype = htype.repr as pointer;
@@ -58,7 +58,7 @@ fn resolve(
// Basic struct
let atype = parse_type("struct { x: int, y: int }");
- defer ast::type_free(atype);
+ defer ast::type_finish(atype);
let htype = lookup(st, &atype)!;
assert(htype.sz == 8);
assert(htype.align == 4);
@@ -78,7 +78,7 @@ fn resolve(
// Basic union
let atype = parse_type("union { x: int, y: int }");
- defer ast::type_free(atype);
+ defer ast::type_finish(atype);
let htype = lookup(st, &atype)!;
assert(htype.sz == 4);
assert(htype.align == 4);
@@ -98,7 +98,7 @@ fn resolve(
// Padding
let atype = parse_type("struct { w: u8, x: u32, y: u8, z: u64 }");
- defer ast::type_free(atype);
+ defer ast::type_finish(atype);
let htype = lookup(st, &atype)!;
assert(htype.sz == 24);
assert(htype.align == 8);
@@ -115,13 +115,13 @@ fn resolve(
assert(z.offs == 16);
let atype = parse_type("struct { x: u8, y: size, z: u8 }");
- defer ast::type_free(atype);
+ defer ast::type_finish(atype);
let htype = lookup(st, &atype)!;
assert(htype.sz == 24);
// Sort order
let atype = parse_type("struct { z: u8, y: u8, x: u8, q: u8 }");
- defer ast::type_free(atype);
+ defer ast::type_finish(atype);
let htype = lookup(st, &atype)!;
let stype = htype.repr as _struct;
assert(stype.fields[0].name == "q");
@@ -139,7 +139,7 @@ fn resolve(
},
p: int,
}");
- defer ast::type_free(atype);
+ defer ast::type_finish(atype);
let htype = lookup(st, &atype)!;
assert(htype.sz == 20);
assert(htype.align == 4);
@@ -165,7 +165,7 @@ fn resolve(
},
p: int,
}");
- defer ast::type_free(atype);
+ defer ast::type_finish(atype);
let htype = lookup(st, &atype)!;
assert(htype.sz == 16);
assert(htype.align == 4);
@@ -193,7 +193,7 @@ fn resolve(
@offset(16) y: int,
@offset(32) z: int,
}");
- defer ast::type_free(atype);
+ defer ast::type_finish(atype);
let htype = lookup(st, &atype)!;
assert(htype.sz == 36);
assert(htype.align == 4);
@@ -212,7 +212,7 @@ fn resolve(
// Basic case
let atype = parse_type("(int, int)");
- defer ast::type_free(atype);
+ defer ast::type_finish(atype);
let htype = lookup(st, &atype)!;
assert(htype.sz == 8);
assert(htype.align == 4);
@@ -226,7 +226,7 @@ fn resolve(
// Padding
let atype = parse_type("(i8, i32, i8, i64)");
- defer ast::type_free(atype);
+ defer ast::type_finish(atype);
let htype = lookup(st, &atype)!;
assert(htype.sz == 24);
assert(htype.align == 8);
@@ -244,7 +244,7 @@ fn resolve(
// Slice
let atype = parse_type("[]int");
- defer ast::type_free(atype);
+ defer ast::type_finish(atype);
let htype = lookup(st, &atype)!;
assert(htype.sz == 24);
assert(htype.align == 8);
@@ -253,7 +253,7 @@ fn resolve(
// Normal array
let atype = parse_type("[5]i32");
- defer ast::type_free(atype);
+ defer ast::type_finish(atype);
let htype = lookup(st, &atype)!;
assert(htype.sz == 4 * 5);
assert(htype.align == 4);
@@ -263,7 +263,7 @@ fn resolve(
// Unbounded array
let atype = parse_type("[*]i32");
- defer ast::type_free(atype);
+ defer ast::type_finish(atype);
let htype = lookup(st, &atype)!;
assert(htype.sz == SIZE_UNDEFINED);
assert(htype.align == 4);
@@ -273,7 +273,7 @@ fn resolve(
// Contextual array (equivalent to unbounded at this compilation stage)
let atype = parse_type("[_]i32");
- defer ast::type_free(atype);
+ defer ast::type_finish(atype);
let htype = lookup(st, &atype)!;
assert(htype.sz == SIZE_UNDEFINED);
assert(htype.align == 4);
@@ -287,7 +287,7 @@ fn resolve(
defer store_free(st);
let atype = parse_type("@noreturn fn() void");
- defer ast::type_free(atype);
+ defer ast::type_finish(atype);
let htype = lookup(st, &atype)!;
assert(htype.sz == SIZE_UNDEFINED);
assert(htype.align == SIZE_UNDEFINED);
@@ -298,7 +298,7 @@ fn resolve(
assert(len(f.params) == 0);
let atype = parse_type("fn(foo: int, bar: str...) int");
- defer ast::type_free(atype);
+ defer ast::type_finish(atype);
let htype = lookup(st, &atype)!;
assert(htype.sz == SIZE_UNDEFINED);
assert(htype.align == SIZE_UNDEFINED);
@@ -316,7 +316,7 @@ fn resolve(
defer store_free(st);
let atype = parse_type("(int | int | void)");
- defer ast::type_free(atype);
+ defer ast::type_finish(atype);
let htype = lookup(st, &atype)!;
assert(htype.sz == st.arch._int * 2);
assert(htype.align == st.arch._int);
@@ -326,7 +326,7 @@ fn resolve(
assert(t[1].repr as builtin == builtin::VOID);
let atype = parse_type("(int | (int | str | void))");
- defer ast::type_free(atype);
+ defer ast::type_finish(atype);
let htype = lookup(st, &atype)!;
assert(htype.sz == 32);
assert(htype.align == 8);