| author | |
| committer | |
| log | 974db231a08731f642dbf72d716f669fed2bd2ab |
| tree | 209e1a0766c98f1a1a471fbd0eab97d3bbb093dc |
| parent | e36680d3bd08fceb3e976edeafae60ce6d577342 |
| signature |
3 files changed, 23 insertions(+), 18 deletions(-)
src/codegen.cpp+6-1| ... | ... | @@ -3853,6 +3853,9 @@ static LLVMValueRef ir_render_struct_field_ptr(CodeGen *g, IrExecutable *executa |
| 3853 | 3853 | static LLVMValueRef ir_render_union_field_ptr(CodeGen *g, IrExecutable *executable, |
| 3854 | 3854 | IrInstructionUnionFieldPtr *instruction) |
| 3855 | 3855 | { |
| 3856 | if (instruction->base.value.special != ConstValSpecialRuntime) | |
| 3857 | return nullptr; | |
| 3858 | ||
| 3856 | 3859 | ZigType *union_ptr_type = instruction->union_ptr->value.type; |
| 3857 | 3860 | assert(union_ptr_type->id == ZigTypeIdPointer); |
| 3858 | 3861 | ZigType *union_type = union_ptr_type->data.pointer.child_type; |
| ... | ... | @@ -4077,6 +4080,9 @@ static LLVMValueRef ir_render_test_non_null(CodeGen *g, IrExecutable *executable |
| 4077 | 4080 | static LLVMValueRef ir_render_optional_unwrap_ptr(CodeGen *g, IrExecutable *executable, |
| 4078 | 4081 | IrInstructionOptionalUnwrapPtr *instruction) |
| 4079 | 4082 | { |
| 4083 | if (instruction->base.value.special != ConstValSpecialRuntime) | |
| 4084 | return nullptr; | |
| 4085 | ||
| 4080 | 4086 | ZigType *ptr_type = instruction->base_ptr->value.type; |
| 4081 | 4087 | assert(ptr_type->id == ZigTypeIdPointer); |
| 4082 | 4088 | ZigType *maybe_type = ptr_type->data.pointer.child_type; |
| ... | ... | @@ -5750,7 +5756,6 @@ static void ir_render(CodeGen *g, ZigFn *fn_entry) { |
| 5750 | 5756 | assert(executable->basic_block_list.length > 0); |
| 5751 | 5757 | for (size_t block_i = 0; block_i < executable->basic_block_list.length; block_i += 1) { |
| 5752 | 5758 | IrBasicBlock *current_block = executable->basic_block_list.at(block_i); |
| 5753 | //assert(current_block->ref_count > 0); | |
| 5754 | 5759 | assert(current_block->llvm_block); |
| 5755 | 5760 | LLVMPositionBuilderAtEnd(g->builder, current_block->llvm_block); |
| 5756 | 5761 | for (size_t instr_i = 0; instr_i < current_block->instruction_list.length; instr_i += 1) { |
test/stage1/behavior.zig+1-1| ... | ... | @@ -45,7 +45,7 @@ comptime { |
| 45 | 45 | //_ = @import("behavior/coroutine_await_struct.zig"); |
| 46 | 46 | //_ = @import("behavior/coroutines.zig"); |
| 47 | 47 | _ = @import("behavior/defer.zig"); |
| 48 | _ = @import("behavior/enum.zig"); // TODO | |
| 48 | _ = @import("behavior/enum.zig"); | |
| 49 | 49 | _ = @import("behavior/enum_with_members.zig"); |
| 50 | 50 | _ = @import("behavior/error.zig"); // TODO |
| 51 | 51 | _ = @import("behavior/eval.zig"); |
test/stage1/behavior/enum.zig+16-16| ... | ... | @@ -1,22 +1,22 @@ |
| 1 | 1 | const expect = @import("std").testing.expect; |
| 2 | 2 | const mem = @import("std").mem; |
| 3 | 3 | |
| 4 | //test "enum type" { | |
| 5 | // const foo1 = Foo{ .One = 13 }; | |
| 6 | // const foo2 = Foo{ | |
| 7 | // .Two = Point{ | |
| 8 | // .x = 1234, | |
| 9 | // .y = 5678, | |
| 10 | // }, | |
| 11 | // }; | |
| 12 | // const bar = Bar.B; | |
| 13 | // | |
| 14 | // expect(bar == Bar.B); | |
| 15 | // expect(@memberCount(Foo) == 3); | |
| 16 | // expect(@memberCount(Bar) == 4); | |
| 17 | // expect(@sizeOf(Foo) == @sizeOf(FooNoVoid)); | |
| 18 | // expect(@sizeOf(Bar) == 1); | |
| 19 | //} | |
| 4 | test "enum type" { | |
| 5 | const foo1 = Foo{ .One = 13 }; | |
| 6 | const foo2 = Foo{ | |
| 7 | .Two = Point{ | |
| 8 | .x = 1234, | |
| 9 | .y = 5678, | |
| 10 | }, | |
| 11 | }; | |
| 12 | const bar = Bar.B; | |
| 13 | ||
| 14 | expect(bar == Bar.B); | |
| 15 | expect(@memberCount(Foo) == 3); | |
| 16 | expect(@memberCount(Bar) == 4); | |
| 17 | expect(@sizeOf(Foo) == @sizeOf(FooNoVoid)); | |
| 18 | expect(@sizeOf(Bar) == 1); | |
| 19 | } | |
| 20 | 20 | |
| 21 | 21 | test "enum as return value" { |
| 22 | 22 | switch (returnAnInt(13)) { |