| author | |
| committer | |
| log | d9eabde319bc035f710b106808022e9b5872f728 |
| tree | 798876d64f37829bdc3eb637ef35e648493afe8f |
| parent | 5931a6b1a5b8f4941fc9b78f8960745f81594f17 |
also rename child field to Child for pointer and array6 files changed, 25 insertions(+), 6 deletions(-)
cmake/Findllvm.cmake+3-1| ... | ... | @@ -104,9 +104,11 @@ else() |
| 104 | 104 | |
| 105 | 105 | set(LLVM_LIBRARIES ${LLVM_LIBRARIES} ${LLVM_SYSTEM_LIBS}) |
| 106 | 106 | |
| 107 | if(LLVM_LIBRARY) | |
| 107 | if(LLVM_LIBRARY AND NOT LLVM_LIBRARIES) | |
| 108 | 108 | set(LLVM_LIBRARIES ${LLVM_LIBRARY}) |
| 109 | 109 | endif() |
| 110 | ||
| 111 | link_directories("${CMAKE_PREFIX_PATH}/lib") | |
| 110 | 112 | endif() |
| 111 | 113 | |
| 112 | 114 |
src/ir.cpp+13-2| ... | ... | @@ -11432,6 +11432,17 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru |
| 11432 | 11432 | if (type_is_invalid(child_type)) { |
| 11433 | 11433 | return ira->codegen->builtin_types.entry_invalid; |
| 11434 | 11434 | } else if (is_container(child_type)) { |
| 11435 | if (is_slice(child_type) && buf_eql_str(field_name, "Child")) { | |
| 11436 | bool ptr_is_const = true; | |
| 11437 | bool ptr_is_volatile = false; | |
| 11438 | TypeStructField *ptr_field = &child_type->data.structure.fields[slice_ptr_index]; | |
| 11439 | assert(ptr_field->type_entry->id == TypeTableEntryIdPointer); | |
| 11440 | TypeTableEntry *child_type = ptr_field->type_entry->data.pointer.child_type; | |
| 11441 | return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, | |
| 11442 | create_const_type(ira->codegen, child_type), | |
| 11443 | ira->codegen->builtin_types.entry_type, | |
| 11444 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile); | |
| 11445 | } | |
| 11435 | 11446 | if (child_type->id == TypeTableEntryIdEnum) { |
| 11436 | 11447 | ensure_complete_type(ira->codegen, child_type); |
| 11437 | 11448 | if (child_type->data.enumeration.is_invalid) |
| ... | ... | @@ -11522,7 +11533,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru |
| 11522 | 11533 | return ira->codegen->builtin_types.entry_invalid; |
| 11523 | 11534 | } |
| 11524 | 11535 | } else if (child_type->id == TypeTableEntryIdPointer) { |
| 11525 | if (buf_eql_str(field_name, "child")) { | |
| 11536 | if (buf_eql_str(field_name, "Child")) { | |
| 11526 | 11537 | bool ptr_is_const = true; |
| 11527 | 11538 | bool ptr_is_volatile = false; |
| 11528 | 11539 | return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, |
| ... | ... | @@ -11544,7 +11555,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru |
| 11544 | 11555 | return ira->codegen->builtin_types.entry_invalid; |
| 11545 | 11556 | } |
| 11546 | 11557 | } else if (child_type->id == TypeTableEntryIdArray) { |
| 11547 | if (buf_eql_str(field_name, "child")) { | |
| 11558 | if (buf_eql_str(field_name, "Child")) { | |
| 11548 | 11559 | bool ptr_is_const = true; |
| 11549 | 11560 | bool ptr_is_volatile = false; |
| 11550 | 11561 | return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, |
std/fmt/index.zig+1-1| ... | ... | @@ -208,7 +208,7 @@ pub fn formatValue(value: var, context: var, output: fn(@typeOf(context), []cons |
| 208 | 208 | return output(context, @errorName(value)); |
| 209 | 209 | }, |
| 210 | 210 | builtin.TypeId.Pointer => { |
| 211 | if (@typeId(T.child) == builtin.TypeId.Array and T.child.child == u8) { | |
| 211 | if (@typeId(T.Child) == builtin.TypeId.Array and T.Child.Child == u8) { | |
| 212 | 212 | return output(context, (*value)[0..]); |
| 213 | 213 | } else { |
| 214 | 214 | @compileError("Unable to format type '" ++ @typeName(T) ++ "'"); |
test/cases/array.zig+1-1| ... | ... | @@ -89,7 +89,7 @@ test "array literal with specified size" { |
| 89 | 89 | |
| 90 | 90 | test "array child property" { |
| 91 | 91 | var x: [5]i32 = undefined; |
| 92 | assert(@typeOf(x).child == i32); | |
| 92 | assert(@typeOf(x).Child == i32); | |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | test "array len property" { |
test/cases/misc.zig+1-1| ... | ... | @@ -536,7 +536,7 @@ export fn writeToVRam() { |
| 536 | 536 | } |
| 537 | 537 | |
| 538 | 538 | test "pointer child field" { |
| 539 | assert((&u32).child == u32); | |
| 539 | assert((&u32).Child == u32); | |
| 540 | 540 | } |
| 541 | 541 | |
| 542 | 542 | const OpaqueA = @OpaqueType(); |
test/cases/slice.zig+6| ... | ... | @@ -9,3 +9,9 @@ test "compile time slice of pointer to hard coded address" { |
| 9 | 9 | assert(@ptrToInt(y.ptr) == 0x1100); |
| 10 | 10 | assert(y.len == 0x400); |
| 11 | 11 | } |
| 12 | ||
| 13 | test "slice child property" { | |
| 14 | var array: [5]i32 = undefined; | |
| 15 | var slice = array[0..]; | |
| 16 | assert(@typeOf(slice).Child == i32); | |
| 17 | } |