Add .hash to integer types. Fixup of make and tmake. Updated map.c3 to become a working example. Fix bug in subarray -> pointer conversion. Search extension methods in std::core. Fix slice <-> slice copy.

This commit is contained in:
Christoffer Lerno
2022-09-21 10:08:37 +02:00
committed by Christoffer Lerno
parent 4d5821408d
commit ad18d9ba48
18 changed files with 836 additions and 108 deletions

View File

@@ -147,3 +147,13 @@ macro bool @convertible(#expr, $To) @builtin
{
return $checks($To x = #expr);
}
macro uint int.hash(int i) = i;
macro uint uint.hash(uint i) = i;
macro uint short.hash(short s) = s;
macro uint ushort.hash(ushort s) = s;
macro uint char.hash(char c) = c;
macro uint ichar.hash(ichar c) = c;
macro uint long.hash(long i) = (uint)((i >> 32) ^ i);
macro uint ulong.hash(ulong i) = (uint)((i >> 32) ^ i);
macro uint bool.hash(bool b) = (uint)b;

View File

@@ -26,7 +26,7 @@ macro talloc($Type, usize elements)
**/
macro make($Type, usize elements)
{
$Type* ptr = calloc($sizeof($Type) * elements);
$Type* ptr = calloc($Type.sizeof * elements);
return ptr[:elements];
}
@@ -35,6 +35,6 @@ macro make($Type, usize elements)
**/
macro tmake($Type, usize elements)
{
$Type* ptr = tcalloc($sizeof($Type) * elements, $alignof($Type[1]));
$Type* ptr = tcalloc($Type.sizeof * elements, $alignof($Type[1]));
return ptr[:elements];
}