mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-07 16:18:52 +00:00
Merge branch 'master' into llvm-integration
This commit is contained in:
+8
-25
@@ -797,18 +797,15 @@ enum_value_to_string :: proc(val: any) -> (string, bool) {
|
|||||||
#partial switch e in type_info.variant {
|
#partial switch e in type_info.variant {
|
||||||
case: return "", false;
|
case: return "", false;
|
||||||
case runtime.Type_Info_Enum:
|
case runtime.Type_Info_Enum:
|
||||||
get_str :: proc(i: $T, e: runtime.Type_Info_Enum) -> (string, bool) {
|
get_str :: proc(data: rawptr, e: runtime.Type_Info_Enum) -> (string, bool) {
|
||||||
if reflect.is_string(e.base) {
|
if len(e.values) == 0 {
|
||||||
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 {
|
|
||||||
return "", true;
|
return "", true;
|
||||||
} else {
|
} else {
|
||||||
for val, idx in e.values {
|
for _, idx in e.values {
|
||||||
if v, ok := val.(T); ok && v == i {
|
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;
|
return e.names[idx], true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -816,21 +813,7 @@ enum_value_to_string :: proc(val: any) -> (string, bool) {
|
|||||||
return "", false;
|
return "", false;
|
||||||
}
|
}
|
||||||
|
|
||||||
a := any{v.data, runtime.type_info_base(e.base).id};
|
return get_str(v.data, e);
|
||||||
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 "", false;
|
return "", false;
|
||||||
|
|||||||
+1
-3
@@ -186,9 +186,7 @@ align_backward :: inline proc(ptr: rawptr, align: uintptr) -> rawptr {
|
|||||||
|
|
||||||
align_backward_uintptr :: proc(ptr, align: uintptr) -> uintptr {
|
align_backward_uintptr :: proc(ptr, align: uintptr) -> uintptr {
|
||||||
assert(is_power_of_two(align));
|
assert(is_power_of_two(align));
|
||||||
|
return align_forward_uintptr(ptr - align + 1, align);
|
||||||
ptr := rawptr(ptr - align);
|
|
||||||
return uintptr(align_forward(ptr, align));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
align_backward_int :: inline proc(ptr, align: int) -> int {
|
align_backward_int :: inline proc(ptr, align: int) -> int {
|
||||||
|
|||||||
@@ -136,6 +136,16 @@ clone_node :: proc(node: ^Node) -> ^Node {
|
|||||||
r.cond = clone(r.cond);
|
r.cond = clone(r.cond);
|
||||||
r.x = clone(r.x);
|
r.x = clone(r.x);
|
||||||
r.y = clone(r.y);
|
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:
|
case Type_Assertion:
|
||||||
r := cast(^Type_Assertion)res;
|
r := cast(^Type_Assertion)res;
|
||||||
r.expr = clone(r.expr);
|
r.expr = clone(r.expr);
|
||||||
|
|||||||
@@ -2754,7 +2754,7 @@ parse_binary_expr :: proc(p: ^Parser, lhs: bool, prec_in: int) -> ^ast.Expr {
|
|||||||
} else if op.kind == .When {
|
} else if op.kind == .When {
|
||||||
x := expr;
|
x := expr;
|
||||||
cond := parse_expr(p, lhs);
|
cond := parse_expr(p, lhs);
|
||||||
op2 := expect_token(p, .Else);
|
else_tok := expect_token(p, .Else);
|
||||||
y := parse_expr(p, lhs);
|
y := parse_expr(p, lhs);
|
||||||
te := ast.new(ast.Ternary_When_Expr, expr.pos, end_pos(p.prev_tok));
|
te := ast.new(ast.Ternary_When_Expr, expr.pos, end_pos(p.prev_tok));
|
||||||
te.x = x;
|
te.x = x;
|
||||||
|
|||||||
@@ -202,10 +202,10 @@ Stat :: struct {
|
|||||||
gid: u32, // Group ID of the file's group
|
gid: u32, // Group ID of the file's group
|
||||||
rdev: i32, // Device ID, if device
|
rdev: i32, // Device ID, if device
|
||||||
|
|
||||||
last_access: File_Time, // Time of last access
|
last_access: _File_Time, // Time of last access
|
||||||
modified: File_Time, // Time of last modification
|
modified: _File_Time, // Time of last modification
|
||||||
status_change: File_Time, // Time of last status change
|
status_change: _File_Time, // Time of last status change
|
||||||
created: File_Time, // Time of creation
|
created: _File_Time, // Time of creation
|
||||||
|
|
||||||
size: i64, // Size of the file, in bytes
|
size: i64, // Size of the file, in bytes
|
||||||
blocks: i64, // Number of blocks allocated for the file
|
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="lseek") _unix_lseek :: proc(fs: Handle, offset: int, whence: int) -> int ---;
|
||||||
@(link_name="gettid") _unix_gettid :: proc() -> u64 ---;
|
@(link_name="gettid") _unix_gettid :: proc() -> u64 ---;
|
||||||
@(link_name="getpagesize") _unix_getpagesize :: proc() -> i32 ---;
|
@(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="access") _unix_access :: proc(path: cstring, mask: int) -> int ---;
|
||||||
|
|
||||||
@(link_name="malloc") _unix_malloc :: proc(size: int) -> rawptr ---;
|
@(link_name="malloc") _unix_malloc :: proc(size: int) -> rawptr ---;
|
||||||
|
|||||||
@@ -199,9 +199,9 @@ Stat :: struct {
|
|||||||
block_size: i64, // Optimal bllocksize for I/O
|
block_size: i64, // Optimal bllocksize for I/O
|
||||||
blocks: i64, // Number of 512-byte blocks allocated
|
blocks: i64, // Number of 512-byte blocks allocated
|
||||||
|
|
||||||
last_access: _File_Time, // Time of last access
|
last_access: File_Time, // Time of last access
|
||||||
modified: _File_Time, // Time of last modification
|
status_change: File_Time, // Time of last status change
|
||||||
status_change: _File_Time, // Time of last status change
|
modified: File_Time, // Time of last modification
|
||||||
|
|
||||||
_reserve1,
|
_reserve1,
|
||||||
_reserve2,
|
_reserve2,
|
||||||
@@ -268,7 +268,7 @@ foreign libc {
|
|||||||
@(link_name="lseek64") _unix_seek :: proc(fd: Handle, offset: i64, whence: c.int) -> i64 ---;
|
@(link_name="lseek64") _unix_seek :: proc(fd: Handle, offset: i64, whence: c.int) -> i64 ---;
|
||||||
@(link_name="gettid") _unix_gettid :: proc() -> u64 ---;
|
@(link_name="gettid") _unix_gettid :: proc() -> u64 ---;
|
||||||
@(link_name="getpagesize") _unix_getpagesize :: proc() -> c.int ---;
|
@(link_name="getpagesize") _unix_getpagesize :: proc() -> c.int ---;
|
||||||
@(link_name="stat") _unix_stat :: proc(path: cstring, stat: ^Stat) -> 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="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="access") _unix_access :: proc(path: cstring, mask: c.int) -> c.int ---;
|
||||||
|
|
||||||
@@ -366,7 +366,7 @@ last_write_time :: proc(fd: Handle) -> (File_Time, Errno) {
|
|||||||
if err != ERROR_NONE {
|
if err != ERROR_NONE {
|
||||||
return 0, err;
|
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) {
|
last_write_time_by_name :: proc(name: string) -> (File_Time, Errno) {
|
||||||
@@ -374,7 +374,7 @@ last_write_time_by_name :: proc(name: string) -> (File_Time, Errno) {
|
|||||||
if err != ERROR_NONE {
|
if err != ERROR_NONE {
|
||||||
return 0, err;
|
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) {
|
stat :: inline proc(path: string) -> (Stat, Errno) {
|
||||||
|
|||||||
+1
-1
@@ -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
|
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 _NO_DEBUG_HEAP=1
|
||||||
|
|
||||||
set path=w:\Odin\misc;%path%
|
rem set path=w:\Odin\misc;%path%
|
||||||
cls
|
cls
|
||||||
|
|||||||
Reference in New Issue
Block a user