mirror of
https://github.com/odin-lang/Odin.git
synced 2026-06-05 10:14:05 +00:00
__args__: []cstring
This commit is contained in:
@@ -132,8 +132,7 @@ Type_Info :: struct {
|
||||
// This will be set by the compiler
|
||||
__type_table: []Type_Info;
|
||||
|
||||
__argc__: i32;
|
||||
__argv__: ^^byte;
|
||||
__args__: []cstring;
|
||||
|
||||
// IMPORTANT NOTE(bill): Must be in this order (as the compiler relies upon it)
|
||||
|
||||
|
||||
@@ -269,9 +269,9 @@ dlerror :: proc() -> string {
|
||||
|
||||
|
||||
_alloc_command_line_arguments :: proc() -> []string {
|
||||
args := make([]string, __argc__);
|
||||
for i in 0..__argc__ {
|
||||
args[i] = string(cstring((__argv__+i)^));
|
||||
args := make([]string, len(__args__));
|
||||
for arg, i in __args__ {
|
||||
args[i] = string(arg);
|
||||
}
|
||||
return args;
|
||||
}
|
||||
|
||||
@@ -284,9 +284,9 @@ dlerror :: proc() -> string {
|
||||
|
||||
|
||||
_alloc_command_line_arguments :: proc() -> []string {
|
||||
args := make([]string, __argc__);
|
||||
for i in 0..__argc__ {
|
||||
args[i] = string((__argv__+i)^);
|
||||
args := make([]string, len(__args__));
|
||||
for arg, i in __args__ {
|
||||
args[i] = string(arg);
|
||||
}
|
||||
return args;
|
||||
}
|
||||
|
||||
10
src/ir.cpp
10
src/ir.cpp
@@ -8566,9 +8566,9 @@ void ir_gen_tree(irGen *s) {
|
||||
array_init(&proc_params->Tuple.variables, a, 2);
|
||||
array_init(&proc_results->Tuple.variables, a, 1);
|
||||
|
||||
Type *char_ptr_ptr = make_type_pointer(a, make_type_pointer(a, t_u8));
|
||||
Type *cstring_ptr = make_type_pointer(a, t_cstring);
|
||||
proc_params->Tuple.variables[0] = make_entity_param(a, proc_scope, make_token_ident(str_lit("argc")), t_i32, false, false);
|
||||
proc_params->Tuple.variables[1] = make_entity_param(a, proc_scope, make_token_ident(str_lit("argv")), char_ptr_ptr, false, false);
|
||||
proc_params->Tuple.variables[1] = make_entity_param(a, proc_scope, make_token_ident(str_lit("argv")), cstring_ptr, false, false);
|
||||
|
||||
|
||||
proc_results->Tuple.variables[0] = make_entity_param(a, proc_scope, empty_token, t_i32, false, false);
|
||||
@@ -8606,11 +8606,9 @@ void ir_gen_tree(irGen *s) {
|
||||
irValue *argc = ir_emit_load(proc, *map_get(&proc->module->values, hash_entity(proc_params->Tuple.variables[0])));
|
||||
irValue *argv = ir_emit_load(proc, *map_get(&proc->module->values, hash_entity(proc_params->Tuple.variables[1])));
|
||||
|
||||
irValue *global_argc = ir_find_global_variable(proc, str_lit("__argc__"));
|
||||
irValue *global_argv = ir_find_global_variable(proc, str_lit("__argv__"));
|
||||
irValue *global_args = ir_find_global_variable(proc, str_lit("__args__"));
|
||||
|
||||
ir_emit_store(proc, global_argc, argc);
|
||||
ir_emit_store(proc, global_argv, argv);
|
||||
ir_fill_slice(proc, global_args, argv, ir_emit_conv(proc, argc, t_int));
|
||||
|
||||
ir_emit(proc, ir_alloc_instr(proc, irInstr_StartupRuntime));
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user