| author | |
| committer | |
| log | 0c1ce21f7d5f2756bc9e642c17092db9f9f2cf05 |
| tree | 1a84a6d707b8d427665b5fe7c31c41886359c2ea |
| parent | 51b2621e6201fa182f166783e79a47f49c04d5cf |
3 files changed, 30 insertions(+), 0 deletions(-)
src/all_types.hpp+2| ... | @@ -1110,6 +1110,7 @@ struct CodeGen { | ... | @@ -1110,6 +1110,7 @@ struct CodeGen { |
| 1110 | TypeTableEntry *entry_pure_error; | 1110 | TypeTableEntry *entry_pure_error; |
| 1111 | TypeTableEntry *entry_os_enum; | 1111 | TypeTableEntry *entry_os_enum; |
| 1112 | TypeTableEntry *entry_arch_enum; | 1112 | TypeTableEntry *entry_arch_enum; |
| 1113 | TypeTableEntry *entry_environ_enum; | ||
| 1113 | } builtin_types; | 1114 | } builtin_types; |
| 1114 | 1115 | ||
| 1115 | ZigTarget zig_target; | 1116 | ZigTarget zig_target; |
| ... | @@ -1130,6 +1131,7 @@ struct CodeGen { | ... | @@ -1130,6 +1131,7 @@ struct CodeGen { |
| 1130 | bool is_test_build; | 1131 | bool is_test_build; |
| 1131 | uint32_t target_os_index; | 1132 | uint32_t target_os_index; |
| 1132 | uint32_t target_arch_index; | 1133 | uint32_t target_arch_index; |
| 1134 | uint32_t target_environ_index; | ||
| 1133 | LLVMTargetMachineRef target_machine; | 1135 | LLVMTargetMachineRef target_machine; |
| 1134 | LLVMZigDIFile *dummy_di_file; | 1136 | LLVMZigDIFile *dummy_di_file; |
| 1135 | bool is_native_target; | 1137 | bool is_native_target; |
src/analyze.cpp+3| ... | @@ -4250,6 +4250,9 @@ static TypeTableEntry *analyze_builtin_fn_call_expr(CodeGen *g, ImportTableEntry | ... | @@ -4250,6 +4250,9 @@ static TypeTableEntry *analyze_builtin_fn_call_expr(CodeGen *g, ImportTableEntry |
| 4250 | } else if (buf_eql_str(&var_name, "arch")) { | 4250 | } else if (buf_eql_str(&var_name, "arch")) { |
| 4251 | const_val->data.x_enum.tag = g->target_arch_index; | 4251 | const_val->data.x_enum.tag = g->target_arch_index; |
| 4252 | return g->builtin_types.entry_arch_enum; | 4252 | return g->builtin_types.entry_arch_enum; |
| 4253 | } else if (buf_eql_str(&var_name, "environ")) { | ||
| 4254 | const_val->data.x_enum.tag = g->target_environ_index; | ||
| 4255 | return g->builtin_types.entry_environ_enum; | ||
| 4253 | } else { | 4256 | } else { |
| 4254 | add_node_error(g, *str_node, | 4257 | add_node_error(g, *str_node, |
| 4255 | buf_sprintf("unrecognized compile variable: '%s'", buf_ptr(&var_name))); | 4258 | buf_sprintf("unrecognized compile variable: '%s'", buf_ptr(&var_name))); |
src/codegen.cpp+25| ... | @@ -3500,6 +3500,31 @@ static void define_builtin_types(CodeGen *g) { | ... | @@ -3500,6 +3500,31 @@ static void define_builtin_types(CodeGen *g) { |
| 3500 | 3500 | ||
| 3501 | g->builtin_types.entry_arch_enum = entry; | 3501 | g->builtin_types.entry_arch_enum = entry; |
| 3502 | } | 3502 | } |
| 3503 | |||
| 3504 | { | ||
| 3505 | TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdEnum); | ||
| 3506 | entry->zero_bits = true; // only allowed at compile time | ||
| 3507 | buf_init_from_str(&entry->name, "@Environ"); | ||
| 3508 | uint32_t field_count = target_environ_count(); | ||
| 3509 | entry->data.enumeration.field_count = field_count; | ||
| 3510 | entry->data.enumeration.fields = allocate<TypeEnumField>(field_count); | ||
| 3511 | for (uint32_t i = 0; i < field_count; i += 1) { | ||
| 3512 | TypeEnumField *type_enum_field = &entry->data.enumeration.fields[i]; | ||
| 3513 | ZigLLVM_EnvironmentType environ_type = get_target_environ(i); | ||
| 3514 | type_enum_field->name = buf_create_from_str(ZigLLVMGetEnvironmentTypeName(environ_type)); | ||
| 3515 | type_enum_field->value = i; | ||
| 3516 | |||
| 3517 | if (environ_type == g->zig_target.environ) { | ||
| 3518 | g->target_environ_index = i; | ||
| 3519 | } | ||
| 3520 | } | ||
| 3521 | entry->data.enumeration.complete = true; | ||
| 3522 | |||
| 3523 | TypeTableEntry *tag_type_entry = get_smallest_unsigned_int_type(g, field_count); | ||
| 3524 | entry->data.enumeration.tag_type = tag_type_entry; | ||
| 3525 | |||
| 3526 | g->builtin_types.entry_environ_enum = entry; | ||
| 3527 | } | ||
| 3503 | } | 3528 | } |
| 3504 | 3529 | ||
| 3505 | 3530 |