authorgravatar for zseri.devel@ytrizja.dezseri <zseri.devel@ytrizja.de> 2022-01-30 11:09:07+01:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-01-30 21:31:54+02:00
log91ad96b88a88016043cb0d069aa9db47747170b6
treecaf6fd8e4c05f5e70db851e3487d57474aa093ad
parent8a97807d6812f62db4c3088fecd04a98a84b9943

ir.cpp: use is_tagged_union to DRY


1 files changed, 3 insertions(+), 10 deletions(-)

src/stage1/ir.cpp+3-10
...@@ -5166,9 +5166,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT...@@ -5166,9 +5166,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT
5166 continue;5166 continue;
5167 }5167 }
51685168
5169 if (prev_type->id == ZigTypeIdEnum && cur_type->id == ZigTypeIdUnion &&5169 if (prev_type->id == ZigTypeIdEnum && is_tagged_union(cur_type)) {
5170 (cur_type->data.unionation.decl_node->data.container_decl.auto_enum || cur_type->data.unionation.decl_node->data.container_decl.init_arg_expr != nullptr))
5171 {
5172 if ((err = type_resolve(ira->codegen, cur_type, ResolveStatusZeroBitsKnown)))5170 if ((err = type_resolve(ira->codegen, cur_type, ResolveStatusZeroBitsKnown)))
5173 return ira->codegen->builtin_types.entry_invalid;5171 return ira->codegen->builtin_types.entry_invalid;
5174 if (cur_type->data.unionation.tag_type == prev_type) {5172 if (cur_type->data.unionation.tag_type == prev_type) {
...@@ -5176,9 +5174,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT...@@ -5176,9 +5174,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT
5176 }5174 }
5177 }5175 }
51785176
5179 if (cur_type->id == ZigTypeIdEnum && prev_type->id == ZigTypeIdUnion &&5177 if (cur_type->id == ZigTypeIdEnum && is_tagged_union(prev_type)) {
5180 (prev_type->data.unionation.decl_node->data.container_decl.auto_enum || prev_type->data.unionation.decl_node->data.container_decl.init_arg_expr != nullptr))
5181 {
5182 if ((err = type_resolve(ira->codegen, prev_type, ResolveStatusZeroBitsKnown)))5178 if ((err = type_resolve(ira->codegen, prev_type, ResolveStatusZeroBitsKnown)))
5183 return ira->codegen->builtin_types.entry_invalid;5179 return ira->codegen->builtin_types.entry_invalid;
5184 if (prev_type->data.unionation.tag_type == cur_type) {5180 if (prev_type->data.unionation.tag_type == cur_type) {
...@@ -15816,10 +15812,7 @@ static Stage1AirInst *ir_analyze_instruction_field_ptr(IrAnalyze *ira, Stage1Zir...@@ -15816,10 +15812,7 @@ static Stage1AirInst *ir_analyze_instruction_field_ptr(IrAnalyze *ira, Stage1Zir
15816 }15812 }
15817 return ir_analyze_decl_ref(ira, field_ptr_instruction->base.scope, field_ptr_instruction->base.source_node, tld);15813 return ir_analyze_decl_ref(ira, field_ptr_instruction->base.scope, field_ptr_instruction->base.source_node, tld);
15818 }15814 }
15819 if (child_type->id == ZigTypeIdUnion &&15815 if (is_tagged_union(child_type)) {
15820 (child_type->data.unionation.decl_node->data.container_decl.init_arg_expr != nullptr ||
15821 child_type->data.unionation.decl_node->data.container_decl.auto_enum))
15822 {
15823 if ((err = type_resolve(ira->codegen, child_type, ResolveStatusSizeKnown)))15816 if ((err = type_resolve(ira->codegen, child_type, ResolveStatusSizeKnown)))
15824 return ira->codegen->invalid_inst_gen;15817 return ira->codegen->invalid_inst_gen;
15825 TypeUnionField *field = find_union_type_field(child_type, field_name);15818 TypeUnionField *field = find_union_type_field(child_type, field_name);