hare

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

commit 8330f2c75131f41bc1f0eb1a1371ddf03addb180
parent cf8af2de534e9ef5403de6598c4840b3534b0695
Author: Autumn! <autumnull@posteo.net>
Date:   Thu, 18 May 2023 18:08:33 +0000

all: rename 'flags' types to 'flag'

Signed-off-by: Autumn! <autumnull@posteo.net>

Diffstat:
Mcmd/haredoc/html.ha | 6+++---
Mcmd/haredoc/main.ha | 2+-
Mcmd/haredoc/sort.ha | 2+-
Mcmd/haredoc/tty.ha | 6+++---
Mcrypto/aes/+x86_64/ni.ha | 2+-
Mfmt/fmt.ha | 20++++++++++----------
Mfnmatch/+test.ha | 78+++++++++++++++++++++++++++++++++++++++---------------------------------------
Mfnmatch/fnmatch.ha | 26+++++++++++++-------------
Mfs/fs.ha | 8++++----
Mfs/types.ha | 10+++++-----
Mglob/+test.ha | 40++++++++++++++++++++--------------------
Mglob/glob.ha | 22+++++++++++-----------
Mhare/ast/type.ha | 8++++----
Mhare/lex/+test.ha | 2+-
Mhare/lex/lex.ha | 14+++++++-------
Mhare/module/manifest.ha | 2+-
Mhare/parse/+test/roundtrip.ha | 2+-
Mhare/parse/decl.ha | 2+-
Mhare/parse/type.ha | 26+++++++++++++-------------
Mhare/types/+test.ha | 2+-
Mhare/types/store.ha | 6+++---
Mhare/types/types.ha | 16++++++++--------
Mhare/unparse/decl.ha | 2+-
Mhare/unparse/type.ha | 16++++++++--------
Mio/+freebsd/mmap.ha | 4++--
Mio/+linux/mmap.ha | 4++--
Mnet/+freebsd.ha | 4++--
Mnet/+linux.ha | 4++--
Mnet/tcp/+freebsd.ha | 4++--
Mnet/tcp/+linux.ha | 4++--
Mnet/tcp/listener.ha | 2+-
Mnet/tcp/options.ha | 4++--
Mnet/udp/+freebsd.ha | 4++--
Mnet/udp/+linux.ha | 4++--
Mnet/udp/options.ha | 4++--
Mnet/unix/+freebsd.ha | 4++--
Mnet/unix/+linux.ha | 4++--
Mnet/unix/listener.ha | 2+-
Mnet/unix/options.ha | 4++--
Mnet/unix/socketpair.ha | 2+-
Mos/+freebsd/dirfdfs.ha | 62+++++++++++++++++++++++++++++++-------------------------------
Mos/+linux/dirfdfs.ha | 40++++++++++++++++++++--------------------
Mos/os.ha | 10+++++-----
Mrt/+x86_64/cpuid.ha | 8++++----
Mtemp/+freebsd.ha | 6+++---
Mtemp/+linux.ha | 12++++++------
Mtest/+test.ha | 2+-
Munix/+freebsd/pipe.ha | 8++++----
Munix/+linux/pipe.ha | 8++++----
Munix/signal/+freebsd.ha | 8++++----
Munix/signal/+linux.ha | 8++++----
Munix/tty/+freebsd/open.ha | 2+-
Munix/tty/+freebsd/pty.ha | 2+-
Munix/tty/+linux/open.ha | 2+-
Munix/tty/+linux/pty.ha | 2+-
55 files changed, 279 insertions(+), 279 deletions(-)

diff --git a/cmd/haredoc/html.ha b/cmd/haredoc/html.ha @@ -642,12 +642,12 @@ fn type_html( // other types and highlight more keywords, like const let z = 0z; - if (_type.flags & ast::type_flags::CONST != 0 + if (_type.flags & ast::type_flag::CONST != 0 && !(_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.flags & ast::type_flag::ERROR != 0) { if (_type.repr is ast::builtin_type) { z += fmt::fprint(out, "<span class='type'>!</span>")?; } else { @@ -713,7 +713,7 @@ fn type_html( z += linelen; z += fmt::fprint(out, ")")?; case let t: ast::pointer_type => - if (t.flags & ast::pointer_flags::NULLABLE != 0) { + if (t.flags & ast::pointer_flag::NULLABLE != 0) { z += fmt::fprint(out, "<span class='type'>nullable</span> ")?; }; z += fmt::fprint(out, "*")?; diff --git a/cmd/haredoc/main.ha b/cmd/haredoc/main.ha @@ -348,7 +348,7 @@ fn scan(path: str) (ast::subunit | error) = { fmt::fatalf("Error reading {}: {}", path, fs::strerror(err)); }; defer io::close(input)!; - const lexer = lex::init(input, path, lex::flags::COMMENTS); + const lexer = lex::init(input, path, lex::flag::COMMENTS); return parse::subunit(&lexer)?; }; diff --git a/cmd/haredoc/sort.ha b/cmd/haredoc/sort.ha @@ -32,7 +32,7 @@ fn sort_decls(decls: []ast::decl) summary = { case let t: []ast::decl_type => for (let j = 0z; j < len(t); j += 1) { let bucket = &sorted.types; - if (t[j]._type.flags & ast::type_flags::ERROR == ast::type_flags::ERROR) { + if (t[j]._type.flags & ast::type_flag::ERROR == ast::type_flag::ERROR) { bucket = &sorted.errors; }; append(bucket, ast::decl { diff --git a/cmd/haredoc/tty.ha b/cmd/haredoc/tty.ha @@ -436,12 +436,12 @@ fn type_tty( t: ast::_type, ) (size | io::error) = { let n = 0z; - if (t.flags & ast::type_flags::CONST != 0 + if (t.flags & ast::type_flag::CONST != 0 && !(t.repr is ast::func_type)) { n += render(out, syn::TYPE)?; n += fmt::fprint(out, "const ")?; }; - if (t.flags & ast::type_flags::ERROR != 0) { + if (t.flags & ast::type_flag::ERROR != 0) { n += render(out, syn::OPERATOR)?; n += fmt::fprint(out, "!")?; }; @@ -530,7 +530,7 @@ fn type_tty( n += fmt::fprint(out, "]")?; n += type_tty(out, indent, *l.members)?; case let p: ast::pointer_type => - if (p.flags & ast::pointer_flags::NULLABLE != 0) { + if (p.flags & ast::pointer_flag::NULLABLE != 0) { n += render(out, syn::TYPE)?; n += fmt::fprint(out, "nullable ")?; }; diff --git a/crypto/aes/+x86_64/ni.ha b/crypto/aes/+x86_64/ni.ha @@ -18,7 +18,7 @@ const x86ni_vtable: cipher::blockvtable = cipher::blockvtable { // Checks if the native AES interface is available. fn x86ni_available() bool = { - return rt::cpuid_hasflags(0, rt::cpuid_ecxflags::AES); + return rt::cpuid_hasflags(0, rt::cpuid_ecxflag::AES); }; // Returns a native AES [[crypto::cipher::block]] implementation for x86_64 diff --git a/fmt/fmt.ha b/fmt/fmt.ha @@ -166,7 +166,7 @@ export type modifiers = struct { base: strconv::base, }; -type modflags = enum uint { +type modflag = enum uint { NONE = 0, ZERO = 1 << 0, MINUS = 1 << 1, @@ -425,7 +425,7 @@ fn scan_uint(iter: *strings::iterator) uint = { }; fn scan_modifier_flags(iter: *strings::iterator, mod: *modifiers) void = { - let flags = modflags::NONE; + let flags = modflag::NONE; for (true) { let r = match (strings::next(iter)) { @@ -437,29 +437,29 @@ fn scan_modifier_flags(iter: *strings::iterator, mod: *modifiers) void = { switch (r) { case '0' => - flags |= modflags::ZERO; + flags |= modflag::ZERO; case '-' => - flags |= modflags::MINUS; + flags |= modflag::MINUS; case ' ' => - flags |= modflags::SPACE; + flags |= modflag::SPACE; case '+' => - flags |= modflags::PLUS; + flags |= modflag::PLUS; case => strings::prev(iter); break; }; }; - mod.padding = if (flags & modflags::MINUS != 0) + mod.padding = if (flags & modflag::MINUS != 0) padding::ALIGN_LEFT - else if (flags & modflags::ZERO != 0) + else if (flags & modflag::ZERO != 0) padding::ZEROES else padding::ALIGN_RIGHT; - mod.negation = if (flags & modflags::PLUS != 0) + mod.negation = if (flags & modflag::PLUS != 0) negation::PLUS - else if (flags & modflags::SPACE != 0) + else if (flags & modflag::SPACE != 0) negation::SPACE else negation::NONE; diff --git a/fnmatch/+test.ha b/fnmatch/+test.ha @@ -1,7 +1,7 @@ // License: MPL-2.0 // (c) 2021 Bor Grošelj Simić <bor.groseljsimic@telemach.net> -type testcase = (str, str, bool, []flags); +type testcase = (str, str, bool, []flag); const testcases: [_]testcase = [ // homegrown tests @@ -108,15 +108,15 @@ const testcases: [_]testcase = [ ("[![:alpha:]]a", "[a", true, []), ("[![:alnum:][:digit:]]", "a", false, []), - (".", ".", true, [flags::PERIOD]), - ("*", ".", false, [flags::PERIOD]), - ("?", ".", false, [flags::PERIOD]), - ("[.]", ".", false, [flags::PERIOD]), - (".*", ".asdf", true, [flags::PERIOD]), - (".*", "asdf", false, [flags::PERIOD]), + (".", ".", true, [flag::PERIOD]), + ("*", ".", false, [flag::PERIOD]), + ("?", ".", false, [flag::PERIOD]), + ("[.]", ".", false, [flag::PERIOD]), + (".*", ".asdf", true, [flag::PERIOD]), + (".*", "asdf", false, [flag::PERIOD]), - ("\\", "\\", true, [flags::NOESCAPE]), - ("\\*", "\\asdf", true, [flags::NOESCAPE]), + ("\\", "\\", true, [flag::NOESCAPE]), + ("\\*", "\\asdf", true, [flag::NOESCAPE]), // adapted from musl tests ("*.c", "foo.c", true, []), @@ -152,36 +152,36 @@ const testcases: [_]testcase = [ ("[![:d-d]", "b", false, []), ("[[:d-d]", "[", false, []), ("[![:d-d]", "[", false, []), - ("[a-z]/[a-z]", "a/b", true, [flags::PATHNAME]), - ("a[/]b", "a/b", false, [flags::PATHNAME]), - ("*", "a/b", false, [flags::PATHNAME]), - ("*[/]b", "a/b", false, [flags::PATHNAME]), - ("*[b]", "a/b", false, [flags::PATHNAME]), - ("a[a/z]*.c", "a/x.c", false, [flags::PATHNAME]), - ("a/*.c", "a/x.c", true, [flags::PATHNAME]), - ("a*.c", "a/x.c", false, [flags::PATHNAME]), - ("*/foo", "/foo", true, [flags::PATHNAME]), - ("*.c", ".foo.c", false, [flags::PERIOD]), - ("*.c", "foo.c", true, [flags::PERIOD]), - ("a\\*.c", "a*.c", false, [flags::NOESCAPE]), - ("???b", "aa/b", false, [flags::PATHNAME]), - ("?a/b", ".a/b", false, [flags::PATHNAME, flags::PERIOD]), - ("a/?b", "a/.b", false, [flags::PATHNAME, flags::PERIOD]), - ("*a/b", ".a/b", false, [flags::PATHNAME, flags::PERIOD]), - ("a/*b", "a/.b", false, [flags::PATHNAME, flags::PERIOD]), - ("[.]a/b", ".a/b", false, [flags::PATHNAME, flags::PERIOD]), - ("a/[.]b", "a/.b", false, [flags::PATHNAME, flags::PERIOD]), - ("*/?", "a/b", true, [flags::PATHNAME, flags::PERIOD]), - ("?/*", "a/b", true, [flags::PATHNAME, flags::PERIOD]), - (".*/?", ".a/b", true, [flags::PATHNAME, flags::PERIOD]), - ("*/.?", "a/.b", true, [flags::PATHNAME, flags::PERIOD]), - ("*/*", "a/.b", false, [flags::PATHNAME, flags::PERIOD]), - ("*?*/*", "a/.b", true, [flags::PERIOD]), - ("*[.]/b", "a./b", true, [flags::PATHNAME, flags::PERIOD]), - ("*[[:alpha:]]/*[[:alnum:]]", "a/b", true, [flags::PATHNAME]), - ("a?b", "a.b", true, [flags::PATHNAME, flags::PERIOD]), - ("a*b", "a.b", true, [flags::PATHNAME, flags::PERIOD]), - ("a[.]b", "a.b", true, [flags::PATHNAME, flags::PERIOD]), + ("[a-z]/[a-z]", "a/b", true, [flag::PATHNAME]), + ("a[/]b", "a/b", false, [flag::PATHNAME]), + ("*", "a/b", false, [flag::PATHNAME]), + ("*[/]b", "a/b", false, [flag::PATHNAME]), + ("*[b]", "a/b", false, [flag::PATHNAME]), + ("a[a/z]*.c", "a/x.c", false, [flag::PATHNAME]), + ("a/*.c", "a/x.c", true, [flag::PATHNAME]), + ("a*.c", "a/x.c", false, [flag::PATHNAME]), + ("*/foo", "/foo", true, [flag::PATHNAME]), + ("*.c", ".foo.c", false, [flag::PERIOD]), + ("*.c", "foo.c", true, [flag::PERIOD]), + ("a\\*.c", "a*.c", false, [flag::NOESCAPE]), + ("???b", "aa/b", false, [flag::PATHNAME]), + ("?a/b", ".a/b", false, [flag::PATHNAME, flag::PERIOD]), + ("a/?b", "a/.b", false, [flag::PATHNAME, flag::PERIOD]), + ("*a/b", ".a/b", false, [flag::PATHNAME, flag::PERIOD]), + ("a/*b", "a/.b", false, [flag::PATHNAME, flag::PERIOD]), + ("[.]a/b", ".a/b", false, [flag::PATHNAME, flag::PERIOD]), + ("a/[.]b", "a/.b", false, [flag::PATHNAME, flag::PERIOD]), + ("*/?", "a/b", true, [flag::PATHNAME, flag::PERIOD]), + ("?/*", "a/b", true, [flag::PATHNAME, flag::PERIOD]), + (".*/?", ".a/b", true, [flag::PATHNAME, flag::PERIOD]), + ("*/.?", "a/.b", true, [flag::PATHNAME, flag::PERIOD]), + ("*/*", "a/.b", false, [flag::PATHNAME, flag::PERIOD]), + ("*?*/*", "a/.b", true, [flag::PERIOD]), + ("*[.]/b", "a./b", true, [flag::PATHNAME, flag::PERIOD]), + ("*[[:alpha:]]/*[[:alnum:]]", "a/b", true, [flag::PATHNAME]), + ("a?b", "a.b", true, [flag::PATHNAME, flag::PERIOD]), + ("a*b", "a.b", true, [flag::PATHNAME, flag::PERIOD]), + ("a[.]b", "a.b", true, [flag::PATHNAME, flag::PERIOD]), ]; @test fn fnmatch() void = { diff --git a/fnmatch/fnmatch.ha b/fnmatch/fnmatch.ha @@ -10,7 +10,7 @@ use errors; use strings; // A set of flags that alter the matching behavior of [[fnmatch]] -export type flags = enum uint { +export type flag = enum uint { NONE = 0, // If this flag is set, slashes in the string will only be matched by @@ -20,7 +20,7 @@ export type flags = enum uint { // character NOESCAPE = 1u << 1, // If this flag is set, a '.' at the beginning of the string can only - // be matched by a literal '.' in the pattern. If [[flags::PATHNAME]] is + // be matched by a literal '.' in the pattern. If [[flag::PATHNAME]] is // set simultaneously, this behavior also apply to any periods // immediately following a slash. PERIOD = 1u << 2, @@ -46,13 +46,13 @@ type token = (rune | bracket | star | question | end); // - all other characters only match themselves // // A set of flags that alter the matching behavior may be passed to -// [[fnmatch]]. For an explanation of their meaning, see [[flags]]. -export fn fnmatch(pattern: str, string: str, flag: flags...) bool = { - let fl: flags = 0; - for (let i = 0z; i < len(flag); i += 1) { - fl |= flag[i]; +// [[fnmatch]]. For an explanation of their meaning, see [[flag]]. +export fn fnmatch(pattern: str, string: str, flags: flag...) bool = { + let fl: flag = 0; + for (let i = 0z; i < len(flags); i += 1) { + fl |= flags[i]; }; - let b = if (fl & flags::PATHNAME != 0) { + let b = if (fl & flag::PATHNAME != 0) { yield fnmatch_pathname(pattern, string, fl); } else { yield fnmatch_internal(pattern, string, fl); @@ -65,7 +65,7 @@ export fn fnmatch(pattern: str, string: str, flag: flags...) bool = { fn fnmatch_pathname( pattern: str, string: str, - fl: flags, + fl: flag, ) (bool | errors::unsupported | errors::invalid) = { let tok = strings::tokenize(string, "/"); let p_iter = strings::iter(pattern); @@ -112,9 +112,9 @@ fn fnmatch_pathname( fn fnmatch_internal( pattern: str, string: str, - fl: flags, + fl: flag, ) (bool | errors::invalid | errors::unsupported) = { - if (fl & flags::PERIOD != 0) { + if (fl & flag::PERIOD != 0) { if (strings::hasprefix(string, ".") && !strings::hasprefix(pattern, ".")) { return false; @@ -329,7 +329,7 @@ fn match_ctype(it: *strings::iterator, c: rune) (bool | errors::invalid) = { return errors::invalid; }; -fn pat_next(pat: *strings::iterator, fl: flags) (token | errors::invalid) = { +fn pat_next(pat: *strings::iterator, fl: flag) (token | errors::invalid) = { let r = match (strings::next(pat)) { case void => return end; @@ -345,7 +345,7 @@ fn pat_next(pat: *strings::iterator, fl: flags) (token | errors::invalid) = { return bracket; case '\\' => // TODO: remove ? (harec bug workaround) - return if (fl & flags::NOESCAPE == 0) advance_or_err(pat)? + return if (fl & flag::NOESCAPE == 0) advance_or_err(pat)? else '\\'; case => return r; diff --git a/fs/fs.ha b/fs/fs.ha @@ -21,7 +21,7 @@ export fn close(fs: *fs) void = { // Opens a file. If no flags are provided, the default read/write mode is // RDONLY. -export fn open(fs: *fs, path: str, flags: flags...) (io::handle | error) = { +export fn open(fs: *fs, path: str, flags: flag...) (io::handle | error) = { match (fs.open) { case null => return errors::unsupported; @@ -35,7 +35,7 @@ export fn open(fs: *fs, path: str, flags: flags...) (io::handle | error) = { // filesystem implementations (such cases will return [[io::unsupported]]). // // If no flags are provided, the default read/write mode is RDONLY. -export fn open_file(fs: *fs, path: str, flags: flags...) (io::file | error) = { +export fn open_file(fs: *fs, path: str, flags: flag...) (io::file | error) = { match (fs.openfile) { case null => return errors::unsupported; @@ -50,7 +50,7 @@ export fn create( fs: *fs, path: str, mode: mode, - flags: flags... + flags: flag... ) (io::handle | error) = { match (fs.create) { case null => @@ -70,7 +70,7 @@ export fn create_file( fs: *fs, path: str, mode: mode, - flags: flags... + flags: flag... ) (io::file | error) = { match (fs.createfile) { case null => diff --git a/fs/types.ha b/fs/types.ha @@ -175,7 +175,7 @@ export fn dirent_finish(e: *dirent) void = free(e.name); // at a minimum, RDONLY, WRONLY, RDWR, and CREATE will be supported. // Note that NOCTTY and CLOEXEC are on by default, and the CTTY/NOCLOEXEC flags // respectively disable them. -export type flags = enum int { +export type flag = enum int { RDONLY = 0, WRONLY = 1, RDWR = 2, @@ -213,27 +213,27 @@ export type symlinkfunc = fn(fs: *fs, target: str, path: str) (void | error); export type openfunc = fn( fs: *fs, path: str, - flags: flags... + flags: flag... ) (io::handle | error); export type openfilefunc = fn( fs: *fs, path: str, - flags: flags... + flags: flag... ) (io::file | error); export type createfunc = fn( fs: *fs, path: str, mode: mode, - flags: flags... + flags: flag... ) (io::handle | error); export type createfilefunc = fn( fs: *fs, path: str, mode: mode, - flags: flags... + flags: flag... ) (io::file | error); // An abstract implementation of a filesystem, which provides common filesystem diff --git a/glob/+test.ha b/glob/+test.ha @@ -2,22 +2,22 @@ use fnmatch; use strings; @test fn glob() void = { - const cases: [_](str, flags) = [ - ("/u??/*in/a*", flags::NONE), - ("/u*r/l?[bc]*/[bg]*", flags::NOSORT), - ("/?sr/[sb]in/*[[:digit:]]*", flags::MARK), - ("/h??\\e/*/.*", flags::NOSORT | flags::MARK), - ("/\\h??e/*/.*", flags::NOSORT | flags::NOESCAPE), - ("/r*/*", flags::NOSORT), - ("/*.?a", flags::NOCHECK), - ("./*.[[:alpha:]]a", flags::NONE), - ("./\\a[bd]c", flags::NOESCAPE), - ("./\\a[be]c", flags::NONE), - ("[[:punct:]]*", flags::NONE), - ("/", flags::NONE), - ("//", flags::NONE), - (".", flags::NONE), - ("..", flags::NONE), + const cases: [_](str, flag) = [ + ("/u??/*in/a*", flag::NONE), + ("/u*r/l?[bc]*/[bg]*", flag::NOSORT), + ("/?sr/[sb]in/*[[:digit:]]*", flag::MARK), + ("/h??\\e/*/.*", flag::NOSORT | flag::MARK), + ("/\\h??e/*/.*", flag::NOSORT | flag::NOESCAPE), + ("/r*/*", flag::NOSORT), + ("/*.?a", flag::NOCHECK), + ("./*.[[:alpha:]]a", flag::NONE), + ("./\\a[bd]c", flag::NOESCAPE), + ("./\\a[be]c", flag::NONE), + ("[[:punct:]]*", flag::NONE), + ("/", flag::NONE), + ("//", flag::NONE), + (".", flag::NONE), + ("..", flag::NONE), ]; for (let i = 0z; i < len(cases); i += 1) { let gen = glob(cases[i].0, cases[i].1); @@ -28,12 +28,12 @@ use strings; case failure => continue; case let s: str => - let bs = fnmatch::flags::PATHNAME; - if (cases[i].1 & flags::NOESCAPE != 0) { - bs |= fnmatch::flags::NOESCAPE; + let bs = fnmatch::flag::PATHNAME; + if (cases[i].1 & flag::NOESCAPE != 0) { + bs |= fnmatch::flag::NOESCAPE; }; assert(fnmatch::fnmatch(cases[i].0, s, bs) - || cases[i].1 & flags::MARK != 0 + || cases[i].1 & flag::MARK != 0 && fnmatch::fnmatch( cases[i].0, strings::rtrim(s, '/'), diff --git a/glob/glob.ha b/glob/glob.ha @@ -9,7 +9,7 @@ use strings; use strio; // Flags used to control the behavior of [[next]]. -export type flags = enum uint { +export type flag = enum uint { NONE = 0, // Slash appending is enabled. A slash character is appended to each // pathname that is a directory that matches the pattern. @@ -28,7 +28,7 @@ export type flags = enum uint { export type generator = struct { pats: strstack, matc: size, - flgs: flags, + flgs: flag, tmpp: pattern, }; @@ -54,10 +54,10 @@ export type failure = !struct { // Returns a generator of pathnames matching a pattern. The result must be // freed using [[finish]]. -export fn glob(pattern: str, flags: flags...) generator = { +export fn glob(pattern: str, flags: flag...) generator = { let ss = strstack_init(); strio::concat(strstack_push(&ss), pattern)!; - let bs = flags::NONE; + let bs = flag::NONE; for (let i = 0z; i < len(flags); i += 1) { bs |= flags[i]; }; @@ -91,7 +91,7 @@ export fn next(gen: *generator) (str | void | failure) = { return f; case void => void; }; - if (init && gen.flgs & flags::NOCHECK != 0) { + if (init && gen.flgs & flag::NOCHECK != 0) { return strio::string(&gen.pats.bufv[0]); }; }; @@ -105,7 +105,7 @@ fn next_match(fs: *fs::fs, gen: *generator) (str | void | failure) = { gen.matc -= 1; return s; }; - pattern_parse(&gen.tmpp, s, gen.flgs & flags::NOESCAPE != 0); + pattern_parse(&gen.tmpp, s, gen.flgs & flag::NOESCAPE != 0); }; const l = strstack_size(&gen.pats); @@ -117,9 +117,9 @@ fn next_match(fs: *fs::fs, gen: *generator) (str | void | failure) = { }; const rem = pattern_rem(&gen.tmpp); - let flgs = fnmatch::flags::PERIOD; - if (gen.flgs & flags::NOESCAPE != 0) { - flgs |= fnmatch::flags::NOESCAPE; + let flgs = fnmatch::flag::PERIOD; + if (gen.flgs & flag::NOESCAPE != 0) { + flgs |= fnmatch::flag::NOESCAPE; }; let it = match(fs::iter(fs, if (len(dir) > 0) dir else ".")) { case let i: *fs::iterator => @@ -149,7 +149,7 @@ fn next_match(fs: *fs::fs, gen: *generator) (str | void | failure) = { continue; }; strio::concat(b, dir, de.name)!; - if (patm || gen.flgs & flags::MARK != 0) { + if (patm || gen.flgs & flag::MARK != 0) { let m = fs::isdir(de.ftype); // POSIX does not specify the behavior when a pathname // that matches the pattern is a symlink to a @@ -175,7 +175,7 @@ fn next_match(fs: *fs::fs, gen: *generator) (str | void | failure) = { }; gen.matc += 1; }; - if (gen.flgs & flags::NOSORT == 0) { + if (gen.flgs & flag::NOSORT == 0) { strstack_sort(&gen.pats, l); }; diff --git a/hare/ast/type.ha b/hare/ast/type.ha @@ -74,7 +74,7 @@ export type list_type = struct { }; // Flags which apply to a pointer type. -export type pointer_flags = enum uint { +export type pointer_flag = enum uint { NONE = 0, NULLABLE = 1 << 0, }; @@ -82,7 +82,7 @@ export type pointer_flags = enum uint { // *int export type pointer_type = struct { referent: *_type, - flags: pointer_flags, + flags: pointer_flag, }; // A single field of a struct type. @@ -124,7 +124,7 @@ export type tagged_type = []*_type; export type tuple_type = []*_type; // Flags which apply to types. -export type type_flags = enum uint { +export type type_flag = enum uint { NONE = 0, CONST = 1 << 0, ERROR = 1 << 1, @@ -134,7 +134,7 @@ export type type_flags = enum uint { export type _type = struct { start: lex::location, end: lex::location, - flags: type_flags, + flags: type_flag, repr: (alias_type | builtin_type | enum_type | func_type | list_type | pointer_type | struct_type | union_type | tagged_type | tuple_type), diff --git a/hare/lex/+test.ha b/hare/lex/+test.ha @@ -206,7 +206,7 @@ fn loc(line: uint, col: uint) location = location { let in = "// foo\n// bar\nhello world// baz\n\n// bad\ntest"; let buf = bufio::fixed(strings::toutf8(in), mode::READ); - let lexer = init(&buf, "<input>", flags::COMMENTS); + let lexer = init(&buf, "<input>", flag::COMMENTS); assert(lex(&lexer) is token); assert(comment(&lexer) == " foo\n bar\n"); assert(lex(&lexer) is token); diff --git a/hare/lex/lex.ha b/hare/lex/lex.ha @@ -27,13 +27,13 @@ export type lexer = struct { // 1 more than the size of un and rb respectively prevunlocs: [2](location, location), prevrlocs: [3]location, - flags: flags, + flags: flag, comment: str, require_int: bool, }; // Flags which apply to this lexer -export type flags = enum uint { +export type flag = enum uint { NONE = 0, // Enables lexing comments COMMENTS = 1 << 0, @@ -58,8 +58,8 @@ export fn strerror(err: error) const str = { }; // Initializes a new lexer for the given input. The path is borrowed. -export fn init(in: io::handle, path: str, flags: flags...) lexer = { - let f = flags::NONE; +export fn init(in: io::handle, path: str, flags: flag...) lexer = { + let f = flag::NONE; for (let i = 0z; i < len(flags); i += 1) { f |= flags[i]; }; @@ -83,7 +83,7 @@ export fn finish(lex: *lexer) void = { }; // Returns the current value of the comment buffer, or empty string if unset (or -// if [[flags::COMMENTS]] was not enabled for this lexer). +// if [[flag::COMMENTS]] was not enabled for this lexer). export fn comment(lex: *lexer) str = lex.comment; // Returns the next token from the lexer. @@ -343,7 +343,7 @@ fn lex_name(lex: *lexer, loc: location) (token | error) = { }; fn line_comment(lex: *lexer) (void | error) = { - if (lex.flags & flags::COMMENTS != flags::COMMENTS) { + if (lex.flags & flag::COMMENTS != flag::COMMENTS) { return; }; @@ -371,7 +371,7 @@ fn line_comment(lex: *lexer) (void | error) = { }; fn lex_comment(lexr: *lexer) (void | error) = { - if (lexr.flags & flags::COMMENTS != flags::COMMENTS) { + if (lexr.flags & flag::COMMENTS != flag::COMMENTS) { for (true) match (next(lexr)?) { case io::EOF => break; diff --git a/hare/module/manifest.ha b/hare/module/manifest.ha @@ -59,7 +59,7 @@ export fn manifest_load(ctx: *context, ident: ast::ident) (manifest | error) = { let mpath = path::init(cachedir, "manifest")!; let mpath = path::string(&mpath); - let truefile = match (fs::open(ctx.fs, mpath, fs::flags::RDONLY)) { + let truefile = match (fs::open(ctx.fs, mpath, fs::flag::RDONLY)) { case errors::noentry => return manifest; case let err: fs::error => diff --git a/hare/parse/+test/roundtrip.ha b/hare/parse/+test/roundtrip.ha @@ -15,7 +15,7 @@ use strio; fn roundtrip(src: str) void = { let buf = bufio::fixed(strings::toutf8(src), mode::READ); - let lexer = lex::init(&buf, "<test>", lex::flags::COMMENTS); + let lexer = lex::init(&buf, "<test>", lex::flag::COMMENTS); defer lex::finish(&lexer); let u = ast::subunit { imports = [], diff --git a/hare/parse/decl.ha b/hare/parse/decl.ha @@ -183,7 +183,7 @@ fn decl_func(lexer: *lex::lexer) (ast::decl_func | error) = { prototype = ast::_type { start = proto_start, end = proto_end, - flags = ast::type_flags::CONST, + flags = ast::type_flag::CONST, repr = prototype, }, body = body, diff --git a/hare/parse/type.ha b/hare/parse/type.ha @@ -132,7 +132,7 @@ fn primitive_type(lexer: *lex::lexer) (ast::_type | error) = { return ast::_type { start = tok.2, end = lex::prevloc(lexer), - flags = ast::type_flags::NONE, + flags = ast::type_flag::NONE, repr = builtin, }; }; @@ -156,16 +156,16 @@ fn pointer_type(lexer: *lex::lexer) (ast::_type | error) = { const start = lex::mkloc(lexer); let flags = match (try(lexer, ltok::NULLABLE)?) { case void => - yield ast::pointer_flags::NONE; + yield ast::pointer_flag::NONE; case => - yield ast::pointer_flags::NULLABLE; + yield ast::pointer_flag::NULLABLE; }; want(lexer, ltok::TIMES)?; let _type = _type(lexer)?; return ast::_type { start = start, end = lex::prevloc(lexer), - flags = ast::type_flags::NONE, + flags = ast::type_flag::NONE, repr = ast::pointer_type { referent = alloc(_type), flags = flags, @@ -190,7 +190,7 @@ fn tagged_type( return ast::_type { start = start, end = lex::prevloc(lexer), - flags = ast::type_flags::NONE, + flags = ast::type_flag::NONE, repr = tagged, }; }; @@ -212,7 +212,7 @@ fn tuple_type( return ast::_type { start = start, end = lex::prevloc(lexer), - flags = ast::type_flags::NONE, + flags = ast::type_flag::NONE, repr = tuple, }; }; @@ -231,7 +231,7 @@ fn fn_type(lexer: *lex::lexer) (ast::_type | error) = { return ast::_type { start = start, end = lex::prevloc(lexer), - flags = ast::type_flags::CONST, + flags = ast::type_flag::CONST, repr = proto, }; }; @@ -297,7 +297,7 @@ fn struct_union_type(lexer: *lex::lexer) (ast::_type | error) = { return ast::_type { start = kind.2, end = lex::prevloc(lexer), - flags = ast::type_flags::NONE, + flags = ast::type_flag::NONE, repr = switch (kind.0) { case ltok::STRUCT => yield ast::struct_type { members = membs, packed = packed, ...}; @@ -381,7 +381,7 @@ fn array_slice_type(lexer: *lex::lexer) (ast::_type | error) = { return ast::_type { start = start.2, end = lex::prevloc(lexer), - flags = ast::type_flags::NONE, + flags = ast::type_flag::NONE, repr = ast::list_type { length = length, members = alloc(_type), @@ -447,7 +447,7 @@ fn enum_type(lexer: *lex::lexer) (ast::_type | error) = { return ast::_type { start = start.2, end = lex::prevloc(lexer), - flags = ast::type_flags::NONE, + flags = ast::type_flag::NONE, repr = ast::enum_type { storage = storage, values = membs, @@ -457,13 +457,13 @@ fn enum_type(lexer: *lex::lexer) (ast::_type | error) = { // Parses a type, e.g. '[]int'. export fn _type(lexer: *lex::lexer) (ast::_type | error) = { - let flags = ast::type_flags::NONE; + let flags = ast::type_flag::NONE; if (try(lexer, ltok::CONST)? is lex::token) { - flags |= ast::type_flags::CONST; + flags |= ast::type_flag::CONST; }; if (try(lexer, ltok::LNOT)? is lex::token) { - flags |= ast::type_flags::ERROR; + flags |= ast::type_flag::ERROR; }; let tok = peek(lexer)? as lex::token; diff --git a/hare/types/+test.ha b/hare/types/+test.ha @@ -295,7 +295,7 @@ fn resolve( let f = htype.repr as func; assert(f.result.repr as builtin == builtin::VOID); assert(f.variadism == variadism::NONE); - assert(f.flags == func_flags::NORETURN); + assert(f.flags == func_flag::NORETURN); assert(len(f.params) == 0); let atype = parse_type("fn(foo: int, bar: str...) int"); diff --git a/hare/types/store.ha b/hare/types/store.ha @@ -260,7 +260,7 @@ fn fromast(store: *typestore, atype: *ast::_type) (_type | deferred | error) = { _align = store.arch._pointer; yield pointer { referent = lookup(store, p.referent)?, - flags = p.flags: pointer_flags, + flags = p.flags: pointer_flag, }; case let st: ast::struct_type => let st = struct_from_ast(store, st, false)?; @@ -330,7 +330,7 @@ fn fromast(store: *typestore, atype: *ast::_type) (_type | deferred | error) = { }; return _type { id = 0, // filled in later - flags = atype.flags: flags, + flags = atype.flags: flag, repr = repr, sz = sz, _align = _align, @@ -355,7 +355,7 @@ fn func_from_ast( params = alloc([], len(ft.params)), }; if (ft.attrs & ast::func_attrs::NORETURN != 0) { - f.flags |= func_flags::NORETURN; + f.flags |= func_flag::NORETURN; }; for (let i = 0z; i < len(ft.params); i += 1) { append(f.params, lookup(store, ft.params[i]._type)?); diff --git a/hare/types/types.ha b/hare/types/types.ha @@ -40,7 +40,7 @@ export type variadism = enum { }; // Indicats if a [[func]] has the @noreturn attribute -export type func_flags = enum uint { +export type func_flag = enum uint { NONE = 0, NORETURN = 1 << 0, }; @@ -49,13 +49,13 @@ export type func_flags = enum uint { export type func = struct { result: const *_type, variadism: variadism, - flags: func_flags, + flags: func_flag, params: []const *_type, }; // Flags which apply to a pointer type. -export type pointer_flags = enum u8 { - // Keep me consistent with ast::pointer_flags +export type pointer_flag = enum u8 { + // Keep me consistent with ast::pointer_flag NONE = 0, NULLABLE = 1 << 0, @@ -64,7 +64,7 @@ export type pointer_flags = enum u8 { // *int export type pointer = struct { referent: const *_type, - flags: pointer_flags, + flags: pointer_flag, }; // []int @@ -106,8 +106,8 @@ export type tuple_value = struct { }; // Flags for a Hare type. -export type flags = enum u8 { - // Keep me consistent with ast::type_flags +export type flag = enum u8 { + // Keep me consistent with ast::type_flag NONE = 0, CONST = 1 << 0, @@ -120,7 +120,7 @@ export def SIZE_UNDEFINED: size = -1: size; // A Hare type. export type _type = struct { - flags: flags, + flags: flag, repr: (alias | array | builtin | _enum | func | pointer | slice | _struct | tagged | tuple), id: u32, diff --git a/hare/unparse/decl.ha b/hare/unparse/decl.ha @@ -146,7 +146,7 @@ fn decl_test(d: ast::decl, expected: str) bool = { let type_fn = ast::_type { start = loc, end = loc, - flags = ast::type_flags::CONST, + flags = ast::type_flag::CONST, repr = ast::func_type { result = &type_int, attrs = ast::func_attrs::NORETURN, diff --git a/hare/unparse/type.ha b/hare/unparse/type.ha @@ -216,11 +216,11 @@ export fn _type( t: ast::_type, ) (size | io::error) = { let n = 0z; - if (t.flags & ast::type_flags::CONST != 0 + if (t.flags & ast::type_flag::CONST != 0 && !(t.repr is ast::func_type)) { n += fmt::fprint(out, "const ")?; }; - if (t.flags & ast::type_flags::ERROR != 0) { + if (t.flags & ast::type_flag::ERROR != 0) { n += fmt::fprint(out, "!")?; }; match (t.repr) { @@ -294,7 +294,7 @@ export fn _type( n += fmt::fprint(out, "]")?; n += _type(out, indent, *l.members)?; case let p: ast::pointer_type => - if (p.flags & ast::pointer_flags::NULLABLE != 0) { + if (p.flags & ast::pointer_flag::NULLABLE != 0) { n += fmt::fprint(out, "nullable ")?; }; n += fmt::fprint(out, "*")?; @@ -376,7 +376,7 @@ fn type_test(t: ast::_type, expected: str) void = { let t = ast::_type { start = loc, end = loc, - flags = ast::type_flags::CONST, + flags = ast::type_flag::CONST, repr = ast::alias_type { unwrap = false, ident = ["foo", "bar"], @@ -402,11 +402,11 @@ fn type_test(t: ast::_type, expected: str) void = { }; type_test(t, "...baz"); - t.flags = ast::type_flags::ERROR; + t.flags = ast::type_flag::ERROR; t.repr = ast::builtin_type::INT; type_test(t, "!int"); - t.flags = ast::type_flags::CONST | ast::type_flags::ERROR; + t.flags = ast::type_flag::CONST | ast::type_flag::ERROR; t.repr = ast::enum_type { storage = ast::builtin_type::U32, values = [ @@ -467,7 +467,7 @@ fn type_test(t: ast::_type, expected: str) void = { }; type_test(t, "fn(foo: int, bar: int...) int"); - t.flags = ast::type_flags::CONST; + t.flags = ast::type_flag::CONST; type_test(t, "fn(foo: int, bar: int...) int"); t.flags = 0; @@ -499,7 +499,7 @@ fn type_test(t: ast::_type, expected: str) void = { type_test(t, "*int"); t.repr = ast::pointer_type { referent = &type_int, - flags = ast::pointer_flags::NULLABLE, + flags = ast::pointer_flag::NULLABLE, }; type_test(t, "nullable *int"); diff --git a/io/+freebsd/mmap.ha b/io/+freebsd/mmap.ha @@ -15,7 +15,7 @@ export type prot = enum uint { // Values for the [[mmap]] flags parameter. Only the SHARED, PRIVATE, and FIXED // values are portable. -export type mflags = enum uint { +export type mflag = enum uint { SHARED = rt::MAP_SHARED, PRIVATE = rt::MAP_PRIVATE, FIXED = rt::MAP_FIXED, @@ -37,7 +37,7 @@ export fn mmap( addr: nullable *void, length: size, prot: prot, - flags: mflags, + flags: mflag, fd: file, offs: size ) (*void | errors::error) = { diff --git a/io/+linux/mmap.ha b/io/+linux/mmap.ha @@ -17,7 +17,7 @@ export type prot = enum uint { // Values for the [[mmap]] flags parameter. Only the SHARED, PRIVATE, and FIXED // values are portable. -export type mflags = enum uint { +export type mflag = enum uint { SHARED = rt::MAP_SHARED, PRIVATE = rt::MAP_PRIVATE, SHARED_VALIDATE = rt::MAP_SHARED_VALIDATE, @@ -57,7 +57,7 @@ export fn mmap( addr: nullable *void, length: size, prot: prot, - flags: mflags, + flags: mflag, fd: file, offs: size ) (*void | errors::error) = { diff --git a/net/+freebsd.ha b/net/+freebsd.ha @@ -12,7 +12,7 @@ export type socket = io::file; // Optional flags to [[accept]] to be set on the returned [[socket]]. // See the O_CLOEXEC and O_NONBLOCK sections of open(2) for details. // Note that CLOEXEC is on by default, and NOCLOEXEC flag disables it. -export type sockflags = enum int { +export type sockflag = enum int { NOCLOEXEC = rt::SOCK_CLOEXEC, NONBLOCK = rt::SOCK_NONBLOCK }; @@ -20,7 +20,7 @@ export type sockflags = enum int { // Accepts the next connection from a socket. Blocks until a new connection is // available. Optionally accepts NOCLOEXEC and NONBLOCK flags. If flags are // supplied, the [[io::file]] returned will have the supplied flags set. -export fn accept(sock: socket, flags: sockflags...) (socket | error) = { +export fn accept(sock: socket, flags: sockflag...) (socket | error) = { // Apply any supplied flags let f = 0i; for (let i = 0z; i < len(flags); i += 1) { diff --git a/net/+linux.ha b/net/+linux.ha @@ -12,7 +12,7 @@ export type socket = io::file; // Optional flags to [[accept]] to be set on the returned [[socket]]. // See the O_CLOEXEC and O_NONBLOCK sections of open(2) for details. // Note that CLOEXEC is on by default, and NOCLOEXEC flag disables it. -export type sockflags = enum int { +export type sockflag = enum int { NOCLOEXEC = rt::SOCK_CLOEXEC, NONBLOCK = rt::SOCK_NONBLOCK }; @@ -20,7 +20,7 @@ export type sockflags = enum int { // Accepts the next connection from a socket. Blocks until a new connection is // available. Optionally accepts NOCLOEXEC and NONBLOCK flags. If flags are // supplied, the [[io::file]] returned will have the supplied flags set. -export fn accept(sock: socket, flags: sockflags...) (socket | error) = { +export fn accept(sock: socket, flags: sockflag...) (socket | error) = { // Apply any supplied flags let f = 0i; for (let i = 0z; i < len(flags); i += 1) { diff --git a/net/tcp/+freebsd.ha b/net/tcp/+freebsd.ha @@ -25,7 +25,7 @@ export fn connect( let f = 0i; for (let i = 0z; i < len(options); i += 1) { match (options[i]) { - case let fl: net::sockflags => + case let fl: net::sockflag => f |= fl; case => void; }; @@ -73,7 +73,7 @@ export fn listen( let f = 0i; for (let i = 0z; i < len(options); i += 1) { match (options[i]) { - case let fl: net::sockflags => + case let fl: net::sockflag => f |= fl; case => void; }; diff --git a/net/tcp/+linux.ha b/net/tcp/+linux.ha @@ -25,7 +25,7 @@ export fn connect( let f = 0i; for (let i = 0z; i < len(options); i += 1) { match (options[i]) { - case let fl: net::sockflags => + case let fl: net::sockflag => f |= fl; case => void; }; @@ -73,7 +73,7 @@ export fn listen( let f = 0i; for (let i = 0z; i < len(options); i += 1) { match (options[i]) { - case let fl: net::sockflags => + case let fl: net::sockflag => f |= fl; case => void; }; diff --git a/net/tcp/listener.ha b/net/tcp/listener.ha @@ -6,5 +6,5 @@ use net; // available. This is a convenience wrapper around [[net::accept]]. export fn accept( sock: net::socket, - flags: net::sockflags... + flags: net::sockflag... ) (net::socket | net::error) = net::accept(sock, flags...); diff --git a/net/tcp/options.ha b/net/tcp/options.ha @@ -21,7 +21,7 @@ export type reuseaddr = void; export type portassignment = *u16; // Options for [[connect]]. -export type connect_option = (keepalive | net::sockflags); +export type connect_option = (keepalive | net::sockflag); // Options for [[listen]]. export type listen_option = ( @@ -30,4 +30,4 @@ export type listen_option = ( reuseaddr | backlog | portassignment | - net::sockflags); + net::sockflag); diff --git a/net/udp/+freebsd.ha b/net/udp/+freebsd.ha @@ -22,7 +22,7 @@ export fn connect( }; let f = 0i; for (let i = 0z; i < len(options); i += 1) { - // Only sockflags for now + // Only sockflag for now f |= options[i]; }; f ^= rt::SOCK_CLOEXEC; // invert CLOEXEC @@ -58,7 +58,7 @@ export fn listen( let f = 0i; for (let i = 0z; i < len(options); i += 1) { match (options[i]) { - case let fl: net::sockflags => + case let fl: net::sockflag => f |= fl; case => void; }; diff --git a/net/udp/+linux.ha b/net/udp/+linux.ha @@ -22,7 +22,7 @@ export fn connect( }; let f = 0i; for (let i = 0z; i < len(options); i += 1) { - // Only sockflags for now + // Only sockflag for now f |= options[i]; }; f ^= rt::SOCK_CLOEXEC; // invert CLOEXEC @@ -58,7 +58,7 @@ export fn listen( let f = 0i; for (let i = 0z; i < len(options); i += 1) { match (options[i]) { - case let fl: net::sockflags => + case let fl: net::sockflag => f |= fl; case => void; }; diff --git a/net/udp/options.ha b/net/udp/options.ha @@ -14,13 +14,13 @@ export type reuseaddr = void; export type portassignment = *u16; // Options for [[connect]]. -export type connect_option = net::sockflags; +export type connect_option = net::sockflag; // Options available for [[listen]]. export type listen_option = ( reuseport | reuseaddr | portassignment | - net::sockflags); + net::sockflag); // TODO: Add send/recv flags diff --git a/net/unix/+freebsd.ha b/net/unix/+freebsd.ha @@ -24,7 +24,7 @@ export fn connect( }; let f = 0i; for (let i = 0z; i < len(options); i += 1) { - // Only sockflags for now + // Only sockflag for now f |= options[i]; }; f ^= rt::SOCK_CLOEXEC; // invert CLOEXEC @@ -59,7 +59,7 @@ export fn listen( let f = 0i; for (let i = 0z; i < len(options); i += 1) { match (options[i]) { - case let fl: net::sockflags => + case let fl: net::sockflag => f |= fl; case => void; }; diff --git a/net/unix/+linux.ha b/net/unix/+linux.ha @@ -25,7 +25,7 @@ export fn connect( }; let f = 0i; for (let i = 0z; i < len(options); i += 1) { - // Only sockflags for now + // Only sockflag for now f |= options[i]; }; f ^= rt::SOCK_CLOEXEC; // invert CLOEXEC @@ -60,7 +60,7 @@ export fn listen( let f = 0i; for (let i = 0z; i < len(options); i += 1) { match (options[i]) { - case let fl: net::sockflags => + case let fl: net::sockflag => f |= fl; case => void; }; diff --git a/net/unix/listener.ha b/net/unix/listener.ha @@ -6,5 +6,5 @@ use net; // available. This is a convenience wrapper around [[net::accept]]. export fn accept( sock: net::socket, - flags: net::sockflags... + flags: net::sockflag... ) (net::socket | net::error) = net::accept(sock, flags...); diff --git a/net/unix/options.ha b/net/unix/options.ha @@ -7,7 +7,7 @@ use net; export type backlog = u32; // Options for [[connect]]. -export type connect_option = net::sockflags; +export type connect_option = net::sockflag; // Options for [[listen]]. -export type listen_option = (backlog | net::sockflags); +export type listen_option = (backlog | net::sockflag); diff --git a/net/unix/socketpair.ha b/net/unix/socketpair.ha @@ -8,7 +8,7 @@ use rt; // A thin wrapper around socketpair(2) that presumes [[rt::AF_UNIX]] for the // domain and returns an unnamed pair of sockets of type [[rt::SOCK_STREAM]]. -export fn socketpair(flags: net::sockflags...) ((net::socket, net::socket) | net::error) = { +export fn socketpair(flags: net::sockflag...) ((net::socket, net::socket) | net::error) = { let sv: [2]int = [0...]; // Apply any supplied flags let f = 0i; diff --git a/os/+freebsd/dirfdfs.ha b/os/+freebsd/dirfdfs.ha @@ -109,58 +109,58 @@ fn _fs_open( return io::fdopen(fd); }; -fn fsflags_to_bsd(flags: fs::flags) int = { +fn fsflags_to_bsd(flags: fs::flag) int = { let out = rt::O_NOCTTY | rt::O_CLOEXEC; - if (flags & fs::flags::WRONLY > 0) { + if (flags & fs::flag::WRONLY > 0) { out |= rt::O_WRONLY; }; - if (flags & fs::flags::RDWR > 0) { + if (flags & fs::flag::RDWR > 0) { out |= rt::O_RDWR; }; - if (flags & fs::flags::CREATE > 0) { + if (flags & fs::flag::CREATE > 0) { out |= rt::O_CREAT; }; - if (flags & fs::flags::EXCL > 0) { + if (flags & fs::flag::EXCL > 0) { out |= rt::O_EXCL; }; - if (flags & fs::flags::CTTY > 0) { + if (flags & fs::flag::CTTY > 0) { out &= ~rt::O_NOCTTY; }; - if (flags & fs::flags::TRUNC > 0) { + if (flags & fs::flag::TRUNC > 0) { out |= rt::O_TRUNC; }; - if (flags & fs::flags::APPEND > 0) { + if (flags & fs::flag::APPEND > 0) { out |= rt::O_APPEND; }; - if (flags & fs::flags::NONBLOCK > 0) { + if (flags & fs::flag::NONBLOCK > 0) { out |= rt::O_NONBLOCK; }; - if (flags & fs::flags::DSYNC > 0) { + if (flags & fs::flag::DSYNC > 0) { out |= rt::O_DSYNC; }; - if (flags & fs::flags::SYNC > 0) { + if (flags & fs::flag::SYNC > 0) { out |= rt::O_SYNC; }; - if (flags & fs::flags::RSYNC > 0) { + if (flags & fs::flag::RSYNC > 0) { out |= rt::O_SYNC; }; - if (flags & fs::flags::DIRECTORY > 0) { + if (flags & fs::flag::DIRECTORY > 0) { out |= rt::O_DIRECTORY; }; - if (flags & fs::flags::NOFOLLOW > 0) { + if (flags & fs::flag::NOFOLLOW > 0) { out |= rt::O_NOFOLLOW; }; - if (flags & fs::flags::NOCLOEXEC > 0) { + if (flags & fs::flag::NOCLOEXEC > 0) { out &= ~rt::O_CLOEXEC; }; - if (flags & fs::flags::PATH > 0) { - abort("fs::flags::PATH is not supported on FreeBSD"); + if (flags & fs::flag::PATH > 0) { + abort("fs::flag::PATH is not supported on FreeBSD"); }; - if (flags & fs::flags::NOATIME > 0) { - abort("fs::flags::NOATIME is not supported on FreeBSD"); + if (flags & fs::flag::NOATIME > 0) { + abort("fs::flag::NOATIME is not supported on FreeBSD"); }; - if (flags & fs::flags::TMPFILE > 0) { - abort("fs::flags::TMPFILE is not supported on FreeBSD"); + if (flags & fs::flag::TMPFILE > 0) { + abort("fs::flag::TMPFILE is not supported on FreeBSD"); }; return out; }; @@ -168,37 +168,37 @@ fn fsflags_to_bsd(flags: fs::flags) int = { fn fs_open_file( fs: *fs::fs, path: str, - flags: fs::flags... + flags: fs::flag... ) (io::file | fs::error) = { - let oflags = fs::flags::RDONLY; + let oflags = fs::flag::RDONLY; for (let i = 0z; i < len(flags); i += 1z) { oflags |= flags[i]; }; - oflags ^= fs::flags::CTTY | fs::flags::NOCLOEXEC; // invert NOCTTY/CLOEXEC + oflags ^= fs::flag::CTTY | fs::flag::NOCLOEXEC; // invert NOCTTY/CLOEXEC return _fs_open(fs, path, fsflags_to_bsd(oflags), 0); }; fn fs_open( fs: *fs::fs, path: str, - flags: fs::flags... + flags: fs::flag... ) (io::handle | fs::error) = fs_open_file(fs, path, flags...)?; fn fs_create_file( fs: *fs::fs, path: str, mode: fs::mode, - flags: fs::flags... + flags: fs::flag... ) (io::file | fs::error) = { - let oflags: fs::flags = 0; + let oflags: fs::flag = 0; if (len(flags) == 0z) { - oflags |= fs::flags::WRONLY; + oflags |= fs::flag::WRONLY; }; for (let i = 0z; i < len(flags); i += 1z) { oflags |= flags[i]; }; - oflags ^= fs::flags::CTTY | fs::flags::NOCLOEXEC; // invert NOCTTY/CLOEXEC - oflags |= fs::flags::CREATE; + oflags ^= fs::flag::CTTY | fs::flag::NOCLOEXEC; // invert NOCTTY/CLOEXEC + oflags |= fs::flag::CREATE; return _fs_open(fs, path, fsflags_to_bsd(oflags), mode)?; }; @@ -206,7 +206,7 @@ fn fs_create( fs: *fs::fs, path: str, mode: fs::mode, - flags: fs::flags... + flags: fs::flag... ) (io::handle | fs::error) = { return fs_create_file(fs, path, mode, flags...)?; }; diff --git a/os/+linux/dirfdfs.ha b/os/+linux/dirfdfs.ha @@ -20,7 +20,7 @@ use types::c; // // Note that on Linux, specifying BENEATH or IN_ROOT will also disable magic // symlinks. -export type resolve_flags = enum { +export type resolve_flag = enum { NORMAL, // Does not allow symlink resolution to occur for any symlinks which @@ -46,13 +46,13 @@ export type resolve_flags = enum { type os_filesystem = struct { fs: fs::fs, dirfd: int, - resolve: resolve_flags, + resolve: resolve_flag, getdents_bufsz: size, }; // Opens a file descriptor as an [[fs::fs]]. This file descriptor must be a // directory file. The file will be closed when the fs is closed. -export fn dirfdopen(fd: io::file, resolve: resolve_flags...) *fs::fs = { +export fn dirfdopen(fd: io::file, resolve: resolve_flag...) *fs::fs = { let ofs = alloc(os_filesystem { ... }); let fs = static_dirfdopen(fd, ofs); for (let i = 0z; i < len(resolve); i += 1) { @@ -90,9 +90,9 @@ fn static_dirfdopen(fd: io::file, filesystem: *os_filesystem) *fs::fs = { return &filesystem.fs; }; -// Clones a dirfd filesystem, optionally adding additional [[resolve_flags]] +// Clones a dirfd filesystem, optionally adding additional [[resolve_flag]] // constraints. -export fn dirfs_clone(fs: *fs::fs, resolve: resolve_flags...) *fs::fs = { +export fn dirfs_clone(fs: *fs::fs, resolve: resolve_flag...) *fs::fs = { assert(fs.open == &fs_open); let fs = fs: *os_filesystem; let new = alloc(*fs); @@ -150,16 +150,16 @@ fn _fs_open( let fs = fs: *os_filesystem; oh.resolve = 0u64; - if (fs.resolve & resolve_flags::BENEATH == resolve_flags::BENEATH) { + if (fs.resolve & resolve_flag::BENEATH == resolve_flag::BENEATH) { oh.resolve |= rt::RESOLVE_BENEATH | rt::RESOLVE_NO_MAGICLINKS; }; - if (fs.resolve & resolve_flags::IN_ROOT == resolve_flags::IN_ROOT) { + if (fs.resolve & resolve_flag::IN_ROOT == resolve_flag::IN_ROOT) { oh.resolve |= rt::RESOLVE_IN_ROOT | rt::RESOLVE_NO_MAGICLINKS; }; - if (fs.resolve & resolve_flags::NO_SYMLINKS == resolve_flags::NO_SYMLINKS) { + if (fs.resolve & resolve_flag::NO_SYMLINKS == resolve_flag::NO_SYMLINKS) { oh.resolve |= rt::RESOLVE_NO_SYMLINKS; }; - if (fs.resolve & resolve_flags::NO_XDEV == resolve_flags::NO_XDEV) { + if (fs.resolve & resolve_flag::NO_XDEV == resolve_flag::NO_XDEV) { oh.resolve |= rt::RESOLVE_NO_XDEV; }; @@ -176,17 +176,17 @@ fn _fs_open( fn fs_open_file( fs: *fs::fs, path: str, - flags: fs::flags... + flags: fs::flag... ) (io::file | fs::error) = { - let oflags = fs::flags::RDONLY: int; + let oflags = fs::flag::RDONLY: int; for (let i = 0z; i < len(flags); i += 1z) { oflags |= flags[i]: int; }; - oflags ^= fs::flags::CTTY | fs::flags::NOCLOEXEC; // invert NOCTTY/CLOEXEC + oflags ^= fs::flag::CTTY | fs::flag::NOCLOEXEC; // invert NOCTTY/CLOEXEC - if ((oflags: fs::flags & fs::flags::DIRECTORY) == fs::flags::DIRECTORY) { + if ((oflags: fs::flag & fs::flag::DIRECTORY) == fs::flag::DIRECTORY) { // This is arch-specific - oflags &= ~fs::flags::DIRECTORY: int; + oflags &= ~fs::flag::DIRECTORY: int; oflags |= rt::O_DIRECTORY: int; }; @@ -200,24 +200,24 @@ fn fs_open_file( fn fs_open( fs: *fs::fs, path: str, - flags: fs::flags... + flags: fs::flag... ) (io::handle | fs::error) = fs_open_file(fs, path, flags...)?; fn fs_create_file( fs: *fs::fs, path: str, mode: fs::mode, - flags: fs::flags... + flags: fs::flag... ) (io::file | fs::error) = { let oflags = 0; if (len(flags) == 0) { - oflags |= fs::flags::WRONLY | fs::flags::TRUNC; + oflags |= fs::flag::WRONLY | fs::flag::TRUNC; }; for (let i = 0z; i < len(flags); i += 1z) { oflags |= flags[i]: int; }; - oflags ^= fs::flags::CTTY | fs::flags::NOCLOEXEC; // invert NOCTTY/CLOEXEC - oflags |= fs::flags::CREATE: int; + oflags ^= fs::flag::CTTY | fs::flag::NOCLOEXEC; // invert NOCTTY/CLOEXEC + oflags |= fs::flag::CREATE: int; let oh = rt::open_how { flags = oflags: u64, @@ -231,7 +231,7 @@ fn fs_create( fs: *fs::fs, path: str, mode: fs::mode, - flags: fs::flags... + flags: fs::flag... ) (io::handle | fs::error) = { return fs_create_file(fs, path, mode, flags...)?; }; diff --git a/os/os.ha b/os/os.ha @@ -86,14 +86,14 @@ export fn symlink(target: str, path: str) (void | fs::error) = // Opens a file. // -// If no flags are provided, [[fs::flags::RDONLY]] is used when opening the +// If no flags are provided, [[fs::flag::RDONLY]] is used when opening the // file. -export fn open(path: str, flags: fs::flags...) (io::file | fs::error) = +export fn open(path: str, flags: fs::flag...) (io::file | fs::error) = fs::open_file(cwd, path, flags...); // Creates a new file and opens it for writing. // -// If no flags are provided, [[fs::flags::WRONLY]] is used when opening the +// If no flags are provided, [[fs::flag::WRONLY]] is used when opening the // file. // // Only the permission bits of the mode are used. If other bits are set, they @@ -101,7 +101,7 @@ export fn open(path: str, flags: fs::flags...) (io::file | fs::error) = export fn create( path: str, mode: fs::mode, - flags: fs::flags... + flags: fs::flag... ) (io::file | fs::error) = fs::create_file(cwd, path, mode, flags...); // Canonicalizes a path in this filesystem by resolving all symlinks and @@ -114,6 +114,6 @@ export fn realpath(path: str) (str | fs::error) = fs::realpath(cwd, path); // Opens a directory as a filesystem. export fn diropen(path: str) (*fs::fs | fs::error) = { - const file = open(path, fs::flags::DIRECTORY | fs::flags::RDONLY)?; + const file = open(path, fs::flag::DIRECTORY | fs::flag::RDONLY)?; return dirfdopen(file); }; diff --git a/rt/+x86_64/cpuid.ha b/rt/+x86_64/cpuid.ha @@ -54,12 +54,12 @@ const vendors: [_]str = [ def VENDOR_OLDAMD: str = "AMDisbetter!"; def VENDOR_OLDTRANSMETA: str = "TransmetaCPU"; -export type cpuid_edxflags = enum uint { +export type cpuid_edxflag = enum uint { SSE = 1 << 25, SSE2 = 1 << 26, }; -export type cpuid_ecxflags = enum uint { +export type cpuid_ecxflag = enum uint { SSE3 = 1 << 0, AES = 1 << 25, }; @@ -91,8 +91,8 @@ export fn cpuid_getvendor() (cpuid_vendor | cpuid_unknownvendor) = { return cpuid_unknownvendor; }; -// Checks if cpu has given features. See [[cpuid_edxflags]] and -// [[cpuid_ecxflags]] for available options. +// Checks if cpu has given features. See [[cpuid_edxflag]] and +// [[cpuid_ecxflag]] for available options. export fn cpuid_hasflags(edx: u32, ecx: u32) bool = { let flags: [2]u32 = [0...]; cpuid_getfeatureflags(&flags); diff --git a/temp/+freebsd.ha b/temp/+freebsd.ha @@ -53,11 +53,11 @@ export fn named( assert(len(mode) == 0 || len(mode) == 1); let fmode = if (len(mode) != 0) mode[0] else 0o644: fs::mode; - let oflags = fs::flags::EXCL; + let oflags = fs::flag::EXCL; if (iomode == io::mode::RDWR) { - oflags |= fs::flags::RDWR; + oflags |= fs::flag::RDWR; } else { - oflags |= fs::flags::WRONLY; + oflags |= fs::flag::WRONLY; }; static let pathbuf = path::buffer { ... }; diff --git a/temp/+linux.ha b/temp/+linux.ha @@ -31,11 +31,11 @@ export fn file( assert(iomode == io::mode::WRITE || iomode == io::mode::RDWR); assert(len(mode) == 0 || len(mode) == 1); let fmode = if (len(mode) != 0) mode[0] else 0o644: fs::mode; - let oflags = fs::flags::TMPFILE | fs::flags::EXCL; + let oflags = fs::flag::TMPFILE | fs::flag::EXCL; if (iomode == io::mode::RDWR) { - oflags |= fs::flags::RDWR; + oflags |= fs::flag::RDWR; } else { - oflags |= fs::flags::WRONLY; + oflags |= fs::flag::WRONLY; }; // TODO: Add a custom "close" function which removes the named file match (os::create(get_tmpdir(), fmode, oflags)) { @@ -67,11 +67,11 @@ export fn named( assert(len(mode) == 0 || len(mode) == 1); let fmode = if (len(mode) != 0) mode[0] else 0o644: fs::mode; - let oflags = fs::flags::EXCL; + let oflags = fs::flag::EXCL; if (iomode == io::mode::RDWR) { - oflags |= fs::flags::RDWR; + oflags |= fs::flag::RDWR; } else { - oflags |= fs::flags::WRONLY; + oflags |= fs::flag::WRONLY; }; static let pathbuf = path::buffer { ... }; diff --git a/test/+test.ha b/test/+test.ha @@ -142,7 +142,7 @@ export @symbol("__test_main") fn main() size = { }; fn do_test(ctx: *context, test: test) void = { - signal::handle(signal::SIGSEGV, &handle_segv, signal::flags::NODEFER); + signal::handle(signal::SIGSEGV, &handle_segv, signal::flag::NODEFER); bufio::reset(&ctx.stdout); bufio::reset(&ctx.stderr); diff --git a/unix/+freebsd/pipe.ha b/unix/+freebsd/pipe.ha @@ -7,7 +7,7 @@ use rt; // Flags to use for the [[io::file]]s returned by [[pipe]]. // Only NOCLOEXEC and NONBLOCK are guaranteed to be available. -export type pipe_flags = enum { +export type pipe_flag = enum { NOCLOEXEC = rt::O_CLOEXEC, DIRECT = rt::O_DIRECT, NONBLOCK = rt::O_NONBLOCK, @@ -15,13 +15,13 @@ export type pipe_flags = enum { // Create a pair of two linked [[io::file]]s, such that any data written to the // second [[io::file]] may be read from the first. -export fn pipe(flags: pipe_flags...) ((io::file, io::file) | errors::error) = { +export fn pipe(flags: pipe_flag...) ((io::file, io::file) | errors::error) = { let fds: [2]int = [0...]; - let flag: pipe_flags = 0; + let flag: pipe_flag = 0; for (let i = 0z; i < len(flags); i += 1) { flag |= flags[i]; }; - flag ^= pipe_flags::NOCLOEXEC; // invert CLOEXEC + flag ^= pipe_flag::NOCLOEXEC; // invert CLOEXEC match (rt::pipe2(&fds, flag)) { case void => void; case let e: rt::errno => diff --git a/unix/+linux/pipe.ha b/unix/+linux/pipe.ha @@ -6,7 +6,7 @@ use rt; // Flags to use for the [[io::file]]s returned by [[pipe]]. // Only NOCLOEXEC and NONBLOCK are guaranteed to be available. -export type pipe_flags = enum { +export type pipe_flag = enum { NOCLOEXEC = rt::O_CLOEXEC, DIRECT = rt::O_DIRECT, NONBLOCK = rt::O_NONBLOCK, @@ -14,13 +14,13 @@ export type pipe_flags = enum { // Create a pair of two linked [[io::file]]s, such that any data written to the // second [[io::file]] may be read from the first. -export fn pipe(flags: pipe_flags...) ((io::file, io::file) | errors::error) = { +export fn pipe(flags: pipe_flag...) ((io::file, io::file) | errors::error) = { let fds: [2]int = [0...]; - let flag: pipe_flags = 0; + let flag: pipe_flag = 0; for (let i = 0z; i < len(flags); i += 1) { flag |= flags[i]; }; - flag ^= pipe_flags::NOCLOEXEC; // invert CLOEXEC + flag ^= pipe_flag::NOCLOEXEC; // invert CLOEXEC match (rt::pipe2(&fds, flag)) { case void => void; case let e: rt::errno => diff --git a/unix/signal/+freebsd.ha b/unix/signal/+freebsd.ha @@ -5,20 +5,20 @@ use rt; // Configures a new signal handler, returning the old details (which can be // passed to [[restore]] to restore its behavior). // -// The variadic parameters specify either [[flags]] to enable or a signal mask +// The variadic parameters specify either [[flag]]s to enable or a signal mask // to use via [[sigset]]; if the latter is provided no more than one may be // used. export fn handle( signum: signal, handler: *handler, - opt: (flags | sigset)... + opt: (flag | sigset)... ) sigaction = { let sa_mask = newsigset(); let sa_flags = 0, nmask = 0; for (let i = 0z; i < len(opt); i += 1) { match (opt[i]) { - case let flag: flags => + case let flag: flag => sa_flags |= flag: int; case let mask: sigset => assert(nmask == 0, "Multiple signal masks provided to signal::handle"); @@ -258,7 +258,7 @@ export type code = enum int { }; // Flags used to configure the behavior of a signal handler. -export type flags = enum int { +export type flag = enum int { // For use with [[SIGCHLD]]. Prevents notifications when child processes // stop (e.g. via [[SIGSTOP]]) or resume (i.e. [[SIGCONT]]). NOCLDSTOP = rt::SA_NOCLDSTOP: int, diff --git a/unix/signal/+linux.ha b/unix/signal/+linux.ha @@ -7,20 +7,20 @@ use rt; // Configures a new signal handler, returning the old details (which can be // passed to [[restore]] to restore its behavior). // -// The variadic parameters specify either [[flags]] to enable or a signal mask +// The variadic parameters specify either [[flag]]s to enable or a signal mask // to use via [[sigset]]; if the latter is provided no more than one may be // used. export fn handle( signum: signal, handler: *handler, - opt: (flags | sigset)... + opt: (flag | sigset)... ) sigaction = { let sa_mask = newsigset(); let sa_flags = 0u64, nmask = 0; for (let i = 0z; i < len(opt); i += 1) { match (opt[i]) { - case let flag: flags => + case let flag: flag => sa_flags |= flag: u64; case let mask: sigset => assert(nmask == 0, "Multiple signal masks provided to signal::handle"); @@ -267,7 +267,7 @@ export type code = enum int { }; // Flags used to configure the behavior of a signal handler. -export type flags = enum int { +export type flag = enum int { // For use with [[SIGCHLD]]. Prevents notifications when child processes // stop (e.g. via [[SIGSTOP]]) or resume (i.e. [[SIGCONT]]). NOCLDSTOP = rt::SA_NOCLDSTOP: int, diff --git a/unix/tty/+freebsd/open.ha b/unix/tty/+freebsd/open.ha @@ -9,7 +9,7 @@ use os; // Returns a stream connected to the TTY of the current process. The caller must // close it using [[io::close]]. export fn open() (io::file | error) = { - match (os::open("/dev/tty", fs::flags::RDWR)) { + match (os::open("/dev/tty", fs::flag::RDWR)) { case let f: io::file => return f; case fs::error => diff --git a/unix/tty/+freebsd/pty.ha b/unix/tty/+freebsd/pty.ha @@ -21,7 +21,7 @@ fn open_master() (io::file | fs::error) = { // Returns a file descriptor referring to the pseudoterminal slave for a // pseudoterminal master. fn get_slave(master: io::file) (io::file | fs::error) = - os::open(ptsname(master)?, fs::flags::RDWR); + os::open(ptsname(master)?, fs::flag::RDWR); // Returns the filename of the pseudoterminal slave. export fn ptsname(master: io::file) (str | error) = { diff --git a/unix/tty/+linux/open.ha b/unix/tty/+linux/open.ha @@ -11,7 +11,7 @@ use os; // Returns a stream connected to the TTY of the current process. The caller must // close it using [[io::close]]. export fn open() (io::file | error) = { - match (os::open("/dev/tty", fs::flags::RDWR)) { + match (os::open("/dev/tty", fs::flag::RDWR)) { case let f: io::file => return f; case fs::error => diff --git a/unix/tty/+linux/pty.ha b/unix/tty/+linux/pty.ha @@ -9,7 +9,7 @@ use rt; // Opens an available pseudoterminal master. fn open_master() (io::file | fs::error) = { - return os::open("/dev/ptmx", fs::flags::RDWR); + return os::open("/dev/ptmx", fs::flag::RDWR); }; // Returns a file descriptor referring to the pseudoterminal slave for a