diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2017-09-13 14:30:57 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-09-13 14:30:57 -0400 |
| commit | d9eabde319bc035f710b106808022e9b5872f728 (patch) | |
| tree | 798876d64f37829bdc3eb637ef35e648493afe8f /src/ir.cpp | |
| parent | 5931a6b1a5b8f4941fc9b78f8960745f81594f17 (diff) | |
| download | zig-d9eabde319bc035f710b106808022e9b5872f728.tar.gz zig-d9eabde319bc035f710b106808022e9b5872f728.zip | |
add Child property of slice type
also rename child field to Child for pointer and array
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index a06fc261c4..6b887a6d83 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -11432,6 +11432,17 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru if (type_is_invalid(child_type)) { return ira->codegen->builtin_types.entry_invalid; } else if (is_container(child_type)) { + if (is_slice(child_type) && buf_eql_str(field_name, "Child")) { + bool ptr_is_const = true; + bool ptr_is_volatile = false; + TypeStructField *ptr_field = &child_type->data.structure.fields[slice_ptr_index]; + assert(ptr_field->type_entry->id == TypeTableEntryIdPointer); + TypeTableEntry *child_type = ptr_field->type_entry->data.pointer.child_type; + return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, + create_const_type(ira->codegen, child_type), + ira->codegen->builtin_types.entry_type, + ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile); + } if (child_type->id == TypeTableEntryIdEnum) { ensure_complete_type(ira->codegen, child_type); if (child_type->data.enumeration.is_invalid) @@ -11522,7 +11533,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru return ira->codegen->builtin_types.entry_invalid; } } else if (child_type->id == TypeTableEntryIdPointer) { - if (buf_eql_str(field_name, "child")) { + if (buf_eql_str(field_name, "Child")) { bool ptr_is_const = true; bool ptr_is_volatile = false; return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, @@ -11544,7 +11555,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru return ira->codegen->builtin_types.entry_invalid; } } else if (child_type->id == TypeTableEntryIdArray) { - if (buf_eql_str(field_name, "child")) { + if (buf_eql_str(field_name, "Child")) { bool ptr_is_const = true; bool ptr_is_volatile = false; return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, |
