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