replace leading _ for private symbols with keyword hide

This commit is contained in:
2026-07-14 20:19:01 +02:00
parent 5157cf3bcc
commit 267947e79d
31 changed files with 125220 additions and 122709 deletions
+4 -4
View File
@@ -1,13 +1,13 @@
_sibling func() i32 {
hide sibling func() i32 {
return 1
}
_Sibling :: struct {
hide Sibling :: struct {
value i32
}
_sibling_value :: 1
hide sibling_value :: 1
_collision c_func() i32 {
collision c_func() i32 {
return 1
}
+5 -5
View File
@@ -1,17 +1,17 @@
import "../dep"
_collision func() i32 {
hide collision func() i32 {
return 2
}
read_sibling func(value _Sibling) i32 {
return value.value + _sibling_value
read_sibling func(value Sibling) i32 {
return value.value + sibling_value
}
read_sibling_value func() i32 {
return _sibling_value
return sibling_value
}
main func() i32 {
return _sibling() + dep._secret() + read_sibling(_Sibling { value = 1 }) + read_sibling_value()
return sibling() + dep.secret() + read_sibling(Sibling { value = 1 }) + read_sibling_value()
}
+1 -1
View File
@@ -1,3 +1,3 @@
_secret func() i32 {
hide secret c_func() i32 {
return 1
}
+30 -8
View File
@@ -1,14 +1,27 @@
_Thing :: struct {
hide helper func() i32 {
thing Thing = Thing { value = value }
return thing.value
}
hide Thing :: struct {
value i32
}
_value :: 1
_helper func() i32 {
thing _Thing = _Thing { value = _value }
return thing.value
hide Local_Union :: union {
value i32
}
hide Local_Enum :: enum {
value
}
hide Local_Opaque :: opaque
hide Local_Distinct :: distinct i32
hide Local_Alias :: alias i32
hide value :: 1
hide mutable_value i32 = 1
_foreign c_func() i32 {
return 1
}
@@ -17,6 +30,15 @@ _C_Record :: c_struct {
value c_int
}
from_a func() i32 {
return _helper()
hide local_foreign c_func() i32 {
return 1
}
hide Local_C_Record :: c_struct {
value c_int
}
from_a func() i32 {
record Local_C_Record = Local_C_Record { value = 0 }
return helper() + local_foreign() + i32(record.value)
}
+28 -5
View File
@@ -1,14 +1,37 @@
_Thing :: struct {
import "../dep"
hide Thing :: struct {
value i32
}
_value :: 2
hide Local_Union :: union {
value i32
}
_helper func() i32 {
thing _Thing = _Thing { value = _value }
hide Local_Enum :: enum {
value
}
hide Local_Opaque :: opaque
hide Local_Distinct :: distinct i32
hide Local_Alias :: alias i32
hide value :: 2
hide mutable_value i32 = 2
hide helper func() i32 {
thing Thing = Thing { value = value }
return thing.value
}
hide local_foreign c_func() i32 {
return 1
}
hide Local_C_Record :: c_struct {
value c_int
}
Box :: struct {
_value i32
}
@@ -16,5 +39,5 @@ Box :: struct {
from_b func(_input i32) i32 {
_local Box = Box { _value = _input }
record _C_Record = _C_Record { value = 0 }
return _helper() + _local._value + _foreign() + i32(record.value)
return helper() + _local._value + _foreign() + i32(record.value) + dep._visible()
}
@@ -0,0 +1,3 @@
_visible func() i32 {
return 1
}
+10 -10
View File
@@ -2,25 +2,25 @@ arraylist :: import "@std/arraylist"
mem :: import "@std/mem"
std :: import "@std"
_fail_alloc func(_ ?*mut anyopaque, _ usize, _ usize) ?*mut u8 {
hide fail_alloc func(_ ?*mut anyopaque, _ usize, _ usize) ?*mut u8 {
return none
}
_fail_realloc func(_ ?*mut anyopaque, _ ?*mut u8, _ usize, _ usize, _ usize) ?*mut u8 {
hide fail_realloc func(_ ?*mut anyopaque, _ ?*mut u8, _ usize, _ usize, _ usize) ?*mut u8 {
return none
}
_fail_free func(_ ?*mut anyopaque, _ ?*mut u8, _ usize, _ usize) void {}
hide fail_free func(_ ?*mut anyopaque, _ ?*mut u8, _ usize, _ usize) void {}
_fail_vtable mem.AllocatorVTable :: mem.AllocatorVTable {
alloc = _fail_alloc,
realloc = _fail_realloc,
free = _fail_free,
hide fail_vtable mem.AllocatorVTable :: mem.AllocatorVTable {
alloc = fail_alloc,
realloc = fail_realloc,
free = fail_free,
}
_fail_allocator mem.Allocator :: mem.Allocator {
hide fail_allocator mem.Allocator :: mem.Allocator {
context = none,
vtable = &_fail_vtable,
vtable = &fail_vtable,
}
run func() i32 ! mem.AllocError {
@@ -59,7 +59,7 @@ run func() i32 ! mem.AllocError {
}
if (empty_values.items.len != 1) return 8
failed arraylist.ArrayList(i32) = arraylist.init(i32, _fail_allocator)
failed arraylist.ArrayList(i32) = arraylist.init(i32, fail_allocator)
failed_as_expected bool = false
arraylist.append(&failed, 1) catch |_| {
failed_as_expected = true
+30 -30
View File
@@ -1,6 +1,6 @@
io :: import "@std/io"
_read_ok func(_ ?*mut anyopaque, _ io.ReadStream, buffer []mut u8) usize ! io.ReadError {
hide read_ok func(_ ?*mut anyopaque, _ io.ReadStream, buffer []mut u8) usize ! io.ReadError {
if buffer.len == 0 {
return 0
}
@@ -12,52 +12,52 @@ _read_ok func(_ ?*mut anyopaque, _ io.ReadStream, buffer []mut u8) usize ! io.Re
return 2
}
_read_too_much func(_ ?*mut anyopaque, _ io.ReadStream, buffer []mut u8) usize ! io.ReadError {
hide read_too_much func(_ ?*mut anyopaque, _ io.ReadStream, buffer []mut u8) usize ! io.ReadError {
return buffer.len + 1
}
_read_eof func(_ ?*mut anyopaque, _ io.ReadStream, _ []mut u8) usize ! io.ReadError {
hide read_eof func(_ ?*mut anyopaque, _ io.ReadStream, _ []mut u8) usize ! io.ReadError {
return 0
}
_write_short func(_ ?*mut anyopaque, _ io.WriteStream, bytes []u8) usize ! io.WriteError {
hide write_short func(_ ?*mut anyopaque, _ io.WriteStream, bytes []u8) usize ! io.WriteError {
if bytes.len > 2 {
return 2
}
return bytes.len
}
_write_none func(_ ?*mut anyopaque, _ io.WriteStream, _ []u8) usize ! io.WriteError {
hide write_none func(_ ?*mut anyopaque, _ io.WriteStream, _ []u8) usize ! io.WriteError {
return 0
}
_write_too_much func(_ ?*mut anyopaque, _ io.WriteStream, bytes []u8) usize ! io.WriteError {
hide write_too_much func(_ ?*mut anyopaque, _ io.WriteStream, bytes []u8) usize ! io.WriteError {
return bytes.len + 1
}
_ok_vtable io.IoVTable :: io.IoVTable {
read = _read_ok,
write = _write_short,
hide ok_vtable io.IoVTable :: io.IoVTable {
read = read_ok,
write = write_short,
}
_read_bad_vtable io.IoVTable :: io.IoVTable {
read = _read_too_much,
write = _write_short,
hide read_bad_vtable io.IoVTable :: io.IoVTable {
read = read_too_much,
write = write_short,
}
_eof_vtable io.IoVTable :: io.IoVTable {
read = _read_eof,
write = _write_short,
hide eof_vtable io.IoVTable :: io.IoVTable {
read = read_eof,
write = write_short,
}
_write_none_vtable io.IoVTable :: io.IoVTable {
read = _read_ok,
write = _write_none,
hide write_none_vtable io.IoVTable :: io.IoVTable {
read = read_ok,
write = write_none,
}
_write_bad_vtable io.IoVTable :: io.IoVTable {
read = _read_ok,
write = _write_too_much,
hide write_bad_vtable io.IoVTable :: io.IoVTable {
read = read_ok,
write = write_too_much,
}
reader_for func(vtable @io.IoVTable) io.Reader {
@@ -76,39 +76,39 @@ writer_for func(vtable @io.IoVTable) io.Writer {
rejects_bad_read func() bool {
buffer [1]mut u8 = [0]
_ = io.read(reader_for(&_read_bad_vtable), buffer[..]) catch |err| {
_ = io.read(reader_for(&read_bad_vtable), buffer[..]) catch |err| {
return err == .read_failed
}
return false
}
rejects_no_progress func() bool {
io.write_all(writer_for(&_write_none_vtable), "x") catch |err| {
io.write_all(writer_for(&write_none_vtable), "x") catch |err| {
return err == .no_progress
}
return false
}
rejects_bad_write func() bool {
_ = io.write(writer_for(&_write_bad_vtable), "x") catch |err| {
_ = io.write(writer_for(&write_bad_vtable), "x") catch |err| {
return err == .write_failed
}
return false
}
main func(system io.Io) i32 {
main func(system std.Io) i32 {
buffer [2]mut u8 = [0, 0]
count usize :: io.read(reader_for(&_ok_vtable), buffer[..]) catch 0
count usize :: io.read(reader_for(&ok_vtable), buffer[..]) catch 0
if count != 2 or buffer[0] != 'o' or buffer[1] != 'k' {
return 1
}
eof usize :: io.read(reader_for(&_eof_vtable), buffer[..]) catch 1
empty_read usize :: io.read(reader_for(&_read_bad_vtable), buffer[0..0]) catch 1
empty_write usize :: io.write(writer_for(&_write_bad_vtable), "") catch 1
eof usize :: io.read(reader_for(&eof_vtable), buffer[..]) catch 1
empty_read usize :: io.read(reader_for(&read_bad_vtable), buffer[0..0]) catch 1
empty_write usize :: io.write(writer_for(&write_bad_vtable), "") catch 1
if eof != 0 or empty_read != 0 or empty_write != 0 {
return 5
}
io.write_all(writer_for(&_ok_vtable), "partial") catch |_| {
io.write_all(writer_for(&ok_vtable), "partial") catch |_| {
return 2
}
if !rejects_bad_read() or !rejects_no_progress() or !rejects_bad_write() {
+13 -13
View File
@@ -1,30 +1,30 @@
mem :: import "@std/mem"
_probe_count func(context ?*mut anyopaque) void {
hide probe_count func(context ?*mut anyopaque) void {
if context |raw| {
counts *mut usize :: ptrcast!(usize, raw)
counts[0] += 1
}
}
_probe_alloc func(context ?*mut anyopaque, _ usize, _ usize) ?*mut u8 {
_probe_count(context)
hide probe_alloc func(context ?*mut anyopaque, _ usize, _ usize) ?*mut u8 {
probe_count(context)
return none
}
_probe_realloc func(context ?*mut anyopaque, _ ?*mut u8, _ usize, _ usize, _ usize) ?*mut u8 {
_probe_count(context)
hide probe_realloc func(context ?*mut anyopaque, _ ?*mut u8, _ usize, _ usize, _ usize) ?*mut u8 {
probe_count(context)
return none
}
_probe_free func(context ?*mut anyopaque, _ ?*mut u8, _ usize, _ usize) void {
_probe_count(context)
hide probe_free func(context ?*mut anyopaque, _ ?*mut u8, _ usize, _ usize) void {
probe_count(context)
}
_probe_vtable mem.AllocatorVTable :: mem.AllocatorVTable {
alloc = _probe_alloc,
realloc = _probe_realloc,
free = _probe_free,
hide probe_vtable mem.AllocatorVTable :: mem.AllocatorVTable {
alloc = probe_alloc,
realloc = probe_realloc,
free = probe_free,
}
typed_allocator_test func() i32 {
@@ -34,11 +34,11 @@ typed_allocator_test func() i32 {
second_calls [1]mut usize = [0]
first_allocator mem.Allocator :: mem.Allocator {
context = (&first_calls).ptr,
vtable = &_probe_vtable,
vtable = &probe_vtable,
}
second_allocator mem.Allocator :: mem.Allocator {
context = (&second_calls).ptr,
vtable = &_probe_vtable,
vtable = &probe_vtable,
}
_ = mem.raw_alloc(first_allocator, 1, 1)