| author | |
| committer | |
| log | 91d911007b8a12405c084cff53237ac26b1f2c5f |
| tree | 1571ed6ef821bd664a35b854c946fa9f67f332a9 |
| parent | a922d5d42a3ba9bbded0740e1eb3246e7b57ad2a |
also fix error type analyze error4 files changed, 11 insertions(+), 4 deletions(-)
src/all_types.hpp+1| ... | @@ -1000,6 +1000,7 @@ struct CodeGen { | ... | @@ -1000,6 +1000,7 @@ struct CodeGen { |
| 1000 | bool error_during_imports; | 1000 | bool error_during_imports; |
| 1001 | uint32_t next_node_index; | 1001 | uint32_t next_node_index; |
| 1002 | uint32_t next_error_index; | 1002 | uint32_t next_error_index; |
| 1003 | uint32_t error_value_count; | ||
| 1003 | TypeTableEntry *err_tag_type; | 1004 | TypeTableEntry *err_tag_type; |
| 1004 | }; | 1005 | }; |
| 1005 | 1006 |
src/analyze.cpp+7-2| ... | @@ -2984,7 +2984,7 @@ static TypeTableEntry *analyze_cast_expr(CodeGen *g, ImportTableEntry *import, B | ... | @@ -2984,7 +2984,7 @@ static TypeTableEntry *analyze_cast_expr(CodeGen *g, ImportTableEntry *import, B |
| 2984 | wanted_type->id == TypeTableEntryIdInt) | 2984 | wanted_type->id == TypeTableEntryIdInt) |
| 2985 | { | 2985 | { |
| 2986 | BigNum bn; | 2986 | BigNum bn; |
| 2987 | bignum_init_unsigned(&bn, g->next_error_index); | 2987 | bignum_init_unsigned(&bn, g->error_value_count); |
| 2988 | if (bignum_fits_in_bits(&bn, wanted_type->size_in_bits, wanted_type->data.integral.is_signed)) { | 2988 | if (bignum_fits_in_bits(&bn, wanted_type->size_in_bits, wanted_type->data.integral.is_signed)) { |
| 2989 | node->data.fn_call_expr.cast_op = CastOpErrToInt; | 2989 | node->data.fn_call_expr.cast_op = CastOpErrToInt; |
| 2990 | eval_const_expr_implicit_cast(g, node, expr_node); | 2990 | eval_const_expr_implicit_cast(g, node, expr_node); |
| ... | @@ -4355,10 +4355,15 @@ void semantic_analyze(CodeGen *g) { | ... | @@ -4355,10 +4355,15 @@ void semantic_analyze(CodeGen *g) { |
| 4355 | assert(target_import); | 4355 | assert(target_import); |
| 4356 | 4356 | ||
| 4357 | target_import->importers.append({import, child}); | 4357 | target_import->importers.append({import, child}); |
| 4358 | } else if (child->type == NodeTypeErrorValueDecl) { | ||
| 4359 | g->error_value_count += 1; | ||
| 4358 | } | 4360 | } |
| 4359 | } | 4361 | } |
| 4360 | } | 4362 | } |
| 4361 | } | 4363 | } |
| 4364 | |||
| 4365 | g->err_tag_type = get_smallest_unsigned_int_type(g, g->error_value_count); | ||
| 4366 | |||
| 4362 | { | 4367 | { |
| 4363 | auto it = g->import_table.entry_iterator(); | 4368 | auto it = g->import_table.entry_iterator(); |
| 4364 | for (;;) { | 4369 | for (;;) { |
| ... | @@ -4375,7 +4380,7 @@ void semantic_analyze(CodeGen *g) { | ... | @@ -4375,7 +4380,7 @@ void semantic_analyze(CodeGen *g) { |
| 4375 | } | 4380 | } |
| 4376 | } | 4381 | } |
| 4377 | 4382 | ||
| 4378 | g->err_tag_type = get_smallest_unsigned_int_type(g, g->next_error_index); | 4383 | assert(g->error_value_count == g->next_error_index); |
| 4379 | 4384 | ||
| 4380 | { | 4385 | { |
| 4381 | auto it = g->import_table.entry_iterator(); | 4386 | auto it = g->import_table.entry_iterator(); |
src/codegen.cpp+2-1| ... | @@ -27,6 +27,7 @@ CodeGen *codegen_create(Buf *root_source_dir) { | ... | @@ -27,6 +27,7 @@ CodeGen *codegen_create(Buf *root_source_dir) { |
| 27 | g->build_type = CodeGenBuildTypeDebug; | 27 | g->build_type = CodeGenBuildTypeDebug; |
| 28 | g->root_source_dir = root_source_dir; | 28 | g->root_source_dir = root_source_dir; |
| 29 | g->next_error_index = 1; | 29 | g->next_error_index = 1; |
| 30 | g->error_value_count = 1; | ||
| 30 | 31 | ||
| 31 | return g; | 32 | return g; |
| 32 | } | 33 | } |
| ... | @@ -684,7 +685,7 @@ static LLVMValueRef gen_field_access_expr(CodeGen *g, AstNode *node, bool is_lva | ... | @@ -684,7 +685,7 @@ static LLVMValueRef gen_field_access_expr(CodeGen *g, AstNode *node, bool is_lva |
| 684 | { | 685 | { |
| 685 | TypeTableEntry *type_entry; | 686 | TypeTableEntry *type_entry; |
| 686 | LLVMValueRef ptr = gen_field_ptr(g, node, &type_entry); | 687 | LLVMValueRef ptr = gen_field_ptr(g, node, &type_entry); |
| 687 | if (is_lvalue) { | 688 | if (is_lvalue || handle_is_ptr(type_entry)) { |
| 688 | return ptr; | 689 | return ptr; |
| 689 | } else { | 690 | } else { |
| 690 | add_debug_source_node(g, node); | 691 | add_debug_source_node(g, node); |
std/std.zig+1-1| ... | @@ -97,7 +97,7 @@ pub struct OutStream { | ... | @@ -97,7 +97,7 @@ pub struct OutStream { |
| 97 | pub fn flush(os: &OutStream) %void => { | 97 | pub fn flush(os: &OutStream) %void => { |
| 98 | const amt_to_write = os.index; | 98 | const amt_to_write = os.index; |
| 99 | os.index = 0; | 99 | os.index = 0; |
| 100 | switch (write(fd, os.buffer.ptr, amt_to_write)) { | 100 | switch (write(os.fd, os.buffer.ptr, amt_to_write)) { |
| 101 | EINVAL => unreachable{}, | 101 | EINVAL => unreachable{}, |
| 102 | EDQUOT => %.DiskQuota, | 102 | EDQUOT => %.DiskQuota, |
| 103 | EFBIG => %.FileTooBig, | 103 | EFBIG => %.FileTooBig, |