move hide behind @ and specify with :

This commit is contained in:
2026-08-10 22:45:41 +02:00
parent 5244bfbf1b
commit ba6052eef3
27 changed files with 162 additions and 149 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ print func($format []u8, $Args type, args Args) void {
io.print(writer, format, Args, args) catch |_| {}
}
hide write func(_ ?@mut anyopaque, handle io.Handle, bytes []u8) usize ! io.WriteError {
@hide write func(_ ?@mut anyopaque, handle io.Handle, bytes []u8) usize ! io.WriteError {
request usize := bytes.len
maximum usize :: usize(maxval!(c_long))
if request > maximum {
+3 -3
View File
@@ -134,7 +134,7 @@ put func(
}
}
hide normalize func(hash usize) usize {
@hide normalize func(hash usize) usize {
# mapping both 0 and 1 to 1 is safe because equality resolves
# collisions (since hash and key must both be equal).
if (hash == 0) return 1
@@ -143,7 +143,7 @@ hide normalize func(hash usize) usize {
#! FNV-1a hash implementation.
#! note: vulnerable to collision attacks.
hide str_hash func(key []u8) usize {
@hide str_hash func(key []u8) usize {
hash u32 := 2166136261 # offset basis
prime u32 := 16777619
@@ -155,6 +155,6 @@ hide str_hash func(key []u8) usize {
return usize(hash)
}
hide str_eql func(a, b []u8) bool {
@hide str_eql func(a, b []u8) bool {
return mem.eql(a, b)
}
+9 -9
View File
@@ -46,7 +46,7 @@ writer func(file File) Writer {
}
}
hide system_read func(_ ?@mut anyopaque, handle Handle, buffer []mut u8) usize ! ReadError {
@hide system_read func(_ ?@mut anyopaque, handle Handle, buffer []mut u8) usize ! ReadError {
request usize := buffer.len
maximum usize :: usize(maxval!(c_long))
if request > maximum {
@@ -68,7 +68,7 @@ hide system_read func(_ ?@mut anyopaque, handle Handle, buffer []mut u8) usize !
}
}
hide system_write func(_ ?@mut anyopaque, handle Handle, bytes []u8) usize ! WriteError {
@hide system_write func(_ ?@mut anyopaque, handle Handle, bytes []u8) usize ! WriteError {
request usize := bytes.len
maximum usize :: usize(maxval!(c_long))
if request > maximum {
@@ -90,7 +90,7 @@ hide system_write func(_ ?@mut anyopaque, handle Handle, bytes []u8) usize ! Wri
}
}
hide system_open func(_ ?@mut anyopaque, path [;0]u8, mode FileMode) Handle ! OpenError {
@hide system_open func(_ ?@mut anyopaque, path [;0]u8, mode FileMode) Handle ! OpenError {
flags c_int := c.O_RDONLY
match mode {
.read_only: flags = c.O_RDONLY
@@ -108,25 +108,25 @@ hide system_open func(_ ?@mut anyopaque, path [;0]u8, mode FileMode) Handle ! Op
}
}
hide system_close func(_ ?@mut anyopaque, handle Handle) void ! CloseError {
@hide system_close func(_ ?@mut anyopaque, handle Handle) void ! CloseError {
if c.close(handle.file_desc) != 0 {
return .close_failed
}
}
hide system_stdin func(_ ?@mut anyopaque) Handle {
@hide system_stdin func(_ ?@mut anyopaque) Handle {
return Handle {file_desc = c_int(Stream.stdin)}
}
hide system_stdout func(_ ?@mut anyopaque) Handle {
@hide system_stdout func(_ ?@mut anyopaque) Handle {
return Handle {file_desc = c_int(Stream.stdout)}
}
hide system_stderr func(_ ?@mut anyopaque) Handle {
@hide system_stderr func(_ ?@mut anyopaque) Handle {
return Handle {file_desc = c_int(Stream.stderr)}
}
hide system_vtable IoVTable :: IoVTable {
@hide system_vtable IoVTable :: IoVTable {
read = system_read,
write = system_write,
open = system_open,
@@ -136,7 +136,7 @@ hide system_vtable IoVTable :: IoVTable {
stderr = system_stderr,
}
hide system func() Io {
@hide system func() Io {
return Io {
context = null,
vtable = &system_vtable,
+13 -13
View File
@@ -128,7 +128,7 @@ print func(output Writer, $format []u8, $Args type, args Args) void ! WriteError
}
}
hide write_integer_signed func(output Writer, value i64, base u64, uppercase bool) void ! WriteError {
@hide write_integer_signed func(output Writer, value i64, base u64, uppercase bool) void ! WriteError {
buffer [65]mut u8 := undefined
end usize := buffer.len
current i64 := value
@@ -161,7 +161,7 @@ hide write_integer_signed func(output Writer, value i64, base u64, uppercase boo
return
}
hide write_integer_unsigned func(output Writer, value u64, base u64, uppercase bool) void ! WriteError {
@hide write_integer_unsigned func(output Writer, value u64, base u64, uppercase bool) void ! WriteError {
buffer [65]mut u8 := undefined
end usize := buffer.len
current u64 := value
@@ -184,7 +184,7 @@ hide write_integer_unsigned func(output Writer, value u64, base u64, uppercase b
return
}
hide FormatTokenKind :: enum {
@hide FormatTokenKind :: enum {
unused
literal
default
@@ -198,14 +198,14 @@ hide FormatTokenKind :: enum {
scientific
}
hide FormatToken :: struct {
@hide FormatToken :: struct {
kind FormatTokenKind
start usize
end usize
field []u8
}
hide parse_format func($N usize, $format []u8, $Args type) [N]mut FormatToken {
@hide parse_format func($N usize, $format []u8, $Args type) [N]mut FormatToken {
tokens [N]mut FormatToken := undefined
for (usize(0))..format.len |index| {
tokens[index] = FormatToken {kind = .unused, start = 0, end = 0, field = ""}
@@ -310,17 +310,17 @@ hide parse_format func($N usize, $format []u8, $Args type) [N]mut FormatToken {
return tokens
}
hide format_field_name func($T type, index usize) []u8 {
@hide format_field_name func($T type, index usize) []u8 {
match typeinfo!(T) {
.record |record|: return record.fields[index].name
else: compile_error!("io.print arguments must be a tuple")
}
}
hide distinct_value func($Backing, $Distinct type, value Distinct) Backing {
@hide distinct_value func($Backing, $Distinct type, value Distinct) Backing {
return ptrcast!(Backing, &value)^
}
hide scalar_or_distinct_type func($T type) bool {
@hide scalar_or_distinct_type func($T type) bool {
match typeinfo!(T) {
.bool: return true
.integer: return true
@@ -332,7 +332,7 @@ hide scalar_or_distinct_type func($T type) bool {
hide write_integer func(output Writer, $T type, value T, base u64, uppercase bool) void ! WriteError {
@hide write_integer func(output Writer, $T type, value T, base u64, uppercase bool) void ! WriteError {
match typeinfo!(T) {
.integer: if minval!(T) < 0 {
try write_integer_signed(output, i64(value), base, uppercase)
@@ -350,7 +350,7 @@ hide write_integer func(output Writer, $T type, value T, base u64, uppercase boo
}
# note: libc keeps float formatting small; replace it with a native shortest-roundtrip writer if locale independence matters.
hide write_float func(output Writer, $T type, value T, scientific bool) void ! WriteError {
@hide write_float func(output Writer, $T type, value T, scientific bool) void ! WriteError {
match typeinfo!(T) {
.float: {
buffer [64]mut u8 := undefined
@@ -381,7 +381,7 @@ hide write_float func(output Writer, $T type, value T, scientific bool) void ! W
return
}
hide write_decimal func(output Writer, $T type, value T) void ! WriteError {
@hide write_decimal func(output Writer, $T type, value T) void ! WriteError {
match typeinfo!(T) {
.integer: try write_integer(output, value, 10, false)
.float: try write_float(output, value, false)
@@ -395,7 +395,7 @@ hide write_decimal func(output Writer, $T type, value T) void ! WriteError {
return
}
hide write_character func(output Writer, $T type, value T) void ! WriteError {
@hide write_character func(output Writer, $T type, value T) void ! WriteError {
match typeinfo!(T) {
.integer: {
if minval!(T) < 0 or maxval!(T) > 255 {
@@ -414,7 +414,7 @@ hide write_character func(output Writer, $T type, value T) void ! WriteError {
return
}
hide write_default func(output Writer, $T type, value T) void ! WriteError {
@hide write_default func(output Writer, $T type, value T) void ! WriteError {
match typeinfo!(T) {
.bool: if value {
try write_all(output, "true")
+7 -7
View File
@@ -119,11 +119,11 @@ empty func($T type) []mut T {
return empty_slice(T, 0)
}
hide empty_storage [1]mut u64 := [0]
@hide empty_storage [1]mut u64 := [0]
hide malloc_alignment usize :: 16 # ponytail: aarch64-macos libc malloc alignment assumption.
@hide malloc_alignment usize :: 16 # ponytail: aarch64-macos libc malloc alignment assumption.
hide power_of_two func(value usize) bool {
@hide power_of_two func(value usize) bool {
if (value == 0) return false
current usize := value
while current > 1 {
@@ -134,7 +134,7 @@ hide power_of_two func(value usize) bool {
return true
}
hide c_alloc func(_ ?@mut anyopaque, size usize, alignment usize) ?*mut u8 {
@hide c_alloc func(_ ?@mut anyopaque, size usize, alignment usize) ?*mut u8 {
if (power_of_two(alignment) == false) return null
if alignment <= malloc_alignment {
@@ -148,7 +148,7 @@ hide c_alloc func(_ ?@mut anyopaque, size usize, alignment usize) ?*mut u8 {
return ptrcast!(u8, memory[0])
}
hide c_realloc func(_ ?@mut anyopaque, memory ?*mut u8, old_size usize, new_size usize, alignment usize) ?*mut u8 {
@hide c_realloc func(_ ?@mut anyopaque, memory ?*mut u8, old_size usize, new_size usize, alignment usize) ?*mut u8 {
if (power_of_two(alignment) == false) return null
if new_size == 0 {
@@ -174,11 +174,11 @@ hide c_realloc func(_ ?@mut anyopaque, memory ?*mut u8, old_size usize, new_size
return c_alloc(null, new_size, alignment)
}
hide c_free func(_ ?@mut anyopaque, memory ?*mut u8, _ usize, _ usize) void {
@hide c_free func(_ ?@mut anyopaque, memory ?*mut u8, _ usize, _ usize) void {
c.free(memory)
}
hide c_vtable AllocatorVTable :: AllocatorVTable {
@hide c_vtable AllocatorVTable :: AllocatorVTable {
alloc = c_alloc,
realloc = c_realloc,
free = c_free,
+2 -2
View File
@@ -13,13 +13,13 @@ TestOuter :: distinct TestInner
TestOuterAlias :: alias TestOuter
hide array_info_matches func($Array, $Child type, $len usize) bool {
@hide array_info_matches func($Array, $Child type, $len usize) bool {
match typeinfo!(Array) {
.array |info|: return info.child == Child and info.len == len
else: return false
}
}
hide distinct_info_matches func($Distinct, $Backing type) bool {
@hide distinct_info_matches func($Distinct, $Backing type) bool {
match typeinfo!(Distinct) {
.distinct |backing|: return backing == Backing
else: return false
+1 -1
View File
@@ -10,7 +10,7 @@ StaticStringMap func($V type) type {
}
}
hide Pair func($V type) type {
@hide Pair func($V type) type {
return struct { []u8, V }
}