diff options
| author | gingerBill <bill@gingerbill.org> | 2018-12-02 15:53:52 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2018-12-02 15:53:52 +0000 |
| commit | 00161023cda147daa5638539df5d46fb18aebfa6 (patch) | |
| tree | b2b811d47b9306e273382f4840c6c3ae9e6099ca /core | |
| parent | 784c48c9e36c11595b23fb0df002c063dd42a2bf (diff) | |
Endian specific integers: e.g. i32 i32le i32be
Diffstat (limited to 'core')
| -rw-r--r-- | core/fmt/fmt.odin | 15 | ||||
| -rw-r--r-- | core/runtime/core.odin | 8 |
2 files changed, 22 insertions, 1 deletions
diff --git a/core/fmt/fmt.odin b/core/fmt/fmt.odin index 4de8cb314..202a65ebb 100644 --- a/core/fmt/fmt.odin +++ b/core/fmt/fmt.odin @@ -3,6 +3,7 @@ package fmt import "core:runtime" import "core:os" import "core:mem" +import "core:bits" import "core:unicode/utf8" import "core:types" import "core:strconv" @@ -1279,6 +1280,20 @@ fmt_arg :: proc(fi: ^Fmt_Info, arg: any, verb: rune) { case typeid: write_typeid(fi.buf, a); + case i16le: fmt_int(fi, u64(a), true, 16, verb); + case u16le: fmt_int(fi, u64(a), false, 16, verb); + case i32le: fmt_int(fi, u64(a), true, 32, verb); + case u32le: fmt_int(fi, u64(a), false, 32, verb); + case i64le: fmt_int(fi, u64(a), true, 64, verb); + case u64le: fmt_int(fi, u64(a), false, 64, verb); + + case i16be: fmt_int(fi, u64(a), true, 16, verb); + case u16be: fmt_int(fi, u64(a), false, 16, verb); + case i32be: fmt_int(fi, u64(a), true, 32, verb); + case u32be: fmt_int(fi, u64(a), false, 32, verb); + case i64be: fmt_int(fi, u64(a), true, 64, verb); + case u64be: fmt_int(fi, u64(a), false, 64, verb); + case: fmt_value(fi, arg, verb); } diff --git a/core/runtime/core.odin b/core/runtime/core.odin index 42cb68aee..679fee1b0 100644 --- a/core/runtime/core.odin +++ b/core/runtime/core.odin @@ -40,9 +40,15 @@ Type_Info_Enum_Value :: union { u8, u16, u32, u64, uint, uintptr, }; +Type_Info_Endianness :: enum u8 { + Platform = 0, + Little = 1, + Big = 2, +} + // Variant Types Type_Info_Named :: struct {name: string, base: ^Type_Info}; -Type_Info_Integer :: struct {signed: bool}; +Type_Info_Integer :: struct {signed: bool, endianness: Type_Info_Endianness}; Type_Info_Rune :: struct {}; Type_Info_Float :: struct {}; Type_Info_Complex :: struct {}; |