mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
Remove u128 and i128
This commit is contained in:
+21
-36
@@ -65,14 +65,9 @@ write_rune :: proc(buf: ^String_Buffer, r: rune) {
|
||||
write_bytes(buf, b[..n]);
|
||||
}
|
||||
|
||||
write_i128 :: proc(buf: ^String_Buffer, i: i128, base: int) {
|
||||
b: [129]byte;
|
||||
s := strconv.append_bits(b[..], u128(i), base, true, 128, strconv.digits, 0);
|
||||
write_string(buf, s);
|
||||
}
|
||||
write_i64 :: proc(buf: ^String_Buffer, i: i64, base: int) {
|
||||
b: [129]byte;
|
||||
s := strconv.append_bits(b[..], u128(i), base, true, 64, strconv.digits, 0);
|
||||
s := strconv.append_bits(b[..], u64(i), base, true, 64, strconv.digits, 0);
|
||||
write_string(buf, s);
|
||||
}
|
||||
|
||||
@@ -418,8 +413,8 @@ fmt_write_padding :: proc(fi: ^Fmt_Info, width: int) {
|
||||
}
|
||||
}
|
||||
|
||||
_fmt_int :: proc(fi: ^Fmt_Info, u: u128, base: int, is_signed: bool, bit_size: int, digits: string) {
|
||||
_, neg := strconv.is_integer_negative(u128(u), is_signed, bit_size);
|
||||
_fmt_int :: proc(fi: ^Fmt_Info, u: u64, base: int, is_signed: bool, bit_size: int, digits: string) {
|
||||
_, neg := strconv.is_integer_negative(u, is_signed, bit_size);
|
||||
|
||||
BUF_SIZE :: 256;
|
||||
if fi.width_set || fi.prec_set {
|
||||
@@ -462,14 +457,13 @@ _fmt_int :: proc(fi: ^Fmt_Info, u: u128, base: int, is_signed: bool, bit_size: i
|
||||
if fi.hash && !fi.zero do flags |= strconv.Int_Flag.Prefix;
|
||||
if fi.plus do flags |= strconv.Int_Flag.Plus;
|
||||
if fi.space do flags |= strconv.Int_Flag.Space;
|
||||
s := strconv.append_bits(buf[start..], u128(u), base, is_signed, bit_size, digits, flags);
|
||||
s := strconv.append_bits(buf[start..], u, base, is_signed, bit_size, digits, flags);
|
||||
|
||||
if fi.hash && fi.zero {
|
||||
c: byte;
|
||||
c: byte = 0;
|
||||
switch base {
|
||||
case 2: c = 'b';
|
||||
case 8: c = 'o';
|
||||
// case 10: c = 'd';
|
||||
case 12: c = 'z';
|
||||
case 16: c = 'x';
|
||||
}
|
||||
@@ -494,11 +488,11 @@ fmt_rune :: proc(fi: ^Fmt_Info, r: rune, verb: rune) {
|
||||
case 'c', 'r', 'v':
|
||||
write_rune(fi.buf, r);
|
||||
case:
|
||||
fmt_int(fi, u128(r), false, 32, verb);
|
||||
fmt_int(fi, u64(r), false, 32, verb);
|
||||
}
|
||||
}
|
||||
|
||||
fmt_int :: proc(fi: ^Fmt_Info, u: u128, is_signed: bool, bit_size: int, verb: rune) {
|
||||
fmt_int :: proc(fi: ^Fmt_Info, u: u64, is_signed: bool, bit_size: int, verb: rune) {
|
||||
switch verb {
|
||||
case 'v': _fmt_int(fi, u, 10, is_signed, bit_size, __DIGITS_LOWER);
|
||||
case 'b': _fmt_int(fi, u, 2, is_signed, bit_size, __DIGITS_LOWER);
|
||||
@@ -597,7 +591,7 @@ fmt_string :: proc(fi: ^Fmt_Info, s: string, verb: rune) {
|
||||
if i > 0 && space do write_byte(fi.buf, ' ');
|
||||
char_set := __DIGITS_UPPER;
|
||||
if verb == 'x' do char_set = __DIGITS_LOWER;
|
||||
_fmt_int(fi, u128(s[i]), 16, false, 8, char_set);
|
||||
_fmt_int(fi, u64(s[i]), 16, false, 8, char_set);
|
||||
}
|
||||
|
||||
case:
|
||||
@@ -613,7 +607,7 @@ fmt_pointer :: proc(fi: ^Fmt_Info, p: rawptr, verb: rune) {
|
||||
fmt_bad_verb(fi, verb);
|
||||
return;
|
||||
}
|
||||
u := u128(uintptr(p));
|
||||
u := u64(uintptr(p));
|
||||
if !fi.hash || verb == 'v' {
|
||||
write_string(fi.buf, "0x");
|
||||
}
|
||||
@@ -652,13 +646,11 @@ enum_value_to_string :: proc(v: any) -> (string, bool) {
|
||||
case i16: return get_str(v, e);
|
||||
case i32: return get_str(v, e);
|
||||
case i64: return get_str(v, e);
|
||||
case i128: return get_str(v, e);
|
||||
case int: return get_str(v, e);
|
||||
case u8: return get_str(v, e);
|
||||
case u16: return get_str(v, e);
|
||||
case u32: return get_str(v, e);
|
||||
case u64: return get_str(v, e);
|
||||
case u128: return get_str(v, e);
|
||||
case uint: return get_str(v, e);
|
||||
case uintptr: return get_str(v, e);
|
||||
|
||||
@@ -817,6 +809,7 @@ fmt_value :: proc(fi: ^Fmt_Info, v: any, verb: rune) {
|
||||
|
||||
m := (^raw.Map)(v.data);
|
||||
if m != nil {
|
||||
assert(info.generated_struct != nil);
|
||||
entries := &m.entries;
|
||||
gs := type_info_base(info.generated_struct).variant.(Type_Info_Struct);
|
||||
ed := type_info_base(gs.types[1]).variant.(Type_Info_Dynamic_Array);
|
||||
@@ -893,8 +886,6 @@ fmt_value :: proc(fi: ^Fmt_Info, v: any, verb: rune) {
|
||||
case i32: tag = i64(i);
|
||||
case u64: tag = i64(i);
|
||||
case i64: tag = i64(i);
|
||||
case u128: tag = i64(i);
|
||||
case i128: tag = i64(i);
|
||||
case: panic("Invalid union tag type");
|
||||
}
|
||||
|
||||
@@ -937,10 +928,6 @@ fmt_complex :: proc(fi: ^Fmt_Info, c: complex128, bits: int, verb: rune) {
|
||||
}
|
||||
}
|
||||
|
||||
_u128_to_lo_hi :: proc(a: u128) -> (lo, hi: u64) do return u64(a), u64(a>>64);
|
||||
_i128_to_lo_hi :: proc(a: u128) -> (lo: u64 hi: i64) do return u64(a), i64(a>>64);
|
||||
|
||||
|
||||
fmt_arg :: proc(fi: ^Fmt_Info, arg: any, verb: rune) {
|
||||
if arg == nil {
|
||||
write_string(fi.buf, "<nil>");
|
||||
@@ -971,21 +958,19 @@ fmt_arg :: proc(fi: ^Fmt_Info, arg: any, verb: rune) {
|
||||
case complex64: fmt_complex(fi, complex128(a), 64, verb);
|
||||
case complex128: fmt_complex(fi, a, 128, verb);
|
||||
|
||||
case int: fmt_int(fi, u128(a), true, 8*size_of(int), verb);
|
||||
case i8: fmt_int(fi, u128(a), true, 8, verb);
|
||||
case i16: fmt_int(fi, u128(a), true, 16, verb);
|
||||
case i32: fmt_int(fi, u128(a), true, 32, verb);
|
||||
case i64: fmt_int(fi, u128(a), true, 64, verb);
|
||||
case i128: fmt_int(fi, u128(a), true, 128, verb);
|
||||
case int: fmt_int(fi, u64(a), true, 8*size_of(int), verb);
|
||||
case i8: fmt_int(fi, u64(a), true, 8, verb);
|
||||
case i16: fmt_int(fi, u64(a), true, 16, verb);
|
||||
case i32: fmt_int(fi, u64(a), true, 32, verb);
|
||||
case i64: fmt_int(fi, u64(a), true, 64, verb);
|
||||
|
||||
case uintptr: fmt_int(fi, u128(a), false, 8*size_of(uintptr), verb);
|
||||
case uintptr: fmt_int(fi, u64(a), false, 8*size_of(uintptr), verb);
|
||||
|
||||
case uint: fmt_int(fi, u128(a), false, 8*size_of(uint), verb);
|
||||
case u8: fmt_int(fi, u128(a), false, 8, verb);
|
||||
case u16: fmt_int(fi, u128(a), false, 16, verb);
|
||||
case u32: fmt_int(fi, u128(a), false, 32, verb);
|
||||
case u64: fmt_int(fi, u128(a), false, 64, verb);
|
||||
case u128: fmt_int(fi, u128(a), false, 128, verb);
|
||||
case uint: fmt_int(fi, u64(a), false, 8*size_of(uint), verb);
|
||||
case u8: fmt_int(fi, u64(a), false, 8, verb);
|
||||
case u16: fmt_int(fi, u64(a), false, 16, verb);
|
||||
case u32: fmt_int(fi, u64(a), false, 32, verb);
|
||||
case u64: fmt_int(fi, u64(a), false, 64, verb);
|
||||
|
||||
case string: fmt_string(fi, a, verb);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user