mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-02 04:38:16 +00:00
Fix core library; Disable adding entity definitions for blank identifiers
This commit is contained in:
@@ -4,8 +4,7 @@
|
|||||||
set exe_name=odin.exe
|
set exe_name=odin.exe
|
||||||
|
|
||||||
:: Debug = 0, Release = 1
|
:: Debug = 0, Release = 1
|
||||||
set release_mode=1
|
set release_mode=0
|
||||||
|
|
||||||
set compiler_flags= -nologo -Oi -TC -fp:fast -fp:except- -Gm- -MP -FC -GS- -EHsc- -GR-
|
set compiler_flags= -nologo -Oi -TC -fp:fast -fp:except- -Gm- -MP -FC -GS- -EHsc- -GR-
|
||||||
|
|
||||||
if %release_mode% EQU 0 ( rem Debug
|
if %release_mode% EQU 0 ( rem Debug
|
||||||
|
|||||||
+4
-67
@@ -1,70 +1,7 @@
|
|||||||
#foreign_system_library "winmm" when ODIN_OS == "windows";
|
|
||||||
#import win32 "sys/windows.odin" when ODIN_OS == "windows";
|
|
||||||
#import "fmt.odin";
|
#import "fmt.odin";
|
||||||
|
|
||||||
timeGetTime :: proc() -> u32 #foreign #dll_import
|
main :: proc() {
|
||||||
GetSystemTimeAsFileTime :: proc(SystemTimeAsFileTime : ^win32.FILETIME) #foreign #dll_import
|
x := "-stats";
|
||||||
|
y := "-begin";
|
||||||
GetCommandLineArguments :: proc() -> []string {
|
fmt.println(x == y);
|
||||||
argString := win32.GetCommandLineA();
|
|
||||||
fullArgString := to_odin_string(argString);
|
|
||||||
// Count Spaces
|
|
||||||
for r : fullArgString {
|
|
||||||
fmt.println(r);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
to_odin_string :: proc(c: ^byte) -> string {
|
|
||||||
s: string;
|
|
||||||
s.data = c;
|
|
||||||
while (c + s.count)^ != 0 {
|
|
||||||
s.count += 1;
|
|
||||||
}
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
//("Hellope!\x00" as string).data
|
|
||||||
|
|
||||||
MAGIC_VALUE :: 0xCA5E713F;
|
|
||||||
|
|
||||||
timing_file_header :: struct #ordered {
|
|
||||||
MagicValue : u32;
|
|
||||||
}
|
|
||||||
|
|
||||||
timing_file_date :: struct #ordered {
|
|
||||||
E : [2]u32;
|
|
||||||
}
|
|
||||||
|
|
||||||
timing_file_entry_flag :: enum {
|
|
||||||
Complete = 0x1,
|
|
||||||
NoErrors = 0x2,
|
|
||||||
}
|
|
||||||
|
|
||||||
timing_file_entry :: struct #ordered {
|
|
||||||
StarDate : timing_file_date;
|
|
||||||
Flags : u32;
|
|
||||||
MillisecondsElapsed : u32;
|
|
||||||
}
|
|
||||||
|
|
||||||
timing_entry_array :: struct #ordered {
|
|
||||||
Entries : []timing_file_entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
GetClock :: proc () -> u32 {
|
|
||||||
return timeGetTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
GetDate :: proc() -> timing_file_date {
|
|
||||||
Result : timing_file_date;
|
|
||||||
FileTime : win32.FILETIME;
|
|
||||||
GetSystemTimeAsFileTime(^FileTime);
|
|
||||||
|
|
||||||
Result.E[0] = FileTime.lo;
|
|
||||||
Result.E[1] = FileTime.hi;
|
|
||||||
|
|
||||||
return Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
main :: proc () {
|
|
||||||
EntryClock := GetClock();
|
|
||||||
GetCommandLineArguments();
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -308,7 +308,7 @@ __bounds_check_error :: proc(file: string, line, column: int, index, count: int)
|
|||||||
if 0 <= index && index < count {
|
if 0 <= index && index < count {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fmt.fprintf(os.stderr, "%(%:%) Index % is out of bounds range [0, %)\n",
|
fmt.fprintf(os.stderr, "%(%:%) Index % is out of bounds range 0..<%\n",
|
||||||
file, line, column, index, count);
|
file, line, column, index, count);
|
||||||
__debug_trap();
|
__debug_trap();
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-27
@@ -26,37 +26,16 @@ copy_non_overlapping :: proc(dst, src: rawptr, len: int) -> rawptr #link_name "_
|
|||||||
}
|
}
|
||||||
|
|
||||||
compare :: proc(dst, src: rawptr, n: int) -> int #link_name "__mem_compare" {
|
compare :: proc(dst, src: rawptr, n: int) -> int #link_name "__mem_compare" {
|
||||||
// Translation of http://mgronhol.github.io/fast-strcmp/
|
|
||||||
a := slice_ptr(dst as ^byte, n);
|
a := slice_ptr(dst as ^byte, n);
|
||||||
b := slice_ptr(src as ^byte, n);
|
b := slice_ptr(src as ^byte, n);
|
||||||
|
for i : 0..<n {
|
||||||
fast := n/size_of(int) + 1;
|
match {
|
||||||
offset := (fast-1)*size_of(int);
|
case a[i] < b[i]:
|
||||||
curr_block := 0;
|
return -1;
|
||||||
if n <= size_of(int) {
|
case a[i] > b[i]:
|
||||||
fast = 0;
|
return +1;
|
||||||
}
|
|
||||||
|
|
||||||
la := slice_ptr(^a[0] as ^int, fast);
|
|
||||||
lb := slice_ptr(^b[0] as ^int, fast);
|
|
||||||
|
|
||||||
for _ : curr_block ..< fast {
|
|
||||||
if (la[curr_block] ~ lb[curr_block]) != 0 {
|
|
||||||
for pos : curr_block*size_of(int) ..< n {
|
|
||||||
if (a[pos] ~ b[pos]) != 0 {
|
|
||||||
return a[pos] as int - b[pos] as int;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
for _ : offset ..< n {
|
|
||||||
if (a[offset] ~ b[offset]) != 0 {
|
|
||||||
return a[offset] as int - b[offset] as int;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+39
-38
@@ -2,11 +2,11 @@
|
|||||||
#import "fmt.odin";
|
#import "fmt.odin";
|
||||||
|
|
||||||
|
|
||||||
Handle :: uint;
|
Handle :: int;
|
||||||
File_Time :: u64;
|
File_Time :: u64;
|
||||||
Error :: int;
|
Errno :: int;
|
||||||
|
|
||||||
INVALID_HANDLE: Handle : ~(0 as Handle);
|
INVALID_HANDLE: Handle : -1;
|
||||||
|
|
||||||
|
|
||||||
O_RDONLY :: 0x00000;
|
O_RDONLY :: 0x00000;
|
||||||
@@ -22,37 +22,37 @@ O_SYNC :: 0x01000;
|
|||||||
O_ASYNC :: 0x02000;
|
O_ASYNC :: 0x02000;
|
||||||
O_CLOEXEC :: 0x80000;
|
O_CLOEXEC :: 0x80000;
|
||||||
|
|
||||||
ERROR_NONE: Error : 0;
|
ERROR_NONE: Errno : 0;
|
||||||
ERROR_FILE_NOT_FOUND: Error : 2;
|
ERROR_FILE_NOT_FOUND: Errno : 2;
|
||||||
ERROR_PATH_NOT_FOUND: Error : 3;
|
ERROR_PATH_NOT_FOUND: Errno : 3;
|
||||||
ERROR_ACCESS_DENIED: Error : 5;
|
ERROR_ACCESS_DENIED: Errno : 5;
|
||||||
ERROR_NO_MORE_FILES: Error : 18;
|
ERROR_NO_MORE_FILES: Errno : 18;
|
||||||
ERROR_HANDLE_EOF: Error : 38;
|
ERROR_HANDLE_EOF: Errno : 38;
|
||||||
ERROR_NETNAME_DELETED: Error : 64;
|
ERROR_NETNAME_DELETED: Errno : 64;
|
||||||
ERROR_FILE_EXISTS: Error : 80;
|
ERROR_FILE_EXISTS: Errno : 80;
|
||||||
ERROR_BROKEN_PIPE: Error : 109;
|
ERROR_BROKEN_PIPE: Errno : 109;
|
||||||
ERROR_BUFFER_OVERFLOW: Error : 111;
|
ERROR_BUFFER_OVERFLOW: Errno : 111;
|
||||||
ERROR_INSUFFICIENT_BUFFER: Error : 122;
|
ERROR_INSUFFICIENT_BUFFER: Errno : 122;
|
||||||
ERROR_MOD_NOT_FOUND: Error : 126;
|
ERROR_MOD_NOT_FOUND: Errno : 126;
|
||||||
ERROR_PROC_NOT_FOUND: Error : 127;
|
ERROR_PROC_NOT_FOUND: Errno : 127;
|
||||||
ERROR_DIR_NOT_EMPTY: Error : 145;
|
ERROR_DIR_NOT_EMPTY: Errno : 145;
|
||||||
ERROR_ALREADY_EXISTS: Error : 183;
|
ERROR_ALREADY_EXISTS: Errno : 183;
|
||||||
ERROR_ENVVAR_NOT_FOUND: Error : 203;
|
ERROR_ENVVAR_NOT_FOUND: Errno : 203;
|
||||||
ERROR_MORE_DATA: Error : 234;
|
ERROR_MORE_DATA: Errno : 234;
|
||||||
ERROR_OPERATION_ABORTED: Error : 995;
|
ERROR_OPERATION_ABORTED: Errno : 995;
|
||||||
ERROR_IO_PENDING: Error : 997;
|
ERROR_IO_PENDING: Errno : 997;
|
||||||
ERROR_NOT_FOUND: Error : 1168;
|
ERROR_NOT_FOUND: Errno : 1168;
|
||||||
ERROR_PRIVILEGE_NOT_HELD: Error : 1314;
|
ERROR_PRIVILEGE_NOT_HELD: Errno : 1314;
|
||||||
WSAEACCES: Error : 10013;
|
WSAEACCES: Errno : 10013;
|
||||||
WSAECONNRESET: Error : 10054;
|
WSAECONNRESET: Errno : 10054;
|
||||||
|
|
||||||
// Windows reserves errors >= 1<<29 for application use
|
// Windows reserves errors >= 1<<29 for application use
|
||||||
ERROR_FILE_IS_PIPE: Error : 1<<29 + 0;
|
ERROR_FILE_IS_PIPE: Errno : 1<<29 + 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
open :: proc(path: string, mode: int, perm: u32) -> (Handle, Error) {
|
open :: proc(path: string, mode: int, perm: u32) -> (Handle, Errno) {
|
||||||
using win32;
|
using win32;
|
||||||
if path.count == 0 {
|
if path.count == 0 {
|
||||||
return INVALID_HANDLE, ERROR_FILE_NOT_FOUND;
|
return INVALID_HANDLE, ERROR_FILE_NOT_FOUND;
|
||||||
@@ -98,37 +98,38 @@ open :: proc(path: string, mode: int, perm: u32) -> (Handle, Error) {
|
|||||||
copy(buf[:], path as []byte);
|
copy(buf[:], path as []byte);
|
||||||
|
|
||||||
handle := CreateFileA(^buf[0], access, share_mode, sa, create_mode, FILE_ATTRIBUTE_NORMAL, nil) as Handle;
|
handle := CreateFileA(^buf[0], access, share_mode, sa, create_mode, FILE_ATTRIBUTE_NORMAL, nil) as Handle;
|
||||||
if handle == INVALID_HANDLE {
|
if handle != INVALID_HANDLE {
|
||||||
return handle, ERROR_NONE;
|
return handle, ERROR_NONE;
|
||||||
}
|
}
|
||||||
err := GetLastError();
|
err := GetLastError();
|
||||||
return INVALID_HANDLE, err as Error;
|
return INVALID_HANDLE, err as Errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
close :: proc(fd: Handle) {
|
close :: proc(fd: Handle) {
|
||||||
win32.CloseHandle(fd as win32.HANDLE);
|
win32.CloseHandle(fd as win32.HANDLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
write :: proc(fd: Handle, data: []byte) -> (int, Error) {
|
write :: proc(fd: Handle, data: []byte) -> (int, Errno) {
|
||||||
bytes_written: i32;
|
bytes_written: i32;
|
||||||
e := win32.WriteFile(fd as win32.HANDLE, data.data, data.count as i32, ^bytes_written, nil);
|
e := win32.WriteFile(fd as win32.HANDLE, data.data, data.count as i32, ^bytes_written, nil);
|
||||||
if e != 0 {
|
if e == win32.FALSE {
|
||||||
return 0, e as Error;
|
err := win32.GetLastError();
|
||||||
|
return 0, err as Errno;
|
||||||
}
|
}
|
||||||
return bytes_written as int, ERROR_NONE;
|
return bytes_written as int, ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
read :: proc(fd: Handle, data: []byte) -> (int, Error) {
|
read :: proc(fd: Handle, data: []byte) -> (int, Errno) {
|
||||||
bytes_read: i32;
|
bytes_read: i32;
|
||||||
e := win32.ReadFile(fd as win32.HANDLE, data.data, data.count as u32, ^bytes_read, nil);
|
e := win32.ReadFile(fd as win32.HANDLE, data.data, data.count as u32, ^bytes_read, nil);
|
||||||
if e != win32.FALSE {
|
if e == win32.FALSE {
|
||||||
err := win32.GetLastError();
|
err := win32.GetLastError();
|
||||||
return 0, err as Error;
|
return 0, err as Errno;
|
||||||
}
|
}
|
||||||
return bytes_read as int, ERROR_NONE;
|
return bytes_read as int, ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
seek :: proc(fd: Handle, offset: i64, whence: int) -> (i64, Error) {
|
seek :: proc(fd: Handle, offset: i64, whence: int) -> (i64, Errno) {
|
||||||
using win32;
|
using win32;
|
||||||
w: u32;
|
w: u32;
|
||||||
match whence {
|
match whence {
|
||||||
@@ -145,7 +146,7 @@ seek :: proc(fd: Handle, offset: i64, whence: int) -> (i64, Error) {
|
|||||||
dw_ptr := SetFilePointer(fd as HANDLE, lo, ^hi, w);
|
dw_ptr := SetFilePointer(fd as HANDLE, lo, ^hi, w);
|
||||||
if dw_ptr == INVALID_SET_FILE_POINTER {
|
if dw_ptr == INVALID_SET_FILE_POINTER {
|
||||||
err := GetLastError();
|
err := GetLastError();
|
||||||
return 0, err as Error;
|
return 0, err as Errno;
|
||||||
}
|
}
|
||||||
return (hi as i64)<<32 + (dw_ptr as i64), ERROR_NONE;
|
return (hi as i64)<<32 + (dw_ptr as i64), ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ CreateFileA :: proc(filename: ^u8, desired_access, share_mode: u32,
|
|||||||
security: rawptr,
|
security: rawptr,
|
||||||
creation, flags_and_attribs: u32, template_file: HANDLE) -> HANDLE #foreign #dll_import
|
creation, flags_and_attribs: u32, template_file: HANDLE) -> HANDLE #foreign #dll_import
|
||||||
ReadFile :: proc(h: HANDLE, buf: rawptr, to_read: u32, bytes_read: ^i32, overlapped: rawptr) -> BOOL #foreign #dll_import
|
ReadFile :: proc(h: HANDLE, buf: rawptr, to_read: u32, bytes_read: ^i32, overlapped: rawptr) -> BOOL #foreign #dll_import
|
||||||
WriteFile :: proc(h: HANDLE, buf: rawptr, len: i32, written_result: ^i32, overlapped: rawptr) -> i32 #foreign #dll_import
|
WriteFile :: proc(h: HANDLE, buf: rawptr, len: i32, written_result: ^i32, overlapped: rawptr) -> BOOL #foreign #dll_import
|
||||||
|
|
||||||
GetFileSizeEx :: proc(file_handle: HANDLE, file_size: ^i64) -> BOOL #foreign #dll_import
|
GetFileSizeEx :: proc(file_handle: HANDLE, file_size: ^i64) -> BOOL #foreign #dll_import
|
||||||
GetFileAttributesExA :: proc(filename: ^u8, info_level_id: GET_FILEEX_INFO_LEVELS, file_info: rawptr) -> BOOL #foreign #dll_import
|
GetFileAttributesExA :: proc(filename: ^u8, info_level_id: GET_FILEEX_INFO_LEVELS, file_info: rawptr) -> BOOL #foreign #dll_import
|
||||||
|
|||||||
+1
-1
@@ -148,7 +148,7 @@ String get_filepath_extension(String path) {
|
|||||||
|
|
||||||
void init_build_context(BuildContext *bc) {
|
void init_build_context(BuildContext *bc) {
|
||||||
bc->ODIN_VENDOR = str_lit("odin");
|
bc->ODIN_VENDOR = str_lit("odin");
|
||||||
bc->ODIN_VERSION = str_lit("0.0.5d");
|
bc->ODIN_VERSION = str_lit("0.0.5e");
|
||||||
bc->ODIN_ROOT = odin_root_dir();
|
bc->ODIN_ROOT = odin_root_dir();
|
||||||
|
|
||||||
#if defined(GB_SYSTEM_WINDOWS)
|
#if defined(GB_SYSTEM_WINDOWS)
|
||||||
|
|||||||
@@ -722,6 +722,9 @@ void add_type_and_value(CheckerInfo *i, AstNode *expression, AddressingMode mode
|
|||||||
void add_entity_definition(CheckerInfo *i, AstNode *identifier, Entity *entity) {
|
void add_entity_definition(CheckerInfo *i, AstNode *identifier, Entity *entity) {
|
||||||
GB_ASSERT(identifier != NULL);
|
GB_ASSERT(identifier != NULL);
|
||||||
if (identifier->kind == AstNode_Ident) {
|
if (identifier->kind == AstNode_Ident) {
|
||||||
|
if (str_eq(identifier->Ident.string, str_lit("_"))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
HashKey key = hash_pointer(identifier);
|
HashKey key = hash_pointer(identifier);
|
||||||
map_entity_set(&i->definitions, key, entity);
|
map_entity_set(&i->definitions, key, entity);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user