| author | |
| committer | |
| log | 6ae6b5f5b546ab63311b6b08281f5962c9d24667 |
| tree | d88b267fdfe0428bad29a599e69f80c8baa2dbba |
| parent | 76f909edebf86a5d46d24a9dcf897f2cc3ded86d |
8 files changed, 31 insertions(+), 5 deletions(-)
README.md+2| ... | ... | @@ -79,6 +79,8 @@ If you have gcc or clang installed, you can find out what `ZIG_LIBC_LIB_DIR`, |
| 79 | 79 | `ZIG_LIBC_STATIC_LIB_DIR`, and `ZIG_LIBC_INCLUDE_DIR` should be set to |
| 80 | 80 | (example below). |
| 81 | 81 | |
| 82 | For MacOS, `ZIG_LIBC_LIB_DIR` and `ZIG_LIBC_STATIC_LIB_DIR` are unused. | |
| 83 | ||
| 82 | 84 | ``` |
| 83 | 85 | mkdir build |
| 84 | 86 | cd build |
src/all_types.hpp+1| ... | ... | @@ -1124,6 +1124,7 @@ enum BuiltinFnId { |
| 1124 | 1124 | BuiltinFnIdCDefine, |
| 1125 | 1125 | BuiltinFnIdCUndef, |
| 1126 | 1126 | BuiltinFnIdCompileVar, |
| 1127 | BuiltinFnIdCompileErr, | |
| 1127 | 1128 | BuiltinFnIdConstEval, |
| 1128 | 1129 | BuiltinFnIdCtz, |
| 1129 | 1130 | BuiltinFnIdClz, |
src/analyze.cpp+22-2| ... | ... | @@ -4759,6 +4759,20 @@ static TypeTableEntry *analyze_truncate(CodeGen *g, ImportTableEntry *import, |
| 4759 | 4759 | return dest_type; |
| 4760 | 4760 | } |
| 4761 | 4761 | |
| 4762 | static TypeTableEntry *analyze_compile_err(CodeGen *g, ImportTableEntry *import, | |
| 4763 | BlockContext *context, AstNode *node) | |
| 4764 | { | |
| 4765 | AstNode *first_param_node = node->data.fn_call_expr.params.at(0); | |
| 4766 | Buf *err_msg = resolve_const_expr_str(g, import, context, first_param_node->parent_field); | |
| 4767 | if (!err_msg) { | |
| 4768 | return g->builtin_types.entry_invalid; | |
| 4769 | } | |
| 4770 | ||
| 4771 | add_node_error(g, node, err_msg); | |
| 4772 | ||
| 4773 | return g->builtin_types.entry_invalid; | |
| 4774 | } | |
| 4775 | ||
| 4762 | 4776 | static TypeTableEntry *analyze_builtin_fn_call_expr(CodeGen *g, ImportTableEntry *import, BlockContext *context, |
| 4763 | 4777 | TypeTableEntry *expected_type, AstNode *node) |
| 4764 | 4778 | { |
| ... | ... | @@ -5103,6 +5117,8 @@ static TypeTableEntry *analyze_builtin_fn_call_expr(CodeGen *g, ImportTableEntry |
| 5103 | 5117 | return analyze_div_exact(g, import, context, node); |
| 5104 | 5118 | case BuiltinFnIdTruncate: |
| 5105 | 5119 | return analyze_truncate(g, import, context, node); |
| 5120 | case BuiltinFnIdCompileErr: | |
| 5121 | return analyze_compile_err(g, import, context, node); | |
| 5106 | 5122 | } |
| 5107 | 5123 | zig_unreachable(); |
| 5108 | 5124 | } |
| ... | ... | @@ -5763,9 +5779,13 @@ static TypeTableEntry *analyze_switch_expr(CodeGen *g, ImportTableEntry *import, |
| 5763 | 5779 | BlockContext *child_context = prong_node->data.switch_prong.block_context; |
| 5764 | 5780 | child_context->codegen_excluded = expr_val->ok && (*const_chosen_prong_index != prong_i); |
| 5765 | 5781 | |
| 5766 | peer_types[prong_i] = analyze_expression(g, import, child_context, expected_type, | |
| 5767 | prong_node->data.switch_prong.expr); | |
| 5768 | 5782 | peer_nodes[prong_i] = prong_node->data.switch_prong.expr; |
| 5783 | if (child_context->codegen_excluded) { | |
| 5784 | peer_types[prong_i] = g->builtin_types.entry_unreachable; | |
| 5785 | } else { | |
| 5786 | peer_types[prong_i] = analyze_expression(g, import, child_context, expected_type, | |
| 5787 | prong_node->data.switch_prong.expr); | |
| 5788 | } | |
| 5769 | 5789 | } |
| 5770 | 5790 | |
| 5771 | 5791 | if (expr_type->id == TypeTableEntryIdEnum && !else_prong) { |
src/codegen.cpp+2| ... | ... | @@ -539,6 +539,7 @@ static LLVMValueRef gen_builtin_fn_call_expr(CodeGen *g, AstNode *node) { |
| 539 | 539 | case BuiltinFnIdCUndef: |
| 540 | 540 | case BuiltinFnIdImport: |
| 541 | 541 | case BuiltinFnIdCImport: |
| 542 | case BuiltinFnIdCompileErr: | |
| 542 | 543 | zig_unreachable(); |
| 543 | 544 | case BuiltinFnIdCtz: |
| 544 | 545 | case BuiltinFnIdClz: |
| ... | ... | @@ -4655,6 +4656,7 @@ static void define_builtin_fns(CodeGen *g) { |
| 4655 | 4656 | create_builtin_fn_with_arg_count(g, BuiltinFnIdFence, "fence", 1); |
| 4656 | 4657 | create_builtin_fn_with_arg_count(g, BuiltinFnIdDivExact, "div_exact", 2); |
| 4657 | 4658 | create_builtin_fn_with_arg_count(g, BuiltinFnIdTruncate, "truncate", 2); |
| 4659 | create_builtin_fn_with_arg_count(g, BuiltinFnIdCompileErr, "compile_err", 1); | |
| 4658 | 4660 | } |
| 4659 | 4661 | |
| 4660 | 4662 | static void init(CodeGen *g, Buf *source_path) { |
src/eval.cpp+1| ... | ... | @@ -833,6 +833,7 @@ static bool eval_fn_call_builtin(EvalFn *ef, AstNode *node, ConstExprValue *out_ |
| 833 | 833 | case BuiltinFnIdInvalid: |
| 834 | 834 | case BuiltinFnIdFrameAddress: |
| 835 | 835 | case BuiltinFnIdReturnAddress: |
| 836 | case BuiltinFnIdCompileErr: | |
| 836 | 837 | zig_unreachable(); |
| 837 | 838 | } |
| 838 | 839 |
std/bootstrap.zig+1-1| ... | ... | @@ -25,7 +25,7 @@ export fn _start() -> unreachable { |
| 25 | 25 | argc = asm("mov (%%esp), %[argc]": [argc] "=r" (-> isize)); |
| 26 | 26 | argv = asm("lea 0x4(%%esp), %[argv]": [argv] "=r" (-> &&u8)); |
| 27 | 27 | }, |
| 28 | else => unreachable{}, | |
| 28 | else => @compile_err("unsupported arch"), | |
| 29 | 29 | } |
| 30 | 30 | call_main_and_exit() |
| 31 | 31 | } |
std/linux.zig+1-1| ... | ... | @@ -1,7 +1,7 @@ |
| 1 | 1 | const arch = switch (@compile_var("arch")) { |
| 2 | 2 | x86_64 => @import("linux_x86_64.zig"), |
| 3 | 3 | i386 => @import("linux_i386.zig"), |
| 4 | else => unreachable{}, | |
| 4 | else => @compile_err("unsupported arch"), | |
| 5 | 5 | }; |
| 6 | 6 | const errno = @import("errno.zig"); |
| 7 | 7 |
std/os.zig+1-1| ... | ... | @@ -17,7 +17,7 @@ pub fn get_random_bytes(buf: []u8) -> %void { |
| 17 | 17 | } |
| 18 | 18 | } |
| 19 | 19 | }, |
| 20 | else => unreachable{}, | |
| 20 | else => @compile_err("unsupported os"), | |
| 21 | 21 | } |
| 22 | 22 | } |
| 23 | 23 |