hare

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

commit cae30bc92ee301851539ee6190b9c1bb530122c5
parent 4c558be6ac492d4062088a9d2e0c59203a226b26
Author: Drew DeVault <sir@cmpwn.com>
Date:   Sun, 22 Aug 2021 12:23:26 +0200

all: s/_type._type/_type.repr/g

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

Diffstat:
Mcmd/harec/gen.ha | 4++--
Mcmd/haredoc/hare.ha | 4++--
Mcmd/haredoc/html.ha | 14+++++++-------
Mhare/ast/type.ha | 4++--
Mhare/parse/decl.ha | 2+-
Mhare/parse/expr.ha | 4++--
Mhare/parse/parse.ha | 4++--
Mhare/parse/type.ha | 18+++++++++---------
Mhare/types/hash.ha | 4++--
Mhare/types/lookup.ha | 4++--
Mhare/types/store.ha | 12++++++------
Mhare/types/types.ha | 4++--
Mhare/unit/process.ha | 2+-
Mhare/unparse/decl.ha | 6+++---
Mhare/unparse/type.ha | 6+++---
15 files changed, 46 insertions(+), 46 deletions(-)

diff --git a/cmd/harec/gen.ha b/cmd/harec/gen.ha @@ -34,7 +34,7 @@ fn gen_func(ctx: *context, decl: *unit::decl) void = { if (fndecl.body == null) { return; // Prototype }; - const fntype = fndecl.prototype._type as types::func; + const fntype = fndecl.prototype.repr as types::func; assert(fntype.flags == 0); ctx.serial = 0; @@ -43,7 +43,7 @@ fn gen_func(ctx: *context, decl: *unit::decl) void = { fmt::printf("{}function section \".text.{}\" \"ax\"", if (decl.exported) "export " else "", ident)!; const rtype = fntype.result; - const has_rval = match (types::dealias(rtype)._type) { + const has_rval = match (types::dealias(rtype).repr) { bi: types::builtin => bi != types::builtin::VOID, * => true, }; diff --git a/cmd/haredoc/hare.ha b/cmd/haredoc/hare.ha @@ -74,7 +74,7 @@ fn unparse_hare(out: *io::stream, d: ast::decl) (size | io::error) = { ast::fndecl_attrs::INIT => "@init ", ast::fndecl_attrs::TEST => "@test ", })?; - let p = f.prototype._type as ast::func_type; + let p = f.prototype.repr as ast::func_type; if (p.attrs & ast::func_attrs::NORETURN != 0) { n += fmt::fprint(out, "@noreturn ")?; }; @@ -85,7 +85,7 @@ fn unparse_hare(out: *io::stream, d: ast::decl) (size | io::error) = { n += fmt::fprint(out, "fn ")?; n += unparse::ident(out, f.ident)?; n += prototype_hare(out, 0, - f.prototype._type as ast::func_type)?; + f.prototype.repr as ast::func_type)?; }, }; n += fmt::fprint(out, ";")?; diff --git a/cmd/haredoc/html.ha b/cmd/haredoc/html.ha @@ -170,7 +170,7 @@ fn tocentry(decl: ast::decl) (void | error) = { }, t: []ast::decl_type => void, f: ast::decl_func => prototype_html(os::stdout, 0, - f.prototype._type as ast::func_type, + f.prototype.repr as ast::func_type, true)?, }; fmt::println(";")?; @@ -346,14 +346,14 @@ fn unparse_html(out: *io::stream, d: ast::decl) (size | io::error) = { ast::fndecl_attrs::INIT => "@init ", ast::fndecl_attrs::TEST => "@test ", })?; - let p = f.prototype._type as ast::func_type; + let p = f.prototype.repr as ast::func_type; if (p.attrs & ast::func_attrs::NORETURN != 0) { n += fmt::fprint(out, "@noreturn ")?; }; n += fmt::fprint(out, "<span class='keyword'>fn</span> ")?; n += unparse::ident(out, f.ident)?; n += prototype_html(out, 0, - f.prototype._type as ast::func_type, + f.prototype.repr as ast::func_type, false)?; }, }; @@ -439,7 +439,7 @@ fn struct_union_html( brief: bool, ) (size | io::error) = { let z = 0z; - let members = match (t._type) { + let members = match (t.repr) { t: ast::struct_type => { z += fmt::fprint(out, "<span class='keyword'>struct</span> {")?; t: []ast::struct_member; @@ -504,19 +504,19 @@ fn type_html( let z = 0z; if (_type.flags & ast::type_flags::CONST != 0 - && !(_type._type is ast::func_type)) { + && !(_type.repr is ast::func_type)) { z += fmt::fprint(out, "<span class='keyword'>const</span> ")?; }; if (_type.flags & ast::type_flags::ERROR != 0) { - if (_type._type is ast::builtin_type) { + if (_type.repr is ast::builtin_type) { z += fmt::fprint(out, "<span class='type'>!</span>")?; } else { z += fmt::fprint(out, "!")?; }; }; - match (_type._type) { + match (_type.repr) { t: ast::builtin_type => { z += fmt::fprintf(out, "<span class='type'>{}</span>", builtin_type(t))?; diff --git a/hare/ast/type.ha b/hare/ast/type.ha @@ -118,7 +118,7 @@ export type _type = struct { start: lex::location, end: lex::location, flags: type_flags, - _type: (alias_type | builtin_type | enum_type | func_type | + repr: (alias_type | builtin_type | enum_type | func_type | list_type | pointer_type | struct_type | union_type | tagged_type | tuple_type), }; @@ -156,7 +156,7 @@ export fn type_free(t: (_type | nullable *_type)) void = match (t) { free(t); }, }, - t: _type => match (t._type) { + t: _type => match (t.repr) { a: alias_type => ident_free(a.ident), builtin_type => void, e: enum_type => { diff --git a/hare/parse/decl.ha b/hare/parse/decl.ha @@ -155,7 +155,7 @@ fn decl_func(lexer: *lex::lexer) (ast::decl_func | error) = { start = proto_start, end = proto_end, flags = ast::type_flags::CONST, - _type = prototype, + repr = prototype, }, body = body, attrs = attr, diff --git a/hare/parse/expr.ha b/hare/parse/expr.ha @@ -967,7 +967,7 @@ fn match_case(lexer: *lex::lexer) (ast::match_case | error) = { start = loc, end = lex::prevloc(lexer), flags = 0, - _type = ast::builtin_type::NULL, + repr = ast::builtin_type::NULL, }); }, * => nametype(lexer)?, @@ -1001,7 +1001,7 @@ fn match_expr(lexer: *lex::lexer) (ast::expr | error) = { start = t.2, end = case._type.end, flags = 0, - _type = ast::pointer_type { + repr = ast::pointer_type { referent = case._type, flags = 0, }, diff --git a/hare/parse/parse.ha b/hare/parse/parse.ha @@ -109,7 +109,7 @@ fn nametype(lexer: *lex::lexer) ((str, ast::_type) | error) = { start = start, end = lex::prevloc(lexer), flags = 0, - _type = ast::alias_type { + repr = ast::alias_type { unwrap = false, ident = id, }, @@ -119,7 +119,7 @@ fn nametype(lexer: *lex::lexer) ((str, ast::_type) | error) = { start = start, end = lex::prevloc(lexer), flags = 0, - _type = ast::alias_type { + repr = ast::alias_type { unwrap = false, ident = alloc([name]), }, diff --git a/hare/parse/type.ha b/hare/parse/type.ha @@ -101,7 +101,7 @@ fn primitive_type(lexer: *lex::lexer) (ast::_type | error) = { start = tok.2, end = lex::prevloc(lexer), flags = 0, - _type = builtin, + repr = builtin, }; }; @@ -116,7 +116,7 @@ fn alias_type(lexer: *lex::lexer) (ast::_type | error) = { start = start, end = lex::prevloc(lexer), flags = 0, - _type = ast::alias_type { + repr = ast::alias_type { unwrap = unwrap, ident = ident, }, @@ -135,7 +135,7 @@ fn pointer_type(lexer: *lex::lexer) (ast::_type | error) = { start = start, end = lex::prevloc(lexer), flags = 0, - _type = ast::pointer_type { + repr = ast::pointer_type { referent = alloc(_type), flags = flags, }, @@ -163,7 +163,7 @@ fn tagged_type( start = start, end = lex::prevloc(lexer), flags = 0, - _type = tagged, + repr = tagged, }; }; @@ -188,7 +188,7 @@ fn tuple_type( start = start, end = lex::prevloc(lexer), flags = 0, - _type = tuple, + repr = tuple, }; }; @@ -205,7 +205,7 @@ fn fn_type(lexer: *lex::lexer) (ast::_type | error) = { start = start, end = lex::prevloc(lexer), flags = ast::type_flags::CONST, - _type = proto, + repr = proto, }; }; @@ -260,7 +260,7 @@ fn struct_union_type(lexer: *lex::lexer) (ast::_type | error) = { start = kind.2, end = lex::prevloc(lexer), flags = 0, - _type = switch (kind.0) { + repr = switch (kind.0) { ltok::STRUCT => membs: ast::struct_type, ltok::UNION => membs: ast::union_type, * => abort(), @@ -334,7 +334,7 @@ fn array_slice_type(lexer: *lex::lexer) (ast::_type | error) = { start = start.2, end = lex::prevloc(lexer), flags = 0, - _type = ast::list_type { + repr = ast::list_type { length = length, members = alloc(_type), }, @@ -383,7 +383,7 @@ fn enum_type(lexer: *lex::lexer) (ast::_type | error) = { start = start.2, end = lex::prevloc(lexer), flags = 0, - _type = ast::enum_type { + repr = ast::enum_type { storage = storage, values = membs, }, diff --git a/hare/types/hash.ha b/hare/types/hash.ha @@ -33,7 +33,7 @@ fn builtin_storage(b: builtin) u8 = switch (b) { builtin::VOID => storage::VOID, }; -fn type_storage(t: *_type) u8 = match (t._type) { +fn type_storage(t: *_type) u8 = match (t.repr) { alias => storage::ALIAS, array => storage::ARRAY, b: builtin => builtin_storage(b), @@ -76,7 +76,7 @@ export fn hash(t: *_type) u32 = { write8(id, type_storage(t)); write8(id, t.flags); - match (t._type) { + match (t.repr) { a: alias => for (let i = len(a.id); i > 0; i -= 1) { hash::write(id, strings::toutf8(a.id[i - 1])); write8(id, 0); diff --git a/hare/types/lookup.ha b/hare/types/lookup.ha @@ -2,7 +2,7 @@ use hare::ast; // Unwraps a type which may be aliased and returns the underlying type. export fn dealias(t: *_type) const *_type = { - for (true) match (t._type) { + for (true) match (t.repr) { a: alias => { assert(a.secondary != null); t = a.secondary: const *_type; @@ -19,7 +19,7 @@ export fn lookup_builtin( ) const *_type = { // TODO: &ast::type { ... } const atype = ast::_type { - _type = _type, + repr = _type, ... }; return lookup(store, &atype)!; diff --git a/hare/types/store.ha b/hare/types/store.ha @@ -83,7 +83,7 @@ export fn lookup( fn fromast(store: *typestore, atype: *ast::_type) (_type | deferred | error) = { let sz = SIZE_UNDEFINED, align = SIZE_UNDEFINED; - let underlying = match (atype._type) { + const repr = match (atype.repr) { a: ast::alias_type => { // TODO: This is incomplete assert(!a.unwrap); @@ -266,7 +266,7 @@ fn fromast(store: *typestore, atype: *ast::_type) (_type | deferred | error) = { }; return _type { flags = atype.flags: flags, - _type = underlying, + repr = repr, sz = sz, align = align, }; @@ -360,13 +360,13 @@ fn _struct_from_ast( const memb = match (membs[i].member) { se: ast::struct_embedded => { - let membs: []ast::struct_member = match (se._type) { + let membs: []ast::struct_member = match (se.repr) { st: ast::struct_type => st, ut: ast::union_type => ut, * => abort(), // Invariant }; _struct_from_ast(store, membs, - se._type is ast::union_type, + se.repr is ast::union_type, fields, offs)?; continue; }, @@ -421,7 +421,7 @@ fn tagged_collect( atype: ast::tagged_type, types: *[]const *_type, ) (void | deferred | error) = { - for (let i = 0z; i < len(atype); i += 1) match (atype[i]._type) { + for (let i = 0z; i < len(atype); i += 1) match (atype[i].repr) { ta: ast::tagged_type => tagged_collect(store, ta, types)?, * => append(types, lookup(store, atype[i])?), }; @@ -481,7 +481,7 @@ fn field_cmp(a: const *void, b: const *void) int = { }; fn type_finish(t: *_type) void = { - match (t._type) { + match (t.repr) { a: alias => ast::ident_free(a.id), array => void, builtin => void, diff --git a/hare/types/types.ha b/hare/types/types.ha @@ -113,8 +113,8 @@ export def SIZE_UNDEFINED: size = -1: size; // A Hare type. export type _type = struct { flags: flags, - _type: (alias | array | builtin | _enum | func | pointer | slice | - _struct | tagged | tuple), + repr: (alias | array | builtin | _enum | func + | pointer | slice | _struct | tagged | tuple), id: u32, sz: size, align: size, diff --git a/hare/unit/process.ha b/hare/unit/process.ha @@ -44,7 +44,7 @@ fn process_func( assert(func.attrs & ast::fndecl_attrs::TEST == 0); // TODO const afndecl = adecl.decl as ast::decl_func; const prototype = types::lookup(ctx.store, &func.prototype)!; - const fntype = prototype._type as types::func; + const fntype = prototype.repr as types::func; assert(fntype.variadism == types::variadism::NONE); // TODO assert(len(fntype.params) == 0); // TODO diff --git a/hare/unparse/decl.ha b/hare/unparse/decl.ha @@ -64,7 +64,7 @@ export fn decl(out: *io::stream, d: ast::decl) (size | io::error) = { ast::fndecl_attrs::INIT => "@init ", ast::fndecl_attrs::TEST => "@test ", })?; - let p = f.prototype._type as ast::func_type; + let p = f.prototype.repr as ast::func_type; if (p.attrs & ast::func_attrs::NORETURN != 0) { n += fmt::fprint(out, "@noreturn ")?; }; @@ -74,8 +74,8 @@ export fn decl(out: *io::stream, d: ast::decl) (size | io::error) = { }; n += fmt::fprint(out, "fn ")?; n += ident(out, f.ident)?; - n += prototype(out, 0, - f.prototype._type as ast::func_type)?; + const fntype = f.prototype.repr as ast::func_type; + n += prototype(out, 0, fntype)?; match (f.body) { void => void, e: ast::expr => { diff --git a/hare/unparse/type.ha b/hare/unparse/type.ha @@ -63,7 +63,7 @@ fn struct_union_type( t: ast::_type, ) (size | io::error) = { let z = 0z; - let membs = match (t._type) { + let membs = match (t.repr) { st: ast::struct_type => { z += fmt::fprint(out, "struct {")?; st: []ast::struct_member; @@ -111,10 +111,10 @@ export fn _type( ) (size | io::error) = { let n = 0z; if (t.flags & ast::type_flags::CONST != 0 - && !(t._type is ast::func_type)) { + && !(t.repr is ast::func_type)) { n += fmt::fprint(out, "const ")?; }; - match (t._type) { + match (t.repr) { a: ast::alias_type => { if (a.unwrap) { n += fmt::fprint(out, "...")?;