mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-02 12:48:14 +00:00
Change uses for parapoly records to use $ always
This commit is contained in:
@@ -3,7 +3,7 @@ package container
|
|||||||
import "core:mem"
|
import "core:mem"
|
||||||
import "core:runtime"
|
import "core:runtime"
|
||||||
|
|
||||||
Array :: struct(T: typeid) {
|
Array :: struct($T: typeid) {
|
||||||
data: ^T,
|
data: ^T,
|
||||||
len: int,
|
len: int,
|
||||||
cap: int,
|
cap: int,
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ import "intrinsics"
|
|||||||
_ :: intrinsics;
|
_ :: intrinsics;
|
||||||
|
|
||||||
|
|
||||||
Map :: struct(Key, Value: typeid) where intrinsics.type_is_valid_map_key(Key) {
|
Map :: struct($Key, $Value: typeid) where intrinsics.type_is_valid_map_key(Key) {
|
||||||
hash: Array(int),
|
hash: Array(int),
|
||||||
entries: Array(Map_Entry(Key, Value)),
|
entries: Array(Map_Entry(Key, Value)),
|
||||||
}
|
}
|
||||||
|
|
||||||
Map_Entry :: struct(Key, Value: typeid) where intrinsics.type_is_valid_map_key(Key) {
|
Map_Entry :: struct($Key, $Value: typeid) where intrinsics.type_is_valid_map_key(Key) {
|
||||||
hash: uintptr,
|
hash: uintptr,
|
||||||
next: int,
|
next: int,
|
||||||
key: Key,
|
key: Key,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package container
|
package container
|
||||||
|
|
||||||
Priority_Queue :: struct(T: typeid) {
|
Priority_Queue :: struct($T: typeid) {
|
||||||
data: Array(T),
|
data: Array(T),
|
||||||
len: int,
|
len: int,
|
||||||
priority: proc(item: T) -> int,
|
priority: proc(item: T) -> int,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package container
|
package container
|
||||||
|
|
||||||
Queue :: struct(T: typeid) {
|
Queue :: struct($T: typeid) {
|
||||||
data: Array(T),
|
data: Array(T),
|
||||||
len: int,
|
len: int,
|
||||||
offset: int,
|
offset: int,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package container
|
package container
|
||||||
|
|
||||||
|
|
||||||
Ring :: struct(T: typeid) {
|
Ring :: struct($T: typeid) {
|
||||||
next, prev: ^Ring(T),
|
next, prev: ^Ring(T),
|
||||||
value: T,
|
value: T,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package container
|
package container
|
||||||
|
|
||||||
Small_Array :: struct(N: int, T: typeid) where N >= 0 {
|
Small_Array :: struct($N: int, $T: typeid) where N >= 0 {
|
||||||
data: [N]T,
|
data: [N]T,
|
||||||
len: int,
|
len: int,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import "core:strconv"
|
|||||||
import "intrinsics"
|
import "intrinsics"
|
||||||
_ :: intrinsics;
|
_ :: intrinsics;
|
||||||
|
|
||||||
Fixed :: struct($Backing: typeid, Fraction_Width: uint)
|
Fixed :: struct($Backing: typeid, $Fraction_Width: uint)
|
||||||
where
|
where
|
||||||
intrinsics.type_is_integer(Backing),
|
intrinsics.type_is_integer(Backing),
|
||||||
0 <= Fraction_Width,
|
0 <= Fraction_Width,
|
||||||
|
|||||||
@@ -919,7 +919,7 @@ tracking_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode,
|
|||||||
// Small_Allocator primary allocates memory from its local buffer of size BUFFER_SIZE
|
// Small_Allocator primary allocates memory from its local buffer of size BUFFER_SIZE
|
||||||
// If that buffer's memory is exhausted, it will use the backing allocator (a scratch allocator is recommended)
|
// If that buffer's memory is exhausted, it will use the backing allocator (a scratch allocator is recommended)
|
||||||
// Memory allocated with Small_Allocator cannot be freed individually using 'free' and must be freed using 'free_all'
|
// Memory allocated with Small_Allocator cannot be freed individually using 'free' and must be freed using 'free_all'
|
||||||
Small_Allocator :: struct(BUFFER_SIZE: int)
|
Small_Allocator :: struct($BUFFER_SIZE: int)
|
||||||
where
|
where
|
||||||
BUFFER_SIZE >= 2*size_of(uintptr),
|
BUFFER_SIZE >= 2*size_of(uintptr),
|
||||||
BUFFER_SIZE & (BUFFER_SIZE-1) == 0 {
|
BUFFER_SIZE & (BUFFER_SIZE-1) == 0 {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import "core:mem"
|
|||||||
_ :: runtime;
|
_ :: runtime;
|
||||||
_ :: mem;
|
_ :: mem;
|
||||||
|
|
||||||
Map_Entry_Info :: struct(Key, Value: typeid) {
|
Map_Entry_Info :: struct($Key, $Value: typeid) {
|
||||||
hash: uintptr,
|
hash: uintptr,
|
||||||
key: Key,
|
key: Key,
|
||||||
value: Value,
|
value: Value,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package runtime
|
|||||||
import "intrinsics"
|
import "intrinsics"
|
||||||
|
|
||||||
@builtin
|
@builtin
|
||||||
Maybe :: union(T: typeid) #maybe {T};
|
Maybe :: union($T: typeid) #maybe {T};
|
||||||
|
|
||||||
@thread_local global_default_temp_allocator_data: Default_Temp_Allocator;
|
@thread_local global_default_temp_allocator_data: Default_Temp_Allocator;
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -27,12 +27,12 @@ map_values :: proc(m: $M/map[$K]$V, allocator := context.allocator) -> (values:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Map_Entry :: struct(Key, Value: typeid) {
|
Map_Entry :: struct($Key, $Value: typeid) {
|
||||||
key: Key,
|
key: Key,
|
||||||
value: Value,
|
value: Value,
|
||||||
}
|
}
|
||||||
|
|
||||||
Map_Entry_Info :: struct(Key, Value: typeid) {
|
Map_Entry_Info :: struct($Key, $Value: typeid) {
|
||||||
hash: uintptr,
|
hash: uintptr,
|
||||||
key: Key,
|
key: Key,
|
||||||
value: Value,
|
value: Value,
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ Channel_Direction :: enum i8 {
|
|||||||
Recv = -1,
|
Recv = -1,
|
||||||
}
|
}
|
||||||
|
|
||||||
Channel :: struct(T: typeid, Direction := Channel_Direction.Both) {
|
Channel :: struct($T: typeid, $Direction := Channel_Direction.Both) {
|
||||||
using _internal: ^Raw_Channel,
|
using _internal: ^Raw_Channel,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -898,14 +898,14 @@ parametric_polymorphism :: proc() {
|
|||||||
|
|
||||||
|
|
||||||
{ // Polymorphic Types and Type Specialization
|
{ // Polymorphic Types and Type Specialization
|
||||||
Table_Slot :: struct(Key, Value: typeid) {
|
Table_Slot :: struct($Key, $Value: typeid) {
|
||||||
occupied: bool,
|
occupied: bool,
|
||||||
hash: u32,
|
hash: u32,
|
||||||
key: Key,
|
key: Key,
|
||||||
value: Value,
|
value: Value,
|
||||||
};
|
};
|
||||||
TABLE_SIZE_MIN :: 32;
|
TABLE_SIZE_MIN :: 32;
|
||||||
Table :: struct(Key, Value: typeid) {
|
Table :: struct($Key, $Value: typeid) {
|
||||||
count: int,
|
count: int,
|
||||||
allocator: mem.Allocator,
|
allocator: mem.Allocator,
|
||||||
slots: []Table_Slot(Key, Value),
|
slots: []Table_Slot(Key, Value),
|
||||||
@@ -1042,7 +1042,7 @@ parametric_polymorphism :: proc() {
|
|||||||
Foo2,
|
Foo2,
|
||||||
Foo3,
|
Foo3,
|
||||||
};
|
};
|
||||||
Para_Union :: union(T: typeid) {T, Error};
|
Para_Union :: union($T: typeid) {T, Error};
|
||||||
r: Para_Union(int);
|
r: Para_Union(int);
|
||||||
fmt.println(typeid_of(type_of(r)));
|
fmt.println(typeid_of(type_of(r)));
|
||||||
|
|
||||||
@@ -1594,7 +1594,7 @@ where_clauses :: proc() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{ // Record types
|
{ // Record types
|
||||||
Foo :: struct(T: typeid, N: int)
|
Foo :: struct($T: typeid, $N: int)
|
||||||
where intrinsics.type_is_integer(T),
|
where intrinsics.type_is_integer(T),
|
||||||
N > 2 {
|
N > 2 {
|
||||||
x: [N]T,
|
x: [N]T,
|
||||||
@@ -1949,7 +1949,8 @@ constant_literal_expressions :: proc() {
|
|||||||
union_maybe :: proc() {
|
union_maybe :: proc() {
|
||||||
fmt.println("\n#union #maybe");
|
fmt.println("\n#union #maybe");
|
||||||
|
|
||||||
Maybe :: union(T: typeid) #maybe {T};
|
// NOTE: This is already built-in, and this is just a reimplementation to explain the behaviour
|
||||||
|
Maybe :: union($T: typeid) #maybe {T};
|
||||||
|
|
||||||
i: Maybe(u8);
|
i: Maybe(u8);
|
||||||
p: Maybe(^u8); // No tag is stored for pointers, nil is the sentinel value
|
p: Maybe(^u8); // No tag is stored for pointers, nil is the sentinel value
|
||||||
|
|||||||
Reference in New Issue
Block a user