enum, union
This commit is contained in:
@@ -161,10 +161,6 @@ struct_to_string :: (s: $T) -> string {
|
||||
concat(result, "}");
|
||||
}
|
||||
|
||||
enum_to_string :: (e: $T) -> string {
|
||||
concat(".", field_name(T, cast(s64) e));
|
||||
}
|
||||
|
||||
vector_to_string :: (v: $T) -> string {
|
||||
result := "[";
|
||||
i := 0;
|
||||
@@ -205,7 +201,7 @@ pointer_to_string :: (p: $T) -> string {
|
||||
}
|
||||
}
|
||||
|
||||
union_to_string :: (u: $T) -> string {
|
||||
enum_to_string :: (u: $T) -> string {
|
||||
tag := cast(s64) u;
|
||||
result := concat(".", field_name(T, tag));
|
||||
payload := field_value(u, tag);
|
||||
@@ -230,7 +226,6 @@ any_to_string :: (val: Any) -> string {
|
||||
case vector: result = vector_to_string(cast(type) val);
|
||||
case array: result = array_to_string(cast(type) val);
|
||||
case slice: result = slice_to_string(cast(type) val);
|
||||
case union: result = union_to_string(cast(type) val);
|
||||
case pointer: result = pointer_to_string(cast(type) val);
|
||||
case type: { s : string = xx val; result = s; }
|
||||
}
|
||||
@@ -314,7 +309,7 @@ List :: struct ($T: Type) {
|
||||
cap: s64 = 0;
|
||||
}
|
||||
|
||||
append :: (list: *List($T), item: T) {
|
||||
append ::(list: *List($T), item: T) {
|
||||
if list.len >= list.cap {
|
||||
new_cap := if list.cap == 0 then 4 else list.cap * 2;
|
||||
new_items : [*]T = xx malloc(new_cap * size_of(T));
|
||||
|
||||
Reference in New Issue
Block a user