Allow for overloading of polymorphic procedures

This commit is contained in:
Ginger Bill
2017-07-04 22:42:25 +01:00
parent 689a0c0b49
commit 188bc28f6a
11 changed files with 203 additions and 122 deletions
+10 -10
View File
@@ -191,7 +191,7 @@ parse_f64 :: proc(s: string) -> f64 {
append_bool :: proc(buf: []u8, b: bool) -> string {
s := b ? "true" : "false";
append(buf, ..[]u8(s));
append(&buf, ..[]u8(s));
return string(buf);
}
@@ -257,7 +257,7 @@ generic_ftoa :: proc(buf: []u8, val: f64, fmt: u8, prec, bit_size: int) -> []u8
} else {
s = "+Inf";
}
append(buf, ..[]u8(s));
append(&buf, ..[]u8(s));
return buf;
case 0: // denormalized
@@ -304,29 +304,29 @@ generic_ftoa :: proc(buf: []u8, val: f64, fmt: u8, prec, bit_size: int) -> []u8
format_digits :: proc(buf: []u8, shortest: bool, neg: bool, digs: DecimalSlice, prec: int, fmt: u8) -> []u8 {
match fmt {
case 'f', 'F':
append(buf, neg ? '-' : '+');
append(&buf, neg ? '-' : '+');
// integer, padded with zeros when needed
if digs.decimal_point > 0 {
m := min(digs.count, digs.decimal_point);
append(buf, ..digs.digits[0..<m]);
append(&buf, ..digs.digits[0..<m]);
for ; m < digs.decimal_point; m++ {
append(buf, '0');
append(&buf, '0');
}
} else {
append(buf, '0');
append(&buf, '0');
}
// fractional part
if prec > 0 {
append(buf, '.');
append(&buf, '.');
for i in 0..<prec {
c: u8 = '0';
if j := digs.decimal_point + i; 0 <= j && j < digs.count {
c = digs.digits[j];
}
append(buf, c);
append(&buf, c);
}
}
@@ -342,7 +342,7 @@ format_digits :: proc(buf: []u8, shortest: bool, neg: bool, digs: DecimalSlice,
}
c := [2]u8{'%', fmt};
append(buf, ..c[..]);
append(&buf, ..c[..]);
return buf;
}
@@ -492,7 +492,7 @@ append_bits :: proc(buf: []u8, u: u128, base: int, is_signed: bool, bit_size: in
i--; a[i] = ' ';
}
append(buf, ..a[i..]);
append(&buf, ..a[i..]);
return string(buf);
}