hare

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

commit 8d5cf5206a6a57d9d2e35e1c34e5961917a4b06a
parent 6abc01bdb6a5ca848f6555f17f47b3c5c39f40de
Author: Drew DeVault <sir@cmpwn.com>
Date:   Sat, 14 Aug 2021 14:48:22 +0200

all: roll back some gen vN workarounds

Signed-off-by: Drew DeVault <sir@cmpwn.com>

Diffstat:
Mcmd/hare/plan.ha | 7+------
Mcmd/hare/schedule.ha | 7+++----
Mcmd/haredoc/sort.ha | 2+-
Mhare/module/scan.ha | 5++---
Mhare/types/store.ha | 15+++++++--------
Mnet/dial/resolve.ha | 6+++---
Mnet/dns/decode.ha | 2+-
Mos/+linux/dirfdfs.ha | 7+++----
8 files changed, 21 insertions(+), 30 deletions(-)

diff --git a/cmd/hare/plan.ha b/cmd/hare/plan.ha @@ -194,9 +194,4 @@ fn mkfile(plan: *plan, ext: str) str = { return path::join(plan.workdir, name); }; -fn mkdepends(t: *task...) []*task = { - // XXX: This should just be one alloc call - let deps: []*task = alloc([], len(t)); - append(deps, t...); - return deps; -}; +fn mkdepends(t: *task...) []*task = alloc(t); diff --git a/cmd/hare/schedule.ha b/cmd/hare/schedule.ha @@ -23,9 +23,8 @@ fn ident_hash(ident: ast::ident) u32 = { fn sched_module(plan: *plan, ident: ast::ident, link: *[]*task) *task = { let hash = ident_hash(ident); - // TODO: We should not have to dereference the bucket for len or append let bucket = &plan.modmap[hash % len(plan.modmap)]; - for (let i = 0z; i < len(*bucket); i += 1) { + for (let i = 0z; i < len(bucket); i += 1) { if (bucket[i].hash == hash) { return bucket[i].task; }; @@ -49,13 +48,13 @@ fn sched_module(plan: *plan, ident: ast::ident, link: *[]*task) *task = { }; let obj = sched_hare_object(plan, ver, ident, depends...); - append(*bucket, modcache { + append(bucket, modcache { hash = hash, task = obj, ident = ident, version = ver, }); - append(*link, obj); + append(link, obj); return obj; }; diff --git a/cmd/haredoc/sort.ha b/cmd/haredoc/sort.ha @@ -31,7 +31,7 @@ fn sort_decls(decls: []ast::decl) summary = { if (t[j]._type.flags & ast::type_flags::ERROR == ast::type_flags::ERROR) { bucket = &sorted.errors; }; - append(*bucket, ast::decl { + append(bucket, ast::decl { exported = true, loc = decl.loc, decl = { diff --git a/hare/module/scan.ha b/hare/module/scan.ha @@ -332,7 +332,7 @@ fn scan_file( o: ast::import_objects => o.ident, }; if (!have_ident(deps, ident)) { - append(*deps, ident); + append(deps, ident); }; }; @@ -347,8 +347,7 @@ fn scan_file( }; fn have_ident(sl: *[]ast::ident, id: ast::ident) bool = { - // XXX: We shouldn't have to deref sl here - for (let i = 0z; i < len(*sl); i += 1) { + for (let i = 0z; i < len(sl); i += 1) { if (ast::ident_eq(sl[i], id)) { return true; }; diff --git a/hare/types/store.ha b/hare/types/store.ha @@ -70,16 +70,15 @@ export fn lookup( const ty = fromast(store, ty)?; const id = hash(&ty); let bucket = &store.map[id % BUCKETS]; - // XXX: Should not have to dereference bucket - for (let i = 0z; i < len(*bucket); i += 1) { + for (let i = 0z; i < len(bucket); i += 1) { if (bucket[i].id == id) { type_finish(&ty); return &bucket[i]; }; }; ty.id = id; - append(*bucket, ty); - return &bucket[len(*bucket) - 1]; + append(bucket, ty); + return &bucket[len(bucket) - 1]; }; fn fromast(store: *typestore, atype: *ast::_type) (_type | deferred | error) = { @@ -346,7 +345,7 @@ fn _struct_from_ast( fields: *[]struct_field, offs: *size, ) (void | deferred | error) = { - const nfields = len(*fields); + const nfields = len(fields); for (let i = 0z; i < len(membs); i += 1) { *offs = match (membs[i]._offset) { ex: *ast::expr => match (store.resolve) { @@ -377,7 +376,7 @@ fn _struct_from_ast( *offs += _type.align - (*offs % _type.align); }; - append(*fields, struct_field { + append(fields, struct_field { name = memb.name, offs = *offs, _type = _type, @@ -390,7 +389,7 @@ fn _struct_from_ast( if (is_union) { let max = 0z; - for (let i = nfields; i < len(*fields); i += 1) { + for (let i = nfields; i < len(fields); i += 1) { if (fields[i].offs + fields[i]._type.sz > max) { max = fields[i].offs + fields[i]._type.sz; }; @@ -421,7 +420,7 @@ fn tagged_collect( ) (void | deferred | error) = { for (let i = 0z; i < len(atype); i += 1) match (atype[i]._type) { ta: ast::tagged_type => tagged_collect(store, ta, types)?, - * => append(*types, lookup(store, atype[i])?), + * => append(types, lookup(store, atype[i])?), }; }; diff --git a/net/dial/resolve.ha b/net/dial/resolve.ha @@ -131,12 +131,12 @@ fn resolve_addr(addr: str) ([]ip::addr | error) = { }; fn collect_answers(addrs: *[]ip::addr, answers: *[]dns::rrecord) void = { - for (let i = 0z; i < len(*answers); i += 1) { + for (let i = 0z; i < len(answers); i += 1) { match (answers[i].rdata) { // XXX: harec bug prevents us from casting directly to // ip::addr - addr: dns::aaaa => append(*addrs, addr: ip::addr6: ip::addr), - addr: dns::a => append(*addrs, addr: ip::addr4: ip::addr), + addr: dns::aaaa => append(addrs, addr: ip::addr6: ip::addr), + addr: dns::a => append(addrs, addr: ip::addr4: ip::addr), * => void, }; }; diff --git a/net/dns/decode.ha b/net/dns/decode.ha @@ -31,7 +31,7 @@ fn decode_rrecords( out: *[]rrecord, ) (void | format) = { for (let i = 0z; i < count; i += 1) { - append(*out, decode_rrecord(dec)?); + append(out, decode_rrecord(dec)?); }; }; diff --git a/os/+linux/dirfdfs.ha b/os/+linux/dirfdfs.ha @@ -311,12 +311,11 @@ fn resolve_part(parts: *[]str, part: str) void = { // no-op void; } else if (part == "..") { - // XXX: We should not have to dereference this - if (len(*parts) != 0) { - delete(parts[len(*parts) - 1]); + if (len(parts) != 0) { + delete(parts[len(parts) - 1]); }; } else { - append(*parts, part); + append(parts, part); }; };