Wrap entry point main around the C style main in the IR

This commit is contained in:
Ginger Bill
2017-09-30 11:20:35 +01:00
parent 8c7cf0dbb0
commit e2b9c87aa8
5 changed files with 191 additions and 95 deletions

View File

@@ -138,8 +138,8 @@ Type_Info :: struct #ordered {
// This will be set by the compiler
__type_table: []Type_Info;
__argv__: ^^u8;
__argc__: i32;
__argv__: ^^u8;
// IMPORTANT NOTE(bill): Must be in this order (as the compiler relies upon it)

View File

@@ -267,6 +267,9 @@ dlerror :: proc() -> string {
_alloc_command_line_arguments :: proc() -> []string {
// TODO(bill):
return nil;
args := make([]string, __argc__);
for i in 0..__argc__ {
args[i] = strings.to_odin_string((__argv__+i)^);
}
return args;
}

View File

@@ -42,7 +42,8 @@ RTLD_NOLOAD :: 0x10;
RTLD_FIRST :: 0x100;
args: [dynamic]string;
// "Argv" arguments converted to Odin strings
args := _alloc_command_line_arguments();
_File_Time :: struct #ordered {
seconds: i64,
@@ -279,3 +280,12 @@ dlclose :: proc(handle: rawptr) -> bool #inline {
dlerror :: proc() -> string {
return strings.to_odin_string(unix_dlerror());
}
_alloc_command_line_arguments :: proc() -> []string {
args := make([]string, __argc__);
for i in 0..__argc__ {
args[i] = strings.to_odin_string((__argv__+i)^);
}
return args;
}