}
// Semi-useful shortcut for adding something to an array.
-#operator << macro (arr: [..] $T, v: T) do #this_package.push(&arr, v);
+#operator << macro (arr: [..] $T, v: T) {
+ #this_package.push(&arr, v)
+}
#doc """
}
}
-#operator << macro (b: Bucket_Array($T), elem: T) do #this_package.push(&b, elem);
+#operator << macro (b: Bucket_Array($T), elem: T) {
+ #this_package.push(&b, elem)
+}
pop :: (use b: &Bucket_Array($T)) {
last_bucket := &buckets[buckets.count - 1];
shift_up(heap, data.count - 1);
}
-#operator << macro (heap: Heap($T), v: T) do #this_package.insert(&heap, v);
+#operator << macro (heap: Heap($T), v: T) {
+ #this_package.insert(&heap, v)
+}
remove_top :: (use heap: &Heap) -> heap.T {
x := data[0];
if full(set) do grow(set);
}
-#operator << macro (set: Set($T), value: T) do #this_package.insert(&set, value);
+#operator << macro (set: Set($T), value: T) {
+ #this_package.insert(&set, value)
+}
has :: (use set: &Set, value: set.Elem_Type) -> bool {
lr := lookup(set, value);
for i in 0 .. 16 {
j := 4 * i;
- m[i] = (cast(u32, data[j]) << 24)
- | (cast(u32, data[j + 1]) << 16)
- | (cast(u32, data[j + 2]) << 8)
- | (cast(u32, data[j + 3]));
+ m[i] = (cast(u32, data[j]) << 24) |
+ (cast(u32, data[j + 1]) << 16) |
+ (cast(u32, data[j + 2]) << 8) |
+ (cast(u32, data[j + 3]));
}
for i in 16 .. 64 {
while count < end {
curr := buffer[count];
- if (curr >= #char "a" && curr <= #char "z")
- || (curr >= #char "A" && curr <= #char "Z")
- || curr == #char "_" {
+ if (curr >= #char "a" && curr <= #char "z") ||
+ (curr >= #char "A" && curr <= #char "Z") ||
+ curr == #char "_" {
count += 1;
} elseif numeric_allowed && (curr >= #char "0" && curr <= #char "9") {
count += 1;
count := start;
while count < end {
curr := buffer[count];
- if (curr >= #char "a" && curr <= #char "z")
- || (curr >= #char "A" && curr <= #char "Z")
- || curr == #char "_" {
+ if (curr >= #char "a" && curr <= #char "z") ||
+ (curr >= #char "A" && curr <= #char "Z") ||
+ curr == #char "_" {
count += 1;
} elseif numeric_allowed && (curr >= #char "0" && curr <= #char "9") {
count += 1;
is_nan :: (x: f32) -> bool {
v := x;
i := *cast(&u32) &v;
- return (i & 0x7f800000) == 0x7f800000
- && (i & 0x007fffff) != 0;
+ return (i & 0x7f800000) == 0x7f800000 &&
+ (i & 0x007fffff) != 0;
}
#overload
is_nan :: (x: f64) -> bool {
v := x;
i := *cast(&u64) &v;
- return (i & 0x7ff0000000000000) == 0x7ff0000000000000
- && (i & 0x000fffffffffffff) != 0;
+ return (i & 0x7ff0000000000000) == 0x7ff0000000000000 &&
+ (i & 0x000fffffffffffff) != 0;
}
is_inf :: (x: f32) -> bool {
v := x;
i := *cast(&u32) &v;
- return (i & 0x7f800000) == 0x7f800000
- && (i & 0x007fffff) == 0;
+ return (i & 0x7f800000) == 0x7f800000 &&
+ (i & 0x007fffff) == 0;
}
#overload
is_inf :: (x: f64) -> bool {
v := x;
i := *cast(&u64) &v;
- return (i & 0x7ff0000000000000) == 0x7ff0000000000000
- && (i & 0x000fffffffffffff) == 0;
+ return (i & 0x7ff0000000000000) == 0x7ff0000000000000 &&
+ (i & 0x000fffffffffffff) == 0;
}
false and are true if one or more of the option values are present.
"""
arg_parse :: (c_args: [] cstr, output: any) -> bool {
- arg_iter := iter.as_iter(c_args)
- |> iter.map(string.from_cstr);
+ arg_iter := iter.as_iter(c_args) |>
+ iter.map(string.from_cstr);
defer arg_iter.close(arg_iter.data);
use runtime.info {*};
#inject u8 {
is_alpha :: (c: u8) -> bool {
- return (c >= #char "A" && c <= #char "Z")
- || (c >= #char "a" && c <= #char "z");
+ return (c >= #char "A" && c <= #char "Z") ||
+ (c >= #char "a" && c <= #char "z");
}
is_num :: (c: u8) -> bool {
#overload
strip_whitespace :: (s: str) =>
- s |> strip_leading_whitespace()
- |> strip_trailing_whitespace()
+ s |> strip_leading_whitespace() |> strip_trailing_whitespace()
strip_leading_whitespace :: #match #local {}
//
// Creates a StringPool capable of storing a string of at
// most `maximum_string_length` bytes.
-pool_make :: (maximum_string_length := 16384, allocator := context.allocator)
- => StringPool.{
+pool_make :: (maximum_string_length := 16384, allocator := context.allocator) =>
+ StringPool.{
arena.make(allocator, maximum_string_length)
}
mi := cast(i64, tm.min);
s := cast(i64, tm.sec);
- return (365 * y + y / 4 - y / 100 + y / 400 + 3 * (m + 1) / 5 + 30 * m + d - 719561) * 86400
- + 3600 * h
- + 60 * mi
- + s;
+ return (365 * y + y / 4 - y / 100 + y / 400 + 3 * (m + 1) / 5 + 30 * m + d - 719561) * 86400 +
+ 3600 * h +
+ 60 * mi +
+ s;
}