diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-02-12 01:23:06 -0700 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-02-12 01:23:06 -0700 |
| commit | 0c1ce21f7d5f2756bc9e642c17092db9f9f2cf05 (patch) | |
| tree | 1a84a6d707b8d427665b5fe7c31c41886359c2ea /src/codegen.cpp | |
| parent | 51b2621e6201fa182f166783e79a47f49c04d5cf (diff) | |
| download | zig-0c1ce21f7d5f2756bc9e642c17092db9f9f2cf05.tar.gz zig-0c1ce21f7d5f2756bc9e642c17092db9f9f2cf05.zip | |
add @compile_var("environ")
Diffstat (limited to 'src/codegen.cpp')
| -rw-r--r-- | src/codegen.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp index 4dc5c18557..2579092567 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -3500,6 +3500,31 @@ static void define_builtin_types(CodeGen *g) { g->builtin_types.entry_arch_enum = entry; } + + { + TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdEnum); + entry->zero_bits = true; // only allowed at compile time + buf_init_from_str(&entry->name, "@Environ"); + uint32_t field_count = target_environ_count(); + entry->data.enumeration.field_count = field_count; + entry->data.enumeration.fields = allocate<TypeEnumField>(field_count); + for (uint32_t i = 0; i < field_count; i += 1) { + TypeEnumField *type_enum_field = &entry->data.enumeration.fields[i]; + ZigLLVM_EnvironmentType environ_type = get_target_environ(i); + type_enum_field->name = buf_create_from_str(ZigLLVMGetEnvironmentTypeName(environ_type)); + type_enum_field->value = i; + + if (environ_type == g->zig_target.environ) { + g->target_environ_index = i; + } + } + entry->data.enumeration.complete = true; + + TypeTableEntry *tag_type_entry = get_smallest_unsigned_int_type(g, field_count); + entry->data.enumeration.tag_type = tag_type_entry; + + g->builtin_types.entry_environ_enum = entry; + } } |
