Void* should never deref and should allow methods to be attached to it.

This commit is contained in:
Christoffer Lerno
2023-10-27 00:10:59 +02:00
parent a0bc03a9f5
commit e17bb5f321
7 changed files with 11 additions and 13 deletions

View File

@@ -362,6 +362,7 @@ macro uint bool.hash(bool b) => (uint)b;
macro uint typeid.hash(typeid t) => ((ulong)(uptr)t).hash();
macro uint String.hash(String c) => (uint)fnv32a::encode(c);
macro uint char[].hash(char[] c) => (uint)fnv32a::encode(c);
macro uint void*.hash(void* ptr) => ((ulong)(uptr)ptr).hash();
module std::core::builtin @if((env::LINUX || env::DARWIN) && env::COMPILER_SAFE_MODE && env::DEBUG_SYMBOLS);
import libc;

View File

@@ -282,10 +282,10 @@ macro void DString.append(&self, value)
self.append_char32(value);
$default:
$switch
$case $assignable(value, Char32):
self.append_char32(value);
$case $assignable(value, String):
self.append_chars(value);
$case $defined((Char32)value):
self.append_char32((Char32)value);
$case $defined((String)value):
self.append_chars((String)value);
$default:
$error "Unsupported type for append use printf instead.";
$endswitch

View File

@@ -136,7 +136,7 @@ macro usz! print_gen(self, x)
$case DString:
return self.write(x.str_view());
$default:
$if $assignable(x, String):
$if $defined((String)x):
return self.write((String)x);
$else
return printf("%s", x);