From 0190f909799f51762d49c41980ad4718c324b5eb Mon Sep 17 00:00:00 2001 From: Tetralux Date: Fri, 28 Feb 2020 12:22:30 +0000 Subject: [PATCH 1/8] Fix mem.align_backward when pointer is already aligned --- core/mem/mem.odin | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/core/mem/mem.odin b/core/mem/mem.odin index 6dd4e9c27..36313e95b 100644 --- a/core/mem/mem.odin +++ b/core/mem/mem.odin @@ -186,9 +186,7 @@ align_backward :: inline proc(ptr: rawptr, align: uintptr) -> rawptr { align_backward_uintptr :: proc(ptr, align: uintptr) -> uintptr { assert(is_power_of_two(align)); - - ptr := rawptr(ptr - align); - return uintptr(align_forward(ptr, align)); + return align_forward_uintptr(ptr - align + 1, align); } align_backward_int :: inline proc(ptr, align: int) -> int { From 85f2f4aa88a22130c3e261da388addf3a880c0af Mon Sep 17 00:00:00 2001 From: Clay Murray Date: Tue, 3 Mar 2020 19:42:20 -0700 Subject: [PATCH 2/8] Fix issues with stat struct. The stat struct was the format for the 64 bit version of stat. So we need to call stat64 to get the proper data. Also we need to use _File_Time instead of File_Time because it is a compound value. These changes were tested and work on my computer, MacOS 64 bit. --- core/os/os_darwin.odin | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core/os/os_darwin.odin b/core/os/os_darwin.odin index d70a2d1c7..c3e41f90e 100644 --- a/core/os/os_darwin.odin +++ b/core/os/os_darwin.odin @@ -202,10 +202,10 @@ Stat :: struct { gid: u32, // Group ID of the file's group rdev: i32, // Device ID, if device - last_access: File_Time, // Time of last access - modified: File_Time, // Time of last modification - status_change: File_Time, // Time of last status change - created: File_Time, // Time of creation + last_access: _File_Time, // Time of last access + modified: _File_Time, // Time of last modification + status_change: _File_Time, // Time of last status change + created: _File_Time, // Time of creation size: i64, // Size of the file, in bytes blocks: i64, // Number of blocks allocated for the file @@ -273,7 +273,7 @@ foreign libc { @(link_name="lseek") _unix_lseek :: proc(fs: Handle, offset: int, whence: int) -> int ---; @(link_name="gettid") _unix_gettid :: proc() -> u64 ---; @(link_name="getpagesize") _unix_getpagesize :: proc() -> i32 ---; - @(link_name="stat") _unix_stat :: proc(path: cstring, stat: ^Stat) -> int ---; + @(link_name="stat64") _unix_stat :: proc(path: cstring, stat: ^Stat) -> int ---; @(link_name="access") _unix_access :: proc(path: cstring, mask: int) -> int ---; @(link_name="malloc") _unix_malloc :: proc(size: int) -> rawptr ---; From 2817bab494a093b861b33cba982d87d178e80501 Mon Sep 17 00:00:00 2001 From: Tyler Erickson Date: Thu, 5 Mar 2020 12:13:22 -0800 Subject: [PATCH 3/8] Fix os_linux stat --- core/os/os_linux.odin | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/os/os_linux.odin b/core/os/os_linux.odin index 0f244c526..3b66bfd82 100644 --- a/core/os/os_linux.odin +++ b/core/os/os_linux.odin @@ -197,9 +197,9 @@ Stat :: struct { block_size: i64, // Optimal bllocksize for I/O blocks: i64, // Number of 512-byte blocks allocated - last_access: _File_Time, // Time of last access - modified: _File_Time, // Time of last modification - status_change: _File_Time, // Time of last status change + last_access: File_Time, // Time of last access + status_change: File_Time, // Time of last status change + modified: File_Time, // Time of last modification _reserve1, _reserve2, @@ -266,7 +266,7 @@ foreign libc { @(link_name="lseek64") _unix_seek :: proc(fd: Handle, offset: i64, whence: i32) -> i64 ---; @(link_name="gettid") _unix_gettid :: proc() -> u64 ---; @(link_name="getpagesize") _unix_getpagesize :: proc() -> i32 ---; - @(link_name="stat") _unix_stat :: proc(path: cstring, stat: ^Stat) -> int ---; + @(link_name="stat64") _unix_stat :: proc(path: cstring, stat: ^Stat) -> int ---; @(link_name="fstat") _unix_fstat :: proc(fd: Handle, stat: ^Stat) -> int ---; @(link_name="access") _unix_access :: proc(path: cstring, mask: int) -> int ---; @@ -362,7 +362,7 @@ last_write_time :: proc(fd: Handle) -> (File_Time, Errno) { if err != ERROR_NONE { return 0, err; } - return File_Time(s.modified.nanoseconds), ERROR_NONE; + return File_Time(s.modified), ERROR_NONE; } last_write_time_by_name :: proc(name: string) -> (File_Time, Errno) { @@ -370,7 +370,7 @@ last_write_time_by_name :: proc(name: string) -> (File_Time, Errno) { if err != ERROR_NONE { return 0, err; } - return File_Time(s.modified.nanoseconds), ERROR_NONE; + return File_Time(s.modified), ERROR_NONE; } stat :: inline proc(path: string) -> (Stat, Errno) { From f6f2ab2f25f52ce79a27160661b242bc08c0153b Mon Sep 17 00:00:00 2001 From: Tyler Erickson Date: Thu, 5 Mar 2020 19:29:32 -0800 Subject: [PATCH 4/8] Fixed bad merge --- core/os/os_linux.odin | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/os/os_linux.odin b/core/os/os_linux.odin index e49f0f611..d03c19ec4 100644 --- a/core/os/os_linux.odin +++ b/core/os/os_linux.odin @@ -267,13 +267,13 @@ foreign libc { @(link_name="write") _unix_write :: proc(fd: Handle, buf: rawptr, size: c.size_t) -> c.ssize_t ---; @(link_name="lseek64") _unix_seek :: proc(fd: Handle, offset: i64, whence: c.int) -> i64 ---; @(link_name="gettid") _unix_gettid :: proc() -> u64 ---; - @(link_name="getpagesize") _unix_getpagesize :: proc() -> i32 ---; - @(link_name="stat64") _unix_stat :: proc(path: cstring, stat: ^Stat) -> int ---; - @(link_name="fstat") _unix_fstat :: proc(fd: Handle, stat: ^Stat) -> int ---; - @(link_name="access") _unix_access :: proc(path: cstring, mask: int) -> int ---; + @(link_name="getpagesize") _unix_getpagesize :: proc() -> c.int ---; + @(link_name="stat64") _unix_stat :: proc(path: cstring, stat: ^Stat) -> c.int ---; + @(link_name="fstat") _unix_fstat :: proc(fd: Handle, stat: ^Stat) -> c.int ---; + @(link_name="access") _unix_access :: proc(path: cstring, mask: c.int) -> c.int ---; - @(link_name="malloc") _unix_malloc :: proc(size: int) -> rawptr ---; - @(link_name="calloc") _unix_calloc :: proc(num, size: int) -> rawptr ---; + @(link_name="malloc") _unix_malloc :: proc(size: c.size_t) -> rawptr ---; + @(link_name="calloc") _unix_calloc :: proc(num, size: c.size_t) -> rawptr ---; @(link_name="free") _unix_free :: proc(ptr: rawptr) ---; @(link_name="realloc") _unix_realloc :: proc(ptr: rawptr, size: c.size_t) -> rawptr ---; @(link_name="getenv") _unix_getenv :: proc(cstring) -> cstring ---; From fb686bdebd98c3b0f6e00eb339bad1725137e4de Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sat, 7 Mar 2020 16:19:55 +0000 Subject: [PATCH 5/8] Remove the need for parapoly to print an enum as a string --- core/fmt/fmt.odin | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/core/fmt/fmt.odin b/core/fmt/fmt.odin index 626b0797d..b9bb1ee2c 100644 --- a/core/fmt/fmt.odin +++ b/core/fmt/fmt.odin @@ -797,18 +797,15 @@ enum_value_to_string :: proc(val: any) -> (string, bool) { #partial switch e in type_info.variant { case: return "", false; case runtime.Type_Info_Enum: - get_str :: proc(i: $T, e: runtime.Type_Info_Enum) -> (string, bool) { - if reflect.is_string(e.base) { - for val, idx in e.values { - if v, ok := val.(T); ok && v == i { - return e.names[idx], true; - } - } - } else if len(e.values) == 0 { + get_str :: proc(data: rawptr, e: runtime.Type_Info_Enum) -> (string, bool) { + if len(e.values) == 0 { return "", true; } else { - for val, idx in e.values { - if v, ok := val.(T); ok && v == i { + for _, idx in e.values { + val := &e.values[idx]; + // NOTE(bill): Removes need for parametric polymorphic check + res := mem.compare_ptrs(val, data, e.base.size); + if res == 0 { return e.names[idx], true; } } @@ -816,21 +813,7 @@ enum_value_to_string :: proc(val: any) -> (string, bool) { return "", false; } - a := any{v.data, runtime.type_info_base(e.base).id}; - switch v in a { - case rune: return get_str(v, e); - case i8: return get_str(v, e); - case i16: return get_str(v, e); - case i32: return get_str(v, e); - case i64: 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 uint: return get_str(v, e); - case uintptr: return get_str(v, e); - } + return get_str(v.data, e); } return "", false; From a83d9f59f64c94e615afbed43b3f99ec9c46feee Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sat, 7 Mar 2020 21:12:52 +0000 Subject: [PATCH 6/8] Fix typo in parser.odin --- core/odin/parser/parser.odin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/odin/parser/parser.odin b/core/odin/parser/parser.odin index c4e6d8142..29655766f 100644 --- a/core/odin/parser/parser.odin +++ b/core/odin/parser/parser.odin @@ -2754,7 +2754,7 @@ parse_binary_expr :: proc(p: ^Parser, lhs: bool, prec_in: int) -> ^ast.Expr { } else if op.kind == .When { x := expr; cond := parse_expr(p, lhs); - op2 := expect_token(p, .Else); + else_tok := expect_token(p, .Else); y := parse_expr(p, lhs); te := ast.new(ast.Ternary_When_Expr, expr.pos, end_pos(p.prev_tok)); te.x = x; From 4cf70f360bcc146c69121888f6f78a53e965a560 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sat, 7 Mar 2020 21:41:27 +0000 Subject: [PATCH 7/8] Add clone for `ast.Ternary_If_Expr` and `ast.Ternary_When_Expr` --- core/odin/ast/clone.odin | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/odin/ast/clone.odin b/core/odin/ast/clone.odin index ddb3068f1..0969c0e29 100644 --- a/core/odin/ast/clone.odin +++ b/core/odin/ast/clone.odin @@ -136,6 +136,16 @@ clone_node :: proc(node: ^Node) -> ^Node { r.cond = clone(r.cond); r.x = clone(r.x); r.y = clone(r.y); + case Ternary_If_Expr: + r := cast(^Ternary_If_Expr)res; + r.x = clone(r.x); + r.cond = clone(r.cond); + r.y = clone(r.y); + case Ternary_When_Expr: + r := cast(^Ternary_When_Expr)res; + r.x = clone(r.x); + r.cond = clone(r.cond); + r.y = clone(r.y); case Type_Assertion: r := cast(^Type_Assertion)res; r.expr = clone(r.expr); From e0a370f8f181d9787312b89bb30da9e638c59584 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sun, 8 Mar 2020 10:12:56 +0000 Subject: [PATCH 8/8] Remove adding to path in shell.bat --- misc/shell.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/shell.bat b/misc/shell.bat index 85a7949c6..60f603bc1 100644 --- a/misc/shell.bat +++ b/misc/shell.bat @@ -7,5 +7,5 @@ rem call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxil rem call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 1> NUL set _NO_DEBUG_HEAP=1 -set path=w:\Odin\misc;%path% +rem set path=w:\Odin\misc;%path% cls