| author | |
| committer | |
| log | 4c50606b9d41c2c3d9f25dc8bf0848e30e338f6e |
| tree | 7bebbbac71fa1fde2f90213b7b0c60d6ef1a84ad |
| parent | fbbef140130e8da13f1d58b884ec3a0225965531 |
4 files changed, 7 insertions(+), 12 deletions(-)
README.md+1-1| ... | ... | @@ -52,7 +52,7 @@ compromises backward compatibility. |
| 52 | 52 | |
| 53 | 53 | * Have a look in the examples/ folder to see some code examples. |
| 54 | 54 | * Basic language features available such as loops, inline assembly, |
| 55 | expressions, literals, functions, importing, structs, enums. | |
| 55 | expressions, literals, functions, importing, structs, tagged unions. | |
| 56 | 56 | * Linux x86_64 is supported. |
| 57 | 57 | * Building for the native target is supported. |
| 58 | 58 | * Optimized machine code that Zig produces is indistinguishable from |
src/codegen.cpp+1-1| ... | ... | @@ -1790,7 +1790,7 @@ static LLVMValueRef gen_for_expr(CodeGen *g, AstNode *node) { |
| 1790 | 1790 | LLVMBasicBlockRef body_block = LLVMAppendBasicBlock(g->cur_fn->fn_value, "ForBody"); |
| 1791 | 1791 | LLVMBasicBlockRef end_block = LLVMAppendBasicBlock(g->cur_fn->fn_value, "ForEnd"); |
| 1792 | 1792 | |
| 1793 | LLVMValueRef array_val = gen_expr(g, node->data.for_expr.array_expr); | |
| 1793 | LLVMValueRef array_val = gen_array_base_ptr(g, node->data.for_expr.array_expr); | |
| 1794 | 1794 | add_debug_source_node(g, node); |
| 1795 | 1795 | LLVMBuildStore(g->builder, LLVMConstNull(index_var->type->type_ref), index_ptr); |
| 1796 | 1796 | LLVMValueRef len_val; |
std/rand.zig+4-5| ... | ... | @@ -11,9 +11,10 @@ pub struct Rand { |
| 11 | 11 | r.index = 0; |
| 12 | 12 | r.array[0] = seed; |
| 13 | 13 | var i : @typeof(ARRAY_SIZE) = 1; |
| 14 | var prev_value: u64 = seed; | |
| 14 | 15 | while (i < ARRAY_SIZE) { |
| 15 | const prev_value : u64 = r.array[i - 1]; | |
| 16 | 16 | r.array[i] = u32((prev_value ^ (prev_value << 30)) * 0x6c078965 + i); |
| 17 | prev_value = r.array[i]; | |
| 17 | 18 | i += 1; |
| 18 | 19 | } |
| 19 | 20 | } |
| ... | ... | @@ -67,9 +68,8 @@ pub struct Rand { |
| 67 | 68 | } |
| 68 | 69 | |
| 69 | 70 | fn generate_numbers(r: &Rand) => { |
| 70 | var i : @typeof(ARRAY_SIZE) = 0; | |
| 71 | while (i < ARRAY_SIZE) { | |
| 72 | const y : u32 = (r.array[i] & 0x80000000) + (r.array[(i + 1) % ARRAY_SIZE] & 0x7fffffff); | |
| 71 | for (item, r.array, i) { | |
| 72 | const y : u32 = (item & 0x80000000) + (r.array[(i + 1) % ARRAY_SIZE] & 0x7fffffff); | |
| 73 | 73 | const untempered : u32 = r.array[(i + 397) % ARRAY_SIZE] ^ (y >> 1); |
| 74 | 74 | r.array[i] = if ((y % 2) == 0) { |
| 75 | 75 | untempered |
| ... | ... | @@ -77,7 +77,6 @@ pub struct Rand { |
| 77 | 77 | // y is odd |
| 78 | 78 | untempered ^ 0x9908b0df |
| 79 | 79 | }; |
| 80 | i += 1; | |
| 81 | 80 | } |
| 82 | 81 | } |
| 83 | 82 |
std/std.zig+1-5| ... | ... | @@ -51,9 +51,7 @@ pub fn readline(buf: []u8, out_len: &usize) bool => { |
| 51 | 51 | pub fn parse_u64(buf: []u8, radix: u8, result: &u64) bool => { |
| 52 | 52 | var x : u64 = 0; |
| 53 | 53 | |
| 54 | var i : @typeof(buf.len) = 0; | |
| 55 | while (i < buf.len) { | |
| 56 | const c = buf[i]; | |
| 54 | for (c, buf) { | |
| 57 | 55 | const digit = char_to_digit(c); |
| 58 | 56 | |
| 59 | 57 | if (digit > radix) { |
| ... | ... | @@ -69,8 +67,6 @@ pub fn parse_u64(buf: []u8, radix: u8, result: &u64) bool => { |
| 69 | 67 | if (@add_with_overflow(u64, x, digit, &x)) { |
| 70 | 68 | return true; |
| 71 | 69 | } |
| 72 | ||
| 73 | i += 1; | |
| 74 | 70 | } |
| 75 | 71 | |
| 76 | 72 | *result = x; |