authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-06-01 11:49:25-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2018-06-01 11:49:25-04:00
log3918e7699db07540d59aeef7728e5dff54d9e874
tree5ccfd67157be19b745c469e923ed92691670b6e9
parent717ac85a5acb5e6ae063c4d0eb3b8f1bd260776a
parente29d12d8218c6f84d4fd59b7c8672d3b38c79390
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #1032 from ziglang/pointer-reform

use * for pointer type instead of &

150 files changed, 2438 insertions(+), 2350 deletions(-)

build.zig+7-7
......@@ -10,7 +10,7 @@ const ArrayList = std.ArrayList;
1010const Buffer = std.Buffer;
1111const io = std.io;
1212
13pub fn build(b: &Builder) !void {
13pub fn build(b: *Builder) !void {
1414 const mode = b.standardReleaseOptions();
1515
1616 var docgen_exe = b.addExecutable("docgen", "doc/docgen.zig");
......@@ -132,7 +132,7 @@ pub fn build(b: &Builder) !void {
132132 test_step.dependOn(tests.addGenHTests(b, test_filter));
133133}
134134
135fn dependOnLib(lib_exe_obj: &std.build.LibExeObjStep, dep: &const LibraryDep) void {
135fn dependOnLib(lib_exe_obj: *std.build.LibExeObjStep, dep: *const LibraryDep) void {
136136 for (dep.libdirs.toSliceConst()) |lib_dir| {
137137 lib_exe_obj.addLibPath(lib_dir);
138138 }
......@@ -147,7 +147,7 @@ fn dependOnLib(lib_exe_obj: &std.build.LibExeObjStep, dep: &const LibraryDep) vo
147147 }
148148}
149149
150fn addCppLib(b: &Builder, lib_exe_obj: &std.build.LibExeObjStep, cmake_binary_dir: []const u8, lib_name: []const u8) void {
150fn addCppLib(b: *Builder, lib_exe_obj: *std.build.LibExeObjStep, cmake_binary_dir: []const u8, lib_name: []const u8) void {
151151 const lib_prefix = if (lib_exe_obj.target.isWindows()) "" else "lib";
152152 lib_exe_obj.addObjectFile(os.path.join(b.allocator, cmake_binary_dir, "zig_cpp", b.fmt("{}{}{}", lib_prefix, lib_name, lib_exe_obj.target.libFileExt())) catch unreachable);
153153}
......@@ -159,7 +159,7 @@ const LibraryDep = struct {
159159 includes: ArrayList([]const u8),
160160};
161161
162fn findLLVM(b: &Builder, llvm_config_exe: []const u8) !LibraryDep {
162fn findLLVM(b: *Builder, llvm_config_exe: []const u8) !LibraryDep {
163163 const libs_output = try b.exec([][]const u8{
164164 llvm_config_exe,
165165 "--libs",
......@@ -217,7 +217,7 @@ fn findLLVM(b: &Builder, llvm_config_exe: []const u8) !LibraryDep {
217217 return result;
218218}
219219
220pub fn installStdLib(b: &Builder, stdlib_files: []const u8) void {
220pub fn installStdLib(b: *Builder, stdlib_files: []const u8) void {
221221 var it = mem.split(stdlib_files, ";");
222222 while (it.next()) |stdlib_file| {
223223 const src_path = os.path.join(b.allocator, "std", stdlib_file) catch unreachable;
......@@ -226,7 +226,7 @@ pub fn installStdLib(b: &Builder, stdlib_files: []const u8) void {
226226 }
227227}
228228
229pub fn installCHeaders(b: &Builder, c_header_files: []const u8) void {
229pub fn installCHeaders(b: *Builder, c_header_files: []const u8) void {
230230 var it = mem.split(c_header_files, ";");
231231 while (it.next()) |c_header_file| {
232232 const src_path = os.path.join(b.allocator, "c_headers", c_header_file) catch unreachable;
......@@ -235,7 +235,7 @@ pub fn installCHeaders(b: &Builder, c_header_files: []const u8) void {
235235 }
236236}
237237
238fn nextValue(index: &usize, build_info: []const u8) []const u8 {
238fn nextValue(index: *usize, build_info: []const u8) []const u8 {
239239 const start = index.*;
240240 while (true) : (index.* += 1) {
241241 switch (build_info[index.*]) {
doc/docgen.zig+11-11
......@@ -104,7 +104,7 @@ const Tokenizer = struct {
104104 };
105105 }
106106
107 fn next(self: &Tokenizer) Token {
107 fn next(self: *Tokenizer) Token {
108108 var result = Token{
109109 .id = Token.Id.Eof,
110110 .start = self.index,
......@@ -196,7 +196,7 @@ const Tokenizer = struct {
196196 line_end: usize,
197197 };
198198
199 fn getTokenLocation(self: &Tokenizer, token: &const Token) Location {
199 fn getTokenLocation(self: *Tokenizer, token: *const Token) Location {
200200 var loc = Location{
201201 .line = 0,
202202 .column = 0,
......@@ -221,7 +221,7 @@ const Tokenizer = struct {
221221 }
222222};
223223
224fn parseError(tokenizer: &Tokenizer, token: &const Token, comptime fmt: []const u8, args: ...) error {
224fn parseError(tokenizer: *Tokenizer, token: *const Token, comptime fmt: []const u8, args: ...) error {
225225 const loc = tokenizer.getTokenLocation(token);
226226 warn("{}:{}:{}: error: " ++ fmt ++ "\n", tokenizer.source_file_name, loc.line + 1, loc.column + 1, args);
227227 if (loc.line_start <= loc.line_end) {
......@@ -244,13 +244,13 @@ fn parseError(tokenizer: &Tokenizer, token: &const Token, comptime fmt: []const
244244 return error.ParseError;
245245}
246246
247fn assertToken(tokenizer: &Tokenizer, token: &const Token, id: Token.Id) !void {
247fn assertToken(tokenizer: *Tokenizer, token: *const Token, id: Token.Id) !void {
248248 if (token.id != id) {
249249 return parseError(tokenizer, token, "expected {}, found {}", @tagName(id), @tagName(token.id));
250250 }
251251}
252252
253fn eatToken(tokenizer: &Tokenizer, id: Token.Id) !Token {
253fn eatToken(tokenizer: *Tokenizer, id: Token.Id) !Token {
254254 const token = tokenizer.next();
255255 try assertToken(tokenizer, token, id);
256256 return token;
......@@ -317,7 +317,7 @@ const Action = enum {
317317 Close,
318318};
319319
320fn genToc(allocator: &mem.Allocator, tokenizer: &Tokenizer) !Toc {
320fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc {
321321 var urls = std.HashMap([]const u8, Token, mem.hash_slice_u8, mem.eql_slice_u8).init(allocator);
322322 errdefer urls.deinit();
323323
......@@ -546,7 +546,7 @@ fn genToc(allocator: &mem.Allocator, tokenizer: &Tokenizer) !Toc {
546546 };
547547}
548548
549fn urlize(allocator: &mem.Allocator, input: []const u8) ![]u8 {
549fn urlize(allocator: *mem.Allocator, input: []const u8) ![]u8 {
550550 var buf = try std.Buffer.initSize(allocator, 0);
551551 defer buf.deinit();
552552
......@@ -566,7 +566,7 @@ fn urlize(allocator: &mem.Allocator, input: []const u8) ![]u8 {
566566 return buf.toOwnedSlice();
567567}
568568
569fn escapeHtml(allocator: &mem.Allocator, input: []const u8) ![]u8 {
569fn escapeHtml(allocator: *mem.Allocator, input: []const u8) ![]u8 {
570570 var buf = try std.Buffer.initSize(allocator, 0);
571571 defer buf.deinit();
572572
......@@ -608,7 +608,7 @@ test "term color" {
608608 assert(mem.eql(u8, result, "A<span class=\"t32\">green</span>B"));
609609}
610610
611fn termColor(allocator: &mem.Allocator, input: []const u8) ![]u8 {
611fn termColor(allocator: *mem.Allocator, input: []const u8) ![]u8 {
612612 var buf = try std.Buffer.initSize(allocator, 0);
613613 defer buf.deinit();
614614
......@@ -688,7 +688,7 @@ fn termColor(allocator: &mem.Allocator, input: []const u8) ![]u8 {
688688 return buf.toOwnedSlice();
689689}
690690
691fn genHtml(allocator: &mem.Allocator, tokenizer: &Tokenizer, toc: &Toc, out: var, zig_exe: []const u8) !void {
691fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var, zig_exe: []const u8) !void {
692692 var code_progress_index: usize = 0;
693693 for (toc.nodes) |node| {
694694 switch (node) {
......@@ -1036,7 +1036,7 @@ fn genHtml(allocator: &mem.Allocator, tokenizer: &Tokenizer, toc: &Toc, out: var
10361036 }
10371037}
10381038
1039fn exec(allocator: &mem.Allocator, args: []const []const u8) !os.ChildProcess.ExecResult {
1039fn exec(allocator: *mem.Allocator, args: []const []const u8) !os.ChildProcess.ExecResult {
10401040 const result = try os.ChildProcess.exec(allocator, args, null, null, max_doc_file_size);
10411041 switch (result.term) {
10421042 os.ChildProcess.Term.Exited => |exit_code| {
doc/langref.html.in+106-106
......@@ -458,7 +458,7 @@ test "string literals" {
458458
459459 // A C string literal is a null terminated pointer.
460460 const null_terminated_bytes = c"hello";
461 assert(@typeOf(null_terminated_bytes) == &const u8);
461 assert(@typeOf(null_terminated_bytes) == *const u8);
462462 assert(null_terminated_bytes[5] == 0);
463463}
464464 {#code_end#}
......@@ -547,7 +547,7 @@ const c_string_literal =
547547;
548548 {#code_end#}
549549 <p>
550 In this example the variable <code>c_string_literal</code> has type <code>&amp;const char</code> and
550 In this example the variable <code>c_string_literal</code> has type <code>*const char</code> and
551551 has a terminating null byte.
552552 </p>
553553 {#see_also|@embedFile#}
......@@ -1403,12 +1403,12 @@ test "address of syntax" {
14031403 assert(x_ptr.* == 1234);
14041404
14051405 // When you get the address of a const variable, you get a const pointer.
1406 assert(@typeOf(x_ptr) == &const i32);
1406 assert(@typeOf(x_ptr) == *const i32);
14071407
14081408 // If you want to mutate the value, you'd need an address of a mutable variable:
14091409 var y: i32 = 5678;
14101410 const y_ptr = &y;
1411 assert(@typeOf(y_ptr) == &i32);
1411 assert(@typeOf(y_ptr) == *i32);
14121412 y_ptr.* += 1;
14131413 assert(y_ptr.* == 5679);
14141414}
......@@ -1455,7 +1455,7 @@ comptime {
14551455
14561456test "@ptrToInt and @intToPtr" {
14571457 // To convert an integer address into a pointer, use @intToPtr:
1458 const ptr = @intToPtr(&i32, 0xdeadbeef);
1458 const ptr = @intToPtr(*i32, 0xdeadbeef);
14591459
14601460 // To convert a pointer to an integer, use @ptrToInt:
14611461 const addr = @ptrToInt(ptr);
......@@ -1467,7 +1467,7 @@ test "@ptrToInt and @intToPtr" {
14671467comptime {
14681468 // Zig is able to do this at compile-time, as long as
14691469 // ptr is never dereferenced.
1470 const ptr = @intToPtr(&i32, 0xdeadbeef);
1470 const ptr = @intToPtr(*i32, 0xdeadbeef);
14711471 const addr = @ptrToInt(ptr);
14721472 assert(@typeOf(addr) == usize);
14731473 assert(addr == 0xdeadbeef);
......@@ -1477,17 +1477,17 @@ test "volatile" {
14771477 // In Zig, loads and stores are assumed to not have side effects.
14781478 // If a given load or store should have side effects, such as
14791479 // Memory Mapped Input/Output (MMIO), use `volatile`:
1480 const mmio_ptr = @intToPtr(&volatile u8, 0x12345678);
1480 const mmio_ptr = @intToPtr(*volatile u8, 0x12345678);
14811481
14821482 // Now loads and stores with mmio_ptr are guaranteed to all happen
14831483 // and in the same order as in source code.
1484 assert(@typeOf(mmio_ptr) == &volatile u8);
1484 assert(@typeOf(mmio_ptr) == *volatile u8);
14851485}
14861486
14871487test "nullable pointers" {
14881488 // Pointers cannot be null. If you want a null pointer, use the nullable
14891489 // prefix `?` to make the pointer type nullable.
1490 var ptr: ?&i32 = null;
1490 var ptr: ?*i32 = null;
14911491
14921492 var x: i32 = 1;
14931493 ptr = &x;
......@@ -1496,7 +1496,7 @@ test "nullable pointers" {
14961496
14971497 // Nullable pointers are the same size as normal pointers, because pointer
14981498 // value 0 is used as the null value.
1499 assert(@sizeOf(?&i32) == @sizeOf(&i32));
1499 assert(@sizeOf(?*i32) == @sizeOf(*i32));
15001500}
15011501
15021502test "pointer casting" {
......@@ -1504,7 +1504,7 @@ test "pointer casting" {
15041504 // operation that Zig cannot protect you against. Use @ptrCast only when other
15051505 // conversions are not possible.
15061506 const bytes align(@alignOf(u32)) = []u8{0x12, 0x12, 0x12, 0x12};
1507 const u32_ptr = @ptrCast(&const u32, &bytes[0]);
1507 const u32_ptr = @ptrCast(*const u32, &bytes[0]);
15081508 assert(u32_ptr.* == 0x12121212);
15091509
15101510 // Even this example is contrived - there are better ways to do the above than
......@@ -1518,7 +1518,7 @@ test "pointer casting" {
15181518
15191519test "pointer child type" {
15201520 // pointer types have a `child` field which tells you the type they point to.
1521 assert((&u32).Child == u32);
1521 assert((*u32).Child == u32);
15221522}
15231523 {#code_end#}
15241524 {#header_open|Alignment#}
......@@ -1543,15 +1543,15 @@ const builtin = @import("builtin");
15431543test "variable alignment" {
15441544 var x: i32 = 1234;
15451545 const align_of_i32 = @alignOf(@typeOf(x));
1546 assert(@typeOf(&x) == &i32);
1547 assert(&i32 == &align(align_of_i32) i32);
1546 assert(@typeOf(&x) == *i32);
1547 assert(*i32 == *align(align_of_i32) i32);
15481548 if (builtin.arch == builtin.Arch.x86_64) {
1549 assert((&i32).alignment == 4);
1549 assert((*i32).alignment == 4);
15501550 }
15511551}
15521552 {#code_end#}
1553 <p>In the same way that a <code>&amp;i32</code> can be implicitly cast to a
1554 <code>&amp;const i32</code>, a pointer with a larger alignment can be implicitly
1553 <p>In the same way that a <code>*i32</code> can be implicitly cast to a
1554 <code>*const i32</code>, a pointer with a larger alignment can be implicitly
15551555 cast to a pointer with a smaller alignment, but not vice versa.
15561556 </p>
15571557 <p>
......@@ -1565,7 +1565,7 @@ var foo: u8 align(4) = 100;
15651565
15661566test "global variable alignment" {
15671567 assert(@typeOf(&foo).alignment == 4);
1568 assert(@typeOf(&foo) == &align(4) u8);
1568 assert(@typeOf(&foo) == *align(4) u8);
15691569 const slice = (&foo)[0..1];
15701570 assert(@typeOf(slice) == []align(4) u8);
15711571}
......@@ -1610,7 +1610,7 @@ fn foo(bytes: []u8) u32 {
16101610 <code>u8</code> can alias any memory.
16111611 </p>
16121612 <p>As an example, this code produces undefined behavior:</p>
1613 <pre><code class="zig">@ptrCast(&amp;u32, f32(12.34)).*</code></pre>
1613 <pre><code class="zig">@ptrCast(*u32, f32(12.34)).*</code></pre>
16141614 <p>Instead, use {#link|@bitCast#}:
16151615 <pre><code class="zig">@bitCast(u32, f32(12.34))</code></pre>
16161616 <p>As an added benefit, the <code>@bitcast</code> version works at compile-time.</p>
......@@ -1736,7 +1736,7 @@ const Vec3 = struct {
17361736 };
17371737 }
17381738
1739 pub fn dot(self: &const Vec3, other: &const Vec3) f32 {
1739 pub fn dot(self: *const Vec3, other: *const Vec3) f32 {
17401740 return self.x * other.x + self.y * other.y + self.z * other.z;
17411741 }
17421742};
......@@ -1768,7 +1768,7 @@ test "struct namespaced variable" {
17681768
17691769// struct field order is determined by the compiler for optimal performance.
17701770// however, you can still calculate a struct base pointer given a field pointer:
1771fn setYBasedOnX(x: &f32, y: f32) void {
1771fn setYBasedOnX(x: *f32, y: f32) void {
17721772 const point = @fieldParentPtr(Point, "x", x);
17731773 point.y = y;
17741774}
......@@ -1786,13 +1786,13 @@ test "field parent pointer" {
17861786fn LinkedList(comptime T: type) type {
17871787 return struct {
17881788 pub const Node = struct {
1789 prev: ?&Node,
1790 next: ?&Node,
1789 prev: ?*Node,
1790 next: ?*Node,
17911791 data: T,
17921792 };
17931793
1794 first: ?&Node,
1795 last: ?&Node,
1794 first: ?*Node,
1795 last: ?*Node,
17961796 len: usize,
17971797 };
17981798}
......@@ -2039,7 +2039,7 @@ const Variant = union(enum) {
20392039 Int: i32,
20402040 Bool: bool,
20412041
2042 fn truthy(self: &const Variant) bool {
2042 fn truthy(self: *const Variant) bool {
20432043 return switch (self.*) {
20442044 Variant.Int => |x_int| x_int != 0,
20452045 Variant.Bool => |x_bool| x_bool,
......@@ -2786,7 +2786,7 @@ test "pass aggregate type by value to function" {
27862786}
27872787 {#code_end#}
27882788 <p>
2789 Instead, one must use <code>&amp;const</code>. Zig allows implicitly casting something
2789 Instead, one must use <code>*const</code>. Zig allows implicitly casting something
27902790 to a const pointer to it:
27912791 </p>
27922792 {#code_begin|test#}
......@@ -2794,7 +2794,7 @@ const Foo = struct {
27942794 x: i32,
27952795};
27962796
2797fn bar(foo: &const Foo) void {}
2797fn bar(foo: *const Foo) void {}
27982798
27992799test "implicitly cast to const pointer" {
28002800 bar(Foo {.x = 12,});
......@@ -3208,16 +3208,16 @@ struct Foo *do_a_thing(void) {
32083208 <p>Zig code</p>
32093209 {#code_begin|syntax#}
32103210// malloc prototype included for reference
3211extern fn malloc(size: size_t) ?&u8;
3211extern fn malloc(size: size_t) ?*u8;
32123212
3213fn doAThing() ?&Foo {
3213fn doAThing() ?*Foo {
32143214 const ptr = malloc(1234) ?? return null;
32153215 // ...
32163216}
32173217 {#code_end#}
32183218 <p>
32193219 Here, Zig is at least as convenient, if not more, than C. And, the type of "ptr"
3220 is <code>&u8</code> <em>not</em> <code>?&u8</code>. The <code>??</code> operator
3220 is <code>*u8</code> <em>not</em> <code>?*u8</code>. The <code>??</code> operator
32213221 unwrapped the nullable type and therefore <code>ptr</code> is guaranteed to be non-null everywhere
32223222 it is used in the function.
32233223 </p>
......@@ -3237,7 +3237,7 @@ fn doAThing() ?&Foo {
32373237 In Zig you can accomplish the same thing:
32383238 </p>
32393239 {#code_begin|syntax#}
3240fn doAThing(nullable_foo: ?&Foo) void {
3240fn doAThing(nullable_foo: ?*Foo) void {
32413241 // do some stuff
32423242
32433243 if (nullable_foo) |foo| {
......@@ -3713,7 +3713,7 @@ fn List(comptime T: type) type {
37133713 </p>
37143714 {#code_begin|syntax#}
37153715const Node = struct {
3716 next: &Node,
3716 next: *Node,
37173717 name: []u8,
37183718};
37193719 {#code_end#}
......@@ -3745,7 +3745,7 @@ pub fn main() void {
37453745
37463746 {#code_begin|syntax#}
37473747/// Calls print and then flushes the buffer.
3748pub fn printf(self: &OutStream, comptime format: []const u8, args: ...) error!void {
3748pub fn printf(self: *OutStream, comptime format: []const u8, args: ...) error!void {
37493749 const State = enum {
37503750 Start,
37513751 OpenBrace,
......@@ -3817,7 +3817,7 @@ pub fn printf(self: &OutStream, comptime format: []const u8, args: ...) error!vo
38173817 and emits a function that actually looks like this:
38183818 </p>
38193819 {#code_begin|syntax#}
3820pub fn printf(self: &OutStream, arg0: i32, arg1: []const u8) !void {
3820pub fn printf(self: *OutStream, arg0: i32, arg1: []const u8) !void {
38213821 try self.write("here is a string: '");
38223822 try self.printValue(arg0);
38233823 try self.write("' here is a number: ");
......@@ -3831,7 +3831,7 @@ pub fn printf(self: &OutStream, arg0: i32, arg1: []const u8) !void {
38313831 on the type:
38323832 </p>
38333833 {#code_begin|syntax#}
3834pub fn printValue(self: &OutStream, value: var) !void {
3834pub fn printValue(self: *OutStream, value: var) !void {
38353835 const T = @typeOf(value);
38363836 if (@isInteger(T)) {
38373837 return self.printInt(T, value);
......@@ -3911,7 +3911,7 @@ pub fn main() void {
39113911 at compile time.
39123912 </p>
39133913 {#header_open|@addWithOverflow#}
3914 <pre><code class="zig">@addWithOverflow(comptime T: type, a: T, b: T, result: &T) -&gt; bool</code></pre>
3914 <pre><code class="zig">@addWithOverflow(comptime T: type, a: T, b: T, result: *T) bool</code></pre>
39153915 <p>
39163916 Performs <code>result.* = a + b</code>. If overflow or underflow occurs,
39173917 stores the overflowed bits in <code>result</code> and returns <code>true</code>.
......@@ -3919,7 +3919,7 @@ pub fn main() void {
39193919 </p>
39203920 {#header_close#}
39213921 {#header_open|@ArgType#}
3922 <pre><code class="zig">@ArgType(comptime T: type, comptime n: usize) -&gt; type</code></pre>
3922 <pre><code class="zig">@ArgType(comptime T: type, comptime n: usize) type</code></pre>
39233923 <p>
39243924 This builtin function takes a function type and returns the type of the parameter at index <code>n</code>.
39253925 </p>
......@@ -3931,7 +3931,7 @@ pub fn main() void {
39313931 </p>
39323932 {#header_close#}
39333933 {#header_open|@atomicLoad#}
3934 <pre><code class="zig">@atomicLoad(comptime T: type, ptr: &amp;const T, comptime ordering: builtin.AtomicOrder) -&gt; T</code></pre>
3934 <pre><code class="zig">@atomicLoad(comptime T: type, ptr: *const T, comptime ordering: builtin.AtomicOrder) T</code></pre>
39353935 <p>
39363936 This builtin function atomically dereferences a pointer and returns the value.
39373937 </p>
......@@ -3950,7 +3950,7 @@ pub fn main() void {
39503950 </p>
39513951 {#header_close#}
39523952 {#header_open|@atomicRmw#}
3953 <pre><code class="zig">@atomicRmw(comptime T: type, ptr: &amp;T, comptime op: builtin.AtomicRmwOp, operand: T, comptime ordering: builtin.AtomicOrder) -&gt; T</code></pre>
3953 <pre><code class="zig">@atomicRmw(comptime T: type, ptr: *T, comptime op: builtin.AtomicRmwOp, operand: T, comptime ordering: builtin.AtomicOrder) T</code></pre>
39543954 <p>
39553955 This builtin function atomically modifies memory and then returns the previous value.
39563956 </p>
......@@ -3969,7 +3969,7 @@ pub fn main() void {
39693969 </p>
39703970 {#header_close#}
39713971 {#header_open|@bitCast#}
3972 <pre><code class="zig">@bitCast(comptime DestType: type, value: var) -&gt; DestType</code></pre>
3972 <pre><code class="zig">@bitCast(comptime DestType: type, value: var) DestType</code></pre>
39733973 <p>
39743974 Converts a value of one type to another type.
39753975 </p>
......@@ -4002,9 +4002,9 @@ pub fn main() void {
40024002
40034003 {#header_close#}
40044004 {#header_open|@alignCast#}
4005 <pre><code class="zig">@alignCast(comptime alignment: u29, ptr: var) -&gt; var</code></pre>
4005 <pre><code class="zig">@alignCast(comptime alignment: u29, ptr: var) var</code></pre>
40064006 <p>
4007 <code>ptr</code> can be <code>&amp;T</code>, <code>fn()</code>, <code>?&amp;T</code>,
4007 <code>ptr</code> can be <code>*T</code>, <code>fn()</code>, <code>?*T</code>,
40084008 <code>?fn()</code>, or <code>[]T</code>. It returns the same type as <code>ptr</code>
40094009 except with the alignment adjusted to the new value.
40104010 </p>
......@@ -4013,7 +4013,7 @@ pub fn main() void {
40134013
40144014 {#header_close#}
40154015 {#header_open|@alignOf#}
4016 <pre><code class="zig">@alignOf(comptime T: type) -&gt; (number literal)</code></pre>
4016 <pre><code class="zig">@alignOf(comptime T: type) (number literal)</code></pre>
40174017 <p>
40184018 This function returns the number of bytes that this type should be aligned to
40194019 for the current target to match the C ABI. When the child type of a pointer has
......@@ -4021,7 +4021,7 @@ pub fn main() void {
40214021 </p>
40224022 <pre><code class="zig">const assert = @import("std").debug.assert;
40234023comptime {
4024 assert(&u32 == &align(@alignOf(u32)) u32);
4024 assert(*u32 == *align(@alignOf(u32)) u32);
40254025}</code></pre>
40264026 <p>
40274027 The result is a target-specific compile time constant. It is guaranteed to be
......@@ -4049,7 +4049,7 @@ comptime {
40494049 {#see_also|Import from C Header File|@cInclude|@cImport|@cUndef|void#}
40504050 {#header_close#}
40514051 {#header_open|@cImport#}
4052 <pre><code class="zig">@cImport(expression) -&gt; (namespace)</code></pre>
4052 <pre><code class="zig">@cImport(expression) (namespace)</code></pre>
40534053 <p>
40544054 This function parses C code and imports the functions, types, variables, and
40554055 compatible macro definitions into the result namespace.
......@@ -4095,13 +4095,13 @@ comptime {
40954095 {#see_also|Import from C Header File|@cImport|@cDefine|@cInclude#}
40964096 {#header_close#}
40974097 {#header_open|@canImplicitCast#}
4098 <pre><code class="zig">@canImplicitCast(comptime T: type, value) -&gt; bool</code></pre>
4098 <pre><code class="zig">@canImplicitCast(comptime T: type, value) bool</code></pre>
40994099 <p>
41004100 Returns whether a value can be implicitly casted to a given type.
41014101 </p>
41024102 {#header_close#}
41034103 {#header_open|@clz#}
4104 <pre><code class="zig">@clz(x: T) -&gt; U</code></pre>
4104 <pre><code class="zig">@clz(x: T) U</code></pre>
41054105 <p>
41064106 This function counts the number of leading zeroes in <code>x</code> which is an integer
41074107 type <code>T</code>.
......@@ -4116,13 +4116,13 @@ comptime {
41164116
41174117 {#header_close#}
41184118 {#header_open|@cmpxchgStrong#}
4119 <pre><code class="zig">@cmpxchgStrong(comptime T: type, ptr: &T, expected_value: T, new_value: T, success_order: AtomicOrder, fail_order: AtomicOrder) -&gt; ?T</code></pre>
4119 <pre><code class="zig">@cmpxchgStrong(comptime T: type, ptr: *T, expected_value: T, new_value: T, success_order: AtomicOrder, fail_order: AtomicOrder) ?T</code></pre>
41204120 <p>
41214121 This function performs a strong atomic compare exchange operation. It's the equivalent of this code,
41224122 except atomic:
41234123 </p>
41244124 {#code_begin|syntax#}
4125fn cmpxchgStrongButNotAtomic(comptime T: type, ptr: &T, expected_value: T, new_value: T) ?T {
4125fn cmpxchgStrongButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_value: T) ?T {
41264126 const old_value = ptr.*;
41274127 if (old_value == expected_value) {
41284128 ptr.* = new_value;
......@@ -4143,13 +4143,13 @@ fn cmpxchgStrongButNotAtomic(comptime T: type, ptr: &T, expected_value: T, new_v
41434143 {#see_also|Compile Variables|cmpxchgWeak#}
41444144 {#header_close#}
41454145 {#header_open|@cmpxchgWeak#}
4146 <pre><code class="zig">@cmpxchgWeak(comptime T: type, ptr: &T, expected_value: T, new_value: T, success_order: AtomicOrder, fail_order: AtomicOrder) -&gt; ?T</code></pre>
4146 <pre><code class="zig">@cmpxchgWeak(comptime T: type, ptr: *T, expected_value: T, new_value: T, success_order: AtomicOrder, fail_order: AtomicOrder) ?T</code></pre>
41474147 <p>
41484148 This function performs a weak atomic compare exchange operation. It's the equivalent of this code,
41494149 except atomic:
41504150 </p>
41514151 {#code_begin|syntax#}
4152fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: &T, expected_value: T, new_value: T) ?T {
4152fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_value: T) ?T {
41534153 const old_value = ptr.*;
41544154 if (old_value == expected_value and usuallyTrueButSometimesFalse()) {
41554155 ptr.* = new_value;
......@@ -4237,7 +4237,7 @@ test "main" {
42374237 {#code_end#}
42384238 {#header_close#}
42394239 {#header_open|@ctz#}
4240 <pre><code class="zig">@ctz(x: T) -&gt; U</code></pre>
4240 <pre><code class="zig">@ctz(x: T) U</code></pre>
42414241 <p>
42424242 This function counts the number of trailing zeroes in <code>x</code> which is an integer
42434243 type <code>T</code>.
......@@ -4251,7 +4251,7 @@ test "main" {
42514251 </p>
42524252 {#header_close#}
42534253 {#header_open|@divExact#}
4254 <pre><code class="zig">@divExact(numerator: T, denominator: T) -&gt; T</code></pre>
4254 <pre><code class="zig">@divExact(numerator: T, denominator: T) T</code></pre>
42554255 <p>
42564256 Exact division. Caller guarantees <code>denominator != 0</code> and
42574257 <code>@divTrunc(numerator, denominator) * denominator == numerator</code>.
......@@ -4264,7 +4264,7 @@ test "main" {
42644264 {#see_also|@divTrunc|@divFloor#}
42654265 {#header_close#}
42664266 {#header_open|@divFloor#}
4267 <pre><code class="zig">@divFloor(numerator: T, denominator: T) -&gt; T</code></pre>
4267 <pre><code class="zig">@divFloor(numerator: T, denominator: T) T</code></pre>
42684268 <p>
42694269 Floored division. Rounds toward negative infinity. For unsigned integers it is
42704270 the same as <code>numerator / denominator</code>. Caller guarantees <code>denominator != 0</code> and
......@@ -4278,7 +4278,7 @@ test "main" {
42784278 {#see_also|@divTrunc|@divExact#}
42794279 {#header_close#}
42804280 {#header_open|@divTrunc#}
4281 <pre><code class="zig">@divTrunc(numerator: T, denominator: T) -&gt; T</code></pre>
4281 <pre><code class="zig">@divTrunc(numerator: T, denominator: T) T</code></pre>
42824282 <p>
42834283 Truncated division. Rounds toward zero. For unsigned integers it is
42844284 the same as <code>numerator / denominator</code>. Caller guarantees <code>denominator != 0</code> and
......@@ -4292,7 +4292,7 @@ test "main" {
42924292 {#see_also|@divFloor|@divExact#}
42934293 {#header_close#}
42944294 {#header_open|@embedFile#}
4295 <pre><code class="zig">@embedFile(comptime path: []const u8) -&gt; [X]u8</code></pre>
4295 <pre><code class="zig">@embedFile(comptime path: []const u8) [X]u8</code></pre>
42964296 <p>
42974297 This function returns a compile time constant fixed-size array with length
42984298 equal to the byte count of the file given by <code>path</code>. The contents of the array
......@@ -4304,19 +4304,19 @@ test "main" {
43044304 {#see_also|@import#}
43054305 {#header_close#}
43064306 {#header_open|@export#}
4307 <pre><code class="zig">@export(comptime name: []const u8, target: var, linkage: builtin.GlobalLinkage) -&gt; []const u8</code></pre>
4307 <pre><code class="zig">@export(comptime name: []const u8, target: var, linkage: builtin.GlobalLinkage) []const u8</code></pre>
43084308 <p>
43094309 Creates a symbol in the output object file.
43104310 </p>
43114311 {#header_close#}
43124312 {#header_open|@tagName#}
4313 <pre><code class="zig">@tagName(value: var) -&gt; []const u8</code></pre>
4313 <pre><code class="zig">@tagName(value: var) []const u8</code></pre>
43144314 <p>
43154315 Converts an enum value or union value to a slice of bytes representing the name.
43164316 </p>
43174317 {#header_close#}
43184318 {#header_open|@TagType#}
4319 <pre><code class="zig">@TagType(T: type) -&gt; type</code></pre>
4319 <pre><code class="zig">@TagType(T: type) type</code></pre>
43204320 <p>
43214321 For an enum, returns the integer type that is used to store the enumeration value.
43224322 </p>
......@@ -4325,7 +4325,7 @@ test "main" {
43254325 </p>
43264326 {#header_close#}
43274327 {#header_open|@errorName#}
4328 <pre><code class="zig">@errorName(err: error) -&gt; []u8</code></pre>
4328 <pre><code class="zig">@errorName(err: error) []u8</code></pre>
43294329 <p>
43304330 This function returns the string representation of an error. If an error
43314331 declaration is:
......@@ -4341,7 +4341,7 @@ test "main" {
43414341 </p>
43424342 {#header_close#}
43434343 {#header_open|@errorReturnTrace#}
4344 <pre><code class="zig">@errorReturnTrace() -&gt; ?&builtin.StackTrace</code></pre>
4344 <pre><code class="zig">@errorReturnTrace() ?*builtin.StackTrace</code></pre>
43454345 <p>
43464346 If the binary is built with error return tracing, and this function is invoked in a
43474347 function that calls a function with an error or error union return type, returns a
......@@ -4360,7 +4360,7 @@ test "main" {
43604360 {#header_close#}
43614361 {#header_open|@fieldParentPtr#}
43624362 <pre><code class="zig">@fieldParentPtr(comptime ParentType: type, comptime field_name: []const u8,
4363 field_ptr: &T) -&gt; &ParentType</code></pre>
4363 field_ptr: *T) *ParentType</code></pre>
43644364 <p>
43654365 Given a pointer to a field, returns the base pointer of a struct.
43664366 </p>
......@@ -4380,7 +4380,7 @@ test "main" {
43804380 </p>
43814381 {#header_close#}
43824382 {#header_open|@import#}
4383 <pre><code class="zig">@import(comptime path: []u8) -&gt; (namespace)</code></pre>
4383 <pre><code class="zig">@import(comptime path: []u8) (namespace)</code></pre>
43844384 <p>
43854385 This function finds a zig file corresponding to <code>path</code> and imports all the
43864386 public top level declarations into the resulting namespace.
......@@ -4400,7 +4400,7 @@ test "main" {
44004400 {#see_also|Compile Variables|@embedFile#}
44014401 {#header_close#}
44024402 {#header_open|@inlineCall#}
4403 <pre><code class="zig">@inlineCall(function: X, args: ...) -&gt; Y</code></pre>
4403 <pre><code class="zig">@inlineCall(function: X, args: ...) Y</code></pre>
44044404 <p>
44054405 This calls a function, in the same way that invoking an expression with parentheses does:
44064406 </p>
......@@ -4420,19 +4420,19 @@ fn add(a: i32, b: i32) i32 { return a + b; }
44204420 {#see_also|@noInlineCall#}
44214421 {#header_close#}
44224422 {#header_open|@intToPtr#}
4423 <pre><code class="zig">@intToPtr(comptime DestType: type, int: usize) -&gt; DestType</code></pre>
4423 <pre><code class="zig">@intToPtr(comptime DestType: type, int: usize) DestType</code></pre>
44244424 <p>
44254425 Converts an integer to a pointer. To convert the other way, use {#link|@ptrToInt#}.
44264426 </p>
44274427 {#header_close#}
44284428 {#header_open|@IntType#}
4429 <pre><code class="zig">@IntType(comptime is_signed: bool, comptime bit_count: u8) -&gt; type</code></pre>
4429 <pre><code class="zig">@IntType(comptime is_signed: bool, comptime bit_count: u8) type</code></pre>
44304430 <p>
44314431 This function returns an integer type with the given signness and bit count.
44324432 </p>
44334433 {#header_close#}
44344434 {#header_open|@maxValue#}
4435 <pre><code class="zig">@maxValue(comptime T: type) -&gt; (number literal)</code></pre>
4435 <pre><code class="zig">@maxValue(comptime T: type) (number literal)</code></pre>
44364436 <p>
44374437 This function returns the maximum value of the integer type <code>T</code>.
44384438 </p>
......@@ -4441,7 +4441,7 @@ fn add(a: i32, b: i32) i32 { return a + b; }
44414441 </p>
44424442 {#header_close#}
44434443 {#header_open|@memberCount#}
4444 <pre><code class="zig">@memberCount(comptime T: type) -&gt; (number literal)</code></pre>
4444 <pre><code class="zig">@memberCount(comptime T: type) (number literal)</code></pre>
44454445 <p>
44464446 This function returns the number of members in a struct, enum, or union type.
44474447 </p>
......@@ -4453,7 +4453,7 @@ fn add(a: i32, b: i32) i32 { return a + b; }
44534453 </p>
44544454 {#header_close#}
44554455 {#header_open|@memberName#}
4456 <pre><code class="zig">@memberName(comptime T: type, comptime index: usize) -&gt; [N]u8</code></pre>
4456 <pre><code class="zig">@memberName(comptime T: type, comptime index: usize) [N]u8</code></pre>
44574457 <p>Returns the field name of a struct, union, or enum.</p>
44584458 <p>
44594459 The result is a compile time constant.
......@@ -4463,15 +4463,15 @@ fn add(a: i32, b: i32) i32 { return a + b; }
44634463 </p>
44644464 {#header_close#}
44654465 {#header_open|@field#}
4466 <pre><code class="zig">@field(lhs: var, comptime field_name: []const u8) -&gt; (field)</code></pre>
4466 <pre><code class="zig">@field(lhs: var, comptime field_name: []const u8) (field)</code></pre>
44674467 <p>Preforms field access equivalent to <code>lhs.-&gtfield_name-&lt</code>.</p>
44684468 {#header_close#}
44694469 {#header_open|@memberType#}
4470 <pre><code class="zig">@memberType(comptime T: type, comptime index: usize) -&gt; type</code></pre>
4470 <pre><code class="zig">@memberType(comptime T: type, comptime index: usize) type</code></pre>
44714471 <p>Returns the field type of a struct or union.</p>
44724472 {#header_close#}
44734473 {#header_open|@memcpy#}
4474 <pre><code class="zig">@memcpy(noalias dest: &u8, noalias source: &const u8, byte_count: usize)</code></pre>
4474 <pre><code class="zig">@memcpy(noalias dest: *u8, noalias source: *const u8, byte_count: usize)</code></pre>
44754475 <p>
44764476 This function copies bytes from one region of memory to another. <code>dest</code> and
44774477 <code>source</code> are both pointers and must not overlap.
......@@ -4489,7 +4489,7 @@ fn add(a: i32, b: i32) i32 { return a + b; }
44894489mem.copy(u8, dest[0...byte_count], source[0...byte_count]);</code></pre>
44904490 {#header_close#}
44914491 {#header_open|@memset#}
4492 <pre><code class="zig">@memset(dest: &u8, c: u8, byte_count: usize)</code></pre>
4492 <pre><code class="zig">@memset(dest: *u8, c: u8, byte_count: usize)</code></pre>
44934493 <p>
44944494 This function sets a region of memory to <code>c</code>. <code>dest</code> is a pointer.
44954495 </p>
......@@ -4506,7 +4506,7 @@ mem.copy(u8, dest[0...byte_count], source[0...byte_count]);</code></pre>
45064506mem.set(u8, dest, c);</code></pre>
45074507 {#header_close#}
45084508 {#header_open|@minValue#}
4509 <pre><code class="zig">@minValue(comptime T: type) -&gt; (number literal)</code></pre>
4509 <pre><code class="zig">@minValue(comptime T: type) (number literal)</code></pre>
45104510 <p>
45114511 This function returns the minimum value of the integer type T.
45124512 </p>
......@@ -4515,7 +4515,7 @@ mem.set(u8, dest, c);</code></pre>
45154515 </p>
45164516 {#header_close#}
45174517 {#header_open|@mod#}
4518 <pre><code class="zig">@mod(numerator: T, denominator: T) -&gt; T</code></pre>
4518 <pre><code class="zig">@mod(numerator: T, denominator: T) T</code></pre>
45194519 <p>
45204520 Modulus division. For unsigned integers this is the same as
45214521 <code>numerator % denominator</code>. Caller guarantees <code>denominator &gt; 0</code>.
......@@ -4528,7 +4528,7 @@ mem.set(u8, dest, c);</code></pre>
45284528 {#see_also|@rem#}
45294529 {#header_close#}
45304530 {#header_open|@mulWithOverflow#}
4531 <pre><code class="zig">@mulWithOverflow(comptime T: type, a: T, b: T, result: &T) -&gt; bool</code></pre>
4531 <pre><code class="zig">@mulWithOverflow(comptime T: type, a: T, b: T, result: *T) bool</code></pre>
45324532 <p>
45334533 Performs <code>result.* = a * b</code>. If overflow or underflow occurs,
45344534 stores the overflowed bits in <code>result</code> and returns <code>true</code>.
......@@ -4536,7 +4536,7 @@ mem.set(u8, dest, c);</code></pre>
45364536 </p>
45374537 {#header_close#}
45384538 {#header_open|@newStackCall#}
4539 <pre><code class="zig">@newStackCall(new_stack: []u8, function: var, args: ...) -&gt; var</code></pre>
4539 <pre><code class="zig">@newStackCall(new_stack: []u8, function: var, args: ...) var</code></pre>
45404540 <p>
45414541 This calls a function, in the same way that invoking an expression with parentheses does. However,
45424542 instead of using the same stack as the caller, the function uses the stack provided in the <code>new_stack</code>
......@@ -4572,7 +4572,7 @@ fn targetFunction(x: i32) usize {
45724572 {#code_end#}
45734573 {#header_close#}
45744574 {#header_open|@noInlineCall#}
4575 <pre><code class="zig">@noInlineCall(function: var, args: ...) -&gt; var</code></pre>
4575 <pre><code class="zig">@noInlineCall(function: var, args: ...) var</code></pre>
45764576 <p>
45774577 This calls a function, in the same way that invoking an expression with parentheses does:
45784578 </p>
......@@ -4594,13 +4594,13 @@ fn add(a: i32, b: i32) i32 {
45944594 {#see_also|@inlineCall#}
45954595 {#header_close#}
45964596 {#header_open|@offsetOf#}
4597 <pre><code class="zig">@offsetOf(comptime T: type, comptime field_name: [] const u8) -&gt; (number literal)</code></pre>
4597 <pre><code class="zig">@offsetOf(comptime T: type, comptime field_name: [] const u8) (number literal)</code></pre>
45984598 <p>
45994599 This function returns the byte offset of a field relative to its containing struct.
46004600 </p>
46014601 {#header_close#}
46024602 {#header_open|@OpaqueType#}
4603 <pre><code class="zig">@OpaqueType() -&gt; type</code></pre>
4603 <pre><code class="zig">@OpaqueType() type</code></pre>
46044604 <p>
46054605 Creates a new type with an unknown size and alignment.
46064606 </p>
......@@ -4608,12 +4608,12 @@ fn add(a: i32, b: i32) i32 {
46084608 This is typically used for type safety when interacting with C code that does not expose struct details.
46094609 Example:
46104610 </p>
4611 {#code_begin|test_err|expected type '&Derp', found '&Wat'#}
4611 {#code_begin|test_err|expected type '*Derp', found '*Wat'#}
46124612const Derp = @OpaqueType();
46134613const Wat = @OpaqueType();
46144614
4615extern fn bar(d: &Derp) void;
4616export fn foo(w: &Wat) void {
4615extern fn bar(d: *Derp) void;
4616export fn foo(w: *Wat) void {
46174617 bar(w);
46184618}
46194619
......@@ -4623,7 +4623,7 @@ test "call foo" {
46234623 {#code_end#}
46244624 {#header_close#}
46254625 {#header_open|@panic#}
4626 <pre><code class="zig">@panic(message: []const u8) -&gt; noreturn</code></pre>
4626 <pre><code class="zig">@panic(message: []const u8) noreturn</code></pre>
46274627 <p>
46284628 Invokes the panic handler function. By default the panic handler function
46294629 calls the public <code>panic</code> function exposed in the root source file, or
......@@ -4639,19 +4639,19 @@ test "call foo" {
46394639 {#see_also|Root Source File#}
46404640 {#header_close#}
46414641 {#header_open|@ptrCast#}
4642 <pre><code class="zig">@ptrCast(comptime DestType: type, value: var) -&gt; DestType</code></pre>
4642 <pre><code class="zig">@ptrCast(comptime DestType: type, value: var) DestType</code></pre>
46434643 <p>
46444644 Converts a pointer of one type to a pointer of another type.
46454645 </p>
46464646 {#header_close#}
46474647 {#header_open|@ptrToInt#}
4648 <pre><code class="zig">@ptrToInt(value: var) -&gt; usize</code></pre>
4648 <pre><code class="zig">@ptrToInt(value: var) usize</code></pre>
46494649 <p>
46504650 Converts <code>value</code> to a <code>usize</code> which is the address of the pointer. <code>value</code> can be one of these types:
46514651 </p>
46524652 <ul>
4653 <li><code>&amp;T</code></li>
4654 <li><code>?&amp;T</code></li>
4653 <li><code>*T</code></li>
4654 <li><code>?*T</code></li>
46554655 <li><code>fn()</code></li>
46564656 <li><code>?fn()</code></li>
46574657 </ul>
......@@ -4659,7 +4659,7 @@ test "call foo" {
46594659
46604660 {#header_close#}
46614661 {#header_open|@rem#}
4662 <pre><code class="zig">@rem(numerator: T, denominator: T) -&gt; T</code></pre>
4662 <pre><code class="zig">@rem(numerator: T, denominator: T) T</code></pre>
46634663 <p>
46644664 Remainder division. For unsigned integers this is the same as
46654665 <code>numerator % denominator</code>. Caller guarantees <code>denominator &gt; 0</code>.
......@@ -4776,13 +4776,13 @@ pub const FloatMode = enum {
47764776 {#see_also|Compile Variables#}
47774777 {#header_close#}
47784778 {#header_open|@setGlobalSection#}
4779 <pre><code class="zig">@setGlobalSection(global_variable_name, comptime section_name: []const u8) -&gt; bool</code></pre>
4779 <pre><code class="zig">@setGlobalSection(global_variable_name, comptime section_name: []const u8) bool</code></pre>
47804780 <p>
47814781 Puts the global variable in the specified section.
47824782 </p>
47834783 {#header_close#}
47844784 {#header_open|@shlExact#}
4785 <pre><code class="zig">@shlExact(value: T, shift_amt: Log2T) -&gt; T</code></pre>
4785 <pre><code class="zig">@shlExact(value: T, shift_amt: Log2T) T</code></pre>
47864786 <p>
47874787 Performs the left shift operation (<code>&lt;&lt;</code>). Caller guarantees
47884788 that the shift will not shift any 1 bits out.
......@@ -4794,7 +4794,7 @@ pub const FloatMode = enum {
47944794 {#see_also|@shrExact|@shlWithOverflow#}
47954795 {#header_close#}
47964796 {#header_open|@shlWithOverflow#}
4797 <pre><code class="zig">@shlWithOverflow(comptime T: type, a: T, shift_amt: Log2T, result: &T) -&gt; bool</code></pre>
4797 <pre><code class="zig">@shlWithOverflow(comptime T: type, a: T, shift_amt: Log2T, result: *T) bool</code></pre>
47984798 <p>
47994799 Performs <code>result.* = a &lt;&lt; b</code>. If overflow or underflow occurs,
48004800 stores the overflowed bits in <code>result</code> and returns <code>true</code>.
......@@ -4807,7 +4807,7 @@ pub const FloatMode = enum {
48074807 {#see_also|@shlExact|@shrExact#}
48084808 {#header_close#}
48094809 {#header_open|@shrExact#}
4810 <pre><code class="zig">@shrExact(value: T, shift_amt: Log2T) -&gt; T</code></pre>
4810 <pre><code class="zig">@shrExact(value: T, shift_amt: Log2T) T</code></pre>
48114811 <p>
48124812 Performs the right shift operation (<code>&gt;&gt;</code>). Caller guarantees
48134813 that the shift will not shift any 1 bits out.
......@@ -4819,7 +4819,7 @@ pub const FloatMode = enum {
48194819 {#see_also|@shlExact|@shlWithOverflow#}
48204820 {#header_close#}
48214821 {#header_open|@sizeOf#}
4822 <pre><code class="zig">@sizeOf(comptime T: type) -&gt; (number literal)</code></pre>
4822 <pre><code class="zig">@sizeOf(comptime T: type) (number literal)</code></pre>
48234823 <p>
48244824 This function returns the number of bytes it takes to store <code>T</code> in memory.
48254825 </p>
......@@ -4828,7 +4828,7 @@ pub const FloatMode = enum {
48284828 </p>
48294829 {#header_close#}
48304830 {#header_open|@sqrt#}
4831 <pre><code class="zig">@sqrt(comptime T: type, value: T) -&gt; T</code></pre>
4831 <pre><code class="zig">@sqrt(comptime T: type, value: T) T</code></pre>
48324832 <p>
48334833 Performs the square root of a floating point number. Uses a dedicated hardware instruction
48344834 when available. Currently only supports f32 and f64 at runtime. f128 at runtime is TODO.
......@@ -4838,7 +4838,7 @@ pub const FloatMode = enum {
48384838 </p>
48394839 {#header_close#}
48404840 {#header_open|@subWithOverflow#}
4841 <pre><code class="zig">@subWithOverflow(comptime T: type, a: T, b: T, result: &T) -&gt; bool</code></pre>
4841 <pre><code class="zig">@subWithOverflow(comptime T: type, a: T, b: T, result: *T) bool</code></pre>
48424842 <p>
48434843 Performs <code>result.* = a - b</code>. If overflow or underflow occurs,
48444844 stores the overflowed bits in <code>result</code> and returns <code>true</code>.
......@@ -4846,7 +4846,7 @@ pub const FloatMode = enum {
48464846 </p>
48474847 {#header_close#}
48484848 {#header_open|@truncate#}
4849 <pre><code class="zig">@truncate(comptime T: type, integer) -&gt; T</code></pre>
4849 <pre><code class="zig">@truncate(comptime T: type, integer) T</code></pre>
48504850 <p>
48514851 This function truncates bits from an integer type, resulting in a smaller
48524852 integer type.
......@@ -4870,7 +4870,7 @@ const b: u8 = @truncate(u8, a);
48704870
48714871 {#header_close#}
48724872 {#header_open|@typeId#}
4873 <pre><code class="zig">@typeId(comptime T: type) -&gt; @import("builtin").TypeId</code></pre>
4873 <pre><code class="zig">@typeId(comptime T: type) @import("builtin").TypeId</code></pre>
48744874 <p>
48754875 Returns which kind of type something is. Possible values:
48764876 </p>
......@@ -4904,7 +4904,7 @@ pub const TypeId = enum {
49044904 {#code_end#}
49054905 {#header_close#}
49064906 {#header_open|@typeInfo#}
4907 <pre><code class="zig">@typeInfo(comptime T: type) -&gt; @import("builtin").TypeInfo</code></pre>
4907 <pre><code class="zig">@typeInfo(comptime T: type) @import("builtin").TypeInfo</code></pre>
49084908 <p>
49094909 Returns information on the type. Returns a value of the following union:
49104910 </p>
......@@ -5080,14 +5080,14 @@ pub const TypeInfo = union(TypeId) {
50805080 {#code_end#}
50815081 {#header_close#}
50825082 {#header_open|@typeName#}
5083 <pre><code class="zig">@typeName(T: type) -&gt; []u8</code></pre>
5083 <pre><code class="zig">@typeName(T: type) []u8</code></pre>
50845084 <p>
50855085 This function returns the string representation of a type.
50865086 </p>
50875087
50885088 {#header_close#}
50895089 {#header_open|@typeOf#}
5090 <pre><code class="zig">@typeOf(expression) -&gt; type</code></pre>
5090 <pre><code class="zig">@typeOf(expression) type</code></pre>
50915091 <p>
50925092 This function returns a compile-time constant, which is the type of the
50935093 expression passed as an argument. The expression is evaluated.
......@@ -5937,7 +5937,7 @@ pub const __zig_test_fn_slice = {}; // overwritten later
59375937 {#header_open|C String Literals#}
59385938 {#code_begin|exe#}
59395939 {#link_libc#}
5940extern fn puts(&const u8) void;
5940extern fn puts(*const u8) void;
59415941
59425942pub fn main() void {
59435943 puts(c"this has a null terminator");
......@@ -5996,8 +5996,8 @@ const c = @cImport({
59965996 {#code_begin|syntax#}
59975997const base64 = @import("std").base64;
59985998
5999export fn decode_base_64(dest_ptr: &u8, dest_len: usize,
6000 source_ptr: &const u8, source_len: usize) usize
5999export fn decode_base_64(dest_ptr: *u8, dest_len: usize,
6000 source_ptr: *const u8, source_len: usize) usize
60016001{
60026002 const src = source_ptr[0..source_len];
60036003 const dest = dest_ptr[0..dest_len];
......@@ -6028,7 +6028,7 @@ int main(int argc, char **argv) {
60286028 {#code_begin|syntax#}
60296029const Builder = @import("std").build.Builder;
60306030
6031pub fn build(b: &Builder) void {
6031pub fn build(b: *Builder) void {
60326032 const obj = b.addObject("base64", "base64.zig");
60336033
60346034 const exe = b.addCExecutable("test");
example/cat/main.zig+1-1
......@@ -41,7 +41,7 @@ fn usage(exe: []const u8) !void {
4141 return error.Invalid;
4242}
4343
44fn cat_file(stdout: &os.File, file: &os.File) !void {
44fn cat_file(stdout: *os.File, file: *os.File) !void {
4545 var buf: [1024 * 4]u8 = undefined;
4646
4747 while (true) {
example/hello_world/hello_libc.zig+1-1
......@@ -7,7 +7,7 @@ const c = @cImport({
77
88const msg = c"Hello, world!\n";
99
10export fn main(argc: c_int, argv: &&u8) c_int {
10export fn main(argc: c_int, argv: **u8) c_int {
1111 if (c.printf(msg) != c_int(c.strlen(msg))) return -1;
1212
1313 return 0;
example/mix_o_files/base64.zig+1-1
......@@ -1,6 +1,6 @@
11const base64 = @import("std").base64;
22
3export fn decode_base_64(dest_ptr: &u8, dest_len: usize, source_ptr: &const u8, source_len: usize) usize {
3export fn decode_base_64(dest_ptr: *u8, dest_len: usize, source_ptr: *const u8, source_len: usize) usize {
44 const src = source_ptr[0..source_len];
55 const dest = dest_ptr[0..dest_len];
66 const base64_decoder = base64.standard_decoder_unsafe;
example/mix_o_files/build.zig+1-1
......@@ -1,6 +1,6 @@
11const Builder = @import("std").build.Builder;
22
3pub fn build(b: &Builder) void {
3pub fn build(b: *Builder) void {
44 const obj = b.addObject("base64", "base64.zig");
55
66 const exe = b.addCExecutable("test");
example/shared_library/build.zig+1-1
......@@ -1,6 +1,6 @@
11const Builder = @import("std").build.Builder;
22
3pub fn build(b: &Builder) void {
3pub fn build(b: *Builder) void {
44 const lib = b.addSharedLibrary("mathtest", "mathtest.zig", b.version(1, 0, 0));
55
66 const exe = b.addCExecutable("test");
src-self-hosted/arg.zig+6-6
......@@ -30,7 +30,7 @@ fn argInAllowedSet(maybe_set: ?[]const []const u8, arg: []const u8) bool {
3030}
3131
3232// Modifies the current argument index during iteration
33fn readFlagArguments(allocator: &Allocator, args: []const []const u8, required: usize, allowed_set: ?[]const []const u8, index: &usize) !FlagArg {
33fn readFlagArguments(allocator: *Allocator, args: []const []const u8, required: usize, allowed_set: ?[]const []const u8, index: *usize) !FlagArg {
3434 switch (required) {
3535 0 => return FlagArg{ .None = undefined }, // TODO: Required to force non-tag but value?
3636 1 => {
......@@ -79,7 +79,7 @@ pub const Args = struct {
7979 flags: HashMapFlags,
8080 positionals: ArrayList([]const u8),
8181
82 pub fn parse(allocator: &Allocator, comptime spec: []const Flag, args: []const []const u8) !Args {
82 pub fn parse(allocator: *Allocator, comptime spec: []const Flag, args: []const []const u8) !Args {
8383 var parsed = Args{
8484 .flags = HashMapFlags.init(allocator),
8585 .positionals = ArrayList([]const u8).init(allocator),
......@@ -143,18 +143,18 @@ pub const Args = struct {
143143 return parsed;
144144 }
145145
146 pub fn deinit(self: &Args) void {
146 pub fn deinit(self: *Args) void {
147147 self.flags.deinit();
148148 self.positionals.deinit();
149149 }
150150
151151 // e.g. --help
152 pub fn present(self: &Args, name: []const u8) bool {
152 pub fn present(self: *Args, name: []const u8) bool {
153153 return self.flags.contains(name);
154154 }
155155
156156 // e.g. --name value
157 pub fn single(self: &Args, name: []const u8) ?[]const u8 {
157 pub fn single(self: *Args, name: []const u8) ?[]const u8 {
158158 if (self.flags.get(name)) |entry| {
159159 switch (entry.value) {
160160 FlagArg.Single => |inner| {
......@@ -168,7 +168,7 @@ pub const Args = struct {
168168 }
169169
170170 // e.g. --names value1 value2 value3
171 pub fn many(self: &Args, name: []const u8) ?[]const []const u8 {
171 pub fn many(self: *Args, name: []const u8) ?[]const []const u8 {
172172 if (self.flags.get(name)) |entry| {
173173 switch (entry.value) {
174174 FlagArg.Many => |inner| {
src-self-hosted/errmsg.zig+7-7
......@@ -16,18 +16,18 @@ pub const Msg = struct {
1616 text: []u8,
1717 first_token: TokenIndex,
1818 last_token: TokenIndex,
19 tree: &ast.Tree,
19 tree: *ast.Tree,
2020};
2121
2222/// `path` must outlive the returned Msg
2323/// `tree` must outlive the returned Msg
2424/// Caller owns returned Msg and must free with `allocator`
2525pub fn createFromParseError(
26 allocator: &mem.Allocator,
27 parse_error: &const ast.Error,
28 tree: &ast.Tree,
26 allocator: *mem.Allocator,
27 parse_error: *const ast.Error,
28 tree: *ast.Tree,
2929 path: []const u8,
30) !&Msg {
30) !*Msg {
3131 const loc_token = parse_error.loc();
3232 var text_buf = try std.Buffer.initSize(allocator, 0);
3333 defer text_buf.deinit();
......@@ -47,7 +47,7 @@ pub fn createFromParseError(
4747 return msg;
4848}
4949
50pub fn printToStream(stream: var, msg: &const Msg, color_on: bool) !void {
50pub fn printToStream(stream: var, msg: *const Msg, color_on: bool) !void {
5151 const first_token = msg.tree.tokens.at(msg.first_token);
5252 const last_token = msg.tree.tokens.at(msg.last_token);
5353 const start_loc = msg.tree.tokenLocationPtr(0, first_token);
......@@ -76,7 +76,7 @@ pub fn printToStream(stream: var, msg: &const Msg, color_on: bool) !void {
7676 try stream.write("\n");
7777}
7878
79pub fn printToFile(file: &os.File, msg: &const Msg, color: Color) !void {
79pub fn printToFile(file: *os.File, msg: *const Msg, color: Color) !void {
8080 const color_on = switch (color) {
8181 Color.Auto => file.isTty(),
8282 Color.On => true,
src-self-hosted/introspect.zig+3-3
......@@ -7,7 +7,7 @@ const os = std.os;
77const warn = std.debug.warn;
88
99/// Caller must free result
10pub fn testZigInstallPrefix(allocator: &mem.Allocator, test_path: []const u8) ![]u8 {
10pub fn testZigInstallPrefix(allocator: *mem.Allocator, test_path: []const u8) ![]u8 {
1111 const test_zig_dir = try os.path.join(allocator, test_path, "lib", "zig");
1212 errdefer allocator.free(test_zig_dir);
1313
......@@ -21,7 +21,7 @@ pub fn testZigInstallPrefix(allocator: &mem.Allocator, test_path: []const u8) ![
2121}
2222
2323/// Caller must free result
24pub fn findZigLibDir(allocator: &mem.Allocator) ![]u8 {
24pub fn findZigLibDir(allocator: *mem.Allocator) ![]u8 {
2525 const self_exe_path = try os.selfExeDirPath(allocator);
2626 defer allocator.free(self_exe_path);
2727
......@@ -42,7 +42,7 @@ pub fn findZigLibDir(allocator: &mem.Allocator) ![]u8 {
4242 return error.FileNotFound;
4343}
4444
45pub fn resolveZigLibDir(allocator: &mem.Allocator) ![]u8 {
45pub fn resolveZigLibDir(allocator: *mem.Allocator) ![]u8 {
4646 return findZigLibDir(allocator) catch |err| {
4747 warn(
4848 \\Unable to find zig lib directory: {}.
src-self-hosted/ir.zig+1-1
......@@ -2,7 +2,7 @@ const Scope = @import("scope.zig").Scope;
22
33pub const Instruction = struct {
44 id: Id,
5 scope: &Scope,
5 scope: *Scope,
66
77 pub const Id = enum {
88 Br,
src-self-hosted/main.zig+18-18
......@@ -18,8 +18,8 @@ const Target = @import("target.zig").Target;
1818const errmsg = @import("errmsg.zig");
1919
2020var stderr_file: os.File = undefined;
21var stderr: &io.OutStream(io.FileOutStream.Error) = undefined;
22var stdout: &io.OutStream(io.FileOutStream.Error) = undefined;
21var stderr: *io.OutStream(io.FileOutStream.Error) = undefined;
22var stdout: *io.OutStream(io.FileOutStream.Error) = undefined;
2323
2424const usage =
2525 \\usage: zig [command] [options]
......@@ -43,7 +43,7 @@ const usage =
4343
4444const Command = struct {
4545 name: []const u8,
46 exec: fn (&Allocator, []const []const u8) error!void,
46 exec: fn (*Allocator, []const []const u8) error!void,
4747};
4848
4949pub fn main() !void {
......@@ -191,7 +191,7 @@ const missing_build_file =
191191 \\
192192;
193193
194fn cmdBuild(allocator: &Allocator, args: []const []const u8) !void {
194fn cmdBuild(allocator: *Allocator, args: []const []const u8) !void {
195195 var flags = try Args.parse(allocator, args_build_spec, args);
196196 defer flags.deinit();
197197
......@@ -426,7 +426,7 @@ const args_build_generic = []Flag{
426426 Flag.Arg1("--ver-patch"),
427427};
428428
429fn buildOutputType(allocator: &Allocator, args: []const []const u8, out_type: Module.Kind) !void {
429fn buildOutputType(allocator: *Allocator, args: []const []const u8, out_type: Module.Kind) !void {
430430 var flags = try Args.parse(allocator, args_build_generic, args);
431431 defer flags.deinit();
432432
......@@ -661,19 +661,19 @@ fn buildOutputType(allocator: &Allocator, args: []const []const u8, out_type: Mo
661661 try stderr.print("building {}: {}\n", @tagName(out_type), in_file);
662662}
663663
664fn cmdBuildExe(allocator: &Allocator, args: []const []const u8) !void {
664fn cmdBuildExe(allocator: *Allocator, args: []const []const u8) !void {
665665 try buildOutputType(allocator, args, Module.Kind.Exe);
666666}
667667
668668// cmd:build-lib ///////////////////////////////////////////////////////////////////////////////////
669669
670fn cmdBuildLib(allocator: &Allocator, args: []const []const u8) !void {
670fn cmdBuildLib(allocator: *Allocator, args: []const []const u8) !void {
671671 try buildOutputType(allocator, args, Module.Kind.Lib);
672672}
673673
674674// cmd:build-obj ///////////////////////////////////////////////////////////////////////////////////
675675
676fn cmdBuildObj(allocator: &Allocator, args: []const []const u8) !void {
676fn cmdBuildObj(allocator: *Allocator, args: []const []const u8) !void {
677677 try buildOutputType(allocator, args, Module.Kind.Obj);
678678}
679679
......@@ -700,7 +700,7 @@ const args_fmt_spec = []Flag{
700700 }),
701701};
702702
703fn cmdFmt(allocator: &Allocator, args: []const []const u8) !void {
703fn cmdFmt(allocator: *Allocator, args: []const []const u8) !void {
704704 var flags = try Args.parse(allocator, args_fmt_spec, args);
705705 defer flags.deinit();
706706
......@@ -768,7 +768,7 @@ fn cmdFmt(allocator: &Allocator, args: []const []const u8) !void {
768768
769769// cmd:targets /////////////////////////////////////////////////////////////////////////////////////
770770
771fn cmdTargets(allocator: &Allocator, args: []const []const u8) !void {
771fn cmdTargets(allocator: *Allocator, args: []const []const u8) !void {
772772 try stdout.write("Architectures:\n");
773773 {
774774 comptime var i: usize = 0;
......@@ -810,7 +810,7 @@ fn cmdTargets(allocator: &Allocator, args: []const []const u8) !void {
810810
811811// cmd:version /////////////////////////////////////////////////////////////////////////////////////
812812
813fn cmdVersion(allocator: &Allocator, args: []const []const u8) !void {
813fn cmdVersion(allocator: *Allocator, args: []const []const u8) !void {
814814 try stdout.print("{}\n", std.cstr.toSliceConst(c.ZIG_VERSION_STRING));
815815}
816816
......@@ -827,7 +827,7 @@ const usage_test =
827827
828828const args_test_spec = []Flag{Flag.Bool("--help")};
829829
830fn cmdTest(allocator: &Allocator, args: []const []const u8) !void {
830fn cmdTest(allocator: *Allocator, args: []const []const u8) !void {
831831 var flags = try Args.parse(allocator, args_build_spec, args);
832832 defer flags.deinit();
833833
......@@ -862,7 +862,7 @@ const usage_run =
862862
863863const args_run_spec = []Flag{Flag.Bool("--help")};
864864
865fn cmdRun(allocator: &Allocator, args: []const []const u8) !void {
865fn cmdRun(allocator: *Allocator, args: []const []const u8) !void {
866866 var compile_args = args;
867867 var runtime_args: []const []const u8 = []const []const u8{};
868868
......@@ -912,7 +912,7 @@ const args_translate_c_spec = []Flag{
912912 Flag.Arg1("--output"),
913913};
914914
915fn cmdTranslateC(allocator: &Allocator, args: []const []const u8) !void {
915fn cmdTranslateC(allocator: *Allocator, args: []const []const u8) !void {
916916 var flags = try Args.parse(allocator, args_translate_c_spec, args);
917917 defer flags.deinit();
918918
......@@ -958,7 +958,7 @@ fn cmdTranslateC(allocator: &Allocator, args: []const []const u8) !void {
958958
959959// cmd:help ////////////////////////////////////////////////////////////////////////////////////////
960960
961fn cmdHelp(allocator: &Allocator, args: []const []const u8) !void {
961fn cmdHelp(allocator: *Allocator, args: []const []const u8) !void {
962962 try stderr.write(usage);
963963}
964964
......@@ -981,7 +981,7 @@ const info_zen =
981981 \\
982982;
983983
984fn cmdZen(allocator: &Allocator, args: []const []const u8) !void {
984fn cmdZen(allocator: *Allocator, args: []const []const u8) !void {
985985 try stdout.write(info_zen);
986986}
987987
......@@ -996,7 +996,7 @@ const usage_internal =
996996 \\
997997;
998998
999fn cmdInternal(allocator: &Allocator, args: []const []const u8) !void {
999fn cmdInternal(allocator: *Allocator, args: []const []const u8) !void {
10001000 if (args.len == 0) {
10011001 try stderr.write(usage_internal);
10021002 os.exit(1);
......@@ -1018,7 +1018,7 @@ fn cmdInternal(allocator: &Allocator, args: []const []const u8) !void {
10181018 try stderr.write(usage_internal);
10191019}
10201020
1021fn cmdInternalBuildInfo(allocator: &Allocator, args: []const []const u8) !void {
1021fn cmdInternalBuildInfo(allocator: *Allocator, args: []const []const u8) !void {
10221022 try stdout.print(
10231023 \\ZIG_CMAKE_BINARY_DIR {}
10241024 \\ZIG_CXX_COMPILER {}
src-self-hosted/module.zig+15-15
......@@ -13,7 +13,7 @@ const ArrayList = std.ArrayList;
1313const errmsg = @import("errmsg.zig");
1414
1515pub const Module = struct {
16 allocator: &mem.Allocator,
16 allocator: *mem.Allocator,
1717 name: Buffer,
1818 root_src_path: ?[]const u8,
1919 module: llvm.ModuleRef,
......@@ -53,8 +53,8 @@ pub const Module = struct {
5353 windows_subsystem_windows: bool,
5454 windows_subsystem_console: bool,
5555
56 link_libs_list: ArrayList(&LinkLib),
57 libc_link_lib: ?&LinkLib,
56 link_libs_list: ArrayList(*LinkLib),
57 libc_link_lib: ?*LinkLib,
5858
5959 err_color: errmsg.Color,
6060
......@@ -106,19 +106,19 @@ pub const Module = struct {
106106 pub const CliPkg = struct {
107107 name: []const u8,
108108 path: []const u8,
109 children: ArrayList(&CliPkg),
110 parent: ?&CliPkg,
109 children: ArrayList(*CliPkg),
110 parent: ?*CliPkg,
111111
112 pub fn init(allocator: &mem.Allocator, name: []const u8, path: []const u8, parent: ?&CliPkg) !&CliPkg {
112 pub fn init(allocator: *mem.Allocator, name: []const u8, path: []const u8, parent: ?*CliPkg) !*CliPkg {
113113 var pkg = try allocator.create(CliPkg);
114114 pkg.name = name;
115115 pkg.path = path;
116 pkg.children = ArrayList(&CliPkg).init(allocator);
116 pkg.children = ArrayList(*CliPkg).init(allocator);
117117 pkg.parent = parent;
118118 return pkg;
119119 }
120120
121 pub fn deinit(self: &CliPkg) void {
121 pub fn deinit(self: *CliPkg) void {
122122 for (self.children.toSliceConst()) |child| {
123123 child.deinit();
124124 }
......@@ -126,7 +126,7 @@ pub const Module = struct {
126126 }
127127 };
128128
129 pub fn create(allocator: &mem.Allocator, name: []const u8, root_src_path: ?[]const u8, target: &const Target, kind: Kind, build_mode: builtin.Mode, zig_lib_dir: []const u8, cache_dir: []const u8) !&Module {
129 pub fn create(allocator: *mem.Allocator, name: []const u8, root_src_path: ?[]const u8, target: *const Target, kind: Kind, build_mode: builtin.Mode, zig_lib_dir: []const u8, cache_dir: []const u8) !*Module {
130130 var name_buffer = try Buffer.init(allocator, name);
131131 errdefer name_buffer.deinit();
132132
......@@ -188,7 +188,7 @@ pub const Module = struct {
188188 .link_objects = [][]const u8{},
189189 .windows_subsystem_windows = false,
190190 .windows_subsystem_console = false,
191 .link_libs_list = ArrayList(&LinkLib).init(allocator),
191 .link_libs_list = ArrayList(*LinkLib).init(allocator),
192192 .libc_link_lib = null,
193193 .err_color = errmsg.Color.Auto,
194194 .darwin_frameworks = [][]const u8{},
......@@ -200,11 +200,11 @@ pub const Module = struct {
200200 return module_ptr;
201201 }
202202
203 fn dump(self: &Module) void {
203 fn dump(self: *Module) void {
204204 c.LLVMDumpModule(self.module);
205205 }
206206
207 pub fn destroy(self: &Module) void {
207 pub fn destroy(self: *Module) void {
208208 c.LLVMDisposeBuilder(self.builder);
209209 c.LLVMDisposeModule(self.module);
210210 c.LLVMContextDispose(self.context);
......@@ -213,7 +213,7 @@ pub const Module = struct {
213213 self.allocator.destroy(self);
214214 }
215215
216 pub fn build(self: &Module) !void {
216 pub fn build(self: *Module) !void {
217217 if (self.llvm_argv.len != 0) {
218218 var c_compatible_args = try std.cstr.NullTerminated2DArray.fromSlices(self.allocator, [][]const []const u8{
219219 [][]const u8{"zig (LLVM option parsing)"},
......@@ -259,12 +259,12 @@ pub const Module = struct {
259259 self.dump();
260260 }
261261
262 pub fn link(self: &Module, out_file: ?[]const u8) !void {
262 pub fn link(self: *Module, out_file: ?[]const u8) !void {
263263 warn("TODO link");
264264 return error.Todo;
265265 }
266266
267 pub fn addLinkLib(self: &Module, name: []const u8, provided_explicitly: bool) !&LinkLib {
267 pub fn addLinkLib(self: *Module, name: []const u8, provided_explicitly: bool) !*LinkLib {
268268 const is_libc = mem.eql(u8, name, "c");
269269
270270 if (is_libc) {
src-self-hosted/scope.zig+1-1
......@@ -1,6 +1,6 @@
11pub const Scope = struct {
22 id: Id,
3 parent: &Scope,
3 parent: *Scope,
44
55 pub const Id = enum {
66 Decls,
src-self-hosted/target.zig+5-5
......@@ -11,7 +11,7 @@ pub const Target = union(enum) {
1111 Native,
1212 Cross: CrossTarget,
1313
14 pub fn oFileExt(self: &const Target) []const u8 {
14 pub fn oFileExt(self: *const Target) []const u8 {
1515 const environ = switch (self.*) {
1616 Target.Native => builtin.environ,
1717 Target.Cross => |t| t.environ,
......@@ -22,28 +22,28 @@ pub const Target = union(enum) {
2222 };
2323 }
2424
25 pub fn exeFileExt(self: &const Target) []const u8 {
25 pub fn exeFileExt(self: *const Target) []const u8 {
2626 return switch (self.getOs()) {
2727 builtin.Os.windows => ".exe",
2828 else => "",
2929 };
3030 }
3131
32 pub fn getOs(self: &const Target) builtin.Os {
32 pub fn getOs(self: *const Target) builtin.Os {
3333 return switch (self.*) {
3434 Target.Native => builtin.os,
3535 Target.Cross => |t| t.os,
3636 };
3737 }
3838
39 pub fn isDarwin(self: &const Target) bool {
39 pub fn isDarwin(self: *const Target) bool {
4040 return switch (self.getOs()) {
4141 builtin.Os.ios, builtin.Os.macosx => true,
4242 else => false,
4343 };
4444 }
4545
46 pub fn isWindows(self: &const Target) bool {
46 pub fn isWindows(self: *const Target) bool {
4747 return switch (self.getOs()) {
4848 builtin.Os.windows => true,
4949 else => false,
src/all_types.hpp+16-17
......@@ -374,7 +374,7 @@ enum NodeType {
374374 NodeTypeCharLiteral,
375375 NodeTypeSymbol,
376376 NodeTypePrefixOpExpr,
377 NodeTypeAddrOfExpr,
377 NodeTypePointerType,
378378 NodeTypeFnCallExpr,
379379 NodeTypeArrayAccessExpr,
380380 NodeTypeSliceExpr,
......@@ -616,6 +616,7 @@ enum PrefixOp {
616616 PrefixOpNegationWrap,
617617 PrefixOpMaybe,
618618 PrefixOpUnwrapMaybe,
619 PrefixOpAddrOf,
619620};
620621
621622struct AstNodePrefixOpExpr {
......@@ -623,7 +624,7 @@ struct AstNodePrefixOpExpr {
623624 AstNode *primary_expr;
624625};
625626
626struct AstNodeAddrOfExpr {
627struct AstNodePointerType {
627628 AstNode *align_expr;
628629 BigInt *bit_offset_start;
629630 BigInt *bit_offset_end;
......@@ -899,7 +900,7 @@ struct AstNode {
899900 AstNodeBinOpExpr bin_op_expr;
900901 AstNodeCatchExpr unwrap_err_expr;
901902 AstNodePrefixOpExpr prefix_op_expr;
902 AstNodeAddrOfExpr addr_of_expr;
903 AstNodePointerType pointer_type;
903904 AstNodeFnCallExpr fn_call_expr;
904905 AstNodeArrayAccessExpr array_access_expr;
905906 AstNodeSliceExpr slice_expr;
......@@ -2053,7 +2054,7 @@ enum IrInstructionId {
20532054 IrInstructionIdTypeInfo,
20542055 IrInstructionIdTypeId,
20552056 IrInstructionIdSetEvalBranchQuota,
2056 IrInstructionIdPtrTypeOf,
2057 IrInstructionIdPtrType,
20572058 IrInstructionIdAlignCast,
20582059 IrInstructionIdOpaqueType,
20592060 IrInstructionIdSetAlignStack,
......@@ -2274,8 +2275,6 @@ struct IrInstructionVarPtr {
22742275 IrInstruction base;
22752276
22762277 VariableTableEntry *var;
2277 bool is_const;
2278 bool is_volatile;
22792278};
22802279
22812280struct IrInstructionCall {
......@@ -2412,6 +2411,17 @@ struct IrInstructionArrayType {
24122411 IrInstruction *child_type;
24132412};
24142413
2414struct IrInstructionPtrType {
2415 IrInstruction base;
2416
2417 IrInstruction *align_value;
2418 IrInstruction *child_type;
2419 uint32_t bit_offset_start;
2420 uint32_t bit_offset_end;
2421 bool is_const;
2422 bool is_volatile;
2423};
2424
24152425struct IrInstructionPromiseType {
24162426 IrInstruction base;
24172427
......@@ -2891,17 +2901,6 @@ struct IrInstructionSetEvalBranchQuota {
28912901 IrInstruction *new_quota;
28922902};
28932903
2894struct IrInstructionPtrTypeOf {
2895 IrInstruction base;
2896
2897 IrInstruction *align_value;
2898 IrInstruction *child_type;
2899 uint32_t bit_offset_start;
2900 uint32_t bit_offset_end;
2901 bool is_const;
2902 bool is_volatile;
2903};
2904
29052904struct IrInstructionAlignCast {
29062905 IrInstruction base;
29072906
src/analyze.cpp+4-4
......@@ -418,12 +418,12 @@ TypeTableEntry *get_pointer_to_type_extra(CodeGen *g, TypeTableEntry *child_type
418418 const char *volatile_str = is_volatile ? "volatile " : "";
419419 buf_resize(&entry->name, 0);
420420 if (unaligned_bit_count == 0 && byte_alignment == abi_alignment) {
421 buf_appendf(&entry->name, "&%s%s%s", const_str, volatile_str, buf_ptr(&child_type->name));
421 buf_appendf(&entry->name, "*%s%s%s", const_str, volatile_str, buf_ptr(&child_type->name));
422422 } else if (unaligned_bit_count == 0) {
423 buf_appendf(&entry->name, "&align(%" PRIu32 ") %s%s%s", byte_alignment,
423 buf_appendf(&entry->name, "*align(%" PRIu32 ") %s%s%s", byte_alignment,
424424 const_str, volatile_str, buf_ptr(&child_type->name));
425425 } else {
426 buf_appendf(&entry->name, "&align(%" PRIu32 ":%" PRIu32 ":%" PRIu32 ") %s%s%s", byte_alignment,
426 buf_appendf(&entry->name, "*align(%" PRIu32 ":%" PRIu32 ":%" PRIu32 ") %s%s%s", byte_alignment,
427427 bit_offset, bit_offset + unaligned_bit_count, const_str, volatile_str, buf_ptr(&child_type->name));
428428 }
429429
......@@ -3270,7 +3270,7 @@ void scan_decls(CodeGen *g, ScopeDecls *decls_scope, AstNode *node) {
32703270 case NodeTypeThisLiteral:
32713271 case NodeTypeSymbol:
32723272 case NodeTypePrefixOpExpr:
3273 case NodeTypeAddrOfExpr:
3273 case NodeTypePointerType:
32743274 case NodeTypeIfBoolExpr:
32753275 case NodeTypeWhileExpr:
32763276 case NodeTypeForExpr:
src/ast_render.cpp+16-15
......@@ -68,6 +68,7 @@ static const char *prefix_op_str(PrefixOp prefix_op) {
6868 case PrefixOpBinNot: return "~";
6969 case PrefixOpMaybe: return "?";
7070 case PrefixOpUnwrapMaybe: return "??";
71 case PrefixOpAddrOf: return "&";
7172 }
7273 zig_unreachable();
7374}
......@@ -185,8 +186,6 @@ static const char *node_type_str(NodeType node_type) {
185186 return "Symbol";
186187 case NodeTypePrefixOpExpr:
187188 return "PrefixOpExpr";
188 case NodeTypeAddrOfExpr:
189 return "AddrOfExpr";
190189 case NodeTypeUse:
191190 return "Use";
192191 case NodeTypeBoolLiteral:
......@@ -251,6 +250,8 @@ static const char *node_type_str(NodeType node_type) {
251250 return "Suspend";
252251 case NodeTypePromiseType:
253252 return "PromiseType";
253 case NodeTypePointerType:
254 return "PointerType";
254255 }
255256 zig_unreachable();
256257}
......@@ -616,41 +617,41 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) {
616617 fprintf(ar->f, "%s", prefix_op_str(op));
617618
618619 AstNode *child_node = node->data.prefix_op_expr.primary_expr;
619 bool new_grouped = child_node->type == NodeTypePrefixOpExpr || child_node->type == NodeTypeAddrOfExpr;
620 bool new_grouped = child_node->type == NodeTypePrefixOpExpr || child_node->type == NodeTypePointerType;
620621 render_node_extra(ar, child_node, new_grouped);
621622 if (!grouped) fprintf(ar->f, ")");
622623 break;
623624 }
624 case NodeTypeAddrOfExpr:
625 case NodeTypePointerType:
625626 {
626627 if (!grouped) fprintf(ar->f, "(");
627 fprintf(ar->f, "&");
628 if (node->data.addr_of_expr.align_expr != nullptr) {
628 fprintf(ar->f, "*");
629 if (node->data.pointer_type.align_expr != nullptr) {
629630 fprintf(ar->f, "align(");
630 render_node_grouped(ar, node->data.addr_of_expr.align_expr);
631 if (node->data.addr_of_expr.bit_offset_start != nullptr) {
632 assert(node->data.addr_of_expr.bit_offset_end != nullptr);
631 render_node_grouped(ar, node->data.pointer_type.align_expr);
632 if (node->data.pointer_type.bit_offset_start != nullptr) {
633 assert(node->data.pointer_type.bit_offset_end != nullptr);
633634
634635 Buf offset_start_buf = BUF_INIT;
635636 buf_resize(&offset_start_buf, 0);
636 bigint_append_buf(&offset_start_buf, node->data.addr_of_expr.bit_offset_start, 10);
637 bigint_append_buf(&offset_start_buf, node->data.pointer_type.bit_offset_start, 10);
637638
638639 Buf offset_end_buf = BUF_INIT;
639640 buf_resize(&offset_end_buf, 0);
640 bigint_append_buf(&offset_end_buf, node->data.addr_of_expr.bit_offset_end, 10);
641 bigint_append_buf(&offset_end_buf, node->data.pointer_type.bit_offset_end, 10);
641642
642643 fprintf(ar->f, ":%s:%s ", buf_ptr(&offset_start_buf), buf_ptr(&offset_end_buf));
643644 }
644645 fprintf(ar->f, ") ");
645646 }
646 if (node->data.addr_of_expr.is_const) {
647 if (node->data.pointer_type.is_const) {
647648 fprintf(ar->f, "const ");
648649 }
649 if (node->data.addr_of_expr.is_volatile) {
650 if (node->data.pointer_type.is_volatile) {
650651 fprintf(ar->f, "volatile ");
651652 }
652653
653 render_node_ungrouped(ar, node->data.addr_of_expr.op_expr);
654 render_node_ungrouped(ar, node->data.pointer_type.op_expr);
654655 if (!grouped) fprintf(ar->f, ")");
655656 break;
656657 }
......@@ -669,7 +670,7 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) {
669670 fprintf(ar->f, " ");
670671 }
671672 AstNode *fn_ref_node = node->data.fn_call_expr.fn_ref_expr;
672 bool grouped = (fn_ref_node->type != NodeTypePrefixOpExpr && fn_ref_node->type != NodeTypeAddrOfExpr);
673 bool grouped = (fn_ref_node->type != NodeTypePrefixOpExpr && fn_ref_node->type != NodeTypePointerType);
673674 render_node_extra(ar, fn_ref_node, grouped);
674675 fprintf(ar->f, "(");
675676 for (size_t i = 0; i < node->data.fn_call_expr.params.length; i += 1) {
src/codegen.cpp+1-1
......@@ -4600,7 +4600,7 @@ static LLVMValueRef ir_render_instruction(CodeGen *g, IrExecutable *executable,
46004600 case IrInstructionIdTypeInfo:
46014601 case IrInstructionIdTypeId:
46024602 case IrInstructionIdSetEvalBranchQuota:
4603 case IrInstructionIdPtrTypeOf:
4603 case IrInstructionIdPtrType:
46044604 case IrInstructionIdOpaqueType:
46054605 case IrInstructionIdSetAlignStack:
46064606 case IrInstructionIdArgType:
src/ir.cpp+173-174
......@@ -41,10 +41,6 @@ struct IrAnalyze {
4141static const LVal LVAL_NONE = { false, false, false };
4242static const LVal LVAL_PTR = { true, false, false };
4343
44static LVal make_lval_addr(bool is_const, bool is_volatile) {
45 return { true, is_const, is_volatile };
46}
47
4844enum ConstCastResultId {
4945 ConstCastResultIdOk,
5046 ConstCastResultIdErrSet,
......@@ -108,8 +104,7 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc
108104static ErrorMsg *exec_add_error_node(CodeGen *codegen, IrExecutable *exec, AstNode *source_node, Buf *msg);
109105static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_name,
110106 IrInstruction *source_instr, IrInstruction *container_ptr, TypeTableEntry *container_type);
111static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction,
112 VariableTableEntry *var, bool is_const_ptr, bool is_volatile_ptr);
107static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction, VariableTableEntry *var);
113108static TypeTableEntry *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstruction *op);
114109static IrInstruction *ir_lval_wrap(IrBuilder *irb, Scope *scope, IrInstruction *value, LVal lval);
115110
......@@ -629,8 +624,8 @@ static constexpr IrInstructionId ir_instruction_id(IrInstructionSetEvalBranchQuo
629624 return IrInstructionIdSetEvalBranchQuota;
630625}
631626
632static constexpr IrInstructionId ir_instruction_id(IrInstructionPtrTypeOf *) {
633 return IrInstructionIdPtrTypeOf;
627static constexpr IrInstructionId ir_instruction_id(IrInstructionPtrType *) {
628 return IrInstructionIdPtrType;
634629}
635630
636631static constexpr IrInstructionId ir_instruction_id(IrInstructionAlignCast *) {
......@@ -1004,13 +999,9 @@ static IrInstruction *ir_build_bin_op_from(IrBuilder *irb, IrInstruction *old_in
1004999 return new_instruction;
10051000}
10061001
1007static IrInstruction *ir_build_var_ptr(IrBuilder *irb, Scope *scope, AstNode *source_node,
1008 VariableTableEntry *var, bool is_const, bool is_volatile)
1009{
1002static IrInstruction *ir_build_var_ptr(IrBuilder *irb, Scope *scope, AstNode *source_node, VariableTableEntry *var) {
10101003 IrInstructionVarPtr *instruction = ir_build_instruction<IrInstructionVarPtr>(irb, scope, source_node);
10111004 instruction->var = var;
1012 instruction->is_const = is_const;
1013 instruction->is_volatile = is_volatile;
10141005
10151006 ir_ref_var(var);
10161007
......@@ -1196,11 +1187,11 @@ static IrInstruction *ir_build_br_from(IrBuilder *irb, IrInstruction *old_instru
11961187 return new_instruction;
11971188}
11981189
1199static IrInstruction *ir_build_ptr_type_of(IrBuilder *irb, Scope *scope, AstNode *source_node,
1190static IrInstruction *ir_build_ptr_type(IrBuilder *irb, Scope *scope, AstNode *source_node,
12001191 IrInstruction *child_type, bool is_const, bool is_volatile, IrInstruction *align_value,
12011192 uint32_t bit_offset_start, uint32_t bit_offset_end)
12021193{
1203 IrInstructionPtrTypeOf *ptr_type_of_instruction = ir_build_instruction<IrInstructionPtrTypeOf>(irb, scope, source_node);
1194 IrInstructionPtrType *ptr_type_of_instruction = ir_build_instruction<IrInstructionPtrType>(irb, scope, source_node);
12041195 ptr_type_of_instruction->align_value = align_value;
12051196 ptr_type_of_instruction->child_type = child_type;
12061197 ptr_type_of_instruction->is_const = is_const;
......@@ -3519,8 +3510,7 @@ static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node,
35193510
35203511 VariableTableEntry *var = find_variable(irb->codegen, scope, variable_name);
35213512 if (var) {
3522 IrInstruction *var_ptr = ir_build_var_ptr(irb, scope, node, var,
3523 !lval.is_ptr || lval.is_const, lval.is_ptr && lval.is_volatile);
3513 IrInstruction *var_ptr = ir_build_var_ptr(irb, scope, node, var);
35243514 if (lval.is_ptr)
35253515 return var_ptr;
35263516 else
......@@ -4609,14 +4599,8 @@ static IrInstruction *ir_gen_if_bool_expr(IrBuilder *irb, Scope *scope, AstNode
46094599}
46104600
46114601static IrInstruction *ir_gen_prefix_op_id_lval(IrBuilder *irb, Scope *scope, AstNode *node, IrUnOp op_id, LVal lval) {
4612 AstNode *expr_node;
4613 if (node->type == NodeTypePrefixOpExpr) {
4614 expr_node = node->data.prefix_op_expr.primary_expr;
4615 } else if (node->type == NodeTypePtrDeref) {
4616 expr_node = node->data.ptr_deref_expr.target;
4617 } else {
4618 zig_unreachable();
4619 }
4602 assert(node->type == NodeTypePrefixOpExpr);
4603 AstNode *expr_node = node->data.prefix_op_expr.primary_expr;
46204604
46214605 IrInstruction *value = ir_gen_node_extra(irb, expr_node, scope, lval);
46224606 if (value == irb->codegen->invalid_instruction)
......@@ -4640,16 +4624,12 @@ static IrInstruction *ir_lval_wrap(IrBuilder *irb, Scope *scope, IrInstruction *
46404624 return ir_build_ref(irb, scope, value->source_node, value, lval.is_const, lval.is_volatile);
46414625}
46424626
4643static IrInstruction *ir_gen_address_of(IrBuilder *irb, Scope *scope, AstNode *node) {
4644 assert(node->type == NodeTypeAddrOfExpr);
4645 bool is_const = node->data.addr_of_expr.is_const;
4646 bool is_volatile = node->data.addr_of_expr.is_volatile;
4647 AstNode *expr_node = node->data.addr_of_expr.op_expr;
4648 AstNode *align_expr = node->data.addr_of_expr.align_expr;
4649
4650 if (align_expr == nullptr && !is_const && !is_volatile) {
4651 return ir_gen_node_extra(irb, expr_node, scope, make_lval_addr(is_const, is_volatile));
4652 }
4627static IrInstruction *ir_gen_pointer_type(IrBuilder *irb, Scope *scope, AstNode *node) {
4628 assert(node->type == NodeTypePointerType);
4629 bool is_const = node->data.pointer_type.is_const;
4630 bool is_volatile = node->data.pointer_type.is_volatile;
4631 AstNode *expr_node = node->data.pointer_type.op_expr;
4632 AstNode *align_expr = node->data.pointer_type.align_expr;
46534633
46544634 IrInstruction *align_value;
46554635 if (align_expr != nullptr) {
......@@ -4665,27 +4645,27 @@ static IrInstruction *ir_gen_address_of(IrBuilder *irb, Scope *scope, AstNode *n
46654645 return child_type;
46664646
46674647 uint32_t bit_offset_start = 0;
4668 if (node->data.addr_of_expr.bit_offset_start != nullptr) {
4669 if (!bigint_fits_in_bits(node->data.addr_of_expr.bit_offset_start, 32, false)) {
4648 if (node->data.pointer_type.bit_offset_start != nullptr) {
4649 if (!bigint_fits_in_bits(node->data.pointer_type.bit_offset_start, 32, false)) {
46704650 Buf *val_buf = buf_alloc();
4671 bigint_append_buf(val_buf, node->data.addr_of_expr.bit_offset_start, 10);
4651 bigint_append_buf(val_buf, node->data.pointer_type.bit_offset_start, 10);
46724652 exec_add_error_node(irb->codegen, irb->exec, node,
46734653 buf_sprintf("value %s too large for u32 bit offset", buf_ptr(val_buf)));
46744654 return irb->codegen->invalid_instruction;
46754655 }
4676 bit_offset_start = bigint_as_unsigned(node->data.addr_of_expr.bit_offset_start);
4656 bit_offset_start = bigint_as_unsigned(node->data.pointer_type.bit_offset_start);
46774657 }
46784658
46794659 uint32_t bit_offset_end = 0;
4680 if (node->data.addr_of_expr.bit_offset_end != nullptr) {
4681 if (!bigint_fits_in_bits(node->data.addr_of_expr.bit_offset_end, 32, false)) {
4660 if (node->data.pointer_type.bit_offset_end != nullptr) {
4661 if (!bigint_fits_in_bits(node->data.pointer_type.bit_offset_end, 32, false)) {
46824662 Buf *val_buf = buf_alloc();
4683 bigint_append_buf(val_buf, node->data.addr_of_expr.bit_offset_end, 10);
4663 bigint_append_buf(val_buf, node->data.pointer_type.bit_offset_end, 10);
46844664 exec_add_error_node(irb->codegen, irb->exec, node,
46854665 buf_sprintf("value %s too large for u32 bit offset", buf_ptr(val_buf)));
46864666 return irb->codegen->invalid_instruction;
46874667 }
4688 bit_offset_end = bigint_as_unsigned(node->data.addr_of_expr.bit_offset_end);
4668 bit_offset_end = bigint_as_unsigned(node->data.pointer_type.bit_offset_end);
46894669 }
46904670
46914671 if ((bit_offset_start != 0 || bit_offset_end != 0) && bit_offset_start >= bit_offset_end) {
......@@ -4694,7 +4674,7 @@ static IrInstruction *ir_gen_address_of(IrBuilder *irb, Scope *scope, AstNode *n
46944674 return irb->codegen->invalid_instruction;
46954675 }
46964676
4697 return ir_build_ptr_type_of(irb, scope, node, child_type, is_const, is_volatile,
4677 return ir_build_ptr_type(irb, scope, node, child_type, is_const, is_volatile,
46984678 align_value, bit_offset_start, bit_offset_end);
46994679}
47004680
......@@ -4761,6 +4741,10 @@ static IrInstruction *ir_gen_prefix_op_expr(IrBuilder *irb, Scope *scope, AstNod
47614741 return ir_lval_wrap(irb, scope, ir_gen_prefix_op_id(irb, scope, node, IrUnOpMaybe), lval);
47624742 case PrefixOpUnwrapMaybe:
47634743 return ir_gen_maybe_assert_ok(irb, scope, node, lval);
4744 case PrefixOpAddrOf: {
4745 AstNode *expr_node = node->data.prefix_op_expr.primary_expr;
4746 return ir_lval_wrap(irb, scope, ir_gen_node_extra(irb, expr_node, scope, LVAL_PTR), lval);
4747 }
47644748 }
47654749 zig_unreachable();
47664750}
......@@ -5150,7 +5134,7 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo
51505134
51515135 IrInstruction *undefined_value = ir_build_const_undefined(irb, child_scope, elem_node);
51525136 ir_build_var_decl(irb, child_scope, elem_node, elem_var, elem_var_type, nullptr, undefined_value);
5153 IrInstruction *elem_var_ptr = ir_build_var_ptr(irb, child_scope, node, elem_var, false, false);
5137 IrInstruction *elem_var_ptr = ir_build_var_ptr(irb, child_scope, node, elem_var);
51545138
51555139 AstNode *index_var_source_node;
51565140 VariableTableEntry *index_var;
......@@ -5168,7 +5152,7 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo
51685152 IrInstruction *zero = ir_build_const_usize(irb, child_scope, node, 0);
51695153 IrInstruction *one = ir_build_const_usize(irb, child_scope, node, 1);
51705154 ir_build_var_decl(irb, child_scope, index_var_source_node, index_var, usize, nullptr, zero);
5171 IrInstruction *index_ptr = ir_build_var_ptr(irb, child_scope, node, index_var, false, false);
5155 IrInstruction *index_ptr = ir_build_var_ptr(irb, child_scope, node, index_var);
51725156
51735157
51745158 IrBasicBlock *cond_block = ir_create_basic_block(irb, child_scope, "ForCond");
......@@ -6397,7 +6381,7 @@ static IrInstruction *ir_gen_await_expr(IrBuilder *irb, Scope *parent_scope, Ast
63976381 IrInstruction *promise_result_type = ir_build_promise_result_type(irb, parent_scope, node, target_promise_type);
63986382 ir_build_await_bookkeeping(irb, parent_scope, node, promise_result_type);
63996383 ir_build_var_decl(irb, parent_scope, node, result_var, promise_result_type, nullptr, undefined_value);
6400 IrInstruction *my_result_var_ptr = ir_build_var_ptr(irb, parent_scope, node, result_var, false, false);
6384 IrInstruction *my_result_var_ptr = ir_build_var_ptr(irb, parent_scope, node, result_var);
64016385 ir_build_store_ptr(irb, parent_scope, node, result_ptr_field_ptr, my_result_var_ptr);
64026386 IrInstruction *save_token = ir_build_coro_save(irb, parent_scope, node, irb->exec->coro_handle);
64036387 IrInstruction *promise_type_val = ir_build_const_type(irb, parent_scope, node,
......@@ -6568,8 +6552,6 @@ static IrInstruction *ir_gen_node_raw(IrBuilder *irb, AstNode *node, Scope *scop
65686552 return ir_lval_wrap(irb, scope, ir_gen_if_bool_expr(irb, scope, node), lval);
65696553 case NodeTypePrefixOpExpr:
65706554 return ir_gen_prefix_op_expr(irb, scope, node, lval);
6571 case NodeTypeAddrOfExpr:
6572 return ir_lval_wrap(irb, scope, ir_gen_address_of(irb, scope, node), lval);
65736555 case NodeTypeContainerInitExpr:
65746556 return ir_lval_wrap(irb, scope, ir_gen_container_init_expr(irb, scope, node), lval);
65756557 case NodeTypeVariableDeclaration:
......@@ -6592,14 +6574,23 @@ static IrInstruction *ir_gen_node_raw(IrBuilder *irb, AstNode *node, Scope *scop
65926574
65936575 return ir_build_load_ptr(irb, scope, node, ptr_instruction);
65946576 }
6595 case NodeTypePtrDeref:
6596 return ir_gen_prefix_op_id_lval(irb, scope, node, IrUnOpDereference, lval);
6577 case NodeTypePtrDeref: {
6578 assert(node->type == NodeTypePtrDeref);
6579 AstNode *expr_node = node->data.ptr_deref_expr.target;
6580 IrInstruction *value = ir_gen_node_extra(irb, expr_node, scope, lval);
6581 if (value == irb->codegen->invalid_instruction)
6582 return value;
6583
6584 return ir_build_un_op(irb, scope, node, IrUnOpDereference, value);
6585 }
65976586 case NodeTypeThisLiteral:
65986587 return ir_lval_wrap(irb, scope, ir_gen_this_literal(irb, scope, node), lval);
65996588 case NodeTypeBoolLiteral:
66006589 return ir_lval_wrap(irb, scope, ir_gen_bool_literal(irb, scope, node), lval);
66016590 case NodeTypeArrayType:
66026591 return ir_lval_wrap(irb, scope, ir_gen_array_type(irb, scope, node), lval);
6592 case NodeTypePointerType:
6593 return ir_lval_wrap(irb, scope, ir_gen_pointer_type(irb, scope, node), lval);
66036594 case NodeTypePromiseType:
66046595 return ir_lval_wrap(irb, scope, ir_gen_promise_type(irb, scope, node), lval);
66056596 case NodeTypeStringLiteral:
......@@ -6711,15 +6702,14 @@ bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutable *ir_exec
67116702 IrInstruction *coro_frame_type_value = ir_build_const_type(irb, coro_scope, node, coro_frame_type);
67126703 // TODO mark this var decl as "no safety" e.g. disable initializing the undef value to 0xaa
67136704 ir_build_var_decl(irb, coro_scope, node, promise_var, coro_frame_type_value, nullptr, undef);
6714 coro_promise_ptr = ir_build_var_ptr(irb, coro_scope, node, promise_var, false, false);
6705 coro_promise_ptr = ir_build_var_ptr(irb, coro_scope, node, promise_var);
67156706
67166707 VariableTableEntry *await_handle_var = ir_create_var(irb, node, coro_scope, nullptr, false, false, true, const_bool_false);
67176708 IrInstruction *null_value = ir_build_const_null(irb, coro_scope, node);
67186709 IrInstruction *await_handle_type_val = ir_build_const_type(irb, coro_scope, node,
67196710 get_maybe_type(irb->codegen, irb->codegen->builtin_types.entry_promise));
67206711 ir_build_var_decl(irb, coro_scope, node, await_handle_var, await_handle_type_val, nullptr, null_value);
6721 irb->exec->await_handle_var_ptr = ir_build_var_ptr(irb, coro_scope, node,
6722 await_handle_var, false, false);
6712 irb->exec->await_handle_var_ptr = ir_build_var_ptr(irb, coro_scope, node, await_handle_var);
67236713
67246714 u8_ptr_type = ir_build_const_type(irb, coro_scope, node,
67256715 get_pointer_to_type(irb->codegen, irb->codegen->builtin_types.entry_u8, false));
......@@ -6859,7 +6849,7 @@ bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutable *ir_exec
68596849 IrInstruction *coro_mem_ptr_maybe = ir_build_coro_free(irb, scope, node, coro_id, irb->exec->coro_handle);
68606850 IrInstruction *coro_mem_ptr = ir_build_ptr_cast(irb, scope, node, u8_ptr_type, coro_mem_ptr_maybe);
68616851 IrInstruction *coro_mem_ptr_ref = ir_build_ref(irb, scope, node, coro_mem_ptr, true, false);
6862 IrInstruction *coro_size_ptr = ir_build_var_ptr(irb, scope, node, coro_size_var, true, false);
6852 IrInstruction *coro_size_ptr = ir_build_var_ptr(irb, scope, node, coro_size_var);
68636853 IrInstruction *coro_size = ir_build_load_ptr(irb, scope, node, coro_size_ptr);
68646854 IrInstruction *mem_slice = ir_build_slice(irb, scope, node, coro_mem_ptr_ref, zero, coro_size, false);
68656855 size_t arg_count = 2;
......@@ -8961,34 +8951,15 @@ static IrInstruction *ir_get_const_ptr(IrAnalyze *ira, IrInstruction *instructio
89618951 ConstExprValue *pointee, TypeTableEntry *pointee_type,
89628952 ConstPtrMut ptr_mut, bool ptr_is_const, bool ptr_is_volatile, uint32_t ptr_align)
89638953{
8964 if (pointee_type->id == TypeTableEntryIdMetaType) {
8965 TypeTableEntry *type_entry = pointee->data.x_type;
8966 if (type_entry->id == TypeTableEntryIdUnreachable) {
8967 ir_add_error(ira, instruction, buf_sprintf("pointer to noreturn not allowed"));
8968 return ira->codegen->invalid_instruction;
8969 }
8970
8971 IrInstruction *const_instr = ir_get_const(ira, instruction);
8972 ConstExprValue *const_val = &const_instr->value;
8973 const_val->type = pointee_type;
8974 type_ensure_zero_bits_known(ira->codegen, type_entry);
8975 if (type_is_invalid(type_entry)) {
8976 return ira->codegen->invalid_instruction;
8977 }
8978 const_val->data.x_type = get_pointer_to_type_extra(ira->codegen, type_entry,
8979 ptr_is_const, ptr_is_volatile, get_abi_alignment(ira->codegen, type_entry), 0, 0);
8980 return const_instr;
8981 } else {
8982 TypeTableEntry *ptr_type = get_pointer_to_type_extra(ira->codegen, pointee_type,
8983 ptr_is_const, ptr_is_volatile, ptr_align, 0, 0);
8984 IrInstruction *const_instr = ir_get_const(ira, instruction);
8985 ConstExprValue *const_val = &const_instr->value;
8986 const_val->type = ptr_type;
8987 const_val->data.x_ptr.special = ConstPtrSpecialRef;
8988 const_val->data.x_ptr.mut = ptr_mut;
8989 const_val->data.x_ptr.data.ref.pointee = pointee;
8990 return const_instr;
8991 }
8954 TypeTableEntry *ptr_type = get_pointer_to_type_extra(ira->codegen, pointee_type,
8955 ptr_is_const, ptr_is_volatile, ptr_align, 0, 0);
8956 IrInstruction *const_instr = ir_get_const(ira, instruction);
8957 ConstExprValue *const_val = &const_instr->value;
8958 const_val->type = ptr_type;
8959 const_val->data.x_ptr.special = ConstPtrSpecialRef;
8960 const_val->data.x_ptr.mut = ptr_mut;
8961 const_val->data.x_ptr.data.ref.pointee = pointee;
8962 return const_instr;
89928963}
89938964
89948965static TypeTableEntry *ir_analyze_const_ptr(IrAnalyze *ira, IrInstruction *instruction,
......@@ -9316,9 +9287,8 @@ static IrInstruction *ir_get_ref(IrAnalyze *ira, IrInstruction *source_instructi
93169287 ConstExprValue *val = ir_resolve_const(ira, value, UndefOk);
93179288 if (!val)
93189289 return ira->codegen->invalid_instruction;
9319 bool final_is_const = (value->value.type->id == TypeTableEntryIdMetaType) ? is_const : true;
93209290 return ir_get_const_ptr(ira, source_instruction, val, value->value.type,
9321 ConstPtrMutComptimeConst, final_is_const, is_volatile,
9291 ConstPtrMutComptimeConst, is_const, is_volatile,
93229292 get_abi_alignment(ira->codegen, value->value.type));
93239293 }
93249294
......@@ -9463,6 +9433,8 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so
94639433 TypeUnionField *union_field = find_union_field_by_tag(wanted_type, &val->data.x_enum_tag);
94649434 assert(union_field != nullptr);
94659435 type_ensure_zero_bits_known(ira->codegen, union_field->type_entry);
9436 if (type_is_invalid(union_field->type_entry))
9437 return ira->codegen->invalid_instruction;
94669438 if (!union_field->type_entry->zero_bits) {
94679439 AstNode *field_node = wanted_type->data.unionation.decl_node->data.container_decl.fields.at(
94689440 union_field->enum_field->decl_index);
......@@ -10045,6 +10017,9 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
1004510017 if (actual_type->id == TypeTableEntryIdNumLitFloat ||
1004610018 actual_type->id == TypeTableEntryIdNumLitInt)
1004710019 {
10020 ensure_complete_type(ira->codegen, wanted_type);
10021 if (type_is_invalid(wanted_type))
10022 return ira->codegen->invalid_instruction;
1004810023 if (wanted_type->id == TypeTableEntryIdEnum) {
1004910024 IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.enumeration.tag_int_type, value);
1005010025 if (type_is_invalid(cast1->value.type))
......@@ -10247,21 +10222,6 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc
1024710222 source_instruction->source_node, ptr);
1024810223 load_ptr_instruction->value.type = child_type;
1024910224 return load_ptr_instruction;
10250 } else if (type_entry->id == TypeTableEntryIdMetaType) {
10251 ConstExprValue *ptr_val = ir_resolve_const(ira, ptr, UndefBad);
10252 if (!ptr_val)
10253 return ira->codegen->invalid_instruction;
10254
10255 TypeTableEntry *ptr_type = ptr_val->data.x_type;
10256 if (ptr_type->id == TypeTableEntryIdPointer) {
10257 TypeTableEntry *child_type = ptr_type->data.pointer.child_type;
10258 return ir_create_const_type(&ira->new_irb, source_instruction->scope,
10259 source_instruction->source_node, child_type);
10260 } else {
10261 ir_add_error(ira, source_instruction,
10262 buf_sprintf("attempt to dereference non pointer type '%s'", buf_ptr(&ptr_type->name)));
10263 return ira->codegen->invalid_instruction;
10264 }
1026510225 } else {
1026610226 ir_add_error_node(ira, source_instruction->source_node,
1026710227 buf_sprintf("attempt to dereference non pointer type '%s'",
......@@ -11968,7 +11928,7 @@ IrInstruction *ir_get_implicit_allocator(IrAnalyze *ira, IrInstruction *source_i
1196811928 {
1196911929 VariableTableEntry *coro_allocator_var = ira->old_irb.exec->coro_allocator_var;
1197011930 assert(coro_allocator_var != nullptr);
11971 IrInstruction *var_ptr_inst = ir_get_var_ptr(ira, source_instr, coro_allocator_var, true, false);
11931 IrInstruction *var_ptr_inst = ir_get_var_ptr(ira, source_instr, coro_allocator_var);
1197211932 IrInstruction *result = ir_get_deref(ira, source_instr, var_ptr_inst);
1197311933 assert(result->value.type != nullptr);
1197411934 return result;
......@@ -12149,7 +12109,7 @@ static VariableTableEntry *get_fn_var_by_index(FnTableEntry *fn_entry, size_t in
1214912109}
1215012110
1215112111static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction,
12152 VariableTableEntry *var, bool is_const_ptr, bool is_volatile_ptr)
12112 VariableTableEntry *var)
1215312113{
1215412114 if (var->mem_slot_index != SIZE_MAX && var->owner_exec->analysis == nullptr) {
1215512115 assert(ira->codegen->errors.length != 0);
......@@ -12175,8 +12135,8 @@ static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction,
1217512135 }
1217612136 }
1217712137
12178 bool is_const = (var->value->type->id == TypeTableEntryIdMetaType) ? is_const_ptr : var->src_is_const;
12179 bool is_volatile = (var->value->type->id == TypeTableEntryIdMetaType) ? is_volatile_ptr : false;
12138 bool is_const = var->src_is_const;
12139 bool is_volatile = false;
1218012140 if (mem_slot != nullptr) {
1218112141 switch (mem_slot->special) {
1218212142 case ConstValSpecialRuntime:
......@@ -12202,7 +12162,7 @@ static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction,
1220212162no_mem_slot:
1220312163
1220412164 IrInstruction *var_ptr_instruction = ir_build_var_ptr(&ira->new_irb,
12205 instruction->scope, instruction->source_node, var, is_const, is_volatile);
12165 instruction->scope, instruction->source_node, var);
1220612166 var_ptr_instruction->value.type = get_pointer_to_type_extra(ira->codegen, var->value->type,
1220712167 var->src_is_const, is_volatile, var->align_bytes, 0, 0);
1220812168 type_ensure_zero_bits_known(ira->codegen, var->value->type);
......@@ -12488,7 +12448,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
1248812448 buf_sprintf("compiler bug: var args can't handle void. https://github.com/ziglang/zig/issues/557"));
1248912449 return ira->codegen->builtin_types.entry_invalid;
1249012450 }
12491 IrInstruction *arg_var_ptr_inst = ir_get_var_ptr(ira, arg, arg_var, true, false);
12451 IrInstruction *arg_var_ptr_inst = ir_get_var_ptr(ira, arg, arg_var);
1249212452 if (type_is_invalid(arg_var_ptr_inst->value.type))
1249312453 return ira->codegen->builtin_types.entry_invalid;
1249412454
......@@ -12811,6 +12771,10 @@ static TypeTableEntry *ir_analyze_maybe(IrAnalyze *ira, IrInstructionUnOp *un_op
1281112771 TypeTableEntry *type_entry = ir_resolve_type(ira, value);
1281212772 if (type_is_invalid(type_entry))
1281312773 return ira->codegen->builtin_types.entry_invalid;
12774 ensure_complete_type(ira->codegen, type_entry);
12775 if (type_is_invalid(type_entry))
12776 return ira->codegen->builtin_types.entry_invalid;
12777
1281412778 switch (type_entry->id) {
1281512779 case TypeTableEntryIdInvalid:
1281612780 zig_unreachable();
......@@ -13122,17 +13086,16 @@ static TypeTableEntry *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionP
1312213086}
1312313087
1312413088static TypeTableEntry *ir_analyze_var_ptr(IrAnalyze *ira, IrInstruction *instruction,
13125 VariableTableEntry *var, bool is_const_ptr, bool is_volatile_ptr)
13089 VariableTableEntry *var)
1312613090{
13127 IrInstruction *result = ir_get_var_ptr(ira, instruction, var, is_const_ptr, is_volatile_ptr);
13091 IrInstruction *result = ir_get_var_ptr(ira, instruction, var);
1312813092 ir_link_new_instruction(result, instruction);
1312913093 return result->value.type;
1313013094}
1313113095
1313213096static TypeTableEntry *ir_analyze_instruction_var_ptr(IrAnalyze *ira, IrInstructionVarPtr *var_ptr_instruction) {
1313313097 VariableTableEntry *var = var_ptr_instruction->var;
13134 return ir_analyze_var_ptr(ira, &var_ptr_instruction->base, var, var_ptr_instruction->is_const,
13135 var_ptr_instruction->is_volatile);
13098 return ir_analyze_var_ptr(ira, &var_ptr_instruction->base, var);
1313613099}
1313713100
1313813101static TypeTableEntry *adjust_ptr_align(CodeGen *g, TypeTableEntry *ptr_type, uint32_t new_align) {
......@@ -13154,11 +13117,6 @@ static TypeTableEntry *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruc
1315413117 return ira->codegen->builtin_types.entry_invalid;
1315513118
1315613119 TypeTableEntry *ptr_type = array_ptr->value.type;
13157 if (ptr_type->id == TypeTableEntryIdMetaType) {
13158 ir_add_error(ira, &elem_ptr_instruction->base,
13159 buf_sprintf("array access of non-array type '%s'", buf_ptr(&ptr_type->name)));
13160 return ira->codegen->builtin_types.entry_invalid;
13161 }
1316213120 assert(ptr_type->id == TypeTableEntryIdPointer);
1316313121
1316413122 TypeTableEntry *array_type = ptr_type->data.pointer.child_type;
......@@ -13220,8 +13178,7 @@ static TypeTableEntry *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruc
1322013178 bool is_const = true;
1322113179 bool is_volatile = false;
1322213180 if (var) {
13223 return ir_analyze_var_ptr(ira, &elem_ptr_instruction->base, var,
13224 is_const, is_volatile);
13181 return ir_analyze_var_ptr(ira, &elem_ptr_instruction->base, var);
1322513182 } else {
1322613183 return ir_analyze_const_ptr(ira, &elem_ptr_instruction->base, &ira->codegen->const_void_val,
1322713184 ira->codegen->builtin_types.entry_void, ConstPtrMutComptimeConst, is_const, is_volatile);
......@@ -13239,6 +13196,9 @@ static TypeTableEntry *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruc
1323913196
1324013197 bool safety_check_on = elem_ptr_instruction->safety_check_on;
1324113198 ensure_complete_type(ira->codegen, return_type->data.pointer.child_type);
13199 if (type_is_invalid(return_type->data.pointer.child_type))
13200 return ira->codegen->builtin_types.entry_invalid;
13201
1324213202 uint64_t elem_size = type_size(ira->codegen, return_type->data.pointer.child_type);
1324313203 uint64_t abi_align = get_abi_alignment(ira->codegen, return_type->data.pointer.child_type);
1324413204 uint64_t ptr_align = return_type->data.pointer.alignment;
......@@ -13605,7 +13565,7 @@ static TypeTableEntry *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source
1360513565 add_link_lib_symbol(ira, tld_var->extern_lib_name, &var->name, source_instruction->source_node);
1360613566 }
1360713567
13608 return ir_analyze_var_ptr(ira, source_instruction, var, false, false);
13568 return ir_analyze_var_ptr(ira, source_instruction, var);
1360913569 }
1361013570 case TldIdFn:
1361113571 {
......@@ -13654,14 +13614,8 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru
1365413614 if (type_is_invalid(container_ptr->value.type))
1365513615 return ira->codegen->builtin_types.entry_invalid;
1365613616
13657 TypeTableEntry *container_type;
13658 if (container_ptr->value.type->id == TypeTableEntryIdPointer) {
13659 container_type = container_ptr->value.type->data.pointer.child_type;
13660 } else if (container_ptr->value.type->id == TypeTableEntryIdMetaType) {
13661 container_type = container_ptr->value.type;
13662 } else {
13663 zig_unreachable();
13664 }
13617 TypeTableEntry *container_type = container_ptr->value.type->data.pointer.child_type;
13618 assert(container_ptr->value.type->id == TypeTableEntryIdPointer);
1366513619
1366613620 Buf *field_name = field_ptr_instruction->field_name_buffer;
1366713621 if (!field_name) {
......@@ -13734,17 +13688,9 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru
1373413688 if (!container_ptr_val)
1373513689 return ira->codegen->builtin_types.entry_invalid;
1373613690
13737 TypeTableEntry *child_type;
13738 if (container_ptr->value.type->id == TypeTableEntryIdMetaType) {
13739 TypeTableEntry *ptr_type = container_ptr_val->data.x_type;
13740 assert(ptr_type->id == TypeTableEntryIdPointer);
13741 child_type = ptr_type->data.pointer.child_type;
13742 } else if (container_ptr->value.type->id == TypeTableEntryIdPointer) {
13743 ConstExprValue *child_val = const_ptr_pointee(ira->codegen, container_ptr_val);
13744 child_type = child_val->data.x_type;
13745 } else {
13746 zig_unreachable();
13747 }
13691 assert(container_ptr->value.type->id == TypeTableEntryIdPointer);
13692 ConstExprValue *child_val = const_ptr_pointee(ira->codegen, container_ptr_val);
13693 TypeTableEntry *child_type = child_val->data.x_type;
1374813694
1374913695 if (type_is_invalid(child_type)) {
1375013696 return ira->codegen->builtin_types.entry_invalid;
......@@ -13762,7 +13708,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru
1376213708 }
1376313709 if (child_type->id == TypeTableEntryIdEnum) {
1376413710 ensure_complete_type(ira->codegen, child_type);
13765 if (child_type->data.enumeration.is_invalid)
13711 if (type_is_invalid(child_type))
1376613712 return ira->codegen->builtin_types.entry_invalid;
1376713713
1376813714 TypeEnumField *field = find_enum_type_field(child_type, field_name);
......@@ -14635,27 +14581,27 @@ static TypeTableEntry *ir_analyze_instruction_unwrap_maybe(IrAnalyze *ira,
1463514581 return ira->codegen->builtin_types.entry_invalid;
1463614582
1463714583 TypeTableEntry *ptr_type = value->value.type;
14638 if (ptr_type->id == TypeTableEntryIdMetaType) {
14584 assert(ptr_type->id == TypeTableEntryIdPointer);
14585
14586 TypeTableEntry *type_entry = ptr_type->data.pointer.child_type;
14587 if (type_is_invalid(type_entry)) {
14588 return ira->codegen->builtin_types.entry_invalid;
14589 } else if (type_entry->id == TypeTableEntryIdMetaType) {
1463914590 // surprise! actually this is just ??T not an unwrap maybe instruction
14640 TypeTableEntry *ptr_type_ptr = ir_resolve_type(ira, value);
14641 assert(ptr_type_ptr->id == TypeTableEntryIdPointer);
14642 TypeTableEntry *child_type = ptr_type_ptr->data.pointer.child_type;
14591 ConstExprValue *ptr_val = const_ptr_pointee(ira->codegen, &value->value);
14592 assert(ptr_val->type->id == TypeTableEntryIdMetaType);
14593 TypeTableEntry *child_type = ptr_val->data.x_type;
14594
1464314595 type_ensure_zero_bits_known(ira->codegen, child_type);
1464414596 TypeTableEntry *layer1 = get_maybe_type(ira->codegen, child_type);
1464514597 TypeTableEntry *layer2 = get_maybe_type(ira->codegen, layer1);
14646 TypeTableEntry *result_type = get_pointer_to_type(ira->codegen, layer2, true);
1464714598
1464814599 IrInstruction *const_instr = ir_build_const_type(&ira->new_irb, unwrap_maybe_instruction->base.scope,
14649 unwrap_maybe_instruction->base.source_node, result_type);
14650 ir_link_new_instruction(const_instr, &unwrap_maybe_instruction->base);
14651 return const_instr->value.type;
14652 }
14653
14654 assert(ptr_type->id == TypeTableEntryIdPointer);
14655
14656 TypeTableEntry *type_entry = ptr_type->data.pointer.child_type;
14657 if (type_is_invalid(type_entry)) {
14658 return ira->codegen->builtin_types.entry_invalid;
14600 unwrap_maybe_instruction->base.source_node, layer2);
14601 IrInstruction *result_instr = ir_get_ref(ira, &unwrap_maybe_instruction->base, const_instr,
14602 ptr_type->data.pointer.is_const, ptr_type->data.pointer.is_volatile);
14603 ir_link_new_instruction(result_instr, &unwrap_maybe_instruction->base);
14604 return result_instr->value.type;
1465914605 } else if (type_entry->id != TypeTableEntryIdMaybe) {
1466014606 ir_add_error_node(ira, unwrap_maybe_instruction->value->source_node,
1466114607 buf_sprintf("expected nullable type, found '%s'", buf_ptr(&type_entry->name)));
......@@ -15181,6 +15127,8 @@ static TypeTableEntry *ir_analyze_container_init_fields_union(IrAnalyze *ira, Ir
1518115127 assert(container_type->id == TypeTableEntryIdUnion);
1518215128
1518315129 ensure_complete_type(ira->codegen, container_type);
15130 if (type_is_invalid(container_type))
15131 return ira->codegen->builtin_types.entry_invalid;
1518415132
1518515133 if (instr_field_count != 1) {
1518615134 ir_add_error(ira, instruction,
......@@ -15248,6 +15196,8 @@ static TypeTableEntry *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstru
1524815196 }
1524915197
1525015198 ensure_complete_type(ira->codegen, container_type);
15199 if (type_is_invalid(container_type))
15200 return ira->codegen->builtin_types.entry_invalid;
1525115201
1525215202 size_t actual_field_count = container_type->data.structure.src_field_count;
1525315203
......@@ -15753,6 +15703,8 @@ static TypeTableEntry *ir_analyze_instruction_offset_of(IrAnalyze *ira,
1575315703 return ira->codegen->builtin_types.entry_invalid;
1575415704
1575515705 ensure_complete_type(ira->codegen, container_type);
15706 if (type_is_invalid(container_type))
15707 return ira->codegen->builtin_types.entry_invalid;
1575615708
1575715709 IrInstruction *field_name_value = instruction->field_name->other;
1575815710 Buf *field_name = ir_resolve_str(ira, field_name_value);
......@@ -15806,6 +15758,9 @@ static TypeTableEntry *ir_type_info_get_type(IrAnalyze *ira, const char *type_na
1580615758 assert(type_info_var->type->id == TypeTableEntryIdMetaType);
1580715759
1580815760 ensure_complete_type(ira->codegen, type_info_var->data.x_type);
15761 if (type_is_invalid(type_info_var->data.x_type))
15762 return ira->codegen->builtin_types.entry_invalid;
15763
1580915764 type_info_type = type_info_var->data.x_type;
1581015765 assert(type_info_type->id == TypeTableEntryIdUnion);
1581115766 }
......@@ -15831,26 +15786,37 @@ static TypeTableEntry *ir_type_info_get_type(IrAnalyze *ira, const char *type_na
1583115786 VariableTableEntry *var = tld->var;
1583215787
1583315788 ensure_complete_type(ira->codegen, var->value->type);
15789 if (type_is_invalid(var->value->type))
15790 return ira->codegen->builtin_types.entry_invalid;
1583415791 assert(var->value->type->id == TypeTableEntryIdMetaType);
1583515792 return var->value->data.x_type;
1583615793}
1583715794
15838static void ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, ScopeDecls *decls_scope)
15795static bool ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, ScopeDecls *decls_scope)
1583915796{
1584015797 TypeTableEntry *type_info_definition_type = ir_type_info_get_type(ira, "Definition");
1584115798 ensure_complete_type(ira->codegen, type_info_definition_type);
15799 if (type_is_invalid(type_info_definition_type))
15800 return false;
15801
1584215802 ensure_field_index(type_info_definition_type, "name", 0);
1584315803 ensure_field_index(type_info_definition_type, "is_pub", 1);
1584415804 ensure_field_index(type_info_definition_type, "data", 2);
1584515805
1584615806 TypeTableEntry *type_info_definition_data_type = ir_type_info_get_type(ira, "Data", type_info_definition_type);
1584715807 ensure_complete_type(ira->codegen, type_info_definition_data_type);
15808 if (type_is_invalid(type_info_definition_data_type))
15809 return false;
1584815810
1584915811 TypeTableEntry *type_info_fn_def_type = ir_type_info_get_type(ira, "FnDef", type_info_definition_data_type);
1585015812 ensure_complete_type(ira->codegen, type_info_fn_def_type);
15813 if (type_is_invalid(type_info_fn_def_type))
15814 return false;
1585115815
1585215816 TypeTableEntry *type_info_fn_def_inline_type = ir_type_info_get_type(ira, "Inline", type_info_fn_def_type);
1585315817 ensure_complete_type(ira->codegen, type_info_fn_def_inline_type);
15818 if (type_is_invalid(type_info_fn_def_inline_type))
15819 return false;
1585415820
1585515821 // Loop through our definitions once to figure out how many definitions we will generate info for.
1585615822 auto decl_it = decls_scope->decl_table.entry_iterator();
......@@ -15865,7 +15831,7 @@ static void ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, Scop
1586515831 resolve_top_level_decl(ira->codegen, curr_entry->value, false, curr_entry->value->source_node);
1586615832 if (curr_entry->value->resolution != TldResolutionOk)
1586715833 {
15868 return;
15834 return false;
1586915835 }
1587015836 }
1587115837
......@@ -15930,6 +15896,9 @@ static void ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, Scop
1593015896 {
1593115897 VariableTableEntry *var = ((TldVar *)curr_entry->value)->var;
1593215898 ensure_complete_type(ira->codegen, var->value->type);
15899 if (type_is_invalid(var->value->type))
15900 return false;
15901
1593315902 if (var->value->type->id == TypeTableEntryIdMetaType)
1593415903 {
1593515904 // We have a variable of type 'type', so it's actually a type definition.
......@@ -16057,6 +16026,9 @@ static void ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, Scop
1605716026 {
1605816027 TypeTableEntry *type_entry = ((TldContainer *)curr_entry->value)->type_entry;
1605916028 ensure_complete_type(ira->codegen, type_entry);
16029 if (type_is_invalid(type_entry))
16030 return false;
16031
1606016032 // This is a type.
1606116033 bigint_init_unsigned(&inner_fields[2].data.x_union.tag, 0);
1606216034
......@@ -16077,6 +16049,7 @@ static void ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, Scop
1607716049 }
1607816050
1607916051 assert(definition_index == definition_count);
16052 return true;
1608016053}
1608116054
1608216055static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *type_entry)
......@@ -16085,6 +16058,8 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t
1608516058 assert(!type_is_invalid(type_entry));
1608616059
1608716060 ensure_complete_type(ira->codegen, type_entry);
16061 if (type_is_invalid(type_entry))
16062 return nullptr;
1608816063
1608916064 const auto make_enum_field_val = [ira](ConstExprValue *enum_field_val, TypeEnumField *enum_field,
1609016065 TypeTableEntry *type_info_enum_field_type) {
......@@ -16312,7 +16287,8 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t
1631216287 }
1631316288 // defs: []TypeInfo.Definition
1631416289 ensure_field_index(result->type, "defs", 3);
16315 ir_make_type_info_defs(ira, &fields[3], type_entry->data.enumeration.decls_scope);
16290 if (!ir_make_type_info_defs(ira, &fields[3], type_entry->data.enumeration.decls_scope))
16291 return nullptr;
1631616292
1631716293 break;
1631816294 }
......@@ -16467,7 +16443,8 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t
1646716443 }
1646816444 // defs: []TypeInfo.Definition
1646916445 ensure_field_index(result->type, "defs", 3);
16470 ir_make_type_info_defs(ira, &fields[3], type_entry->data.unionation.decls_scope);
16446 if (!ir_make_type_info_defs(ira, &fields[3], type_entry->data.unionation.decls_scope))
16447 return nullptr;
1647116448
1647216449 break;
1647316450 }
......@@ -16478,6 +16455,8 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t
1647816455 buf_init_from_str(&ptr_field_name, "ptr");
1647916456 TypeTableEntry *ptr_type = type_entry->data.structure.fields_by_name.get(&ptr_field_name)->type_entry;
1648016457 ensure_complete_type(ira->codegen, ptr_type);
16458 if (type_is_invalid(ptr_type))
16459 return nullptr;
1648116460 buf_deinit(&ptr_field_name);
1648216461
1648316462 result = create_ptr_like_type_info("Slice", ptr_type);
......@@ -16548,7 +16527,8 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t
1654816527 }
1654916528 // defs: []TypeInfo.Definition
1655016529 ensure_field_index(result->type, "defs", 2);
16551 ir_make_type_info_defs(ira, &fields[2], type_entry->data.structure.decls_scope);
16530 if (!ir_make_type_info_defs(ira, &fields[2], type_entry->data.structure.decls_scope))
16531 return nullptr;
1655216532
1655316533 break;
1655416534 }
......@@ -17339,8 +17319,11 @@ static TypeTableEntry *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructio
1733917319 if (array_type->data.array.len == 0 && byte_alignment == 0) {
1734017320 byte_alignment = get_abi_alignment(ira->codegen, array_type->data.array.child_type);
1734117321 }
17322 bool is_comptime_const = ptr_ptr->value.special == ConstValSpecialStatic &&
17323 ptr_ptr->value.data.x_ptr.mut == ConstPtrMutComptimeConst;
1734217324 TypeTableEntry *slice_ptr_type = get_pointer_to_type_extra(ira->codegen, array_type->data.array.child_type,
17343 ptr_type->data.pointer.is_const, ptr_type->data.pointer.is_volatile,
17325 ptr_type->data.pointer.is_const || is_comptime_const,
17326 ptr_type->data.pointer.is_volatile,
1734417327 byte_alignment, 0, 0);
1734517328 return_type = get_slice_type(ira->codegen, slice_ptr_type);
1734617329 } else if (array_type->id == TypeTableEntryIdPointer) {
......@@ -17527,6 +17510,10 @@ static TypeTableEntry *ir_analyze_instruction_member_count(IrAnalyze *ira, IrIns
1752717510 return ira->codegen->builtin_types.entry_invalid;
1752817511 TypeTableEntry *container_type = ir_resolve_type(ira, container);
1752917512
17513 ensure_complete_type(ira->codegen, container_type);
17514 if (type_is_invalid(container_type))
17515 return ira->codegen->builtin_types.entry_invalid;
17516
1753017517 uint64_t result;
1753117518 if (type_is_invalid(container_type)) {
1753217519 return ira->codegen->builtin_types.entry_invalid;
......@@ -17561,6 +17548,11 @@ static TypeTableEntry *ir_analyze_instruction_member_type(IrAnalyze *ira, IrInst
1756117548 if (type_is_invalid(container_type))
1756217549 return ira->codegen->builtin_types.entry_invalid;
1756317550
17551 ensure_complete_type(ira->codegen, container_type);
17552 if (type_is_invalid(container_type))
17553 return ira->codegen->builtin_types.entry_invalid;
17554
17555
1756417556 uint64_t member_index;
1756517557 IrInstruction *index_value = instruction->member_index->other;
1756617558 if (!ir_resolve_usize(ira, index_value, &member_index))
......@@ -17603,6 +17595,10 @@ static TypeTableEntry *ir_analyze_instruction_member_name(IrAnalyze *ira, IrInst
1760317595 if (type_is_invalid(container_type))
1760417596 return ira->codegen->builtin_types.entry_invalid;
1760517597
17598 ensure_complete_type(ira->codegen, container_type);
17599 if (type_is_invalid(container_type))
17600 return ira->codegen->builtin_types.entry_invalid;
17601
1760617602 uint64_t member_index;
1760717603 IrInstruction *index_value = instruction->member_index->other;
1760817604 if (!ir_resolve_usize(ira, index_value, &member_index))
......@@ -17914,15 +17910,6 @@ static TypeTableEntry *ir_analyze_instruction_unwrap_err_payload(IrAnalyze *ira,
1791417910 return ira->codegen->builtin_types.entry_invalid;
1791517911 TypeTableEntry *ptr_type = value->value.type;
1791617912
17917 // Because we don't have Pointer Reform yet, we can't have a pointer to a 'type'.
17918 // Therefor, we have to check for type 'type' here, so we can output a correct error
17919 // without asserting the assert below.
17920 if (ptr_type->id == TypeTableEntryIdMetaType) {
17921 ir_add_error(ira, value,
17922 buf_sprintf("expected error union type, found '%s'", buf_ptr(&ptr_type->name)));
17923 return ira->codegen->builtin_types.entry_invalid;
17924 }
17925
1792617913 // This will be a pointer type because unwrap err payload IR instruction operates on a pointer to a thing.
1792717914 assert(ptr_type->id == TypeTableEntryIdPointer);
1792817915
......@@ -18553,7 +18540,12 @@ static TypeTableEntry *ir_analyze_instruction_bit_cast(IrAnalyze *ira, IrInstruc
1855318540 return ira->codegen->builtin_types.entry_invalid;
1855418541
1855518542 ensure_complete_type(ira->codegen, dest_type);
18543 if (type_is_invalid(dest_type))
18544 return ira->codegen->builtin_types.entry_invalid;
18545
1855618546 ensure_complete_type(ira->codegen, src_type);
18547 if (type_is_invalid(src_type))
18548 return ira->codegen->builtin_types.entry_invalid;
1855718549
1855818550 if (get_codegen_ptr_type(src_type) != nullptr) {
1855918551 ir_add_error(ira, value,
......@@ -18699,8 +18691,7 @@ static TypeTableEntry *ir_analyze_instruction_decl_ref(IrAnalyze *ira,
1869918691 TldVar *tld_var = (TldVar *)tld;
1870018692 VariableTableEntry *var = tld_var->var;
1870118693
18702 IrInstruction *var_ptr = ir_get_var_ptr(ira, &instruction->base, var,
18703 !lval.is_ptr || lval.is_const, lval.is_ptr && lval.is_volatile);
18694 IrInstruction *var_ptr = ir_get_var_ptr(ira, &instruction->base, var);
1870418695 if (type_is_invalid(var_ptr->value.type))
1870518696 return ira->codegen->builtin_types.entry_invalid;
1870618697
......@@ -18778,16 +18769,24 @@ static TypeTableEntry *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstr
1877818769 return usize;
1877918770}
1878018771
18781static TypeTableEntry *ir_analyze_instruction_ptr_type_of(IrAnalyze *ira, IrInstructionPtrTypeOf *instruction) {
18772static TypeTableEntry *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstructionPtrType *instruction) {
1878218773 TypeTableEntry *child_type = ir_resolve_type(ira, instruction->child_type->other);
1878318774 if (type_is_invalid(child_type))
1878418775 return ira->codegen->builtin_types.entry_invalid;
1878518776
18777 if (child_type->id == TypeTableEntryIdUnreachable) {
18778 ir_add_error(ira, &instruction->base, buf_sprintf("pointer to noreturn not allowed"));
18779 return ira->codegen->builtin_types.entry_invalid;
18780 }
18781
1878618782 uint32_t align_bytes;
1878718783 if (instruction->align_value != nullptr) {
1878818784 if (!ir_resolve_align(ira, instruction->align_value->other, &align_bytes))
1878918785 return ira->codegen->builtin_types.entry_invalid;
1879018786 } else {
18787 type_ensure_zero_bits_known(ira->codegen, child_type);
18788 if (type_is_invalid(child_type))
18789 return ira->codegen->builtin_types.entry_invalid;
1879118790 align_bytes = get_abi_alignment(ira->codegen, child_type);
1879218791 }
1879318792
......@@ -19606,8 +19605,8 @@ static TypeTableEntry *ir_analyze_instruction_nocast(IrAnalyze *ira, IrInstructi
1960619605 return ir_analyze_instruction_type_id(ira, (IrInstructionTypeId *)instruction);
1960719606 case IrInstructionIdSetEvalBranchQuota:
1960819607 return ir_analyze_instruction_set_eval_branch_quota(ira, (IrInstructionSetEvalBranchQuota *)instruction);
19609 case IrInstructionIdPtrTypeOf:
19610 return ir_analyze_instruction_ptr_type_of(ira, (IrInstructionPtrTypeOf *)instruction);
19608 case IrInstructionIdPtrType:
19609 return ir_analyze_instruction_ptr_type(ira, (IrInstructionPtrType *)instruction);
1961119610 case IrInstructionIdAlignCast:
1961219611 return ir_analyze_instruction_align_cast(ira, (IrInstructionAlignCast *)instruction);
1961319612 case IrInstructionIdOpaqueType:
......@@ -19783,7 +19782,7 @@ bool ir_has_side_effects(IrInstruction *instruction) {
1978319782 case IrInstructionIdCheckStatementIsVoid:
1978419783 case IrInstructionIdPanic:
1978519784 case IrInstructionIdSetEvalBranchQuota:
19786 case IrInstructionIdPtrTypeOf:
19785 case IrInstructionIdPtrType:
1978719786 case IrInstructionIdSetAlignStack:
1978819787 case IrInstructionIdExport:
1978919788 case IrInstructionIdCancel:
src/ir_print.cpp+3-3
......@@ -921,7 +921,7 @@ static void ir_print_can_implicit_cast(IrPrint *irp, IrInstructionCanImplicitCas
921921 fprintf(irp->f, ")");
922922}
923923
924static void ir_print_ptr_type_of(IrPrint *irp, IrInstructionPtrTypeOf *instruction) {
924static void ir_print_ptr_type(IrPrint *irp, IrInstructionPtrType *instruction) {
925925 fprintf(irp->f, "&");
926926 if (instruction->align_value != nullptr) {
927927 fprintf(irp->f, "align(");
......@@ -1527,8 +1527,8 @@ static void ir_print_instruction(IrPrint *irp, IrInstruction *instruction) {
15271527 case IrInstructionIdCanImplicitCast:
15281528 ir_print_can_implicit_cast(irp, (IrInstructionCanImplicitCast *)instruction);
15291529 break;
1530 case IrInstructionIdPtrTypeOf:
1531 ir_print_ptr_type_of(irp, (IrInstructionPtrTypeOf *)instruction);
1530 case IrInstructionIdPtrType:
1531 ir_print_ptr_type(irp, (IrInstructionPtrType *)instruction);
15321532 break;
15331533 case IrInstructionIdDeclRef:
15341534 ir_print_decl_ref(irp, (IrInstructionDeclRef *)instruction);
src/parser.cpp+24-17
......@@ -1167,20 +1167,19 @@ static PrefixOp tok_to_prefix_op(Token *token) {
11671167 case TokenIdTilde: return PrefixOpBinNot;
11681168 case TokenIdMaybe: return PrefixOpMaybe;
11691169 case TokenIdDoubleQuestion: return PrefixOpUnwrapMaybe;
1170 case TokenIdAmpersand: return PrefixOpAddrOf;
11701171 default: return PrefixOpInvalid;
11711172 }
11721173}
11731174
1174static AstNode *ast_parse_addr_of(ParseContext *pc, size_t *token_index) {
1175 Token *ampersand_tok = ast_eat_token(pc, token_index, TokenIdAmpersand);
1176
1177 AstNode *node = ast_create_node(pc, NodeTypeAddrOfExpr, ampersand_tok);
1175static AstNode *ast_parse_pointer_type(ParseContext *pc, size_t *token_index, Token *star_tok) {
1176 AstNode *node = ast_create_node(pc, NodeTypePointerType, star_tok);
11781177
11791178 Token *token = &pc->tokens->at(*token_index);
11801179 if (token->id == TokenIdKeywordAlign) {
11811180 *token_index += 1;
11821181 ast_eat_token(pc, token_index, TokenIdLParen);
1183 node->data.addr_of_expr.align_expr = ast_parse_expression(pc, token_index, true);
1182 node->data.pointer_type.align_expr = ast_parse_expression(pc, token_index, true);
11841183
11851184 token = &pc->tokens->at(*token_index);
11861185 if (token->id == TokenIdColon) {
......@@ -1189,24 +1188,24 @@ static AstNode *ast_parse_addr_of(ParseContext *pc, size_t *token_index) {
11891188 ast_eat_token(pc, token_index, TokenIdColon);
11901189 Token *bit_offset_end_tok = ast_eat_token(pc, token_index, TokenIdIntLiteral);
11911190
1192 node->data.addr_of_expr.bit_offset_start = token_bigint(bit_offset_start_tok);
1193 node->data.addr_of_expr.bit_offset_end = token_bigint(bit_offset_end_tok);
1191 node->data.pointer_type.bit_offset_start = token_bigint(bit_offset_start_tok);
1192 node->data.pointer_type.bit_offset_end = token_bigint(bit_offset_end_tok);
11941193 }
11951194 ast_eat_token(pc, token_index, TokenIdRParen);
11961195 token = &pc->tokens->at(*token_index);
11971196 }
11981197 if (token->id == TokenIdKeywordConst) {
11991198 *token_index += 1;
1200 node->data.addr_of_expr.is_const = true;
1199 node->data.pointer_type.is_const = true;
12011200
12021201 token = &pc->tokens->at(*token_index);
12031202 }
12041203 if (token->id == TokenIdKeywordVolatile) {
12051204 *token_index += 1;
1206 node->data.addr_of_expr.is_volatile = true;
1205 node->data.pointer_type.is_volatile = true;
12071206 }
12081207
1209 node->data.addr_of_expr.op_expr = ast_parse_prefix_op_expr(pc, token_index, true);
1208 node->data.pointer_type.op_expr = ast_parse_prefix_op_expr(pc, token_index, true);
12101209 return node;
12111210}
12121211
......@@ -1216,8 +1215,17 @@ PrefixOp = "!" | "-" | "~" | ("*" option("align" "(" Expression option(":" Integ
12161215*/
12171216static AstNode *ast_parse_prefix_op_expr(ParseContext *pc, size_t *token_index, bool mandatory) {
12181217 Token *token = &pc->tokens->at(*token_index);
1219 if (token->id == TokenIdAmpersand) {
1220 return ast_parse_addr_of(pc, token_index);
1218 if (token->id == TokenIdStar) {
1219 *token_index += 1;
1220 return ast_parse_pointer_type(pc, token_index, token);
1221 }
1222 if (token->id == TokenIdStarStar) {
1223 *token_index += 1;
1224 AstNode *child_node = ast_parse_pointer_type(pc, token_index, token);
1225 child_node->column += 1;
1226 AstNode *parent_node = ast_create_node(pc, NodeTypePointerType, token);
1227 parent_node->data.pointer_type.op_expr = child_node;
1228 return parent_node;
12211229 }
12221230 if (token->id == TokenIdKeywordTry) {
12231231 return ast_parse_try_expr(pc, token_index);
......@@ -1234,13 +1242,12 @@ static AstNode *ast_parse_prefix_op_expr(ParseContext *pc, size_t *token_index,
12341242
12351243
12361244 AstNode *node = ast_create_node(pc, NodeTypePrefixOpExpr, token);
1237 AstNode *parent_node = node;
12381245
12391246 AstNode *prefix_op_expr = ast_parse_error_set_expr(pc, token_index, true);
12401247 node->data.prefix_op_expr.primary_expr = prefix_op_expr;
12411248 node->data.prefix_op_expr.prefix_op = prefix_op;
12421249
1243 return parent_node;
1250 return node;
12441251}
12451252
12461253
......@@ -3121,9 +3128,9 @@ void ast_visit_node_children(AstNode *node, void (*visit)(AstNode **, void *cont
31213128 case NodeTypeErrorType:
31223129 // none
31233130 break;
3124 case NodeTypeAddrOfExpr:
3125 visit_field(&node->data.addr_of_expr.align_expr, visit, context);
3126 visit_field(&node->data.addr_of_expr.op_expr, visit, context);
3131 case NodeTypePointerType:
3132 visit_field(&node->data.pointer_type.align_expr, visit, context);
3133 visit_field(&node->data.pointer_type.op_expr, visit, context);
31273134 break;
31283135 case NodeTypeErrorSetDecl:
31293136 visit_node_list(&node->data.err_set_decl.decls, visit, context);
src/translate_c.cpp+20-13
......@@ -276,11 +276,18 @@ static AstNode *maybe_suppress_result(Context *c, ResultUsed result_used, AstNod
276276 node);
277277}
278278
279static AstNode *trans_create_node_addr_of(Context *c, bool is_const, bool is_volatile, AstNode *child_node) {
280 AstNode *node = trans_create_node(c, NodeTypeAddrOfExpr);
281 node->data.addr_of_expr.is_const = is_const;
282 node->data.addr_of_expr.is_volatile = is_volatile;
283 node->data.addr_of_expr.op_expr = child_node;
279static AstNode *trans_create_node_ptr_type(Context *c, bool is_const, bool is_volatile, AstNode *child_node) {
280 AstNode *node = trans_create_node(c, NodeTypePointerType);
281 node->data.pointer_type.is_const = is_const;
282 node->data.pointer_type.is_volatile = is_volatile;
283 node->data.pointer_type.op_expr = child_node;
284 return node;
285}
286
287static AstNode *trans_create_node_addr_of(Context *c, AstNode *child_node) {
288 AstNode *node = trans_create_node(c, NodeTypePrefixOpExpr);
289 node->data.prefix_op_expr.prefix_op = PrefixOpAddrOf;
290 node->data.prefix_op_expr.primary_expr = child_node;
284291 return node;
285292}
286293
......@@ -848,7 +855,7 @@ static AstNode *trans_type(Context *c, const Type *ty, const SourceLocation &sou
848855 return trans_create_node_prefix_op(c, PrefixOpMaybe, child_node);
849856 }
850857
851 AstNode *pointer_node = trans_create_node_addr_of(c, child_qt.isConstQualified(),
858 AstNode *pointer_node = trans_create_node_ptr_type(c, child_qt.isConstQualified(),
852859 child_qt.isVolatileQualified(), child_node);
853860 return trans_create_node_prefix_op(c, PrefixOpMaybe, pointer_node);
854861 }
......@@ -1033,7 +1040,7 @@ static AstNode *trans_type(Context *c, const Type *ty, const SourceLocation &sou
10331040 emit_warning(c, source_loc, "unresolved array element type");
10341041 return nullptr;
10351042 }
1036 AstNode *pointer_node = trans_create_node_addr_of(c, child_qt.isConstQualified(),
1043 AstNode *pointer_node = trans_create_node_ptr_type(c, child_qt.isConstQualified(),
10371044 child_qt.isVolatileQualified(), child_type_node);
10381045 return pointer_node;
10391046 }
......@@ -1402,7 +1409,7 @@ static AstNode *trans_create_compound_assign_shift(Context *c, ResultUsed result
14021409 // const _ref = &lhs;
14031410 AstNode *lhs = trans_expr(c, ResultUsedYes, &child_scope->base, stmt->getLHS(), TransLValue);
14041411 if (lhs == nullptr) return nullptr;
1405 AstNode *addr_of_lhs = trans_create_node_addr_of(c, false, false, lhs);
1412 AstNode *addr_of_lhs = trans_create_node_addr_of(c, lhs);
14061413 // TODO: avoid name collisions with generated variable names
14071414 Buf* tmp_var_name = buf_create_from_str("_ref");
14081415 AstNode *tmp_var_decl = trans_create_node_var_decl_local(c, true, tmp_var_name, nullptr, addr_of_lhs);
......@@ -1476,7 +1483,7 @@ static AstNode *trans_create_compound_assign(Context *c, ResultUsed result_used,
14761483 // const _ref = &lhs;
14771484 AstNode *lhs = trans_expr(c, ResultUsedYes, &child_scope->base, stmt->getLHS(), TransLValue);
14781485 if (lhs == nullptr) return nullptr;
1479 AstNode *addr_of_lhs = trans_create_node_addr_of(c, false, false, lhs);
1486 AstNode *addr_of_lhs = trans_create_node_addr_of(c, lhs);
14801487 // TODO: avoid name collisions with generated variable names
14811488 Buf* tmp_var_name = buf_create_from_str("_ref");
14821489 AstNode *tmp_var_decl = trans_create_node_var_decl_local(c, true, tmp_var_name, nullptr, addr_of_lhs);
......@@ -1813,7 +1820,7 @@ static AstNode *trans_create_post_crement(Context *c, ResultUsed result_used, Tr
18131820 // const _ref = &expr;
18141821 AstNode *expr = trans_expr(c, ResultUsedYes, &child_scope->base, op_expr, TransLValue);
18151822 if (expr == nullptr) return nullptr;
1816 AstNode *addr_of_expr = trans_create_node_addr_of(c, false, false, expr);
1823 AstNode *addr_of_expr = trans_create_node_addr_of(c, expr);
18171824 // TODO: avoid name collisions with generated variable names
18181825 Buf* ref_var_name = buf_create_from_str("_ref");
18191826 AstNode *ref_var_decl = trans_create_node_var_decl_local(c, true, ref_var_name, nullptr, addr_of_expr);
......@@ -1868,7 +1875,7 @@ static AstNode *trans_create_pre_crement(Context *c, ResultUsed result_used, Tra
18681875 // const _ref = &expr;
18691876 AstNode *expr = trans_expr(c, ResultUsedYes, &child_scope->base, op_expr, TransLValue);
18701877 if (expr == nullptr) return nullptr;
1871 AstNode *addr_of_expr = trans_create_node_addr_of(c, false, false, expr);
1878 AstNode *addr_of_expr = trans_create_node_addr_of(c, expr);
18721879 // TODO: avoid name collisions with generated variable names
18731880 Buf* ref_var_name = buf_create_from_str("_ref");
18741881 AstNode *ref_var_decl = trans_create_node_var_decl_local(c, true, ref_var_name, nullptr, addr_of_expr);
......@@ -1917,7 +1924,7 @@ static AstNode *trans_unary_operator(Context *c, ResultUsed result_used, TransSc
19171924 AstNode *value_node = trans_expr(c, result_used, scope, stmt->getSubExpr(), TransLValue);
19181925 if (value_node == nullptr)
19191926 return value_node;
1920 return trans_create_node_addr_of(c, false, false, value_node);
1927 return trans_create_node_addr_of(c, value_node);
19211928 }
19221929 case UO_Deref:
19231930 {
......@@ -4441,7 +4448,7 @@ static AstNode *parse_ctok_suffix_op_expr(Context *c, CTokenize *ctok, size_t *t
44414448 } else if (first_tok->id == CTokIdAsterisk) {
44424449 *tok_i += 1;
44434450
4444 node = trans_create_node_addr_of(c, false, false, node);
4451 node = trans_create_node_ptr_type(c, false, false, node);
44454452 } else {
44464453 return node;
44474454 }
std/array_list.zig+23-23
......@@ -17,10 +17,10 @@ pub fn AlignedArrayList(comptime T: type, comptime A: u29) type {
1717 /// you uninitialized memory.
1818 items: []align(A) T,
1919 len: usize,
20 allocator: &Allocator,
20 allocator: *Allocator,
2121
2222 /// Deinitialize with `deinit` or use `toOwnedSlice`.
23 pub fn init(allocator: &Allocator) Self {
23 pub fn init(allocator: *Allocator) Self {
2424 return Self{
2525 .items = []align(A) T{},
2626 .len = 0,
......@@ -28,30 +28,30 @@ pub fn AlignedArrayList(comptime T: type, comptime A: u29) type {
2828 };
2929 }
3030
31 pub fn deinit(l: &const Self) void {
31 pub fn deinit(l: *const Self) void {
3232 l.allocator.free(l.items);
3333 }
3434
35 pub fn toSlice(l: &const Self) []align(A) T {
35 pub fn toSlice(l: *const Self) []align(A) T {
3636 return l.items[0..l.len];
3737 }
3838
39 pub fn toSliceConst(l: &const Self) []align(A) const T {
39 pub fn toSliceConst(l: *const Self) []align(A) const T {
4040 return l.items[0..l.len];
4141 }
4242
43 pub fn at(l: &const Self, n: usize) T {
43 pub fn at(l: *const Self, n: usize) T {
4444 return l.toSliceConst()[n];
4545 }
4646
47 pub fn count(self: &const Self) usize {
47 pub fn count(self: *const Self) usize {
4848 return self.len;
4949 }
5050
5151 /// ArrayList takes ownership of the passed in slice. The slice must have been
5252 /// allocated with `allocator`.
5353 /// Deinitialize with `deinit` or use `toOwnedSlice`.
54 pub fn fromOwnedSlice(allocator: &Allocator, slice: []align(A) T) Self {
54 pub fn fromOwnedSlice(allocator: *Allocator, slice: []align(A) T) Self {
5555 return Self{
5656 .items = slice,
5757 .len = slice.len,
......@@ -60,14 +60,14 @@ pub fn AlignedArrayList(comptime T: type, comptime A: u29) type {
6060 }
6161
6262 /// The caller owns the returned memory. ArrayList becomes empty.
63 pub fn toOwnedSlice(self: &Self) []align(A) T {
63 pub fn toOwnedSlice(self: *Self) []align(A) T {
6464 const allocator = self.allocator;
6565 const result = allocator.alignedShrink(T, A, self.items, self.len);
6666 self.* = init(allocator);
6767 return result;
6868 }
6969
70 pub fn insert(l: &Self, n: usize, item: &const T) !void {
70 pub fn insert(l: *Self, n: usize, item: *const T) !void {
7171 try l.ensureCapacity(l.len + 1);
7272 l.len += 1;
7373
......@@ -75,7 +75,7 @@ pub fn AlignedArrayList(comptime T: type, comptime A: u29) type {
7575 l.items[n] = item.*;
7676 }
7777
78 pub fn insertSlice(l: &Self, n: usize, items: []align(A) const T) !void {
78 pub fn insertSlice(l: *Self, n: usize, items: []align(A) const T) !void {
7979 try l.ensureCapacity(l.len + items.len);
8080 l.len += items.len;
8181
......@@ -83,28 +83,28 @@ pub fn AlignedArrayList(comptime T: type, comptime A: u29) type {
8383 mem.copy(T, l.items[n .. n + items.len], items);
8484 }
8585
86 pub fn append(l: &Self, item: &const T) !void {
86 pub fn append(l: *Self, item: *const T) !void {
8787 const new_item_ptr = try l.addOne();
8888 new_item_ptr.* = item.*;
8989 }
9090
91 pub fn appendSlice(l: &Self, items: []align(A) const T) !void {
91 pub fn appendSlice(l: *Self, items: []align(A) const T) !void {
9292 try l.ensureCapacity(l.len + items.len);
9393 mem.copy(T, l.items[l.len..], items);
9494 l.len += items.len;
9595 }
9696
97 pub fn resize(l: &Self, new_len: usize) !void {
97 pub fn resize(l: *Self, new_len: usize) !void {
9898 try l.ensureCapacity(new_len);
9999 l.len = new_len;
100100 }
101101
102 pub fn shrink(l: &Self, new_len: usize) void {
102 pub fn shrink(l: *Self, new_len: usize) void {
103103 assert(new_len <= l.len);
104104 l.len = new_len;
105105 }
106106
107 pub fn ensureCapacity(l: &Self, new_capacity: usize) !void {
107 pub fn ensureCapacity(l: *Self, new_capacity: usize) !void {
108108 var better_capacity = l.items.len;
109109 if (better_capacity >= new_capacity) return;
110110 while (true) {
......@@ -114,7 +114,7 @@ pub fn AlignedArrayList(comptime T: type, comptime A: u29) type {
114114 l.items = try l.allocator.alignedRealloc(T, A, l.items, better_capacity);
115115 }
116116
117 pub fn addOne(l: &Self) !&T {
117 pub fn addOne(l: *Self) !*T {
118118 const new_length = l.len + 1;
119119 try l.ensureCapacity(new_length);
120120 const result = &l.items[l.len];
......@@ -122,34 +122,34 @@ pub fn AlignedArrayList(comptime T: type, comptime A: u29) type {
122122 return result;
123123 }
124124
125 pub fn pop(self: &Self) T {
125 pub fn pop(self: *Self) T {
126126 self.len -= 1;
127127 return self.items[self.len];
128128 }
129129
130 pub fn popOrNull(self: &Self) ?T {
130 pub fn popOrNull(self: *Self) ?T {
131131 if (self.len == 0) return null;
132132 return self.pop();
133133 }
134134
135135 pub const Iterator = struct {
136 list: &const Self,
136 list: *const Self,
137137 // how many items have we returned
138138 count: usize,
139139
140 pub fn next(it: &Iterator) ?T {
140 pub fn next(it: *Iterator) ?T {
141141 if (it.count >= it.list.len) return null;
142142 const val = it.list.at(it.count);
143143 it.count += 1;
144144 return val;
145145 }
146146
147 pub fn reset(it: &Iterator) void {
147 pub fn reset(it: *Iterator) void {
148148 it.count = 0;
149149 }
150150 };
151151
152 pub fn iterator(self: &const Self) Iterator {
152 pub fn iterator(self: *const Self) Iterator {
153153 return Iterator{
154154 .list = self,
155155 .count = 0,
std/atomic/queue.zig+16-16
......@@ -5,36 +5,36 @@ const AtomicRmwOp = builtin.AtomicRmwOp;
55/// Many reader, many writer, non-allocating, thread-safe, lock-free
66pub fn Queue(comptime T: type) type {
77 return struct {
8 head: &Node,
9 tail: &Node,
8 head: *Node,
9 tail: *Node,
1010 root: Node,
1111
1212 pub const Self = this;
1313
1414 pub const Node = struct {
15 next: ?&Node,
15 next: ?*Node,
1616 data: T,
1717 };
1818
1919 // TODO: well defined copy elision: https://github.com/ziglang/zig/issues/287
20 pub fn init(self: &Self) void {
20 pub fn init(self: *Self) void {
2121 self.root.next = null;
2222 self.head = &self.root;
2323 self.tail = &self.root;
2424 }
2525
26 pub fn put(self: &Self, node: &Node) void {
26 pub fn put(self: *Self, node: *Node) void {
2727 node.next = null;
2828
29 const tail = @atomicRmw(&Node, &self.tail, AtomicRmwOp.Xchg, node, AtomicOrder.SeqCst);
30 _ = @atomicRmw(?&Node, &tail.next, AtomicRmwOp.Xchg, node, AtomicOrder.SeqCst);
29 const tail = @atomicRmw(*Node, &self.tail, AtomicRmwOp.Xchg, node, AtomicOrder.SeqCst);
30 _ = @atomicRmw(?*Node, &tail.next, AtomicRmwOp.Xchg, node, AtomicOrder.SeqCst);
3131 }
3232
33 pub fn get(self: &Self) ?&Node {
34 var head = @atomicLoad(&Node, &self.head, AtomicOrder.SeqCst);
33 pub fn get(self: *Self) ?*Node {
34 var head = @atomicLoad(*Node, &self.head, AtomicOrder.SeqCst);
3535 while (true) {
3636 const node = head.next ?? return null;
37 head = @cmpxchgWeak(&Node, &self.head, head, node, AtomicOrder.SeqCst, AtomicOrder.SeqCst) ?? return node;
37 head = @cmpxchgWeak(*Node, &self.head, head, node, AtomicOrder.SeqCst, AtomicOrder.SeqCst) ?? return node;
3838 }
3939 }
4040 };
......@@ -42,8 +42,8 @@ pub fn Queue(comptime T: type) type {
4242
4343const std = @import("std");
4444const Context = struct {
45 allocator: &std.mem.Allocator,
46 queue: &Queue(i32),
45 allocator: *std.mem.Allocator,
46 queue: *Queue(i32),
4747 put_sum: isize,
4848 get_sum: isize,
4949 get_count: usize,
......@@ -79,11 +79,11 @@ test "std.atomic.queue" {
7979 .get_count = 0,
8080 };
8181
82 var putters: [put_thread_count]&std.os.Thread = undefined;
82 var putters: [put_thread_count]*std.os.Thread = undefined;
8383 for (putters) |*t| {
8484 t.* = try std.os.spawnThread(&context, startPuts);
8585 }
86 var getters: [put_thread_count]&std.os.Thread = undefined;
86 var getters: [put_thread_count]*std.os.Thread = undefined;
8787 for (getters) |*t| {
8888 t.* = try std.os.spawnThread(&context, startGets);
8989 }
......@@ -98,7 +98,7 @@ test "std.atomic.queue" {
9898 std.debug.assert(context.get_count == puts_per_thread * put_thread_count);
9999}
100100
101fn startPuts(ctx: &Context) u8 {
101fn startPuts(ctx: *Context) u8 {
102102 var put_count: usize = puts_per_thread;
103103 var r = std.rand.DefaultPrng.init(0xdeadbeef);
104104 while (put_count != 0) : (put_count -= 1) {
......@@ -112,7 +112,7 @@ fn startPuts(ctx: &Context) u8 {
112112 return 0;
113113}
114114
115fn startGets(ctx: &Context) u8 {
115fn startGets(ctx: *Context) u8 {
116116 while (true) {
117117 while (ctx.queue.get()) |node| {
118118 std.os.time.sleep(0, 1); // let the os scheduler be our fuzz
std/atomic/stack.zig+18-18
......@@ -4,12 +4,12 @@ const AtomicOrder = builtin.AtomicOrder;
44/// Many reader, many writer, non-allocating, thread-safe, lock-free
55pub fn Stack(comptime T: type) type {
66 return struct {
7 root: ?&Node,
7 root: ?*Node,
88
99 pub const Self = this;
1010
1111 pub const Node = struct {
12 next: ?&Node,
12 next: ?*Node,
1313 data: T,
1414 };
1515
......@@ -19,36 +19,36 @@ pub fn Stack(comptime T: type) type {
1919
2020 /// push operation, but only if you are the first item in the stack. if you did not succeed in
2121 /// being the first item in the stack, returns the other item that was there.
22 pub fn pushFirst(self: &Self, node: &Node) ?&Node {
22 pub fn pushFirst(self: *Self, node: *Node) ?*Node {
2323 node.next = null;
24 return @cmpxchgStrong(?&Node, &self.root, null, node, AtomicOrder.SeqCst, AtomicOrder.SeqCst);
24 return @cmpxchgStrong(?*Node, &self.root, null, node, AtomicOrder.SeqCst, AtomicOrder.SeqCst);
2525 }
2626
27 pub fn push(self: &Self, node: &Node) void {
28 var root = @atomicLoad(?&Node, &self.root, AtomicOrder.SeqCst);
27 pub fn push(self: *Self, node: *Node) void {
28 var root = @atomicLoad(?*Node, &self.root, AtomicOrder.SeqCst);
2929 while (true) {
3030 node.next = root;
31 root = @cmpxchgWeak(?&Node, &self.root, root, node, AtomicOrder.SeqCst, AtomicOrder.SeqCst) ?? break;
31 root = @cmpxchgWeak(?*Node, &self.root, root, node, AtomicOrder.SeqCst, AtomicOrder.SeqCst) ?? break;
3232 }
3333 }
3434
35 pub fn pop(self: &Self) ?&Node {
36 var root = @atomicLoad(?&Node, &self.root, AtomicOrder.SeqCst);
35 pub fn pop(self: *Self) ?*Node {
36 var root = @atomicLoad(?*Node, &self.root, AtomicOrder.SeqCst);
3737 while (true) {
38 root = @cmpxchgWeak(?&Node, &self.root, root, (root ?? return null).next, AtomicOrder.SeqCst, AtomicOrder.SeqCst) ?? return root;
38 root = @cmpxchgWeak(?*Node, &self.root, root, (root ?? return null).next, AtomicOrder.SeqCst, AtomicOrder.SeqCst) ?? return root;
3939 }
4040 }
4141
42 pub fn isEmpty(self: &Self) bool {
43 return @atomicLoad(?&Node, &self.root, AtomicOrder.SeqCst) == null;
42 pub fn isEmpty(self: *Self) bool {
43 return @atomicLoad(?*Node, &self.root, AtomicOrder.SeqCst) == null;
4444 }
4545 };
4646}
4747
4848const std = @import("std");
4949const Context = struct {
50 allocator: &std.mem.Allocator,
51 stack: &Stack(i32),
50 allocator: *std.mem.Allocator,
51 stack: *Stack(i32),
5252 put_sum: isize,
5353 get_sum: isize,
5454 get_count: usize,
......@@ -82,11 +82,11 @@ test "std.atomic.stack" {
8282 .get_count = 0,
8383 };
8484
85 var putters: [put_thread_count]&std.os.Thread = undefined;
85 var putters: [put_thread_count]*std.os.Thread = undefined;
8686 for (putters) |*t| {
8787 t.* = try std.os.spawnThread(&context, startPuts);
8888 }
89 var getters: [put_thread_count]&std.os.Thread = undefined;
89 var getters: [put_thread_count]*std.os.Thread = undefined;
9090 for (getters) |*t| {
9191 t.* = try std.os.spawnThread(&context, startGets);
9292 }
......@@ -101,7 +101,7 @@ test "std.atomic.stack" {
101101 std.debug.assert(context.get_count == puts_per_thread * put_thread_count);
102102}
103103
104fn startPuts(ctx: &Context) u8 {
104fn startPuts(ctx: *Context) u8 {
105105 var put_count: usize = puts_per_thread;
106106 var r = std.rand.DefaultPrng.init(0xdeadbeef);
107107 while (put_count != 0) : (put_count -= 1) {
......@@ -115,7 +115,7 @@ fn startPuts(ctx: &Context) u8 {
115115 return 0;
116116}
117117
118fn startGets(ctx: &Context) u8 {
118fn startGets(ctx: *Context) u8 {
119119 while (true) {
120120 while (ctx.stack.pop()) |node| {
121121 std.os.time.sleep(0, 1); // let the os scheduler be our fuzz
std/base64.zig+6-6
......@@ -32,7 +32,7 @@ pub const Base64Encoder = struct {
3232 }
3333
3434 /// dest.len must be what you get from ::calcSize.
35 pub fn encode(encoder: &const Base64Encoder, dest: []u8, source: []const u8) void {
35 pub fn encode(encoder: *const Base64Encoder, dest: []u8, source: []const u8) void {
3636 assert(dest.len == Base64Encoder.calcSize(source.len));
3737
3838 var i: usize = 0;
......@@ -107,7 +107,7 @@ pub const Base64Decoder = struct {
107107 }
108108
109109 /// If the encoded buffer is detected to be invalid, returns error.InvalidPadding.
110 pub fn calcSize(decoder: &const Base64Decoder, source: []const u8) !usize {
110 pub fn calcSize(decoder: *const Base64Decoder, source: []const u8) !usize {
111111 if (source.len % 4 != 0) return error.InvalidPadding;
112112 return calcDecodedSizeExactUnsafe(source, decoder.pad_char);
113113 }
......@@ -115,7 +115,7 @@ pub const Base64Decoder = struct {
115115 /// dest.len must be what you get from ::calcSize.
116116 /// invalid characters result in error.InvalidCharacter.
117117 /// invalid padding results in error.InvalidPadding.
118 pub fn decode(decoder: &const Base64Decoder, dest: []u8, source: []const u8) !void {
118 pub fn decode(decoder: *const Base64Decoder, dest: []u8, source: []const u8) !void {
119119 assert(dest.len == (decoder.calcSize(source) catch unreachable));
120120 assert(source.len % 4 == 0);
121121
......@@ -181,7 +181,7 @@ pub const Base64DecoderWithIgnore = struct {
181181 /// Invalid padding results in error.InvalidPadding.
182182 /// Decoding more data than can fit in dest results in error.OutputTooSmall. See also ::calcSizeUpperBound.
183183 /// Returns the number of bytes writen to dest.
184 pub fn decode(decoder_with_ignore: &const Base64DecoderWithIgnore, dest: []u8, source: []const u8) !usize {
184 pub fn decode(decoder_with_ignore: *const Base64DecoderWithIgnore, dest: []u8, source: []const u8) !usize {
185185 const decoder = &decoder_with_ignore.decoder;
186186
187187 var src_cursor: usize = 0;
......@@ -290,13 +290,13 @@ pub const Base64DecoderUnsafe = struct {
290290 }
291291
292292 /// The source buffer must be valid.
293 pub fn calcSize(decoder: &const Base64DecoderUnsafe, source: []const u8) usize {
293 pub fn calcSize(decoder: *const Base64DecoderUnsafe, source: []const u8) usize {
294294 return calcDecodedSizeExactUnsafe(source, decoder.pad_char);
295295 }
296296
297297 /// dest.len must be what you get from ::calcDecodedSizeExactUnsafe.
298298 /// invalid characters or padding will result in undefined values.
299 pub fn decode(decoder: &const Base64DecoderUnsafe, dest: []u8, source: []const u8) void {
299 pub fn decode(decoder: *const Base64DecoderUnsafe, dest: []u8, source: []const u8) void {
300300 assert(dest.len == decoder.calcSize(source));
301301
302302 var src_index: usize = 0;
std/buf_map.zig+9-9
......@@ -11,12 +11,12 @@ pub const BufMap = struct {
1111
1212 const BufMapHashMap = HashMap([]const u8, []const u8, mem.hash_slice_u8, mem.eql_slice_u8);
1313
14 pub fn init(allocator: &Allocator) BufMap {
14 pub fn init(allocator: *Allocator) BufMap {
1515 var self = BufMap{ .hash_map = BufMapHashMap.init(allocator) };
1616 return self;
1717 }
1818
19 pub fn deinit(self: &const BufMap) void {
19 pub fn deinit(self: *const BufMap) void {
2020 var it = self.hash_map.iterator();
2121 while (true) {
2222 const entry = it.next() ?? break;
......@@ -27,7 +27,7 @@ pub const BufMap = struct {
2727 self.hash_map.deinit();
2828 }
2929
30 pub fn set(self: &BufMap, key: []const u8, value: []const u8) !void {
30 pub fn set(self: *BufMap, key: []const u8, value: []const u8) !void {
3131 self.delete(key);
3232 const key_copy = try self.copy(key);
3333 errdefer self.free(key_copy);
......@@ -36,30 +36,30 @@ pub const BufMap = struct {
3636 _ = try self.hash_map.put(key_copy, value_copy);
3737 }
3838
39 pub fn get(self: &const BufMap, key: []const u8) ?[]const u8 {
39 pub fn get(self: *const BufMap, key: []const u8) ?[]const u8 {
4040 const entry = self.hash_map.get(key) ?? return null;
4141 return entry.value;
4242 }
4343
44 pub fn delete(self: &BufMap, key: []const u8) void {
44 pub fn delete(self: *BufMap, key: []const u8) void {
4545 const entry = self.hash_map.remove(key) ?? return;
4646 self.free(entry.key);
4747 self.free(entry.value);
4848 }
4949
50 pub fn count(self: &const BufMap) usize {
50 pub fn count(self: *const BufMap) usize {
5151 return self.hash_map.count();
5252 }
5353
54 pub fn iterator(self: &const BufMap) BufMapHashMap.Iterator {
54 pub fn iterator(self: *const BufMap) BufMapHashMap.Iterator {
5555 return self.hash_map.iterator();
5656 }
5757
58 fn free(self: &const BufMap, value: []const u8) void {
58 fn free(self: *const BufMap, value: []const u8) void {
5959 self.hash_map.allocator.free(value);
6060 }
6161
62 fn copy(self: &const BufMap, value: []const u8) ![]const u8 {
62 fn copy(self: *const BufMap, value: []const u8) ![]const u8 {
6363 return mem.dupe(self.hash_map.allocator, u8, value);
6464 }
6565};
std/buf_set.zig+9-9
......@@ -9,12 +9,12 @@ pub const BufSet = struct {
99
1010 const BufSetHashMap = HashMap([]const u8, void, mem.hash_slice_u8, mem.eql_slice_u8);
1111
12 pub fn init(a: &Allocator) BufSet {
12 pub fn init(a: *Allocator) BufSet {
1313 var self = BufSet{ .hash_map = BufSetHashMap.init(a) };
1414 return self;
1515 }
1616
17 pub fn deinit(self: &const BufSet) void {
17 pub fn deinit(self: *const BufSet) void {
1818 var it = self.hash_map.iterator();
1919 while (true) {
2020 const entry = it.next() ?? break;
......@@ -24,7 +24,7 @@ pub const BufSet = struct {
2424 self.hash_map.deinit();
2525 }
2626
27 pub fn put(self: &BufSet, key: []const u8) !void {
27 pub fn put(self: *BufSet, key: []const u8) !void {
2828 if (self.hash_map.get(key) == null) {
2929 const key_copy = try self.copy(key);
3030 errdefer self.free(key_copy);
......@@ -32,28 +32,28 @@ pub const BufSet = struct {
3232 }
3333 }
3434
35 pub fn delete(self: &BufSet, key: []const u8) void {
35 pub fn delete(self: *BufSet, key: []const u8) void {
3636 const entry = self.hash_map.remove(key) ?? return;
3737 self.free(entry.key);
3838 }
3939
40 pub fn count(self: &const BufSet) usize {
40 pub fn count(self: *const BufSet) usize {
4141 return self.hash_map.count();
4242 }
4343
44 pub fn iterator(self: &const BufSet) BufSetHashMap.Iterator {
44 pub fn iterator(self: *const BufSet) BufSetHashMap.Iterator {
4545 return self.hash_map.iterator();
4646 }
4747
48 pub fn allocator(self: &const BufSet) &Allocator {
48 pub fn allocator(self: *const BufSet) *Allocator {
4949 return self.hash_map.allocator;
5050 }
5151
52 fn free(self: &const BufSet, value: []const u8) void {
52 fn free(self: *const BufSet, value: []const u8) void {
5353 self.hash_map.allocator.free(value);
5454 }
5555
56 fn copy(self: &const BufSet, value: []const u8) ![]const u8 {
56 fn copy(self: *const BufSet, value: []const u8) ![]const u8 {
5757 const result = try self.hash_map.allocator.alloc(u8, value.len);
5858 mem.copy(u8, result, value);
5959 return result;
std/buffer.zig+20-20
......@@ -12,14 +12,14 @@ pub const Buffer = struct {
1212 list: ArrayList(u8),
1313
1414 /// Must deinitialize with deinit.
15 pub fn init(allocator: &Allocator, m: []const u8) !Buffer {
15 pub fn init(allocator: *Allocator, m: []const u8) !Buffer {
1616 var self = try initSize(allocator, m.len);
1717 mem.copy(u8, self.list.items, m);
1818 return self;
1919 }
2020
2121 /// Must deinitialize with deinit.
22 pub fn initSize(allocator: &Allocator, size: usize) !Buffer {
22 pub fn initSize(allocator: *Allocator, size: usize) !Buffer {
2323 var self = initNull(allocator);
2424 try self.resize(size);
2525 return self;
......@@ -30,19 +30,19 @@ pub const Buffer = struct {
3030 /// * ::replaceContents
3131 /// * ::replaceContentsBuffer
3232 /// * ::resize
33 pub fn initNull(allocator: &Allocator) Buffer {
33 pub fn initNull(allocator: *Allocator) Buffer {
3434 return Buffer{ .list = ArrayList(u8).init(allocator) };
3535 }
3636
3737 /// Must deinitialize with deinit.
38 pub fn initFromBuffer(buffer: &const Buffer) !Buffer {
38 pub fn initFromBuffer(buffer: *const Buffer) !Buffer {
3939 return Buffer.init(buffer.list.allocator, buffer.toSliceConst());
4040 }
4141
4242 /// Buffer takes ownership of the passed in slice. The slice must have been
4343 /// allocated with `allocator`.
4444 /// Must deinitialize with deinit.
45 pub fn fromOwnedSlice(allocator: &Allocator, slice: []u8) Buffer {
45 pub fn fromOwnedSlice(allocator: *Allocator, slice: []u8) Buffer {
4646 var self = Buffer{ .list = ArrayList(u8).fromOwnedSlice(allocator, slice) };
4747 self.list.append(0);
4848 return self;
......@@ -50,79 +50,79 @@ pub const Buffer = struct {
5050
5151 /// The caller owns the returned memory. The Buffer becomes null and
5252 /// is safe to `deinit`.
53 pub fn toOwnedSlice(self: &Buffer) []u8 {
53 pub fn toOwnedSlice(self: *Buffer) []u8 {
5454 const allocator = self.list.allocator;
5555 const result = allocator.shrink(u8, self.list.items, self.len());
5656 self.* = initNull(allocator);
5757 return result;
5858 }
5959
60 pub fn deinit(self: &Buffer) void {
60 pub fn deinit(self: *Buffer) void {
6161 self.list.deinit();
6262 }
6363
64 pub fn toSlice(self: &const Buffer) []u8 {
64 pub fn toSlice(self: *const Buffer) []u8 {
6565 return self.list.toSlice()[0..self.len()];
6666 }
6767
68 pub fn toSliceConst(self: &const Buffer) []const u8 {
68 pub fn toSliceConst(self: *const Buffer) []const u8 {
6969 return self.list.toSliceConst()[0..self.len()];
7070 }
7171
72 pub fn shrink(self: &Buffer, new_len: usize) void {
72 pub fn shrink(self: *Buffer, new_len: usize) void {
7373 assert(new_len <= self.len());
7474 self.list.shrink(new_len + 1);
7575 self.list.items[self.len()] = 0;
7676 }
7777
78 pub fn resize(self: &Buffer, new_len: usize) !void {
78 pub fn resize(self: *Buffer, new_len: usize) !void {
7979 try self.list.resize(new_len + 1);
8080 self.list.items[self.len()] = 0;
8181 }
8282
83 pub fn isNull(self: &const Buffer) bool {
83 pub fn isNull(self: *const Buffer) bool {
8484 return self.list.len == 0;
8585 }
8686
87 pub fn len(self: &const Buffer) usize {
87 pub fn len(self: *const Buffer) usize {
8888 return self.list.len - 1;
8989 }
9090
91 pub fn append(self: &Buffer, m: []const u8) !void {
91 pub fn append(self: *Buffer, m: []const u8) !void {
9292 const old_len = self.len();
9393 try self.resize(old_len + m.len);
9494 mem.copy(u8, self.list.toSlice()[old_len..], m);
9595 }
9696
97 pub fn appendByte(self: &Buffer, byte: u8) !void {
97 pub fn appendByte(self: *Buffer, byte: u8) !void {
9898 const old_len = self.len();
9999 try self.resize(old_len + 1);
100100 self.list.toSlice()[old_len] = byte;
101101 }
102102
103 pub fn eql(self: &const Buffer, m: []const u8) bool {
103 pub fn eql(self: *const Buffer, m: []const u8) bool {
104104 return mem.eql(u8, self.toSliceConst(), m);
105105 }
106106
107 pub fn startsWith(self: &const Buffer, m: []const u8) bool {
107 pub fn startsWith(self: *const Buffer, m: []const u8) bool {
108108 if (self.len() < m.len) return false;
109109 return mem.eql(u8, self.list.items[0..m.len], m);
110110 }
111111
112 pub fn endsWith(self: &const Buffer, m: []const u8) bool {
112 pub fn endsWith(self: *const Buffer, m: []const u8) bool {
113113 const l = self.len();
114114 if (l < m.len) return false;
115115 const start = l - m.len;
116116 return mem.eql(u8, self.list.items[start..l], m);
117117 }
118118
119 pub fn replaceContents(self: &const Buffer, m: []const u8) !void {
119 pub fn replaceContents(self: *const Buffer, m: []const u8) !void {
120120 try self.resize(m.len);
121121 mem.copy(u8, self.list.toSlice(), m);
122122 }
123123
124124 /// For passing to C functions.
125 pub fn ptr(self: &const Buffer) &u8 {
125 pub fn ptr(self: *const Buffer) *u8 {
126126 return self.list.items.ptr;
127127 }
128128};
std/build.zig+139-139
......@@ -20,7 +20,7 @@ pub const Builder = struct {
2020 install_tls: TopLevelStep,
2121 have_uninstall_step: bool,
2222 have_install_step: bool,
23 allocator: &Allocator,
23 allocator: *Allocator,
2424 lib_paths: ArrayList([]const u8),
2525 include_paths: ArrayList([]const u8),
2626 rpaths: ArrayList([]const u8),
......@@ -36,9 +36,9 @@ pub const Builder = struct {
3636 verbose_cimport: bool,
3737 invalid_user_input: bool,
3838 zig_exe: []const u8,
39 default_step: &Step,
39 default_step: *Step,
4040 env_map: BufMap,
41 top_level_steps: ArrayList(&TopLevelStep),
41 top_level_steps: ArrayList(*TopLevelStep),
4242 prefix: []const u8,
4343 search_prefixes: ArrayList([]const u8),
4444 lib_dir: []const u8,
......@@ -82,7 +82,7 @@ pub const Builder = struct {
8282 description: []const u8,
8383 };
8484
85 pub fn init(allocator: &Allocator, zig_exe: []const u8, build_root: []const u8, cache_root: []const u8) Builder {
85 pub fn init(allocator: *Allocator, zig_exe: []const u8, build_root: []const u8, cache_root: []const u8) Builder {
8686 var self = Builder{
8787 .zig_exe = zig_exe,
8888 .build_root = build_root,
......@@ -102,7 +102,7 @@ pub const Builder = struct {
102102 .user_input_options = UserInputOptionsMap.init(allocator),
103103 .available_options_map = AvailableOptionsMap.init(allocator),
104104 .available_options_list = ArrayList(AvailableOption).init(allocator),
105 .top_level_steps = ArrayList(&TopLevelStep).init(allocator),
105 .top_level_steps = ArrayList(*TopLevelStep).init(allocator),
106106 .default_step = undefined,
107107 .env_map = os.getEnvMap(allocator) catch unreachable,
108108 .prefix = undefined,
......@@ -127,7 +127,7 @@ pub const Builder = struct {
127127 return self;
128128 }
129129
130 pub fn deinit(self: &Builder) void {
130 pub fn deinit(self: *Builder) void {
131131 self.lib_paths.deinit();
132132 self.include_paths.deinit();
133133 self.rpaths.deinit();
......@@ -135,81 +135,81 @@ pub const Builder = struct {
135135 self.top_level_steps.deinit();
136136 }
137137
138 pub fn setInstallPrefix(self: &Builder, maybe_prefix: ?[]const u8) void {
138 pub fn setInstallPrefix(self: *Builder, maybe_prefix: ?[]const u8) void {
139139 self.prefix = maybe_prefix ?? "/usr/local"; // TODO better default
140140 self.lib_dir = os.path.join(self.allocator, self.prefix, "lib") catch unreachable;
141141 self.exe_dir = os.path.join(self.allocator, self.prefix, "bin") catch unreachable;
142142 }
143143
144 pub fn addExecutable(self: &Builder, name: []const u8, root_src: ?[]const u8) &LibExeObjStep {
144 pub fn addExecutable(self: *Builder, name: []const u8, root_src: ?[]const u8) *LibExeObjStep {
145145 return LibExeObjStep.createExecutable(self, name, root_src);
146146 }
147147
148 pub fn addObject(self: &Builder, name: []const u8, root_src: []const u8) &LibExeObjStep {
148 pub fn addObject(self: *Builder, name: []const u8, root_src: []const u8) *LibExeObjStep {
149149 return LibExeObjStep.createObject(self, name, root_src);
150150 }
151151
152 pub fn addSharedLibrary(self: &Builder, name: []const u8, root_src: ?[]const u8, ver: &const Version) &LibExeObjStep {
152 pub fn addSharedLibrary(self: *Builder, name: []const u8, root_src: ?[]const u8, ver: *const Version) *LibExeObjStep {
153153 return LibExeObjStep.createSharedLibrary(self, name, root_src, ver);
154154 }
155155
156 pub fn addStaticLibrary(self: &Builder, name: []const u8, root_src: ?[]const u8) &LibExeObjStep {
156 pub fn addStaticLibrary(self: *Builder, name: []const u8, root_src: ?[]const u8) *LibExeObjStep {
157157 return LibExeObjStep.createStaticLibrary(self, name, root_src);
158158 }
159159
160 pub fn addTest(self: &Builder, root_src: []const u8) &TestStep {
160 pub fn addTest(self: *Builder, root_src: []const u8) *TestStep {
161161 const test_step = self.allocator.create(TestStep) catch unreachable;
162162 test_step.* = TestStep.init(self, root_src);
163163 return test_step;
164164 }
165165
166 pub fn addAssemble(self: &Builder, name: []const u8, src: []const u8) &LibExeObjStep {
166 pub fn addAssemble(self: *Builder, name: []const u8, src: []const u8) *LibExeObjStep {
167167 const obj_step = LibExeObjStep.createObject(self, name, null);
168168 obj_step.addAssemblyFile(src);
169169 return obj_step;
170170 }
171171
172 pub fn addCStaticLibrary(self: &Builder, name: []const u8) &LibExeObjStep {
172 pub fn addCStaticLibrary(self: *Builder, name: []const u8) *LibExeObjStep {
173173 return LibExeObjStep.createCStaticLibrary(self, name);
174174 }
175175
176 pub fn addCSharedLibrary(self: &Builder, name: []const u8, ver: &const Version) &LibExeObjStep {
176 pub fn addCSharedLibrary(self: *Builder, name: []const u8, ver: *const Version) *LibExeObjStep {
177177 return LibExeObjStep.createCSharedLibrary(self, name, ver);
178178 }
179179
180 pub fn addCExecutable(self: &Builder, name: []const u8) &LibExeObjStep {
180 pub fn addCExecutable(self: *Builder, name: []const u8) *LibExeObjStep {
181181 return LibExeObjStep.createCExecutable(self, name);
182182 }
183183
184 pub fn addCObject(self: &Builder, name: []const u8, src: []const u8) &LibExeObjStep {
184 pub fn addCObject(self: *Builder, name: []const u8, src: []const u8) *LibExeObjStep {
185185 return LibExeObjStep.createCObject(self, name, src);
186186 }
187187
188188 /// ::argv is copied.
189 pub fn addCommand(self: &Builder, cwd: ?[]const u8, env_map: &const BufMap, argv: []const []const u8) &CommandStep {
189 pub fn addCommand(self: *Builder, cwd: ?[]const u8, env_map: *const BufMap, argv: []const []const u8) *CommandStep {
190190 return CommandStep.create(self, cwd, env_map, argv);
191191 }
192192
193 pub fn addWriteFile(self: &Builder, file_path: []const u8, data: []const u8) &WriteFileStep {
193 pub fn addWriteFile(self: *Builder, file_path: []const u8, data: []const u8) *WriteFileStep {
194194 const write_file_step = self.allocator.create(WriteFileStep) catch unreachable;
195195 write_file_step.* = WriteFileStep.init(self, file_path, data);
196196 return write_file_step;
197197 }
198198
199 pub fn addLog(self: &Builder, comptime format: []const u8, args: ...) &LogStep {
199 pub fn addLog(self: *Builder, comptime format: []const u8, args: ...) *LogStep {
200200 const data = self.fmt(format, args);
201201 const log_step = self.allocator.create(LogStep) catch unreachable;
202202 log_step.* = LogStep.init(self, data);
203203 return log_step;
204204 }
205205
206 pub fn addRemoveDirTree(self: &Builder, dir_path: []const u8) &RemoveDirStep {
206 pub fn addRemoveDirTree(self: *Builder, dir_path: []const u8) *RemoveDirStep {
207207 const remove_dir_step = self.allocator.create(RemoveDirStep) catch unreachable;
208208 remove_dir_step.* = RemoveDirStep.init(self, dir_path);
209209 return remove_dir_step;
210210 }
211211
212 pub fn version(self: &const Builder, major: u32, minor: u32, patch: u32) Version {
212 pub fn version(self: *const Builder, major: u32, minor: u32, patch: u32) Version {
213213 return Version{
214214 .major = major,
215215 .minor = minor,
......@@ -217,20 +217,20 @@ pub const Builder = struct {
217217 };
218218 }
219219
220 pub fn addCIncludePath(self: &Builder, path: []const u8) void {
220 pub fn addCIncludePath(self: *Builder, path: []const u8) void {
221221 self.include_paths.append(path) catch unreachable;
222222 }
223223
224 pub fn addRPath(self: &Builder, path: []const u8) void {
224 pub fn addRPath(self: *Builder, path: []const u8) void {
225225 self.rpaths.append(path) catch unreachable;
226226 }
227227
228 pub fn addLibPath(self: &Builder, path: []const u8) void {
228 pub fn addLibPath(self: *Builder, path: []const u8) void {
229229 self.lib_paths.append(path) catch unreachable;
230230 }
231231
232 pub fn make(self: &Builder, step_names: []const []const u8) !void {
233 var wanted_steps = ArrayList(&Step).init(self.allocator);
232 pub fn make(self: *Builder, step_names: []const []const u8) !void {
233 var wanted_steps = ArrayList(*Step).init(self.allocator);
234234 defer wanted_steps.deinit();
235235
236236 if (step_names.len == 0) {
......@@ -247,7 +247,7 @@ pub const Builder = struct {
247247 }
248248 }
249249
250 pub fn getInstallStep(self: &Builder) &Step {
250 pub fn getInstallStep(self: *Builder) *Step {
251251 if (self.have_install_step) return &self.install_tls.step;
252252
253253 self.top_level_steps.append(&self.install_tls) catch unreachable;
......@@ -255,7 +255,7 @@ pub const Builder = struct {
255255 return &self.install_tls.step;
256256 }
257257
258 pub fn getUninstallStep(self: &Builder) &Step {
258 pub fn getUninstallStep(self: *Builder) *Step {
259259 if (self.have_uninstall_step) return &self.uninstall_tls.step;
260260
261261 self.top_level_steps.append(&self.uninstall_tls) catch unreachable;
......@@ -263,7 +263,7 @@ pub const Builder = struct {
263263 return &self.uninstall_tls.step;
264264 }
265265
266 fn makeUninstall(uninstall_step: &Step) error!void {
266 fn makeUninstall(uninstall_step: *Step) error!void {
267267 const uninstall_tls = @fieldParentPtr(TopLevelStep, "step", uninstall_step);
268268 const self = @fieldParentPtr(Builder, "uninstall_tls", uninstall_tls);
269269
......@@ -277,7 +277,7 @@ pub const Builder = struct {
277277 // TODO remove empty directories
278278 }
279279
280 fn makeOneStep(self: &Builder, s: &Step) error!void {
280 fn makeOneStep(self: *Builder, s: *Step) error!void {
281281 if (s.loop_flag) {
282282 warn("Dependency loop detected:\n {}\n", s.name);
283283 return error.DependencyLoopDetected;
......@@ -298,7 +298,7 @@ pub const Builder = struct {
298298 try s.make();
299299 }
300300
301 fn getTopLevelStepByName(self: &Builder, name: []const u8) !&Step {
301 fn getTopLevelStepByName(self: *Builder, name: []const u8) !*Step {
302302 for (self.top_level_steps.toSliceConst()) |top_level_step| {
303303 if (mem.eql(u8, top_level_step.step.name, name)) {
304304 return &top_level_step.step;
......@@ -308,7 +308,7 @@ pub const Builder = struct {
308308 return error.InvalidStepName;
309309 }
310310
311 fn processNixOSEnvVars(self: &Builder) void {
311 fn processNixOSEnvVars(self: *Builder) void {
312312 if (os.getEnvVarOwned(self.allocator, "NIX_CFLAGS_COMPILE")) |nix_cflags_compile| {
313313 var it = mem.split(nix_cflags_compile, " ");
314314 while (true) {
......@@ -350,7 +350,7 @@ pub const Builder = struct {
350350 }
351351 }
352352
353 pub fn option(self: &Builder, comptime T: type, name: []const u8, description: []const u8) ?T {
353 pub fn option(self: *Builder, comptime T: type, name: []const u8, description: []const u8) ?T {
354354 const type_id = comptime typeToEnum(T);
355355 const available_option = AvailableOption{
356356 .name = name,
......@@ -403,7 +403,7 @@ pub const Builder = struct {
403403 }
404404 }
405405
406 pub fn step(self: &Builder, name: []const u8, description: []const u8) &Step {
406 pub fn step(self: *Builder, name: []const u8, description: []const u8) *Step {
407407 const step_info = self.allocator.create(TopLevelStep) catch unreachable;
408408 step_info.* = TopLevelStep{
409409 .step = Step.initNoOp(name, self.allocator),
......@@ -413,7 +413,7 @@ pub const Builder = struct {
413413 return &step_info.step;
414414 }
415415
416 pub fn standardReleaseOptions(self: &Builder) builtin.Mode {
416 pub fn standardReleaseOptions(self: *Builder) builtin.Mode {
417417 if (self.release_mode) |mode| return mode;
418418
419419 const release_safe = self.option(bool, "release-safe", "optimizations on and safety on") ?? false;
......@@ -429,7 +429,7 @@ pub const Builder = struct {
429429 return mode;
430430 }
431431
432 pub fn addUserInputOption(self: &Builder, name: []const u8, value: []const u8) bool {
432 pub fn addUserInputOption(self: *Builder, name: []const u8, value: []const u8) bool {
433433 if (self.user_input_options.put(name, UserInputOption{
434434 .name = name,
435435 .value = UserValue{ .Scalar = value },
......@@ -466,7 +466,7 @@ pub const Builder = struct {
466466 return false;
467467 }
468468
469 pub fn addUserInputFlag(self: &Builder, name: []const u8) bool {
469 pub fn addUserInputFlag(self: *Builder, name: []const u8) bool {
470470 if (self.user_input_options.put(name, UserInputOption{
471471 .name = name,
472472 .value = UserValue{ .Flag = {} },
......@@ -500,7 +500,7 @@ pub const Builder = struct {
500500 };
501501 }
502502
503 fn markInvalidUserInput(self: &Builder) void {
503 fn markInvalidUserInput(self: *Builder) void {
504504 self.invalid_user_input = true;
505505 }
506506
......@@ -514,7 +514,7 @@ pub const Builder = struct {
514514 };
515515 }
516516
517 pub fn validateUserInputDidItFail(self: &Builder) bool {
517 pub fn validateUserInputDidItFail(self: *Builder) bool {
518518 // make sure all args are used
519519 var it = self.user_input_options.iterator();
520520 while (true) {
......@@ -528,7 +528,7 @@ pub const Builder = struct {
528528 return self.invalid_user_input;
529529 }
530530
531 fn spawnChild(self: &Builder, argv: []const []const u8) !void {
531 fn spawnChild(self: *Builder, argv: []const []const u8) !void {
532532 return self.spawnChildEnvMap(null, &self.env_map, argv);
533533 }
534534
......@@ -540,7 +540,7 @@ pub const Builder = struct {
540540 warn("\n");
541541 }
542542
543 fn spawnChildEnvMap(self: &Builder, cwd: ?[]const u8, env_map: &const BufMap, argv: []const []const u8) !void {
543 fn spawnChildEnvMap(self: *Builder, cwd: ?[]const u8, env_map: *const BufMap, argv: []const []const u8) !void {
544544 if (self.verbose) {
545545 printCmd(cwd, argv);
546546 }
......@@ -573,28 +573,28 @@ pub const Builder = struct {
573573 }
574574 }
575575
576 pub fn makePath(self: &Builder, path: []const u8) !void {
576 pub fn makePath(self: *Builder, path: []const u8) !void {
577577 os.makePath(self.allocator, self.pathFromRoot(path)) catch |err| {
578578 warn("Unable to create path {}: {}\n", path, @errorName(err));
579579 return err;
580580 };
581581 }
582582
583 pub fn installArtifact(self: &Builder, artifact: &LibExeObjStep) void {
583 pub fn installArtifact(self: *Builder, artifact: *LibExeObjStep) void {
584584 self.getInstallStep().dependOn(&self.addInstallArtifact(artifact).step);
585585 }
586586
587 pub fn addInstallArtifact(self: &Builder, artifact: &LibExeObjStep) &InstallArtifactStep {
587 pub fn addInstallArtifact(self: *Builder, artifact: *LibExeObjStep) *InstallArtifactStep {
588588 return InstallArtifactStep.create(self, artifact);
589589 }
590590
591591 ///::dest_rel_path is relative to prefix path or it can be an absolute path
592 pub fn installFile(self: &Builder, src_path: []const u8, dest_rel_path: []const u8) void {
592 pub fn installFile(self: *Builder, src_path: []const u8, dest_rel_path: []const u8) void {
593593 self.getInstallStep().dependOn(&self.addInstallFile(src_path, dest_rel_path).step);
594594 }
595595
596596 ///::dest_rel_path is relative to prefix path or it can be an absolute path
597 pub fn addInstallFile(self: &Builder, src_path: []const u8, dest_rel_path: []const u8) &InstallFileStep {
597 pub fn addInstallFile(self: *Builder, src_path: []const u8, dest_rel_path: []const u8) *InstallFileStep {
598598 const full_dest_path = os.path.resolve(self.allocator, self.prefix, dest_rel_path) catch unreachable;
599599 self.pushInstalledFile(full_dest_path);
600600
......@@ -603,16 +603,16 @@ pub const Builder = struct {
603603 return install_step;
604604 }
605605
606 pub fn pushInstalledFile(self: &Builder, full_path: []const u8) void {
606 pub fn pushInstalledFile(self: *Builder, full_path: []const u8) void {
607607 _ = self.getUninstallStep();
608608 self.installed_files.append(full_path) catch unreachable;
609609 }
610610
611 fn copyFile(self: &Builder, source_path: []const u8, dest_path: []const u8) !void {
611 fn copyFile(self: *Builder, source_path: []const u8, dest_path: []const u8) !void {
612612 return self.copyFileMode(source_path, dest_path, os.default_file_mode);
613613 }
614614
615 fn copyFileMode(self: &Builder, source_path: []const u8, dest_path: []const u8, mode: os.FileMode) !void {
615 fn copyFileMode(self: *Builder, source_path: []const u8, dest_path: []const u8, mode: os.FileMode) !void {
616616 if (self.verbose) {
617617 warn("cp {} {}\n", source_path, dest_path);
618618 }
......@@ -629,15 +629,15 @@ pub const Builder = struct {
629629 };
630630 }
631631
632 fn pathFromRoot(self: &Builder, rel_path: []const u8) []u8 {
632 fn pathFromRoot(self: *Builder, rel_path: []const u8) []u8 {
633633 return os.path.resolve(self.allocator, self.build_root, rel_path) catch unreachable;
634634 }
635635
636 pub fn fmt(self: &Builder, comptime format: []const u8, args: ...) []u8 {
636 pub fn fmt(self: *Builder, comptime format: []const u8, args: ...) []u8 {
637637 return fmt_lib.allocPrint(self.allocator, format, args) catch unreachable;
638638 }
639639
640 fn getCCExe(self: &Builder) []const u8 {
640 fn getCCExe(self: *Builder) []const u8 {
641641 if (builtin.environ == builtin.Environ.msvc) {
642642 return "cl.exe";
643643 } else {
......@@ -645,7 +645,7 @@ pub const Builder = struct {
645645 }
646646 }
647647
648 pub fn findProgram(self: &Builder, names: []const []const u8, paths: []const []const u8) ![]const u8 {
648 pub fn findProgram(self: *Builder, names: []const []const u8, paths: []const []const u8) ![]const u8 {
649649 // TODO report error for ambiguous situations
650650 const exe_extension = (Target{ .Native = {} }).exeFileExt();
651651 for (self.search_prefixes.toSliceConst()) |search_prefix| {
......@@ -693,7 +693,7 @@ pub const Builder = struct {
693693 return error.FileNotFound;
694694 }
695695
696 pub fn exec(self: &Builder, argv: []const []const u8) ![]u8 {
696 pub fn exec(self: *Builder, argv: []const []const u8) ![]u8 {
697697 const max_output_size = 100 * 1024;
698698 const result = try os.ChildProcess.exec(self.allocator, argv, null, null, max_output_size);
699699 switch (result.term) {
......@@ -715,7 +715,7 @@ pub const Builder = struct {
715715 }
716716 }
717717
718 pub fn addSearchPrefix(self: &Builder, search_prefix: []const u8) void {
718 pub fn addSearchPrefix(self: *Builder, search_prefix: []const u8) void {
719719 self.search_prefixes.append(search_prefix) catch unreachable;
720720 }
721721};
......@@ -736,7 +736,7 @@ pub const Target = union(enum) {
736736 Native: void,
737737 Cross: CrossTarget,
738738
739 pub fn oFileExt(self: &const Target) []const u8 {
739 pub fn oFileExt(self: *const Target) []const u8 {
740740 const environ = switch (self.*) {
741741 Target.Native => builtin.environ,
742742 Target.Cross => |t| t.environ,
......@@ -747,49 +747,49 @@ pub const Target = union(enum) {
747747 };
748748 }
749749
750 pub fn exeFileExt(self: &const Target) []const u8 {
750 pub fn exeFileExt(self: *const Target) []const u8 {
751751 return switch (self.getOs()) {
752752 builtin.Os.windows => ".exe",
753753 else => "",
754754 };
755755 }
756756
757 pub fn libFileExt(self: &const Target) []const u8 {
757 pub fn libFileExt(self: *const Target) []const u8 {
758758 return switch (self.getOs()) {
759759 builtin.Os.windows => ".lib",
760760 else => ".a",
761761 };
762762 }
763763
764 pub fn getOs(self: &const Target) builtin.Os {
764 pub fn getOs(self: *const Target) builtin.Os {
765765 return switch (self.*) {
766766 Target.Native => builtin.os,
767767 Target.Cross => |t| t.os,
768768 };
769769 }
770770
771 pub fn isDarwin(self: &const Target) bool {
771 pub fn isDarwin(self: *const Target) bool {
772772 return switch (self.getOs()) {
773773 builtin.Os.ios, builtin.Os.macosx => true,
774774 else => false,
775775 };
776776 }
777777
778 pub fn isWindows(self: &const Target) bool {
778 pub fn isWindows(self: *const Target) bool {
779779 return switch (self.getOs()) {
780780 builtin.Os.windows => true,
781781 else => false,
782782 };
783783 }
784784
785 pub fn wantSharedLibSymLinks(self: &const Target) bool {
785 pub fn wantSharedLibSymLinks(self: *const Target) bool {
786786 return !self.isWindows();
787787 }
788788};
789789
790790pub const LibExeObjStep = struct {
791791 step: Step,
792 builder: &Builder,
792 builder: *Builder,
793793 name: []const u8,
794794 target: Target,
795795 link_libs: BufSet,
......@@ -836,56 +836,56 @@ pub const LibExeObjStep = struct {
836836 Obj,
837837 };
838838
839 pub fn createSharedLibrary(builder: &Builder, name: []const u8, root_src: ?[]const u8, ver: &const Version) &LibExeObjStep {
839 pub fn createSharedLibrary(builder: *Builder, name: []const u8, root_src: ?[]const u8, ver: *const Version) *LibExeObjStep {
840840 const self = builder.allocator.create(LibExeObjStep) catch unreachable;
841841 self.* = initExtraArgs(builder, name, root_src, Kind.Lib, false, ver);
842842 return self;
843843 }
844844
845 pub fn createCSharedLibrary(builder: &Builder, name: []const u8, version: &const Version) &LibExeObjStep {
845 pub fn createCSharedLibrary(builder: *Builder, name: []const u8, version: *const Version) *LibExeObjStep {
846846 const self = builder.allocator.create(LibExeObjStep) catch unreachable;
847847 self.* = initC(builder, name, Kind.Lib, version, false);
848848 return self;
849849 }
850850
851 pub fn createStaticLibrary(builder: &Builder, name: []const u8, root_src: ?[]const u8) &LibExeObjStep {
851 pub fn createStaticLibrary(builder: *Builder, name: []const u8, root_src: ?[]const u8) *LibExeObjStep {
852852 const self = builder.allocator.create(LibExeObjStep) catch unreachable;
853853 self.* = initExtraArgs(builder, name, root_src, Kind.Lib, true, builder.version(0, 0, 0));
854854 return self;
855855 }
856856
857 pub fn createCStaticLibrary(builder: &Builder, name: []const u8) &LibExeObjStep {
857 pub fn createCStaticLibrary(builder: *Builder, name: []const u8) *LibExeObjStep {
858858 const self = builder.allocator.create(LibExeObjStep) catch unreachable;
859859 self.* = initC(builder, name, Kind.Lib, builder.version(0, 0, 0), true);
860860 return self;
861861 }
862862
863 pub fn createObject(builder: &Builder, name: []const u8, root_src: []const u8) &LibExeObjStep {
863 pub fn createObject(builder: *Builder, name: []const u8, root_src: []const u8) *LibExeObjStep {
864864 const self = builder.allocator.create(LibExeObjStep) catch unreachable;
865865 self.* = initExtraArgs(builder, name, root_src, Kind.Obj, false, builder.version(0, 0, 0));
866866 return self;
867867 }
868868
869 pub fn createCObject(builder: &Builder, name: []const u8, src: []const u8) &LibExeObjStep {
869 pub fn createCObject(builder: *Builder, name: []const u8, src: []const u8) *LibExeObjStep {
870870 const self = builder.allocator.create(LibExeObjStep) catch unreachable;
871871 self.* = initC(builder, name, Kind.Obj, builder.version(0, 0, 0), false);
872872 self.object_src = src;
873873 return self;
874874 }
875875
876 pub fn createExecutable(builder: &Builder, name: []const u8, root_src: ?[]const u8) &LibExeObjStep {
876 pub fn createExecutable(builder: *Builder, name: []const u8, root_src: ?[]const u8) *LibExeObjStep {
877877 const self = builder.allocator.create(LibExeObjStep) catch unreachable;
878878 self.* = initExtraArgs(builder, name, root_src, Kind.Exe, false, builder.version(0, 0, 0));
879879 return self;
880880 }
881881
882 pub fn createCExecutable(builder: &Builder, name: []const u8) &LibExeObjStep {
882 pub fn createCExecutable(builder: *Builder, name: []const u8) *LibExeObjStep {
883883 const self = builder.allocator.create(LibExeObjStep) catch unreachable;
884884 self.* = initC(builder, name, Kind.Exe, builder.version(0, 0, 0), false);
885885 return self;
886886 }
887887
888 fn initExtraArgs(builder: &Builder, name: []const u8, root_src: ?[]const u8, kind: Kind, static: bool, ver: &const Version) LibExeObjStep {
888 fn initExtraArgs(builder: *Builder, name: []const u8, root_src: ?[]const u8, kind: Kind, static: bool, ver: *const Version) LibExeObjStep {
889889 var self = LibExeObjStep{
890890 .strip = false,
891891 .builder = builder,
......@@ -924,7 +924,7 @@ pub const LibExeObjStep = struct {
924924 return self;
925925 }
926926
927 fn initC(builder: &Builder, name: []const u8, kind: Kind, version: &const Version, static: bool) LibExeObjStep {
927 fn initC(builder: *Builder, name: []const u8, kind: Kind, version: *const Version, static: bool) LibExeObjStep {
928928 var self = LibExeObjStep{
929929 .builder = builder,
930930 .name = name,
......@@ -964,7 +964,7 @@ pub const LibExeObjStep = struct {
964964 return self;
965965 }
966966
967 fn computeOutFileNames(self: &LibExeObjStep) void {
967 fn computeOutFileNames(self: *LibExeObjStep) void {
968968 switch (self.kind) {
969969 Kind.Obj => {
970970 self.out_filename = self.builder.fmt("{}{}", self.name, self.target.oFileExt());
......@@ -996,7 +996,7 @@ pub const LibExeObjStep = struct {
996996 }
997997 }
998998
999 pub fn setTarget(self: &LibExeObjStep, target_arch: builtin.Arch, target_os: builtin.Os, target_environ: builtin.Environ) void {
999 pub fn setTarget(self: *LibExeObjStep, target_arch: builtin.Arch, target_os: builtin.Os, target_environ: builtin.Environ) void {
10001000 self.target = Target{
10011001 .Cross = CrossTarget{
10021002 .arch = target_arch,
......@@ -1008,16 +1008,16 @@ pub const LibExeObjStep = struct {
10081008 }
10091009
10101010 // TODO respect this in the C args
1011 pub fn setLinkerScriptPath(self: &LibExeObjStep, path: []const u8) void {
1011 pub fn setLinkerScriptPath(self: *LibExeObjStep, path: []const u8) void {
10121012 self.linker_script = path;
10131013 }
10141014
1015 pub fn linkFramework(self: &LibExeObjStep, framework_name: []const u8) void {
1015 pub fn linkFramework(self: *LibExeObjStep, framework_name: []const u8) void {
10161016 assert(self.target.isDarwin());
10171017 self.frameworks.put(framework_name) catch unreachable;
10181018 }
10191019
1020 pub fn linkLibrary(self: &LibExeObjStep, lib: &LibExeObjStep) void {
1020 pub fn linkLibrary(self: *LibExeObjStep, lib: *LibExeObjStep) void {
10211021 assert(self.kind != Kind.Obj);
10221022 assert(lib.kind == Kind.Lib);
10231023
......@@ -1038,26 +1038,26 @@ pub const LibExeObjStep = struct {
10381038 }
10391039 }
10401040
1041 pub fn linkSystemLibrary(self: &LibExeObjStep, name: []const u8) void {
1041 pub fn linkSystemLibrary(self: *LibExeObjStep, name: []const u8) void {
10421042 assert(self.kind != Kind.Obj);
10431043 self.link_libs.put(name) catch unreachable;
10441044 }
10451045
1046 pub fn addSourceFile(self: &LibExeObjStep, file: []const u8) void {
1046 pub fn addSourceFile(self: *LibExeObjStep, file: []const u8) void {
10471047 assert(self.kind != Kind.Obj);
10481048 assert(!self.is_zig);
10491049 self.source_files.append(file) catch unreachable;
10501050 }
10511051
1052 pub fn setVerboseLink(self: &LibExeObjStep, value: bool) void {
1052 pub fn setVerboseLink(self: *LibExeObjStep, value: bool) void {
10531053 self.verbose_link = value;
10541054 }
10551055
1056 pub fn setBuildMode(self: &LibExeObjStep, mode: builtin.Mode) void {
1056 pub fn setBuildMode(self: *LibExeObjStep, mode: builtin.Mode) void {
10571057 self.build_mode = mode;
10581058 }
10591059
1060 pub fn setOutputPath(self: &LibExeObjStep, file_path: []const u8) void {
1060 pub fn setOutputPath(self: *LibExeObjStep, file_path: []const u8) void {
10611061 self.output_path = file_path;
10621062
10631063 // catch a common mistake
......@@ -1066,11 +1066,11 @@ pub const LibExeObjStep = struct {
10661066 }
10671067 }
10681068
1069 pub fn getOutputPath(self: &LibExeObjStep) []const u8 {
1069 pub fn getOutputPath(self: *LibExeObjStep) []const u8 {
10701070 return if (self.output_path) |output_path| output_path else os.path.join(self.builder.allocator, self.builder.cache_root, self.out_filename) catch unreachable;
10711071 }
10721072
1073 pub fn setOutputHPath(self: &LibExeObjStep, file_path: []const u8) void {
1073 pub fn setOutputHPath(self: *LibExeObjStep, file_path: []const u8) void {
10741074 self.output_h_path = file_path;
10751075
10761076 // catch a common mistake
......@@ -1079,21 +1079,21 @@ pub const LibExeObjStep = struct {
10791079 }
10801080 }
10811081
1082 pub fn getOutputHPath(self: &LibExeObjStep) []const u8 {
1082 pub fn getOutputHPath(self: *LibExeObjStep) []const u8 {
10831083 return if (self.output_h_path) |output_h_path| output_h_path else os.path.join(self.builder.allocator, self.builder.cache_root, self.out_h_filename) catch unreachable;
10841084 }
10851085
1086 pub fn addAssemblyFile(self: &LibExeObjStep, path: []const u8) void {
1086 pub fn addAssemblyFile(self: *LibExeObjStep, path: []const u8) void {
10871087 self.assembly_files.append(path) catch unreachable;
10881088 }
10891089
1090 pub fn addObjectFile(self: &LibExeObjStep, path: []const u8) void {
1090 pub fn addObjectFile(self: *LibExeObjStep, path: []const u8) void {
10911091 assert(self.kind != Kind.Obj);
10921092
10931093 self.object_files.append(path) catch unreachable;
10941094 }
10951095
1096 pub fn addObject(self: &LibExeObjStep, obj: &LibExeObjStep) void {
1096 pub fn addObject(self: *LibExeObjStep, obj: *LibExeObjStep) void {
10971097 assert(obj.kind == Kind.Obj);
10981098 assert(self.kind != Kind.Obj);
10991099
......@@ -1110,15 +1110,15 @@ pub const LibExeObjStep = struct {
11101110 self.include_dirs.append(self.builder.cache_root) catch unreachable;
11111111 }
11121112
1113 pub fn addIncludeDir(self: &LibExeObjStep, path: []const u8) void {
1113 pub fn addIncludeDir(self: *LibExeObjStep, path: []const u8) void {
11141114 self.include_dirs.append(path) catch unreachable;
11151115 }
11161116
1117 pub fn addLibPath(self: &LibExeObjStep, path: []const u8) void {
1117 pub fn addLibPath(self: *LibExeObjStep, path: []const u8) void {
11181118 self.lib_paths.append(path) catch unreachable;
11191119 }
11201120
1121 pub fn addPackagePath(self: &LibExeObjStep, name: []const u8, pkg_index_path: []const u8) void {
1121 pub fn addPackagePath(self: *LibExeObjStep, name: []const u8, pkg_index_path: []const u8) void {
11221122 assert(self.is_zig);
11231123
11241124 self.packages.append(Pkg{
......@@ -1127,23 +1127,23 @@ pub const LibExeObjStep = struct {
11271127 }) catch unreachable;
11281128 }
11291129
1130 pub fn addCompileFlags(self: &LibExeObjStep, flags: []const []const u8) void {
1130 pub fn addCompileFlags(self: *LibExeObjStep, flags: []const []const u8) void {
11311131 for (flags) |flag| {
11321132 self.cflags.append(flag) catch unreachable;
11331133 }
11341134 }
11351135
1136 pub fn setNoStdLib(self: &LibExeObjStep, disable: bool) void {
1136 pub fn setNoStdLib(self: *LibExeObjStep, disable: bool) void {
11371137 assert(!self.is_zig);
11381138 self.disable_libc = disable;
11391139 }
11401140
1141 fn make(step: &Step) !void {
1141 fn make(step: *Step) !void {
11421142 const self = @fieldParentPtr(LibExeObjStep, "step", step);
11431143 return if (self.is_zig) self.makeZig() else self.makeC();
11441144 }
11451145
1146 fn makeZig(self: &LibExeObjStep) !void {
1146 fn makeZig(self: *LibExeObjStep) !void {
11471147 const builder = self.builder;
11481148
11491149 assert(self.is_zig);
......@@ -1309,7 +1309,7 @@ pub const LibExeObjStep = struct {
13091309 }
13101310 }
13111311
1312 fn appendCompileFlags(self: &LibExeObjStep, args: &ArrayList([]const u8)) void {
1312 fn appendCompileFlags(self: *LibExeObjStep, args: *ArrayList([]const u8)) void {
13131313 if (!self.strip) {
13141314 args.append("-g") catch unreachable;
13151315 }
......@@ -1354,7 +1354,7 @@ pub const LibExeObjStep = struct {
13541354 }
13551355 }
13561356
1357 fn makeC(self: &LibExeObjStep) !void {
1357 fn makeC(self: *LibExeObjStep) !void {
13581358 const builder = self.builder;
13591359
13601360 const cc = builder.getCCExe();
......@@ -1580,7 +1580,7 @@ pub const LibExeObjStep = struct {
15801580
15811581pub const TestStep = struct {
15821582 step: Step,
1583 builder: &Builder,
1583 builder: *Builder,
15841584 root_src: []const u8,
15851585 build_mode: builtin.Mode,
15861586 verbose: bool,
......@@ -1591,7 +1591,7 @@ pub const TestStep = struct {
15911591 exec_cmd_args: ?[]const ?[]const u8,
15921592 include_dirs: ArrayList([]const u8),
15931593
1594 pub fn init(builder: &Builder, root_src: []const u8) TestStep {
1594 pub fn init(builder: *Builder, root_src: []const u8) TestStep {
15951595 const step_name = builder.fmt("test {}", root_src);
15961596 return TestStep{
15971597 .step = Step.init(step_name, builder.allocator, make),
......@@ -1608,31 +1608,31 @@ pub const TestStep = struct {
16081608 };
16091609 }
16101610
1611 pub fn setVerbose(self: &TestStep, value: bool) void {
1611 pub fn setVerbose(self: *TestStep, value: bool) void {
16121612 self.verbose = value;
16131613 }
16141614
1615 pub fn addIncludeDir(self: &TestStep, path: []const u8) void {
1615 pub fn addIncludeDir(self: *TestStep, path: []const u8) void {
16161616 self.include_dirs.append(path) catch unreachable;
16171617 }
16181618
1619 pub fn setBuildMode(self: &TestStep, mode: builtin.Mode) void {
1619 pub fn setBuildMode(self: *TestStep, mode: builtin.Mode) void {
16201620 self.build_mode = mode;
16211621 }
16221622
1623 pub fn linkSystemLibrary(self: &TestStep, name: []const u8) void {
1623 pub fn linkSystemLibrary(self: *TestStep, name: []const u8) void {
16241624 self.link_libs.put(name) catch unreachable;
16251625 }
16261626
1627 pub fn setNamePrefix(self: &TestStep, text: []const u8) void {
1627 pub fn setNamePrefix(self: *TestStep, text: []const u8) void {
16281628 self.name_prefix = text;
16291629 }
16301630
1631 pub fn setFilter(self: &TestStep, text: ?[]const u8) void {
1631 pub fn setFilter(self: *TestStep, text: ?[]const u8) void {
16321632 self.filter = text;
16331633 }
16341634
1635 pub fn setTarget(self: &TestStep, target_arch: builtin.Arch, target_os: builtin.Os, target_environ: builtin.Environ) void {
1635 pub fn setTarget(self: *TestStep, target_arch: builtin.Arch, target_os: builtin.Os, target_environ: builtin.Environ) void {
16361636 self.target = Target{
16371637 .Cross = CrossTarget{
16381638 .arch = target_arch,
......@@ -1642,11 +1642,11 @@ pub const TestStep = struct {
16421642 };
16431643 }
16441644
1645 pub fn setExecCmd(self: &TestStep, args: []const ?[]const u8) void {
1645 pub fn setExecCmd(self: *TestStep, args: []const ?[]const u8) void {
16461646 self.exec_cmd_args = args;
16471647 }
16481648
1649 fn make(step: &Step) !void {
1649 fn make(step: *Step) !void {
16501650 const self = @fieldParentPtr(TestStep, "step", step);
16511651 const builder = self.builder;
16521652
......@@ -1739,13 +1739,13 @@ pub const TestStep = struct {
17391739
17401740pub const CommandStep = struct {
17411741 step: Step,
1742 builder: &Builder,
1742 builder: *Builder,
17431743 argv: [][]const u8,
17441744 cwd: ?[]const u8,
1745 env_map: &const BufMap,
1745 env_map: *const BufMap,
17461746
17471747 /// ::argv is copied.
1748 pub fn create(builder: &Builder, cwd: ?[]const u8, env_map: &const BufMap, argv: []const []const u8) &CommandStep {
1748 pub fn create(builder: *Builder, cwd: ?[]const u8, env_map: *const BufMap, argv: []const []const u8) *CommandStep {
17491749 const self = builder.allocator.create(CommandStep) catch unreachable;
17501750 self.* = CommandStep{
17511751 .builder = builder,
......@@ -1759,7 +1759,7 @@ pub const CommandStep = struct {
17591759 return self;
17601760 }
17611761
1762 fn make(step: &Step) !void {
1762 fn make(step: *Step) !void {
17631763 const self = @fieldParentPtr(CommandStep, "step", step);
17641764
17651765 const cwd = if (self.cwd) |cwd| self.builder.pathFromRoot(cwd) else self.builder.build_root;
......@@ -1769,13 +1769,13 @@ pub const CommandStep = struct {
17691769
17701770const InstallArtifactStep = struct {
17711771 step: Step,
1772 builder: &Builder,
1773 artifact: &LibExeObjStep,
1772 builder: *Builder,
1773 artifact: *LibExeObjStep,
17741774 dest_file: []const u8,
17751775
17761776 const Self = this;
17771777
1778 pub fn create(builder: &Builder, artifact: &LibExeObjStep) &Self {
1778 pub fn create(builder: *Builder, artifact: *LibExeObjStep) *Self {
17791779 const self = builder.allocator.create(Self) catch unreachable;
17801780 const dest_dir = switch (artifact.kind) {
17811781 LibExeObjStep.Kind.Obj => unreachable,
......@@ -1797,7 +1797,7 @@ const InstallArtifactStep = struct {
17971797 return self;
17981798 }
17991799
1800 fn make(step: &Step) !void {
1800 fn make(step: *Step) !void {
18011801 const self = @fieldParentPtr(Self, "step", step);
18021802 const builder = self.builder;
18031803
......@@ -1818,11 +1818,11 @@ const InstallArtifactStep = struct {
18181818
18191819pub const InstallFileStep = struct {
18201820 step: Step,
1821 builder: &Builder,
1821 builder: *Builder,
18221822 src_path: []const u8,
18231823 dest_path: []const u8,
18241824
1825 pub fn init(builder: &Builder, src_path: []const u8, dest_path: []const u8) InstallFileStep {
1825 pub fn init(builder: *Builder, src_path: []const u8, dest_path: []const u8) InstallFileStep {
18261826 return InstallFileStep{
18271827 .builder = builder,
18281828 .step = Step.init(builder.fmt("install {}", src_path), builder.allocator, make),
......@@ -1831,7 +1831,7 @@ pub const InstallFileStep = struct {
18311831 };
18321832 }
18331833
1834 fn make(step: &Step) !void {
1834 fn make(step: *Step) !void {
18351835 const self = @fieldParentPtr(InstallFileStep, "step", step);
18361836 try self.builder.copyFile(self.src_path, self.dest_path);
18371837 }
......@@ -1839,11 +1839,11 @@ pub const InstallFileStep = struct {
18391839
18401840pub const WriteFileStep = struct {
18411841 step: Step,
1842 builder: &Builder,
1842 builder: *Builder,
18431843 file_path: []const u8,
18441844 data: []const u8,
18451845
1846 pub fn init(builder: &Builder, file_path: []const u8, data: []const u8) WriteFileStep {
1846 pub fn init(builder: *Builder, file_path: []const u8, data: []const u8) WriteFileStep {
18471847 return WriteFileStep{
18481848 .builder = builder,
18491849 .step = Step.init(builder.fmt("writefile {}", file_path), builder.allocator, make),
......@@ -1852,7 +1852,7 @@ pub const WriteFileStep = struct {
18521852 };
18531853 }
18541854
1855 fn make(step: &Step) !void {
1855 fn make(step: *Step) !void {
18561856 const self = @fieldParentPtr(WriteFileStep, "step", step);
18571857 const full_path = self.builder.pathFromRoot(self.file_path);
18581858 const full_path_dir = os.path.dirname(full_path);
......@@ -1869,10 +1869,10 @@ pub const WriteFileStep = struct {
18691869
18701870pub const LogStep = struct {
18711871 step: Step,
1872 builder: &Builder,
1872 builder: *Builder,
18731873 data: []const u8,
18741874
1875 pub fn init(builder: &Builder, data: []const u8) LogStep {
1875 pub fn init(builder: *Builder, data: []const u8) LogStep {
18761876 return LogStep{
18771877 .builder = builder,
18781878 .step = Step.init(builder.fmt("log {}", data), builder.allocator, make),
......@@ -1880,7 +1880,7 @@ pub const LogStep = struct {
18801880 };
18811881 }
18821882
1883 fn make(step: &Step) error!void {
1883 fn make(step: *Step) error!void {
18841884 const self = @fieldParentPtr(LogStep, "step", step);
18851885 warn("{}", self.data);
18861886 }
......@@ -1888,10 +1888,10 @@ pub const LogStep = struct {
18881888
18891889pub const RemoveDirStep = struct {
18901890 step: Step,
1891 builder: &Builder,
1891 builder: *Builder,
18921892 dir_path: []const u8,
18931893
1894 pub fn init(builder: &Builder, dir_path: []const u8) RemoveDirStep {
1894 pub fn init(builder: *Builder, dir_path: []const u8) RemoveDirStep {
18951895 return RemoveDirStep{
18961896 .builder = builder,
18971897 .step = Step.init(builder.fmt("RemoveDir {}", dir_path), builder.allocator, make),
......@@ -1899,7 +1899,7 @@ pub const RemoveDirStep = struct {
18991899 };
19001900 }
19011901
1902 fn make(step: &Step) !void {
1902 fn make(step: *Step) !void {
19031903 const self = @fieldParentPtr(RemoveDirStep, "step", step);
19041904
19051905 const full_path = self.builder.pathFromRoot(self.dir_path);
......@@ -1912,39 +1912,39 @@ pub const RemoveDirStep = struct {
19121912
19131913pub const Step = struct {
19141914 name: []const u8,
1915 makeFn: fn (self: &Step) error!void,
1916 dependencies: ArrayList(&Step),
1915 makeFn: fn (self: *Step) error!void,
1916 dependencies: ArrayList(*Step),
19171917 loop_flag: bool,
19181918 done_flag: bool,
19191919
1920 pub fn init(name: []const u8, allocator: &Allocator, makeFn: fn (&Step) error!void) Step {
1920 pub fn init(name: []const u8, allocator: *Allocator, makeFn: fn (*Step) error!void) Step {
19211921 return Step{
19221922 .name = name,
19231923 .makeFn = makeFn,
1924 .dependencies = ArrayList(&Step).init(allocator),
1924 .dependencies = ArrayList(*Step).init(allocator),
19251925 .loop_flag = false,
19261926 .done_flag = false,
19271927 };
19281928 }
1929 pub fn initNoOp(name: []const u8, allocator: &Allocator) Step {
1929 pub fn initNoOp(name: []const u8, allocator: *Allocator) Step {
19301930 return init(name, allocator, makeNoOp);
19311931 }
19321932
1933 pub fn make(self: &Step) !void {
1933 pub fn make(self: *Step) !void {
19341934 if (self.done_flag) return;
19351935
19361936 try self.makeFn(self);
19371937 self.done_flag = true;
19381938 }
19391939
1940 pub fn dependOn(self: &Step, other: &Step) void {
1940 pub fn dependOn(self: *Step, other: *Step) void {
19411941 self.dependencies.append(other) catch unreachable;
19421942 }
19431943
1944 fn makeNoOp(self: &Step) error!void {}
1944 fn makeNoOp(self: *Step) error!void {}
19451945};
19461946
1947fn doAtomicSymLinks(allocator: &Allocator, output_path: []const u8, filename_major_only: []const u8, filename_name_only: []const u8) !void {
1947fn doAtomicSymLinks(allocator: *Allocator, output_path: []const u8, filename_major_only: []const u8, filename_name_only: []const u8) !void {
19481948 const out_dir = os.path.dirname(output_path);
19491949 const out_basename = os.path.basename(output_path);
19501950 // sym link for libfoo.so.1 to libfoo.so.1.2.3
std/c/darwin.zig+4-4
......@@ -1,10 +1,10 @@
1extern "c" fn __error() &c_int;
2pub extern "c" fn _NSGetExecutablePath(buf: &u8, bufsize: &u32) c_int;
1extern "c" fn __error() *c_int;
2pub extern "c" fn _NSGetExecutablePath(buf: *u8, bufsize: *u32) c_int;
33
4pub extern "c" fn __getdirentries64(fd: c_int, buf_ptr: &u8, buf_len: usize, basep: &i64) usize;
4pub extern "c" fn __getdirentries64(fd: c_int, buf_ptr: *u8, buf_len: usize, basep: *i64) usize;
55
66pub extern "c" fn mach_absolute_time() u64;
7pub extern "c" fn mach_timebase_info(tinfo: ?&mach_timebase_info_data) void;
7pub extern "c" fn mach_timebase_info(tinfo: ?*mach_timebase_info_data) void;
88
99pub use @import("../os/darwin_errno.zig");
1010
std/c/index.zig+36-36
......@@ -13,49 +13,49 @@ pub extern "c" fn abort() noreturn;
1313pub extern "c" fn exit(code: c_int) noreturn;
1414pub extern "c" fn isatty(fd: c_int) c_int;
1515pub extern "c" fn close(fd: c_int) c_int;
16pub extern "c" fn fstat(fd: c_int, buf: &Stat) c_int;
17pub extern "c" fn @"fstat$INODE64"(fd: c_int, buf: &Stat) c_int;
16pub extern "c" fn fstat(fd: c_int, buf: *Stat) c_int;
17pub extern "c" fn @"fstat$INODE64"(fd: c_int, buf: *Stat) c_int;
1818pub extern "c" fn lseek(fd: c_int, offset: isize, whence: c_int) isize;
19pub extern "c" fn open(path: &const u8, oflag: c_int, ...) c_int;
19pub extern "c" fn open(path: *const u8, oflag: c_int, ...) c_int;
2020pub extern "c" fn raise(sig: c_int) c_int;
21pub extern "c" fn read(fd: c_int, buf: &c_void, nbyte: usize) isize;
22pub extern "c" fn stat(noalias path: &const u8, noalias buf: &Stat) c_int;
23pub extern "c" fn write(fd: c_int, buf: &const c_void, nbyte: usize) isize;
24pub extern "c" fn mmap(addr: ?&c_void, len: usize, prot: c_int, flags: c_int, fd: c_int, offset: isize) ?&c_void;
25pub extern "c" fn munmap(addr: &c_void, len: usize) c_int;
26pub extern "c" fn unlink(path: &const u8) c_int;
27pub extern "c" fn getcwd(buf: &u8, size: usize) ?&u8;
28pub extern "c" fn waitpid(pid: c_int, stat_loc: &c_int, options: c_int) c_int;
21pub extern "c" fn read(fd: c_int, buf: *c_void, nbyte: usize) isize;
22pub extern "c" fn stat(noalias path: *const u8, noalias buf: *Stat) c_int;
23pub extern "c" fn write(fd: c_int, buf: *const c_void, nbyte: usize) isize;
24pub extern "c" fn mmap(addr: ?*c_void, len: usize, prot: c_int, flags: c_int, fd: c_int, offset: isize) ?*c_void;
25pub extern "c" fn munmap(addr: *c_void, len: usize) c_int;
26pub extern "c" fn unlink(path: *const u8) c_int;
27pub extern "c" fn getcwd(buf: *u8, size: usize) ?*u8;
28pub extern "c" fn waitpid(pid: c_int, stat_loc: *c_int, options: c_int) c_int;
2929pub extern "c" fn fork() c_int;
30pub extern "c" fn access(path: &const u8, mode: c_uint) c_int;
31pub extern "c" fn pipe(fds: &c_int) c_int;
32pub extern "c" fn mkdir(path: &const u8, mode: c_uint) c_int;
33pub extern "c" fn symlink(existing: &const u8, new: &const u8) c_int;
34pub extern "c" fn rename(old: &const u8, new: &const u8) c_int;
35pub extern "c" fn chdir(path: &const u8) c_int;
36pub extern "c" fn execve(path: &const u8, argv: &const ?&const u8, envp: &const ?&const u8) c_int;
30pub extern "c" fn access(path: *const u8, mode: c_uint) c_int;
31pub extern "c" fn pipe(fds: *c_int) c_int;
32pub extern "c" fn mkdir(path: *const u8, mode: c_uint) c_int;
33pub extern "c" fn symlink(existing: *const u8, new: *const u8) c_int;
34pub extern "c" fn rename(old: *const u8, new: *const u8) c_int;
35pub extern "c" fn chdir(path: *const u8) c_int;
36pub extern "c" fn execve(path: *const u8, argv: *const ?*const u8, envp: *const ?*const u8) c_int;
3737pub extern "c" fn dup(fd: c_int) c_int;
3838pub extern "c" fn dup2(old_fd: c_int, new_fd: c_int) c_int;
39pub extern "c" fn readlink(noalias path: &const u8, noalias buf: &u8, bufsize: usize) isize;
40pub extern "c" fn realpath(noalias file_name: &const u8, noalias resolved_name: &u8) ?&u8;
41pub extern "c" fn sigprocmask(how: c_int, noalias set: &const sigset_t, noalias oset: ?&sigset_t) c_int;
42pub extern "c" fn gettimeofday(tv: ?&timeval, tz: ?&timezone) c_int;
43pub extern "c" fn sigaction(sig: c_int, noalias act: &const Sigaction, noalias oact: ?&Sigaction) c_int;
44pub extern "c" fn nanosleep(rqtp: &const timespec, rmtp: ?&timespec) c_int;
39pub extern "c" fn readlink(noalias path: *const u8, noalias buf: *u8, bufsize: usize) isize;
40pub extern "c" fn realpath(noalias file_name: *const u8, noalias resolved_name: *u8) ?*u8;
41pub extern "c" fn sigprocmask(how: c_int, noalias set: *const sigset_t, noalias oset: ?*sigset_t) c_int;
42pub extern "c" fn gettimeofday(tv: ?*timeval, tz: ?*timezone) c_int;
43pub extern "c" fn sigaction(sig: c_int, noalias act: *const Sigaction, noalias oact: ?*Sigaction) c_int;
44pub extern "c" fn nanosleep(rqtp: *const timespec, rmtp: ?*timespec) c_int;
4545pub extern "c" fn setreuid(ruid: c_uint, euid: c_uint) c_int;
4646pub extern "c" fn setregid(rgid: c_uint, egid: c_uint) c_int;
47pub extern "c" fn rmdir(path: &const u8) c_int;
47pub extern "c" fn rmdir(path: *const u8) c_int;
4848
49pub extern "c" fn aligned_alloc(alignment: usize, size: usize) ?&c_void;
50pub extern "c" fn malloc(usize) ?&c_void;
51pub extern "c" fn realloc(&c_void, usize) ?&c_void;
52pub extern "c" fn free(&c_void) void;
53pub extern "c" fn posix_memalign(memptr: &&c_void, alignment: usize, size: usize) c_int;
49pub extern "c" fn aligned_alloc(alignment: usize, size: usize) ?*c_void;
50pub extern "c" fn malloc(usize) ?*c_void;
51pub extern "c" fn realloc(*c_void, usize) ?*c_void;
52pub extern "c" fn free(*c_void) void;
53pub extern "c" fn posix_memalign(memptr: **c_void, alignment: usize, size: usize) c_int;
5454
55pub extern "pthread" fn pthread_create(noalias newthread: &pthread_t, noalias attr: ?&const pthread_attr_t, start_routine: extern fn (?&c_void) ?&c_void, noalias arg: ?&c_void) c_int;
56pub extern "pthread" fn pthread_attr_init(attr: &pthread_attr_t) c_int;
57pub extern "pthread" fn pthread_attr_setstack(attr: &pthread_attr_t, stackaddr: &c_void, stacksize: usize) c_int;
58pub extern "pthread" fn pthread_attr_destroy(attr: &pthread_attr_t) c_int;
59pub extern "pthread" fn pthread_join(thread: pthread_t, arg_return: ?&?&c_void) c_int;
55pub extern "pthread" fn pthread_create(noalias newthread: *pthread_t, noalias attr: ?*const pthread_attr_t, start_routine: extern fn (?*c_void) ?*c_void, noalias arg: ?*c_void) c_int;
56pub extern "pthread" fn pthread_attr_init(attr: *pthread_attr_t) c_int;
57pub extern "pthread" fn pthread_attr_setstack(attr: *pthread_attr_t, stackaddr: *c_void, stacksize: usize) c_int;
58pub extern "pthread" fn pthread_attr_destroy(attr: *pthread_attr_t) c_int;
59pub extern "pthread" fn pthread_join(thread: pthread_t, arg_return: ?*?*c_void) c_int;
6060
61pub const pthread_t = &@OpaqueType();
61pub const pthread_t = *@OpaqueType();
std/c/linux.zig+2-2
......@@ -1,7 +1,7 @@
11pub use @import("../os/linux/errno.zig");
22
3pub extern "c" fn getrandom(buf_ptr: &u8, buf_len: usize, flags: c_uint) c_int;
4extern "c" fn __errno_location() &c_int;
3pub extern "c" fn getrandom(buf_ptr: *u8, buf_len: usize, flags: c_uint) c_int;
4extern "c" fn __errno_location() *c_int;
55pub const _errno = __errno_location;
66
77pub const pthread_attr_t = extern struct {
std/c/windows.zig+1-1
......@@ -1 +1 @@
1pub extern "c" fn _errno() &c_int;
1pub extern "c" fn _errno() *c_int;
std/crypto/blake2.zig+8-8
......@@ -75,7 +75,7 @@ fn Blake2s(comptime out_len: usize) type {
7575 return s;
7676 }
7777
78 pub fn reset(d: &Self) void {
78 pub fn reset(d: *Self) void {
7979 mem.copy(u32, d.h[0..], iv[0..]);
8080
8181 // No key plus default parameters
......@@ -90,7 +90,7 @@ fn Blake2s(comptime out_len: usize) type {
9090 d.final(out);
9191 }
9292
93 pub fn update(d: &Self, b: []const u8) void {
93 pub fn update(d: *Self, b: []const u8) void {
9494 var off: usize = 0;
9595
9696 // Partial buffer exists from previous update. Copy into buffer then hash.
......@@ -113,7 +113,7 @@ fn Blake2s(comptime out_len: usize) type {
113113 d.buf_len += u8(b[off..].len);
114114 }
115115
116 pub fn final(d: &Self, out: []u8) void {
116 pub fn final(d: *Self, out: []u8) void {
117117 debug.assert(out.len >= out_len / 8);
118118
119119 mem.set(u8, d.buf[d.buf_len..], 0);
......@@ -127,7 +127,7 @@ fn Blake2s(comptime out_len: usize) type {
127127 }
128128 }
129129
130 fn round(d: &Self, b: []const u8, last: bool) void {
130 fn round(d: *Self, b: []const u8, last: bool) void {
131131 debug.assert(b.len == 64);
132132
133133 var m: [16]u32 = undefined;
......@@ -310,7 +310,7 @@ fn Blake2b(comptime out_len: usize) type {
310310 return s;
311311 }
312312
313 pub fn reset(d: &Self) void {
313 pub fn reset(d: *Self) void {
314314 mem.copy(u64, d.h[0..], iv[0..]);
315315
316316 // No key plus default parameters
......@@ -325,7 +325,7 @@ fn Blake2b(comptime out_len: usize) type {
325325 d.final(out);
326326 }
327327
328 pub fn update(d: &Self, b: []const u8) void {
328 pub fn update(d: *Self, b: []const u8) void {
329329 var off: usize = 0;
330330
331331 // Partial buffer exists from previous update. Copy into buffer then hash.
......@@ -348,7 +348,7 @@ fn Blake2b(comptime out_len: usize) type {
348348 d.buf_len += u8(b[off..].len);
349349 }
350350
351 pub fn final(d: &Self, out: []u8) void {
351 pub fn final(d: *Self, out: []u8) void {
352352 mem.set(u8, d.buf[d.buf_len..], 0);
353353 d.t += d.buf_len;
354354 d.round(d.buf[0..], true);
......@@ -360,7 +360,7 @@ fn Blake2b(comptime out_len: usize) type {
360360 }
361361 }
362362
363 fn round(d: &Self, b: []const u8, last: bool) void {
363 fn round(d: *Self, b: []const u8, last: bool) void {
364364 debug.assert(b.len == 128);
365365
366366 var m: [16]u64 = undefined;
std/crypto/md5.zig+4-4
......@@ -44,7 +44,7 @@ pub const Md5 = struct {
4444 return d;
4545 }
4646
47 pub fn reset(d: &Self) void {
47 pub fn reset(d: *Self) void {
4848 d.s[0] = 0x67452301;
4949 d.s[1] = 0xEFCDAB89;
5050 d.s[2] = 0x98BADCFE;
......@@ -59,7 +59,7 @@ pub const Md5 = struct {
5959 d.final(out);
6060 }
6161
62 pub fn update(d: &Self, b: []const u8) void {
62 pub fn update(d: *Self, b: []const u8) void {
6363 var off: usize = 0;
6464
6565 // Partial buffer exists from previous update. Copy into buffer then hash.
......@@ -84,7 +84,7 @@ pub const Md5 = struct {
8484 d.total_len +%= b.len;
8585 }
8686
87 pub fn final(d: &Self, out: []u8) void {
87 pub fn final(d: *Self, out: []u8) void {
8888 debug.assert(out.len >= 16);
8989
9090 // The buffer here will never be completely full.
......@@ -116,7 +116,7 @@ pub const Md5 = struct {
116116 }
117117 }
118118
119 fn round(d: &Self, b: []const u8) void {
119 fn round(d: *Self, b: []const u8) void {
120120 debug.assert(b.len == 64);
121121
122122 var s: [16]u32 = undefined;
std/crypto/sha1.zig+4-4
......@@ -43,7 +43,7 @@ pub const Sha1 = struct {
4343 return d;
4444 }
4545
46 pub fn reset(d: &Self) void {
46 pub fn reset(d: *Self) void {
4747 d.s[0] = 0x67452301;
4848 d.s[1] = 0xEFCDAB89;
4949 d.s[2] = 0x98BADCFE;
......@@ -59,7 +59,7 @@ pub const Sha1 = struct {
5959 d.final(out);
6060 }
6161
62 pub fn update(d: &Self, b: []const u8) void {
62 pub fn update(d: *Self, b: []const u8) void {
6363 var off: usize = 0;
6464
6565 // Partial buffer exists from previous update. Copy into buffer then hash.
......@@ -83,7 +83,7 @@ pub const Sha1 = struct {
8383 d.total_len += b.len;
8484 }
8585
86 pub fn final(d: &Self, out: []u8) void {
86 pub fn final(d: *Self, out: []u8) void {
8787 debug.assert(out.len >= 20);
8888
8989 // The buffer here will never be completely full.
......@@ -115,7 +115,7 @@ pub const Sha1 = struct {
115115 }
116116 }
117117
118 fn round(d: &Self, b: []const u8) void {
118 fn round(d: *Self, b: []const u8) void {
119119 debug.assert(b.len == 64);
120120
121121 var s: [16]u32 = undefined;
std/crypto/sha2.zig+8-8
......@@ -93,7 +93,7 @@ fn Sha2_32(comptime params: Sha2Params32) type {
9393 return d;
9494 }
9595
96 pub fn reset(d: &Self) void {
96 pub fn reset(d: *Self) void {
9797 d.s[0] = params.iv0;
9898 d.s[1] = params.iv1;
9999 d.s[2] = params.iv2;
......@@ -112,7 +112,7 @@ fn Sha2_32(comptime params: Sha2Params32) type {
112112 d.final(out);
113113 }
114114
115 pub fn update(d: &Self, b: []const u8) void {
115 pub fn update(d: *Self, b: []const u8) void {
116116 var off: usize = 0;
117117
118118 // Partial buffer exists from previous update. Copy into buffer then hash.
......@@ -136,7 +136,7 @@ fn Sha2_32(comptime params: Sha2Params32) type {
136136 d.total_len += b.len;
137137 }
138138
139 pub fn final(d: &Self, out: []u8) void {
139 pub fn final(d: *Self, out: []u8) void {
140140 debug.assert(out.len >= params.out_len / 8);
141141
142142 // The buffer here will never be completely full.
......@@ -171,7 +171,7 @@ fn Sha2_32(comptime params: Sha2Params32) type {
171171 }
172172 }
173173
174 fn round(d: &Self, b: []const u8) void {
174 fn round(d: *Self, b: []const u8) void {
175175 debug.assert(b.len == 64);
176176
177177 var s: [64]u32 = undefined;
......@@ -434,7 +434,7 @@ fn Sha2_64(comptime params: Sha2Params64) type {
434434 return d;
435435 }
436436
437 pub fn reset(d: &Self) void {
437 pub fn reset(d: *Self) void {
438438 d.s[0] = params.iv0;
439439 d.s[1] = params.iv1;
440440 d.s[2] = params.iv2;
......@@ -453,7 +453,7 @@ fn Sha2_64(comptime params: Sha2Params64) type {
453453 d.final(out);
454454 }
455455
456 pub fn update(d: &Self, b: []const u8) void {
456 pub fn update(d: *Self, b: []const u8) void {
457457 var off: usize = 0;
458458
459459 // Partial buffer exists from previous update. Copy into buffer then hash.
......@@ -477,7 +477,7 @@ fn Sha2_64(comptime params: Sha2Params64) type {
477477 d.total_len += b.len;
478478 }
479479
480 pub fn final(d: &Self, out: []u8) void {
480 pub fn final(d: *Self, out: []u8) void {
481481 debug.assert(out.len >= params.out_len / 8);
482482
483483 // The buffer here will never be completely full.
......@@ -512,7 +512,7 @@ fn Sha2_64(comptime params: Sha2Params64) type {
512512 }
513513 }
514514
515 fn round(d: &Self, b: []const u8) void {
515 fn round(d: *Self, b: []const u8) void {
516516 debug.assert(b.len == 128);
517517
518518 var s: [80]u64 = undefined;
std/crypto/sha3.zig+3-3
......@@ -26,7 +26,7 @@ fn Keccak(comptime bits: usize, comptime delim: u8) type {
2626 return d;
2727 }
2828
29 pub fn reset(d: &Self) void {
29 pub fn reset(d: *Self) void {
3030 mem.set(u8, d.s[0..], 0);
3131 d.offset = 0;
3232 d.rate = 200 - (bits / 4);
......@@ -38,7 +38,7 @@ fn Keccak(comptime bits: usize, comptime delim: u8) type {
3838 d.final(out);
3939 }
4040
41 pub fn update(d: &Self, b: []const u8) void {
41 pub fn update(d: *Self, b: []const u8) void {
4242 var ip: usize = 0;
4343 var len = b.len;
4444 var rate = d.rate - d.offset;
......@@ -63,7 +63,7 @@ fn Keccak(comptime bits: usize, comptime delim: u8) type {
6363 d.offset = offset + len;
6464 }
6565
66 pub fn final(d: &Self, out: []u8) void {
66 pub fn final(d: *Self, out: []u8) void {
6767 // padding
6868 d.s[d.offset] ^= delim;
6969 d.s[d.rate - 1] ^= 0x80;
std/crypto/throughput_test.zig+2-2
......@@ -15,8 +15,8 @@ const BytesToHash = 1024 * MiB;
1515
1616pub fn main() !void {
1717 var stdout_file = try std.io.getStdOut();
18 var stdout_out_stream = std.io.FileOutStream.init(&stdout_file);
19 const stdout = &stdout_out_stream.stream;
18 var stdout_out_stream = std.io.FileOutStream.init(*stdout_file);
19 const stdout = *stdout_out_stream.stream;
2020
2121 var block: [HashFunction.block_size]u8 = undefined;
2222 std.mem.set(u8, block[0..], 0);
std/cstr.zig+13-13
......@@ -9,13 +9,13 @@ pub const line_sep = switch (builtin.os) {
99 else => "\n",
1010};
1111
12pub fn len(ptr: &const u8) usize {
12pub fn len(ptr: *const u8) usize {
1313 var count: usize = 0;
1414 while (ptr[count] != 0) : (count += 1) {}
1515 return count;
1616}
1717
18pub fn cmp(a: &const u8, b: &const u8) i8 {
18pub fn cmp(a: *const u8, b: *const u8) i8 {
1919 var index: usize = 0;
2020 while (a[index] == b[index] and a[index] != 0) : (index += 1) {}
2121 if (a[index] > b[index]) {
......@@ -27,11 +27,11 @@ pub fn cmp(a: &const u8, b: &const u8) i8 {
2727 }
2828}
2929
30pub fn toSliceConst(str: &const u8) []const u8 {
30pub fn toSliceConst(str: *const u8) []const u8 {
3131 return str[0..len(str)];
3232}
3333
34pub fn toSlice(str: &u8) []u8 {
34pub fn toSlice(str: *u8) []u8 {
3535 return str[0..len(str)];
3636}
3737
......@@ -47,7 +47,7 @@ fn testCStrFnsImpl() void {
4747
4848/// Returns a mutable slice with 1 more byte of length which is a null byte.
4949/// Caller owns the returned memory.
50pub fn addNullByte(allocator: &mem.Allocator, slice: []const u8) ![]u8 {
50pub fn addNullByte(allocator: *mem.Allocator, slice: []const u8) ![]u8 {
5151 const result = try allocator.alloc(u8, slice.len + 1);
5252 mem.copy(u8, result, slice);
5353 result[slice.len] = 0;
......@@ -55,13 +55,13 @@ pub fn addNullByte(allocator: &mem.Allocator, slice: []const u8) ![]u8 {
5555}
5656
5757pub const NullTerminated2DArray = struct {
58 allocator: &mem.Allocator,
58 allocator: *mem.Allocator,
5959 byte_count: usize,
60 ptr: ?&?&u8,
60 ptr: ?*?*u8,
6161
6262 /// Takes N lists of strings, concatenates the lists together, and adds a null terminator
6363 /// Caller must deinit result
64 pub fn fromSlices(allocator: &mem.Allocator, slices: []const []const []const u8) !NullTerminated2DArray {
64 pub fn fromSlices(allocator: *mem.Allocator, slices: []const []const []const u8) !NullTerminated2DArray {
6565 var new_len: usize = 1; // 1 for the list null
6666 var byte_count: usize = 0;
6767 for (slices) |slice| {
......@@ -75,11 +75,11 @@ pub const NullTerminated2DArray = struct {
7575 const index_size = @sizeOf(usize) * new_len; // size of the ptrs
7676 byte_count += index_size;
7777
78 const buf = try allocator.alignedAlloc(u8, @alignOf(?&u8), byte_count);
78 const buf = try allocator.alignedAlloc(u8, @alignOf(?*u8), byte_count);
7979 errdefer allocator.free(buf);
8080
8181 var write_index = index_size;
82 const index_buf = ([]?&u8)(buf);
82 const index_buf = ([]?*u8)(buf);
8383
8484 var i: usize = 0;
8585 for (slices) |slice| {
......@@ -97,12 +97,12 @@ pub const NullTerminated2DArray = struct {
9797 return NullTerminated2DArray{
9898 .allocator = allocator,
9999 .byte_count = byte_count,
100 .ptr = @ptrCast(?&?&u8, buf.ptr),
100 .ptr = @ptrCast(?*?*u8, buf.ptr),
101101 };
102102 }
103103
104 pub fn deinit(self: &NullTerminated2DArray) void {
105 const buf = @ptrCast(&u8, self.ptr);
104 pub fn deinit(self: *NullTerminated2DArray) void {
105 const buf = @ptrCast(*u8, self.ptr);
106106 self.allocator.free(buf[0..self.byte_count]);
107107 }
108108};
std/debug/failing_allocator.zig+5-5
......@@ -7,12 +7,12 @@ pub const FailingAllocator = struct {
77 allocator: mem.Allocator,
88 index: usize,
99 fail_index: usize,
10 internal_allocator: &mem.Allocator,
10 internal_allocator: *mem.Allocator,
1111 allocated_bytes: usize,
1212 freed_bytes: usize,
1313 deallocations: usize,
1414
15 pub fn init(allocator: &mem.Allocator, fail_index: usize) FailingAllocator {
15 pub fn init(allocator: *mem.Allocator, fail_index: usize) FailingAllocator {
1616 return FailingAllocator{
1717 .internal_allocator = allocator,
1818 .fail_index = fail_index,
......@@ -28,7 +28,7 @@ pub const FailingAllocator = struct {
2828 };
2929 }
3030
31 fn alloc(allocator: &mem.Allocator, n: usize, alignment: u29) ![]u8 {
31 fn alloc(allocator: *mem.Allocator, n: usize, alignment: u29) ![]u8 {
3232 const self = @fieldParentPtr(FailingAllocator, "allocator", allocator);
3333 if (self.index == self.fail_index) {
3434 return error.OutOfMemory;
......@@ -39,7 +39,7 @@ pub const FailingAllocator = struct {
3939 return result;
4040 }
4141
42 fn realloc(allocator: &mem.Allocator, old_mem: []u8, new_size: usize, alignment: u29) ![]u8 {
42 fn realloc(allocator: *mem.Allocator, old_mem: []u8, new_size: usize, alignment: u29) ![]u8 {
4343 const self = @fieldParentPtr(FailingAllocator, "allocator", allocator);
4444 if (new_size <= old_mem.len) {
4545 self.freed_bytes += old_mem.len - new_size;
......@@ -55,7 +55,7 @@ pub const FailingAllocator = struct {
5555 return result;
5656 }
5757
58 fn free(allocator: &mem.Allocator, bytes: []u8) void {
58 fn free(allocator: *mem.Allocator, bytes: []u8) void {
5959 const self = @fieldParentPtr(FailingAllocator, "allocator", allocator);
6060 self.freed_bytes += bytes.len;
6161 self.deallocations += 1;
std/debug/index.zig+53-53
......@@ -16,12 +16,12 @@ pub const FailingAllocator = @import("failing_allocator.zig").FailingAllocator;
1616/// TODO atomic/multithread support
1717var stderr_file: os.File = undefined;
1818var stderr_file_out_stream: io.FileOutStream = undefined;
19var stderr_stream: ?&io.OutStream(io.FileOutStream.Error) = null;
19var stderr_stream: ?*io.OutStream(io.FileOutStream.Error) = null;
2020pub fn warn(comptime fmt: []const u8, args: ...) void {
2121 const stderr = getStderrStream() catch return;
2222 stderr.print(fmt, args) catch return;
2323}
24fn getStderrStream() !&io.OutStream(io.FileOutStream.Error) {
24fn getStderrStream() !*io.OutStream(io.FileOutStream.Error) {
2525 if (stderr_stream) |st| {
2626 return st;
2727 } else {
......@@ -33,8 +33,8 @@ fn getStderrStream() !&io.OutStream(io.FileOutStream.Error) {
3333 }
3434}
3535
36var self_debug_info: ?&ElfStackTrace = null;
37pub fn getSelfDebugInfo() !&ElfStackTrace {
36var self_debug_info: ?*ElfStackTrace = null;
37pub fn getSelfDebugInfo() !*ElfStackTrace {
3838 if (self_debug_info) |info| {
3939 return info;
4040 } else {
......@@ -58,7 +58,7 @@ pub fn dumpCurrentStackTrace(start_addr: ?usize) void {
5858}
5959
6060/// Tries to print a stack trace to stderr, unbuffered, and ignores any error returned.
61pub fn dumpStackTrace(stack_trace: &const builtin.StackTrace) void {
61pub fn dumpStackTrace(stack_trace: *const builtin.StackTrace) void {
6262 const stderr = getStderrStream() catch return;
6363 const debug_info = getSelfDebugInfo() catch |err| {
6464 stderr.print("Unable to dump stack trace: Unable to open debug info: {}\n", @errorName(err)) catch return;
......@@ -104,7 +104,7 @@ pub fn panic(comptime format: []const u8, args: ...) noreturn {
104104
105105var panicking: u8 = 0; // TODO make this a bool
106106
107pub fn panicExtra(trace: ?&const builtin.StackTrace, first_trace_addr: ?usize, comptime format: []const u8, args: ...) noreturn {
107pub fn panicExtra(trace: ?*const builtin.StackTrace, first_trace_addr: ?usize, comptime format: []const u8, args: ...) noreturn {
108108 @setCold(true);
109109
110110 if (@atomicRmw(u8, &panicking, builtin.AtomicRmwOp.Xchg, 1, builtin.AtomicOrder.SeqCst) == 1) {
......@@ -130,7 +130,7 @@ const WHITE = "\x1b[37;1m";
130130const DIM = "\x1b[2m";
131131const RESET = "\x1b[0m";
132132
133pub fn writeStackTrace(stack_trace: &const builtin.StackTrace, out_stream: var, allocator: &mem.Allocator, debug_info: &ElfStackTrace, tty_color: bool) !void {
133pub fn writeStackTrace(stack_trace: *const builtin.StackTrace, out_stream: var, allocator: *mem.Allocator, debug_info: *ElfStackTrace, tty_color: bool) !void {
134134 var frame_index: usize = undefined;
135135 var frames_left: usize = undefined;
136136 if (stack_trace.index < stack_trace.instruction_addresses.len) {
......@@ -150,7 +150,7 @@ pub fn writeStackTrace(stack_trace: &const builtin.StackTrace, out_stream: var,
150150 }
151151}
152152
153pub fn writeCurrentStackTrace(out_stream: var, allocator: &mem.Allocator, debug_info: &ElfStackTrace, tty_color: bool, start_addr: ?usize) !void {
153pub fn writeCurrentStackTrace(out_stream: var, allocator: *mem.Allocator, debug_info: *ElfStackTrace, tty_color: bool, start_addr: ?usize) !void {
154154 const AddressState = union(enum) {
155155 NotLookingForStartAddress,
156156 LookingForStartAddress: usize,
......@@ -166,8 +166,8 @@ pub fn writeCurrentStackTrace(out_stream: var, allocator: &mem.Allocator, debug_
166166 }
167167
168168 var fp = @ptrToInt(@frameAddress());
169 while (fp != 0) : (fp = @intToPtr(&const usize, fp).*) {
170 const return_address = @intToPtr(&const usize, fp + @sizeOf(usize)).*;
169 while (fp != 0) : (fp = @intToPtr(*const usize, fp).*) {
170 const return_address = @intToPtr(*const usize, fp + @sizeOf(usize)).*;
171171
172172 switch (addr_state) {
173173 AddressState.NotLookingForStartAddress => {},
......@@ -183,7 +183,7 @@ pub fn writeCurrentStackTrace(out_stream: var, allocator: &mem.Allocator, debug_
183183 }
184184}
185185
186fn printSourceAtAddress(debug_info: &ElfStackTrace, out_stream: var, address: usize) !void {
186fn printSourceAtAddress(debug_info: *ElfStackTrace, out_stream: var, address: usize) !void {
187187 const ptr_hex = "0x{x}";
188188
189189 switch (builtin.os) {
......@@ -236,7 +236,7 @@ fn printSourceAtAddress(debug_info: &ElfStackTrace, out_stream: var, address: us
236236 }
237237}
238238
239pub fn openSelfDebugInfo(allocator: &mem.Allocator) !&ElfStackTrace {
239pub fn openSelfDebugInfo(allocator: *mem.Allocator) !*ElfStackTrace {
240240 switch (builtin.object_format) {
241241 builtin.ObjectFormat.elf => {
242242 const st = try allocator.create(ElfStackTrace);
......@@ -289,7 +289,7 @@ pub fn openSelfDebugInfo(allocator: &mem.Allocator) !&ElfStackTrace {
289289 }
290290}
291291
292fn printLineFromFile(allocator: &mem.Allocator, out_stream: var, line_info: &const LineInfo) !void {
292fn printLineFromFile(allocator: *mem.Allocator, out_stream: var, line_info: *const LineInfo) !void {
293293 var f = try os.File.openRead(allocator, line_info.file_name);
294294 defer f.close();
295295 // TODO fstat and make sure that the file has the correct size
......@@ -325,32 +325,32 @@ pub const ElfStackTrace = switch (builtin.os) {
325325 builtin.Os.macosx => struct {
326326 symbol_table: macho.SymbolTable,
327327
328 pub fn close(self: &ElfStackTrace) void {
328 pub fn close(self: *ElfStackTrace) void {
329329 self.symbol_table.deinit();
330330 }
331331 },
332332 else => struct {
333333 self_exe_file: os.File,
334334 elf: elf.Elf,
335 debug_info: &elf.SectionHeader,
336 debug_abbrev: &elf.SectionHeader,
337 debug_str: &elf.SectionHeader,
338 debug_line: &elf.SectionHeader,
339 debug_ranges: ?&elf.SectionHeader,
335 debug_info: *elf.SectionHeader,
336 debug_abbrev: *elf.SectionHeader,
337 debug_str: *elf.SectionHeader,
338 debug_line: *elf.SectionHeader,
339 debug_ranges: ?*elf.SectionHeader,
340340 abbrev_table_list: ArrayList(AbbrevTableHeader),
341341 compile_unit_list: ArrayList(CompileUnit),
342342
343 pub fn allocator(self: &const ElfStackTrace) &mem.Allocator {
343 pub fn allocator(self: *const ElfStackTrace) *mem.Allocator {
344344 return self.abbrev_table_list.allocator;
345345 }
346346
347 pub fn readString(self: &ElfStackTrace) ![]u8 {
347 pub fn readString(self: *ElfStackTrace) ![]u8 {
348348 var in_file_stream = io.FileInStream.init(&self.self_exe_file);
349349 const in_stream = &in_file_stream.stream;
350350 return readStringRaw(self.allocator(), in_stream);
351351 }
352352
353 pub fn close(self: &ElfStackTrace) void {
353 pub fn close(self: *ElfStackTrace) void {
354354 self.self_exe_file.close();
355355 self.elf.close();
356356 }
......@@ -365,7 +365,7 @@ const PcRange = struct {
365365const CompileUnit = struct {
366366 version: u16,
367367 is_64: bool,
368 die: &Die,
368 die: *Die,
369369 index: usize,
370370 pc_range: ?PcRange,
371371};
......@@ -408,7 +408,7 @@ const Constant = struct {
408408 payload: []u8,
409409 signed: bool,
410410
411 fn asUnsignedLe(self: &const Constant) !u64 {
411 fn asUnsignedLe(self: *const Constant) !u64 {
412412 if (self.payload.len > @sizeOf(u64)) return error.InvalidDebugInfo;
413413 if (self.signed) return error.InvalidDebugInfo;
414414 return mem.readInt(self.payload, u64, builtin.Endian.Little);
......@@ -425,14 +425,14 @@ const Die = struct {
425425 value: FormValue,
426426 };
427427
428 fn getAttr(self: &const Die, id: u64) ?&const FormValue {
428 fn getAttr(self: *const Die, id: u64) ?*const FormValue {
429429 for (self.attrs.toSliceConst()) |*attr| {
430430 if (attr.id == id) return &attr.value;
431431 }
432432 return null;
433433 }
434434
435 fn getAttrAddr(self: &const Die, id: u64) !u64 {
435 fn getAttrAddr(self: *const Die, id: u64) !u64 {
436436 const form_value = self.getAttr(id) ?? return error.MissingDebugInfo;
437437 return switch (form_value.*) {
438438 FormValue.Address => |value| value,
......@@ -440,7 +440,7 @@ const Die = struct {
440440 };
441441 }
442442
443 fn getAttrSecOffset(self: &const Die, id: u64) !u64 {
443 fn getAttrSecOffset(self: *const Die, id: u64) !u64 {
444444 const form_value = self.getAttr(id) ?? return error.MissingDebugInfo;
445445 return switch (form_value.*) {
446446 FormValue.Const => |value| value.asUnsignedLe(),
......@@ -449,7 +449,7 @@ const Die = struct {
449449 };
450450 }
451451
452 fn getAttrUnsignedLe(self: &const Die, id: u64) !u64 {
452 fn getAttrUnsignedLe(self: *const Die, id: u64) !u64 {
453453 const form_value = self.getAttr(id) ?? return error.MissingDebugInfo;
454454 return switch (form_value.*) {
455455 FormValue.Const => |value| value.asUnsignedLe(),
......@@ -457,7 +457,7 @@ const Die = struct {
457457 };
458458 }
459459
460 fn getAttrString(self: &const Die, st: &ElfStackTrace, id: u64) ![]u8 {
460 fn getAttrString(self: *const Die, st: *ElfStackTrace, id: u64) ![]u8 {
461461 const form_value = self.getAttr(id) ?? return error.MissingDebugInfo;
462462 return switch (form_value.*) {
463463 FormValue.String => |value| value,
......@@ -478,9 +478,9 @@ const LineInfo = struct {
478478 line: usize,
479479 column: usize,
480480 file_name: []u8,
481 allocator: &mem.Allocator,
481 allocator: *mem.Allocator,
482482
483 fn deinit(self: &const LineInfo) void {
483 fn deinit(self: *const LineInfo) void {
484484 self.allocator.free(self.file_name);
485485 }
486486};
......@@ -496,7 +496,7 @@ const LineNumberProgram = struct {
496496
497497 target_address: usize,
498498 include_dirs: []const []const u8,
499 file_entries: &ArrayList(FileEntry),
499 file_entries: *ArrayList(FileEntry),
500500
501501 prev_address: usize,
502502 prev_file: usize,
......@@ -506,7 +506,7 @@ const LineNumberProgram = struct {
506506 prev_basic_block: bool,
507507 prev_end_sequence: bool,
508508
509 pub fn init(is_stmt: bool, include_dirs: []const []const u8, file_entries: &ArrayList(FileEntry), target_address: usize) LineNumberProgram {
509 pub fn init(is_stmt: bool, include_dirs: []const []const u8, file_entries: *ArrayList(FileEntry), target_address: usize) LineNumberProgram {
510510 return LineNumberProgram{
511511 .address = 0,
512512 .file = 1,
......@@ -528,7 +528,7 @@ const LineNumberProgram = struct {
528528 };
529529 }
530530
531 pub fn checkLineMatch(self: &LineNumberProgram) !?LineInfo {
531 pub fn checkLineMatch(self: *LineNumberProgram) !?LineInfo {
532532 if (self.target_address >= self.prev_address and self.target_address < self.address) {
533533 const file_entry = if (self.prev_file == 0) {
534534 return error.MissingDebugInfo;
......@@ -562,7 +562,7 @@ const LineNumberProgram = struct {
562562 }
563563};
564564
565fn readStringRaw(allocator: &mem.Allocator, in_stream: var) ![]u8 {
565fn readStringRaw(allocator: *mem.Allocator, in_stream: var) ![]u8 {
566566 var buf = ArrayList(u8).init(allocator);
567567 while (true) {
568568 const byte = try in_stream.readByte();
......@@ -572,30 +572,30 @@ fn readStringRaw(allocator: &mem.Allocator, in_stream: var) ![]u8 {
572572 return buf.toSlice();
573573}
574574
575fn getString(st: &ElfStackTrace, offset: u64) ![]u8 {
575fn getString(st: *ElfStackTrace, offset: u64) ![]u8 {
576576 const pos = st.debug_str.offset + offset;
577577 try st.self_exe_file.seekTo(pos);
578578 return st.readString();
579579}
580580
581fn readAllocBytes(allocator: &mem.Allocator, in_stream: var, size: usize) ![]u8 {
581fn readAllocBytes(allocator: *mem.Allocator, in_stream: var, size: usize) ![]u8 {
582582 const buf = try allocator.alloc(u8, size);
583583 errdefer allocator.free(buf);
584584 if ((try in_stream.read(buf)) < size) return error.EndOfFile;
585585 return buf;
586586}
587587
588fn parseFormValueBlockLen(allocator: &mem.Allocator, in_stream: var, size: usize) !FormValue {
588fn parseFormValueBlockLen(allocator: *mem.Allocator, in_stream: var, size: usize) !FormValue {
589589 const buf = try readAllocBytes(allocator, in_stream, size);
590590 return FormValue{ .Block = buf };
591591}
592592
593fn parseFormValueBlock(allocator: &mem.Allocator, in_stream: var, size: usize) !FormValue {
593fn parseFormValueBlock(allocator: *mem.Allocator, in_stream: var, size: usize) !FormValue {
594594 const block_len = try in_stream.readVarInt(builtin.Endian.Little, usize, size);
595595 return parseFormValueBlockLen(allocator, in_stream, block_len);
596596}
597597
598fn parseFormValueConstant(allocator: &mem.Allocator, in_stream: var, signed: bool, size: usize) !FormValue {
598fn parseFormValueConstant(allocator: *mem.Allocator, in_stream: var, signed: bool, size: usize) !FormValue {
599599 return FormValue{
600600 .Const = Constant{
601601 .signed = signed,
......@@ -612,12 +612,12 @@ fn parseFormValueTargetAddrSize(in_stream: var) !u64 {
612612 return if (@sizeOf(usize) == 4) u64(try in_stream.readIntLe(u32)) else if (@sizeOf(usize) == 8) try in_stream.readIntLe(u64) else unreachable;
613613}
614614
615fn parseFormValueRefLen(allocator: &mem.Allocator, in_stream: var, size: usize) !FormValue {
615fn parseFormValueRefLen(allocator: *mem.Allocator, in_stream: var, size: usize) !FormValue {
616616 const buf = try readAllocBytes(allocator, in_stream, size);
617617 return FormValue{ .Ref = buf };
618618}
619619
620fn parseFormValueRef(allocator: &mem.Allocator, in_stream: var, comptime T: type) !FormValue {
620fn parseFormValueRef(allocator: *mem.Allocator, in_stream: var, comptime T: type) !FormValue {
621621 const block_len = try in_stream.readIntLe(T);
622622 return parseFormValueRefLen(allocator, in_stream, block_len);
623623}
......@@ -632,7 +632,7 @@ const ParseFormValueError = error{
632632 OutOfMemory,
633633};
634634
635fn parseFormValue(allocator: &mem.Allocator, in_stream: var, form_id: u64, is_64: bool) ParseFormValueError!FormValue {
635fn parseFormValue(allocator: *mem.Allocator, in_stream: var, form_id: u64, is_64: bool) ParseFormValueError!FormValue {
636636 return switch (form_id) {
637637 DW.FORM_addr => FormValue{ .Address = try parseFormValueTargetAddrSize(in_stream) },
638638 DW.FORM_block1 => parseFormValueBlock(allocator, in_stream, 1),
......@@ -682,7 +682,7 @@ fn parseFormValue(allocator: &mem.Allocator, in_stream: var, form_id: u64, is_64
682682 };
683683}
684684
685fn parseAbbrevTable(st: &ElfStackTrace) !AbbrevTable {
685fn parseAbbrevTable(st: *ElfStackTrace) !AbbrevTable {
686686 const in_file = &st.self_exe_file;
687687 var in_file_stream = io.FileInStream.init(in_file);
688688 const in_stream = &in_file_stream.stream;
......@@ -712,7 +712,7 @@ fn parseAbbrevTable(st: &ElfStackTrace) !AbbrevTable {
712712
713713/// Gets an already existing AbbrevTable given the abbrev_offset, or if not found,
714714/// seeks in the stream and parses it.
715fn getAbbrevTable(st: &ElfStackTrace, abbrev_offset: u64) !&const AbbrevTable {
715fn getAbbrevTable(st: *ElfStackTrace, abbrev_offset: u64) !*const AbbrevTable {
716716 for (st.abbrev_table_list.toSlice()) |*header| {
717717 if (header.offset == abbrev_offset) {
718718 return &header.table;
......@@ -726,14 +726,14 @@ fn getAbbrevTable(st: &ElfStackTrace, abbrev_offset: u64) !&const AbbrevTable {
726726 return &st.abbrev_table_list.items[st.abbrev_table_list.len - 1].table;
727727}
728728
729fn getAbbrevTableEntry(abbrev_table: &const AbbrevTable, abbrev_code: u64) ?&const AbbrevTableEntry {
729fn getAbbrevTableEntry(abbrev_table: *const AbbrevTable, abbrev_code: u64) ?*const AbbrevTableEntry {
730730 for (abbrev_table.toSliceConst()) |*table_entry| {
731731 if (table_entry.abbrev_code == abbrev_code) return table_entry;
732732 }
733733 return null;
734734}
735735
736fn parseDie(st: &ElfStackTrace, abbrev_table: &const AbbrevTable, is_64: bool) !Die {
736fn parseDie(st: *ElfStackTrace, abbrev_table: *const AbbrevTable, is_64: bool) !Die {
737737 const in_file = &st.self_exe_file;
738738 var in_file_stream = io.FileInStream.init(in_file);
739739 const in_stream = &in_file_stream.stream;
......@@ -755,7 +755,7 @@ fn parseDie(st: &ElfStackTrace, abbrev_table: &const AbbrevTable, is_64: bool) !
755755 return result;
756756}
757757
758fn getLineNumberInfo(st: &ElfStackTrace, compile_unit: &const CompileUnit, target_address: usize) !LineInfo {
758fn getLineNumberInfo(st: *ElfStackTrace, compile_unit: *const CompileUnit, target_address: usize) !LineInfo {
759759 const compile_unit_cwd = try compile_unit.die.getAttrString(st, DW.AT_comp_dir);
760760
761761 const in_file = &st.self_exe_file;
......@@ -934,7 +934,7 @@ fn getLineNumberInfo(st: &ElfStackTrace, compile_unit: &const CompileUnit, targe
934934 return error.MissingDebugInfo;
935935}
936936
937fn scanAllCompileUnits(st: &ElfStackTrace) !void {
937fn scanAllCompileUnits(st: *ElfStackTrace) !void {
938938 const debug_info_end = st.debug_info.offset + st.debug_info.size;
939939 var this_unit_offset = st.debug_info.offset;
940940 var cu_index: usize = 0;
......@@ -1005,7 +1005,7 @@ fn scanAllCompileUnits(st: &ElfStackTrace) !void {
10051005 }
10061006}
10071007
1008fn findCompileUnit(st: &ElfStackTrace, target_address: u64) !&const CompileUnit {
1008fn findCompileUnit(st: *ElfStackTrace, target_address: u64) !*const CompileUnit {
10091009 var in_file_stream = io.FileInStream.init(&st.self_exe_file);
10101010 const in_stream = &in_file_stream.stream;
10111011 for (st.compile_unit_list.toSlice()) |*compile_unit| {
......@@ -1039,7 +1039,7 @@ fn findCompileUnit(st: &ElfStackTrace, target_address: u64) !&const CompileUnit
10391039 return error.MissingDebugInfo;
10401040}
10411041
1042fn readInitialLength(comptime E: type, in_stream: &io.InStream(E), is_64: &bool) !u64 {
1042fn readInitialLength(comptime E: type, in_stream: *io.InStream(E), is_64: *bool) !u64 {
10431043 const first_32_bits = try in_stream.readIntLe(u32);
10441044 is_64.* = (first_32_bits == 0xffffffff);
10451045 if (is_64.*) {
......@@ -1096,10 +1096,10 @@ var global_fixed_allocator = std.heap.FixedBufferAllocator.init(global_allocator
10961096var global_allocator_mem: [100 * 1024]u8 = undefined;
10971097
10981098// TODO make thread safe
1099var debug_info_allocator: ?&mem.Allocator = null;
1099var debug_info_allocator: ?*mem.Allocator = null;
11001100var debug_info_direct_allocator: std.heap.DirectAllocator = undefined;
11011101var debug_info_arena_allocator: std.heap.ArenaAllocator = undefined;
1102fn getDebugInfoAllocator() &mem.Allocator {
1102fn getDebugInfoAllocator() *mem.Allocator {
11031103 if (debug_info_allocator) |a| return a;
11041104
11051105 debug_info_direct_allocator = std.heap.DirectAllocator.init();
std/elf.zig+9-9
......@@ -338,7 +338,7 @@ pub const SectionHeader = struct {
338338};
339339
340340pub const Elf = struct {
341 in_file: &os.File,
341 in_file: *os.File,
342342 auto_close_stream: bool,
343343 is_64: bool,
344344 endian: builtin.Endian,
......@@ -348,20 +348,20 @@ pub const Elf = struct {
348348 program_header_offset: u64,
349349 section_header_offset: u64,
350350 string_section_index: u64,
351 string_section: &SectionHeader,
351 string_section: *SectionHeader,
352352 section_headers: []SectionHeader,
353 allocator: &mem.Allocator,
353 allocator: *mem.Allocator,
354354 prealloc_file: os.File,
355355
356356 /// Call close when done.
357 pub fn openPath(elf: &Elf, allocator: &mem.Allocator, path: []const u8) !void {
357 pub fn openPath(elf: *Elf, allocator: *mem.Allocator, path: []const u8) !void {
358358 try elf.prealloc_file.open(path);
359 try elf.openFile(allocator, &elf.prealloc_file);
359 try elf.openFile(allocator, *elf.prealloc_file);
360360 elf.auto_close_stream = true;
361361 }
362362
363363 /// Call close when done.
364 pub fn openFile(elf: &Elf, allocator: &mem.Allocator, file: &os.File) !void {
364 pub fn openFile(elf: *Elf, allocator: *mem.Allocator, file: *os.File) !void {
365365 elf.allocator = allocator;
366366 elf.in_file = file;
367367 elf.auto_close_stream = false;
......@@ -503,13 +503,13 @@ pub const Elf = struct {
503503 }
504504 }
505505
506 pub fn close(elf: &Elf) void {
506 pub fn close(elf: *Elf) void {
507507 elf.allocator.free(elf.section_headers);
508508
509509 if (elf.auto_close_stream) elf.in_file.close();
510510 }
511511
512 pub fn findSection(elf: &Elf, name: []const u8) !?&SectionHeader {
512 pub fn findSection(elf: *Elf, name: []const u8) !?*SectionHeader {
513513 var file_stream = io.FileInStream.init(elf.in_file);
514514 const in = &file_stream.stream;
515515
......@@ -533,7 +533,7 @@ pub const Elf = struct {
533533 return null;
534534 }
535535
536 pub fn seekToSection(elf: &Elf, elf_section: &SectionHeader) !void {
536 pub fn seekToSection(elf: *Elf, elf_section: *SectionHeader) !void {
537537 try elf.in_file.seekTo(elf_section.offset);
538538 }
539539};
std/event.zig+17-17
......@@ -6,9 +6,9 @@ const mem = std.mem;
66const posix = std.os.posix;
77
88pub const TcpServer = struct {
9 handleRequestFn: async<&mem.Allocator> fn (&TcpServer, &const std.net.Address, &const std.os.File) void,
9 handleRequestFn: async<*mem.Allocator> fn (*TcpServer, *const std.net.Address, *const std.os.File) void,
1010
11 loop: &Loop,
11 loop: *Loop,
1212 sockfd: i32,
1313 accept_coro: ?promise,
1414 listen_address: std.net.Address,
......@@ -17,7 +17,7 @@ pub const TcpServer = struct {
1717
1818 const PromiseNode = std.LinkedList(promise).Node;
1919
20 pub fn init(loop: &Loop) !TcpServer {
20 pub fn init(loop: *Loop) !TcpServer {
2121 const sockfd = try std.os.posixSocket(posix.AF_INET, posix.SOCK_STREAM | posix.SOCK_CLOEXEC | posix.SOCK_NONBLOCK, posix.PROTO_tcp);
2222 errdefer std.os.close(sockfd);
2323
......@@ -32,7 +32,7 @@ pub const TcpServer = struct {
3232 };
3333 }
3434
35 pub fn listen(self: &TcpServer, address: &const std.net.Address, handleRequestFn: async<&mem.Allocator> fn (&TcpServer, &const std.net.Address, &const std.os.File) void) !void {
35 pub fn listen(self: *TcpServer, address: *const std.net.Address, handleRequestFn: async<*mem.Allocator> fn (*TcpServer, *const std.net.Address, *const std.os.File) void) !void {
3636 self.handleRequestFn = handleRequestFn;
3737
3838 try std.os.posixBind(self.sockfd, &address.os_addr);
......@@ -46,13 +46,13 @@ pub const TcpServer = struct {
4646 errdefer self.loop.removeFd(self.sockfd);
4747 }
4848
49 pub fn deinit(self: &TcpServer) void {
49 pub fn deinit(self: *TcpServer) void {
5050 self.loop.removeFd(self.sockfd);
5151 if (self.accept_coro) |accept_coro| cancel accept_coro;
5252 std.os.close(self.sockfd);
5353 }
5454
55 pub async fn handler(self: &TcpServer) void {
55 pub async fn handler(self: *TcpServer) void {
5656 while (true) {
5757 var accepted_addr: std.net.Address = undefined;
5858 if (std.os.posixAccept(self.sockfd, &accepted_addr.os_addr, posix.SOCK_NONBLOCK | posix.SOCK_CLOEXEC)) |accepted_fd| {
......@@ -92,11 +92,11 @@ pub const TcpServer = struct {
9292};
9393
9494pub const Loop = struct {
95 allocator: &mem.Allocator,
95 allocator: *mem.Allocator,
9696 epollfd: i32,
9797 keep_running: bool,
9898
99 fn init(allocator: &mem.Allocator) !Loop {
99 fn init(allocator: *mem.Allocator) !Loop {
100100 const epollfd = try std.os.linuxEpollCreate(std.os.linux.EPOLL_CLOEXEC);
101101 return Loop{
102102 .keep_running = true,
......@@ -105,7 +105,7 @@ pub const Loop = struct {
105105 };
106106 }
107107
108 pub fn addFd(self: &Loop, fd: i32, prom: promise) !void {
108 pub fn addFd(self: *Loop, fd: i32, prom: promise) !void {
109109 var ev = std.os.linux.epoll_event{
110110 .events = std.os.linux.EPOLLIN | std.os.linux.EPOLLOUT | std.os.linux.EPOLLET,
111111 .data = std.os.linux.epoll_data{ .ptr = @ptrToInt(prom) },
......@@ -113,23 +113,23 @@ pub const Loop = struct {
113113 try std.os.linuxEpollCtl(self.epollfd, std.os.linux.EPOLL_CTL_ADD, fd, &ev);
114114 }
115115
116 pub fn removeFd(self: &Loop, fd: i32) void {
116 pub fn removeFd(self: *Loop, fd: i32) void {
117117 std.os.linuxEpollCtl(self.epollfd, std.os.linux.EPOLL_CTL_DEL, fd, undefined) catch {};
118118 }
119 async fn waitFd(self: &Loop, fd: i32) !void {
119 async fn waitFd(self: *Loop, fd: i32) !void {
120120 defer self.removeFd(fd);
121121 suspend |p| {
122122 try self.addFd(fd, p);
123123 }
124124 }
125125
126 pub fn stop(self: &Loop) void {
126 pub fn stop(self: *Loop) void {
127127 // TODO make atomic
128128 self.keep_running = false;
129129 // TODO activate an fd in the epoll set
130130 }
131131
132 pub fn run(self: &Loop) void {
132 pub fn run(self: *Loop) void {
133133 while (self.keep_running) {
134134 var events: [16]std.os.linux.epoll_event = undefined;
135135 const count = std.os.linuxEpollWait(self.epollfd, events[0..], -1);
......@@ -141,7 +141,7 @@ pub const Loop = struct {
141141 }
142142};
143143
144pub async fn connect(loop: &Loop, _address: &const std.net.Address) !std.os.File {
144pub async fn connect(loop: *Loop, _address: *const std.net.Address) !std.os.File {
145145 var address = _address.*; // TODO https://github.com/ziglang/zig/issues/733
146146
147147 const sockfd = try std.os.posixSocket(posix.AF_INET, posix.SOCK_STREAM | posix.SOCK_CLOEXEC | posix.SOCK_NONBLOCK, posix.PROTO_tcp);
......@@ -163,7 +163,7 @@ test "listen on a port, send bytes, receive bytes" {
163163 tcp_server: TcpServer,
164164
165165 const Self = this;
166 async<&mem.Allocator> fn handler(tcp_server: &TcpServer, _addr: &const std.net.Address, _socket: &const std.os.File) void {
166 async<*mem.Allocator> fn handler(tcp_server: *TcpServer, _addr: *const std.net.Address, _socket: *const std.os.File) void {
167167 const self = @fieldParentPtr(Self, "tcp_server", tcp_server);
168168 var socket = _socket.*; // TODO https://github.com/ziglang/zig/issues/733
169169 defer socket.close();
......@@ -177,7 +177,7 @@ test "listen on a port, send bytes, receive bytes" {
177177 cancel p;
178178 }
179179 }
180 async fn errorableHandler(self: &Self, _addr: &const std.net.Address, _socket: &const std.os.File) !void {
180 async fn errorableHandler(self: *Self, _addr: *const std.net.Address, _socket: *const std.os.File) !void {
181181 const addr = _addr.*; // TODO https://github.com/ziglang/zig/issues/733
182182 var socket = _socket.*; // TODO https://github.com/ziglang/zig/issues/733
183183
......@@ -199,7 +199,7 @@ test "listen on a port, send bytes, receive bytes" {
199199 defer cancel p;
200200 loop.run();
201201}
202async fn doAsyncTest(loop: &Loop, address: &const std.net.Address) void {
202async fn doAsyncTest(loop: *Loop, address: *const std.net.Address) void {
203203 errdefer @panic("test failure");
204204
205205 var socket_file = try await try async event.connect(loop, address);
std/fmt/errol/index.zig+7-7
......@@ -21,7 +21,7 @@ pub const RoundMode = enum {
2121
2222/// Round a FloatDecimal as returned by errol3 to the specified fractional precision.
2323/// All digits after the specified precision should be considered invalid.
24pub fn roundToPrecision(float_decimal: &FloatDecimal, precision: usize, mode: RoundMode) void {
24pub fn roundToPrecision(float_decimal: *FloatDecimal, precision: usize, mode: RoundMode) void {
2525 // The round digit refers to the index which we should look at to determine
2626 // whether we need to round to match the specified precision.
2727 var round_digit: usize = 0;
......@@ -59,7 +59,7 @@ pub fn roundToPrecision(float_decimal: &FloatDecimal, precision: usize, mode: Ro
5959 float_decimal.exp += 1;
6060
6161 // Re-size the buffer to use the reserved leading byte.
62 const one_before = @intToPtr(&u8, @ptrToInt(&float_decimal.digits[0]) - 1);
62 const one_before = @intToPtr(*u8, @ptrToInt(&float_decimal.digits[0]) - 1);
6363 float_decimal.digits = one_before[0 .. float_decimal.digits.len + 1];
6464 float_decimal.digits[0] = '1';
6565 return;
......@@ -217,7 +217,7 @@ fn tableLowerBound(k: u64) usize {
217217/// @in: The HP number.
218218/// @val: The double.
219219/// &returns: The HP number.
220fn hpProd(in: &const HP, val: f64) HP {
220fn hpProd(in: *const HP, val: f64) HP {
221221 var hi: f64 = undefined;
222222 var lo: f64 = undefined;
223223 split(in.val, &hi, &lo);
......@@ -239,7 +239,7 @@ fn hpProd(in: &const HP, val: f64) HP {
239239/// @val: The double.
240240/// @hi: The high bits.
241241/// @lo: The low bits.
242fn split(val: f64, hi: &f64, lo: &f64) void {
242fn split(val: f64, hi: *f64, lo: *f64) void {
243243 hi.* = gethi(val);
244244 lo.* = val - hi.*;
245245}
......@@ -252,7 +252,7 @@ fn gethi(in: f64) f64 {
252252
253253/// Normalize the number by factoring in the error.
254254/// @hp: The float pair.
255fn hpNormalize(hp: &HP) void {
255fn hpNormalize(hp: *HP) void {
256256 // Required to avoid segfaults causing buffer overrun during errol3 digit output termination.
257257 @setFloatMode(this, @import("builtin").FloatMode.Strict);
258258
......@@ -264,7 +264,7 @@ fn hpNormalize(hp: &HP) void {
264264
265265/// Divide the high-precision number by ten.
266266/// @hp: The high-precision number
267fn hpDiv10(hp: &HP) void {
267fn hpDiv10(hp: *HP) void {
268268 var val = hp.val;
269269
270270 hp.val /= 10.0;
......@@ -280,7 +280,7 @@ fn hpDiv10(hp: &HP) void {
280280
281281/// Multiply the high-precision number by ten.
282282/// @hp: The high-precision number
283fn hpMul10(hp: &HP) void {
283fn hpMul10(hp: *HP) void {
284284 const val = hp.val;
285285
286286 hp.val *= 10.0;
std/fmt/index.zig+4-4
......@@ -679,7 +679,7 @@ const FormatIntBuf = struct {
679679 out_buf: []u8,
680680 index: usize,
681681};
682fn formatIntCallback(context: &FormatIntBuf, bytes: []const u8) (error{}!void) {
682fn formatIntCallback(context: *FormatIntBuf, bytes: []const u8) (error{}!void) {
683683 mem.copy(u8, context.out_buf[context.index..], bytes);
684684 context.index += bytes.len;
685685}
......@@ -751,7 +751,7 @@ const BufPrintContext = struct {
751751 remaining: []u8,
752752};
753753
754fn bufPrintWrite(context: &BufPrintContext, bytes: []const u8) !void {
754fn bufPrintWrite(context: *BufPrintContext, bytes: []const u8) !void {
755755 if (context.remaining.len < bytes.len) return error.BufferTooSmall;
756756 mem.copy(u8, context.remaining, bytes);
757757 context.remaining = context.remaining[bytes.len..];
......@@ -763,14 +763,14 @@ pub fn bufPrint(buf: []u8, comptime fmt: []const u8, args: ...) ![]u8 {
763763 return buf[0 .. buf.len - context.remaining.len];
764764}
765765
766pub fn allocPrint(allocator: &mem.Allocator, comptime fmt: []const u8, args: ...) ![]u8 {
766pub fn allocPrint(allocator: *mem.Allocator, comptime fmt: []const u8, args: ...) ![]u8 {
767767 var size: usize = 0;
768768 format(&size, error{}, countSize, fmt, args) catch |err| switch (err) {};
769769 const buf = try allocator.alloc(u8, size);
770770 return bufPrint(buf, fmt, args);
771771}
772772
773fn countSize(size: &usize, bytes: []const u8) (error{}!void) {
773fn countSize(size: *usize, bytes: []const u8) (error{}!void) {
774774 size.* += bytes.len;
775775}
776776
std/hash/adler.zig+2-2
......@@ -18,7 +18,7 @@ pub const Adler32 = struct {
1818
1919 // This fast variant is taken from zlib. It reduces the required modulos and unrolls longer
2020 // buffer inputs and should be much quicker.
21 pub fn update(self: &Adler32, input: []const u8) void {
21 pub fn update(self: *Adler32, input: []const u8) void {
2222 var s1 = self.adler & 0xffff;
2323 var s2 = (self.adler >> 16) & 0xffff;
2424
......@@ -77,7 +77,7 @@ pub const Adler32 = struct {
7777 self.adler = s1 | (s2 << 16);
7878 }
7979
80 pub fn final(self: &Adler32) u32 {
80 pub fn final(self: *Adler32) u32 {
8181 return self.adler;
8282 }
8383
std/hash/crc.zig+4-4
......@@ -58,7 +58,7 @@ pub fn Crc32WithPoly(comptime poly: u32) type {
5858 return Self{ .crc = 0xffffffff };
5959 }
6060
61 pub fn update(self: &Self, input: []const u8) void {
61 pub fn update(self: *Self, input: []const u8) void {
6262 var i: usize = 0;
6363 while (i + 8 <= input.len) : (i += 8) {
6464 const p = input[i .. i + 8];
......@@ -86,7 +86,7 @@ pub fn Crc32WithPoly(comptime poly: u32) type {
8686 }
8787 }
8888
89 pub fn final(self: &Self) u32 {
89 pub fn final(self: *Self) u32 {
9090 return ~self.crc;
9191 }
9292
......@@ -143,14 +143,14 @@ pub fn Crc32SmallWithPoly(comptime poly: u32) type {
143143 return Self{ .crc = 0xffffffff };
144144 }
145145
146 pub fn update(self: &Self, input: []const u8) void {
146 pub fn update(self: *Self, input: []const u8) void {
147147 for (input) |b| {
148148 self.crc = lookup_table[@truncate(u4, self.crc ^ (b >> 0))] ^ (self.crc >> 4);
149149 self.crc = lookup_table[@truncate(u4, self.crc ^ (b >> 4))] ^ (self.crc >> 4);
150150 }
151151 }
152152
153 pub fn final(self: &Self) u32 {
153 pub fn final(self: *Self) u32 {
154154 return ~self.crc;
155155 }
156156
std/hash/fnv.zig+2-2
......@@ -21,14 +21,14 @@ fn Fnv1a(comptime T: type, comptime prime: T, comptime offset: T) type {
2121 return Self{ .value = offset };
2222 }
2323
24 pub fn update(self: &Self, input: []const u8) void {
24 pub fn update(self: *Self, input: []const u8) void {
2525 for (input) |b| {
2626 self.value ^= b;
2727 self.value *%= prime;
2828 }
2929 }
3030
31 pub fn final(self: &Self) T {
31 pub fn final(self: *Self) T {
3232 return self.value;
3333 }
3434
std/hash/siphash.zig+4-4
......@@ -63,7 +63,7 @@ fn SipHash(comptime T: type, comptime c_rounds: usize, comptime d_rounds: usize)
6363 return d;
6464 }
6565
66 pub fn update(d: &Self, b: []const u8) void {
66 pub fn update(d: *Self, b: []const u8) void {
6767 var off: usize = 0;
6868
6969 // Partial from previous.
......@@ -85,7 +85,7 @@ fn SipHash(comptime T: type, comptime c_rounds: usize, comptime d_rounds: usize)
8585 d.msg_len +%= @truncate(u8, b.len);
8686 }
8787
88 pub fn final(d: &Self) T {
88 pub fn final(d: *Self) T {
8989 // Padding
9090 mem.set(u8, d.buf[d.buf_len..], 0);
9191 d.buf[7] = d.msg_len;
......@@ -118,7 +118,7 @@ fn SipHash(comptime T: type, comptime c_rounds: usize, comptime d_rounds: usize)
118118 return (u128(b2) << 64) | b1;
119119 }
120120
121 fn round(d: &Self, b: []const u8) void {
121 fn round(d: *Self, b: []const u8) void {
122122 debug.assert(b.len == 8);
123123
124124 const m = mem.readInt(b[0..], u64, Endian.Little);
......@@ -132,7 +132,7 @@ fn SipHash(comptime T: type, comptime c_rounds: usize, comptime d_rounds: usize)
132132 d.v0 ^= m;
133133 }
134134
135 fn sipRound(d: &Self) void {
135 fn sipRound(d: *Self) void {
136136 d.v0 +%= d.v1;
137137 d.v1 = math.rotl(u64, d.v1, u64(13));
138138 d.v1 ^= d.v0;
std/hash_map.zig+18-18
......@@ -14,7 +14,7 @@ pub fn HashMap(comptime K: type, comptime V: type, comptime hash: fn (key: K) u3
1414 entries: []Entry,
1515 size: usize,
1616 max_distance_from_start_index: usize,
17 allocator: &Allocator,
17 allocator: *Allocator,
1818 // this is used to detect bugs where a hashtable is edited while an iterator is running.
1919 modification_count: debug_u32,
2020
......@@ -28,7 +28,7 @@ pub fn HashMap(comptime K: type, comptime V: type, comptime hash: fn (key: K) u3
2828 };
2929
3030 pub const Iterator = struct {
31 hm: &const Self,
31 hm: *const Self,
3232 // how many items have we returned
3333 count: usize,
3434 // iterator through the entry array
......@@ -36,7 +36,7 @@ pub fn HashMap(comptime K: type, comptime V: type, comptime hash: fn (key: K) u3
3636 // used to detect concurrent modification
3737 initial_modification_count: debug_u32,
3838
39 pub fn next(it: &Iterator) ?&Entry {
39 pub fn next(it: *Iterator) ?*Entry {
4040 if (want_modification_safety) {
4141 assert(it.initial_modification_count == it.hm.modification_count); // concurrent modification
4242 }
......@@ -53,7 +53,7 @@ pub fn HashMap(comptime K: type, comptime V: type, comptime hash: fn (key: K) u3
5353 }
5454
5555 // Reset the iterator to the initial index
56 pub fn reset(it: &Iterator) void {
56 pub fn reset(it: *Iterator) void {
5757 it.count = 0;
5858 it.index = 0;
5959 // Resetting the modification count too
......@@ -61,7 +61,7 @@ pub fn HashMap(comptime K: type, comptime V: type, comptime hash: fn (key: K) u3
6161 }
6262 };
6363
64 pub fn init(allocator: &Allocator) Self {
64 pub fn init(allocator: *Allocator) Self {
6565 return Self{
6666 .entries = []Entry{},
6767 .allocator = allocator,
......@@ -71,11 +71,11 @@ pub fn HashMap(comptime K: type, comptime V: type, comptime hash: fn (key: K) u3
7171 };
7272 }
7373
74 pub fn deinit(hm: &const Self) void {
74 pub fn deinit(hm: *const Self) void {
7575 hm.allocator.free(hm.entries);
7676 }
7777
78 pub fn clear(hm: &Self) void {
78 pub fn clear(hm: *Self) void {
7979 for (hm.entries) |*entry| {
8080 entry.used = false;
8181 }
......@@ -84,12 +84,12 @@ pub fn HashMap(comptime K: type, comptime V: type, comptime hash: fn (key: K) u3
8484 hm.incrementModificationCount();
8585 }
8686
87 pub fn count(hm: &const Self) usize {
87 pub fn count(hm: *const Self) usize {
8888 return hm.size;
8989 }
9090
9191 /// Returns the value that was already there.
92 pub fn put(hm: &Self, key: K, value: &const V) !?V {
92 pub fn put(hm: *Self, key: K, value: *const V) !?V {
9393 if (hm.entries.len == 0) {
9494 try hm.initCapacity(16);
9595 }
......@@ -111,18 +111,18 @@ pub fn HashMap(comptime K: type, comptime V: type, comptime hash: fn (key: K) u3
111111 return hm.internalPut(key, value);
112112 }
113113
114 pub fn get(hm: &const Self, key: K) ?&Entry {
114 pub fn get(hm: *const Self, key: K) ?*Entry {
115115 if (hm.entries.len == 0) {
116116 return null;
117117 }
118118 return hm.internalGet(key);
119119 }
120120
121 pub fn contains(hm: &const Self, key: K) bool {
121 pub fn contains(hm: *const Self, key: K) bool {
122122 return hm.get(key) != null;
123123 }
124124
125 pub fn remove(hm: &Self, key: K) ?&Entry {
125 pub fn remove(hm: *Self, key: K) ?*Entry {
126126 if (hm.entries.len == 0) return null;
127127 hm.incrementModificationCount();
128128 const start_index = hm.keyToIndex(key);
......@@ -154,7 +154,7 @@ pub fn HashMap(comptime K: type, comptime V: type, comptime hash: fn (key: K) u3
154154 return null;
155155 }
156156
157 pub fn iterator(hm: &const Self) Iterator {
157 pub fn iterator(hm: *const Self) Iterator {
158158 return Iterator{
159159 .hm = hm,
160160 .count = 0,
......@@ -163,7 +163,7 @@ pub fn HashMap(comptime K: type, comptime V: type, comptime hash: fn (key: K) u3
163163 };
164164 }
165165
166 fn initCapacity(hm: &Self, capacity: usize) !void {
166 fn initCapacity(hm: *Self, capacity: usize) !void {
167167 hm.entries = try hm.allocator.alloc(Entry, capacity);
168168 hm.size = 0;
169169 hm.max_distance_from_start_index = 0;
......@@ -172,14 +172,14 @@ pub fn HashMap(comptime K: type, comptime V: type, comptime hash: fn (key: K) u3
172172 }
173173 }
174174
175 fn incrementModificationCount(hm: &Self) void {
175 fn incrementModificationCount(hm: *Self) void {
176176 if (want_modification_safety) {
177177 hm.modification_count +%= 1;
178178 }
179179 }
180180
181181 /// Returns the value that was already there.
182 fn internalPut(hm: &Self, orig_key: K, orig_value: &const V) ?V {
182 fn internalPut(hm: *Self, orig_key: K, orig_value: *const V) ?V {
183183 var key = orig_key;
184184 var value = orig_value.*;
185185 const start_index = hm.keyToIndex(key);
......@@ -231,7 +231,7 @@ pub fn HashMap(comptime K: type, comptime V: type, comptime hash: fn (key: K) u3
231231 unreachable; // put into a full map
232232 }
233233
234 fn internalGet(hm: &const Self, key: K) ?&Entry {
234 fn internalGet(hm: *const Self, key: K) ?*Entry {
235235 const start_index = hm.keyToIndex(key);
236236 {
237237 var roll_over: usize = 0;
......@@ -246,7 +246,7 @@ pub fn HashMap(comptime K: type, comptime V: type, comptime hash: fn (key: K) u3
246246 return null;
247247 }
248248
249 fn keyToIndex(hm: &const Self, key: K) usize {
249 fn keyToIndex(hm: *const Self, key: K) usize {
250250 return usize(hash(key)) % hm.entries.len;
251251 }
252252 };
std/heap.zig+40-40
......@@ -16,15 +16,15 @@ var c_allocator_state = Allocator{
1616 .freeFn = cFree,
1717};
1818
19fn cAlloc(self: &Allocator, n: usize, alignment: u29) ![]u8 {
19fn cAlloc(self: *Allocator, n: usize, alignment: u29) ![]u8 {
2020 assert(alignment <= @alignOf(c_longdouble));
21 return if (c.malloc(n)) |buf| @ptrCast(&u8, buf)[0..n] else error.OutOfMemory;
21 return if (c.malloc(n)) |buf| @ptrCast(*u8, buf)[0..n] else error.OutOfMemory;
2222}
2323
24fn cRealloc(self: &Allocator, old_mem: []u8, new_size: usize, alignment: u29) ![]u8 {
25 const old_ptr = @ptrCast(&c_void, old_mem.ptr);
24fn cRealloc(self: *Allocator, old_mem: []u8, new_size: usize, alignment: u29) ![]u8 {
25 const old_ptr = @ptrCast(*c_void, old_mem.ptr);
2626 if (c.realloc(old_ptr, new_size)) |buf| {
27 return @ptrCast(&u8, buf)[0..new_size];
27 return @ptrCast(*u8, buf)[0..new_size];
2828 } else if (new_size <= old_mem.len) {
2929 return old_mem[0..new_size];
3030 } else {
......@@ -32,8 +32,8 @@ fn cRealloc(self: &Allocator, old_mem: []u8, new_size: usize, alignment: u29) ![
3232 }
3333}
3434
35fn cFree(self: &Allocator, old_mem: []u8) void {
36 const old_ptr = @ptrCast(&c_void, old_mem.ptr);
35fn cFree(self: *Allocator, old_mem: []u8) void {
36 const old_ptr = @ptrCast(*c_void, old_mem.ptr);
3737 c.free(old_ptr);
3838}
3939
......@@ -55,7 +55,7 @@ pub const DirectAllocator = struct {
5555 };
5656 }
5757
58 pub fn deinit(self: &DirectAllocator) void {
58 pub fn deinit(self: *DirectAllocator) void {
5959 switch (builtin.os) {
6060 Os.windows => if (self.heap_handle) |heap_handle| {
6161 _ = os.windows.HeapDestroy(heap_handle);
......@@ -64,7 +64,7 @@ pub const DirectAllocator = struct {
6464 }
6565 }
6666
67 fn alloc(allocator: &Allocator, n: usize, alignment: u29) ![]u8 {
67 fn alloc(allocator: *Allocator, n: usize, alignment: u29) ![]u8 {
6868 const self = @fieldParentPtr(DirectAllocator, "allocator", allocator);
6969
7070 switch (builtin.os) {
......@@ -74,7 +74,7 @@ pub const DirectAllocator = struct {
7474 const addr = p.mmap(null, alloc_size, p.PROT_READ | p.PROT_WRITE, p.MAP_PRIVATE | p.MAP_ANONYMOUS, -1, 0);
7575 if (addr == p.MAP_FAILED) return error.OutOfMemory;
7676
77 if (alloc_size == n) return @intToPtr(&u8, addr)[0..n];
77 if (alloc_size == n) return @intToPtr(*u8, addr)[0..n];
7878
7979 var aligned_addr = addr & ~usize(alignment - 1);
8080 aligned_addr += alignment;
......@@ -93,7 +93,7 @@ pub const DirectAllocator = struct {
9393 //It is impossible that there is an unoccupied page at the top of our
9494 // mmap.
9595
96 return @intToPtr(&u8, aligned_addr)[0..n];
96 return @intToPtr(*u8, aligned_addr)[0..n];
9797 },
9898 Os.windows => {
9999 const amt = n + alignment + @sizeOf(usize);
......@@ -108,14 +108,14 @@ pub const DirectAllocator = struct {
108108 const march_forward_bytes = if (rem == 0) 0 else (alignment - rem);
109109 const adjusted_addr = root_addr + march_forward_bytes;
110110 const record_addr = adjusted_addr + n;
111 @intToPtr(&align(1) usize, record_addr).* = root_addr;
112 return @intToPtr(&u8, adjusted_addr)[0..n];
111 @intToPtr(*align(1) usize, record_addr).* = root_addr;
112 return @intToPtr(*u8, adjusted_addr)[0..n];
113113 },
114114 else => @compileError("Unsupported OS"),
115115 }
116116 }
117117
118 fn realloc(allocator: &Allocator, old_mem: []u8, new_size: usize, alignment: u29) ![]u8 {
118 fn realloc(allocator: *Allocator, old_mem: []u8, new_size: usize, alignment: u29) ![]u8 {
119119 const self = @fieldParentPtr(DirectAllocator, "allocator", allocator);
120120
121121 switch (builtin.os) {
......@@ -139,13 +139,13 @@ pub const DirectAllocator = struct {
139139 Os.windows => {
140140 const old_adjusted_addr = @ptrToInt(old_mem.ptr);
141141 const old_record_addr = old_adjusted_addr + old_mem.len;
142 const root_addr = @intToPtr(&align(1) usize, old_record_addr).*;
142 const root_addr = @intToPtr(*align(1) usize, old_record_addr).*;
143143 const old_ptr = @intToPtr(os.windows.LPVOID, root_addr);
144144 const amt = new_size + alignment + @sizeOf(usize);
145145 const new_ptr = os.windows.HeapReAlloc(??self.heap_handle, 0, old_ptr, amt) ?? blk: {
146146 if (new_size > old_mem.len) return error.OutOfMemory;
147147 const new_record_addr = old_record_addr - new_size + old_mem.len;
148 @intToPtr(&align(1) usize, new_record_addr).* = root_addr;
148 @intToPtr(*align(1) usize, new_record_addr).* = root_addr;
149149 return old_mem[0..new_size];
150150 };
151151 const offset = old_adjusted_addr - root_addr;
......@@ -153,14 +153,14 @@ pub const DirectAllocator = struct {
153153 const new_adjusted_addr = new_root_addr + offset;
154154 assert(new_adjusted_addr % alignment == 0);
155155 const new_record_addr = new_adjusted_addr + new_size;
156 @intToPtr(&align(1) usize, new_record_addr).* = new_root_addr;
157 return @intToPtr(&u8, new_adjusted_addr)[0..new_size];
156 @intToPtr(*align(1) usize, new_record_addr).* = new_root_addr;
157 return @intToPtr(*u8, new_adjusted_addr)[0..new_size];
158158 },
159159 else => @compileError("Unsupported OS"),
160160 }
161161 }
162162
163 fn free(allocator: &Allocator, bytes: []u8) void {
163 fn free(allocator: *Allocator, bytes: []u8) void {
164164 const self = @fieldParentPtr(DirectAllocator, "allocator", allocator);
165165
166166 switch (builtin.os) {
......@@ -169,7 +169,7 @@ pub const DirectAllocator = struct {
169169 },
170170 Os.windows => {
171171 const record_addr = @ptrToInt(bytes.ptr) + bytes.len;
172 const root_addr = @intToPtr(&align(1) usize, record_addr).*;
172 const root_addr = @intToPtr(*align(1) usize, record_addr).*;
173173 const ptr = @intToPtr(os.windows.LPVOID, root_addr);
174174 _ = os.windows.HeapFree(??self.heap_handle, 0, ptr);
175175 },
......@@ -183,13 +183,13 @@ pub const DirectAllocator = struct {
183183pub const ArenaAllocator = struct {
184184 pub allocator: Allocator,
185185
186 child_allocator: &Allocator,
186 child_allocator: *Allocator,
187187 buffer_list: std.LinkedList([]u8),
188188 end_index: usize,
189189
190190 const BufNode = std.LinkedList([]u8).Node;
191191
192 pub fn init(child_allocator: &Allocator) ArenaAllocator {
192 pub fn init(child_allocator: *Allocator) ArenaAllocator {
193193 return ArenaAllocator{
194194 .allocator = Allocator{
195195 .allocFn = alloc,
......@@ -202,7 +202,7 @@ pub const ArenaAllocator = struct {
202202 };
203203 }
204204
205 pub fn deinit(self: &ArenaAllocator) void {
205 pub fn deinit(self: *ArenaAllocator) void {
206206 var it = self.buffer_list.first;
207207 while (it) |node| {
208208 // this has to occur before the free because the free frees node
......@@ -212,7 +212,7 @@ pub const ArenaAllocator = struct {
212212 }
213213 }
214214
215 fn createNode(self: &ArenaAllocator, prev_len: usize, minimum_size: usize) !&BufNode {
215 fn createNode(self: *ArenaAllocator, prev_len: usize, minimum_size: usize) !*BufNode {
216216 const actual_min_size = minimum_size + @sizeOf(BufNode);
217217 var len = prev_len;
218218 while (true) {
......@@ -233,7 +233,7 @@ pub const ArenaAllocator = struct {
233233 return buf_node;
234234 }
235235
236 fn alloc(allocator: &Allocator, n: usize, alignment: u29) ![]u8 {
236 fn alloc(allocator: *Allocator, n: usize, alignment: u29) ![]u8 {
237237 const self = @fieldParentPtr(ArenaAllocator, "allocator", allocator);
238238
239239 var cur_node = if (self.buffer_list.last) |last_node| last_node else try self.createNode(0, n + alignment);
......@@ -254,7 +254,7 @@ pub const ArenaAllocator = struct {
254254 }
255255 }
256256
257 fn realloc(allocator: &Allocator, old_mem: []u8, new_size: usize, alignment: u29) ![]u8 {
257 fn realloc(allocator: *Allocator, old_mem: []u8, new_size: usize, alignment: u29) ![]u8 {
258258 if (new_size <= old_mem.len) {
259259 return old_mem[0..new_size];
260260 } else {
......@@ -264,7 +264,7 @@ pub const ArenaAllocator = struct {
264264 }
265265 }
266266
267 fn free(allocator: &Allocator, bytes: []u8) void {}
267 fn free(allocator: *Allocator, bytes: []u8) void {}
268268};
269269
270270pub const FixedBufferAllocator = struct {
......@@ -284,7 +284,7 @@ pub const FixedBufferAllocator = struct {
284284 };
285285 }
286286
287 fn alloc(allocator: &Allocator, n: usize, alignment: u29) ![]u8 {
287 fn alloc(allocator: *Allocator, n: usize, alignment: u29) ![]u8 {
288288 const self = @fieldParentPtr(FixedBufferAllocator, "allocator", allocator);
289289 const addr = @ptrToInt(self.buffer.ptr) + self.end_index;
290290 const rem = @rem(addr, alignment);
......@@ -300,7 +300,7 @@ pub const FixedBufferAllocator = struct {
300300 return result;
301301 }
302302
303 fn realloc(allocator: &Allocator, old_mem: []u8, new_size: usize, alignment: u29) ![]u8 {
303 fn realloc(allocator: *Allocator, old_mem: []u8, new_size: usize, alignment: u29) ![]u8 {
304304 if (new_size <= old_mem.len) {
305305 return old_mem[0..new_size];
306306 } else {
......@@ -310,7 +310,7 @@ pub const FixedBufferAllocator = struct {
310310 }
311311 }
312312
313 fn free(allocator: &Allocator, bytes: []u8) void {}
313 fn free(allocator: *Allocator, bytes: []u8) void {}
314314};
315315
316316/// lock free
......@@ -331,7 +331,7 @@ pub const ThreadSafeFixedBufferAllocator = struct {
331331 };
332332 }
333333
334 fn alloc(allocator: &Allocator, n: usize, alignment: u29) ![]u8 {
334 fn alloc(allocator: *Allocator, n: usize, alignment: u29) ![]u8 {
335335 const self = @fieldParentPtr(ThreadSafeFixedBufferAllocator, "allocator", allocator);
336336 var end_index = @atomicLoad(usize, &self.end_index, builtin.AtomicOrder.SeqCst);
337337 while (true) {
......@@ -347,7 +347,7 @@ pub const ThreadSafeFixedBufferAllocator = struct {
347347 }
348348 }
349349
350 fn realloc(allocator: &Allocator, old_mem: []u8, new_size: usize, alignment: u29) ![]u8 {
350 fn realloc(allocator: *Allocator, old_mem: []u8, new_size: usize, alignment: u29) ![]u8 {
351351 if (new_size <= old_mem.len) {
352352 return old_mem[0..new_size];
353353 } else {
......@@ -357,7 +357,7 @@ pub const ThreadSafeFixedBufferAllocator = struct {
357357 }
358358 }
359359
360 fn free(allocator: &Allocator, bytes: []u8) void {}
360 fn free(allocator: *Allocator, bytes: []u8) void {}
361361};
362362
363363test "c_allocator" {
......@@ -403,8 +403,8 @@ test "ThreadSafeFixedBufferAllocator" {
403403 try testAllocatorLargeAlignment(&fixed_buffer_allocator.allocator);
404404}
405405
406fn testAllocator(allocator: &mem.Allocator) !void {
407 var slice = try allocator.alloc(&i32, 100);
406fn testAllocator(allocator: *mem.Allocator) !void {
407 var slice = try allocator.alloc(*i32, 100);
408408
409409 for (slice) |*item, i| {
410410 item.* = try allocator.create(i32);
......@@ -415,15 +415,15 @@ fn testAllocator(allocator: &mem.Allocator) !void {
415415 allocator.destroy(item);
416416 }
417417
418 slice = try allocator.realloc(&i32, slice, 20000);
419 slice = try allocator.realloc(&i32, slice, 50);
420 slice = try allocator.realloc(&i32, slice, 25);
421 slice = try allocator.realloc(&i32, slice, 10);
418 slice = try allocator.realloc(*i32, slice, 20000);
419 slice = try allocator.realloc(*i32, slice, 50);
420 slice = try allocator.realloc(*i32, slice, 25);
421 slice = try allocator.realloc(*i32, slice, 10);
422422
423423 allocator.free(slice);
424424}
425425
426fn testAllocatorLargeAlignment(allocator: &mem.Allocator) mem.Allocator.Error!void {
426fn testAllocatorLargeAlignment(allocator: *mem.Allocator) mem.Allocator.Error!void {
427427 //Maybe a platform's page_size is actually the same as or
428428 // very near usize?
429429 if (os.page_size << 2 > @maxValue(usize)) return;
std/io.zig+40-40
......@@ -34,20 +34,20 @@ pub fn getStdIn() GetStdIoErrs!File {
3434
3535/// Implementation of InStream trait for File
3636pub const FileInStream = struct {
37 file: &File,
37 file: *File,
3838 stream: Stream,
3939
4040 pub const Error = @typeOf(File.read).ReturnType.ErrorSet;
4141 pub const Stream = InStream(Error);
4242
43 pub fn init(file: &File) FileInStream {
43 pub fn init(file: *File) FileInStream {
4444 return FileInStream{
4545 .file = file,
4646 .stream = Stream{ .readFn = readFn },
4747 };
4848 }
4949
50 fn readFn(in_stream: &Stream, buffer: []u8) Error!usize {
50 fn readFn(in_stream: *Stream, buffer: []u8) Error!usize {
5151 const self = @fieldParentPtr(FileInStream, "stream", in_stream);
5252 return self.file.read(buffer);
5353 }
......@@ -55,20 +55,20 @@ pub const FileInStream = struct {
5555
5656/// Implementation of OutStream trait for File
5757pub const FileOutStream = struct {
58 file: &File,
58 file: *File,
5959 stream: Stream,
6060
6161 pub const Error = File.WriteError;
6262 pub const Stream = OutStream(Error);
6363
64 pub fn init(file: &File) FileOutStream {
64 pub fn init(file: *File) FileOutStream {
6565 return FileOutStream{
6666 .file = file,
6767 .stream = Stream{ .writeFn = writeFn },
6868 };
6969 }
7070
71 fn writeFn(out_stream: &Stream, bytes: []const u8) !void {
71 fn writeFn(out_stream: *Stream, bytes: []const u8) !void {
7272 const self = @fieldParentPtr(FileOutStream, "stream", out_stream);
7373 return self.file.write(bytes);
7474 }
......@@ -82,12 +82,12 @@ pub fn InStream(comptime ReadError: type) type {
8282 /// Return the number of bytes read. If the number read is smaller than buf.len, it
8383 /// means the stream reached the end. Reaching the end of a stream is not an error
8484 /// condition.
85 readFn: fn (self: &Self, buffer: []u8) Error!usize,
85 readFn: fn (self: *Self, buffer: []u8) Error!usize,
8686
8787 /// Replaces `buffer` contents by reading from the stream until it is finished.
8888 /// If `buffer.len()` would exceed `max_size`, `error.StreamTooLong` is returned and
8989 /// the contents read from the stream are lost.
90 pub fn readAllBuffer(self: &Self, buffer: &Buffer, max_size: usize) !void {
90 pub fn readAllBuffer(self: *Self, buffer: *Buffer, max_size: usize) !void {
9191 try buffer.resize(0);
9292
9393 var actual_buf_len: usize = 0;
......@@ -111,7 +111,7 @@ pub fn InStream(comptime ReadError: type) type {
111111 /// memory would be greater than `max_size`, returns `error.StreamTooLong`.
112112 /// Caller owns returned memory.
113113 /// If this function returns an error, the contents from the stream read so far are lost.
114 pub fn readAllAlloc(self: &Self, allocator: &mem.Allocator, max_size: usize) ![]u8 {
114 pub fn readAllAlloc(self: *Self, allocator: *mem.Allocator, max_size: usize) ![]u8 {
115115 var buf = Buffer.initNull(allocator);
116116 defer buf.deinit();
117117
......@@ -123,7 +123,7 @@ pub fn InStream(comptime ReadError: type) type {
123123 /// Does not include the delimiter in the result.
124124 /// If `buffer.len()` would exceed `max_size`, `error.StreamTooLong` is returned and the contents
125125 /// read from the stream so far are lost.
126 pub fn readUntilDelimiterBuffer(self: &Self, buffer: &Buffer, delimiter: u8, max_size: usize) !void {
126 pub fn readUntilDelimiterBuffer(self: *Self, buffer: *Buffer, delimiter: u8, max_size: usize) !void {
127127 try buffer.resize(0);
128128
129129 while (true) {
......@@ -145,7 +145,7 @@ pub fn InStream(comptime ReadError: type) type {
145145 /// memory would be greater than `max_size`, returns `error.StreamTooLong`.
146146 /// Caller owns returned memory.
147147 /// If this function returns an error, the contents from the stream read so far are lost.
148 pub fn readUntilDelimiterAlloc(self: &Self, allocator: &mem.Allocator, delimiter: u8, max_size: usize) ![]u8 {
148 pub fn readUntilDelimiterAlloc(self: *Self, allocator: *mem.Allocator, delimiter: u8, max_size: usize) ![]u8 {
149149 var buf = Buffer.initNull(allocator);
150150 defer buf.deinit();
151151
......@@ -156,43 +156,43 @@ pub fn InStream(comptime ReadError: type) type {
156156 /// Returns the number of bytes read. If the number read is smaller than buf.len, it
157157 /// means the stream reached the end. Reaching the end of a stream is not an error
158158 /// condition.
159 pub fn read(self: &Self, buffer: []u8) !usize {
159 pub fn read(self: *Self, buffer: []u8) !usize {
160160 return self.readFn(self, buffer);
161161 }
162162
163163 /// Same as `read` but end of stream returns `error.EndOfStream`.
164 pub fn readNoEof(self: &Self, buf: []u8) !void {
164 pub fn readNoEof(self: *Self, buf: []u8) !void {
165165 const amt_read = try self.read(buf);
166166 if (amt_read < buf.len) return error.EndOfStream;
167167 }
168168
169169 /// Reads 1 byte from the stream or returns `error.EndOfStream`.
170 pub fn readByte(self: &Self) !u8 {
170 pub fn readByte(self: *Self) !u8 {
171171 var result: [1]u8 = undefined;
172172 try self.readNoEof(result[0..]);
173173 return result[0];
174174 }
175175
176176 /// Same as `readByte` except the returned byte is signed.
177 pub fn readByteSigned(self: &Self) !i8 {
177 pub fn readByteSigned(self: *Self) !i8 {
178178 return @bitCast(i8, try self.readByte());
179179 }
180180
181 pub fn readIntLe(self: &Self, comptime T: type) !T {
181 pub fn readIntLe(self: *Self, comptime T: type) !T {
182182 return self.readInt(builtin.Endian.Little, T);
183183 }
184184
185 pub fn readIntBe(self: &Self, comptime T: type) !T {
185 pub fn readIntBe(self: *Self, comptime T: type) !T {
186186 return self.readInt(builtin.Endian.Big, T);
187187 }
188188
189 pub fn readInt(self: &Self, endian: builtin.Endian, comptime T: type) !T {
189 pub fn readInt(self: *Self, endian: builtin.Endian, comptime T: type) !T {
190190 var bytes: [@sizeOf(T)]u8 = undefined;
191191 try self.readNoEof(bytes[0..]);
192192 return mem.readInt(bytes, T, endian);
193193 }
194194
195 pub fn readVarInt(self: &Self, endian: builtin.Endian, comptime T: type, size: usize) !T {
195 pub fn readVarInt(self: *Self, endian: builtin.Endian, comptime T: type, size: usize) !T {
196196 assert(size <= @sizeOf(T));
197197 assert(size <= 8);
198198 var input_buf: [8]u8 = undefined;
......@@ -208,22 +208,22 @@ pub fn OutStream(comptime WriteError: type) type {
208208 const Self = this;
209209 pub const Error = WriteError;
210210
211 writeFn: fn (self: &Self, bytes: []const u8) Error!void,
211 writeFn: fn (self: *Self, bytes: []const u8) Error!void,
212212
213 pub fn print(self: &Self, comptime format: []const u8, args: ...) !void {
213 pub fn print(self: *Self, comptime format: []const u8, args: ...) !void {
214214 return std.fmt.format(self, Error, self.writeFn, format, args);
215215 }
216216
217 pub fn write(self: &Self, bytes: []const u8) !void {
217 pub fn write(self: *Self, bytes: []const u8) !void {
218218 return self.writeFn(self, bytes);
219219 }
220220
221 pub fn writeByte(self: &Self, byte: u8) !void {
221 pub fn writeByte(self: *Self, byte: u8) !void {
222222 const slice = (&byte)[0..1];
223223 return self.writeFn(self, slice);
224224 }
225225
226 pub fn writeByteNTimes(self: &Self, byte: u8, n: usize) !void {
226 pub fn writeByteNTimes(self: *Self, byte: u8, n: usize) !void {
227227 const slice = (&byte)[0..1];
228228 var i: usize = 0;
229229 while (i < n) : (i += 1) {
......@@ -234,14 +234,14 @@ pub fn OutStream(comptime WriteError: type) type {
234234}
235235
236236/// `path` needs to be copied in memory to add a null terminating byte, hence the allocator.
237pub fn writeFile(allocator: &mem.Allocator, path: []const u8, data: []const u8) !void {
237pub fn writeFile(allocator: *mem.Allocator, path: []const u8, data: []const u8) !void {
238238 var file = try File.openWrite(allocator, path);
239239 defer file.close();
240240 try file.write(data);
241241}
242242
243243/// On success, caller owns returned buffer.
244pub fn readFileAlloc(allocator: &mem.Allocator, path: []const u8) ![]u8 {
244pub fn readFileAlloc(allocator: *mem.Allocator, path: []const u8) ![]u8 {
245245 var file = try File.openRead(allocator, path);
246246 defer file.close();
247247
......@@ -265,13 +265,13 @@ pub fn BufferedInStreamCustom(comptime buffer_size: usize, comptime Error: type)
265265
266266 pub stream: Stream,
267267
268 unbuffered_in_stream: &Stream,
268 unbuffered_in_stream: *Stream,
269269
270270 buffer: [buffer_size]u8,
271271 start_index: usize,
272272 end_index: usize,
273273
274 pub fn init(unbuffered_in_stream: &Stream) Self {
274 pub fn init(unbuffered_in_stream: *Stream) Self {
275275 return Self{
276276 .unbuffered_in_stream = unbuffered_in_stream,
277277 .buffer = undefined,
......@@ -287,7 +287,7 @@ pub fn BufferedInStreamCustom(comptime buffer_size: usize, comptime Error: type)
287287 };
288288 }
289289
290 fn readFn(in_stream: &Stream, dest: []u8) !usize {
290 fn readFn(in_stream: *Stream, dest: []u8) !usize {
291291 const self = @fieldParentPtr(Self, "stream", in_stream);
292292
293293 var dest_index: usize = 0;
......@@ -338,12 +338,12 @@ pub fn BufferedOutStreamCustom(comptime buffer_size: usize, comptime OutStreamEr
338338
339339 pub stream: Stream,
340340
341 unbuffered_out_stream: &Stream,
341 unbuffered_out_stream: *Stream,
342342
343343 buffer: [buffer_size]u8,
344344 index: usize,
345345
346 pub fn init(unbuffered_out_stream: &Stream) Self {
346 pub fn init(unbuffered_out_stream: *Stream) Self {
347347 return Self{
348348 .unbuffered_out_stream = unbuffered_out_stream,
349349 .buffer = undefined,
......@@ -352,12 +352,12 @@ pub fn BufferedOutStreamCustom(comptime buffer_size: usize, comptime OutStreamEr
352352 };
353353 }
354354
355 pub fn flush(self: &Self) !void {
355 pub fn flush(self: *Self) !void {
356356 try self.unbuffered_out_stream.write(self.buffer[0..self.index]);
357357 self.index = 0;
358358 }
359359
360 fn writeFn(out_stream: &Stream, bytes: []const u8) !void {
360 fn writeFn(out_stream: *Stream, bytes: []const u8) !void {
361361 const self = @fieldParentPtr(Self, "stream", out_stream);
362362
363363 if (bytes.len >= self.buffer.len) {
......@@ -383,20 +383,20 @@ pub fn BufferedOutStreamCustom(comptime buffer_size: usize, comptime OutStreamEr
383383
384384/// Implementation of OutStream trait for Buffer
385385pub const BufferOutStream = struct {
386 buffer: &Buffer,
386 buffer: *Buffer,
387387 stream: Stream,
388388
389389 pub const Error = error{OutOfMemory};
390390 pub const Stream = OutStream(Error);
391391
392 pub fn init(buffer: &Buffer) BufferOutStream {
392 pub fn init(buffer: *Buffer) BufferOutStream {
393393 return BufferOutStream{
394394 .buffer = buffer,
395395 .stream = Stream{ .writeFn = writeFn },
396396 };
397397 }
398398
399 fn writeFn(out_stream: &Stream, bytes: []const u8) !void {
399 fn writeFn(out_stream: *Stream, bytes: []const u8) !void {
400400 const self = @fieldParentPtr(BufferOutStream, "stream", out_stream);
401401 return self.buffer.append(bytes);
402402 }
......@@ -407,7 +407,7 @@ pub const BufferedAtomicFile = struct {
407407 file_stream: FileOutStream,
408408 buffered_stream: BufferedOutStream(FileOutStream.Error),
409409
410 pub fn create(allocator: &mem.Allocator, dest_path: []const u8) !&BufferedAtomicFile {
410 pub fn create(allocator: *mem.Allocator, dest_path: []const u8) !*BufferedAtomicFile {
411411 // TODO with well defined copy elision we don't need this allocation
412412 var self = try allocator.create(BufferedAtomicFile);
413413 errdefer allocator.destroy(self);
......@@ -427,18 +427,18 @@ pub const BufferedAtomicFile = struct {
427427 }
428428
429429 /// always call destroy, even after successful finish()
430 pub fn destroy(self: &BufferedAtomicFile) void {
430 pub fn destroy(self: *BufferedAtomicFile) void {
431431 const allocator = self.atomic_file.allocator;
432432 self.atomic_file.deinit();
433433 allocator.destroy(self);
434434 }
435435
436 pub fn finish(self: &BufferedAtomicFile) !void {
436 pub fn finish(self: *BufferedAtomicFile) !void {
437437 try self.buffered_stream.flush();
438438 try self.atomic_file.finish();
439439 }
440440
441 pub fn stream(self: &BufferedAtomicFile) &OutStream(FileOutStream.Error) {
441 pub fn stream(self: *BufferedAtomicFile) *OutStream(FileOutStream.Error) {
442442 return &self.buffered_stream.stream;
443443 }
444444};
std/json.zig+18-18
......@@ -76,7 +76,7 @@ pub const Token = struct {
7676 }
7777
7878 // Slice into the underlying input string.
79 pub fn slice(self: &const Token, input: []const u8, i: usize) []const u8 {
79 pub fn slice(self: *const Token, input: []const u8, i: usize) []const u8 {
8080 return input[i + self.offset - self.count .. i + self.offset];
8181 }
8282};
......@@ -115,7 +115,7 @@ pub const StreamingJsonParser = struct {
115115 return p;
116116 }
117117
118 pub fn reset(p: &StreamingJsonParser) void {
118 pub fn reset(p: *StreamingJsonParser) void {
119119 p.state = State.TopLevelBegin;
120120 p.count = 0;
121121 // Set before ever read in main transition function
......@@ -205,7 +205,7 @@ pub const StreamingJsonParser = struct {
205205 // tokens. token2 is always null if token1 is null.
206206 //
207207 // There is currently no error recovery on a bad stream.
208 pub fn feed(p: &StreamingJsonParser, c: u8, token1: &?Token, token2: &?Token) Error!void {
208 pub fn feed(p: *StreamingJsonParser, c: u8, token1: *?Token, token2: *?Token) Error!void {
209209 token1.* = null;
210210 token2.* = null;
211211 p.count += 1;
......@@ -217,7 +217,7 @@ pub const StreamingJsonParser = struct {
217217 }
218218
219219 // Perform a single transition on the state machine and return any possible token.
220 fn transition(p: &StreamingJsonParser, c: u8, token: &?Token) Error!bool {
220 fn transition(p: *StreamingJsonParser, c: u8, token: *?Token) Error!bool {
221221 switch (p.state) {
222222 State.TopLevelBegin => switch (c) {
223223 '{' => {
......@@ -861,7 +861,7 @@ pub fn validate(s: []const u8) bool {
861861 var token1: ?Token = undefined;
862862 var token2: ?Token = undefined;
863863
864 p.feed(c, &token1, &token2) catch |err| {
864 p.feed(c, *token1, *token2) catch |err| {
865865 return false;
866866 };
867867 }
......@@ -878,7 +878,7 @@ pub const ValueTree = struct {
878878 arena: ArenaAllocator,
879879 root: Value,
880880
881 pub fn deinit(self: &ValueTree) void {
881 pub fn deinit(self: *ValueTree) void {
882882 self.arena.deinit();
883883 }
884884};
......@@ -894,7 +894,7 @@ pub const Value = union(enum) {
894894 Array: ArrayList(Value),
895895 Object: ObjectMap,
896896
897 pub fn dump(self: &const Value) void {
897 pub fn dump(self: *const Value) void {
898898 switch (self.*) {
899899 Value.Null => {
900900 std.debug.warn("null");
......@@ -941,7 +941,7 @@ pub const Value = union(enum) {
941941 }
942942 }
943943
944 pub fn dumpIndent(self: &const Value, indent: usize) void {
944 pub fn dumpIndent(self: *const Value, indent: usize) void {
945945 if (indent == 0) {
946946 self.dump();
947947 } else {
......@@ -949,7 +949,7 @@ pub const Value = union(enum) {
949949 }
950950 }
951951
952 fn dumpIndentLevel(self: &const Value, indent: usize, level: usize) void {
952 fn dumpIndentLevel(self: *const Value, indent: usize, level: usize) void {
953953 switch (self.*) {
954954 Value.Null => {
955955 std.debug.warn("null");
......@@ -1013,7 +1013,7 @@ pub const Value = union(enum) {
10131013
10141014// A non-stream JSON parser which constructs a tree of Value's.
10151015pub const JsonParser = struct {
1016 allocator: &Allocator,
1016 allocator: *Allocator,
10171017 state: State,
10181018 copy_strings: bool,
10191019 // Stores parent nodes and un-combined Values.
......@@ -1026,7 +1026,7 @@ pub const JsonParser = struct {
10261026 Simple,
10271027 };
10281028
1029 pub fn init(allocator: &Allocator, copy_strings: bool) JsonParser {
1029 pub fn init(allocator: *Allocator, copy_strings: bool) JsonParser {
10301030 return JsonParser{
10311031 .allocator = allocator,
10321032 .state = State.Simple,
......@@ -1035,16 +1035,16 @@ pub const JsonParser = struct {
10351035 };
10361036 }
10371037
1038 pub fn deinit(p: &JsonParser) void {
1038 pub fn deinit(p: *JsonParser) void {
10391039 p.stack.deinit();
10401040 }
10411041
1042 pub fn reset(p: &JsonParser) void {
1042 pub fn reset(p: *JsonParser) void {
10431043 p.state = State.Simple;
10441044 p.stack.shrink(0);
10451045 }
10461046
1047 pub fn parse(p: &JsonParser, input: []const u8) !ValueTree {
1047 pub fn parse(p: *JsonParser, input: []const u8) !ValueTree {
10481048 var mp = StreamingJsonParser.init();
10491049
10501050 var arena = ArenaAllocator.init(p.allocator);
......@@ -1090,7 +1090,7 @@ pub const JsonParser = struct {
10901090
10911091 // Even though p.allocator exists, we take an explicit allocator so that allocation state
10921092 // can be cleaned up on error correctly during a `parse` on call.
1093 fn transition(p: &JsonParser, allocator: &Allocator, input: []const u8, i: usize, token: &const Token) !void {
1093 fn transition(p: *JsonParser, allocator: *Allocator, input: []const u8, i: usize, token: *const Token) !void {
10941094 switch (p.state) {
10951095 State.ObjectKey => switch (token.id) {
10961096 Token.Id.ObjectEnd => {
......@@ -1223,7 +1223,7 @@ pub const JsonParser = struct {
12231223 }
12241224 }
12251225
1226 fn pushToParent(p: &JsonParser, value: &const Value) !void {
1226 fn pushToParent(p: *JsonParser, value: *const Value) !void {
12271227 switch (p.stack.at(p.stack.len - 1)) {
12281228 // Object Parent -> [ ..., object, <key>, value ]
12291229 Value.String => |key| {
......@@ -1244,14 +1244,14 @@ pub const JsonParser = struct {
12441244 }
12451245 }
12461246
1247 fn parseString(p: &JsonParser, allocator: &Allocator, token: &const Token, input: []const u8, i: usize) !Value {
1247 fn parseString(p: *JsonParser, allocator: *Allocator, token: *const Token, input: []const u8, i: usize) !Value {
12481248 // TODO: We don't strictly have to copy values which do not contain any escape
12491249 // characters if flagged with the option.
12501250 const slice = token.slice(input, i);
12511251 return Value{ .String = try mem.dupe(p.allocator, u8, slice) };
12521252 }
12531253
1254 fn parseNumber(p: &JsonParser, token: &const Token, input: []const u8, i: usize) !Value {
1254 fn parseNumber(p: *JsonParser, token: *const Token, input: []const u8, i: usize) !Value {
12551255 return if (token.number_is_integer)
12561256 Value{ .Integer = try std.fmt.parseInt(i64, token.slice(input, i), 10) }
12571257 else
std/linked_list.zig+16-16
......@@ -21,11 +21,11 @@ fn BaseLinkedList(comptime T: type, comptime ParentType: type, comptime field_na
2121
2222 /// Node inside the linked list wrapping the actual data.
2323 pub const Node = struct {
24 prev: ?&Node,
25 next: ?&Node,
24 prev: ?*Node,
25 next: ?*Node,
2626 data: T,
2727
28 pub fn init(value: &const T) Node {
28 pub fn init(value: *const T) Node {
2929 return Node{
3030 .prev = null,
3131 .next = null,
......@@ -38,14 +38,14 @@ fn BaseLinkedList(comptime T: type, comptime ParentType: type, comptime field_na
3838 return Node.init({});
3939 }
4040
41 pub fn toData(node: &Node) &ParentType {
41 pub fn toData(node: *Node) *ParentType {
4242 comptime assert(isIntrusive());
4343 return @fieldParentPtr(ParentType, field_name, node);
4444 }
4545 };
4646
47 first: ?&Node,
48 last: ?&Node,
47 first: ?*Node,
48 last: ?*Node,
4949 len: usize,
5050
5151 /// Initialize a linked list.
......@@ -69,7 +69,7 @@ fn BaseLinkedList(comptime T: type, comptime ParentType: type, comptime field_na
6969 /// Arguments:
7070 /// node: Pointer to a node in the list.
7171 /// new_node: Pointer to the new node to insert.
72 pub fn insertAfter(list: &Self, node: &Node, new_node: &Node) void {
72 pub fn insertAfter(list: *Self, node: *Node, new_node: *Node) void {
7373 new_node.prev = node;
7474 if (node.next) |next_node| {
7575 // Intermediate node.
......@@ -90,7 +90,7 @@ fn BaseLinkedList(comptime T: type, comptime ParentType: type, comptime field_na
9090 /// Arguments:
9191 /// node: Pointer to a node in the list.
9292 /// new_node: Pointer to the new node to insert.
93 pub fn insertBefore(list: &Self, node: &Node, new_node: &Node) void {
93 pub fn insertBefore(list: *Self, node: *Node, new_node: *Node) void {
9494 new_node.next = node;
9595 if (node.prev) |prev_node| {
9696 // Intermediate node.
......@@ -110,7 +110,7 @@ fn BaseLinkedList(comptime T: type, comptime ParentType: type, comptime field_na
110110 ///
111111 /// Arguments:
112112 /// new_node: Pointer to the new node to insert.
113 pub fn append(list: &Self, new_node: &Node) void {
113 pub fn append(list: *Self, new_node: *Node) void {
114114 if (list.last) |last| {
115115 // Insert after last.
116116 list.insertAfter(last, new_node);
......@@ -124,7 +124,7 @@ fn BaseLinkedList(comptime T: type, comptime ParentType: type, comptime field_na
124124 ///
125125 /// Arguments:
126126 /// new_node: Pointer to the new node to insert.
127 pub fn prepend(list: &Self, new_node: &Node) void {
127 pub fn prepend(list: *Self, new_node: *Node) void {
128128 if (list.first) |first| {
129129 // Insert before first.
130130 list.insertBefore(first, new_node);
......@@ -143,7 +143,7 @@ fn BaseLinkedList(comptime T: type, comptime ParentType: type, comptime field_na
143143 ///
144144 /// Arguments:
145145 /// node: Pointer to the node to be removed.
146 pub fn remove(list: &Self, node: &Node) void {
146 pub fn remove(list: *Self, node: *Node) void {
147147 if (node.prev) |prev_node| {
148148 // Intermediate node.
149149 prev_node.next = node.next;
......@@ -168,7 +168,7 @@ fn BaseLinkedList(comptime T: type, comptime ParentType: type, comptime field_na
168168 ///
169169 /// Returns:
170170 /// A pointer to the last node in the list.
171 pub fn pop(list: &Self) ?&Node {
171 pub fn pop(list: *Self) ?*Node {
172172 const last = list.last ?? return null;
173173 list.remove(last);
174174 return last;
......@@ -178,7 +178,7 @@ fn BaseLinkedList(comptime T: type, comptime ParentType: type, comptime field_na
178178 ///
179179 /// Returns:
180180 /// A pointer to the first node in the list.
181 pub fn popFirst(list: &Self) ?&Node {
181 pub fn popFirst(list: *Self) ?*Node {
182182 const first = list.first ?? return null;
183183 list.remove(first);
184184 return first;
......@@ -191,7 +191,7 @@ fn BaseLinkedList(comptime T: type, comptime ParentType: type, comptime field_na
191191 ///
192192 /// Returns:
193193 /// A pointer to the new node.
194 pub fn allocateNode(list: &Self, allocator: &Allocator) !&Node {
194 pub fn allocateNode(list: *Self, allocator: *Allocator) !*Node {
195195 comptime assert(!isIntrusive());
196196 return allocator.create(Node);
197197 }
......@@ -201,7 +201,7 @@ fn BaseLinkedList(comptime T: type, comptime ParentType: type, comptime field_na
201201 /// Arguments:
202202 /// node: Pointer to the node to deallocate.
203203 /// allocator: Dynamic memory allocator.
204 pub fn destroyNode(list: &Self, node: &Node, allocator: &Allocator) void {
204 pub fn destroyNode(list: *Self, node: *Node, allocator: *Allocator) void {
205205 comptime assert(!isIntrusive());
206206 allocator.destroy(node);
207207 }
......@@ -214,7 +214,7 @@ fn BaseLinkedList(comptime T: type, comptime ParentType: type, comptime field_na
214214 ///
215215 /// Returns:
216216 /// A pointer to the new node.
217 pub fn createNode(list: &Self, data: &const T, allocator: &Allocator) !&Node {
217 pub fn createNode(list: *Self, data: *const T, allocator: *Allocator) !*Node {
218218 comptime assert(!isIntrusive());
219219 var node = try list.allocateNode(allocator);
220220 node.* = Node.init(data);
std/macho.zig+8-8
......@@ -42,13 +42,13 @@ pub const Symbol = struct {
4242 name: []const u8,
4343 address: u64,
4444
45 fn addressLessThan(lhs: &const Symbol, rhs: &const Symbol) bool {
45 fn addressLessThan(lhs: *const Symbol, rhs: *const Symbol) bool {
4646 return lhs.address < rhs.address;
4747 }
4848};
4949
5050pub const SymbolTable = struct {
51 allocator: &mem.Allocator,
51 allocator: *mem.Allocator,
5252 symbols: []const Symbol,
5353 strings: []const u8,
5454
......@@ -56,7 +56,7 @@ pub const SymbolTable = struct {
5656 // Ideally we'd use _mh_execute_header because it's always at 0x100000000
5757 // in the image but as it's located in a different section than executable
5858 // code, its displacement is different.
59 pub fn deinit(self: &SymbolTable) void {
59 pub fn deinit(self: *SymbolTable) void {
6060 self.allocator.free(self.symbols);
6161 self.symbols = []const Symbol{};
6262
......@@ -64,7 +64,7 @@ pub const SymbolTable = struct {
6464 self.strings = []const u8{};
6565 }
6666
67 pub fn search(self: &const SymbolTable, address: usize) ?&const Symbol {
67 pub fn search(self: *const SymbolTable, address: usize) ?*const Symbol {
6868 var min: usize = 0;
6969 var max: usize = self.symbols.len - 1; // Exclude sentinel.
7070 while (min < max) {
......@@ -83,7 +83,7 @@ pub const SymbolTable = struct {
8383 }
8484};
8585
86pub fn loadSymbols(allocator: &mem.Allocator, in: &io.FileInStream) !SymbolTable {
86pub fn loadSymbols(allocator: *mem.Allocator, in: *io.FileInStream) !SymbolTable {
8787 var file = in.file;
8888 try file.seekTo(0);
8989
......@@ -160,13 +160,13 @@ pub fn loadSymbols(allocator: &mem.Allocator, in: &io.FileInStream) !SymbolTable
160160 };
161161}
162162
163fn readNoEof(in: &io.FileInStream, comptime T: type, result: []T) !void {
163fn readNoEof(in: *io.FileInStream, comptime T: type, result: []T) !void {
164164 return in.stream.readNoEof(([]u8)(result));
165165}
166fn readOneNoEof(in: &io.FileInStream, comptime T: type, result: &T) !void {
166fn readOneNoEof(in: *io.FileInStream, comptime T: type, result: *T) !void {
167167 return readNoEof(in, T, result[0..1]);
168168}
169169
170fn isSymbol(sym: &const Nlist64) bool {
170fn isSymbol(sym: *const Nlist64) bool {
171171 return sym.n_value != 0 and sym.n_desc == 0;
172172}
std/math/complex/atan.zig+2-2
......@@ -29,7 +29,7 @@ fn redupif32(x: f32) f32 {
2929 return ((x - u * DP1) - u * DP2) - t * DP3;
3030}
3131
32fn atan32(z: &const Complex(f32)) Complex(f32) {
32fn atan32(z: *const Complex(f32)) Complex(f32) {
3333 const maxnum = 1.0e38;
3434
3535 const x = z.re;
......@@ -78,7 +78,7 @@ fn redupif64(x: f64) f64 {
7878 return ((x - u * DP1) - u * DP2) - t * DP3;
7979}
8080
81fn atan64(z: &const Complex(f64)) Complex(f64) {
81fn atan64(z: *const Complex(f64)) Complex(f64) {
8282 const maxnum = 1.0e308;
8383
8484 const x = z.re;
std/math/complex/cosh.zig+2-2
......@@ -15,7 +15,7 @@ pub fn cosh(z: var) Complex(@typeOf(z.re)) {
1515 };
1616}
1717
18fn cosh32(z: &const Complex(f32)) Complex(f32) {
18fn cosh32(z: *const Complex(f32)) Complex(f32) {
1919 const x = z.re;
2020 const y = z.im;
2121
......@@ -78,7 +78,7 @@ fn cosh32(z: &const Complex(f32)) Complex(f32) {
7878 return Complex(f32).new((x * x) * (y - y), (x + x) * (y - y));
7979}
8080
81fn cosh64(z: &const Complex(f64)) Complex(f64) {
81fn cosh64(z: *const Complex(f64)) Complex(f64) {
8282 const x = z.re;
8383 const y = z.im;
8484
std/math/complex/exp.zig+2-2
......@@ -16,7 +16,7 @@ pub fn exp(z: var) Complex(@typeOf(z.re)) {
1616 };
1717}
1818
19fn exp32(z: &const Complex(f32)) Complex(f32) {
19fn exp32(z: *const Complex(f32)) Complex(f32) {
2020 @setFloatMode(this, @import("builtin").FloatMode.Strict);
2121
2222 const exp_overflow = 0x42b17218; // max_exp * ln2 ~= 88.72283955
......@@ -63,7 +63,7 @@ fn exp32(z: &const Complex(f32)) Complex(f32) {
6363 }
6464}
6565
66fn exp64(z: &const Complex(f64)) Complex(f64) {
66fn exp64(z: *const Complex(f64)) Complex(f64) {
6767 const exp_overflow = 0x40862e42; // high bits of max_exp * ln2 ~= 710
6868 const cexp_overflow = 0x4096b8e4; // (max_exp - min_denorm_exp) * ln2
6969
std/math/complex/index.zig+7-7
......@@ -37,28 +37,28 @@ pub fn Complex(comptime T: type) type {
3737 };
3838 }
3939
40 pub fn add(self: &const Self, other: &const Self) Self {
40 pub fn add(self: *const Self, other: *const Self) Self {
4141 return Self{
4242 .re = self.re + other.re,
4343 .im = self.im + other.im,
4444 };
4545 }
4646
47 pub fn sub(self: &const Self, other: &const Self) Self {
47 pub fn sub(self: *const Self, other: *const Self) Self {
4848 return Self{
4949 .re = self.re - other.re,
5050 .im = self.im - other.im,
5151 };
5252 }
5353
54 pub fn mul(self: &const Self, other: &const Self) Self {
54 pub fn mul(self: *const Self, other: *const Self) Self {
5555 return Self{
5656 .re = self.re * other.re - self.im * other.im,
5757 .im = self.im * other.re + self.re * other.im,
5858 };
5959 }
6060
61 pub fn div(self: &const Self, other: &const Self) Self {
61 pub fn div(self: *const Self, other: *const Self) Self {
6262 const re_num = self.re * other.re + self.im * other.im;
6363 const im_num = self.im * other.re - self.re * other.im;
6464 const den = other.re * other.re + other.im * other.im;
......@@ -69,14 +69,14 @@ pub fn Complex(comptime T: type) type {
6969 };
7070 }
7171
72 pub fn conjugate(self: &const Self) Self {
72 pub fn conjugate(self: *const Self) Self {
7373 return Self{
7474 .re = self.re,
7575 .im = -self.im,
7676 };
7777 }
7878
79 pub fn reciprocal(self: &const Self) Self {
79 pub fn reciprocal(self: *const Self) Self {
8080 const m = self.re * self.re + self.im * self.im;
8181 return Self{
8282 .re = self.re / m,
......@@ -84,7 +84,7 @@ pub fn Complex(comptime T: type) type {
8484 };
8585 }
8686
87 pub fn magnitude(self: &const Self) T {
87 pub fn magnitude(self: *const Self) T {
8888 return math.sqrt(self.re * self.re + self.im * self.im);
8989 }
9090 };
std/math/complex/ldexp.zig+4-4
......@@ -14,7 +14,7 @@ pub fn ldexp_cexp(z: var, expt: i32) Complex(@typeOf(z.re)) {
1414 };
1515}
1616
17fn frexp_exp32(x: f32, expt: &i32) f32 {
17fn frexp_exp32(x: f32, expt: *i32) f32 {
1818 const k = 235; // reduction constant
1919 const kln2 = 162.88958740; // k * ln2
2020
......@@ -24,7 +24,7 @@ fn frexp_exp32(x: f32, expt: &i32) f32 {
2424 return @bitCast(f32, (hx & 0x7fffff) | ((0x7f + 127) << 23));
2525}
2626
27fn ldexp_cexp32(z: &const Complex(f32), expt: i32) Complex(f32) {
27fn ldexp_cexp32(z: *const Complex(f32), expt: i32) Complex(f32) {
2828 var ex_expt: i32 = undefined;
2929 const exp_x = frexp_exp32(z.re, &ex_expt);
3030 const exptf = expt + ex_expt;
......@@ -38,7 +38,7 @@ fn ldexp_cexp32(z: &const Complex(f32), expt: i32) Complex(f32) {
3838 return Complex(f32).new(math.cos(z.im) * exp_x * scale1 * scale2, math.sin(z.im) * exp_x * scale1 * scale2);
3939}
4040
41fn frexp_exp64(x: f64, expt: &i32) f64 {
41fn frexp_exp64(x: f64, expt: *i32) f64 {
4242 const k = 1799; // reduction constant
4343 const kln2 = 1246.97177782734161156; // k * ln2
4444
......@@ -54,7 +54,7 @@ fn frexp_exp64(x: f64, expt: &i32) f64 {
5454 return @bitCast(f64, (u64(high_word) << 32) | lx);
5555}
5656
57fn ldexp_cexp64(z: &const Complex(f64), expt: i32) Complex(f64) {
57fn ldexp_cexp64(z: *const Complex(f64), expt: i32) Complex(f64) {
5858 var ex_expt: i32 = undefined;
5959 const exp_x = frexp_exp64(z.re, &ex_expt);
6060 const exptf = i64(expt + ex_expt);
std/math/complex/pow.zig+1-1
......@@ -4,7 +4,7 @@ const math = std.math;
44const cmath = math.complex;
55const Complex = cmath.Complex;
66
7pub fn pow(comptime T: type, z: &const T, c: &const T) T {
7pub fn pow(comptime T: type, z: *const T, c: *const T) T {
88 const p = cmath.log(z);
99 const q = c.mul(p);
1010 return cmath.exp(q);
std/math/complex/sinh.zig+2-2
......@@ -15,7 +15,7 @@ pub fn sinh(z: var) Complex(@typeOf(z.re)) {
1515 };
1616}
1717
18fn sinh32(z: &const Complex(f32)) Complex(f32) {
18fn sinh32(z: *const Complex(f32)) Complex(f32) {
1919 const x = z.re;
2020 const y = z.im;
2121
......@@ -78,7 +78,7 @@ fn sinh32(z: &const Complex(f32)) Complex(f32) {
7878 return Complex(f32).new((x * x) * (y - y), (x + x) * (y - y));
7979}
8080
81fn sinh64(z: &const Complex(f64)) Complex(f64) {
81fn sinh64(z: *const Complex(f64)) Complex(f64) {
8282 const x = z.re;
8383 const y = z.im;
8484
std/math/complex/sqrt.zig+2-2
......@@ -15,7 +15,7 @@ pub fn sqrt(z: var) Complex(@typeOf(z.re)) {
1515 };
1616}
1717
18fn sqrt32(z: &const Complex(f32)) Complex(f32) {
18fn sqrt32(z: *const Complex(f32)) Complex(f32) {
1919 const x = z.re;
2020 const y = z.im;
2121
......@@ -57,7 +57,7 @@ fn sqrt32(z: &const Complex(f32)) Complex(f32) {
5757 }
5858}
5959
60fn sqrt64(z: &const Complex(f64)) Complex(f64) {
60fn sqrt64(z: *const Complex(f64)) Complex(f64) {
6161 // may encounter overflow for im,re >= DBL_MAX / (1 + sqrt(2))
6262 const threshold = 0x1.a827999fcef32p+1022;
6363
std/math/complex/tanh.zig+2-2
......@@ -13,7 +13,7 @@ pub fn tanh(z: var) Complex(@typeOf(z.re)) {
1313 };
1414}
1515
16fn tanh32(z: &const Complex(f32)) Complex(f32) {
16fn tanh32(z: *const Complex(f32)) Complex(f32) {
1717 const x = z.re;
1818 const y = z.im;
1919
......@@ -51,7 +51,7 @@ fn tanh32(z: &const Complex(f32)) Complex(f32) {
5151 return Complex(f32).new((beta * rho * s) / den, t / den);
5252}
5353
54fn tanh64(z: &const Complex(f64)) Complex(f64) {
54fn tanh64(z: *const Complex(f64)) Complex(f64) {
5555 const x = z.re;
5656 const y = z.im;
5757
std/math/hypot.zig+1-1
......@@ -52,7 +52,7 @@ fn hypot32(x: f32, y: f32) f32 {
5252 return z * math.sqrt(f32(f64(x) * x + f64(y) * y));
5353}
5454
55fn sq(hi: &f64, lo: &f64, x: f64) void {
55fn sq(hi: *f64, lo: *f64, x: f64) void {
5656 const split: f64 = 0x1.0p27 + 1.0;
5757 const xc = x * split;
5858 const xh = x - xc + xc;
std/math/index.zig+2-2
......@@ -46,12 +46,12 @@ pub fn forceEval(value: var) void {
4646 switch (T) {
4747 f32 => {
4848 var x: f32 = undefined;
49 const p = @ptrCast(&volatile f32, &x);
49 const p = @ptrCast(*volatile f32, &x);
5050 p.* = x;
5151 },
5252 f64 => {
5353 var x: f64 = undefined;
54 const p = @ptrCast(&volatile f64, &x);
54 const p = @ptrCast(*volatile f64, &x);
5555 p.* = x;
5656 },
5757 else => {
std/mem.zig+24-24
......@@ -13,7 +13,7 @@ pub const Allocator = struct {
1313 /// The returned newly allocated memory is undefined.
1414 /// `alignment` is guaranteed to be >= 1
1515 /// `alignment` is guaranteed to be a power of 2
16 allocFn: fn (self: &Allocator, byte_count: usize, alignment: u29) Error![]u8,
16 allocFn: fn (self: *Allocator, byte_count: usize, alignment: u29) Error![]u8,
1717
1818 /// If `new_byte_count > old_mem.len`:
1919 /// * `old_mem.len` is the same as what was returned from allocFn or reallocFn.
......@@ -26,22 +26,22 @@ pub const Allocator = struct {
2626 /// The returned newly allocated memory is undefined.
2727 /// `alignment` is guaranteed to be >= 1
2828 /// `alignment` is guaranteed to be a power of 2
29 reallocFn: fn (self: &Allocator, old_mem: []u8, new_byte_count: usize, alignment: u29) Error![]u8,
29 reallocFn: fn (self: *Allocator, old_mem: []u8, new_byte_count: usize, alignment: u29) Error![]u8,
3030
3131 /// Guaranteed: `old_mem.len` is the same as what was returned from `allocFn` or `reallocFn`
32 freeFn: fn (self: &Allocator, old_mem: []u8) void,
32 freeFn: fn (self: *Allocator, old_mem: []u8) void,
3333
34 fn create(self: &Allocator, comptime T: type) !&T {
35 if (@sizeOf(T) == 0) return &{};
34 fn create(self: *Allocator, comptime T: type) !*T {
35 if (@sizeOf(T) == 0) return *{};
3636 const slice = try self.alloc(T, 1);
3737 return &slice[0];
3838 }
3939
4040 // TODO once #733 is solved, this will replace create
41 fn construct(self: &Allocator, init: var) t: {
41 fn construct(self: *Allocator, init: var) t: {
4242 // TODO this is a workaround for type getting parsed as Error!&const T
4343 const T = @typeOf(init).Child;
44 break :t Error!&T;
44 break :t Error!*T;
4545 } {
4646 const T = @typeOf(init).Child;
4747 if (@sizeOf(T) == 0) return &{};
......@@ -51,17 +51,17 @@ pub const Allocator = struct {
5151 return ptr;
5252 }
5353
54 fn destroy(self: &Allocator, ptr: var) void {
54 fn destroy(self: *Allocator, ptr: var) void {
5555 self.free(ptr[0..1]);
5656 }
5757
58 fn alloc(self: &Allocator, comptime T: type, n: usize) ![]T {
58 fn alloc(self: *Allocator, comptime T: type, n: usize) ![]T {
5959 return self.alignedAlloc(T, @alignOf(T), n);
6060 }
6161
62 fn alignedAlloc(self: &Allocator, comptime T: type, comptime alignment: u29, n: usize) ![]align(alignment) T {
62 fn alignedAlloc(self: *Allocator, comptime T: type, comptime alignment: u29, n: usize) ![]align(alignment) T {
6363 if (n == 0) {
64 return (&align(alignment) T)(undefined)[0..0];
64 return (*align(alignment) T)(undefined)[0..0];
6565 }
6666 const byte_count = math.mul(usize, @sizeOf(T), n) catch return Error.OutOfMemory;
6767 const byte_slice = try self.allocFn(self, byte_count, alignment);
......@@ -73,17 +73,17 @@ pub const Allocator = struct {
7373 return ([]align(alignment) T)(@alignCast(alignment, byte_slice));
7474 }
7575
76 fn realloc(self: &Allocator, comptime T: type, old_mem: []T, n: usize) ![]T {
76 fn realloc(self: *Allocator, comptime T: type, old_mem: []T, n: usize) ![]T {
7777 return self.alignedRealloc(T, @alignOf(T), @alignCast(@alignOf(T), old_mem), n);
7878 }
7979
80 fn alignedRealloc(self: &Allocator, comptime T: type, comptime alignment: u29, old_mem: []align(alignment) T, n: usize) ![]align(alignment) T {
80 fn alignedRealloc(self: *Allocator, comptime T: type, comptime alignment: u29, old_mem: []align(alignment) T, n: usize) ![]align(alignment) T {
8181 if (old_mem.len == 0) {
8282 return self.alloc(T, n);
8383 }
8484 if (n == 0) {
8585 self.free(old_mem);
86 return (&align(alignment) T)(undefined)[0..0];
86 return (*align(alignment) T)(undefined)[0..0];
8787 }
8888
8989 const old_byte_slice = ([]u8)(old_mem);
......@@ -102,11 +102,11 @@ pub const Allocator = struct {
102102 /// Reallocate, but `n` must be less than or equal to `old_mem.len`.
103103 /// Unlike `realloc`, this function cannot fail.
104104 /// Shrinking to 0 is the same as calling `free`.
105 fn shrink(self: &Allocator, comptime T: type, old_mem: []T, n: usize) []T {
105 fn shrink(self: *Allocator, comptime T: type, old_mem: []T, n: usize) []T {
106106 return self.alignedShrink(T, @alignOf(T), @alignCast(@alignOf(T), old_mem), n);
107107 }
108108
109 fn alignedShrink(self: &Allocator, comptime T: type, comptime alignment: u29, old_mem: []align(alignment) T, n: usize) []align(alignment) T {
109 fn alignedShrink(self: *Allocator, comptime T: type, comptime alignment: u29, old_mem: []align(alignment) T, n: usize) []align(alignment) T {
110110 if (n == 0) {
111111 self.free(old_mem);
112112 return old_mem[0..0];
......@@ -123,10 +123,10 @@ pub const Allocator = struct {
123123 return ([]align(alignment) T)(@alignCast(alignment, byte_slice));
124124 }
125125
126 fn free(self: &Allocator, memory: var) void {
126 fn free(self: *Allocator, memory: var) void {
127127 const bytes = ([]const u8)(memory);
128128 if (bytes.len == 0) return;
129 const non_const_ptr = @intToPtr(&u8, @ptrToInt(bytes.ptr));
129 const non_const_ptr = @intToPtr(*u8, @ptrToInt(bytes.ptr));
130130 self.freeFn(self, non_const_ptr[0..bytes.len]);
131131 }
132132};
......@@ -186,7 +186,7 @@ pub fn allEqual(comptime T: type, slice: []const T, scalar: T) bool {
186186}
187187
188188/// Copies ::m to newly allocated memory. Caller is responsible to free it.
189pub fn dupe(allocator: &Allocator, comptime T: type, m: []const T) ![]T {
189pub fn dupe(allocator: *Allocator, comptime T: type, m: []const T) ![]T {
190190 const new_buf = try allocator.alloc(T, m.len);
191191 copy(T, new_buf, m);
192192 return new_buf;
......@@ -457,7 +457,7 @@ pub const SplitIterator = struct {
457457 split_bytes: []const u8,
458458 index: usize,
459459
460 pub fn next(self: &SplitIterator) ?[]const u8 {
460 pub fn next(self: *SplitIterator) ?[]const u8 {
461461 // move to beginning of token
462462 while (self.index < self.buffer.len and self.isSplitByte(self.buffer[self.index])) : (self.index += 1) {}
463463 const start = self.index;
......@@ -473,14 +473,14 @@ pub const SplitIterator = struct {
473473 }
474474
475475 /// Returns a slice of the remaining bytes. Does not affect iterator state.
476 pub fn rest(self: &const SplitIterator) []const u8 {
476 pub fn rest(self: *const SplitIterator) []const u8 {
477477 // move to beginning of token
478478 var index: usize = self.index;
479479 while (index < self.buffer.len and self.isSplitByte(self.buffer[index])) : (index += 1) {}
480480 return self.buffer[index..];
481481 }
482482
483 fn isSplitByte(self: &const SplitIterator, byte: u8) bool {
483 fn isSplitByte(self: *const SplitIterator, byte: u8) bool {
484484 for (self.split_bytes) |split_byte| {
485485 if (byte == split_byte) {
486486 return true;
......@@ -492,7 +492,7 @@ pub const SplitIterator = struct {
492492
493493/// Naively combines a series of strings with a separator.
494494/// Allocates memory for the result, which must be freed by the caller.
495pub fn join(allocator: &Allocator, sep: u8, strings: ...) ![]u8 {
495pub fn join(allocator: *Allocator, sep: u8, strings: ...) ![]u8 {
496496 comptime assert(strings.len >= 1);
497497 var total_strings_len: usize = strings.len; // 1 sep per string
498498 {
......@@ -649,7 +649,7 @@ test "mem.max" {
649649 assert(max(u8, "abcdefg") == 'g');
650650}
651651
652pub fn swap(comptime T: type, a: &T, b: &T) void {
652pub fn swap(comptime T: type, a: *T, b: *T) void {
653653 const tmp = a.*;
654654 a.* = b.*;
655655 b.* = tmp;
std/net.zig+4-4
......@@ -31,7 +31,7 @@ pub const Address = struct {
3131 };
3232 }
3333
34 pub fn initIp6(ip6: &const Ip6Addr, port: u16) Address {
34 pub fn initIp6(ip6: *const Ip6Addr, port: u16) Address {
3535 return Address{
3636 .family = posix.AF_INET6,
3737 .os_addr = posix.sockaddr{
......@@ -46,15 +46,15 @@ pub const Address = struct {
4646 };
4747 }
4848
49 pub fn initPosix(addr: &const posix.sockaddr) Address {
49 pub fn initPosix(addr: *const posix.sockaddr) Address {
5050 return Address{ .os_addr = addr.* };
5151 }
5252
53 pub fn format(self: &const Address, out_stream: var) !void {
53 pub fn format(self: *const Address, out_stream: var) !void {
5454 switch (self.os_addr.in.family) {
5555 posix.AF_INET => {
5656 const native_endian_port = std.mem.endianSwapIfLe(u16, self.os_addr.in.port);
57 const bytes = ([]const u8)((&self.os_addr.in.addr)[0..1]);
57 const bytes = ([]const u8)((*self.os_addr.in.addr)[0..1]);
5858 try out_stream.print("{}.{}.{}.{}:{}", bytes[0], bytes[1], bytes[2], bytes[3], native_endian_port);
5959 },
6060 posix.AF_INET6 => {
std/os/child_process.zig+30-30
......@@ -20,7 +20,7 @@ pub const ChildProcess = struct {
2020 pub handle: if (is_windows) windows.HANDLE else void,
2121 pub thread_handle: if (is_windows) windows.HANDLE else void,
2222
23 pub allocator: &mem.Allocator,
23 pub allocator: *mem.Allocator,
2424
2525 pub stdin: ?os.File,
2626 pub stdout: ?os.File,
......@@ -31,7 +31,7 @@ pub const ChildProcess = struct {
3131 pub argv: []const []const u8,
3232
3333 /// Leave as null to use the current env map using the supplied allocator.
34 pub env_map: ?&const BufMap,
34 pub env_map: ?*const BufMap,
3535
3636 pub stdin_behavior: StdIo,
3737 pub stdout_behavior: StdIo,
......@@ -47,7 +47,7 @@ pub const ChildProcess = struct {
4747 pub cwd: ?[]const u8,
4848
4949 err_pipe: if (is_windows) void else [2]i32,
50 llnode: if (is_windows) void else LinkedList(&ChildProcess).Node,
50 llnode: if (is_windows) void else LinkedList(*ChildProcess).Node,
5151
5252 pub const SpawnError = error{
5353 ProcessFdQuotaExceeded,
......@@ -84,7 +84,7 @@ pub const ChildProcess = struct {
8484
8585 /// First argument in argv is the executable.
8686 /// On success must call deinit.
87 pub fn init(argv: []const []const u8, allocator: &mem.Allocator) !&ChildProcess {
87 pub fn init(argv: []const []const u8, allocator: *mem.Allocator) !*ChildProcess {
8888 const child = try allocator.create(ChildProcess);
8989 errdefer allocator.destroy(child);
9090
......@@ -114,14 +114,14 @@ pub const ChildProcess = struct {
114114 return child;
115115 }
116116
117 pub fn setUserName(self: &ChildProcess, name: []const u8) !void {
117 pub fn setUserName(self: *ChildProcess, name: []const u8) !void {
118118 const user_info = try os.getUserInfo(name);
119119 self.uid = user_info.uid;
120120 self.gid = user_info.gid;
121121 }
122122
123123 /// On success must call `kill` or `wait`.
124 pub fn spawn(self: &ChildProcess) !void {
124 pub fn spawn(self: *ChildProcess) !void {
125125 if (is_windows) {
126126 return self.spawnWindows();
127127 } else {
......@@ -129,13 +129,13 @@ pub const ChildProcess = struct {
129129 }
130130 }
131131
132 pub fn spawnAndWait(self: &ChildProcess) !Term {
132 pub fn spawnAndWait(self: *ChildProcess) !Term {
133133 try self.spawn();
134134 return self.wait();
135135 }
136136
137137 /// Forcibly terminates child process and then cleans up all resources.
138 pub fn kill(self: &ChildProcess) !Term {
138 pub fn kill(self: *ChildProcess) !Term {
139139 if (is_windows) {
140140 return self.killWindows(1);
141141 } else {
......@@ -143,7 +143,7 @@ pub const ChildProcess = struct {
143143 }
144144 }
145145
146 pub fn killWindows(self: &ChildProcess, exit_code: windows.UINT) !Term {
146 pub fn killWindows(self: *ChildProcess, exit_code: windows.UINT) !Term {
147147 if (self.term) |term| {
148148 self.cleanupStreams();
149149 return term;
......@@ -159,7 +159,7 @@ pub const ChildProcess = struct {
159159 return ??self.term;
160160 }
161161
162 pub fn killPosix(self: &ChildProcess) !Term {
162 pub fn killPosix(self: *ChildProcess) !Term {
163163 if (self.term) |term| {
164164 self.cleanupStreams();
165165 return term;
......@@ -179,7 +179,7 @@ pub const ChildProcess = struct {
179179 }
180180
181181 /// Blocks until child process terminates and then cleans up all resources.
182 pub fn wait(self: &ChildProcess) !Term {
182 pub fn wait(self: *ChildProcess) !Term {
183183 if (is_windows) {
184184 return self.waitWindows();
185185 } else {
......@@ -195,7 +195,7 @@ pub const ChildProcess = struct {
195195
196196 /// Spawns a child process, waits for it, collecting stdout and stderr, and then returns.
197197 /// If it succeeds, the caller owns result.stdout and result.stderr memory.
198 pub fn exec(allocator: &mem.Allocator, argv: []const []const u8, cwd: ?[]const u8, env_map: ?&const BufMap, max_output_size: usize) !ExecResult {
198 pub fn exec(allocator: *mem.Allocator, argv: []const []const u8, cwd: ?[]const u8, env_map: ?*const BufMap, max_output_size: usize) !ExecResult {
199199 const child = try ChildProcess.init(argv, allocator);
200200 defer child.deinit();
201201
......@@ -225,7 +225,7 @@ pub const ChildProcess = struct {
225225 };
226226 }
227227
228 fn waitWindows(self: &ChildProcess) !Term {
228 fn waitWindows(self: *ChildProcess) !Term {
229229 if (self.term) |term| {
230230 self.cleanupStreams();
231231 return term;
......@@ -235,7 +235,7 @@ pub const ChildProcess = struct {
235235 return ??self.term;
236236 }
237237
238 fn waitPosix(self: &ChildProcess) !Term {
238 fn waitPosix(self: *ChildProcess) !Term {
239239 if (self.term) |term| {
240240 self.cleanupStreams();
241241 return term;
......@@ -245,11 +245,11 @@ pub const ChildProcess = struct {
245245 return ??self.term;
246246 }
247247
248 pub fn deinit(self: &ChildProcess) void {
248 pub fn deinit(self: *ChildProcess) void {
249249 self.allocator.destroy(self);
250250 }
251251
252 fn waitUnwrappedWindows(self: &ChildProcess) !void {
252 fn waitUnwrappedWindows(self: *ChildProcess) !void {
253253 const result = os.windowsWaitSingle(self.handle, windows.INFINITE);
254254
255255 self.term = (SpawnError!Term)(x: {
......@@ -267,7 +267,7 @@ pub const ChildProcess = struct {
267267 return result;
268268 }
269269
270 fn waitUnwrapped(self: &ChildProcess) void {
270 fn waitUnwrapped(self: *ChildProcess) void {
271271 var status: i32 = undefined;
272272 while (true) {
273273 const err = posix.getErrno(posix.waitpid(self.pid, &status, 0));
......@@ -283,11 +283,11 @@ pub const ChildProcess = struct {
283283 }
284284 }
285285
286 fn handleWaitResult(self: &ChildProcess, status: i32) void {
286 fn handleWaitResult(self: *ChildProcess, status: i32) void {
287287 self.term = self.cleanupAfterWait(status);
288288 }
289289
290 fn cleanupStreams(self: &ChildProcess) void {
290 fn cleanupStreams(self: *ChildProcess) void {
291291 if (self.stdin) |*stdin| {
292292 stdin.close();
293293 self.stdin = null;
......@@ -302,7 +302,7 @@ pub const ChildProcess = struct {
302302 }
303303 }
304304
305 fn cleanupAfterWait(self: &ChildProcess, status: i32) !Term {
305 fn cleanupAfterWait(self: *ChildProcess, status: i32) !Term {
306306 defer {
307307 os.close(self.err_pipe[0]);
308308 os.close(self.err_pipe[1]);
......@@ -335,7 +335,7 @@ pub const ChildProcess = struct {
335335 Term{ .Unknown = status };
336336 }
337337
338 fn spawnPosix(self: &ChildProcess) !void {
338 fn spawnPosix(self: *ChildProcess) !void {
339339 const stdin_pipe = if (self.stdin_behavior == StdIo.Pipe) try makePipe() else undefined;
340340 errdefer if (self.stdin_behavior == StdIo.Pipe) {
341341 destroyPipe(stdin_pipe);
......@@ -432,7 +432,7 @@ pub const ChildProcess = struct {
432432
433433 self.pid = pid;
434434 self.err_pipe = err_pipe;
435 self.llnode = LinkedList(&ChildProcess).Node.init(self);
435 self.llnode = LinkedList(*ChildProcess).Node.init(self);
436436 self.term = null;
437437
438438 if (self.stdin_behavior == StdIo.Pipe) {
......@@ -446,7 +446,7 @@ pub const ChildProcess = struct {
446446 }
447447 }
448448
449 fn spawnWindows(self: &ChildProcess) !void {
449 fn spawnWindows(self: *ChildProcess) !void {
450450 const saAttr = windows.SECURITY_ATTRIBUTES{
451451 .nLength = @sizeOf(windows.SECURITY_ATTRIBUTES),
452452 .bInheritHandle = windows.TRUE,
......@@ -639,8 +639,8 @@ pub const ChildProcess = struct {
639639 }
640640};
641641
642fn windowsCreateProcess(app_name: &u8, cmd_line: &u8, envp_ptr: ?&u8, cwd_ptr: ?&u8, lpStartupInfo: &windows.STARTUPINFOA, lpProcessInformation: &windows.PROCESS_INFORMATION) !void {
643 if (windows.CreateProcessA(app_name, cmd_line, null, null, windows.TRUE, 0, @ptrCast(?&c_void, envp_ptr), cwd_ptr, lpStartupInfo, lpProcessInformation) == 0) {
642fn windowsCreateProcess(app_name: *u8, cmd_line: *u8, envp_ptr: ?*u8, cwd_ptr: ?*u8, lpStartupInfo: *windows.STARTUPINFOA, lpProcessInformation: *windows.PROCESS_INFORMATION) !void {
643 if (windows.CreateProcessA(app_name, cmd_line, null, null, windows.TRUE, 0, @ptrCast(?*c_void, envp_ptr), cwd_ptr, lpStartupInfo, lpProcessInformation) == 0) {
644644 const err = windows.GetLastError();
645645 return switch (err) {
646646 windows.ERROR.FILE_NOT_FOUND, windows.ERROR.PATH_NOT_FOUND => error.FileNotFound,
......@@ -653,7 +653,7 @@ fn windowsCreateProcess(app_name: &u8, cmd_line: &u8, envp_ptr: ?&u8, cwd_ptr: ?
653653
654654/// Caller must dealloc.
655655/// Guarantees a null byte at result[result.len].
656fn windowsCreateCommandLine(allocator: &mem.Allocator, argv: []const []const u8) ![]u8 {
656fn windowsCreateCommandLine(allocator: *mem.Allocator, argv: []const []const u8) ![]u8 {
657657 var buf = try Buffer.initSize(allocator, 0);
658658 defer buf.deinit();
659659
......@@ -698,7 +698,7 @@ fn windowsDestroyPipe(rd: ?windows.HANDLE, wr: ?windows.HANDLE) void {
698698// a namespace field lookup
699699const SECURITY_ATTRIBUTES = windows.SECURITY_ATTRIBUTES;
700700
701fn windowsMakePipe(rd: &windows.HANDLE, wr: &windows.HANDLE, sattr: &const SECURITY_ATTRIBUTES) !void {
701fn windowsMakePipe(rd: *windows.HANDLE, wr: *windows.HANDLE, sattr: *const SECURITY_ATTRIBUTES) !void {
702702 if (windows.CreatePipe(rd, wr, sattr, 0) == 0) {
703703 const err = windows.GetLastError();
704704 return switch (err) {
......@@ -716,7 +716,7 @@ fn windowsSetHandleInfo(h: windows.HANDLE, mask: windows.DWORD, flags: windows.D
716716 }
717717}
718718
719fn windowsMakePipeIn(rd: &?windows.HANDLE, wr: &?windows.HANDLE, sattr: &const SECURITY_ATTRIBUTES) !void {
719fn windowsMakePipeIn(rd: *?windows.HANDLE, wr: *?windows.HANDLE, sattr: *const SECURITY_ATTRIBUTES) !void {
720720 var rd_h: windows.HANDLE = undefined;
721721 var wr_h: windows.HANDLE = undefined;
722722 try windowsMakePipe(&rd_h, &wr_h, sattr);
......@@ -726,7 +726,7 @@ fn windowsMakePipeIn(rd: &?windows.HANDLE, wr: &?windows.HANDLE, sattr: &const S
726726 wr.* = wr_h;
727727}
728728
729fn windowsMakePipeOut(rd: &?windows.HANDLE, wr: &?windows.HANDLE, sattr: &const SECURITY_ATTRIBUTES) !void {
729fn windowsMakePipeOut(rd: *?windows.HANDLE, wr: *?windows.HANDLE, sattr: *const SECURITY_ATTRIBUTES) !void {
730730 var rd_h: windows.HANDLE = undefined;
731731 var wr_h: windows.HANDLE = undefined;
732732 try windowsMakePipe(&rd_h, &wr_h, sattr);
......@@ -748,7 +748,7 @@ fn makePipe() ![2]i32 {
748748 return fds;
749749}
750750
751fn destroyPipe(pipe: &const [2]i32) void {
751fn destroyPipe(pipe: *const [2]i32) void {
752752 os.close((pipe.*)[0]);
753753 os.close((pipe.*)[1]);
754754}
std/os/darwin.zig+32-32
......@@ -309,7 +309,7 @@ pub fn isatty(fd: i32) bool {
309309 return c.isatty(fd) != 0;
310310}
311311
312pub fn fstat(fd: i32, buf: &c.Stat) usize {
312pub fn fstat(fd: i32, buf: *c.Stat) usize {
313313 return errnoWrap(c.@"fstat$INODE64"(fd, buf));
314314}
315315
......@@ -317,7 +317,7 @@ pub fn lseek(fd: i32, offset: isize, whence: c_int) usize {
317317 return errnoWrap(c.lseek(fd, offset, whence));
318318}
319319
320pub fn open(path: &const u8, flags: u32, mode: usize) usize {
320pub fn open(path: *const u8, flags: u32, mode: usize) usize {
321321 return errnoWrap(c.open(path, @bitCast(c_int, flags), mode));
322322}
323323
......@@ -325,79 +325,79 @@ pub fn raise(sig: i32) usize {
325325 return errnoWrap(c.raise(sig));
326326}
327327
328pub fn read(fd: i32, buf: &u8, nbyte: usize) usize {
329 return errnoWrap(c.read(fd, @ptrCast(&c_void, buf), nbyte));
328pub fn read(fd: i32, buf: *u8, nbyte: usize) usize {
329 return errnoWrap(c.read(fd, @ptrCast(*c_void, buf), nbyte));
330330}
331331
332pub fn stat(noalias path: &const u8, noalias buf: &stat) usize {
332pub fn stat(noalias path: *const u8, noalias buf: *stat) usize {
333333 return errnoWrap(c.stat(path, buf));
334334}
335335
336pub fn write(fd: i32, buf: &const u8, nbyte: usize) usize {
337 return errnoWrap(c.write(fd, @ptrCast(&const c_void, buf), nbyte));
336pub fn write(fd: i32, buf: *const u8, nbyte: usize) usize {
337 return errnoWrap(c.write(fd, @ptrCast(*const c_void, buf), nbyte));
338338}
339339
340pub fn mmap(address: ?&u8, length: usize, prot: usize, flags: u32, fd: i32, offset: isize) usize {
341 const ptr_result = c.mmap(@ptrCast(&c_void, address), length, @bitCast(c_int, c_uint(prot)), @bitCast(c_int, c_uint(flags)), fd, offset);
340pub fn mmap(address: ?*u8, length: usize, prot: usize, flags: u32, fd: i32, offset: isize) usize {
341 const ptr_result = c.mmap(@ptrCast(*c_void, address), length, @bitCast(c_int, c_uint(prot)), @bitCast(c_int, c_uint(flags)), fd, offset);
342342 const isize_result = @bitCast(isize, @ptrToInt(ptr_result));
343343 return errnoWrap(isize_result);
344344}
345345
346346pub fn munmap(address: usize, length: usize) usize {
347 return errnoWrap(c.munmap(@intToPtr(&c_void, address), length));
347 return errnoWrap(c.munmap(@intToPtr(*c_void, address), length));
348348}
349349
350pub fn unlink(path: &const u8) usize {
350pub fn unlink(path: *const u8) usize {
351351 return errnoWrap(c.unlink(path));
352352}
353353
354pub fn getcwd(buf: &u8, size: usize) usize {
354pub fn getcwd(buf: *u8, size: usize) usize {
355355 return if (c.getcwd(buf, size) == null) @bitCast(usize, -isize(c._errno().*)) else 0;
356356}
357357
358pub fn waitpid(pid: i32, status: &i32, options: u32) usize {
358pub fn waitpid(pid: i32, status: *i32, options: u32) usize {
359359 comptime assert(i32.bit_count == c_int.bit_count);
360 return errnoWrap(c.waitpid(pid, @ptrCast(&c_int, status), @bitCast(c_int, options)));
360 return errnoWrap(c.waitpid(pid, @ptrCast(*c_int, status), @bitCast(c_int, options)));
361361}
362362
363363pub fn fork() usize {
364364 return errnoWrap(c.fork());
365365}
366366
367pub fn access(path: &const u8, mode: u32) usize {
367pub fn access(path: *const u8, mode: u32) usize {
368368 return errnoWrap(c.access(path, mode));
369369}
370370
371pub fn pipe(fds: &[2]i32) usize {
371pub fn pipe(fds: *[2]i32) usize {
372372 comptime assert(i32.bit_count == c_int.bit_count);
373 return errnoWrap(c.pipe(@ptrCast(&c_int, fds)));
373 return errnoWrap(c.pipe(@ptrCast(*c_int, fds)));
374374}
375375
376pub fn getdirentries64(fd: i32, buf_ptr: &u8, buf_len: usize, basep: &i64) usize {
376pub fn getdirentries64(fd: i32, buf_ptr: *u8, buf_len: usize, basep: *i64) usize {
377377 return errnoWrap(@bitCast(isize, c.__getdirentries64(fd, buf_ptr, buf_len, basep)));
378378}
379379
380pub fn mkdir(path: &const u8, mode: u32) usize {
380pub fn mkdir(path: *const u8, mode: u32) usize {
381381 return errnoWrap(c.mkdir(path, mode));
382382}
383383
384pub fn symlink(existing: &const u8, new: &const u8) usize {
384pub fn symlink(existing: *const u8, new: *const u8) usize {
385385 return errnoWrap(c.symlink(existing, new));
386386}
387387
388pub fn rename(old: &const u8, new: &const u8) usize {
388pub fn rename(old: *const u8, new: *const u8) usize {
389389 return errnoWrap(c.rename(old, new));
390390}
391391
392pub fn rmdir(path: &const u8) usize {
392pub fn rmdir(path: *const u8) usize {
393393 return errnoWrap(c.rmdir(path));
394394}
395395
396pub fn chdir(path: &const u8) usize {
396pub fn chdir(path: *const u8) usize {
397397 return errnoWrap(c.chdir(path));
398398}
399399
400pub fn execve(path: &const u8, argv: &const ?&const u8, envp: &const ?&const u8) usize {
400pub fn execve(path: *const u8, argv: *const ?*const u8, envp: *const ?*const u8) usize {
401401 return errnoWrap(c.execve(path, argv, envp));
402402}
403403
......@@ -405,19 +405,19 @@ pub fn dup2(old: i32, new: i32) usize {
405405 return errnoWrap(c.dup2(old, new));
406406}
407407
408pub fn readlink(noalias path: &const u8, noalias buf_ptr: &u8, buf_len: usize) usize {
408pub fn readlink(noalias path: *const u8, noalias buf_ptr: *u8, buf_len: usize) usize {
409409 return errnoWrap(c.readlink(path, buf_ptr, buf_len));
410410}
411411
412pub fn gettimeofday(tv: ?&timeval, tz: ?&timezone) usize {
412pub fn gettimeofday(tv: ?*timeval, tz: ?*timezone) usize {
413413 return errnoWrap(c.gettimeofday(tv, tz));
414414}
415415
416pub fn nanosleep(req: &const timespec, rem: ?&timespec) usize {
416pub fn nanosleep(req: *const timespec, rem: ?*timespec) usize {
417417 return errnoWrap(c.nanosleep(req, rem));
418418}
419419
420pub fn realpath(noalias filename: &const u8, noalias resolved_name: &u8) usize {
420pub fn realpath(noalias filename: *const u8, noalias resolved_name: *u8) usize {
421421 return if (c.realpath(filename, resolved_name) == null) @bitCast(usize, -isize(c._errno().*)) else 0;
422422}
423423
......@@ -429,11 +429,11 @@ pub fn setregid(rgid: u32, egid: u32) usize {
429429 return errnoWrap(c.setregid(rgid, egid));
430430}
431431
432pub fn sigprocmask(flags: u32, noalias set: &const sigset_t, noalias oldset: ?&sigset_t) usize {
432pub fn sigprocmask(flags: u32, noalias set: *const sigset_t, noalias oldset: ?*sigset_t) usize {
433433 return errnoWrap(c.sigprocmask(@bitCast(c_int, flags), set, oldset));
434434}
435435
436pub fn sigaction(sig: u5, noalias act: &const Sigaction, noalias oact: ?&Sigaction) usize {
436pub fn sigaction(sig: u5, noalias act: *const Sigaction, noalias oact: ?*Sigaction) usize {
437437 assert(sig != SIGKILL);
438438 assert(sig != SIGSTOP);
439439 var cact = c.Sigaction{
......@@ -442,7 +442,7 @@ pub fn sigaction(sig: u5, noalias act: &const Sigaction, noalias oact: ?&Sigacti
442442 .sa_mask = act.mask,
443443 };
444444 var coact: c.Sigaction = undefined;
445 const result = errnoWrap(c.sigaction(sig, &cact, &coact));
445 const result = errnoWrap(c.sigaction(sig, *cact, *coact));
446446 if (result != 0) {
447447 return result;
448448 }
......@@ -473,7 +473,7 @@ pub const Sigaction = struct {
473473 flags: u32,
474474};
475475
476pub fn sigaddset(set: &sigset_t, signo: u5) void {
476pub fn sigaddset(set: *sigset_t, signo: u5) void {
477477 set.* |= u32(1) << (signo - 1);
478478}
479479
std/os/file.zig+16-16
......@@ -19,7 +19,7 @@ pub const File = struct {
1919
2020 /// `path` needs to be copied in memory to add a null terminating byte, hence the allocator.
2121 /// Call close to clean up.
22 pub fn openRead(allocator: &mem.Allocator, path: []const u8) OpenError!File {
22 pub fn openRead(allocator: *mem.Allocator, path: []const u8) OpenError!File {
2323 if (is_posix) {
2424 const flags = posix.O_LARGEFILE | posix.O_RDONLY;
2525 const fd = try os.posixOpen(allocator, path, flags, 0);
......@@ -40,7 +40,7 @@ pub const File = struct {
4040 }
4141
4242 /// Calls `openWriteMode` with os.default_file_mode for the mode.
43 pub fn openWrite(allocator: &mem.Allocator, path: []const u8) OpenError!File {
43 pub fn openWrite(allocator: *mem.Allocator, path: []const u8) OpenError!File {
4444 return openWriteMode(allocator, path, os.default_file_mode);
4545 }
4646
......@@ -48,7 +48,7 @@ pub const File = struct {
4848 /// If a file already exists in the destination it will be truncated.
4949 /// `path` needs to be copied in memory to add a null terminating byte, hence the allocator.
5050 /// Call close to clean up.
51 pub fn openWriteMode(allocator: &mem.Allocator, path: []const u8, file_mode: os.FileMode) OpenError!File {
51 pub fn openWriteMode(allocator: *mem.Allocator, path: []const u8, file_mode: os.FileMode) OpenError!File {
5252 if (is_posix) {
5353 const flags = posix.O_LARGEFILE | posix.O_WRONLY | posix.O_CREAT | posix.O_CLOEXEC | posix.O_TRUNC;
5454 const fd = try os.posixOpen(allocator, path, flags, file_mode);
......@@ -72,7 +72,7 @@ pub const File = struct {
7272 /// If a file already exists in the destination this returns OpenError.PathAlreadyExists
7373 /// `path` needs to be copied in memory to add a null terminating byte, hence the allocator.
7474 /// Call close to clean up.
75 pub fn openWriteNoClobber(allocator: &mem.Allocator, path: []const u8, file_mode: os.FileMode) OpenError!File {
75 pub fn openWriteNoClobber(allocator: *mem.Allocator, path: []const u8, file_mode: os.FileMode) OpenError!File {
7676 if (is_posix) {
7777 const flags = posix.O_LARGEFILE | posix.O_WRONLY | posix.O_CREAT | posix.O_CLOEXEC | posix.O_EXCL;
7878 const fd = try os.posixOpen(allocator, path, flags, file_mode);
......@@ -96,7 +96,7 @@ pub const File = struct {
9696 return File{ .handle = handle };
9797 }
9898
99 pub fn access(allocator: &mem.Allocator, path: []const u8, file_mode: os.FileMode) !bool {
99 pub fn access(allocator: *mem.Allocator, path: []const u8, file_mode: os.FileMode) !bool {
100100 const path_with_null = try std.cstr.addNullByte(allocator, path);
101101 defer allocator.free(path_with_null);
102102
......@@ -140,17 +140,17 @@ pub const File = struct {
140140
141141 /// Upon success, the stream is in an uninitialized state. To continue using it,
142142 /// you must use the open() function.
143 pub fn close(self: &File) void {
143 pub fn close(self: *File) void {
144144 os.close(self.handle);
145145 self.handle = undefined;
146146 }
147147
148148 /// Calls `os.isTty` on `self.handle`.
149 pub fn isTty(self: &File) bool {
149 pub fn isTty(self: *File) bool {
150150 return os.isTty(self.handle);
151151 }
152152
153 pub fn seekForward(self: &File, amount: isize) !void {
153 pub fn seekForward(self: *File, amount: isize) !void {
154154 switch (builtin.os) {
155155 Os.linux, Os.macosx, Os.ios => {
156156 const result = posix.lseek(self.handle, amount, posix.SEEK_CUR);
......@@ -179,7 +179,7 @@ pub const File = struct {
179179 }
180180 }
181181
182 pub fn seekTo(self: &File, pos: usize) !void {
182 pub fn seekTo(self: *File, pos: usize) !void {
183183 switch (builtin.os) {
184184 Os.linux, Os.macosx, Os.ios => {
185185 const ipos = try math.cast(isize, pos);
......@@ -210,7 +210,7 @@ pub const File = struct {
210210 }
211211 }
212212
213 pub fn getPos(self: &File) !usize {
213 pub fn getPos(self: *File) !usize {
214214 switch (builtin.os) {
215215 Os.linux, Os.macosx, Os.ios => {
216216 const result = posix.lseek(self.handle, 0, posix.SEEK_CUR);
......@@ -229,7 +229,7 @@ pub const File = struct {
229229 },
230230 Os.windows => {
231231 var pos: windows.LARGE_INTEGER = undefined;
232 if (windows.SetFilePointerEx(self.handle, 0, &pos, windows.FILE_CURRENT) == 0) {
232 if (windows.SetFilePointerEx(self.handle, 0, *pos, windows.FILE_CURRENT) == 0) {
233233 const err = windows.GetLastError();
234234 return switch (err) {
235235 windows.ERROR.INVALID_PARAMETER => error.BadFd,
......@@ -250,7 +250,7 @@ pub const File = struct {
250250 }
251251 }
252252
253 pub fn getEndPos(self: &File) !usize {
253 pub fn getEndPos(self: *File) !usize {
254254 if (is_posix) {
255255 var stat: posix.Stat = undefined;
256256 const err = posix.getErrno(posix.fstat(self.handle, &stat));
......@@ -285,7 +285,7 @@ pub const File = struct {
285285 Unexpected,
286286 };
287287
288 fn mode(self: &File) ModeError!os.FileMode {
288 fn mode(self: *File) ModeError!os.FileMode {
289289 if (is_posix) {
290290 var stat: posix.Stat = undefined;
291291 const err = posix.getErrno(posix.fstat(self.handle, &stat));
......@@ -309,7 +309,7 @@ pub const File = struct {
309309
310310 pub const ReadError = error{};
311311
312 pub fn read(self: &File, buffer: []u8) !usize {
312 pub fn read(self: *File, buffer: []u8) !usize {
313313 if (is_posix) {
314314 var index: usize = 0;
315315 while (index < buffer.len) {
......@@ -334,7 +334,7 @@ pub const File = struct {
334334 while (index < buffer.len) {
335335 const want_read_count = windows.DWORD(math.min(windows.DWORD(@maxValue(windows.DWORD)), buffer.len - index));
336336 var amt_read: windows.DWORD = undefined;
337 if (windows.ReadFile(self.handle, @ptrCast(&c_void, &buffer[index]), want_read_count, &amt_read, null) == 0) {
337 if (windows.ReadFile(self.handle, @ptrCast(*c_void, &buffer[index]), want_read_count, &amt_read, null) == 0) {
338338 const err = windows.GetLastError();
339339 return switch (err) {
340340 windows.ERROR.OPERATION_ABORTED => continue,
......@@ -353,7 +353,7 @@ pub const File = struct {
353353
354354 pub const WriteError = os.WindowsWriteError || os.PosixWriteError;
355355
356 fn write(self: &File, bytes: []const u8) WriteError!void {
356 fn write(self: *File, bytes: []const u8) WriteError!void {
357357 if (is_posix) {
358358 try os.posixWrite(self.handle, bytes);
359359 } else if (is_windows) {
std/os/get_user_id.zig+4-4
......@@ -77,8 +77,8 @@ pub fn posixGetUserInfo(name: []const u8) !UserInfo {
7777 '0'...'9' => byte - '0',
7878 else => return error.CorruptPasswordFile,
7979 };
80 if (@mulWithOverflow(u32, uid, 10, &uid)) return error.CorruptPasswordFile;
81 if (@addWithOverflow(u32, uid, digit, &uid)) return error.CorruptPasswordFile;
80 if (@mulWithOverflow(u32, uid, 10, *uid)) return error.CorruptPasswordFile;
81 if (@addWithOverflow(u32, uid, digit, *uid)) return error.CorruptPasswordFile;
8282 },
8383 },
8484 State.ReadGroupId => switch (byte) {
......@@ -93,8 +93,8 @@ pub fn posixGetUserInfo(name: []const u8) !UserInfo {
9393 '0'...'9' => byte - '0',
9494 else => return error.CorruptPasswordFile,
9595 };
96 if (@mulWithOverflow(u32, gid, 10, &gid)) return error.CorruptPasswordFile;
97 if (@addWithOverflow(u32, gid, digit, &gid)) return error.CorruptPasswordFile;
96 if (@mulWithOverflow(u32, gid, 10, *gid)) return error.CorruptPasswordFile;
97 if (@addWithOverflow(u32, gid, digit, *gid)) return error.CorruptPasswordFile;
9898 },
9999 },
100100 }
std/os/index.zig+82-82
......@@ -321,14 +321,14 @@ pub const PosixOpenError = error{
321321/// ::file_path needs to be copied in memory to add a null terminating byte.
322322/// Calls POSIX open, keeps trying if it gets interrupted, and translates
323323/// the return value into zig errors.
324pub fn posixOpen(allocator: &Allocator, file_path: []const u8, flags: u32, perm: usize) PosixOpenError!i32 {
324pub fn posixOpen(allocator: *Allocator, file_path: []const u8, flags: u32, perm: usize) PosixOpenError!i32 {
325325 const path_with_null = try cstr.addNullByte(allocator, file_path);
326326 defer allocator.free(path_with_null);
327327
328328 return posixOpenC(path_with_null.ptr, flags, perm);
329329}
330330
331pub fn posixOpenC(file_path: &const u8, flags: u32, perm: usize) !i32 {
331pub fn posixOpenC(file_path: *const u8, flags: u32, perm: usize) !i32 {
332332 while (true) {
333333 const result = posix.open(file_path, flags, perm);
334334 const err = posix.getErrno(result);
......@@ -374,10 +374,10 @@ pub fn posixDup2(old_fd: i32, new_fd: i32) !void {
374374 }
375375}
376376
377pub fn createNullDelimitedEnvMap(allocator: &Allocator, env_map: &const BufMap) ![]?&u8 {
377pub fn createNullDelimitedEnvMap(allocator: *Allocator, env_map: *const BufMap) ![]?*u8 {
378378 const envp_count = env_map.count();
379 const envp_buf = try allocator.alloc(?&u8, envp_count + 1);
380 mem.set(?&u8, envp_buf, null);
379 const envp_buf = try allocator.alloc(?*u8, envp_count + 1);
380 mem.set(?*u8, envp_buf, null);
381381 errdefer freeNullDelimitedEnvMap(allocator, envp_buf);
382382 {
383383 var it = env_map.iterator();
......@@ -397,7 +397,7 @@ pub fn createNullDelimitedEnvMap(allocator: &Allocator, env_map: &const BufMap)
397397 return envp_buf;
398398}
399399
400pub fn freeNullDelimitedEnvMap(allocator: &Allocator, envp_buf: []?&u8) void {
400pub fn freeNullDelimitedEnvMap(allocator: *Allocator, envp_buf: []?*u8) void {
401401 for (envp_buf) |env| {
402402 const env_buf = if (env) |ptr| ptr[0 .. cstr.len(ptr) + 1] else break;
403403 allocator.free(env_buf);
......@@ -410,9 +410,9 @@ pub fn freeNullDelimitedEnvMap(allocator: &Allocator, envp_buf: []?&u8) void {
410410/// pointers after the args and after the environment variables.
411411/// `argv[0]` is the executable path.
412412/// This function also uses the PATH environment variable to get the full path to the executable.
413pub fn posixExecve(argv: []const []const u8, env_map: &const BufMap, allocator: &Allocator) !void {
414 const argv_buf = try allocator.alloc(?&u8, argv.len + 1);
415 mem.set(?&u8, argv_buf, null);
413pub fn posixExecve(argv: []const []const u8, env_map: *const BufMap, allocator: *Allocator) !void {
414 const argv_buf = try allocator.alloc(?*u8, argv.len + 1);
415 mem.set(?*u8, argv_buf, null);
416416 defer {
417417 for (argv_buf) |arg| {
418418 const arg_buf = if (arg) |ptr| cstr.toSlice(ptr) else break;
......@@ -494,10 +494,10 @@ fn posixExecveErrnoToErr(err: usize) PosixExecveError {
494494}
495495
496496pub var linux_aux_raw = []usize{0} ** 38;
497pub var posix_environ_raw: []&u8 = undefined;
497pub var posix_environ_raw: []*u8 = undefined;
498498
499499/// Caller must free result when done.
500pub fn getEnvMap(allocator: &Allocator) !BufMap {
500pub fn getEnvMap(allocator: *Allocator) !BufMap {
501501 var result = BufMap.init(allocator);
502502 errdefer result.deinit();
503503
......@@ -557,7 +557,7 @@ pub fn getEnvPosix(key: []const u8) ?[]const u8 {
557557}
558558
559559/// Caller must free returned memory.
560pub fn getEnvVarOwned(allocator: &mem.Allocator, key: []const u8) ![]u8 {
560pub fn getEnvVarOwned(allocator: *mem.Allocator, key: []const u8) ![]u8 {
561561 if (is_windows) {
562562 const key_with_null = try cstr.addNullByte(allocator, key);
563563 defer allocator.free(key_with_null);
......@@ -591,7 +591,7 @@ pub fn getEnvVarOwned(allocator: &mem.Allocator, key: []const u8) ![]u8 {
591591}
592592
593593/// Caller must free the returned memory.
594pub fn getCwd(allocator: &Allocator) ![]u8 {
594pub fn getCwd(allocator: *Allocator) ![]u8 {
595595 switch (builtin.os) {
596596 Os.windows => {
597597 var buf = try allocator.alloc(u8, 256);
......@@ -640,7 +640,7 @@ test "os.getCwd" {
640640
641641pub const SymLinkError = PosixSymLinkError || WindowsSymLinkError;
642642
643pub fn symLink(allocator: &Allocator, existing_path: []const u8, new_path: []const u8) SymLinkError!void {
643pub fn symLink(allocator: *Allocator, existing_path: []const u8, new_path: []const u8) SymLinkError!void {
644644 if (is_windows) {
645645 return symLinkWindows(allocator, existing_path, new_path);
646646 } else {
......@@ -653,7 +653,7 @@ pub const WindowsSymLinkError = error{
653653 Unexpected,
654654};
655655
656pub fn symLinkWindows(allocator: &Allocator, existing_path: []const u8, new_path: []const u8) WindowsSymLinkError!void {
656pub fn symLinkWindows(allocator: *Allocator, existing_path: []const u8, new_path: []const u8) WindowsSymLinkError!void {
657657 const existing_with_null = try cstr.addNullByte(allocator, existing_path);
658658 defer allocator.free(existing_with_null);
659659 const new_with_null = try cstr.addNullByte(allocator, new_path);
......@@ -683,7 +683,7 @@ pub const PosixSymLinkError = error{
683683 Unexpected,
684684};
685685
686pub fn symLinkPosix(allocator: &Allocator, existing_path: []const u8, new_path: []const u8) PosixSymLinkError!void {
686pub fn symLinkPosix(allocator: *Allocator, existing_path: []const u8, new_path: []const u8) PosixSymLinkError!void {
687687 const full_buf = try allocator.alloc(u8, existing_path.len + new_path.len + 2);
688688 defer allocator.free(full_buf);
689689
......@@ -718,7 +718,7 @@ pub fn symLinkPosix(allocator: &Allocator, existing_path: []const u8, new_path:
718718// here we replace the standard +/ with -_ so that it can be used in a file name
719719const b64_fs_encoder = base64.Base64Encoder.init("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", base64.standard_pad_char);
720720
721pub fn atomicSymLink(allocator: &Allocator, existing_path: []const u8, new_path: []const u8) !void {
721pub fn atomicSymLink(allocator: *Allocator, existing_path: []const u8, new_path: []const u8) !void {
722722 if (symLink(allocator, existing_path, new_path)) {
723723 return;
724724 } else |err| switch (err) {
......@@ -746,7 +746,7 @@ pub fn atomicSymLink(allocator: &Allocator, existing_path: []const u8, new_path:
746746 }
747747}
748748
749pub fn deleteFile(allocator: &Allocator, file_path: []const u8) !void {
749pub fn deleteFile(allocator: *Allocator, file_path: []const u8) !void {
750750 if (builtin.os == Os.windows) {
751751 return deleteFileWindows(allocator, file_path);
752752 } else {
......@@ -754,7 +754,7 @@ pub fn deleteFile(allocator: &Allocator, file_path: []const u8) !void {
754754 }
755755}
756756
757pub fn deleteFileWindows(allocator: &Allocator, file_path: []const u8) !void {
757pub fn deleteFileWindows(allocator: *Allocator, file_path: []const u8) !void {
758758 const buf = try allocator.alloc(u8, file_path.len + 1);
759759 defer allocator.free(buf);
760760
......@@ -772,7 +772,7 @@ pub fn deleteFileWindows(allocator: &Allocator, file_path: []const u8) !void {
772772 }
773773}
774774
775pub fn deleteFilePosix(allocator: &Allocator, file_path: []const u8) !void {
775pub fn deleteFilePosix(allocator: *Allocator, file_path: []const u8) !void {
776776 const buf = try allocator.alloc(u8, file_path.len + 1);
777777 defer allocator.free(buf);
778778
......@@ -803,7 +803,7 @@ pub fn deleteFilePosix(allocator: &Allocator, file_path: []const u8) !void {
803803/// there is a possibility of power loss or application termination leaving temporary files present
804804/// in the same directory as dest_path.
805805/// Destination file will have the same mode as the source file.
806pub fn copyFile(allocator: &Allocator, source_path: []const u8, dest_path: []const u8) !void {
806pub fn copyFile(allocator: *Allocator, source_path: []const u8, dest_path: []const u8) !void {
807807 var in_file = try os.File.openRead(allocator, source_path);
808808 defer in_file.close();
809809
......@@ -825,7 +825,7 @@ pub fn copyFile(allocator: &Allocator, source_path: []const u8, dest_path: []con
825825/// Guaranteed to be atomic. However until https://patchwork.kernel.org/patch/9636735/ is
826826/// merged and readily available,
827827/// there is a possibility of power loss or application termination leaving temporary files present
828pub fn copyFileMode(allocator: &Allocator, source_path: []const u8, dest_path: []const u8, mode: FileMode) !void {
828pub fn copyFileMode(allocator: *Allocator, source_path: []const u8, dest_path: []const u8, mode: FileMode) !void {
829829 var in_file = try os.File.openRead(allocator, source_path);
830830 defer in_file.close();
831831
......@@ -843,7 +843,7 @@ pub fn copyFileMode(allocator: &Allocator, source_path: []const u8, dest_path: [
843843}
844844
845845pub const AtomicFile = struct {
846 allocator: &Allocator,
846 allocator: *Allocator,
847847 file: os.File,
848848 tmp_path: []u8,
849849 dest_path: []const u8,
......@@ -851,7 +851,7 @@ pub const AtomicFile = struct {
851851
852852 /// dest_path must remain valid for the lifetime of AtomicFile
853853 /// call finish to atomically replace dest_path with contents
854 pub fn init(allocator: &Allocator, dest_path: []const u8, mode: FileMode) !AtomicFile {
854 pub fn init(allocator: *Allocator, dest_path: []const u8, mode: FileMode) !AtomicFile {
855855 const dirname = os.path.dirname(dest_path);
856856
857857 var rand_buf: [12]u8 = undefined;
......@@ -888,7 +888,7 @@ pub const AtomicFile = struct {
888888 }
889889
890890 /// always call deinit, even after successful finish()
891 pub fn deinit(self: &AtomicFile) void {
891 pub fn deinit(self: *AtomicFile) void {
892892 if (!self.finished) {
893893 self.file.close();
894894 deleteFile(self.allocator, self.tmp_path) catch {};
......@@ -897,7 +897,7 @@ pub const AtomicFile = struct {
897897 }
898898 }
899899
900 pub fn finish(self: &AtomicFile) !void {
900 pub fn finish(self: *AtomicFile) !void {
901901 assert(!self.finished);
902902 self.file.close();
903903 try rename(self.allocator, self.tmp_path, self.dest_path);
......@@ -906,7 +906,7 @@ pub const AtomicFile = struct {
906906 }
907907};
908908
909pub fn rename(allocator: &Allocator, old_path: []const u8, new_path: []const u8) !void {
909pub fn rename(allocator: *Allocator, old_path: []const u8, new_path: []const u8) !void {
910910 const full_buf = try allocator.alloc(u8, old_path.len + new_path.len + 2);
911911 defer allocator.free(full_buf);
912912
......@@ -951,7 +951,7 @@ pub fn rename(allocator: &Allocator, old_path: []const u8, new_path: []const u8)
951951 }
952952}
953953
954pub fn makeDir(allocator: &Allocator, dir_path: []const u8) !void {
954pub fn makeDir(allocator: *Allocator, dir_path: []const u8) !void {
955955 if (is_windows) {
956956 return makeDirWindows(allocator, dir_path);
957957 } else {
......@@ -959,7 +959,7 @@ pub fn makeDir(allocator: &Allocator, dir_path: []const u8) !void {
959959 }
960960}
961961
962pub fn makeDirWindows(allocator: &Allocator, dir_path: []const u8) !void {
962pub fn makeDirWindows(allocator: *Allocator, dir_path: []const u8) !void {
963963 const path_buf = try cstr.addNullByte(allocator, dir_path);
964964 defer allocator.free(path_buf);
965965
......@@ -973,7 +973,7 @@ pub fn makeDirWindows(allocator: &Allocator, dir_path: []const u8) !void {
973973 }
974974}
975975
976pub fn makeDirPosix(allocator: &Allocator, dir_path: []const u8) !void {
976pub fn makeDirPosix(allocator: *Allocator, dir_path: []const u8) !void {
977977 const path_buf = try cstr.addNullByte(allocator, dir_path);
978978 defer allocator.free(path_buf);
979979
......@@ -999,7 +999,7 @@ pub fn makeDirPosix(allocator: &Allocator, dir_path: []const u8) !void {
999999
10001000/// Calls makeDir recursively to make an entire path. Returns success if the path
10011001/// already exists and is a directory.
1002pub fn makePath(allocator: &Allocator, full_path: []const u8) !void {
1002pub fn makePath(allocator: *Allocator, full_path: []const u8) !void {
10031003 const resolved_path = try path.resolve(allocator, full_path);
10041004 defer allocator.free(resolved_path);
10051005
......@@ -1033,7 +1033,7 @@ pub fn makePath(allocator: &Allocator, full_path: []const u8) !void {
10331033
10341034/// Returns ::error.DirNotEmpty if the directory is not empty.
10351035/// To delete a directory recursively, see ::deleteTree
1036pub fn deleteDir(allocator: &Allocator, dir_path: []const u8) !void {
1036pub fn deleteDir(allocator: *Allocator, dir_path: []const u8) !void {
10371037 const path_buf = try allocator.alloc(u8, dir_path.len + 1);
10381038 defer allocator.free(path_buf);
10391039
......@@ -1084,7 +1084,7 @@ const DeleteTreeError = error{
10841084 DirNotEmpty,
10851085 Unexpected,
10861086};
1087pub fn deleteTree(allocator: &Allocator, full_path: []const u8) DeleteTreeError!void {
1087pub fn deleteTree(allocator: *Allocator, full_path: []const u8) DeleteTreeError!void {
10881088 start_over: while (true) {
10891089 var got_access_denied = false;
10901090 // First, try deleting the item as a file. This way we don't follow sym links.
......@@ -1153,7 +1153,7 @@ pub fn deleteTree(allocator: &Allocator, full_path: []const u8) DeleteTreeError!
11531153pub const Dir = struct {
11541154 fd: i32,
11551155 darwin_seek: darwin_seek_t,
1156 allocator: &Allocator,
1156 allocator: *Allocator,
11571157 buf: []u8,
11581158 index: usize,
11591159 end_index: usize,
......@@ -1180,7 +1180,7 @@ pub const Dir = struct {
11801180 };
11811181 };
11821182
1183 pub fn open(allocator: &Allocator, dir_path: []const u8) !Dir {
1183 pub fn open(allocator: *Allocator, dir_path: []const u8) !Dir {
11841184 const fd = switch (builtin.os) {
11851185 Os.windows => @compileError("TODO support Dir.open for windows"),
11861186 Os.linux => try posixOpen(allocator, dir_path, posix.O_RDONLY | posix.O_DIRECTORY | posix.O_CLOEXEC, 0),
......@@ -1206,14 +1206,14 @@ pub const Dir = struct {
12061206 };
12071207 }
12081208
1209 pub fn close(self: &Dir) void {
1209 pub fn close(self: *Dir) void {
12101210 self.allocator.free(self.buf);
12111211 os.close(self.fd);
12121212 }
12131213
12141214 /// Memory such as file names referenced in this returned entry becomes invalid
12151215 /// with subsequent calls to next, as well as when this ::Dir is deinitialized.
1216 pub fn next(self: &Dir) !?Entry {
1216 pub fn next(self: *Dir) !?Entry {
12171217 switch (builtin.os) {
12181218 Os.linux => return self.nextLinux(),
12191219 Os.macosx, Os.ios => return self.nextDarwin(),
......@@ -1222,7 +1222,7 @@ pub const Dir = struct {
12221222 }
12231223 }
12241224
1225 fn nextDarwin(self: &Dir) !?Entry {
1225 fn nextDarwin(self: *Dir) !?Entry {
12261226 start_over: while (true) {
12271227 if (self.index >= self.end_index) {
12281228 if (self.buf.len == 0) {
......@@ -1248,7 +1248,7 @@ pub const Dir = struct {
12481248 break;
12491249 }
12501250 }
1251 const darwin_entry = @ptrCast(&align(1) posix.dirent, &self.buf[self.index]);
1251 const darwin_entry = @ptrCast(*align(1) posix.dirent, &self.buf[self.index]);
12521252 const next_index = self.index + darwin_entry.d_reclen;
12531253 self.index = next_index;
12541254
......@@ -1277,11 +1277,11 @@ pub const Dir = struct {
12771277 }
12781278 }
12791279
1280 fn nextWindows(self: &Dir) !?Entry {
1280 fn nextWindows(self: *Dir) !?Entry {
12811281 @compileError("TODO support Dir.next for windows");
12821282 }
12831283
1284 fn nextLinux(self: &Dir) !?Entry {
1284 fn nextLinux(self: *Dir) !?Entry {
12851285 start_over: while (true) {
12861286 if (self.index >= self.end_index) {
12871287 if (self.buf.len == 0) {
......@@ -1307,7 +1307,7 @@ pub const Dir = struct {
13071307 break;
13081308 }
13091309 }
1310 const linux_entry = @ptrCast(&align(1) posix.dirent, &self.buf[self.index]);
1310 const linux_entry = @ptrCast(*align(1) posix.dirent, &self.buf[self.index]);
13111311 const next_index = self.index + linux_entry.d_reclen;
13121312 self.index = next_index;
13131313
......@@ -1337,7 +1337,7 @@ pub const Dir = struct {
13371337 }
13381338};
13391339
1340pub fn changeCurDir(allocator: &Allocator, dir_path: []const u8) !void {
1340pub fn changeCurDir(allocator: *Allocator, dir_path: []const u8) !void {
13411341 const path_buf = try allocator.alloc(u8, dir_path.len + 1);
13421342 defer allocator.free(path_buf);
13431343
......@@ -1361,7 +1361,7 @@ pub fn changeCurDir(allocator: &Allocator, dir_path: []const u8) !void {
13611361}
13621362
13631363/// Read value of a symbolic link.
1364pub fn readLink(allocator: &Allocator, pathname: []const u8) ![]u8 {
1364pub fn readLink(allocator: *Allocator, pathname: []const u8) ![]u8 {
13651365 const path_buf = try allocator.alloc(u8, pathname.len + 1);
13661366 defer allocator.free(path_buf);
13671367
......@@ -1468,7 +1468,7 @@ pub const ArgIteratorPosix = struct {
14681468 };
14691469 }
14701470
1471 pub fn next(self: &ArgIteratorPosix) ?[]const u8 {
1471 pub fn next(self: *ArgIteratorPosix) ?[]const u8 {
14721472 if (self.index == self.count) return null;
14731473
14741474 const s = raw[self.index];
......@@ -1476,7 +1476,7 @@ pub const ArgIteratorPosix = struct {
14761476 return cstr.toSlice(s);
14771477 }
14781478
1479 pub fn skip(self: &ArgIteratorPosix) bool {
1479 pub fn skip(self: *ArgIteratorPosix) bool {
14801480 if (self.index == self.count) return false;
14811481
14821482 self.index += 1;
......@@ -1485,12 +1485,12 @@ pub const ArgIteratorPosix = struct {
14851485
14861486 /// This is marked as public but actually it's only meant to be used
14871487 /// internally by zig's startup code.
1488 pub var raw: []&u8 = undefined;
1488 pub var raw: []*u8 = undefined;
14891489};
14901490
14911491pub const ArgIteratorWindows = struct {
14921492 index: usize,
1493 cmd_line: &const u8,
1493 cmd_line: *const u8,
14941494 in_quote: bool,
14951495 quote_count: usize,
14961496 seen_quote_count: usize,
......@@ -1501,7 +1501,7 @@ pub const ArgIteratorWindows = struct {
15011501 return initWithCmdLine(windows.GetCommandLineA());
15021502 }
15031503
1504 pub fn initWithCmdLine(cmd_line: &const u8) ArgIteratorWindows {
1504 pub fn initWithCmdLine(cmd_line: *const u8) ArgIteratorWindows {
15051505 return ArgIteratorWindows{
15061506 .index = 0,
15071507 .cmd_line = cmd_line,
......@@ -1512,7 +1512,7 @@ pub const ArgIteratorWindows = struct {
15121512 }
15131513
15141514 /// You must free the returned memory when done.
1515 pub fn next(self: &ArgIteratorWindows, allocator: &Allocator) ?(NextError![]u8) {
1515 pub fn next(self: *ArgIteratorWindows, allocator: *Allocator) ?(NextError![]u8) {
15161516 // march forward over whitespace
15171517 while (true) : (self.index += 1) {
15181518 const byte = self.cmd_line[self.index];
......@@ -1526,7 +1526,7 @@ pub const ArgIteratorWindows = struct {
15261526 return self.internalNext(allocator);
15271527 }
15281528
1529 pub fn skip(self: &ArgIteratorWindows) bool {
1529 pub fn skip(self: *ArgIteratorWindows) bool {
15301530 // march forward over whitespace
15311531 while (true) : (self.index += 1) {
15321532 const byte = self.cmd_line[self.index];
......@@ -1565,7 +1565,7 @@ pub const ArgIteratorWindows = struct {
15651565 }
15661566 }
15671567
1568 fn internalNext(self: &ArgIteratorWindows, allocator: &Allocator) NextError![]u8 {
1568 fn internalNext(self: *ArgIteratorWindows, allocator: *Allocator) NextError![]u8 {
15691569 var buf = try Buffer.initSize(allocator, 0);
15701570 defer buf.deinit();
15711571
......@@ -1609,14 +1609,14 @@ pub const ArgIteratorWindows = struct {
16091609 }
16101610 }
16111611
1612 fn emitBackslashes(self: &ArgIteratorWindows, buf: &Buffer, emit_count: usize) !void {
1612 fn emitBackslashes(self: *ArgIteratorWindows, buf: *Buffer, emit_count: usize) !void {
16131613 var i: usize = 0;
16141614 while (i < emit_count) : (i += 1) {
16151615 try buf.appendByte('\\');
16161616 }
16171617 }
16181618
1619 fn countQuotes(cmd_line: &const u8) usize {
1619 fn countQuotes(cmd_line: *const u8) usize {
16201620 var result: usize = 0;
16211621 var backslash_count: usize = 0;
16221622 var index: usize = 0;
......@@ -1649,7 +1649,7 @@ pub const ArgIterator = struct {
16491649 pub const NextError = ArgIteratorWindows.NextError;
16501650
16511651 /// You must free the returned memory when done.
1652 pub fn next(self: &ArgIterator, allocator: &Allocator) ?(NextError![]u8) {
1652 pub fn next(self: *ArgIterator, allocator: *Allocator) ?(NextError![]u8) {
16531653 if (builtin.os == Os.windows) {
16541654 return self.inner.next(allocator);
16551655 } else {
......@@ -1658,13 +1658,13 @@ pub const ArgIterator = struct {
16581658 }
16591659
16601660 /// If you only are targeting posix you can call this and not need an allocator.
1661 pub fn nextPosix(self: &ArgIterator) ?[]const u8 {
1661 pub fn nextPosix(self: *ArgIterator) ?[]const u8 {
16621662 return self.inner.next();
16631663 }
16641664
16651665 /// Parse past 1 argument without capturing it.
16661666 /// Returns `true` if skipped an arg, `false` if we are at the end.
1667 pub fn skip(self: &ArgIterator) bool {
1667 pub fn skip(self: *ArgIterator) bool {
16681668 return self.inner.skip();
16691669 }
16701670};
......@@ -1674,7 +1674,7 @@ pub fn args() ArgIterator {
16741674}
16751675
16761676/// Caller must call freeArgs on result.
1677pub fn argsAlloc(allocator: &mem.Allocator) ![]const []u8 {
1677pub fn argsAlloc(allocator: *mem.Allocator) ![]const []u8 {
16781678 // TODO refactor to only make 1 allocation.
16791679 var it = args();
16801680 var contents = try Buffer.initSize(allocator, 0);
......@@ -1711,12 +1711,12 @@ pub fn argsAlloc(allocator: &mem.Allocator) ![]const []u8 {
17111711 return result_slice_list;
17121712}
17131713
1714pub fn argsFree(allocator: &mem.Allocator, args_alloc: []const []u8) void {
1714pub fn argsFree(allocator: *mem.Allocator, args_alloc: []const []u8) void {
17151715 var total_bytes: usize = 0;
17161716 for (args_alloc) |arg| {
17171717 total_bytes += @sizeOf([]u8) + arg.len;
17181718 }
1719 const unaligned_allocated_buf = @ptrCast(&const u8, args_alloc.ptr)[0..total_bytes];
1719 const unaligned_allocated_buf = @ptrCast(*const u8, args_alloc.ptr)[0..total_bytes];
17201720 const aligned_allocated_buf = @alignCast(@alignOf([]u8), unaligned_allocated_buf);
17211721 return allocator.free(aligned_allocated_buf);
17221722}
......@@ -1765,7 +1765,7 @@ test "windows arg parsing" {
17651765 });
17661766}
17671767
1768fn testWindowsCmdLine(input_cmd_line: &const u8, expected_args: []const []const u8) void {
1768fn testWindowsCmdLine(input_cmd_line: *const u8, expected_args: []const []const u8) void {
17691769 var it = ArgIteratorWindows.initWithCmdLine(input_cmd_line);
17701770 for (expected_args) |expected_arg| {
17711771 const arg = ??it.next(debug.global_allocator) catch unreachable;
......@@ -1832,7 +1832,7 @@ test "openSelfExe" {
18321832/// This function may return an error if the current executable
18331833/// was deleted after spawning.
18341834/// Caller owns returned memory.
1835pub fn selfExePath(allocator: &mem.Allocator) ![]u8 {
1835pub fn selfExePath(allocator: *mem.Allocator) ![]u8 {
18361836 switch (builtin.os) {
18371837 Os.linux => {
18381838 // If the currently executing binary has been deleted,
......@@ -1875,7 +1875,7 @@ pub fn selfExePath(allocator: &mem.Allocator) ![]u8 {
18751875
18761876/// Get the directory path that contains the current executable.
18771877/// Caller owns returned memory.
1878pub fn selfExeDirPath(allocator: &mem.Allocator) ![]u8 {
1878pub fn selfExeDirPath(allocator: *mem.Allocator) ![]u8 {
18791879 switch (builtin.os) {
18801880 Os.linux => {
18811881 // If the currently executing binary has been deleted,
......@@ -2001,7 +2001,7 @@ pub const PosixBindError = error{
20012001};
20022002
20032003/// addr is `&const T` where T is one of the sockaddr
2004pub fn posixBind(fd: i32, addr: &const posix.sockaddr) PosixBindError!void {
2004pub fn posixBind(fd: i32, addr: *const posix.sockaddr) PosixBindError!void {
20052005 const rc = posix.bind(fd, addr, @sizeOf(posix.sockaddr));
20062006 const err = posix.getErrno(rc);
20072007 switch (err) {
......@@ -2096,7 +2096,7 @@ pub const PosixAcceptError = error{
20962096 Unexpected,
20972097};
20982098
2099pub fn posixAccept(fd: i32, addr: &posix.sockaddr, flags: u32) PosixAcceptError!i32 {
2099pub fn posixAccept(fd: i32, addr: *posix.sockaddr, flags: u32) PosixAcceptError!i32 {
21002100 while (true) {
21012101 var sockaddr_size = u32(@sizeOf(posix.sockaddr));
21022102 const rc = posix.accept4(fd, addr, &sockaddr_size, flags);
......@@ -2195,7 +2195,7 @@ pub const LinuxEpollCtlError = error{
21952195 Unexpected,
21962196};
21972197
2198pub fn linuxEpollCtl(epfd: i32, op: u32, fd: i32, event: &linux.epoll_event) LinuxEpollCtlError!void {
2198pub fn linuxEpollCtl(epfd: i32, op: u32, fd: i32, event: *linux.epoll_event) LinuxEpollCtlError!void {
21992199 const rc = posix.epoll_ctl(epfd, op, fd, event);
22002200 const err = posix.getErrno(rc);
22012201 switch (err) {
......@@ -2288,7 +2288,7 @@ pub const PosixConnectError = error{
22882288 Unexpected,
22892289};
22902290
2291pub fn posixConnect(sockfd: i32, sockaddr: &const posix.sockaddr) PosixConnectError!void {
2291pub fn posixConnect(sockfd: i32, sockaddr: *const posix.sockaddr) PosixConnectError!void {
22922292 while (true) {
22932293 const rc = posix.connect(sockfd, sockaddr, @sizeOf(posix.sockaddr));
22942294 const err = posix.getErrno(rc);
......@@ -2319,7 +2319,7 @@ pub fn posixConnect(sockfd: i32, sockaddr: &const posix.sockaddr) PosixConnectEr
23192319
23202320/// Same as posixConnect except it is for blocking socket file descriptors.
23212321/// It expects to receive EINPROGRESS.
2322pub fn posixConnectAsync(sockfd: i32, sockaddr: &const posix.sockaddr) PosixConnectError!void {
2322pub fn posixConnectAsync(sockfd: i32, sockaddr: *const posix.sockaddr) PosixConnectError!void {
23232323 while (true) {
23242324 const rc = posix.connect(sockfd, sockaddr, @sizeOf(posix.sockaddr));
23252325 const err = posix.getErrno(rc);
......@@ -2350,7 +2350,7 @@ pub fn posixConnectAsync(sockfd: i32, sockaddr: &const posix.sockaddr) PosixConn
23502350pub fn posixGetSockOptConnectError(sockfd: i32) PosixConnectError!void {
23512351 var err_code: i32 = undefined;
23522352 var size: u32 = @sizeOf(i32);
2353 const rc = posix.getsockopt(sockfd, posix.SOL_SOCKET, posix.SO_ERROR, @ptrCast(&u8, &err_code), &size);
2353 const rc = posix.getsockopt(sockfd, posix.SOL_SOCKET, posix.SO_ERROR, @ptrCast(*u8, &err_code), &size);
23542354 assert(size == 4);
23552355 const err = posix.getErrno(rc);
23562356 switch (err) {
......@@ -2401,13 +2401,13 @@ pub const Thread = struct {
24012401 },
24022402 builtin.Os.windows => struct {
24032403 handle: windows.HANDLE,
2404 alloc_start: &c_void,
2404 alloc_start: *c_void,
24052405 heap_handle: windows.HANDLE,
24062406 },
24072407 else => @compileError("Unsupported OS"),
24082408 };
24092409
2410 pub fn wait(self: &const Thread) void {
2410 pub fn wait(self: *const Thread) void {
24112411 if (use_pthreads) {
24122412 const err = c.pthread_join(self.data.handle, null);
24132413 switch (err) {
......@@ -2473,7 +2473,7 @@ pub const SpawnThreadError = error{
24732473/// fn startFn(@typeOf(context)) T
24742474/// where T is u8, noreturn, void, or !void
24752475/// caller must call wait on the returned thread
2476pub fn spawnThread(context: var, comptime startFn: var) SpawnThreadError!&Thread {
2476pub fn spawnThread(context: var, comptime startFn: var) SpawnThreadError!*Thread {
24772477 // TODO compile-time call graph analysis to determine stack upper bound
24782478 // https://github.com/ziglang/zig/issues/157
24792479 const default_stack_size = 8 * 1024 * 1024;
......@@ -2491,7 +2491,7 @@ pub fn spawnThread(context: var, comptime startFn: var) SpawnThreadError!&Thread
24912491 if (@sizeOf(Context) == 0) {
24922492 return startFn({});
24932493 } else {
2494 return startFn(@ptrCast(&Context, @alignCast(@alignOf(Context), arg)).*);
2494 return startFn(@ptrCast(*Context, @alignCast(@alignOf(Context), arg)).*);
24952495 }
24962496 }
24972497 };
......@@ -2500,13 +2500,13 @@ pub fn spawnThread(context: var, comptime startFn: var) SpawnThreadError!&Thread
25002500 const byte_count = @alignOf(WinThread.OuterContext) + @sizeOf(WinThread.OuterContext);
25012501 const bytes_ptr = windows.HeapAlloc(heap_handle, 0, byte_count) ?? return SpawnThreadError.OutOfMemory;
25022502 errdefer assert(windows.HeapFree(heap_handle, 0, bytes_ptr) != 0);
2503 const bytes = @ptrCast(&u8, bytes_ptr)[0..byte_count];
2503 const bytes = @ptrCast(*u8, bytes_ptr)[0..byte_count];
25042504 const outer_context = std.heap.FixedBufferAllocator.init(bytes).allocator.create(WinThread.OuterContext) catch unreachable;
25052505 outer_context.inner = context;
25062506 outer_context.thread.data.heap_handle = heap_handle;
25072507 outer_context.thread.data.alloc_start = bytes_ptr;
25082508
2509 const parameter = if (@sizeOf(Context) == 0) null else @ptrCast(&c_void, &outer_context.inner);
2509 const parameter = if (@sizeOf(Context) == 0) null else @ptrCast(*c_void, &outer_context.inner);
25102510 outer_context.thread.data.handle = windows.CreateThread(null, default_stack_size, WinThread.threadMain, parameter, 0, null) ?? {
25112511 const err = windows.GetLastError();
25122512 return switch (err) {
......@@ -2521,15 +2521,15 @@ pub fn spawnThread(context: var, comptime startFn: var) SpawnThreadError!&Thread
25212521 if (@sizeOf(Context) == 0) {
25222522 return startFn({});
25232523 } else {
2524 return startFn(@intToPtr(&const Context, ctx_addr).*);
2524 return startFn(@intToPtr(*const Context, ctx_addr).*);
25252525 }
25262526 }
2527 extern fn posixThreadMain(ctx: ?&c_void) ?&c_void {
2527 extern fn posixThreadMain(ctx: ?*c_void) ?*c_void {
25282528 if (@sizeOf(Context) == 0) {
25292529 _ = startFn({});
25302530 return null;
25312531 } else {
2532 _ = startFn(@ptrCast(&const Context, @alignCast(@alignOf(Context), ctx)).*);
2532 _ = startFn(@ptrCast(*const Context, @alignCast(@alignOf(Context), ctx)).*);
25332533 return null;
25342534 }
25352535 }
......@@ -2548,7 +2548,7 @@ pub fn spawnThread(context: var, comptime startFn: var) SpawnThreadError!&Thread
25482548 stack_end -= @sizeOf(Context);
25492549 stack_end -= stack_end % @alignOf(Context);
25502550 assert(stack_end >= stack_addr);
2551 const context_ptr = @alignCast(@alignOf(Context), @intToPtr(&Context, stack_end));
2551 const context_ptr = @alignCast(@alignOf(Context), @intToPtr(*Context, stack_end));
25522552 context_ptr.* = context;
25532553 arg = stack_end;
25542554 }
......@@ -2556,7 +2556,7 @@ pub fn spawnThread(context: var, comptime startFn: var) SpawnThreadError!&Thread
25562556 stack_end -= @sizeOf(Thread);
25572557 stack_end -= stack_end % @alignOf(Thread);
25582558 assert(stack_end >= stack_addr);
2559 const thread_ptr = @alignCast(@alignOf(Thread), @intToPtr(&Thread, stack_end));
2559 const thread_ptr = @alignCast(@alignOf(Thread), @intToPtr(*Thread, stack_end));
25602560
25612561 thread_ptr.data.stack_addr = stack_addr;
25622562 thread_ptr.data.stack_len = mmap_len;
......@@ -2572,9 +2572,9 @@ pub fn spawnThread(context: var, comptime startFn: var) SpawnThreadError!&Thread
25722572
25732573 // align to page
25742574 stack_end -= stack_end % os.page_size;
2575 assert(c.pthread_attr_setstack(&attr, @intToPtr(&c_void, stack_addr), stack_end - stack_addr) == 0);
2575 assert(c.pthread_attr_setstack(&attr, @intToPtr(*c_void, stack_addr), stack_end - stack_addr) == 0);
25762576
2577 const err = c.pthread_create(&thread_ptr.data.handle, &attr, MainFuncs.posixThreadMain, @intToPtr(&c_void, arg));
2577 const err = c.pthread_create(&thread_ptr.data.handle, &attr, MainFuncs.posixThreadMain, @intToPtr(*c_void, arg));
25782578 switch (err) {
25792579 0 => return thread_ptr,
25802580 posix.EAGAIN => return SpawnThreadError.SystemResources,
std/os/linux/index.zig+87-87
......@@ -665,15 +665,15 @@ pub fn dup2(old: i32, new: i32) usize {
665665 return syscall2(SYS_dup2, usize(old), usize(new));
666666}
667667
668pub fn chdir(path: &const u8) usize {
668pub fn chdir(path: *const u8) usize {
669669 return syscall1(SYS_chdir, @ptrToInt(path));
670670}
671671
672pub fn chroot(path: &const u8) usize {
672pub fn chroot(path: *const u8) usize {
673673 return syscall1(SYS_chroot, @ptrToInt(path));
674674}
675675
676pub fn execve(path: &const u8, argv: &const ?&const u8, envp: &const ?&const u8) usize {
676pub fn execve(path: *const u8, argv: *const ?*const u8, envp: *const ?*const u8) usize {
677677 return syscall3(SYS_execve, @ptrToInt(path), @ptrToInt(argv), @ptrToInt(envp));
678678}
679679
......@@ -681,15 +681,15 @@ pub fn fork() usize {
681681 return syscall0(SYS_fork);
682682}
683683
684pub fn futex_wait(uaddr: usize, futex_op: u32, val: i32, timeout: ?&timespec) usize {
684pub fn futex_wait(uaddr: usize, futex_op: u32, val: i32, timeout: ?*timespec) usize {
685685 return syscall4(SYS_futex, uaddr, futex_op, @bitCast(u32, val), @ptrToInt(timeout));
686686}
687687
688pub fn getcwd(buf: &u8, size: usize) usize {
688pub fn getcwd(buf: *u8, size: usize) usize {
689689 return syscall2(SYS_getcwd, @ptrToInt(buf), size);
690690}
691691
692pub fn getdents(fd: i32, dirp: &u8, count: usize) usize {
692pub fn getdents(fd: i32, dirp: *u8, count: usize) usize {
693693 return syscall3(SYS_getdents, usize(fd), @ptrToInt(dirp), count);
694694}
695695
......@@ -698,27 +698,27 @@ pub fn isatty(fd: i32) bool {
698698 return syscall3(SYS_ioctl, usize(fd), TIOCGWINSZ, @ptrToInt(&wsz)) == 0;
699699}
700700
701pub fn readlink(noalias path: &const u8, noalias buf_ptr: &u8, buf_len: usize) usize {
701pub fn readlink(noalias path: *const u8, noalias buf_ptr: *u8, buf_len: usize) usize {
702702 return syscall3(SYS_readlink, @ptrToInt(path), @ptrToInt(buf_ptr), buf_len);
703703}
704704
705pub fn mkdir(path: &const u8, mode: u32) usize {
705pub fn mkdir(path: *const u8, mode: u32) usize {
706706 return syscall2(SYS_mkdir, @ptrToInt(path), mode);
707707}
708708
709pub fn mount(special: &const u8, dir: &const u8, fstype: &const u8, flags: usize, data: usize) usize {
709pub fn mount(special: *const u8, dir: *const u8, fstype: *const u8, flags: usize, data: usize) usize {
710710 return syscall5(SYS_mount, @ptrToInt(special), @ptrToInt(dir), @ptrToInt(fstype), flags, data);
711711}
712712
713pub fn umount(special: &const u8) usize {
713pub fn umount(special: *const u8) usize {
714714 return syscall2(SYS_umount2, @ptrToInt(special), 0);
715715}
716716
717pub fn umount2(special: &const u8, flags: u32) usize {
717pub fn umount2(special: *const u8, flags: u32) usize {
718718 return syscall2(SYS_umount2, @ptrToInt(special), flags);
719719}
720720
721pub fn mmap(address: ?&u8, length: usize, prot: usize, flags: u32, fd: i32, offset: isize) usize {
721pub fn mmap(address: ?*u8, length: usize, prot: usize, flags: u32, fd: i32, offset: isize) usize {
722722 return syscall6(SYS_mmap, @ptrToInt(address), length, prot, flags, usize(fd), @bitCast(usize, offset));
723723}
724724
......@@ -726,60 +726,60 @@ pub fn munmap(address: usize, length: usize) usize {
726726 return syscall2(SYS_munmap, address, length);
727727}
728728
729pub fn read(fd: i32, buf: &u8, count: usize) usize {
729pub fn read(fd: i32, buf: *u8, count: usize) usize {
730730 return syscall3(SYS_read, usize(fd), @ptrToInt(buf), count);
731731}
732732
733pub fn rmdir(path: &const u8) usize {
733pub fn rmdir(path: *const u8) usize {
734734 return syscall1(SYS_rmdir, @ptrToInt(path));
735735}
736736
737pub fn symlink(existing: &const u8, new: &const u8) usize {
737pub fn symlink(existing: *const u8, new: *const u8) usize {
738738 return syscall2(SYS_symlink, @ptrToInt(existing), @ptrToInt(new));
739739}
740740
741pub fn pread(fd: i32, buf: &u8, count: usize, offset: usize) usize {
741pub fn pread(fd: i32, buf: *u8, count: usize, offset: usize) usize {
742742 return syscall4(SYS_pread, usize(fd), @ptrToInt(buf), count, offset);
743743}
744744
745pub fn access(path: &const u8, mode: u32) usize {
745pub fn access(path: *const u8, mode: u32) usize {
746746 return syscall2(SYS_access, @ptrToInt(path), mode);
747747}
748748
749pub fn pipe(fd: &[2]i32) usize {
749pub fn pipe(fd: *[2]i32) usize {
750750 return pipe2(fd, 0);
751751}
752752
753pub fn pipe2(fd: &[2]i32, flags: usize) usize {
753pub fn pipe2(fd: *[2]i32, flags: usize) usize {
754754 return syscall2(SYS_pipe2, @ptrToInt(fd), flags);
755755}
756756
757pub fn write(fd: i32, buf: &const u8, count: usize) usize {
757pub fn write(fd: i32, buf: *const u8, count: usize) usize {
758758 return syscall3(SYS_write, usize(fd), @ptrToInt(buf), count);
759759}
760760
761pub fn pwrite(fd: i32, buf: &const u8, count: usize, offset: usize) usize {
761pub fn pwrite(fd: i32, buf: *const u8, count: usize, offset: usize) usize {
762762 return syscall4(SYS_pwrite, usize(fd), @ptrToInt(buf), count, offset);
763763}
764764
765pub fn rename(old: &const u8, new: &const u8) usize {
765pub fn rename(old: *const u8, new: *const u8) usize {
766766 return syscall2(SYS_rename, @ptrToInt(old), @ptrToInt(new));
767767}
768768
769pub fn open(path: &const u8, flags: u32, perm: usize) usize {
769pub fn open(path: *const u8, flags: u32, perm: usize) usize {
770770 return syscall3(SYS_open, @ptrToInt(path), flags, perm);
771771}
772772
773pub fn create(path: &const u8, perm: usize) usize {
773pub fn create(path: *const u8, perm: usize) usize {
774774 return syscall2(SYS_creat, @ptrToInt(path), perm);
775775}
776776
777pub fn openat(dirfd: i32, path: &const u8, flags: usize, mode: usize) usize {
777pub fn openat(dirfd: i32, path: *const u8, flags: usize, mode: usize) usize {
778778 return syscall4(SYS_openat, usize(dirfd), @ptrToInt(path), flags, mode);
779779}
780780
781781/// See also `clone` (from the arch-specific include)
782pub fn clone5(flags: usize, child_stack_ptr: usize, parent_tid: &i32, child_tid: &i32, newtls: usize) usize {
782pub fn clone5(flags: usize, child_stack_ptr: usize, parent_tid: *i32, child_tid: *i32, newtls: usize) usize {
783783 return syscall5(SYS_clone, flags, child_stack_ptr, @ptrToInt(parent_tid), @ptrToInt(child_tid), newtls);
784784}
785785
......@@ -801,7 +801,7 @@ pub fn exit(status: i32) noreturn {
801801 unreachable;
802802}
803803
804pub fn getrandom(buf: &u8, count: usize, flags: u32) usize {
804pub fn getrandom(buf: *u8, count: usize, flags: u32) usize {
805805 return syscall3(SYS_getrandom, @ptrToInt(buf), count, usize(flags));
806806}
807807
......@@ -809,15 +809,15 @@ pub fn kill(pid: i32, sig: i32) usize {
809809 return syscall2(SYS_kill, @bitCast(usize, isize(pid)), usize(sig));
810810}
811811
812pub fn unlink(path: &const u8) usize {
812pub fn unlink(path: *const u8) usize {
813813 return syscall1(SYS_unlink, @ptrToInt(path));
814814}
815815
816pub fn waitpid(pid: i32, status: &i32, options: i32) usize {
816pub fn waitpid(pid: i32, status: *i32, options: i32) usize {
817817 return syscall4(SYS_wait4, @bitCast(usize, isize(pid)), @ptrToInt(status), @bitCast(usize, isize(options)), 0);
818818}
819819
820pub fn clock_gettime(clk_id: i32, tp: &timespec) usize {
820pub fn clock_gettime(clk_id: i32, tp: *timespec) usize {
821821 if (VDSO_CGT_SYM.len != 0) {
822822 const f = @atomicLoad(@typeOf(init_vdso_clock_gettime), &vdso_clock_gettime, builtin.AtomicOrder.Unordered);
823823 if (@ptrToInt(f) != 0) {
......@@ -831,7 +831,7 @@ pub fn clock_gettime(clk_id: i32, tp: &timespec) usize {
831831 return syscall2(SYS_clock_gettime, @bitCast(usize, isize(clk_id)), @ptrToInt(tp));
832832}
833833var vdso_clock_gettime = init_vdso_clock_gettime;
834extern fn init_vdso_clock_gettime(clk: i32, ts: &timespec) usize {
834extern fn init_vdso_clock_gettime(clk: i32, ts: *timespec) usize {
835835 const addr = vdso.lookup(VDSO_CGT_VER, VDSO_CGT_SYM);
836836 var f = @intToPtr(@typeOf(init_vdso_clock_gettime), addr);
837837 _ = @cmpxchgStrong(@typeOf(init_vdso_clock_gettime), &vdso_clock_gettime, init_vdso_clock_gettime, f, builtin.AtomicOrder.Monotonic, builtin.AtomicOrder.Monotonic);
......@@ -839,23 +839,23 @@ extern fn init_vdso_clock_gettime(clk: i32, ts: &timespec) usize {
839839 return f(clk, ts);
840840}
841841
842pub fn clock_getres(clk_id: i32, tp: &timespec) usize {
842pub fn clock_getres(clk_id: i32, tp: *timespec) usize {
843843 return syscall2(SYS_clock_getres, @bitCast(usize, isize(clk_id)), @ptrToInt(tp));
844844}
845845
846pub fn clock_settime(clk_id: i32, tp: &const timespec) usize {
846pub fn clock_settime(clk_id: i32, tp: *const timespec) usize {
847847 return syscall2(SYS_clock_settime, @bitCast(usize, isize(clk_id)), @ptrToInt(tp));
848848}
849849
850pub fn gettimeofday(tv: &timeval, tz: &timezone) usize {
850pub fn gettimeofday(tv: *timeval, tz: *timezone) usize {
851851 return syscall2(SYS_gettimeofday, @ptrToInt(tv), @ptrToInt(tz));
852852}
853853
854pub fn settimeofday(tv: &const timeval, tz: &const timezone) usize {
854pub fn settimeofday(tv: *const timeval, tz: *const timezone) usize {
855855 return syscall2(SYS_settimeofday, @ptrToInt(tv), @ptrToInt(tz));
856856}
857857
858pub fn nanosleep(req: &const timespec, rem: ?&timespec) usize {
858pub fn nanosleep(req: *const timespec, rem: ?*timespec) usize {
859859 return syscall2(SYS_nanosleep, @ptrToInt(req), @ptrToInt(rem));
860860}
861861
......@@ -899,11 +899,11 @@ pub fn setegid(egid: u32) usize {
899899 return syscall1(SYS_setegid, egid);
900900}
901901
902pub fn getresuid(ruid: &u32, euid: &u32, suid: &u32) usize {
902pub fn getresuid(ruid: *u32, euid: *u32, suid: *u32) usize {
903903 return syscall3(SYS_getresuid, @ptrToInt(ruid), @ptrToInt(euid), @ptrToInt(suid));
904904}
905905
906pub fn getresgid(rgid: &u32, egid: &u32, sgid: &u32) usize {
906pub fn getresgid(rgid: *u32, egid: *u32, sgid: *u32) usize {
907907 return syscall3(SYS_getresgid, @ptrToInt(rgid), @ptrToInt(egid), @ptrToInt(sgid));
908908}
909909
......@@ -915,11 +915,11 @@ pub fn setresgid(rgid: u32, egid: u32, sgid: u32) usize {
915915 return syscall3(SYS_setresgid, rgid, egid, sgid);
916916}
917917
918pub fn getgroups(size: usize, list: &u32) usize {
918pub fn getgroups(size: usize, list: *u32) usize {
919919 return syscall2(SYS_getgroups, size, @ptrToInt(list));
920920}
921921
922pub fn setgroups(size: usize, list: &const u32) usize {
922pub fn setgroups(size: usize, list: *const u32) usize {
923923 return syscall2(SYS_setgroups, size, @ptrToInt(list));
924924}
925925
......@@ -927,11 +927,11 @@ pub fn getpid() i32 {
927927 return @bitCast(i32, u32(syscall0(SYS_getpid)));
928928}
929929
930pub fn sigprocmask(flags: u32, noalias set: &const sigset_t, noalias oldset: ?&sigset_t) usize {
930pub fn sigprocmask(flags: u32, noalias set: *const sigset_t, noalias oldset: ?*sigset_t) usize {
931931 return syscall4(SYS_rt_sigprocmask, flags, @ptrToInt(set), @ptrToInt(oldset), NSIG / 8);
932932}
933933
934pub fn sigaction(sig: u6, noalias act: &const Sigaction, noalias oact: ?&Sigaction) usize {
934pub fn sigaction(sig: u6, noalias act: *const Sigaction, noalias oact: ?*Sigaction) usize {
935935 assert(sig >= 1);
936936 assert(sig != SIGKILL);
937937 assert(sig != SIGSTOP);
......@@ -942,8 +942,8 @@ pub fn sigaction(sig: u6, noalias act: &const Sigaction, noalias oact: ?&Sigacti
942942 .restorer = @ptrCast(extern fn () void, restore_rt),
943943 };
944944 var ksa_old: k_sigaction = undefined;
945 @memcpy(@ptrCast(&u8, &ksa.mask), @ptrCast(&const u8, &act.mask), 8);
946 const result = syscall4(SYS_rt_sigaction, sig, @ptrToInt(&ksa), @ptrToInt(&ksa_old), @sizeOf(@typeOf(ksa.mask)));
945 @memcpy(@ptrCast(*u8, *ksa.mask), @ptrCast(*const u8, *act.mask), 8);
946 const result = syscall4(SYS_rt_sigaction, sig, @ptrToInt(*ksa), @ptrToInt(*ksa_old), @sizeOf(@typeOf(ksa.mask)));
947947 const err = getErrno(result);
948948 if (err != 0) {
949949 return result;
......@@ -951,7 +951,7 @@ pub fn sigaction(sig: u6, noalias act: &const Sigaction, noalias oact: ?&Sigacti
951951 if (oact) |old| {
952952 old.handler = ksa_old.handler;
953953 old.flags = @truncate(u32, ksa_old.flags);
954 @memcpy(@ptrCast(&u8, &old.mask), @ptrCast(&const u8, &ksa_old.mask), @sizeOf(@typeOf(ksa_old.mask)));
954 @memcpy(@ptrCast(*u8, *old.mask), @ptrCast(*const u8, *ksa_old.mask), @sizeOf(@typeOf(ksa_old.mask)));
955955 }
956956 return 0;
957957}
......@@ -989,24 +989,24 @@ pub fn raise(sig: i32) usize {
989989 return ret;
990990}
991991
992fn blockAllSignals(set: &sigset_t) void {
992fn blockAllSignals(set: *sigset_t) void {
993993 _ = syscall4(SYS_rt_sigprocmask, SIG_BLOCK, @ptrToInt(&all_mask), @ptrToInt(set), NSIG / 8);
994994}
995995
996fn blockAppSignals(set: &sigset_t) void {
996fn blockAppSignals(set: *sigset_t) void {
997997 _ = syscall4(SYS_rt_sigprocmask, SIG_BLOCK, @ptrToInt(&app_mask), @ptrToInt(set), NSIG / 8);
998998}
999999
1000fn restoreSignals(set: &sigset_t) void {
1000fn restoreSignals(set: *sigset_t) void {
10011001 _ = syscall4(SYS_rt_sigprocmask, SIG_SETMASK, @ptrToInt(set), 0, NSIG / 8);
10021002}
10031003
1004pub fn sigaddset(set: &sigset_t, sig: u6) void {
1004pub fn sigaddset(set: *sigset_t, sig: u6) void {
10051005 const s = sig - 1;
10061006 (set.*)[usize(s) / usize.bit_count] |= usize(1) << (s & (usize.bit_count - 1));
10071007}
10081008
1009pub fn sigismember(set: &const sigset_t, sig: u6) bool {
1009pub fn sigismember(set: *const sigset_t, sig: u6) bool {
10101010 const s = sig - 1;
10111011 return ((set.*)[usize(s) / usize.bit_count] & (usize(1) << (s & (usize.bit_count - 1)))) != 0;
10121012}
......@@ -1036,15 +1036,15 @@ pub const sockaddr_in6 = extern struct {
10361036};
10371037
10381038pub const iovec = extern struct {
1039 iov_base: &u8,
1039 iov_base: *u8,
10401040 iov_len: usize,
10411041};
10421042
1043pub fn getsockname(fd: i32, noalias addr: &sockaddr, noalias len: &socklen_t) usize {
1043pub fn getsockname(fd: i32, noalias addr: *sockaddr, noalias len: *socklen_t) usize {
10441044 return syscall3(SYS_getsockname, usize(fd), @ptrToInt(addr), @ptrToInt(len));
10451045}
10461046
1047pub fn getpeername(fd: i32, noalias addr: &sockaddr, noalias len: &socklen_t) usize {
1047pub fn getpeername(fd: i32, noalias addr: *sockaddr, noalias len: *socklen_t) usize {
10481048 return syscall3(SYS_getpeername, usize(fd), @ptrToInt(addr), @ptrToInt(len));
10491049}
10501050
......@@ -1052,27 +1052,27 @@ pub fn socket(domain: u32, socket_type: u32, protocol: u32) usize {
10521052 return syscall3(SYS_socket, domain, socket_type, protocol);
10531053}
10541054
1055pub fn setsockopt(fd: i32, level: u32, optname: u32, optval: &const u8, optlen: socklen_t) usize {
1055pub fn setsockopt(fd: i32, level: u32, optname: u32, optval: *const u8, optlen: socklen_t) usize {
10561056 return syscall5(SYS_setsockopt, usize(fd), level, optname, usize(optval), @ptrToInt(optlen));
10571057}
10581058
1059pub fn getsockopt(fd: i32, level: u32, optname: u32, noalias optval: &u8, noalias optlen: &socklen_t) usize {
1059pub fn getsockopt(fd: i32, level: u32, optname: u32, noalias optval: *u8, noalias optlen: *socklen_t) usize {
10601060 return syscall5(SYS_getsockopt, usize(fd), level, optname, @ptrToInt(optval), @ptrToInt(optlen));
10611061}
10621062
1063pub fn sendmsg(fd: i32, msg: &const msghdr, flags: u32) usize {
1063pub fn sendmsg(fd: i32, msg: *const msghdr, flags: u32) usize {
10641064 return syscall3(SYS_sendmsg, usize(fd), @ptrToInt(msg), flags);
10651065}
10661066
1067pub fn connect(fd: i32, addr: &const sockaddr, len: socklen_t) usize {
1067pub fn connect(fd: i32, addr: *const sockaddr, len: socklen_t) usize {
10681068 return syscall3(SYS_connect, usize(fd), @ptrToInt(addr), usize(len));
10691069}
10701070
1071pub fn recvmsg(fd: i32, msg: &msghdr, flags: u32) usize {
1071pub fn recvmsg(fd: i32, msg: *msghdr, flags: u32) usize {
10721072 return syscall3(SYS_recvmsg, usize(fd), @ptrToInt(msg), flags);
10731073}
10741074
1075pub fn recvfrom(fd: i32, noalias buf: &u8, len: usize, flags: u32, noalias addr: ?&sockaddr, noalias alen: ?&socklen_t) usize {
1075pub fn recvfrom(fd: i32, noalias buf: *u8, len: usize, flags: u32, noalias addr: ?*sockaddr, noalias alen: ?*socklen_t) usize {
10761076 return syscall6(SYS_recvfrom, usize(fd), @ptrToInt(buf), len, flags, @ptrToInt(addr), @ptrToInt(alen));
10771077}
10781078
......@@ -1080,7 +1080,7 @@ pub fn shutdown(fd: i32, how: i32) usize {
10801080 return syscall2(SYS_shutdown, usize(fd), usize(how));
10811081}
10821082
1083pub fn bind(fd: i32, addr: &const sockaddr, len: socklen_t) usize {
1083pub fn bind(fd: i32, addr: *const sockaddr, len: socklen_t) usize {
10841084 return syscall3(SYS_bind, usize(fd), @ptrToInt(addr), usize(len));
10851085}
10861086
......@@ -1088,79 +1088,79 @@ pub fn listen(fd: i32, backlog: u32) usize {
10881088 return syscall2(SYS_listen, usize(fd), backlog);
10891089}
10901090
1091pub fn sendto(fd: i32, buf: &const u8, len: usize, flags: u32, addr: ?&const sockaddr, alen: socklen_t) usize {
1091pub fn sendto(fd: i32, buf: *const u8, len: usize, flags: u32, addr: ?*const sockaddr, alen: socklen_t) usize {
10921092 return syscall6(SYS_sendto, usize(fd), @ptrToInt(buf), len, flags, @ptrToInt(addr), usize(alen));
10931093}
10941094
10951095pub fn socketpair(domain: i32, socket_type: i32, protocol: i32, fd: [2]i32) usize {
1096 return syscall4(SYS_socketpair, usize(domain), usize(socket_type), usize(protocol), @ptrToInt(&fd[0]));
1096 return syscall4(SYS_socketpair, usize(domain), usize(socket_type), usize(protocol), @ptrToInt(*fd[0]));
10971097}
10981098
1099pub fn accept(fd: i32, noalias addr: &sockaddr, noalias len: &socklen_t) usize {
1099pub fn accept(fd: i32, noalias addr: *sockaddr, noalias len: *socklen_t) usize {
11001100 return accept4(fd, addr, len, 0);
11011101}
11021102
1103pub fn accept4(fd: i32, noalias addr: &sockaddr, noalias len: &socklen_t, flags: u32) usize {
1103pub fn accept4(fd: i32, noalias addr: *sockaddr, noalias len: *socklen_t, flags: u32) usize {
11041104 return syscall4(SYS_accept4, usize(fd), @ptrToInt(addr), @ptrToInt(len), flags);
11051105}
11061106
1107pub fn fstat(fd: i32, stat_buf: &Stat) usize {
1107pub fn fstat(fd: i32, stat_buf: *Stat) usize {
11081108 return syscall2(SYS_fstat, usize(fd), @ptrToInt(stat_buf));
11091109}
11101110
1111pub fn stat(pathname: &const u8, statbuf: &Stat) usize {
1111pub fn stat(pathname: *const u8, statbuf: *Stat) usize {
11121112 return syscall2(SYS_stat, @ptrToInt(pathname), @ptrToInt(statbuf));
11131113}
11141114
1115pub fn lstat(pathname: &const u8, statbuf: &Stat) usize {
1115pub fn lstat(pathname: *const u8, statbuf: *Stat) usize {
11161116 return syscall2(SYS_lstat, @ptrToInt(pathname), @ptrToInt(statbuf));
11171117}
11181118
1119pub fn listxattr(path: &const u8, list: &u8, size: usize) usize {
1119pub fn listxattr(path: *const u8, list: *u8, size: usize) usize {
11201120 return syscall3(SYS_listxattr, @ptrToInt(path), @ptrToInt(list), size);
11211121}
11221122
1123pub fn llistxattr(path: &const u8, list: &u8, size: usize) usize {
1123pub fn llistxattr(path: *const u8, list: *u8, size: usize) usize {
11241124 return syscall3(SYS_llistxattr, @ptrToInt(path), @ptrToInt(list), size);
11251125}
11261126
1127pub fn flistxattr(fd: usize, list: &u8, size: usize) usize {
1127pub fn flistxattr(fd: usize, list: *u8, size: usize) usize {
11281128 return syscall3(SYS_flistxattr, fd, @ptrToInt(list), size);
11291129}
11301130
1131pub fn getxattr(path: &const u8, name: &const u8, value: &void, size: usize) usize {
1131pub fn getxattr(path: *const u8, name: *const u8, value: *void, size: usize) usize {
11321132 return syscall4(SYS_getxattr, @ptrToInt(path), @ptrToInt(name), @ptrToInt(value), size);
11331133}
11341134
1135pub fn lgetxattr(path: &const u8, name: &const u8, value: &void, size: usize) usize {
1135pub fn lgetxattr(path: *const u8, name: *const u8, value: *void, size: usize) usize {
11361136 return syscall4(SYS_lgetxattr, @ptrToInt(path), @ptrToInt(name), @ptrToInt(value), size);
11371137}
11381138
1139pub fn fgetxattr(fd: usize, name: &const u8, value: &void, size: usize) usize {
1139pub fn fgetxattr(fd: usize, name: *const u8, value: *void, size: usize) usize {
11401140 return syscall4(SYS_lgetxattr, fd, @ptrToInt(name), @ptrToInt(value), size);
11411141}
11421142
1143pub fn setxattr(path: &const u8, name: &const u8, value: &const void, size: usize, flags: usize) usize {
1143pub fn setxattr(path: *const u8, name: *const u8, value: *const void, size: usize, flags: usize) usize {
11441144 return syscall5(SYS_setxattr, @ptrToInt(path), @ptrToInt(name), @ptrToInt(value), size, flags);
11451145}
11461146
1147pub fn lsetxattr(path: &const u8, name: &const u8, value: &const void, size: usize, flags: usize) usize {
1147pub fn lsetxattr(path: *const u8, name: *const u8, value: *const void, size: usize, flags: usize) usize {
11481148 return syscall5(SYS_lsetxattr, @ptrToInt(path), @ptrToInt(name), @ptrToInt(value), size, flags);
11491149}
11501150
1151pub fn fsetxattr(fd: usize, name: &const u8, value: &const void, size: usize, flags: usize) usize {
1151pub fn fsetxattr(fd: usize, name: *const u8, value: *const void, size: usize, flags: usize) usize {
11521152 return syscall5(SYS_fsetxattr, fd, @ptrToInt(name), @ptrToInt(value), size, flags);
11531153}
11541154
1155pub fn removexattr(path: &const u8, name: &const u8) usize {
1155pub fn removexattr(path: *const u8, name: *const u8) usize {
11561156 return syscall2(SYS_removexattr, @ptrToInt(path), @ptrToInt(name));
11571157}
11581158
1159pub fn lremovexattr(path: &const u8, name: &const u8) usize {
1159pub fn lremovexattr(path: *const u8, name: *const u8) usize {
11601160 return syscall2(SYS_lremovexattr, @ptrToInt(path), @ptrToInt(name));
11611161}
11621162
1163pub fn fremovexattr(fd: usize, name: &const u8) usize {
1163pub fn fremovexattr(fd: usize, name: *const u8) usize {
11641164 return syscall2(SYS_fremovexattr, fd, @ptrToInt(name));
11651165}
11661166
......@@ -1184,11 +1184,11 @@ pub fn epoll_create1(flags: usize) usize {
11841184 return syscall1(SYS_epoll_create1, flags);
11851185}
11861186
1187pub fn epoll_ctl(epoll_fd: i32, op: u32, fd: i32, ev: &epoll_event) usize {
1187pub fn epoll_ctl(epoll_fd: i32, op: u32, fd: i32, ev: *epoll_event) usize {
11881188 return syscall4(SYS_epoll_ctl, usize(epoll_fd), usize(op), usize(fd), @ptrToInt(ev));
11891189}
11901190
1191pub fn epoll_wait(epoll_fd: i32, events: &epoll_event, maxevents: u32, timeout: i32) usize {
1191pub fn epoll_wait(epoll_fd: i32, events: *epoll_event, maxevents: u32, timeout: i32) usize {
11921192 return syscall4(SYS_epoll_wait, usize(epoll_fd), @ptrToInt(events), usize(maxevents), usize(timeout));
11931193}
11941194
......@@ -1201,11 +1201,11 @@ pub const itimerspec = extern struct {
12011201 it_value: timespec,
12021202};
12031203
1204pub fn timerfd_gettime(fd: i32, curr_value: &itimerspec) usize {
1204pub fn timerfd_gettime(fd: i32, curr_value: *itimerspec) usize {
12051205 return syscall2(SYS_timerfd_gettime, usize(fd), @ptrToInt(curr_value));
12061206}
12071207
1208pub fn timerfd_settime(fd: i32, flags: u32, new_value: &const itimerspec, old_value: ?&itimerspec) usize {
1208pub fn timerfd_settime(fd: i32, flags: u32, new_value: *const itimerspec, old_value: ?*itimerspec) usize {
12091209 return syscall4(SYS_timerfd_settime, usize(fd), usize(flags), @ptrToInt(new_value), @ptrToInt(old_value));
12101210}
12111211
......@@ -1300,8 +1300,8 @@ pub fn CAP_TO_INDEX(cap: u8) u8 {
13001300}
13011301
13021302pub const cap_t = extern struct {
1303 hdrp: &cap_user_header_t,
1304 datap: &cap_user_data_t,
1303 hdrp: *cap_user_header_t,
1304 datap: *cap_user_data_t,
13051305};
13061306
13071307pub const cap_user_header_t = extern struct {
......@@ -1319,11 +1319,11 @@ pub fn unshare(flags: usize) usize {
13191319 return syscall1(SYS_unshare, usize(flags));
13201320}
13211321
1322pub fn capget(hdrp: &cap_user_header_t, datap: &cap_user_data_t) usize {
1322pub fn capget(hdrp: *cap_user_header_t, datap: *cap_user_data_t) usize {
13231323 return syscall2(SYS_capget, @ptrToInt(hdrp), @ptrToInt(datap));
13241324}
13251325
1326pub fn capset(hdrp: &cap_user_header_t, datap: &const cap_user_data_t) usize {
1326pub fn capset(hdrp: *cap_user_header_t, datap: *const cap_user_data_t) usize {
13271327 return syscall2(SYS_capset, @ptrToInt(hdrp), @ptrToInt(datap));
13281328}
13291329
std/os/linux/vdso.zig+18-18
......@@ -8,11 +8,11 @@ pub fn lookup(vername: []const u8, name: []const u8) usize {
88 const vdso_addr = std.os.linux_aux_raw[std.elf.AT_SYSINFO_EHDR];
99 if (vdso_addr == 0) return 0;
1010
11 const eh = @intToPtr(&elf.Ehdr, vdso_addr);
11 const eh = @intToPtr(*elf.Ehdr, vdso_addr);
1212 var ph_addr: usize = vdso_addr + eh.e_phoff;
13 const ph = @intToPtr(&elf.Phdr, ph_addr);
13 const ph = @intToPtr(*elf.Phdr, ph_addr);
1414
15 var maybe_dynv: ?&usize = null;
15 var maybe_dynv: ?*usize = null;
1616 var base: usize = @maxValue(usize);
1717 {
1818 var i: usize = 0;
......@@ -20,10 +20,10 @@ pub fn lookup(vername: []const u8, name: []const u8) usize {
2020 i += 1;
2121 ph_addr += eh.e_phentsize;
2222 }) {
23 const this_ph = @intToPtr(&elf.Phdr, ph_addr);
23 const this_ph = @intToPtr(*elf.Phdr, ph_addr);
2424 switch (this_ph.p_type) {
2525 elf.PT_LOAD => base = vdso_addr + this_ph.p_offset - this_ph.p_vaddr,
26 elf.PT_DYNAMIC => maybe_dynv = @intToPtr(&usize, vdso_addr + this_ph.p_offset),
26 elf.PT_DYNAMIC => maybe_dynv = @intToPtr(*usize, vdso_addr + this_ph.p_offset),
2727 else => {},
2828 }
2929 }
......@@ -31,22 +31,22 @@ pub fn lookup(vername: []const u8, name: []const u8) usize {
3131 const dynv = maybe_dynv ?? return 0;
3232 if (base == @maxValue(usize)) return 0;
3333
34 var maybe_strings: ?&u8 = null;
35 var maybe_syms: ?&elf.Sym = null;
36 var maybe_hashtab: ?&linux.Elf_Symndx = null;
37 var maybe_versym: ?&u16 = null;
38 var maybe_verdef: ?&elf.Verdef = null;
34 var maybe_strings: ?*u8 = null;
35 var maybe_syms: ?*elf.Sym = null;
36 var maybe_hashtab: ?*linux.Elf_Symndx = null;
37 var maybe_versym: ?*u16 = null;
38 var maybe_verdef: ?*elf.Verdef = null;
3939
4040 {
4141 var i: usize = 0;
4242 while (dynv[i] != 0) : (i += 2) {
4343 const p = base + dynv[i + 1];
4444 switch (dynv[i]) {
45 elf.DT_STRTAB => maybe_strings = @intToPtr(&u8, p),
46 elf.DT_SYMTAB => maybe_syms = @intToPtr(&elf.Sym, p),
47 elf.DT_HASH => maybe_hashtab = @intToPtr(&linux.Elf_Symndx, p),
48 elf.DT_VERSYM => maybe_versym = @intToPtr(&u16, p),
49 elf.DT_VERDEF => maybe_verdef = @intToPtr(&elf.Verdef, p),
45 elf.DT_STRTAB => maybe_strings = @intToPtr(*u8, p),
46 elf.DT_SYMTAB => maybe_syms = @intToPtr(*elf.Sym, p),
47 elf.DT_HASH => maybe_hashtab = @intToPtr(*linux.Elf_Symndx, p),
48 elf.DT_VERSYM => maybe_versym = @intToPtr(*u16, p),
49 elf.DT_VERDEF => maybe_verdef = @intToPtr(*elf.Verdef, p),
5050 else => {},
5151 }
5252 }
......@@ -76,7 +76,7 @@ pub fn lookup(vername: []const u8, name: []const u8) usize {
7676 return 0;
7777}
7878
79fn checkver(def_arg: &elf.Verdef, vsym_arg: i32, vername: []const u8, strings: &u8) bool {
79fn checkver(def_arg: *elf.Verdef, vsym_arg: i32, vername: []const u8, strings: *u8) bool {
8080 var def = def_arg;
8181 const vsym = @bitCast(u32, vsym_arg) & 0x7fff;
8282 while (true) {
......@@ -84,8 +84,8 @@ fn checkver(def_arg: &elf.Verdef, vsym_arg: i32, vername: []const u8, strings: &
8484 break;
8585 if (def.vd_next == 0)
8686 return false;
87 def = @intToPtr(&elf.Verdef, @ptrToInt(def) + def.vd_next);
87 def = @intToPtr(*elf.Verdef, @ptrToInt(def) + def.vd_next);
8888 }
89 const aux = @intToPtr(&elf.Verdaux, @ptrToInt(def) + def.vd_aux);
89 const aux = @intToPtr(*elf.Verdaux, @ptrToInt(def) + def.vd_aux);
9090 return mem.eql(u8, vername, cstr.toSliceConst(&strings[aux.vda_name]));
9191}
std/os/linux/x86_64.zig+4-4
......@@ -463,7 +463,7 @@ pub fn syscall6(
463463}
464464
465465/// This matches the libc clone function.
466pub extern fn clone(func: extern fn (arg: usize) u8, stack: usize, flags: usize, arg: usize, ptid: &i32, tls: usize, ctid: &i32) usize;
466pub extern fn clone(func: extern fn (arg: usize) u8, stack: usize, flags: usize, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize;
467467
468468pub nakedcc fn restore_rt() void {
469469 return asm volatile ("syscall"
......@@ -474,12 +474,12 @@ pub nakedcc fn restore_rt() void {
474474}
475475
476476pub const msghdr = extern struct {
477 msg_name: &u8,
477 msg_name: *u8,
478478 msg_namelen: socklen_t,
479 msg_iov: &iovec,
479 msg_iov: *iovec,
480480 msg_iovlen: i32,
481481 __pad1: i32,
482 msg_control: &u8,
482 msg_control: *u8,
483483 msg_controllen: socklen_t,
484484 __pad2: socklen_t,
485485 msg_flags: i32,
std/os/path.zig+11-11
......@@ -32,7 +32,7 @@ pub fn isSep(byte: u8) bool {
3232
3333/// Naively combines a series of paths with the native path seperator.
3434/// Allocates memory for the result, which must be freed by the caller.
35pub fn join(allocator: &Allocator, paths: ...) ![]u8 {
35pub fn join(allocator: *Allocator, paths: ...) ![]u8 {
3636 if (is_windows) {
3737 return joinWindows(allocator, paths);
3838 } else {
......@@ -40,11 +40,11 @@ pub fn join(allocator: &Allocator, paths: ...) ![]u8 {
4040 }
4141}
4242
43pub fn joinWindows(allocator: &Allocator, paths: ...) ![]u8 {
43pub fn joinWindows(allocator: *Allocator, paths: ...) ![]u8 {
4444 return mem.join(allocator, sep_windows, paths);
4545}
4646
47pub fn joinPosix(allocator: &Allocator, paths: ...) ![]u8 {
47pub fn joinPosix(allocator: *Allocator, paths: ...) ![]u8 {
4848 return mem.join(allocator, sep_posix, paths);
4949}
5050
......@@ -310,7 +310,7 @@ fn asciiEqlIgnoreCase(s1: []const u8, s2: []const u8) bool {
310310}
311311
312312/// Converts the command line arguments into a slice and calls `resolveSlice`.
313pub fn resolve(allocator: &Allocator, args: ...) ![]u8 {
313pub fn resolve(allocator: *Allocator, args: ...) ![]u8 {
314314 var paths: [args.len][]const u8 = undefined;
315315 comptime var arg_i = 0;
316316 inline while (arg_i < args.len) : (arg_i += 1) {
......@@ -320,7 +320,7 @@ pub fn resolve(allocator: &Allocator, args: ...) ![]u8 {
320320}
321321
322322/// On Windows, this calls `resolveWindows` and on POSIX it calls `resolvePosix`.
323pub fn resolveSlice(allocator: &Allocator, paths: []const []const u8) ![]u8 {
323pub fn resolveSlice(allocator: *Allocator, paths: []const []const u8) ![]u8 {
324324 if (is_windows) {
325325 return resolveWindows(allocator, paths);
326326 } else {
......@@ -334,7 +334,7 @@ pub fn resolveSlice(allocator: &Allocator, paths: []const []const u8) ![]u8 {
334334/// If all paths are relative it uses the current working directory as a starting point.
335335/// Each drive has its own current working directory.
336336/// Path separators are canonicalized to '\\' and drives are canonicalized to capital letters.
337pub fn resolveWindows(allocator: &Allocator, paths: []const []const u8) ![]u8 {
337pub fn resolveWindows(allocator: *Allocator, paths: []const []const u8) ![]u8 {
338338 if (paths.len == 0) {
339339 assert(is_windows); // resolveWindows called on non windows can't use getCwd
340340 return os.getCwd(allocator);
......@@ -513,7 +513,7 @@ pub fn resolveWindows(allocator: &Allocator, paths: []const []const u8) ![]u8 {
513513/// It resolves "." and "..".
514514/// The result does not have a trailing path separator.
515515/// If all paths are relative it uses the current working directory as a starting point.
516pub fn resolvePosix(allocator: &Allocator, paths: []const []const u8) ![]u8 {
516pub fn resolvePosix(allocator: *Allocator, paths: []const []const u8) ![]u8 {
517517 if (paths.len == 0) {
518518 assert(!is_windows); // resolvePosix called on windows can't use getCwd
519519 return os.getCwd(allocator);
......@@ -883,7 +883,7 @@ fn testBasenameWindows(input: []const u8, expected_output: []const u8) void {
883883/// resolve to the same path (after calling `resolve` on each), a zero-length
884884/// string is returned.
885885/// On Windows this canonicalizes the drive to a capital letter and paths to `\\`.
886pub fn relative(allocator: &Allocator, from: []const u8, to: []const u8) ![]u8 {
886pub fn relative(allocator: *Allocator, from: []const u8, to: []const u8) ![]u8 {
887887 if (is_windows) {
888888 return relativeWindows(allocator, from, to);
889889 } else {
......@@ -891,7 +891,7 @@ pub fn relative(allocator: &Allocator, from: []const u8, to: []const u8) ![]u8 {
891891 }
892892}
893893
894pub fn relativeWindows(allocator: &Allocator, from: []const u8, to: []const u8) ![]u8 {
894pub fn relativeWindows(allocator: *Allocator, from: []const u8, to: []const u8) ![]u8 {
895895 const resolved_from = try resolveWindows(allocator, [][]const u8{from});
896896 defer allocator.free(resolved_from);
897897
......@@ -964,7 +964,7 @@ pub fn relativeWindows(allocator: &Allocator, from: []const u8, to: []const u8)
964964 return []u8{};
965965}
966966
967pub fn relativePosix(allocator: &Allocator, from: []const u8, to: []const u8) ![]u8 {
967pub fn relativePosix(allocator: *Allocator, from: []const u8, to: []const u8) ![]u8 {
968968 const resolved_from = try resolvePosix(allocator, [][]const u8{from});
969969 defer allocator.free(resolved_from);
970970
......@@ -1063,7 +1063,7 @@ fn testRelativeWindows(from: []const u8, to: []const u8, expected_output: []cons
10631063/// Expands all symbolic links and resolves references to `.`, `..`, and
10641064/// extra `/` characters in ::pathname.
10651065/// Caller must deallocate result.
1066pub fn real(allocator: &Allocator, pathname: []const u8) ![]u8 {
1066pub fn real(allocator: *Allocator, pathname: []const u8) ![]u8 {
10671067 switch (builtin.os) {
10681068 Os.windows => {
10691069 const pathname_buf = try allocator.alloc(u8, pathname.len + 1);
std/os/test.zig+1-1
......@@ -63,7 +63,7 @@ fn start1(ctx: void) u8 {
6363 return 0;
6464}
6565
66fn start2(ctx: &i32) u8 {
66fn start2(ctx: *i32) u8 {
6767 _ = @atomicRmw(i32, ctx, AtomicRmwOp.Add, 1, AtomicOrder.SeqCst);
6868 return 0;
6969}
std/os/time.zig+3-3
......@@ -200,7 +200,7 @@ pub const Timer = struct {
200200 }
201201
202202 /// Reads the timer value since start or the last reset in nanoseconds
203 pub fn read(self: &Timer) u64 {
203 pub fn read(self: *Timer) u64 {
204204 var clock = clockNative() - self.start_time;
205205 return switch (builtin.os) {
206206 Os.windows => @divFloor(clock * ns_per_s, self.frequency),
......@@ -211,12 +211,12 @@ pub const Timer = struct {
211211 }
212212
213213 /// Resets the timer value to 0/now.
214 pub fn reset(self: &Timer) void {
214 pub fn reset(self: *Timer) void {
215215 self.start_time = clockNative();
216216 }
217217
218218 /// Returns the current value of the timer in nanoseconds, then resets it
219 pub fn lap(self: &Timer) u64 {
219 pub fn lap(self: *Timer) u64 {
220220 var now = clockNative();
221221 var lap_time = self.read();
222222 self.start_time = now;
std/os/windows/index.zig+48-48
......@@ -1,7 +1,7 @@
11pub const ERROR = @import("error.zig");
22
33pub extern "advapi32" stdcallcc fn CryptAcquireContextA(
4 phProv: &HCRYPTPROV,
4 phProv: *HCRYPTPROV,
55 pszContainer: ?LPCSTR,
66 pszProvider: ?LPCSTR,
77 dwProvType: DWORD,
......@@ -10,13 +10,13 @@ pub extern "advapi32" stdcallcc fn CryptAcquireContextA(
1010
1111pub extern "advapi32" stdcallcc fn CryptReleaseContext(hProv: HCRYPTPROV, dwFlags: DWORD) BOOL;
1212
13pub extern "advapi32" stdcallcc fn CryptGenRandom(hProv: HCRYPTPROV, dwLen: DWORD, pbBuffer: &BYTE) BOOL;
13pub extern "advapi32" stdcallcc fn CryptGenRandom(hProv: HCRYPTPROV, dwLen: DWORD, pbBuffer: *BYTE) BOOL;
1414
1515pub extern "kernel32" stdcallcc fn CloseHandle(hObject: HANDLE) BOOL;
1616
1717pub extern "kernel32" stdcallcc fn CreateDirectoryA(
1818 lpPathName: LPCSTR,
19 lpSecurityAttributes: ?&SECURITY_ATTRIBUTES,
19 lpSecurityAttributes: ?*SECURITY_ATTRIBUTES,
2020) BOOL;
2121
2222pub extern "kernel32" stdcallcc fn CreateFileA(
......@@ -30,23 +30,23 @@ pub extern "kernel32" stdcallcc fn CreateFileA(
3030) HANDLE;
3131
3232pub extern "kernel32" stdcallcc fn CreatePipe(
33 hReadPipe: &HANDLE,
34 hWritePipe: &HANDLE,
35 lpPipeAttributes: &const SECURITY_ATTRIBUTES,
33 hReadPipe: *HANDLE,
34 hWritePipe: *HANDLE,
35 lpPipeAttributes: *const SECURITY_ATTRIBUTES,
3636 nSize: DWORD,
3737) BOOL;
3838
3939pub extern "kernel32" stdcallcc fn CreateProcessA(
4040 lpApplicationName: ?LPCSTR,
4141 lpCommandLine: LPSTR,
42 lpProcessAttributes: ?&SECURITY_ATTRIBUTES,
43 lpThreadAttributes: ?&SECURITY_ATTRIBUTES,
42 lpProcessAttributes: ?*SECURITY_ATTRIBUTES,
43 lpThreadAttributes: ?*SECURITY_ATTRIBUTES,
4444 bInheritHandles: BOOL,
4545 dwCreationFlags: DWORD,
46 lpEnvironment: ?&c_void,
46 lpEnvironment: ?*c_void,
4747 lpCurrentDirectory: ?LPCSTR,
48 lpStartupInfo: &STARTUPINFOA,
49 lpProcessInformation: &PROCESS_INFORMATION,
48 lpStartupInfo: *STARTUPINFOA,
49 lpProcessInformation: *PROCESS_INFORMATION,
5050) BOOL;
5151
5252pub extern "kernel32" stdcallcc fn CreateSymbolicLinkA(
......@@ -65,7 +65,7 @@ pub extern "kernel32" stdcallcc fn FreeEnvironmentStringsA(penv: LPCH) BOOL;
6565
6666pub extern "kernel32" stdcallcc fn GetCommandLineA() LPSTR;
6767
68pub extern "kernel32" stdcallcc fn GetConsoleMode(in_hConsoleHandle: HANDLE, out_lpMode: &DWORD) BOOL;
68pub extern "kernel32" stdcallcc fn GetConsoleMode(in_hConsoleHandle: HANDLE, out_lpMode: *DWORD) BOOL;
6969
7070pub extern "kernel32" stdcallcc fn GetCurrentDirectoryA(nBufferLength: WORD, lpBuffer: ?LPSTR) DWORD;
7171
......@@ -73,9 +73,9 @@ pub extern "kernel32" stdcallcc fn GetEnvironmentStringsA() ?LPCH;
7373
7474pub extern "kernel32" stdcallcc fn GetEnvironmentVariableA(lpName: LPCSTR, lpBuffer: LPSTR, nSize: DWORD) DWORD;
7575
76pub extern "kernel32" stdcallcc fn GetExitCodeProcess(hProcess: HANDLE, lpExitCode: &DWORD) BOOL;
76pub extern "kernel32" stdcallcc fn GetExitCodeProcess(hProcess: HANDLE, lpExitCode: *DWORD) BOOL;
7777
78pub extern "kernel32" stdcallcc fn GetFileSizeEx(hFile: HANDLE, lpFileSize: &LARGE_INTEGER) BOOL;
78pub extern "kernel32" stdcallcc fn GetFileSizeEx(hFile: HANDLE, lpFileSize: *LARGE_INTEGER) BOOL;
7979
8080pub extern "kernel32" stdcallcc fn GetModuleFileNameA(hModule: ?HMODULE, lpFilename: LPSTR, nSize: DWORD) DWORD;
8181
......@@ -84,7 +84,7 @@ pub extern "kernel32" stdcallcc fn GetLastError() DWORD;
8484pub extern "kernel32" stdcallcc fn GetFileInformationByHandleEx(
8585 in_hFile: HANDLE,
8686 in_FileInformationClass: FILE_INFO_BY_HANDLE_CLASS,
87 out_lpFileInformation: &c_void,
87 out_lpFileInformation: *c_void,
8888 in_dwBufferSize: DWORD,
8989) BOOL;
9090
......@@ -97,21 +97,21 @@ pub extern "kernel32" stdcallcc fn GetFinalPathNameByHandleA(
9797
9898pub extern "kernel32" stdcallcc fn GetProcessHeap() ?HANDLE;
9999
100pub extern "kernel32" stdcallcc fn GetSystemTimeAsFileTime(?&FILETIME) void;
100pub extern "kernel32" stdcallcc fn GetSystemTimeAsFileTime(?*FILETIME) void;
101101
102102pub extern "kernel32" stdcallcc fn HeapCreate(flOptions: DWORD, dwInitialSize: SIZE_T, dwMaximumSize: SIZE_T) ?HANDLE;
103103pub extern "kernel32" stdcallcc fn HeapDestroy(hHeap: HANDLE) BOOL;
104pub extern "kernel32" stdcallcc fn HeapReAlloc(hHeap: HANDLE, dwFlags: DWORD, lpMem: &c_void, dwBytes: SIZE_T) ?&c_void;
105pub extern "kernel32" stdcallcc fn HeapSize(hHeap: HANDLE, dwFlags: DWORD, lpMem: &const c_void) SIZE_T;
106pub extern "kernel32" stdcallcc fn HeapValidate(hHeap: HANDLE, dwFlags: DWORD, lpMem: &const c_void) BOOL;
104pub extern "kernel32" stdcallcc fn HeapReAlloc(hHeap: HANDLE, dwFlags: DWORD, lpMem: *c_void, dwBytes: SIZE_T) ?*c_void;
105pub extern "kernel32" stdcallcc fn HeapSize(hHeap: HANDLE, dwFlags: DWORD, lpMem: *const c_void) SIZE_T;
106pub extern "kernel32" stdcallcc fn HeapValidate(hHeap: HANDLE, dwFlags: DWORD, lpMem: *const c_void) BOOL;
107107pub extern "kernel32" stdcallcc fn HeapCompact(hHeap: HANDLE, dwFlags: DWORD) SIZE_T;
108108pub extern "kernel32" stdcallcc fn HeapSummary(hHeap: HANDLE, dwFlags: DWORD, lpSummary: LPHEAP_SUMMARY) BOOL;
109109
110110pub extern "kernel32" stdcallcc fn GetStdHandle(in_nStdHandle: DWORD) ?HANDLE;
111111
112pub extern "kernel32" stdcallcc fn HeapAlloc(hHeap: HANDLE, dwFlags: DWORD, dwBytes: SIZE_T) ?&c_void;
112pub extern "kernel32" stdcallcc fn HeapAlloc(hHeap: HANDLE, dwFlags: DWORD, dwBytes: SIZE_T) ?*c_void;
113113
114pub extern "kernel32" stdcallcc fn HeapFree(hHeap: HANDLE, dwFlags: DWORD, lpMem: &c_void) BOOL;
114pub extern "kernel32" stdcallcc fn HeapFree(hHeap: HANDLE, dwFlags: DWORD, lpMem: *c_void) BOOL;
115115
116116pub extern "kernel32" stdcallcc fn MoveFileExA(
117117 lpExistingFileName: LPCSTR,
......@@ -119,24 +119,24 @@ pub extern "kernel32" stdcallcc fn MoveFileExA(
119119 dwFlags: DWORD,
120120) BOOL;
121121
122pub extern "kernel32" stdcallcc fn QueryPerformanceCounter(lpPerformanceCount: &LARGE_INTEGER) BOOL;
122pub extern "kernel32" stdcallcc fn QueryPerformanceCounter(lpPerformanceCount: *LARGE_INTEGER) BOOL;
123123
124pub extern "kernel32" stdcallcc fn QueryPerformanceFrequency(lpFrequency: &LARGE_INTEGER) BOOL;
124pub extern "kernel32" stdcallcc fn QueryPerformanceFrequency(lpFrequency: *LARGE_INTEGER) BOOL;
125125
126126pub extern "kernel32" stdcallcc fn PathFileExists(pszPath: ?LPCTSTR) BOOL;
127127
128128pub extern "kernel32" stdcallcc fn ReadFile(
129129 in_hFile: HANDLE,
130 out_lpBuffer: &c_void,
130 out_lpBuffer: *c_void,
131131 in_nNumberOfBytesToRead: DWORD,
132 out_lpNumberOfBytesRead: &DWORD,
133 in_out_lpOverlapped: ?&OVERLAPPED,
132 out_lpNumberOfBytesRead: *DWORD,
133 in_out_lpOverlapped: ?*OVERLAPPED,
134134) BOOL;
135135
136136pub extern "kernel32" stdcallcc fn SetFilePointerEx(
137137 in_fFile: HANDLE,
138138 in_liDistanceToMove: LARGE_INTEGER,
139 out_opt_ldNewFilePointer: ?&LARGE_INTEGER,
139 out_opt_ldNewFilePointer: ?*LARGE_INTEGER,
140140 in_dwMoveMethod: DWORD,
141141) BOOL;
142142
......@@ -150,10 +150,10 @@ pub extern "kernel32" stdcallcc fn WaitForSingleObject(hHandle: HANDLE, dwMillis
150150
151151pub extern "kernel32" stdcallcc fn WriteFile(
152152 in_hFile: HANDLE,
153 in_lpBuffer: &const c_void,
153 in_lpBuffer: *const c_void,
154154 in_nNumberOfBytesToWrite: DWORD,
155 out_lpNumberOfBytesWritten: ?&DWORD,
156 in_out_lpOverlapped: ?&OVERLAPPED,
155 out_lpNumberOfBytesWritten: ?*DWORD,
156 in_out_lpOverlapped: ?*OVERLAPPED,
157157) BOOL;
158158
159159//TODO: call unicode versions instead of relying on ANSI code page
......@@ -171,23 +171,23 @@ pub const BYTE = u8;
171171pub const CHAR = u8;
172172pub const DWORD = u32;
173173pub const FLOAT = f32;
174pub const HANDLE = &c_void;
174pub const HANDLE = *c_void;
175175pub const HCRYPTPROV = ULONG_PTR;
176pub const HINSTANCE = &@OpaqueType();
177pub const HMODULE = &@OpaqueType();
176pub const HINSTANCE = *@OpaqueType();
177pub const HMODULE = *@OpaqueType();
178178pub const INT = c_int;
179pub const LPBYTE = &BYTE;
180pub const LPCH = &CHAR;
181pub const LPCSTR = &const CHAR;
182pub const LPCTSTR = &const TCHAR;
183pub const LPCVOID = &const c_void;
184pub const LPDWORD = &DWORD;
185pub const LPSTR = &CHAR;
179pub const LPBYTE = *BYTE;
180pub const LPCH = *CHAR;
181pub const LPCSTR = *const CHAR;
182pub const LPCTSTR = *const TCHAR;
183pub const LPCVOID = *const c_void;
184pub const LPDWORD = *DWORD;
185pub const LPSTR = *CHAR;
186186pub const LPTSTR = if (UNICODE) LPWSTR else LPSTR;
187pub const LPVOID = &c_void;
188pub const LPWSTR = &WCHAR;
189pub const PVOID = &c_void;
190pub const PWSTR = &WCHAR;
187pub const LPVOID = *c_void;
188pub const LPWSTR = *WCHAR;
189pub const PVOID = *c_void;
190pub const PWSTR = *WCHAR;
191191pub const SIZE_T = usize;
192192pub const TCHAR = if (UNICODE) WCHAR else u8;
193193pub const UINT = c_uint;
......@@ -218,7 +218,7 @@ pub const OVERLAPPED = extern struct {
218218 Pointer: PVOID,
219219 hEvent: HANDLE,
220220};
221pub const LPOVERLAPPED = &OVERLAPPED;
221pub const LPOVERLAPPED = *OVERLAPPED;
222222
223223pub const MAX_PATH = 260;
224224
......@@ -271,11 +271,11 @@ pub const VOLUME_NAME_NT = 0x2;
271271
272272pub const SECURITY_ATTRIBUTES = extern struct {
273273 nLength: DWORD,
274 lpSecurityDescriptor: ?&c_void,
274 lpSecurityDescriptor: ?*c_void,
275275 bInheritHandle: BOOL,
276276};
277pub const PSECURITY_ATTRIBUTES = &SECURITY_ATTRIBUTES;
278pub const LPSECURITY_ATTRIBUTES = &SECURITY_ATTRIBUTES;
277pub const PSECURITY_ATTRIBUTES = *SECURITY_ATTRIBUTES;
278pub const LPSECURITY_ATTRIBUTES = *SECURITY_ATTRIBUTES;
279279
280280pub const GENERIC_READ = 0x80000000;
281281pub const GENERIC_WRITE = 0x40000000;
std/os/windows/util.zig+6-6
......@@ -42,7 +42,7 @@ pub const WriteError = error{
4242};
4343
4444pub fn windowsWrite(handle: windows.HANDLE, bytes: []const u8) WriteError!void {
45 if (windows.WriteFile(handle, @ptrCast(&const c_void, bytes.ptr), u32(bytes.len), null, null) == 0) {
45 if (windows.WriteFile(handle, @ptrCast(*const c_void, bytes.ptr), u32(bytes.len), null, null) == 0) {
4646 const err = windows.GetLastError();
4747 return switch (err) {
4848 windows.ERROR.INVALID_USER_BUFFER => WriteError.SystemResources,
......@@ -68,11 +68,11 @@ pub fn windowsIsCygwinPty(handle: windows.HANDLE) bool {
6868 const size = @sizeOf(windows.FILE_NAME_INFO);
6969 var name_info_bytes align(@alignOf(windows.FILE_NAME_INFO)) = []u8{0} ** (size + windows.MAX_PATH);
7070
71 if (windows.GetFileInformationByHandleEx(handle, windows.FileNameInfo, @ptrCast(&c_void, &name_info_bytes[0]), u32(name_info_bytes.len)) == 0) {
71 if (windows.GetFileInformationByHandleEx(handle, windows.FileNameInfo, @ptrCast(*c_void, &name_info_bytes[0]), u32(name_info_bytes.len)) == 0) {
7272 return true;
7373 }
7474
75 const name_info = @ptrCast(&const windows.FILE_NAME_INFO, &name_info_bytes[0]);
75 const name_info = @ptrCast(*const windows.FILE_NAME_INFO, &name_info_bytes[0]);
7676 const name_bytes = name_info_bytes[size .. size + usize(name_info.FileNameLength)];
7777 const name_wide = ([]u16)(name_bytes);
7878 return mem.indexOf(u16, name_wide, []u16{ 'm', 's', 'y', 's', '-' }) != null or
......@@ -91,7 +91,7 @@ pub const OpenError = error{
9191
9292/// `file_path` needs to be copied in memory to add a null terminating byte, hence the allocator.
9393pub fn windowsOpen(
94 allocator: &mem.Allocator,
94 allocator: *mem.Allocator,
9595 file_path: []const u8,
9696 desired_access: windows.DWORD,
9797 share_mode: windows.DWORD,
......@@ -119,7 +119,7 @@ pub fn windowsOpen(
119119}
120120
121121/// Caller must free result.
122pub fn createWindowsEnvBlock(allocator: &mem.Allocator, env_map: &const BufMap) ![]u8 {
122pub fn createWindowsEnvBlock(allocator: *mem.Allocator, env_map: *const BufMap) ![]u8 {
123123 // count bytes needed
124124 const bytes_needed = x: {
125125 var bytes_needed: usize = 1; // 1 for the final null byte
......@@ -150,7 +150,7 @@ pub fn createWindowsEnvBlock(allocator: &mem.Allocator, env_map: &const BufMap)
150150 return result;
151151}
152152
153pub fn windowsLoadDll(allocator: &mem.Allocator, dll_path: []const u8) !windows.HMODULE {
153pub fn windowsLoadDll(allocator: *mem.Allocator, dll_path: []const u8) !windows.HMODULE {
154154 const padded_buff = try cstr.addNullByte(allocator, dll_path);
155155 defer allocator.free(padded_buff);
156156 return windows.LoadLibraryA(padded_buff.ptr) ?? error.DllNotFound;
std/os/zen.zig+10-10
......@@ -8,7 +8,7 @@ pub const Message = struct {
88 type: usize,
99 payload: usize,
1010
11 pub fn from(mailbox_id: &const MailboxId) Message {
11 pub fn from(mailbox_id: *const MailboxId) Message {
1212 return Message{
1313 .sender = MailboxId.Undefined,
1414 .receiver = *mailbox_id,
......@@ -17,7 +17,7 @@ pub const Message = struct {
1717 };
1818 }
1919
20 pub fn to(mailbox_id: &const MailboxId, msg_type: usize) Message {
20 pub fn to(mailbox_id: *const MailboxId, msg_type: usize) Message {
2121 return Message{
2222 .sender = MailboxId.This,
2323 .receiver = *mailbox_id,
......@@ -26,7 +26,7 @@ pub const Message = struct {
2626 };
2727 }
2828
29 pub fn withData(mailbox_id: &const MailboxId, msg_type: usize, payload: usize) Message {
29 pub fn withData(mailbox_id: *const MailboxId, msg_type: usize, payload: usize) Message {
3030 return Message{
3131 .sender = MailboxId.This,
3232 .receiver = *mailbox_id,
......@@ -67,7 +67,7 @@ pub const getErrno = @import("linux/index.zig").getErrno;
6767use @import("linux/errno.zig");
6868
6969// TODO: implement this correctly.
70pub fn read(fd: i32, buf: &u8, count: usize) usize {
70pub fn read(fd: i32, buf: *u8, count: usize) usize {
7171 switch (fd) {
7272 STDIN_FILENO => {
7373 var i: usize = 0;
......@@ -75,7 +75,7 @@ pub fn read(fd: i32, buf: &u8, count: usize) usize {
7575 send(Message.to(Server.Keyboard, 0));
7676
7777 var message = Message.from(MailboxId.This);
78 receive(&message);
78 receive(*message);
7979
8080 buf[i] = u8(message.payload);
8181 }
......@@ -86,7 +86,7 @@ pub fn read(fd: i32, buf: &u8, count: usize) usize {
8686}
8787
8888// TODO: implement this correctly.
89pub fn write(fd: i32, buf: &const u8, count: usize) usize {
89pub fn write(fd: i32, buf: *const u8, count: usize) usize {
9090 switch (fd) {
9191 STDOUT_FILENO, STDERR_FILENO => {
9292 var i: usize = 0;
......@@ -126,22 +126,22 @@ pub fn exit(status: i32) noreturn {
126126 unreachable;
127127}
128128
129pub fn createPort(mailbox_id: &const MailboxId) void {
129pub fn createPort(mailbox_id: *const MailboxId) void {
130130 _ = switch (*mailbox_id) {
131131 MailboxId.Port => |id| syscall1(Syscall.createPort, id),
132132 else => unreachable,
133133 };
134134}
135135
136pub fn send(message: &const Message) void {
136pub fn send(message: *const Message) void {
137137 _ = syscall1(Syscall.send, @ptrToInt(message));
138138}
139139
140pub fn receive(destination: &Message) void {
140pub fn receive(destination: *Message) void {
141141 _ = syscall1(Syscall.receive, @ptrToInt(destination));
142142}
143143
144pub fn subscribeIRQ(irq: u8, mailbox_id: &const MailboxId) void {
144pub fn subscribeIRQ(irq: u8, mailbox_id: *const MailboxId) void {
145145 _ = syscall2(Syscall.subscribeIRQ, irq, @ptrToInt(mailbox_id));
146146}
147147
std/rand/index.zig+23-23
......@@ -28,15 +28,15 @@ pub const DefaultPrng = Xoroshiro128;
2828pub const DefaultCsprng = Isaac64;
2929
3030pub const Random = struct {
31 fillFn: fn (r: &Random, buf: []u8) void,
31 fillFn: fn (r: *Random, buf: []u8) void,
3232
3333 /// Read random bytes into the specified buffer until fill.
34 pub fn bytes(r: &Random, buf: []u8) void {
34 pub fn bytes(r: *Random, buf: []u8) void {
3535 r.fillFn(r, buf);
3636 }
3737
3838 /// Return a random integer/boolean type.
39 pub fn scalar(r: &Random, comptime T: type) T {
39 pub fn scalar(r: *Random, comptime T: type) T {
4040 var rand_bytes: [@sizeOf(T)]u8 = undefined;
4141 r.bytes(rand_bytes[0..]);
4242
......@@ -50,7 +50,7 @@ pub const Random = struct {
5050
5151 /// Get a random unsigned integer with even distribution between `start`
5252 /// inclusive and `end` exclusive.
53 pub fn range(r: &Random, comptime T: type, start: T, end: T) T {
53 pub fn range(r: *Random, comptime T: type, start: T, end: T) T {
5454 assert(start <= end);
5555 if (T.is_signed) {
5656 const uint = @IntType(false, T.bit_count);
......@@ -92,7 +92,7 @@ pub const Random = struct {
9292 }
9393
9494 /// Return a floating point value evenly distributed in the range [0, 1).
95 pub fn float(r: &Random, comptime T: type) T {
95 pub fn float(r: *Random, comptime T: type) T {
9696 // Generate a uniform value between [1, 2) and scale down to [0, 1).
9797 // Note: The lowest mantissa bit is always set to 0 so we only use half the available range.
9898 switch (T) {
......@@ -113,7 +113,7 @@ pub const Random = struct {
113113 /// Return a floating point value normally distributed with mean = 0, stddev = 1.
114114 ///
115115 /// To use different parameters, use: floatNorm(...) * desiredStddev + desiredMean.
116 pub fn floatNorm(r: &Random, comptime T: type) T {
116 pub fn floatNorm(r: *Random, comptime T: type) T {
117117 const value = ziggurat.next_f64(r, ziggurat.NormDist);
118118 switch (T) {
119119 f32 => return f32(value),
......@@ -125,7 +125,7 @@ pub const Random = struct {
125125 /// Return an exponentially distributed float with a rate parameter of 1.
126126 ///
127127 /// To use a different rate parameter, use: floatExp(...) / desiredRate.
128 pub fn floatExp(r: &Random, comptime T: type) T {
128 pub fn floatExp(r: *Random, comptime T: type) T {
129129 const value = ziggurat.next_f64(r, ziggurat.ExpDist);
130130 switch (T) {
131131 f32 => return f32(value),
......@@ -135,7 +135,7 @@ pub const Random = struct {
135135 }
136136
137137 /// Shuffle a slice into a random order.
138 pub fn shuffle(r: &Random, comptime T: type, buf: []T) void {
138 pub fn shuffle(r: *Random, comptime T: type, buf: []T) void {
139139 if (buf.len < 2) {
140140 return;
141141 }
......@@ -159,7 +159,7 @@ const SplitMix64 = struct {
159159 return SplitMix64{ .s = seed };
160160 }
161161
162 pub fn next(self: &SplitMix64) u64 {
162 pub fn next(self: *SplitMix64) u64 {
163163 self.s +%= 0x9e3779b97f4a7c15;
164164
165165 var z = self.s;
......@@ -208,7 +208,7 @@ pub const Pcg = struct {
208208 return pcg;
209209 }
210210
211 fn next(self: &Pcg) u32 {
211 fn next(self: *Pcg) u32 {
212212 const l = self.s;
213213 self.s = l *% default_multiplier +% (self.i | 1);
214214
......@@ -218,13 +218,13 @@ pub const Pcg = struct {
218218 return (xor_s >> u5(rot)) | (xor_s << u5((0 -% rot) & 31));
219219 }
220220
221 fn seed(self: &Pcg, init_s: u64) void {
221 fn seed(self: *Pcg, init_s: u64) void {
222222 // Pcg requires 128-bits of seed.
223223 var gen = SplitMix64.init(init_s);
224224 self.seedTwo(gen.next(), gen.next());
225225 }
226226
227 fn seedTwo(self: &Pcg, init_s: u64, init_i: u64) void {
227 fn seedTwo(self: *Pcg, init_s: u64, init_i: u64) void {
228228 self.s = 0;
229229 self.i = (init_s << 1) | 1;
230230 self.s = self.s *% default_multiplier +% self.i;
......@@ -232,7 +232,7 @@ pub const Pcg = struct {
232232 self.s = self.s *% default_multiplier +% self.i;
233233 }
234234
235 fn fill(r: &Random, buf: []u8) void {
235 fn fill(r: *Random, buf: []u8) void {
236236 const self = @fieldParentPtr(Pcg, "random", r);
237237
238238 var i: usize = 0;
......@@ -297,7 +297,7 @@ pub const Xoroshiro128 = struct {
297297 return x;
298298 }
299299
300 fn next(self: &Xoroshiro128) u64 {
300 fn next(self: *Xoroshiro128) u64 {
301301 const s0 = self.s[0];
302302 var s1 = self.s[1];
303303 const r = s0 +% s1;
......@@ -310,7 +310,7 @@ pub const Xoroshiro128 = struct {
310310 }
311311
312312 // Skip 2^64 places ahead in the sequence
313 fn jump(self: &Xoroshiro128) void {
313 fn jump(self: *Xoroshiro128) void {
314314 var s0: u64 = 0;
315315 var s1: u64 = 0;
316316
......@@ -334,7 +334,7 @@ pub const Xoroshiro128 = struct {
334334 self.s[1] = s1;
335335 }
336336
337 fn seed(self: &Xoroshiro128, init_s: u64) void {
337 fn seed(self: *Xoroshiro128, init_s: u64) void {
338338 // Xoroshiro requires 128-bits of seed.
339339 var gen = SplitMix64.init(init_s);
340340
......@@ -342,7 +342,7 @@ pub const Xoroshiro128 = struct {
342342 self.s[1] = gen.next();
343343 }
344344
345 fn fill(r: &Random, buf: []u8) void {
345 fn fill(r: *Random, buf: []u8) void {
346346 const self = @fieldParentPtr(Xoroshiro128, "random", r);
347347
348348 var i: usize = 0;
......@@ -435,7 +435,7 @@ pub const Isaac64 = struct {
435435 return isaac;
436436 }
437437
438 fn step(self: &Isaac64, mix: u64, base: usize, comptime m1: usize, comptime m2: usize) void {
438 fn step(self: *Isaac64, mix: u64, base: usize, comptime m1: usize, comptime m2: usize) void {
439439 const x = self.m[base + m1];
440440 self.a = mix +% self.m[base + m2];
441441
......@@ -446,7 +446,7 @@ pub const Isaac64 = struct {
446446 self.r[self.r.len - 1 - base - m1] = self.b;
447447 }
448448
449 fn refill(self: &Isaac64) void {
449 fn refill(self: *Isaac64) void {
450450 const midpoint = self.r.len / 2;
451451
452452 self.c +%= 1;
......@@ -475,7 +475,7 @@ pub const Isaac64 = struct {
475475 self.i = 0;
476476 }
477477
478 fn next(self: &Isaac64) u64 {
478 fn next(self: *Isaac64) u64 {
479479 if (self.i >= self.r.len) {
480480 self.refill();
481481 }
......@@ -485,7 +485,7 @@ pub const Isaac64 = struct {
485485 return value;
486486 }
487487
488 fn seed(self: &Isaac64, init_s: u64, comptime rounds: usize) void {
488 fn seed(self: *Isaac64, init_s: u64, comptime rounds: usize) void {
489489 // We ignore the multi-pass requirement since we don't currently expose full access to
490490 // seeding the self.m array completely.
491491 mem.set(u64, self.m[0..], 0);
......@@ -551,7 +551,7 @@ pub const Isaac64 = struct {
551551 self.i = self.r.len; // trigger refill on first value
552552 }
553553
554 fn fill(r: &Random, buf: []u8) void {
554 fn fill(r: *Random, buf: []u8) void {
555555 const self = @fieldParentPtr(Isaac64, "random", r);
556556
557557 var i: usize = 0;
......@@ -666,7 +666,7 @@ test "Random range" {
666666 testRange(&prng.random, 10, 14);
667667}
668668
669fn testRange(r: &Random, start: i32, end: i32) void {
669fn testRange(r: *Random, start: i32, end: i32) void {
670670 const count = usize(end - start);
671671 var values_buffer = []bool{false} ** 20;
672672 const values = values_buffer[0..count];
std/rand/ziggurat.zig+5-5
......@@ -12,7 +12,7 @@ const std = @import("../index.zig");
1212const math = std.math;
1313const Random = std.rand.Random;
1414
15pub fn next_f64(random: &Random, comptime tables: &const ZigTable) f64 {
15pub fn next_f64(random: *Random, comptime tables: *const ZigTable) f64 {
1616 while (true) {
1717 // We manually construct a float from parts as we can avoid an extra random lookup here by
1818 // using the unused exponent for the lookup table entry.
......@@ -60,7 +60,7 @@ pub const ZigTable = struct {
6060 // whether the distribution is symmetric
6161 is_symmetric: bool,
6262 // fallback calculation in the case we are in the 0 block
63 zero_case: fn (&Random, f64) f64,
63 zero_case: fn (*Random, f64) f64,
6464};
6565
6666// zigNorInit
......@@ -70,7 +70,7 @@ fn ZigTableGen(
7070 comptime v: f64,
7171 comptime f: fn (f64) f64,
7272 comptime f_inv: fn (f64) f64,
73 comptime zero_case: fn (&Random, f64) f64,
73 comptime zero_case: fn (*Random, f64) f64,
7474) ZigTable {
7575 var tables: ZigTable = undefined;
7676
......@@ -110,7 +110,7 @@ fn norm_f(x: f64) f64 {
110110fn norm_f_inv(y: f64) f64 {
111111 return math.sqrt(-2.0 * math.ln(y));
112112}
113fn norm_zero_case(random: &Random, u: f64) f64 {
113fn norm_zero_case(random: *Random, u: f64) f64 {
114114 var x: f64 = 1;
115115 var y: f64 = 0;
116116
......@@ -149,7 +149,7 @@ fn exp_f(x: f64) f64 {
149149fn exp_f_inv(y: f64) f64 {
150150 return -math.ln(y);
151151}
152fn exp_zero_case(random: &Random, _: f64) f64 {
152fn exp_zero_case(random: *Random, _: f64) f64 {
153153 return exp_r - math.ln(random.float(f64));
154154}
155155
std/segmented_list.zig+27-27
......@@ -87,49 +87,49 @@ pub fn SegmentedList(comptime T: type, comptime prealloc_item_count: usize) type
8787 const ShelfIndex = std.math.Log2Int(usize);
8888
8989 prealloc_segment: [prealloc_item_count]T,
90 dynamic_segments: []&T,
91 allocator: &Allocator,
90 dynamic_segments: []*T,
91 allocator: *Allocator,
9292 len: usize,
9393
9494 pub const prealloc_count = prealloc_item_count;
9595
9696 /// Deinitialize with `deinit`
97 pub fn init(allocator: &Allocator) Self {
97 pub fn init(allocator: *Allocator) Self {
9898 return Self{
9999 .allocator = allocator,
100100 .len = 0,
101101 .prealloc_segment = undefined,
102 .dynamic_segments = []&T{},
102 .dynamic_segments = []*T{},
103103 };
104104 }
105105
106 pub fn deinit(self: &Self) void {
106 pub fn deinit(self: *Self) void {
107107 self.freeShelves(ShelfIndex(self.dynamic_segments.len), 0);
108108 self.allocator.free(self.dynamic_segments);
109109 self.* = undefined;
110110 }
111111
112 pub fn at(self: &Self, i: usize) &T {
112 pub fn at(self: *Self, i: usize) *T {
113113 assert(i < self.len);
114114 return self.uncheckedAt(i);
115115 }
116116
117 pub fn count(self: &const Self) usize {
117 pub fn count(self: *const Self) usize {
118118 return self.len;
119119 }
120120
121 pub fn push(self: &Self, item: &const T) !void {
121 pub fn push(self: *Self, item: *const T) !void {
122122 const new_item_ptr = try self.addOne();
123123 new_item_ptr.* = item.*;
124124 }
125125
126 pub fn pushMany(self: &Self, items: []const T) !void {
126 pub fn pushMany(self: *Self, items: []const T) !void {
127127 for (items) |item| {
128128 try self.push(item);
129129 }
130130 }
131131
132 pub fn pop(self: &Self) ?T {
132 pub fn pop(self: *Self) ?T {
133133 if (self.len == 0) return null;
134134
135135 const index = self.len - 1;
......@@ -138,7 +138,7 @@ pub fn SegmentedList(comptime T: type, comptime prealloc_item_count: usize) type
138138 return result;
139139 }
140140
141 pub fn addOne(self: &Self) !&T {
141 pub fn addOne(self: *Self) !*T {
142142 const new_length = self.len + 1;
143143 try self.growCapacity(new_length);
144144 const result = self.uncheckedAt(self.len);
......@@ -147,7 +147,7 @@ pub fn SegmentedList(comptime T: type, comptime prealloc_item_count: usize) type
147147 }
148148
149149 /// Grows or shrinks capacity to match usage.
150 pub fn setCapacity(self: &Self, new_capacity: usize) !void {
150 pub fn setCapacity(self: *Self, new_capacity: usize) !void {
151151 if (new_capacity <= usize(1) << (prealloc_exp + self.dynamic_segments.len)) {
152152 return self.shrinkCapacity(new_capacity);
153153 } else {
......@@ -156,15 +156,15 @@ pub fn SegmentedList(comptime T: type, comptime prealloc_item_count: usize) type
156156 }
157157
158158 /// Only grows capacity, or retains current capacity
159 pub fn growCapacity(self: &Self, new_capacity: usize) !void {
159 pub fn growCapacity(self: *Self, new_capacity: usize) !void {
160160 const new_cap_shelf_count = shelfCount(new_capacity);
161161 const old_shelf_count = ShelfIndex(self.dynamic_segments.len);
162162 if (new_cap_shelf_count > old_shelf_count) {
163 self.dynamic_segments = try self.allocator.realloc(&T, self.dynamic_segments, new_cap_shelf_count);
163 self.dynamic_segments = try self.allocator.realloc(*T, self.dynamic_segments, new_cap_shelf_count);
164164 var i = old_shelf_count;
165165 errdefer {
166166 self.freeShelves(i, old_shelf_count);
167 self.dynamic_segments = self.allocator.shrink(&T, self.dynamic_segments, old_shelf_count);
167 self.dynamic_segments = self.allocator.shrink(*T, self.dynamic_segments, old_shelf_count);
168168 }
169169 while (i < new_cap_shelf_count) : (i += 1) {
170170 self.dynamic_segments[i] = (try self.allocator.alloc(T, shelfSize(i))).ptr;
......@@ -173,12 +173,12 @@ pub fn SegmentedList(comptime T: type, comptime prealloc_item_count: usize) type
173173 }
174174
175175 /// Only shrinks capacity or retains current capacity
176 pub fn shrinkCapacity(self: &Self, new_capacity: usize) void {
176 pub fn shrinkCapacity(self: *Self, new_capacity: usize) void {
177177 if (new_capacity <= prealloc_item_count) {
178178 const len = ShelfIndex(self.dynamic_segments.len);
179179 self.freeShelves(len, 0);
180180 self.allocator.free(self.dynamic_segments);
181 self.dynamic_segments = []&T{};
181 self.dynamic_segments = []*T{};
182182 return;
183183 }
184184
......@@ -190,10 +190,10 @@ pub fn SegmentedList(comptime T: type, comptime prealloc_item_count: usize) type
190190 }
191191
192192 self.freeShelves(old_shelf_count, new_cap_shelf_count);
193 self.dynamic_segments = self.allocator.shrink(&T, self.dynamic_segments, new_cap_shelf_count);
193 self.dynamic_segments = self.allocator.shrink(*T, self.dynamic_segments, new_cap_shelf_count);
194194 }
195195
196 pub fn uncheckedAt(self: &Self, index: usize) &T {
196 pub fn uncheckedAt(self: *Self, index: usize) *T {
197197 if (index < prealloc_item_count) {
198198 return &self.prealloc_segment[index];
199199 }
......@@ -230,7 +230,7 @@ pub fn SegmentedList(comptime T: type, comptime prealloc_item_count: usize) type
230230 return list_index + prealloc_item_count - (usize(1) << ((prealloc_exp + 1) + shelf_index));
231231 }
232232
233 fn freeShelves(self: &Self, from_count: ShelfIndex, to_count: ShelfIndex) void {
233 fn freeShelves(self: *Self, from_count: ShelfIndex, to_count: ShelfIndex) void {
234234 var i = from_count;
235235 while (i != to_count) {
236236 i -= 1;
......@@ -239,13 +239,13 @@ pub fn SegmentedList(comptime T: type, comptime prealloc_item_count: usize) type
239239 }
240240
241241 pub const Iterator = struct {
242 list: &Self,
242 list: *Self,
243243 index: usize,
244244 box_index: usize,
245245 shelf_index: ShelfIndex,
246246 shelf_size: usize,
247247
248 pub fn next(it: &Iterator) ?&T {
248 pub fn next(it: *Iterator) ?*T {
249249 if (it.index >= it.list.len) return null;
250250 if (it.index < prealloc_item_count) {
251251 const ptr = &it.list.prealloc_segment[it.index];
......@@ -269,7 +269,7 @@ pub fn SegmentedList(comptime T: type, comptime prealloc_item_count: usize) type
269269 return ptr;
270270 }
271271
272 pub fn prev(it: &Iterator) ?&T {
272 pub fn prev(it: *Iterator) ?*T {
273273 if (it.index == 0) return null;
274274
275275 it.index -= 1;
......@@ -286,7 +286,7 @@ pub fn SegmentedList(comptime T: type, comptime prealloc_item_count: usize) type
286286 return &it.list.dynamic_segments[it.shelf_index][it.box_index];
287287 }
288288
289 pub fn peek(it: &Iterator) ?&T {
289 pub fn peek(it: *Iterator) ?*T {
290290 if (it.index >= it.list.len)
291291 return null;
292292 if (it.index < prealloc_item_count)
......@@ -295,7 +295,7 @@ pub fn SegmentedList(comptime T: type, comptime prealloc_item_count: usize) type
295295 return &it.list.dynamic_segments[it.shelf_index][it.box_index];
296296 }
297297
298 pub fn set(it: &Iterator, index: usize) void {
298 pub fn set(it: *Iterator, index: usize) void {
299299 it.index = index;
300300 if (index < prealloc_item_count) return;
301301 it.shelf_index = shelfIndex(index);
......@@ -304,7 +304,7 @@ pub fn SegmentedList(comptime T: type, comptime prealloc_item_count: usize) type
304304 }
305305 };
306306
307 pub fn iterator(self: &Self, start_index: usize) Iterator {
307 pub fn iterator(self: *Self, start_index: usize) Iterator {
308308 var it = Iterator{
309309 .list = self,
310310 .index = undefined,
......@@ -331,7 +331,7 @@ test "std.SegmentedList" {
331331 try testSegmentedList(16, a);
332332}
333333
334fn testSegmentedList(comptime prealloc: usize, allocator: &Allocator) !void {
334fn testSegmentedList(comptime prealloc: usize, allocator: *Allocator) !void {
335335 var list = SegmentedList(i32, prealloc).init(allocator);
336336 defer list.deinit();
337337
std/sort.zig+27-27
......@@ -5,7 +5,7 @@ const math = std.math;
55const builtin = @import("builtin");
66
77/// Stable in-place sort. O(n) best case, O(pow(n, 2)) worst case. O(1) memory (no allocator required).
8pub fn insertionSort(comptime T: type, items: []T, lessThan: fn (lhs: &const T, rhs: &const T) bool) void {
8pub fn insertionSort(comptime T: type, items: []T, lessThan: fn (lhs: *const T, rhs: *const T) bool) void {
99 {
1010 var i: usize = 1;
1111 while (i < items.len) : (i += 1) {
......@@ -30,7 +30,7 @@ const Range = struct {
3030 };
3131 }
3232
33 fn length(self: &const Range) usize {
33 fn length(self: *const Range) usize {
3434 return self.end - self.start;
3535 }
3636};
......@@ -58,12 +58,12 @@ const Iterator = struct {
5858 };
5959 }
6060
61 fn begin(self: &Iterator) void {
61 fn begin(self: *Iterator) void {
6262 self.numerator = 0;
6363 self.decimal = 0;
6464 }
6565
66 fn nextRange(self: &Iterator) Range {
66 fn nextRange(self: *Iterator) Range {
6767 const start = self.decimal;
6868
6969 self.decimal += self.decimal_step;
......@@ -79,11 +79,11 @@ const Iterator = struct {
7979 };
8080 }
8181
82 fn finished(self: &Iterator) bool {
82 fn finished(self: *Iterator) bool {
8383 return self.decimal >= self.size;
8484 }
8585
86 fn nextLevel(self: &Iterator) bool {
86 fn nextLevel(self: *Iterator) bool {
8787 self.decimal_step += self.decimal_step;
8888 self.numerator_step += self.numerator_step;
8989 if (self.numerator_step >= self.denominator) {
......@@ -94,7 +94,7 @@ const Iterator = struct {
9494 return (self.decimal_step < self.size);
9595 }
9696
97 fn length(self: &Iterator) usize {
97 fn length(self: *Iterator) usize {
9898 return self.decimal_step;
9999 }
100100};
......@@ -108,7 +108,7 @@ const Pull = struct {
108108
109109/// Stable in-place sort. O(n) best case, O(n*log(n)) worst case and average case. O(1) memory (no allocator required).
110110/// Currently implemented as block sort.
111pub fn sort(comptime T: type, items: []T, lessThan: fn (lhs: &const T, rhs: &const T) bool) void {
111pub fn sort(comptime T: type, items: []T, lessThan: fn (lhs: *const T, rhs: *const T) bool) void {
112112 // Implementation ported from https://github.com/BonzaiThePenguin/WikiSort/blob/master/WikiSort.c
113113 var cache: [512]T = undefined;
114114
......@@ -741,7 +741,7 @@ pub fn sort(comptime T: type, items: []T, lessThan: fn (lhs: &const T, rhs: &con
741741}
742742
743743// merge operation without a buffer
744fn mergeInPlace(comptime T: type, items: []T, A_arg: &const Range, B_arg: &const Range, lessThan: fn (&const T, &const T) bool) void {
744fn mergeInPlace(comptime T: type, items: []T, A_arg: *const Range, B_arg: *const Range, lessThan: fn (*const T, *const T) bool) void {
745745 if (A_arg.length() == 0 or B_arg.length() == 0) return;
746746
747747 // this just repeatedly binary searches into B and rotates A into position.
......@@ -783,7 +783,7 @@ fn mergeInPlace(comptime T: type, items: []T, A_arg: &const Range, B_arg: &const
783783}
784784
785785// merge operation using an internal buffer
786fn mergeInternal(comptime T: type, items: []T, A: &const Range, B: &const Range, lessThan: fn (&const T, &const T) bool, buffer: &const Range) void {
786fn mergeInternal(comptime T: type, items: []T, A: *const Range, B: *const Range, lessThan: fn (*const T, *const T) bool, buffer: *const Range) void {
787787 // whenever we find a value to add to the final array, swap it with the value that's already in that spot
788788 // when this algorithm is finished, 'buffer' will contain its original contents, but in a different order
789789 var A_count: usize = 0;
......@@ -819,7 +819,7 @@ fn blockSwap(comptime T: type, items: []T, start1: usize, start2: usize, block_s
819819
820820// combine a linear search with a binary search to reduce the number of comparisons in situations
821821// where have some idea as to how many unique values there are and where the next value might be
822fn findFirstForward(comptime T: type, items: []T, value: &const T, range: &const Range, lessThan: fn (&const T, &const T) bool, unique: usize) usize {
822fn findFirstForward(comptime T: type, items: []T, value: *const T, range: *const Range, lessThan: fn (*const T, *const T) bool, unique: usize) usize {
823823 if (range.length() == 0) return range.start;
824824 const skip = math.max(range.length() / unique, usize(1));
825825
......@@ -833,7 +833,7 @@ fn findFirstForward(comptime T: type, items: []T, value: &const T, range: &const
833833 return binaryFirst(T, items, value, Range.init(index - skip, index), lessThan);
834834}
835835
836fn findFirstBackward(comptime T: type, items: []T, value: &const T, range: &const Range, lessThan: fn (&const T, &const T) bool, unique: usize) usize {
836fn findFirstBackward(comptime T: type, items: []T, value: *const T, range: *const Range, lessThan: fn (*const T, *const T) bool, unique: usize) usize {
837837 if (range.length() == 0) return range.start;
838838 const skip = math.max(range.length() / unique, usize(1));
839839
......@@ -847,7 +847,7 @@ fn findFirstBackward(comptime T: type, items: []T, value: &const T, range: &cons
847847 return binaryFirst(T, items, value, Range.init(index, index + skip), lessThan);
848848}
849849
850fn findLastForward(comptime T: type, items: []T, value: &const T, range: &const Range, lessThan: fn (&const T, &const T) bool, unique: usize) usize {
850fn findLastForward(comptime T: type, items: []T, value: *const T, range: *const Range, lessThan: fn (*const T, *const T) bool, unique: usize) usize {
851851 if (range.length() == 0) return range.start;
852852 const skip = math.max(range.length() / unique, usize(1));
853853
......@@ -861,7 +861,7 @@ fn findLastForward(comptime T: type, items: []T, value: &const T, range: &const
861861 return binaryLast(T, items, value, Range.init(index - skip, index), lessThan);
862862}
863863
864fn findLastBackward(comptime T: type, items: []T, value: &const T, range: &const Range, lessThan: fn (&const T, &const T) bool, unique: usize) usize {
864fn findLastBackward(comptime T: type, items: []T, value: *const T, range: *const Range, lessThan: fn (*const T, *const T) bool, unique: usize) usize {
865865 if (range.length() == 0) return range.start;
866866 const skip = math.max(range.length() / unique, usize(1));
867867
......@@ -875,7 +875,7 @@ fn findLastBackward(comptime T: type, items: []T, value: &const T, range: &const
875875 return binaryLast(T, items, value, Range.init(index, index + skip), lessThan);
876876}
877877
878fn binaryFirst(comptime T: type, items: []T, value: &const T, range: &const Range, lessThan: fn (&const T, &const T) bool) usize {
878fn binaryFirst(comptime T: type, items: []T, value: *const T, range: *const Range, lessThan: fn (*const T, *const T) bool) usize {
879879 var start = range.start;
880880 var end = range.end - 1;
881881 if (range.start >= range.end) return range.end;
......@@ -893,7 +893,7 @@ fn binaryFirst(comptime T: type, items: []T, value: &const T, range: &const Rang
893893 return start;
894894}
895895
896fn binaryLast(comptime T: type, items: []T, value: &const T, range: &const Range, lessThan: fn (&const T, &const T) bool) usize {
896fn binaryLast(comptime T: type, items: []T, value: *const T, range: *const Range, lessThan: fn (*const T, *const T) bool) usize {
897897 var start = range.start;
898898 var end = range.end - 1;
899899 if (range.start >= range.end) return range.end;
......@@ -911,7 +911,7 @@ fn binaryLast(comptime T: type, items: []T, value: &const T, range: &const Range
911911 return start;
912912}
913913
914fn mergeInto(comptime T: type, from: []T, A: &const Range, B: &const Range, lessThan: fn (&const T, &const T) bool, into: []T) void {
914fn mergeInto(comptime T: type, from: []T, A: *const Range, B: *const Range, lessThan: fn (*const T, *const T) bool, into: []T) void {
915915 var A_index: usize = A.start;
916916 var B_index: usize = B.start;
917917 const A_last = A.end;
......@@ -941,7 +941,7 @@ fn mergeInto(comptime T: type, from: []T, A: &const Range, B: &const Range, less
941941 }
942942}
943943
944fn mergeExternal(comptime T: type, items: []T, A: &const Range, B: &const Range, lessThan: fn (&const T, &const T) bool, cache: []T) void {
944fn mergeExternal(comptime T: type, items: []T, A: *const Range, B: *const Range, lessThan: fn (*const T, *const T) bool, cache: []T) void {
945945 // A fits into the cache, so use that instead of the internal buffer
946946 var A_index: usize = 0;
947947 var B_index: usize = B.start;
......@@ -969,26 +969,26 @@ fn mergeExternal(comptime T: type, items: []T, A: &const Range, B: &const Range,
969969 mem.copy(T, items[insert_index..], cache[A_index..A_last]);
970970}
971971
972fn swap(comptime T: type, items: []T, lessThan: fn (lhs: &const T, rhs: &const T) bool, order: &[8]u8, x: usize, y: usize) void {
972fn swap(comptime T: type, items: []T, lessThan: fn (lhs: *const T, rhs: *const T) bool, order: *[8]u8, x: usize, y: usize) void {
973973 if (lessThan(items[y], items[x]) or ((order.*)[x] > (order.*)[y] and !lessThan(items[x], items[y]))) {
974974 mem.swap(T, &items[x], &items[y]);
975975 mem.swap(u8, &(order.*)[x], &(order.*)[y]);
976976 }
977977}
978978
979fn i32asc(lhs: &const i32, rhs: &const i32) bool {
979fn i32asc(lhs: *const i32, rhs: *const i32) bool {
980980 return lhs.* < rhs.*;
981981}
982982
983fn i32desc(lhs: &const i32, rhs: &const i32) bool {
983fn i32desc(lhs: *const i32, rhs: *const i32) bool {
984984 return rhs.* < lhs.*;
985985}
986986
987fn u8asc(lhs: &const u8, rhs: &const u8) bool {
987fn u8asc(lhs: *const u8, rhs: *const u8) bool {
988988 return lhs.* < rhs.*;
989989}
990990
991fn u8desc(lhs: &const u8, rhs: &const u8) bool {
991fn u8desc(lhs: *const u8, rhs: *const u8) bool {
992992 return rhs.* < lhs.*;
993993}
994994
......@@ -1125,7 +1125,7 @@ const IdAndValue = struct {
11251125 id: usize,
11261126 value: i32,
11271127};
1128fn cmpByValue(a: &const IdAndValue, b: &const IdAndValue) bool {
1128fn cmpByValue(a: *const IdAndValue, b: *const IdAndValue) bool {
11291129 return i32asc(a.value, b.value);
11301130}
11311131
......@@ -1324,7 +1324,7 @@ test "sort fuzz testing" {
13241324
13251325var fixed_buffer_mem: [100 * 1024]u8 = undefined;
13261326
1327fn fuzzTest(rng: &std.rand.Random) void {
1327fn fuzzTest(rng: *std.rand.Random) void {
13281328 const array_size = rng.range(usize, 0, 1000);
13291329 var fixed_allocator = std.heap.FixedBufferAllocator.init(fixed_buffer_mem[0..]);
13301330 var array = fixed_allocator.allocator.alloc(IdAndValue, array_size) catch unreachable;
......@@ -1345,7 +1345,7 @@ fn fuzzTest(rng: &std.rand.Random) void {
13451345 }
13461346}
13471347
1348pub fn min(comptime T: type, items: []T, lessThan: fn (lhs: &const T, rhs: &const T) bool) T {
1348pub fn min(comptime T: type, items: []T, lessThan: fn (lhs: *const T, rhs: *const T) bool) T {
13491349 var i: usize = 0;
13501350 var smallest = items[0];
13511351 for (items[1..]) |item| {
......@@ -1356,7 +1356,7 @@ pub fn min(comptime T: type, items: []T, lessThan: fn (lhs: &const T, rhs: &cons
13561356 return smallest;
13571357}
13581358
1359pub fn max(comptime T: type, items: []T, lessThan: fn (lhs: &const T, rhs: &const T) bool) T {
1359pub fn max(comptime T: type, items: []T, lessThan: fn (lhs: *const T, rhs: *const T) bool) T {
13601360 var i: usize = 0;
13611361 var biggest = items[0];
13621362 for (items[1..]) |item| {
std/special/bootstrap.zig+10-10
......@@ -5,7 +5,7 @@ const root = @import("@root");
55const std = @import("std");
66const builtin = @import("builtin");
77
8var argc_ptr: &usize = undefined;
8var argc_ptr: *usize = undefined;
99
1010comptime {
1111 const strong_linkage = builtin.GlobalLinkage.Strong;
......@@ -28,12 +28,12 @@ nakedcc fn _start() noreturn {
2828 switch (builtin.arch) {
2929 builtin.Arch.x86_64 => {
3030 argc_ptr = asm ("lea (%%rsp), %[argc]"
31 : [argc] "=r" (-> &usize)
31 : [argc] "=r" (-> *usize)
3232 );
3333 },
3434 builtin.Arch.i386 => {
3535 argc_ptr = asm ("lea (%%esp), %[argc]"
36 : [argc] "=r" (-> &usize)
36 : [argc] "=r" (-> *usize)
3737 );
3838 },
3939 else => @compileError("unsupported arch"),
......@@ -51,13 +51,13 @@ extern fn WinMainCRTStartup() noreturn {
5151
5252fn posixCallMainAndExit() noreturn {
5353 const argc = argc_ptr.*;
54 const argv = @ptrCast(&&u8, &argc_ptr[1]);
55 const envp_nullable = @ptrCast(&?&u8, &argv[argc + 1]);
54 const argv = @ptrCast(**u8, &argc_ptr[1]);
55 const envp_nullable = @ptrCast(*?*u8, &argv[argc + 1]);
5656 var envp_count: usize = 0;
5757 while (envp_nullable[envp_count]) |_| : (envp_count += 1) {}
58 const envp = @ptrCast(&&u8, envp_nullable)[0..envp_count];
58 const envp = @ptrCast(**u8, envp_nullable)[0..envp_count];
5959 if (builtin.os == builtin.Os.linux) {
60 const auxv = &@ptrCast(&usize, envp.ptr)[envp_count + 1];
60 const auxv = &@ptrCast(*usize, envp.ptr)[envp_count + 1];
6161 var i: usize = 0;
6262 while (auxv[i] != 0) : (i += 2) {
6363 if (auxv[i] < std.os.linux_aux_raw.len) std.os.linux_aux_raw[auxv[i]] = auxv[i + 1];
......@@ -68,16 +68,16 @@ fn posixCallMainAndExit() noreturn {
6868 std.os.posix.exit(callMainWithArgs(argc, argv, envp));
6969}
7070
71fn callMainWithArgs(argc: usize, argv: &&u8, envp: []&u8) u8 {
71fn callMainWithArgs(argc: usize, argv: **u8, envp: []*u8) u8 {
7272 std.os.ArgIteratorPosix.raw = argv[0..argc];
7373 std.os.posix_environ_raw = envp;
7474 return callMain();
7575}
7676
77extern fn main(c_argc: i32, c_argv: &&u8, c_envp: &?&u8) i32 {
77extern fn main(c_argc: i32, c_argv: **u8, c_envp: *?*u8) i32 {
7878 var env_count: usize = 0;
7979 while (c_envp[env_count] != null) : (env_count += 1) {}
80 const envp = @ptrCast(&&u8, c_envp)[0..env_count];
80 const envp = @ptrCast(**u8, c_envp)[0..env_count];
8181 return callMainWithArgs(usize(c_argc), c_argv, envp);
8282}
8383
std/special/build_file_template.zig+2-2
......@@ -1,10 +1,10 @@
11const Builder = @import("std").build.Builder;
22
3pub fn build(b: &Builder) void {
3pub fn build(b: *Builder) void {
44 const mode = b.standardReleaseOptions();
55 const exe = b.addExecutable("YOUR_NAME_HERE", "src/main.zig");
66 exe.setBuildMode(mode);
77
8 b.default_step.dependOn(&exe.step);
8 b.default_step.dependOn(*exe.step);
99 b.installArtifact(exe);
1010}
std/special/build_runner.zig+3-3
......@@ -129,7 +129,7 @@ pub fn main() !void {
129129 };
130130}
131131
132fn runBuild(builder: &Builder) error!void {
132fn runBuild(builder: *Builder) error!void {
133133 switch (@typeId(@typeOf(root.build).ReturnType)) {
134134 builtin.TypeId.Void => root.build(builder),
135135 builtin.TypeId.ErrorUnion => try root.build(builder),
......@@ -137,7 +137,7 @@ fn runBuild(builder: &Builder) error!void {
137137 }
138138}
139139
140fn usage(builder: &Builder, already_ran_build: bool, out_stream: var) !void {
140fn usage(builder: *Builder, already_ran_build: bool, out_stream: var) !void {
141141 // run the build script to collect the options
142142 if (!already_ran_build) {
143143 builder.setInstallPrefix(null);
......@@ -195,7 +195,7 @@ fn usage(builder: &Builder, already_ran_build: bool, out_stream: var) !void {
195195 );
196196}
197197
198fn usageAndErr(builder: &Builder, already_ran_build: bool, out_stream: var) error {
198fn usageAndErr(builder: *Builder, already_ran_build: bool, out_stream: var) error {
199199 usage(builder, already_ran_build, out_stream) catch {};
200200 return error.InvalidArgs;
201201}
std/special/builtin.zig+4-4
......@@ -5,7 +5,7 @@ const builtin = @import("builtin");
55
66// Avoid dragging in the runtime safety mechanisms into this .o file,
77// unless we're trying to test this file.
8pub fn panic(msg: []const u8, error_return_trace: ?&builtin.StackTrace) noreturn {
8pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn {
99 if (builtin.is_test) {
1010 @setCold(true);
1111 @import("std").debug.panic("{}", msg);
......@@ -14,7 +14,7 @@ pub fn panic(msg: []const u8, error_return_trace: ?&builtin.StackTrace) noreturn
1414 }
1515}
1616
17export fn memset(dest: ?&u8, c: u8, n: usize) ?&u8 {
17export fn memset(dest: ?*u8, c: u8, n: usize) ?*u8 {
1818 @setRuntimeSafety(false);
1919
2020 var index: usize = 0;
......@@ -24,7 +24,7 @@ export fn memset(dest: ?&u8, c: u8, n: usize) ?&u8 {
2424 return dest;
2525}
2626
27export fn memcpy(noalias dest: ?&u8, noalias src: ?&const u8, n: usize) ?&u8 {
27export fn memcpy(noalias dest: ?*u8, noalias src: ?*const u8, n: usize) ?*u8 {
2828 @setRuntimeSafety(false);
2929
3030 var index: usize = 0;
......@@ -34,7 +34,7 @@ export fn memcpy(noalias dest: ?&u8, noalias src: ?&const u8, n: usize) ?&u8 {
3434 return dest;
3535}
3636
37export fn memmove(dest: ?&u8, src: ?&const u8, n: usize) ?&u8 {
37export fn memmove(dest: ?*u8, src: ?*const u8, n: usize) ?*u8 {
3838 @setRuntimeSafety(false);
3939
4040 if (@ptrToInt(dest) < @ptrToInt(src)) {
std/special/compiler_rt/index.zig+2-2
......@@ -78,7 +78,7 @@ const __udivmoddi4 = @import("udivmoddi4.zig").__udivmoddi4;
7878
7979// Avoid dragging in the runtime safety mechanisms into this .o file,
8080// unless we're trying to test this file.
81pub fn panic(msg: []const u8, error_return_trace: ?&builtin.StackTrace) noreturn {
81pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn {
8282 @setCold(true);
8383 if (is_test) {
8484 std.debug.panic("{}", msg);
......@@ -284,7 +284,7 @@ nakedcc fn ___chkstk_ms() align(4) void {
284284 );
285285}
286286
287extern fn __udivmodsi4(a: u32, b: u32, rem: &u32) u32 {
287extern fn __udivmodsi4(a: u32, b: u32, rem: *u32) u32 {
288288 @setRuntimeSafety(is_test);
289289
290290 const d = __udivsi3(a, b);
std/special/compiler_rt/udivmod.zig+9-9
......@@ -7,15 +7,15 @@ const low = switch (builtin.endian) {
77};
88const high = 1 - low;
99
10pub fn udivmod(comptime DoubleInt: type, a: DoubleInt, b: DoubleInt, maybe_rem: ?&DoubleInt) DoubleInt {
10pub fn udivmod(comptime DoubleInt: type, a: DoubleInt, b: DoubleInt, maybe_rem: ?*DoubleInt) DoubleInt {
1111 @setRuntimeSafety(is_test);
1212
1313 const SingleInt = @IntType(false, @divExact(DoubleInt.bit_count, 2));
1414 const SignedDoubleInt = @IntType(true, DoubleInt.bit_count);
1515 const Log2SingleInt = @import("std").math.Log2Int(SingleInt);
1616
17 const n = @ptrCast(&const [2]SingleInt, &a).*; // TODO issue #421
18 const d = @ptrCast(&const [2]SingleInt, &b).*; // TODO issue #421
17 const n = @ptrCast(*const [2]SingleInt, &a).*; // TODO issue #421
18 const d = @ptrCast(*const [2]SingleInt, &b).*; // TODO issue #421
1919 var q: [2]SingleInt = undefined;
2020 var r: [2]SingleInt = undefined;
2121 var sr: c_uint = undefined;
......@@ -57,7 +57,7 @@ pub fn udivmod(comptime DoubleInt: type, a: DoubleInt, b: DoubleInt, maybe_rem:
5757 if (maybe_rem) |rem| {
5858 r[high] = n[high] % d[high];
5959 r[low] = 0;
60 rem.* = @ptrCast(&align(@alignOf(SingleInt)) DoubleInt, &r[0]).*; // TODO issue #421
60 rem.* = @ptrCast(*align(@alignOf(SingleInt)) DoubleInt, &r[0]).*; // TODO issue #421
6161 }
6262 return n[high] / d[high];
6363 }
......@@ -69,7 +69,7 @@ pub fn udivmod(comptime DoubleInt: type, a: DoubleInt, b: DoubleInt, maybe_rem:
6969 if (maybe_rem) |rem| {
7070 r[low] = n[low];
7171 r[high] = n[high] & (d[high] - 1);
72 rem.* = @ptrCast(&align(@alignOf(SingleInt)) DoubleInt, &r[0]).*; // TODO issue #421
72 rem.* = @ptrCast(*align(@alignOf(SingleInt)) DoubleInt, &r[0]).*; // TODO issue #421
7373 }
7474 return n[high] >> Log2SingleInt(@ctz(d[high]));
7575 }
......@@ -109,7 +109,7 @@ pub fn udivmod(comptime DoubleInt: type, a: DoubleInt, b: DoubleInt, maybe_rem:
109109 sr = @ctz(d[low]);
110110 q[high] = n[high] >> Log2SingleInt(sr);
111111 q[low] = (n[high] << Log2SingleInt(SingleInt.bit_count - sr)) | (n[low] >> Log2SingleInt(sr));
112 return @ptrCast(&align(@alignOf(SingleInt)) DoubleInt, &q[0]).*; // TODO issue #421
112 return @ptrCast(*align(@alignOf(SingleInt)) DoubleInt, &q[0]).*; // TODO issue #421
113113 }
114114 // K X
115115 // ---
......@@ -183,13 +183,13 @@ pub fn udivmod(comptime DoubleInt: type, a: DoubleInt, b: DoubleInt, maybe_rem:
183183 // r.all -= b;
184184 // carry = 1;
185185 // }
186 r_all = @ptrCast(&align(@alignOf(SingleInt)) DoubleInt, &r[0]).*; // TODO issue #421
186 r_all = @ptrCast(*align(@alignOf(SingleInt)) DoubleInt, &r[0]).*; // TODO issue #421
187187 const s: SignedDoubleInt = SignedDoubleInt(b -% r_all -% 1) >> (DoubleInt.bit_count - 1);
188188 carry = u32(s & 1);
189189 r_all -= b & @bitCast(DoubleInt, s);
190 r = @ptrCast(&[2]SingleInt, &r_all).*; // TODO issue #421
190 r = @ptrCast(*[2]SingleInt, &r_all).*; // TODO issue #421
191191 }
192 const q_all = ((@ptrCast(&align(@alignOf(SingleInt)) DoubleInt, &q[0]).*) << 1) | carry; // TODO issue #421
192 const q_all = ((@ptrCast(*align(@alignOf(SingleInt)) DoubleInt, &q[0]).*) << 1) | carry; // TODO issue #421
193193 if (maybe_rem) |rem| {
194194 rem.* = r_all;
195195 }
std/special/compiler_rt/udivmoddi4.zig+1-1
......@@ -1,7 +1,7 @@
11const udivmod = @import("udivmod.zig").udivmod;
22const builtin = @import("builtin");
33
4pub extern fn __udivmoddi4(a: u64, b: u64, maybe_rem: ?&u64) u64 {
4pub extern fn __udivmoddi4(a: u64, b: u64, maybe_rem: ?*u64) u64 {
55 @setRuntimeSafety(builtin.is_test);
66 return udivmod(u64, a, b, maybe_rem);
77}
std/special/compiler_rt/udivmodti4.zig+2-2
......@@ -2,12 +2,12 @@ const udivmod = @import("udivmod.zig").udivmod;
22const builtin = @import("builtin");
33const compiler_rt = @import("index.zig");
44
5pub extern fn __udivmodti4(a: u128, b: u128, maybe_rem: ?&u128) u128 {
5pub extern fn __udivmodti4(a: u128, b: u128, maybe_rem: ?*u128) u128 {
66 @setRuntimeSafety(builtin.is_test);
77 return udivmod(u128, a, b, maybe_rem);
88}
99
10pub extern fn __udivmodti4_windows_x86_64(a: &const u128, b: &const u128, maybe_rem: ?&u128) void {
10pub extern fn __udivmodti4_windows_x86_64(a: *const u128, b: *const u128, maybe_rem: ?*u128) void {
1111 @setRuntimeSafety(builtin.is_test);
1212 compiler_rt.setXmm0(u128, udivmod(u128, a.*, b.*, maybe_rem));
1313}
std/special/compiler_rt/udivti3.zig+1-1
......@@ -6,7 +6,7 @@ pub extern fn __udivti3(a: u128, b: u128) u128 {
66 return udivmodti4.__udivmodti4(a, b, null);
77}
88
9pub extern fn __udivti3_windows_x86_64(a: &const u128, b: &const u128) void {
9pub extern fn __udivti3_windows_x86_64(a: *const u128, b: *const u128) void {
1010 @setRuntimeSafety(builtin.is_test);
1111 udivmodti4.__udivmodti4_windows_x86_64(a, b, null);
1212}
std/special/compiler_rt/umodti3.zig+1-1
......@@ -9,7 +9,7 @@ pub extern fn __umodti3(a: u128, b: u128) u128 {
99 return r;
1010}
1111
12pub extern fn __umodti3_windows_x86_64(a: &const u128, b: &const u128) void {
12pub extern fn __umodti3_windows_x86_64(a: *const u128, b: *const u128) void {
1313 @setRuntimeSafety(builtin.is_test);
1414 compiler_rt.setXmm0(u128, __umodti3(a.*, b.*));
1515}
std/special/panic.zig+1-1
......@@ -6,7 +6,7 @@
66const builtin = @import("builtin");
77const std = @import("std");
88
9pub fn panic(msg: []const u8, error_return_trace: ?&builtin.StackTrace) noreturn {
9pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn {
1010 @setCold(true);
1111 switch (builtin.os) {
1212 // TODO: fix panic in zen.
std/unicode.zig+3-3
......@@ -196,7 +196,7 @@ pub const Utf8View = struct {
196196 }
197197 }
198198
199 pub fn iterator(s: &const Utf8View) Utf8Iterator {
199 pub fn iterator(s: *const Utf8View) Utf8Iterator {
200200 return Utf8Iterator{
201201 .bytes = s.bytes,
202202 .i = 0,
......@@ -208,7 +208,7 @@ const Utf8Iterator = struct {
208208 bytes: []const u8,
209209 i: usize,
210210
211 pub fn nextCodepointSlice(it: &Utf8Iterator) ?[]const u8 {
211 pub fn nextCodepointSlice(it: *Utf8Iterator) ?[]const u8 {
212212 if (it.i >= it.bytes.len) {
213213 return null;
214214 }
......@@ -219,7 +219,7 @@ const Utf8Iterator = struct {
219219 return it.bytes[it.i - cp_len .. it.i];
220220 }
221221
222 pub fn nextCodepoint(it: &Utf8Iterator) ?u32 {
222 pub fn nextCodepoint(it: *Utf8Iterator) ?u32 {
223223 const slice = it.nextCodepointSlice() ?? return null;
224224
225225 switch (slice.len) {
std/zig/ast.zig+289-289
......@@ -9,26 +9,26 @@ pub const TokenIndex = usize;
99pub const Tree = struct {
1010 source: []const u8,
1111 tokens: TokenList,
12 root_node: &Node.Root,
12 root_node: *Node.Root,
1313 arena_allocator: std.heap.ArenaAllocator,
1414 errors: ErrorList,
1515
1616 pub const TokenList = SegmentedList(Token, 64);
1717 pub const ErrorList = SegmentedList(Error, 0);
1818
19 pub fn deinit(self: &Tree) void {
19 pub fn deinit(self: *Tree) void {
2020 self.arena_allocator.deinit();
2121 }
2222
23 pub fn renderError(self: &Tree, parse_error: &Error, stream: var) !void {
23 pub fn renderError(self: *Tree, parse_error: *Error, stream: var) !void {
2424 return parse_error.render(&self.tokens, stream);
2525 }
2626
27 pub fn tokenSlice(self: &Tree, token_index: TokenIndex) []const u8 {
27 pub fn tokenSlice(self: *Tree, token_index: TokenIndex) []const u8 {
2828 return self.tokenSlicePtr(self.tokens.at(token_index));
2929 }
3030
31 pub fn tokenSlicePtr(self: &Tree, token: &const Token) []const u8 {
31 pub fn tokenSlicePtr(self: *Tree, token: *const Token) []const u8 {
3232 return self.source[token.start..token.end];
3333 }
3434
......@@ -39,7 +39,7 @@ pub const Tree = struct {
3939 line_end: usize,
4040 };
4141
42 pub fn tokenLocationPtr(self: &Tree, start_index: usize, token: &const Token) Location {
42 pub fn tokenLocationPtr(self: *Tree, start_index: usize, token: *const Token) Location {
4343 var loc = Location{
4444 .line = 0,
4545 .column = 0,
......@@ -64,24 +64,24 @@ pub const Tree = struct {
6464 return loc;
6565 }
6666
67 pub fn tokenLocation(self: &Tree, start_index: usize, token_index: TokenIndex) Location {
67 pub fn tokenLocation(self: *Tree, start_index: usize, token_index: TokenIndex) Location {
6868 return self.tokenLocationPtr(start_index, self.tokens.at(token_index));
6969 }
7070
71 pub fn tokensOnSameLine(self: &Tree, token1_index: TokenIndex, token2_index: TokenIndex) bool {
71 pub fn tokensOnSameLine(self: *Tree, token1_index: TokenIndex, token2_index: TokenIndex) bool {
7272 return self.tokensOnSameLinePtr(self.tokens.at(token1_index), self.tokens.at(token2_index));
7373 }
7474
75 pub fn tokensOnSameLinePtr(self: &Tree, token1: &const Token, token2: &const Token) bool {
75 pub fn tokensOnSameLinePtr(self: *Tree, token1: *const Token, token2: *const Token) bool {
7676 return mem.indexOfScalar(u8, self.source[token1.end..token2.start], '\n') == null;
7777 }
7878
79 pub fn dump(self: &Tree) void {
79 pub fn dump(self: *Tree) void {
8080 self.root_node.base.dump(0);
8181 }
8282
8383 /// Skips over comments
84 pub fn prevToken(self: &Tree, token_index: TokenIndex) TokenIndex {
84 pub fn prevToken(self: *Tree, token_index: TokenIndex) TokenIndex {
8585 var index = token_index - 1;
8686 while (self.tokens.at(index).id == Token.Id.LineComment) {
8787 index -= 1;
......@@ -90,7 +90,7 @@ pub const Tree = struct {
9090 }
9191
9292 /// Skips over comments
93 pub fn nextToken(self: &Tree, token_index: TokenIndex) TokenIndex {
93 pub fn nextToken(self: *Tree, token_index: TokenIndex) TokenIndex {
9494 var index = token_index + 1;
9595 while (self.tokens.at(index).id == Token.Id.LineComment) {
9696 index += 1;
......@@ -120,7 +120,7 @@ pub const Error = union(enum) {
120120 ExpectedToken: ExpectedToken,
121121 ExpectedCommaOrEnd: ExpectedCommaOrEnd,
122122
123 pub fn render(self: &const Error, tokens: &Tree.TokenList, stream: var) !void {
123 pub fn render(self: *const Error, tokens: *Tree.TokenList, stream: var) !void {
124124 switch (self.*) {
125125 // TODO https://github.com/ziglang/zig/issues/683
126126 @TagType(Error).InvalidToken => |*x| return x.render(tokens, stream),
......@@ -145,7 +145,7 @@ pub const Error = union(enum) {
145145 }
146146 }
147147
148 pub fn loc(self: &const Error) TokenIndex {
148 pub fn loc(self: *const Error) TokenIndex {
149149 switch (self.*) {
150150 // TODO https://github.com/ziglang/zig/issues/683
151151 @TagType(Error).InvalidToken => |x| return x.token,
......@@ -188,17 +188,17 @@ pub const Error = union(enum) {
188188 pub const ExtraVolatileQualifier = SimpleError("Extra volatile qualifier");
189189
190190 pub const ExpectedCall = struct {
191 node: &Node,
191 node: *Node,
192192
193 pub fn render(self: &const ExpectedCall, tokens: &Tree.TokenList, stream: var) !void {
193 pub fn render(self: *const ExpectedCall, tokens: *Tree.TokenList, stream: var) !void {
194194 return stream.print("expected " ++ @tagName(@TagType(Node.SuffixOp.Op).Call) ++ ", found {}", @tagName(self.node.id));
195195 }
196196 };
197197
198198 pub const ExpectedCallOrFnProto = struct {
199 node: &Node,
199 node: *Node,
200200
201 pub fn render(self: &const ExpectedCallOrFnProto, tokens: &Tree.TokenList, stream: var) !void {
201 pub fn render(self: *const ExpectedCallOrFnProto, tokens: *Tree.TokenList, stream: var) !void {
202202 return stream.print("expected " ++ @tagName(@TagType(Node.SuffixOp.Op).Call) ++ " or " ++ @tagName(Node.Id.FnProto) ++ ", found {}", @tagName(self.node.id));
203203 }
204204 };
......@@ -207,7 +207,7 @@ pub const Error = union(enum) {
207207 token: TokenIndex,
208208 expected_id: @TagType(Token.Id),
209209
210 pub fn render(self: &const ExpectedToken, tokens: &Tree.TokenList, stream: var) !void {
210 pub fn render(self: *const ExpectedToken, tokens: *Tree.TokenList, stream: var) !void {
211211 const token_name = @tagName(tokens.at(self.token).id);
212212 return stream.print("expected {}, found {}", @tagName(self.expected_id), token_name);
213213 }
......@@ -217,7 +217,7 @@ pub const Error = union(enum) {
217217 token: TokenIndex,
218218 end_id: @TagType(Token.Id),
219219
220 pub fn render(self: &const ExpectedCommaOrEnd, tokens: &Tree.TokenList, stream: var) !void {
220 pub fn render(self: *const ExpectedCommaOrEnd, tokens: *Tree.TokenList, stream: var) !void {
221221 const token_name = @tagName(tokens.at(self.token).id);
222222 return stream.print("expected ',' or {}, found {}", @tagName(self.end_id), token_name);
223223 }
......@@ -229,7 +229,7 @@ pub const Error = union(enum) {
229229
230230 token: TokenIndex,
231231
232 pub fn render(self: &const ThisError, tokens: &Tree.TokenList, stream: var) !void {
232 pub fn render(self: *const ThisError, tokens: *Tree.TokenList, stream: var) !void {
233233 const token_name = @tagName(tokens.at(self.token).id);
234234 return stream.print(msg, token_name);
235235 }
......@@ -242,7 +242,7 @@ pub const Error = union(enum) {
242242
243243 token: TokenIndex,
244244
245 pub fn render(self: &const ThisError, tokens: &Tree.TokenList, stream: var) !void {
245 pub fn render(self: *const ThisError, tokens: *Tree.TokenList, stream: var) !void {
246246 return stream.write(msg);
247247 }
248248 };
......@@ -320,14 +320,14 @@ pub const Node = struct {
320320 FieldInitializer,
321321 };
322322
323 pub fn cast(base: &Node, comptime T: type) ?&T {
323 pub fn cast(base: *Node, comptime T: type) ?*T {
324324 if (base.id == comptime typeToId(T)) {
325325 return @fieldParentPtr(T, "base", base);
326326 }
327327 return null;
328328 }
329329
330 pub fn iterate(base: &Node, index: usize) ?&Node {
330 pub fn iterate(base: *Node, index: usize) ?*Node {
331331 comptime var i = 0;
332332 inline while (i < @memberCount(Id)) : (i += 1) {
333333 if (base.id == @field(Id, @memberName(Id, i))) {
......@@ -338,7 +338,7 @@ pub const Node = struct {
338338 unreachable;
339339 }
340340
341 pub fn firstToken(base: &Node) TokenIndex {
341 pub fn firstToken(base: *Node) TokenIndex {
342342 comptime var i = 0;
343343 inline while (i < @memberCount(Id)) : (i += 1) {
344344 if (base.id == @field(Id, @memberName(Id, i))) {
......@@ -349,7 +349,7 @@ pub const Node = struct {
349349 unreachable;
350350 }
351351
352 pub fn lastToken(base: &Node) TokenIndex {
352 pub fn lastToken(base: *Node) TokenIndex {
353353 comptime var i = 0;
354354 inline while (i < @memberCount(Id)) : (i += 1) {
355355 if (base.id == @field(Id, @memberName(Id, i))) {
......@@ -370,7 +370,7 @@ pub const Node = struct {
370370 unreachable;
371371 }
372372
373 pub fn requireSemiColon(base: &const Node) bool {
373 pub fn requireSemiColon(base: *const Node) bool {
374374 var n = base;
375375 while (true) {
376376 switch (n.id) {
......@@ -443,7 +443,7 @@ pub const Node = struct {
443443 }
444444 }
445445
446 pub fn dump(self: &Node, indent: usize) void {
446 pub fn dump(self: *Node, indent: usize) void {
447447 {
448448 var i: usize = 0;
449449 while (i < indent) : (i += 1) {
......@@ -460,44 +460,44 @@ pub const Node = struct {
460460
461461 pub const Root = struct {
462462 base: Node,
463 doc_comments: ?&DocComment,
463 doc_comments: ?*DocComment,
464464 decls: DeclList,
465465 eof_token: TokenIndex,
466466
467 pub const DeclList = SegmentedList(&Node, 4);
467 pub const DeclList = SegmentedList(*Node, 4);
468468
469 pub fn iterate(self: &Root, index: usize) ?&Node {
469 pub fn iterate(self: *Root, index: usize) ?*Node {
470470 if (index < self.decls.len) {
471471 return self.decls.at(index).*;
472472 }
473473 return null;
474474 }
475475
476 pub fn firstToken(self: &Root) TokenIndex {
476 pub fn firstToken(self: *Root) TokenIndex {
477477 return if (self.decls.len == 0) self.eof_token else (self.decls.at(0).*).firstToken();
478478 }
479479
480 pub fn lastToken(self: &Root) TokenIndex {
480 pub fn lastToken(self: *Root) TokenIndex {
481481 return if (self.decls.len == 0) self.eof_token else (self.decls.at(self.decls.len - 1).*).lastToken();
482482 }
483483 };
484484
485485 pub const VarDecl = struct {
486486 base: Node,
487 doc_comments: ?&DocComment,
487 doc_comments: ?*DocComment,
488488 visib_token: ?TokenIndex,
489489 name_token: TokenIndex,
490490 eq_token: TokenIndex,
491491 mut_token: TokenIndex,
492492 comptime_token: ?TokenIndex,
493493 extern_export_token: ?TokenIndex,
494 lib_name: ?&Node,
495 type_node: ?&Node,
496 align_node: ?&Node,
497 init_node: ?&Node,
494 lib_name: ?*Node,
495 type_node: ?*Node,
496 align_node: ?*Node,
497 init_node: ?*Node,
498498 semicolon_token: TokenIndex,
499499
500 pub fn iterate(self: &VarDecl, index: usize) ?&Node {
500 pub fn iterate(self: *VarDecl, index: usize) ?*Node {
501501 var i = index;
502502
503503 if (self.type_node) |type_node| {
......@@ -518,7 +518,7 @@ pub const Node = struct {
518518 return null;
519519 }
520520
521 pub fn firstToken(self: &VarDecl) TokenIndex {
521 pub fn firstToken(self: *VarDecl) TokenIndex {
522522 if (self.visib_token) |visib_token| return visib_token;
523523 if (self.comptime_token) |comptime_token| return comptime_token;
524524 if (self.extern_export_token) |extern_export_token| return extern_export_token;
......@@ -526,20 +526,20 @@ pub const Node = struct {
526526 return self.mut_token;
527527 }
528528
529 pub fn lastToken(self: &VarDecl) TokenIndex {
529 pub fn lastToken(self: *VarDecl) TokenIndex {
530530 return self.semicolon_token;
531531 }
532532 };
533533
534534 pub const Use = struct {
535535 base: Node,
536 doc_comments: ?&DocComment,
536 doc_comments: ?*DocComment,
537537 visib_token: ?TokenIndex,
538538 use_token: TokenIndex,
539 expr: &Node,
539 expr: *Node,
540540 semicolon_token: TokenIndex,
541541
542 pub fn iterate(self: &Use, index: usize) ?&Node {
542 pub fn iterate(self: *Use, index: usize) ?*Node {
543543 var i = index;
544544
545545 if (i < 1) return self.expr;
......@@ -548,12 +548,12 @@ pub const Node = struct {
548548 return null;
549549 }
550550
551 pub fn firstToken(self: &Use) TokenIndex {
551 pub fn firstToken(self: *Use) TokenIndex {
552552 if (self.visib_token) |visib_token| return visib_token;
553553 return self.use_token;
554554 }
555555
556 pub fn lastToken(self: &Use) TokenIndex {
556 pub fn lastToken(self: *Use) TokenIndex {
557557 return self.semicolon_token;
558558 }
559559 };
......@@ -564,9 +564,9 @@ pub const Node = struct {
564564 decls: DeclList,
565565 rbrace_token: TokenIndex,
566566
567 pub const DeclList = SegmentedList(&Node, 2);
567 pub const DeclList = SegmentedList(*Node, 2);
568568
569 pub fn iterate(self: &ErrorSetDecl, index: usize) ?&Node {
569 pub fn iterate(self: *ErrorSetDecl, index: usize) ?*Node {
570570 var i = index;
571571
572572 if (i < self.decls.len) return self.decls.at(i).*;
......@@ -575,11 +575,11 @@ pub const Node = struct {
575575 return null;
576576 }
577577
578 pub fn firstToken(self: &ErrorSetDecl) TokenIndex {
578 pub fn firstToken(self: *ErrorSetDecl) TokenIndex {
579579 return self.error_token;
580580 }
581581
582 pub fn lastToken(self: &ErrorSetDecl) TokenIndex {
582 pub fn lastToken(self: *ErrorSetDecl) TokenIndex {
583583 return self.rbrace_token;
584584 }
585585 };
......@@ -597,11 +597,11 @@ pub const Node = struct {
597597
598598 const InitArg = union(enum) {
599599 None,
600 Enum: ?&Node,
601 Type: &Node,
600 Enum: ?*Node,
601 Type: *Node,
602602 };
603603
604 pub fn iterate(self: &ContainerDecl, index: usize) ?&Node {
604 pub fn iterate(self: *ContainerDecl, index: usize) ?*Node {
605605 var i = index;
606606
607607 switch (self.init_arg_expr) {
......@@ -618,26 +618,26 @@ pub const Node = struct {
618618 return null;
619619 }
620620
621 pub fn firstToken(self: &ContainerDecl) TokenIndex {
621 pub fn firstToken(self: *ContainerDecl) TokenIndex {
622622 if (self.layout_token) |layout_token| {
623623 return layout_token;
624624 }
625625 return self.kind_token;
626626 }
627627
628 pub fn lastToken(self: &ContainerDecl) TokenIndex {
628 pub fn lastToken(self: *ContainerDecl) TokenIndex {
629629 return self.rbrace_token;
630630 }
631631 };
632632
633633 pub const StructField = struct {
634634 base: Node,
635 doc_comments: ?&DocComment,
635 doc_comments: ?*DocComment,
636636 visib_token: ?TokenIndex,
637637 name_token: TokenIndex,
638 type_expr: &Node,
638 type_expr: *Node,
639639
640 pub fn iterate(self: &StructField, index: usize) ?&Node {
640 pub fn iterate(self: *StructField, index: usize) ?*Node {
641641 var i = index;
642642
643643 if (i < 1) return self.type_expr;
......@@ -646,24 +646,24 @@ pub const Node = struct {
646646 return null;
647647 }
648648
649 pub fn firstToken(self: &StructField) TokenIndex {
649 pub fn firstToken(self: *StructField) TokenIndex {
650650 if (self.visib_token) |visib_token| return visib_token;
651651 return self.name_token;
652652 }
653653
654 pub fn lastToken(self: &StructField) TokenIndex {
654 pub fn lastToken(self: *StructField) TokenIndex {
655655 return self.type_expr.lastToken();
656656 }
657657 };
658658
659659 pub const UnionTag = struct {
660660 base: Node,
661 doc_comments: ?&DocComment,
661 doc_comments: ?*DocComment,
662662 name_token: TokenIndex,
663 type_expr: ?&Node,
664 value_expr: ?&Node,
663 type_expr: ?*Node,
664 value_expr: ?*Node,
665665
666 pub fn iterate(self: &UnionTag, index: usize) ?&Node {
666 pub fn iterate(self: *UnionTag, index: usize) ?*Node {
667667 var i = index;
668668
669669 if (self.type_expr) |type_expr| {
......@@ -679,11 +679,11 @@ pub const Node = struct {
679679 return null;
680680 }
681681
682 pub fn firstToken(self: &UnionTag) TokenIndex {
682 pub fn firstToken(self: *UnionTag) TokenIndex {
683683 return self.name_token;
684684 }
685685
686 pub fn lastToken(self: &UnionTag) TokenIndex {
686 pub fn lastToken(self: *UnionTag) TokenIndex {
687687 if (self.value_expr) |value_expr| {
688688 return value_expr.lastToken();
689689 }
......@@ -697,11 +697,11 @@ pub const Node = struct {
697697
698698 pub const EnumTag = struct {
699699 base: Node,
700 doc_comments: ?&DocComment,
700 doc_comments: ?*DocComment,
701701 name_token: TokenIndex,
702 value: ?&Node,
702 value: ?*Node,
703703
704 pub fn iterate(self: &EnumTag, index: usize) ?&Node {
704 pub fn iterate(self: *EnumTag, index: usize) ?*Node {
705705 var i = index;
706706
707707 if (self.value) |value| {
......@@ -712,11 +712,11 @@ pub const Node = struct {
712712 return null;
713713 }
714714
715 pub fn firstToken(self: &EnumTag) TokenIndex {
715 pub fn firstToken(self: *EnumTag) TokenIndex {
716716 return self.name_token;
717717 }
718718
719 pub fn lastToken(self: &EnumTag) TokenIndex {
719 pub fn lastToken(self: *EnumTag) TokenIndex {
720720 if (self.value) |value| {
721721 return value.lastToken();
722722 }
......@@ -727,25 +727,25 @@ pub const Node = struct {
727727
728728 pub const ErrorTag = struct {
729729 base: Node,
730 doc_comments: ?&DocComment,
730 doc_comments: ?*DocComment,
731731 name_token: TokenIndex,
732732
733 pub fn iterate(self: &ErrorTag, index: usize) ?&Node {
733 pub fn iterate(self: *ErrorTag, index: usize) ?*Node {
734734 var i = index;
735735
736736 if (self.doc_comments) |comments| {
737 if (i < 1) return &comments.base;
737 if (i < 1) return *comments.base;
738738 i -= 1;
739739 }
740740
741741 return null;
742742 }
743743
744 pub fn firstToken(self: &ErrorTag) TokenIndex {
744 pub fn firstToken(self: *ErrorTag) TokenIndex {
745745 return self.name_token;
746746 }
747747
748 pub fn lastToken(self: &ErrorTag) TokenIndex {
748 pub fn lastToken(self: *ErrorTag) TokenIndex {
749749 return self.name_token;
750750 }
751751 };
......@@ -754,15 +754,15 @@ pub const Node = struct {
754754 base: Node,
755755 token: TokenIndex,
756756
757 pub fn iterate(self: &Identifier, index: usize) ?&Node {
757 pub fn iterate(self: *Identifier, index: usize) ?*Node {
758758 return null;
759759 }
760760
761 pub fn firstToken(self: &Identifier) TokenIndex {
761 pub fn firstToken(self: *Identifier) TokenIndex {
762762 return self.token;
763763 }
764764
765 pub fn lastToken(self: &Identifier) TokenIndex {
765 pub fn lastToken(self: *Identifier) TokenIndex {
766766 return self.token;
767767 }
768768 };
......@@ -770,10 +770,10 @@ pub const Node = struct {
770770 pub const AsyncAttribute = struct {
771771 base: Node,
772772 async_token: TokenIndex,
773 allocator_type: ?&Node,
773 allocator_type: ?*Node,
774774 rangle_bracket: ?TokenIndex,
775775
776 pub fn iterate(self: &AsyncAttribute, index: usize) ?&Node {
776 pub fn iterate(self: *AsyncAttribute, index: usize) ?*Node {
777777 var i = index;
778778
779779 if (self.allocator_type) |allocator_type| {
......@@ -784,11 +784,11 @@ pub const Node = struct {
784784 return null;
785785 }
786786
787 pub fn firstToken(self: &AsyncAttribute) TokenIndex {
787 pub fn firstToken(self: *AsyncAttribute) TokenIndex {
788788 return self.async_token;
789789 }
790790
791 pub fn lastToken(self: &AsyncAttribute) TokenIndex {
791 pub fn lastToken(self: *AsyncAttribute) TokenIndex {
792792 if (self.rangle_bracket) |rangle_bracket| {
793793 return rangle_bracket;
794794 }
......@@ -799,7 +799,7 @@ pub const Node = struct {
799799
800800 pub const FnProto = struct {
801801 base: Node,
802 doc_comments: ?&DocComment,
802 doc_comments: ?*DocComment,
803803 visib_token: ?TokenIndex,
804804 fn_token: TokenIndex,
805805 name_token: ?TokenIndex,
......@@ -808,19 +808,19 @@ pub const Node = struct {
808808 var_args_token: ?TokenIndex,
809809 extern_export_inline_token: ?TokenIndex,
810810 cc_token: ?TokenIndex,
811 async_attr: ?&AsyncAttribute,
812 body_node: ?&Node,
813 lib_name: ?&Node, // populated if this is an extern declaration
814 align_expr: ?&Node, // populated if align(A) is present
811 async_attr: ?*AsyncAttribute,
812 body_node: ?*Node,
813 lib_name: ?*Node, // populated if this is an extern declaration
814 align_expr: ?*Node, // populated if align(A) is present
815815
816 pub const ParamList = SegmentedList(&Node, 2);
816 pub const ParamList = SegmentedList(*Node, 2);
817817
818818 pub const ReturnType = union(enum) {
819 Explicit: &Node,
820 InferErrorSet: &Node,
819 Explicit: *Node,
820 InferErrorSet: *Node,
821821 };
822822
823 pub fn iterate(self: &FnProto, index: usize) ?&Node {
823 pub fn iterate(self: *FnProto, index: usize) ?*Node {
824824 var i = index;
825825
826826 if (self.lib_name) |lib_name| {
......@@ -856,7 +856,7 @@ pub const Node = struct {
856856 return null;
857857 }
858858
859 pub fn firstToken(self: &FnProto) TokenIndex {
859 pub fn firstToken(self: *FnProto) TokenIndex {
860860 if (self.visib_token) |visib_token| return visib_token;
861861 if (self.extern_export_inline_token) |extern_export_inline_token| return extern_export_inline_token;
862862 assert(self.lib_name == null);
......@@ -864,7 +864,7 @@ pub const Node = struct {
864864 return self.fn_token;
865865 }
866866
867 pub fn lastToken(self: &FnProto) TokenIndex {
867 pub fn lastToken(self: *FnProto) TokenIndex {
868868 if (self.body_node) |body_node| return body_node.lastToken();
869869 switch (self.return_type) {
870870 // TODO allow this and next prong to share bodies since the types are the same
......@@ -881,10 +881,10 @@ pub const Node = struct {
881881
882882 pub const Result = struct {
883883 arrow_token: TokenIndex,
884 return_type: &Node,
884 return_type: *Node,
885885 };
886886
887 pub fn iterate(self: &PromiseType, index: usize) ?&Node {
887 pub fn iterate(self: *PromiseType, index: usize) ?*Node {
888888 var i = index;
889889
890890 if (self.result) |result| {
......@@ -895,11 +895,11 @@ pub const Node = struct {
895895 return null;
896896 }
897897
898 pub fn firstToken(self: &PromiseType) TokenIndex {
898 pub fn firstToken(self: *PromiseType) TokenIndex {
899899 return self.promise_token;
900900 }
901901
902 pub fn lastToken(self: &PromiseType) TokenIndex {
902 pub fn lastToken(self: *PromiseType) TokenIndex {
903903 if (self.result) |result| return result.return_type.lastToken();
904904 return self.promise_token;
905905 }
......@@ -910,10 +910,10 @@ pub const Node = struct {
910910 comptime_token: ?TokenIndex,
911911 noalias_token: ?TokenIndex,
912912 name_token: ?TokenIndex,
913 type_node: &Node,
913 type_node: *Node,
914914 var_args_token: ?TokenIndex,
915915
916 pub fn iterate(self: &ParamDecl, index: usize) ?&Node {
916 pub fn iterate(self: *ParamDecl, index: usize) ?*Node {
917917 var i = index;
918918
919919 if (i < 1) return self.type_node;
......@@ -922,14 +922,14 @@ pub const Node = struct {
922922 return null;
923923 }
924924
925 pub fn firstToken(self: &ParamDecl) TokenIndex {
925 pub fn firstToken(self: *ParamDecl) TokenIndex {
926926 if (self.comptime_token) |comptime_token| return comptime_token;
927927 if (self.noalias_token) |noalias_token| return noalias_token;
928928 if (self.name_token) |name_token| return name_token;
929929 return self.type_node.firstToken();
930930 }
931931
932 pub fn lastToken(self: &ParamDecl) TokenIndex {
932 pub fn lastToken(self: *ParamDecl) TokenIndex {
933933 if (self.var_args_token) |var_args_token| return var_args_token;
934934 return self.type_node.lastToken();
935935 }
......@@ -944,7 +944,7 @@ pub const Node = struct {
944944
945945 pub const StatementList = Root.DeclList;
946946
947 pub fn iterate(self: &Block, index: usize) ?&Node {
947 pub fn iterate(self: *Block, index: usize) ?*Node {
948948 var i = index;
949949
950950 if (i < self.statements.len) return self.statements.at(i).*;
......@@ -953,7 +953,7 @@ pub const Node = struct {
953953 return null;
954954 }
955955
956 pub fn firstToken(self: &Block) TokenIndex {
956 pub fn firstToken(self: *Block) TokenIndex {
957957 if (self.label) |label| {
958958 return label;
959959 }
......@@ -961,7 +961,7 @@ pub const Node = struct {
961961 return self.lbrace;
962962 }
963963
964 pub fn lastToken(self: &Block) TokenIndex {
964 pub fn lastToken(self: *Block) TokenIndex {
965965 return self.rbrace;
966966 }
967967 };
......@@ -970,14 +970,14 @@ pub const Node = struct {
970970 base: Node,
971971 defer_token: TokenIndex,
972972 kind: Kind,
973 expr: &Node,
973 expr: *Node,
974974
975975 const Kind = enum {
976976 Error,
977977 Unconditional,
978978 };
979979
980 pub fn iterate(self: &Defer, index: usize) ?&Node {
980 pub fn iterate(self: *Defer, index: usize) ?*Node {
981981 var i = index;
982982
983983 if (i < 1) return self.expr;
......@@ -986,22 +986,22 @@ pub const Node = struct {
986986 return null;
987987 }
988988
989 pub fn firstToken(self: &Defer) TokenIndex {
989 pub fn firstToken(self: *Defer) TokenIndex {
990990 return self.defer_token;
991991 }
992992
993 pub fn lastToken(self: &Defer) TokenIndex {
993 pub fn lastToken(self: *Defer) TokenIndex {
994994 return self.expr.lastToken();
995995 }
996996 };
997997
998998 pub const Comptime = struct {
999999 base: Node,
1000 doc_comments: ?&DocComment,
1000 doc_comments: ?*DocComment,
10011001 comptime_token: TokenIndex,
1002 expr: &Node,
1002 expr: *Node,
10031003
1004 pub fn iterate(self: &Comptime, index: usize) ?&Node {
1004 pub fn iterate(self: *Comptime, index: usize) ?*Node {
10051005 var i = index;
10061006
10071007 if (i < 1) return self.expr;
......@@ -1010,11 +1010,11 @@ pub const Node = struct {
10101010 return null;
10111011 }
10121012
1013 pub fn firstToken(self: &Comptime) TokenIndex {
1013 pub fn firstToken(self: *Comptime) TokenIndex {
10141014 return self.comptime_token;
10151015 }
10161016
1017 pub fn lastToken(self: &Comptime) TokenIndex {
1017 pub fn lastToken(self: *Comptime) TokenIndex {
10181018 return self.expr.lastToken();
10191019 }
10201020 };
......@@ -1022,10 +1022,10 @@ pub const Node = struct {
10221022 pub const Payload = struct {
10231023 base: Node,
10241024 lpipe: TokenIndex,
1025 error_symbol: &Node,
1025 error_symbol: *Node,
10261026 rpipe: TokenIndex,
10271027
1028 pub fn iterate(self: &Payload, index: usize) ?&Node {
1028 pub fn iterate(self: *Payload, index: usize) ?*Node {
10291029 var i = index;
10301030
10311031 if (i < 1) return self.error_symbol;
......@@ -1034,11 +1034,11 @@ pub const Node = struct {
10341034 return null;
10351035 }
10361036
1037 pub fn firstToken(self: &Payload) TokenIndex {
1037 pub fn firstToken(self: *Payload) TokenIndex {
10381038 return self.lpipe;
10391039 }
10401040
1041 pub fn lastToken(self: &Payload) TokenIndex {
1041 pub fn lastToken(self: *Payload) TokenIndex {
10421042 return self.rpipe;
10431043 }
10441044 };
......@@ -1047,10 +1047,10 @@ pub const Node = struct {
10471047 base: Node,
10481048 lpipe: TokenIndex,
10491049 ptr_token: ?TokenIndex,
1050 value_symbol: &Node,
1050 value_symbol: *Node,
10511051 rpipe: TokenIndex,
10521052
1053 pub fn iterate(self: &PointerPayload, index: usize) ?&Node {
1053 pub fn iterate(self: *PointerPayload, index: usize) ?*Node {
10541054 var i = index;
10551055
10561056 if (i < 1) return self.value_symbol;
......@@ -1059,11 +1059,11 @@ pub const Node = struct {
10591059 return null;
10601060 }
10611061
1062 pub fn firstToken(self: &PointerPayload) TokenIndex {
1062 pub fn firstToken(self: *PointerPayload) TokenIndex {
10631063 return self.lpipe;
10641064 }
10651065
1066 pub fn lastToken(self: &PointerPayload) TokenIndex {
1066 pub fn lastToken(self: *PointerPayload) TokenIndex {
10671067 return self.rpipe;
10681068 }
10691069 };
......@@ -1072,11 +1072,11 @@ pub const Node = struct {
10721072 base: Node,
10731073 lpipe: TokenIndex,
10741074 ptr_token: ?TokenIndex,
1075 value_symbol: &Node,
1076 index_symbol: ?&Node,
1075 value_symbol: *Node,
1076 index_symbol: ?*Node,
10771077 rpipe: TokenIndex,
10781078
1079 pub fn iterate(self: &PointerIndexPayload, index: usize) ?&Node {
1079 pub fn iterate(self: *PointerIndexPayload, index: usize) ?*Node {
10801080 var i = index;
10811081
10821082 if (i < 1) return self.value_symbol;
......@@ -1090,11 +1090,11 @@ pub const Node = struct {
10901090 return null;
10911091 }
10921092
1093 pub fn firstToken(self: &PointerIndexPayload) TokenIndex {
1093 pub fn firstToken(self: *PointerIndexPayload) TokenIndex {
10941094 return self.lpipe;
10951095 }
10961096
1097 pub fn lastToken(self: &PointerIndexPayload) TokenIndex {
1097 pub fn lastToken(self: *PointerIndexPayload) TokenIndex {
10981098 return self.rpipe;
10991099 }
11001100 };
......@@ -1102,10 +1102,10 @@ pub const Node = struct {
11021102 pub const Else = struct {
11031103 base: Node,
11041104 else_token: TokenIndex,
1105 payload: ?&Node,
1106 body: &Node,
1105 payload: ?*Node,
1106 body: *Node,
11071107
1108 pub fn iterate(self: &Else, index: usize) ?&Node {
1108 pub fn iterate(self: *Else, index: usize) ?*Node {
11091109 var i = index;
11101110
11111111 if (self.payload) |payload| {
......@@ -1119,11 +1119,11 @@ pub const Node = struct {
11191119 return null;
11201120 }
11211121
1122 pub fn firstToken(self: &Else) TokenIndex {
1122 pub fn firstToken(self: *Else) TokenIndex {
11231123 return self.else_token;
11241124 }
11251125
1126 pub fn lastToken(self: &Else) TokenIndex {
1126 pub fn lastToken(self: *Else) TokenIndex {
11271127 return self.body.lastToken();
11281128 }
11291129 };
......@@ -1131,15 +1131,15 @@ pub const Node = struct {
11311131 pub const Switch = struct {
11321132 base: Node,
11331133 switch_token: TokenIndex,
1134 expr: &Node,
1134 expr: *Node,
11351135
11361136 /// these must be SwitchCase nodes
11371137 cases: CaseList,
11381138 rbrace: TokenIndex,
11391139
1140 pub const CaseList = SegmentedList(&Node, 2);
1140 pub const CaseList = SegmentedList(*Node, 2);
11411141
1142 pub fn iterate(self: &Switch, index: usize) ?&Node {
1142 pub fn iterate(self: *Switch, index: usize) ?*Node {
11431143 var i = index;
11441144
11451145 if (i < 1) return self.expr;
......@@ -1151,11 +1151,11 @@ pub const Node = struct {
11511151 return null;
11521152 }
11531153
1154 pub fn firstToken(self: &Switch) TokenIndex {
1154 pub fn firstToken(self: *Switch) TokenIndex {
11551155 return self.switch_token;
11561156 }
11571157
1158 pub fn lastToken(self: &Switch) TokenIndex {
1158 pub fn lastToken(self: *Switch) TokenIndex {
11591159 return self.rbrace;
11601160 }
11611161 };
......@@ -1164,12 +1164,12 @@ pub const Node = struct {
11641164 base: Node,
11651165 items: ItemList,
11661166 arrow_token: TokenIndex,
1167 payload: ?&Node,
1168 expr: &Node,
1167 payload: ?*Node,
1168 expr: *Node,
11691169
1170 pub const ItemList = SegmentedList(&Node, 1);
1170 pub const ItemList = SegmentedList(*Node, 1);
11711171
1172 pub fn iterate(self: &SwitchCase, index: usize) ?&Node {
1172 pub fn iterate(self: *SwitchCase, index: usize) ?*Node {
11731173 var i = index;
11741174
11751175 if (i < self.items.len) return self.items.at(i).*;
......@@ -1186,11 +1186,11 @@ pub const Node = struct {
11861186 return null;
11871187 }
11881188
1189 pub fn firstToken(self: &SwitchCase) TokenIndex {
1189 pub fn firstToken(self: *SwitchCase) TokenIndex {
11901190 return (self.items.at(0).*).firstToken();
11911191 }
11921192
1193 pub fn lastToken(self: &SwitchCase) TokenIndex {
1193 pub fn lastToken(self: *SwitchCase) TokenIndex {
11941194 return self.expr.lastToken();
11951195 }
11961196 };
......@@ -1199,15 +1199,15 @@ pub const Node = struct {
11991199 base: Node,
12001200 token: TokenIndex,
12011201
1202 pub fn iterate(self: &SwitchElse, index: usize) ?&Node {
1202 pub fn iterate(self: *SwitchElse, index: usize) ?*Node {
12031203 return null;
12041204 }
12051205
1206 pub fn firstToken(self: &SwitchElse) TokenIndex {
1206 pub fn firstToken(self: *SwitchElse) TokenIndex {
12071207 return self.token;
12081208 }
12091209
1210 pub fn lastToken(self: &SwitchElse) TokenIndex {
1210 pub fn lastToken(self: *SwitchElse) TokenIndex {
12111211 return self.token;
12121212 }
12131213 };
......@@ -1217,13 +1217,13 @@ pub const Node = struct {
12171217 label: ?TokenIndex,
12181218 inline_token: ?TokenIndex,
12191219 while_token: TokenIndex,
1220 condition: &Node,
1221 payload: ?&Node,
1222 continue_expr: ?&Node,
1223 body: &Node,
1224 @"else": ?&Else,
1220 condition: *Node,
1221 payload: ?*Node,
1222 continue_expr: ?*Node,
1223 body: *Node,
1224 @"else": ?*Else,
12251225
1226 pub fn iterate(self: &While, index: usize) ?&Node {
1226 pub fn iterate(self: *While, index: usize) ?*Node {
12271227 var i = index;
12281228
12291229 if (i < 1) return self.condition;
......@@ -1243,14 +1243,14 @@ pub const Node = struct {
12431243 i -= 1;
12441244
12451245 if (self.@"else") |@"else"| {
1246 if (i < 1) return &@"else".base;
1246 if (i < 1) return *@"else".base;
12471247 i -= 1;
12481248 }
12491249
12501250 return null;
12511251 }
12521252
1253 pub fn firstToken(self: &While) TokenIndex {
1253 pub fn firstToken(self: *While) TokenIndex {
12541254 if (self.label) |label| {
12551255 return label;
12561256 }
......@@ -1262,7 +1262,7 @@ pub const Node = struct {
12621262 return self.while_token;
12631263 }
12641264
1265 pub fn lastToken(self: &While) TokenIndex {
1265 pub fn lastToken(self: *While) TokenIndex {
12661266 if (self.@"else") |@"else"| {
12671267 return @"else".body.lastToken();
12681268 }
......@@ -1276,12 +1276,12 @@ pub const Node = struct {
12761276 label: ?TokenIndex,
12771277 inline_token: ?TokenIndex,
12781278 for_token: TokenIndex,
1279 array_expr: &Node,
1280 payload: ?&Node,
1281 body: &Node,
1282 @"else": ?&Else,
1279 array_expr: *Node,
1280 payload: ?*Node,
1281 body: *Node,
1282 @"else": ?*Else,
12831283
1284 pub fn iterate(self: &For, index: usize) ?&Node {
1284 pub fn iterate(self: *For, index: usize) ?*Node {
12851285 var i = index;
12861286
12871287 if (i < 1) return self.array_expr;
......@@ -1296,14 +1296,14 @@ pub const Node = struct {
12961296 i -= 1;
12971297
12981298 if (self.@"else") |@"else"| {
1299 if (i < 1) return &@"else".base;
1299 if (i < 1) return *@"else".base;
13001300 i -= 1;
13011301 }
13021302
13031303 return null;
13041304 }
13051305
1306 pub fn firstToken(self: &For) TokenIndex {
1306 pub fn firstToken(self: *For) TokenIndex {
13071307 if (self.label) |label| {
13081308 return label;
13091309 }
......@@ -1315,7 +1315,7 @@ pub const Node = struct {
13151315 return self.for_token;
13161316 }
13171317
1318 pub fn lastToken(self: &For) TokenIndex {
1318 pub fn lastToken(self: *For) TokenIndex {
13191319 if (self.@"else") |@"else"| {
13201320 return @"else".body.lastToken();
13211321 }
......@@ -1327,12 +1327,12 @@ pub const Node = struct {
13271327 pub const If = struct {
13281328 base: Node,
13291329 if_token: TokenIndex,
1330 condition: &Node,
1331 payload: ?&Node,
1332 body: &Node,
1333 @"else": ?&Else,
1330 condition: *Node,
1331 payload: ?*Node,
1332 body: *Node,
1333 @"else": ?*Else,
13341334
1335 pub fn iterate(self: &If, index: usize) ?&Node {
1335 pub fn iterate(self: *If, index: usize) ?*Node {
13361336 var i = index;
13371337
13381338 if (i < 1) return self.condition;
......@@ -1347,18 +1347,18 @@ pub const Node = struct {
13471347 i -= 1;
13481348
13491349 if (self.@"else") |@"else"| {
1350 if (i < 1) return &@"else".base;
1350 if (i < 1) return *@"else".base;
13511351 i -= 1;
13521352 }
13531353
13541354 return null;
13551355 }
13561356
1357 pub fn firstToken(self: &If) TokenIndex {
1357 pub fn firstToken(self: *If) TokenIndex {
13581358 return self.if_token;
13591359 }
13601360
1361 pub fn lastToken(self: &If) TokenIndex {
1361 pub fn lastToken(self: *If) TokenIndex {
13621362 if (self.@"else") |@"else"| {
13631363 return @"else".body.lastToken();
13641364 }
......@@ -1370,9 +1370,9 @@ pub const Node = struct {
13701370 pub const InfixOp = struct {
13711371 base: Node,
13721372 op_token: TokenIndex,
1373 lhs: &Node,
1373 lhs: *Node,
13741374 op: Op,
1375 rhs: &Node,
1375 rhs: *Node,
13761376
13771377 pub const Op = union(enum) {
13781378 Add,
......@@ -1401,7 +1401,7 @@ pub const Node = struct {
14011401 BitXor,
14021402 BoolAnd,
14031403 BoolOr,
1404 Catch: ?&Node,
1404 Catch: ?*Node,
14051405 Div,
14061406 EqualEqual,
14071407 ErrorUnion,
......@@ -1420,7 +1420,7 @@ pub const Node = struct {
14201420 UnwrapMaybe,
14211421 };
14221422
1423 pub fn iterate(self: &InfixOp, index: usize) ?&Node {
1423 pub fn iterate(self: *InfixOp, index: usize) ?*Node {
14241424 var i = index;
14251425
14261426 if (i < 1) return self.lhs;
......@@ -1485,11 +1485,11 @@ pub const Node = struct {
14851485 return null;
14861486 }
14871487
1488 pub fn firstToken(self: &InfixOp) TokenIndex {
1488 pub fn firstToken(self: *InfixOp) TokenIndex {
14891489 return self.lhs.firstToken();
14901490 }
14911491
1492 pub fn lastToken(self: &InfixOp) TokenIndex {
1492 pub fn lastToken(self: *InfixOp) TokenIndex {
14931493 return self.rhs.lastToken();
14941494 }
14951495 };
......@@ -1498,42 +1498,42 @@ pub const Node = struct {
14981498 base: Node,
14991499 op_token: TokenIndex,
15001500 op: Op,
1501 rhs: &Node,
1501 rhs: *Node,
15021502
15031503 pub const Op = union(enum) {
1504 AddrOf: AddrOfInfo,
1505 ArrayType: &Node,
1504 AddressOf,
1505 ArrayType: *Node,
15061506 Await,
15071507 BitNot,
15081508 BoolNot,
15091509 Cancel,
1510 PointerType,
15111510 MaybeType,
15121511 Negation,
15131512 NegationWrap,
15141513 Resume,
1515 SliceType: AddrOfInfo,
1514 PtrType: PtrInfo,
1515 SliceType: PtrInfo,
15161516 Try,
15171517 UnwrapMaybe,
15181518 };
15191519
1520 pub const AddrOfInfo = struct {
1520 pub const PtrInfo = struct {
15211521 align_info: ?Align,
15221522 const_token: ?TokenIndex,
15231523 volatile_token: ?TokenIndex,
15241524
15251525 pub const Align = struct {
1526 node: &Node,
1526 node: *Node,
15271527 bit_range: ?BitRange,
15281528
15291529 pub const BitRange = struct {
1530 start: &Node,
1531 end: &Node,
1530 start: *Node,
1531 end: *Node,
15321532 };
15331533 };
15341534 };
15351535
1536 pub fn iterate(self: &PrefixOp, index: usize) ?&Node {
1536 pub fn iterate(self: *PrefixOp, index: usize) ?*Node {
15371537 var i = index;
15381538
15391539 switch (self.op) {
......@@ -1573,11 +1573,11 @@ pub const Node = struct {
15731573 return null;
15741574 }
15751575
1576 pub fn firstToken(self: &PrefixOp) TokenIndex {
1576 pub fn firstToken(self: *PrefixOp) TokenIndex {
15771577 return self.op_token;
15781578 }
15791579
1580 pub fn lastToken(self: &PrefixOp) TokenIndex {
1580 pub fn lastToken(self: *PrefixOp) TokenIndex {
15811581 return self.rhs.lastToken();
15821582 }
15831583 };
......@@ -1586,9 +1586,9 @@ pub const Node = struct {
15861586 base: Node,
15871587 period_token: TokenIndex,
15881588 name_token: TokenIndex,
1589 expr: &Node,
1589 expr: *Node,
15901590
1591 pub fn iterate(self: &FieldInitializer, index: usize) ?&Node {
1591 pub fn iterate(self: *FieldInitializer, index: usize) ?*Node {
15921592 var i = index;
15931593
15941594 if (i < 1) return self.expr;
......@@ -1597,45 +1597,45 @@ pub const Node = struct {
15971597 return null;
15981598 }
15991599
1600 pub fn firstToken(self: &FieldInitializer) TokenIndex {
1600 pub fn firstToken(self: *FieldInitializer) TokenIndex {
16011601 return self.period_token;
16021602 }
16031603
1604 pub fn lastToken(self: &FieldInitializer) TokenIndex {
1604 pub fn lastToken(self: *FieldInitializer) TokenIndex {
16051605 return self.expr.lastToken();
16061606 }
16071607 };
16081608
16091609 pub const SuffixOp = struct {
16101610 base: Node,
1611 lhs: &Node,
1611 lhs: *Node,
16121612 op: Op,
16131613 rtoken: TokenIndex,
16141614
16151615 pub const Op = union(enum) {
16161616 Call: Call,
1617 ArrayAccess: &Node,
1617 ArrayAccess: *Node,
16181618 Slice: Slice,
16191619 ArrayInitializer: InitList,
16201620 StructInitializer: InitList,
16211621 Deref,
16221622
1623 pub const InitList = SegmentedList(&Node, 2);
1623 pub const InitList = SegmentedList(*Node, 2);
16241624
16251625 pub const Call = struct {
16261626 params: ParamList,
1627 async_attr: ?&AsyncAttribute,
1627 async_attr: ?*AsyncAttribute,
16281628
1629 pub const ParamList = SegmentedList(&Node, 2);
1629 pub const ParamList = SegmentedList(*Node, 2);
16301630 };
16311631
16321632 pub const Slice = struct {
1633 start: &Node,
1634 end: ?&Node,
1633 start: *Node,
1634 end: ?*Node,
16351635 };
16361636 };
16371637
1638 pub fn iterate(self: &SuffixOp, index: usize) ?&Node {
1638 pub fn iterate(self: *SuffixOp, index: usize) ?*Node {
16391639 var i = index;
16401640
16411641 if (i < 1) return self.lhs;
......@@ -1673,7 +1673,7 @@ pub const Node = struct {
16731673 return null;
16741674 }
16751675
1676 pub fn firstToken(self: &SuffixOp) TokenIndex {
1676 pub fn firstToken(self: *SuffixOp) TokenIndex {
16771677 switch (self.op) {
16781678 @TagType(Op).Call => |*call_info| if (call_info.async_attr) |async_attr| return async_attr.firstToken(),
16791679 else => {},
......@@ -1681,7 +1681,7 @@ pub const Node = struct {
16811681 return self.lhs.firstToken();
16821682 }
16831683
1684 pub fn lastToken(self: &SuffixOp) TokenIndex {
1684 pub fn lastToken(self: *SuffixOp) TokenIndex {
16851685 return self.rtoken;
16861686 }
16871687 };
......@@ -1689,10 +1689,10 @@ pub const Node = struct {
16891689 pub const GroupedExpression = struct {
16901690 base: Node,
16911691 lparen: TokenIndex,
1692 expr: &Node,
1692 expr: *Node,
16931693 rparen: TokenIndex,
16941694
1695 pub fn iterate(self: &GroupedExpression, index: usize) ?&Node {
1695 pub fn iterate(self: *GroupedExpression, index: usize) ?*Node {
16961696 var i = index;
16971697
16981698 if (i < 1) return self.expr;
......@@ -1701,11 +1701,11 @@ pub const Node = struct {
17011701 return null;
17021702 }
17031703
1704 pub fn firstToken(self: &GroupedExpression) TokenIndex {
1704 pub fn firstToken(self: *GroupedExpression) TokenIndex {
17051705 return self.lparen;
17061706 }
17071707
1708 pub fn lastToken(self: &GroupedExpression) TokenIndex {
1708 pub fn lastToken(self: *GroupedExpression) TokenIndex {
17091709 return self.rparen;
17101710 }
17111711 };
......@@ -1714,15 +1714,15 @@ pub const Node = struct {
17141714 base: Node,
17151715 ltoken: TokenIndex,
17161716 kind: Kind,
1717 rhs: ?&Node,
1717 rhs: ?*Node,
17181718
17191719 const Kind = union(enum) {
1720 Break: ?&Node,
1721 Continue: ?&Node,
1720 Break: ?*Node,
1721 Continue: ?*Node,
17221722 Return,
17231723 };
17241724
1725 pub fn iterate(self: &ControlFlowExpression, index: usize) ?&Node {
1725 pub fn iterate(self: *ControlFlowExpression, index: usize) ?*Node {
17261726 var i = index;
17271727
17281728 switch (self.kind) {
......@@ -1749,11 +1749,11 @@ pub const Node = struct {
17491749 return null;
17501750 }
17511751
1752 pub fn firstToken(self: &ControlFlowExpression) TokenIndex {
1752 pub fn firstToken(self: *ControlFlowExpression) TokenIndex {
17531753 return self.ltoken;
17541754 }
17551755
1756 pub fn lastToken(self: &ControlFlowExpression) TokenIndex {
1756 pub fn lastToken(self: *ControlFlowExpression) TokenIndex {
17571757 if (self.rhs) |rhs| {
17581758 return rhs.lastToken();
17591759 }
......@@ -1780,10 +1780,10 @@ pub const Node = struct {
17801780 base: Node,
17811781 label: ?TokenIndex,
17821782 suspend_token: TokenIndex,
1783 payload: ?&Node,
1784 body: ?&Node,
1783 payload: ?*Node,
1784 body: ?*Node,
17851785
1786 pub fn iterate(self: &Suspend, index: usize) ?&Node {
1786 pub fn iterate(self: *Suspend, index: usize) ?*Node {
17871787 var i = index;
17881788
17891789 if (self.payload) |payload| {
......@@ -1799,12 +1799,12 @@ pub const Node = struct {
17991799 return null;
18001800 }
18011801
1802 pub fn firstToken(self: &Suspend) TokenIndex {
1802 pub fn firstToken(self: *Suspend) TokenIndex {
18031803 if (self.label) |label| return label;
18041804 return self.suspend_token;
18051805 }
18061806
1807 pub fn lastToken(self: &Suspend) TokenIndex {
1807 pub fn lastToken(self: *Suspend) TokenIndex {
18081808 if (self.body) |body| {
18091809 return body.lastToken();
18101810 }
......@@ -1821,15 +1821,15 @@ pub const Node = struct {
18211821 base: Node,
18221822 token: TokenIndex,
18231823
1824 pub fn iterate(self: &IntegerLiteral, index: usize) ?&Node {
1824 pub fn iterate(self: *IntegerLiteral, index: usize) ?*Node {
18251825 return null;
18261826 }
18271827
1828 pub fn firstToken(self: &IntegerLiteral) TokenIndex {
1828 pub fn firstToken(self: *IntegerLiteral) TokenIndex {
18291829 return self.token;
18301830 }
18311831
1832 pub fn lastToken(self: &IntegerLiteral) TokenIndex {
1832 pub fn lastToken(self: *IntegerLiteral) TokenIndex {
18331833 return self.token;
18341834 }
18351835 };
......@@ -1838,15 +1838,15 @@ pub const Node = struct {
18381838 base: Node,
18391839 token: TokenIndex,
18401840
1841 pub fn iterate(self: &FloatLiteral, index: usize) ?&Node {
1841 pub fn iterate(self: *FloatLiteral, index: usize) ?*Node {
18421842 return null;
18431843 }
18441844
1845 pub fn firstToken(self: &FloatLiteral) TokenIndex {
1845 pub fn firstToken(self: *FloatLiteral) TokenIndex {
18461846 return self.token;
18471847 }
18481848
1849 pub fn lastToken(self: &FloatLiteral) TokenIndex {
1849 pub fn lastToken(self: *FloatLiteral) TokenIndex {
18501850 return self.token;
18511851 }
18521852 };
......@@ -1857,9 +1857,9 @@ pub const Node = struct {
18571857 params: ParamList,
18581858 rparen_token: TokenIndex,
18591859
1860 pub const ParamList = SegmentedList(&Node, 2);
1860 pub const ParamList = SegmentedList(*Node, 2);
18611861
1862 pub fn iterate(self: &BuiltinCall, index: usize) ?&Node {
1862 pub fn iterate(self: *BuiltinCall, index: usize) ?*Node {
18631863 var i = index;
18641864
18651865 if (i < self.params.len) return self.params.at(i).*;
......@@ -1868,11 +1868,11 @@ pub const Node = struct {
18681868 return null;
18691869 }
18701870
1871 pub fn firstToken(self: &BuiltinCall) TokenIndex {
1871 pub fn firstToken(self: *BuiltinCall) TokenIndex {
18721872 return self.builtin_token;
18731873 }
18741874
1875 pub fn lastToken(self: &BuiltinCall) TokenIndex {
1875 pub fn lastToken(self: *BuiltinCall) TokenIndex {
18761876 return self.rparen_token;
18771877 }
18781878 };
......@@ -1881,15 +1881,15 @@ pub const Node = struct {
18811881 base: Node,
18821882 token: TokenIndex,
18831883
1884 pub fn iterate(self: &StringLiteral, index: usize) ?&Node {
1884 pub fn iterate(self: *StringLiteral, index: usize) ?*Node {
18851885 return null;
18861886 }
18871887
1888 pub fn firstToken(self: &StringLiteral) TokenIndex {
1888 pub fn firstToken(self: *StringLiteral) TokenIndex {
18891889 return self.token;
18901890 }
18911891
1892 pub fn lastToken(self: &StringLiteral) TokenIndex {
1892 pub fn lastToken(self: *StringLiteral) TokenIndex {
18931893 return self.token;
18941894 }
18951895 };
......@@ -1900,15 +1900,15 @@ pub const Node = struct {
19001900
19011901 pub const LineList = SegmentedList(TokenIndex, 4);
19021902
1903 pub fn iterate(self: &MultilineStringLiteral, index: usize) ?&Node {
1903 pub fn iterate(self: *MultilineStringLiteral, index: usize) ?*Node {
19041904 return null;
19051905 }
19061906
1907 pub fn firstToken(self: &MultilineStringLiteral) TokenIndex {
1907 pub fn firstToken(self: *MultilineStringLiteral) TokenIndex {
19081908 return self.lines.at(0).*;
19091909 }
19101910
1911 pub fn lastToken(self: &MultilineStringLiteral) TokenIndex {
1911 pub fn lastToken(self: *MultilineStringLiteral) TokenIndex {
19121912 return self.lines.at(self.lines.len - 1).*;
19131913 }
19141914 };
......@@ -1917,15 +1917,15 @@ pub const Node = struct {
19171917 base: Node,
19181918 token: TokenIndex,
19191919
1920 pub fn iterate(self: &CharLiteral, index: usize) ?&Node {
1920 pub fn iterate(self: *CharLiteral, index: usize) ?*Node {
19211921 return null;
19221922 }
19231923
1924 pub fn firstToken(self: &CharLiteral) TokenIndex {
1924 pub fn firstToken(self: *CharLiteral) TokenIndex {
19251925 return self.token;
19261926 }
19271927
1928 pub fn lastToken(self: &CharLiteral) TokenIndex {
1928 pub fn lastToken(self: *CharLiteral) TokenIndex {
19291929 return self.token;
19301930 }
19311931 };
......@@ -1934,15 +1934,15 @@ pub const Node = struct {
19341934 base: Node,
19351935 token: TokenIndex,
19361936
1937 pub fn iterate(self: &BoolLiteral, index: usize) ?&Node {
1937 pub fn iterate(self: *BoolLiteral, index: usize) ?*Node {
19381938 return null;
19391939 }
19401940
1941 pub fn firstToken(self: &BoolLiteral) TokenIndex {
1941 pub fn firstToken(self: *BoolLiteral) TokenIndex {
19421942 return self.token;
19431943 }
19441944
1945 pub fn lastToken(self: &BoolLiteral) TokenIndex {
1945 pub fn lastToken(self: *BoolLiteral) TokenIndex {
19461946 return self.token;
19471947 }
19481948 };
......@@ -1951,15 +1951,15 @@ pub const Node = struct {
19511951 base: Node,
19521952 token: TokenIndex,
19531953
1954 pub fn iterate(self: &NullLiteral, index: usize) ?&Node {
1954 pub fn iterate(self: *NullLiteral, index: usize) ?*Node {
19551955 return null;
19561956 }
19571957
1958 pub fn firstToken(self: &NullLiteral) TokenIndex {
1958 pub fn firstToken(self: *NullLiteral) TokenIndex {
19591959 return self.token;
19601960 }
19611961
1962 pub fn lastToken(self: &NullLiteral) TokenIndex {
1962 pub fn lastToken(self: *NullLiteral) TokenIndex {
19631963 return self.token;
19641964 }
19651965 };
......@@ -1968,15 +1968,15 @@ pub const Node = struct {
19681968 base: Node,
19691969 token: TokenIndex,
19701970
1971 pub fn iterate(self: &UndefinedLiteral, index: usize) ?&Node {
1971 pub fn iterate(self: *UndefinedLiteral, index: usize) ?*Node {
19721972 return null;
19731973 }
19741974
1975 pub fn firstToken(self: &UndefinedLiteral) TokenIndex {
1975 pub fn firstToken(self: *UndefinedLiteral) TokenIndex {
19761976 return self.token;
19771977 }
19781978
1979 pub fn lastToken(self: &UndefinedLiteral) TokenIndex {
1979 pub fn lastToken(self: *UndefinedLiteral) TokenIndex {
19801980 return self.token;
19811981 }
19821982 };
......@@ -1985,15 +1985,15 @@ pub const Node = struct {
19851985 base: Node,
19861986 token: TokenIndex,
19871987
1988 pub fn iterate(self: &ThisLiteral, index: usize) ?&Node {
1988 pub fn iterate(self: *ThisLiteral, index: usize) ?*Node {
19891989 return null;
19901990 }
19911991
1992 pub fn firstToken(self: &ThisLiteral) TokenIndex {
1992 pub fn firstToken(self: *ThisLiteral) TokenIndex {
19931993 return self.token;
19941994 }
19951995
1996 pub fn lastToken(self: &ThisLiteral) TokenIndex {
1996 pub fn lastToken(self: *ThisLiteral) TokenIndex {
19971997 return self.token;
19981998 }
19991999 };
......@@ -2001,17 +2001,17 @@ pub const Node = struct {
20012001 pub const AsmOutput = struct {
20022002 base: Node,
20032003 lbracket: TokenIndex,
2004 symbolic_name: &Node,
2005 constraint: &Node,
2004 symbolic_name: *Node,
2005 constraint: *Node,
20062006 kind: Kind,
20072007 rparen: TokenIndex,
20082008
20092009 const Kind = union(enum) {
2010 Variable: &Identifier,
2011 Return: &Node,
2010 Variable: *Identifier,
2011 Return: *Node,
20122012 };
20132013
2014 pub fn iterate(self: &AsmOutput, index: usize) ?&Node {
2014 pub fn iterate(self: *AsmOutput, index: usize) ?*Node {
20152015 var i = index;
20162016
20172017 if (i < 1) return self.symbolic_name;
......@@ -2022,7 +2022,7 @@ pub const Node = struct {
20222022
20232023 switch (self.kind) {
20242024 Kind.Variable => |variable_name| {
2025 if (i < 1) return &variable_name.base;
2025 if (i < 1) return *variable_name.base;
20262026 i -= 1;
20272027 },
20282028 Kind.Return => |return_type| {
......@@ -2034,11 +2034,11 @@ pub const Node = struct {
20342034 return null;
20352035 }
20362036
2037 pub fn firstToken(self: &AsmOutput) TokenIndex {
2037 pub fn firstToken(self: *AsmOutput) TokenIndex {
20382038 return self.lbracket;
20392039 }
20402040
2041 pub fn lastToken(self: &AsmOutput) TokenIndex {
2041 pub fn lastToken(self: *AsmOutput) TokenIndex {
20422042 return self.rparen;
20432043 }
20442044 };
......@@ -2046,12 +2046,12 @@ pub const Node = struct {
20462046 pub const AsmInput = struct {
20472047 base: Node,
20482048 lbracket: TokenIndex,
2049 symbolic_name: &Node,
2050 constraint: &Node,
2051 expr: &Node,
2049 symbolic_name: *Node,
2050 constraint: *Node,
2051 expr: *Node,
20522052 rparen: TokenIndex,
20532053
2054 pub fn iterate(self: &AsmInput, index: usize) ?&Node {
2054 pub fn iterate(self: *AsmInput, index: usize) ?*Node {
20552055 var i = index;
20562056
20572057 if (i < 1) return self.symbolic_name;
......@@ -2066,11 +2066,11 @@ pub const Node = struct {
20662066 return null;
20672067 }
20682068
2069 pub fn firstToken(self: &AsmInput) TokenIndex {
2069 pub fn firstToken(self: *AsmInput) TokenIndex {
20702070 return self.lbracket;
20712071 }
20722072
2073 pub fn lastToken(self: &AsmInput) TokenIndex {
2073 pub fn lastToken(self: *AsmInput) TokenIndex {
20742074 return self.rparen;
20752075 }
20762076 };
......@@ -2079,33 +2079,33 @@ pub const Node = struct {
20792079 base: Node,
20802080 asm_token: TokenIndex,
20812081 volatile_token: ?TokenIndex,
2082 template: &Node,
2082 template: *Node,
20832083 outputs: OutputList,
20842084 inputs: InputList,
20852085 clobbers: ClobberList,
20862086 rparen: TokenIndex,
20872087
2088 const OutputList = SegmentedList(&AsmOutput, 2);
2089 const InputList = SegmentedList(&AsmInput, 2);
2088 const OutputList = SegmentedList(*AsmOutput, 2);
2089 const InputList = SegmentedList(*AsmInput, 2);
20902090 const ClobberList = SegmentedList(TokenIndex, 2);
20912091
2092 pub fn iterate(self: &Asm, index: usize) ?&Node {
2092 pub fn iterate(self: *Asm, index: usize) ?*Node {
20932093 var i = index;
20942094
2095 if (i < self.outputs.len) return &(self.outputs.at(index).*).base;
2095 if (i < self.outputs.len) return *(self.outputs.at(index).*).base;
20962096 i -= self.outputs.len;
20972097
2098 if (i < self.inputs.len) return &(self.inputs.at(index).*).base;
2098 if (i < self.inputs.len) return *(self.inputs.at(index).*).base;
20992099 i -= self.inputs.len;
21002100
21012101 return null;
21022102 }
21032103
2104 pub fn firstToken(self: &Asm) TokenIndex {
2104 pub fn firstToken(self: *Asm) TokenIndex {
21052105 return self.asm_token;
21062106 }
21072107
2108 pub fn lastToken(self: &Asm) TokenIndex {
2108 pub fn lastToken(self: *Asm) TokenIndex {
21092109 return self.rparen;
21102110 }
21112111 };
......@@ -2114,15 +2114,15 @@ pub const Node = struct {
21142114 base: Node,
21152115 token: TokenIndex,
21162116
2117 pub fn iterate(self: &Unreachable, index: usize) ?&Node {
2117 pub fn iterate(self: *Unreachable, index: usize) ?*Node {
21182118 return null;
21192119 }
21202120
2121 pub fn firstToken(self: &Unreachable) TokenIndex {
2121 pub fn firstToken(self: *Unreachable) TokenIndex {
21222122 return self.token;
21232123 }
21242124
2125 pub fn lastToken(self: &Unreachable) TokenIndex {
2125 pub fn lastToken(self: *Unreachable) TokenIndex {
21262126 return self.token;
21272127 }
21282128 };
......@@ -2131,15 +2131,15 @@ pub const Node = struct {
21312131 base: Node,
21322132 token: TokenIndex,
21332133
2134 pub fn iterate(self: &ErrorType, index: usize) ?&Node {
2134 pub fn iterate(self: *ErrorType, index: usize) ?*Node {
21352135 return null;
21362136 }
21372137
2138 pub fn firstToken(self: &ErrorType) TokenIndex {
2138 pub fn firstToken(self: *ErrorType) TokenIndex {
21392139 return self.token;
21402140 }
21412141
2142 pub fn lastToken(self: &ErrorType) TokenIndex {
2142 pub fn lastToken(self: *ErrorType) TokenIndex {
21432143 return self.token;
21442144 }
21452145 };
......@@ -2148,15 +2148,15 @@ pub const Node = struct {
21482148 base: Node,
21492149 token: TokenIndex,
21502150
2151 pub fn iterate(self: &VarType, index: usize) ?&Node {
2151 pub fn iterate(self: *VarType, index: usize) ?*Node {
21522152 return null;
21532153 }
21542154
2155 pub fn firstToken(self: &VarType) TokenIndex {
2155 pub fn firstToken(self: *VarType) TokenIndex {
21562156 return self.token;
21572157 }
21582158
2159 pub fn lastToken(self: &VarType) TokenIndex {
2159 pub fn lastToken(self: *VarType) TokenIndex {
21602160 return self.token;
21612161 }
21622162 };
......@@ -2167,27 +2167,27 @@ pub const Node = struct {
21672167
21682168 pub const LineList = SegmentedList(TokenIndex, 4);
21692169
2170 pub fn iterate(self: &DocComment, index: usize) ?&Node {
2170 pub fn iterate(self: *DocComment, index: usize) ?*Node {
21712171 return null;
21722172 }
21732173
2174 pub fn firstToken(self: &DocComment) TokenIndex {
2174 pub fn firstToken(self: *DocComment) TokenIndex {
21752175 return self.lines.at(0).*;
21762176 }
21772177
2178 pub fn lastToken(self: &DocComment) TokenIndex {
2178 pub fn lastToken(self: *DocComment) TokenIndex {
21792179 return self.lines.at(self.lines.len - 1).*;
21802180 }
21812181 };
21822182
21832183 pub const TestDecl = struct {
21842184 base: Node,
2185 doc_comments: ?&DocComment,
2185 doc_comments: ?*DocComment,
21862186 test_token: TokenIndex,
2187 name: &Node,
2188 body_node: &Node,
2187 name: *Node,
2188 body_node: *Node,
21892189
2190 pub fn iterate(self: &TestDecl, index: usize) ?&Node {
2190 pub fn iterate(self: *TestDecl, index: usize) ?*Node {
21912191 var i = index;
21922192
21932193 if (i < 1) return self.body_node;
......@@ -2196,11 +2196,11 @@ pub const Node = struct {
21962196 return null;
21972197 }
21982198
2199 pub fn firstToken(self: &TestDecl) TokenIndex {
2199 pub fn firstToken(self: *TestDecl) TokenIndex {
22002200 return self.test_token;
22012201 }
22022202
2203 pub fn lastToken(self: &TestDecl) TokenIndex {
2203 pub fn lastToken(self: *TestDecl) TokenIndex {
22042204 return self.body_node.lastToken();
22052205 }
22062206 };
std/zig/bench.zig+3-3
......@@ -24,15 +24,15 @@ pub fn main() !void {
2424 const mb_per_sec = bytes_per_sec / (1024 * 1024);
2525
2626 var stdout_file = try std.io.getStdOut();
27 const stdout = &std.io.FileOutStream.init(&stdout_file).stream;
27 const stdout = *std.io.FileOutStream.init(*stdout_file).stream;
2828 try stdout.print("{.3} MB/s, {} KB used \n", mb_per_sec, memory_used / 1024);
2929}
3030
3131fn testOnce() usize {
3232 var fixed_buf_alloc = std.heap.FixedBufferAllocator.init(fixed_buffer_mem[0..]);
33 var allocator = &fixed_buf_alloc.allocator;
33 var allocator = *fixed_buf_alloc.allocator;
3434 var tokenizer = Tokenizer.init(source);
35 var parser = Parser.init(&tokenizer, allocator, "(memory buffer)");
35 var parser = Parser.init(*tokenizer, allocator, "(memory buffer)");
3636 _ = parser.parse() catch @panic("parse failure");
3737 return fixed_buf_alloc.end_index;
3838}
std/zig/parse.zig+89-89
......@@ -9,7 +9,7 @@ const Error = ast.Error;
99
1010/// Result should be freed with tree.deinit() when there are
1111/// no more references to any of the tokens or nodes.
12pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
12pub fn parse(allocator: *mem.Allocator, source: []const u8) !ast.Tree {
1313 var tree_arena = std.heap.ArenaAllocator.init(allocator);
1414 errdefer tree_arena.deinit();
1515
......@@ -1533,14 +1533,14 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
15331533 State.SliceOrArrayType => |node| {
15341534 if (eatToken(&tok_it, &tree, Token.Id.RBracket)) |_| {
15351535 node.op = ast.Node.PrefixOp.Op{
1536 .SliceType = ast.Node.PrefixOp.AddrOfInfo{
1536 .SliceType = ast.Node.PrefixOp.PtrInfo{
15371537 .align_info = null,
15381538 .const_token = null,
15391539 .volatile_token = null,
15401540 },
15411541 };
15421542 stack.append(State{ .TypeExprBegin = OptionalCtx{ .Required = &node.rhs } }) catch unreachable;
1543 try stack.append(State{ .AddrOfModifiers = &node.op.SliceType });
1543 try stack.append(State{ .PtrTypeModifiers = &node.op.SliceType });
15441544 continue;
15451545 }
15461546
......@@ -1551,7 +1551,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
15511551 continue;
15521552 },
15531553
1554 State.AddrOfModifiers => |addr_of_info| {
1554 State.PtrTypeModifiers => |addr_of_info| {
15551555 const token = nextToken(&tok_it, &tree);
15561556 const token_index = token.index;
15571557 const token_ptr = token.ptr;
......@@ -1562,7 +1562,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
15621562 ((try tree.errors.addOne())).* = Error{ .ExtraAlignQualifier = Error.ExtraAlignQualifier{ .token = token_index } };
15631563 return tree;
15641564 }
1565 addr_of_info.align_info = ast.Node.PrefixOp.AddrOfInfo.Align{
1565 addr_of_info.align_info = ast.Node.PrefixOp.PtrInfo.Align{
15661566 .node = undefined,
15671567 .bit_range = null,
15681568 };
......@@ -1603,7 +1603,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
16031603 const token = nextToken(&tok_it, &tree);
16041604 switch (token.ptr.id) {
16051605 Token.Id.Colon => {
1606 align_info.bit_range = ast.Node.PrefixOp.AddrOfInfo.Align.BitRange(undefined);
1606 align_info.bit_range = ast.Node.PrefixOp.PtrInfo.Align.BitRange(undefined);
16071607 const bit_range = &??align_info.bit_range;
16081608
16091609 try stack.append(State{ .ExpectToken = Token.Id.RParen });
......@@ -2220,7 +2220,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
22202220 });
22212221 opt_ctx.store(&node.base);
22222222
2223 // Treat '**' token as two derefs
2223 // Treat '**' token as two pointer types
22242224 if (token_ptr.id == Token.Id.AsteriskAsterisk) {
22252225 const child = try arena.construct(ast.Node.PrefixOp{
22262226 .base = ast.Node{ .id = ast.Node.Id.PrefixOp },
......@@ -2233,8 +2233,8 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
22332233 }
22342234
22352235 stack.append(State{ .TypeExprBegin = OptionalCtx{ .Required = &node.rhs } }) catch unreachable;
2236 if (node.op == ast.Node.PrefixOp.Op.AddrOf) {
2237 try stack.append(State{ .AddrOfModifiers = &node.op.AddrOf });
2236 if (node.op == ast.Node.PrefixOp.Op.PtrType) {
2237 try stack.append(State{ .PtrTypeModifiers = &node.op.PtrType });
22382238 }
22392239 continue;
22402240 } else {
......@@ -2754,16 +2754,16 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
27542754}
27552755
27562756const AnnotatedToken = struct {
2757 ptr: &Token,
2757 ptr: *Token,
27582758 index: TokenIndex,
27592759};
27602760
27612761const TopLevelDeclCtx = struct {
2762 decls: &ast.Node.Root.DeclList,
2762 decls: *ast.Node.Root.DeclList,
27632763 visib_token: ?TokenIndex,
27642764 extern_export_inline_token: ?AnnotatedToken,
2765 lib_name: ?&ast.Node,
2766 comments: ?&ast.Node.DocComment,
2765 lib_name: ?*ast.Node,
2766 comments: ?*ast.Node.DocComment,
27672767};
27682768
27692769const VarDeclCtx = struct {
......@@ -2771,21 +2771,21 @@ const VarDeclCtx = struct {
27712771 visib_token: ?TokenIndex,
27722772 comptime_token: ?TokenIndex,
27732773 extern_export_token: ?TokenIndex,
2774 lib_name: ?&ast.Node,
2775 list: &ast.Node.Root.DeclList,
2776 comments: ?&ast.Node.DocComment,
2774 lib_name: ?*ast.Node,
2775 list: *ast.Node.Root.DeclList,
2776 comments: ?*ast.Node.DocComment,
27772777};
27782778
27792779const TopLevelExternOrFieldCtx = struct {
27802780 visib_token: TokenIndex,
2781 container_decl: &ast.Node.ContainerDecl,
2782 comments: ?&ast.Node.DocComment,
2781 container_decl: *ast.Node.ContainerDecl,
2782 comments: ?*ast.Node.DocComment,
27832783};
27842784
27852785const ExternTypeCtx = struct {
27862786 opt_ctx: OptionalCtx,
27872787 extern_token: TokenIndex,
2788 comments: ?&ast.Node.DocComment,
2788 comments: ?*ast.Node.DocComment,
27892789};
27902790
27912791const ContainerKindCtx = struct {
......@@ -2795,24 +2795,24 @@ const ContainerKindCtx = struct {
27952795
27962796const ExpectTokenSave = struct {
27972797 id: @TagType(Token.Id),
2798 ptr: &TokenIndex,
2798 ptr: *TokenIndex,
27992799};
28002800
28012801const OptionalTokenSave = struct {
28022802 id: @TagType(Token.Id),
2803 ptr: &?TokenIndex,
2803 ptr: *?TokenIndex,
28042804};
28052805
28062806const ExprListCtx = struct {
2807 list: &ast.Node.SuffixOp.Op.InitList,
2807 list: *ast.Node.SuffixOp.Op.InitList,
28082808 end: Token.Id,
2809 ptr: &TokenIndex,
2809 ptr: *TokenIndex,
28102810};
28112811
28122812fn ListSave(comptime List: type) type {
28132813 return struct {
2814 list: &List,
2815 ptr: &TokenIndex,
2814 list: *List,
2815 ptr: *TokenIndex,
28162816 };
28172817}
28182818
......@@ -2841,7 +2841,7 @@ const LoopCtx = struct {
28412841
28422842const AsyncEndCtx = struct {
28432843 ctx: OptionalCtx,
2844 attribute: &ast.Node.AsyncAttribute,
2844 attribute: *ast.Node.AsyncAttribute,
28452845};
28462846
28472847const ErrorTypeOrSetDeclCtx = struct {
......@@ -2850,21 +2850,21 @@ const ErrorTypeOrSetDeclCtx = struct {
28502850};
28512851
28522852const ParamDeclEndCtx = struct {
2853 fn_proto: &ast.Node.FnProto,
2854 param_decl: &ast.Node.ParamDecl,
2853 fn_proto: *ast.Node.FnProto,
2854 param_decl: *ast.Node.ParamDecl,
28552855};
28562856
28572857const ComptimeStatementCtx = struct {
28582858 comptime_token: TokenIndex,
2859 block: &ast.Node.Block,
2859 block: *ast.Node.Block,
28602860};
28612861
28622862const OptionalCtx = union(enum) {
2863 Optional: &?&ast.Node,
2864 RequiredNull: &?&ast.Node,
2865 Required: &&ast.Node,
2863 Optional: *?*ast.Node,
2864 RequiredNull: *?*ast.Node,
2865 Required: **ast.Node,
28662866
2867 pub fn store(self: &const OptionalCtx, value: &ast.Node) void {
2867 pub fn store(self: *const OptionalCtx, value: *ast.Node) void {
28682868 switch (self.*) {
28692869 OptionalCtx.Optional => |ptr| ptr.* = value,
28702870 OptionalCtx.RequiredNull => |ptr| ptr.* = value,
......@@ -2872,7 +2872,7 @@ const OptionalCtx = union(enum) {
28722872 }
28732873 }
28742874
2875 pub fn get(self: &const OptionalCtx) ?&ast.Node {
2875 pub fn get(self: *const OptionalCtx) ?*ast.Node {
28762876 switch (self.*) {
28772877 OptionalCtx.Optional => |ptr| return ptr.*,
28782878 OptionalCtx.RequiredNull => |ptr| return ??ptr.*,
......@@ -2880,7 +2880,7 @@ const OptionalCtx = union(enum) {
28802880 }
28812881 }
28822882
2883 pub fn toRequired(self: &const OptionalCtx) OptionalCtx {
2883 pub fn toRequired(self: *const OptionalCtx) OptionalCtx {
28842884 switch (self.*) {
28852885 OptionalCtx.Optional => |ptr| {
28862886 return OptionalCtx{ .RequiredNull = ptr };
......@@ -2892,8 +2892,8 @@ const OptionalCtx = union(enum) {
28922892};
28932893
28942894const AddCommentsCtx = struct {
2895 node_ptr: &&ast.Node,
2896 comments: ?&ast.Node.DocComment,
2895 node_ptr: **ast.Node,
2896 comments: ?*ast.Node.DocComment,
28972897};
28982898
28992899const State = union(enum) {
......@@ -2904,67 +2904,67 @@ const State = union(enum) {
29042904 TopLevelExternOrField: TopLevelExternOrFieldCtx,
29052905
29062906 ContainerKind: ContainerKindCtx,
2907 ContainerInitArgStart: &ast.Node.ContainerDecl,
2908 ContainerInitArg: &ast.Node.ContainerDecl,
2909 ContainerDecl: &ast.Node.ContainerDecl,
2907 ContainerInitArgStart: *ast.Node.ContainerDecl,
2908 ContainerInitArg: *ast.Node.ContainerDecl,
2909 ContainerDecl: *ast.Node.ContainerDecl,
29102910
29112911 VarDecl: VarDeclCtx,
2912 VarDeclAlign: &ast.Node.VarDecl,
2913 VarDeclEq: &ast.Node.VarDecl,
2914 VarDeclSemiColon: &ast.Node.VarDecl,
2915
2916 FnDef: &ast.Node.FnProto,
2917 FnProto: &ast.Node.FnProto,
2918 FnProtoAlign: &ast.Node.FnProto,
2919 FnProtoReturnType: &ast.Node.FnProto,
2920
2921 ParamDecl: &ast.Node.FnProto,
2922 ParamDeclAliasOrComptime: &ast.Node.ParamDecl,
2923 ParamDeclName: &ast.Node.ParamDecl,
2912 VarDeclAlign: *ast.Node.VarDecl,
2913 VarDeclEq: *ast.Node.VarDecl,
2914 VarDeclSemiColon: *ast.Node.VarDecl,
2915
2916 FnDef: *ast.Node.FnProto,
2917 FnProto: *ast.Node.FnProto,
2918 FnProtoAlign: *ast.Node.FnProto,
2919 FnProtoReturnType: *ast.Node.FnProto,
2920
2921 ParamDecl: *ast.Node.FnProto,
2922 ParamDeclAliasOrComptime: *ast.Node.ParamDecl,
2923 ParamDeclName: *ast.Node.ParamDecl,
29242924 ParamDeclEnd: ParamDeclEndCtx,
2925 ParamDeclComma: &ast.Node.FnProto,
2925 ParamDeclComma: *ast.Node.FnProto,
29262926
29272927 MaybeLabeledExpression: MaybeLabeledExpressionCtx,
29282928 LabeledExpression: LabelCtx,
29292929 Inline: InlineCtx,
29302930 While: LoopCtx,
2931 WhileContinueExpr: &?&ast.Node,
2931 WhileContinueExpr: *?*ast.Node,
29322932 For: LoopCtx,
2933 Else: &?&ast.Node.Else,
2933 Else: *?*ast.Node.Else,
29342934
2935 Block: &ast.Node.Block,
2936 Statement: &ast.Node.Block,
2935 Block: *ast.Node.Block,
2936 Statement: *ast.Node.Block,
29372937 ComptimeStatement: ComptimeStatementCtx,
2938 Semicolon: &&ast.Node,
2938 Semicolon: **ast.Node,
29392939
2940 AsmOutputItems: &ast.Node.Asm.OutputList,
2941 AsmOutputReturnOrType: &ast.Node.AsmOutput,
2942 AsmInputItems: &ast.Node.Asm.InputList,
2943 AsmClobberItems: &ast.Node.Asm.ClobberList,
2940 AsmOutputItems: *ast.Node.Asm.OutputList,
2941 AsmOutputReturnOrType: *ast.Node.AsmOutput,
2942 AsmInputItems: *ast.Node.Asm.InputList,
2943 AsmClobberItems: *ast.Node.Asm.ClobberList,
29442944
29452945 ExprListItemOrEnd: ExprListCtx,
29462946 ExprListCommaOrEnd: ExprListCtx,
29472947 FieldInitListItemOrEnd: ListSave(ast.Node.SuffixOp.Op.InitList),
29482948 FieldInitListCommaOrEnd: ListSave(ast.Node.SuffixOp.Op.InitList),
2949 FieldListCommaOrEnd: &ast.Node.ContainerDecl,
2949 FieldListCommaOrEnd: *ast.Node.ContainerDecl,
29502950 FieldInitValue: OptionalCtx,
29512951 ErrorTagListItemOrEnd: ListSave(ast.Node.ErrorSetDecl.DeclList),
29522952 ErrorTagListCommaOrEnd: ListSave(ast.Node.ErrorSetDecl.DeclList),
29532953 SwitchCaseOrEnd: ListSave(ast.Node.Switch.CaseList),
29542954 SwitchCaseCommaOrEnd: ListSave(ast.Node.Switch.CaseList),
2955 SwitchCaseFirstItem: &ast.Node.SwitchCase,
2956 SwitchCaseItemCommaOrEnd: &ast.Node.SwitchCase,
2957 SwitchCaseItemOrEnd: &ast.Node.SwitchCase,
2955 SwitchCaseFirstItem: *ast.Node.SwitchCase,
2956 SwitchCaseItemCommaOrEnd: *ast.Node.SwitchCase,
2957 SwitchCaseItemOrEnd: *ast.Node.SwitchCase,
29582958
2959 SuspendBody: &ast.Node.Suspend,
2960 AsyncAllocator: &ast.Node.AsyncAttribute,
2959 SuspendBody: *ast.Node.Suspend,
2960 AsyncAllocator: *ast.Node.AsyncAttribute,
29612961 AsyncEnd: AsyncEndCtx,
29622962
29632963 ExternType: ExternTypeCtx,
2964 SliceOrArrayAccess: &ast.Node.SuffixOp,
2965 SliceOrArrayType: &ast.Node.PrefixOp,
2966 AddrOfModifiers: &ast.Node.PrefixOp.AddrOfInfo,
2967 AlignBitRange: &ast.Node.PrefixOp.AddrOfInfo.Align,
2964 SliceOrArrayAccess: *ast.Node.SuffixOp,
2965 SliceOrArrayType: *ast.Node.PrefixOp,
2966 PtrTypeModifiers: *ast.Node.PrefixOp.PtrInfo,
2967 AlignBitRange: *ast.Node.PrefixOp.PtrInfo.Align,
29682968
29692969 Payload: OptionalCtx,
29702970 PointerPayload: OptionalCtx,
......@@ -3007,7 +3007,7 @@ const State = union(enum) {
30073007 ErrorTypeOrSetDecl: ErrorTypeOrSetDeclCtx,
30083008 StringLiteral: OptionalCtx,
30093009 Identifier: OptionalCtx,
3010 ErrorTag: &&ast.Node,
3010 ErrorTag: **ast.Node,
30113011
30123012 IfToken: @TagType(Token.Id),
30133013 IfTokenSave: ExpectTokenSave,
......@@ -3016,7 +3016,7 @@ const State = union(enum) {
30163016 OptionalTokenSave: OptionalTokenSave,
30173017};
30183018
3019fn pushDocComment(arena: &mem.Allocator, line_comment: TokenIndex, result: &?&ast.Node.DocComment) !void {
3019fn pushDocComment(arena: *mem.Allocator, line_comment: TokenIndex, result: *?*ast.Node.DocComment) !void {
30203020 const node = blk: {
30213021 if (result.*) |comment_node| {
30223022 break :blk comment_node;
......@@ -3032,8 +3032,8 @@ fn pushDocComment(arena: &mem.Allocator, line_comment: TokenIndex, result: &?&as
30323032 try node.lines.push(line_comment);
30333033}
30343034
3035fn eatDocComments(arena: &mem.Allocator, tok_it: &ast.Tree.TokenList.Iterator, tree: &ast.Tree) !?&ast.Node.DocComment {
3036 var result: ?&ast.Node.DocComment = null;
3035fn eatDocComments(arena: *mem.Allocator, tok_it: *ast.Tree.TokenList.Iterator, tree: *ast.Tree) !?*ast.Node.DocComment {
3036 var result: ?*ast.Node.DocComment = null;
30373037 while (true) {
30383038 if (eatToken(tok_it, tree, Token.Id.DocComment)) |line_comment| {
30393039 try pushDocComment(arena, line_comment, &result);
......@@ -3044,7 +3044,7 @@ fn eatDocComments(arena: &mem.Allocator, tok_it: &ast.Tree.TokenList.Iterator, t
30443044 return result;
30453045}
30463046
3047fn parseStringLiteral(arena: &mem.Allocator, tok_it: &ast.Tree.TokenList.Iterator, token_ptr: &const Token, token_index: TokenIndex, tree: &ast.Tree) !?&ast.Node {
3047fn parseStringLiteral(arena: *mem.Allocator, tok_it: *ast.Tree.TokenList.Iterator, token_ptr: *const Token, token_index: TokenIndex, tree: *ast.Tree) !?*ast.Node {
30483048 switch (token_ptr.id) {
30493049 Token.Id.StringLiteral => {
30503050 return &(try createLiteral(arena, ast.Node.StringLiteral, token_index)).base;
......@@ -3071,11 +3071,11 @@ fn parseStringLiteral(arena: &mem.Allocator, tok_it: &ast.Tree.TokenList.Iterato
30713071 },
30723072 // TODO: We shouldn't need a cast, but:
30733073 // zig: /home/jc/Documents/zig/src/ir.cpp:7962: TypeTableEntry* ir_resolve_peer_types(IrAnalyze*, AstNode*, IrInstruction**, size_t): Assertion `err_set_type != nullptr' failed.
3074 else => return (?&ast.Node)(null),
3074 else => return (?*ast.Node)(null),
30753075 }
30763076}
30773077
3078fn parseBlockExpr(stack: &std.ArrayList(State), arena: &mem.Allocator, ctx: &const OptionalCtx, token_ptr: &const Token, token_index: TokenIndex) !bool {
3078fn parseBlockExpr(stack: *std.ArrayList(State), arena: *mem.Allocator, ctx: *const OptionalCtx, token_ptr: *const Token, token_index: TokenIndex) !bool {
30793079 switch (token_ptr.id) {
30803080 Token.Id.Keyword_suspend => {
30813081 const node = try arena.construct(ast.Node.Suspend{
......@@ -3189,7 +3189,7 @@ const ExpectCommaOrEndResult = union(enum) {
31893189 parse_error: Error,
31903190};
31913191
3192fn expectCommaOrEnd(tok_it: &ast.Tree.TokenList.Iterator, tree: &ast.Tree, end: @TagType(Token.Id)) ExpectCommaOrEndResult {
3192fn expectCommaOrEnd(tok_it: *ast.Tree.TokenList.Iterator, tree: *ast.Tree, end: @TagType(Token.Id)) ExpectCommaOrEndResult {
31933193 const token = nextToken(tok_it, tree);
31943194 const token_index = token.index;
31953195 const token_ptr = token.ptr;
......@@ -3212,7 +3212,7 @@ fn expectCommaOrEnd(tok_it: &ast.Tree.TokenList.Iterator, tree: &ast.Tree, end:
32123212 }
32133213}
32143214
3215fn tokenIdToAssignment(id: &const Token.Id) ?ast.Node.InfixOp.Op {
3215fn tokenIdToAssignment(id: *const Token.Id) ?ast.Node.InfixOp.Op {
32163216 // TODO: We have to cast all cases because of this:
32173217 // error: expected type '?InfixOp', found '?@TagType(InfixOp)'
32183218 return switch (id.*) {
......@@ -3291,9 +3291,9 @@ fn tokenIdToPrefixOp(id: @TagType(Token.Id)) ?ast.Node.PrefixOp.Op {
32913291 Token.Id.Tilde => ast.Node.PrefixOp.Op{ .BitNot = void{} },
32923292 Token.Id.Minus => ast.Node.PrefixOp.Op{ .Negation = void{} },
32933293 Token.Id.MinusPercent => ast.Node.PrefixOp.Op{ .NegationWrap = void{} },
3294 Token.Id.Asterisk, Token.Id.AsteriskAsterisk => ast.Node.PrefixOp.Op{ .PointerType = void{} },
3295 Token.Id.Ampersand => ast.Node.PrefixOp.Op{
3296 .AddrOf = ast.Node.PrefixOp.AddrOfInfo{
3294 Token.Id.Ampersand => ast.Node.PrefixOp.Op{ .AddressOf = void{} },
3295 Token.Id.Asterisk, Token.Id.AsteriskAsterisk => ast.Node.PrefixOp.Op{
3296 .PtrType = ast.Node.PrefixOp.PtrInfo{
32973297 .align_info = null,
32983298 .const_token = null,
32993299 .volatile_token = null,
......@@ -3307,21 +3307,21 @@ fn tokenIdToPrefixOp(id: @TagType(Token.Id)) ?ast.Node.PrefixOp.Op {
33073307 };
33083308}
33093309
3310fn createLiteral(arena: &mem.Allocator, comptime T: type, token_index: TokenIndex) !&T {
3310fn createLiteral(arena: *mem.Allocator, comptime T: type, token_index: TokenIndex) !*T {
33113311 return arena.construct(T{
33123312 .base = ast.Node{ .id = ast.Node.typeToId(T) },
33133313 .token = token_index,
33143314 });
33153315}
33163316
3317fn createToCtxLiteral(arena: &mem.Allocator, opt_ctx: &const OptionalCtx, comptime T: type, token_index: TokenIndex) !&T {
3317fn createToCtxLiteral(arena: *mem.Allocator, opt_ctx: *const OptionalCtx, comptime T: type, token_index: TokenIndex) !*T {
33183318 const node = try createLiteral(arena, T, token_index);
33193319 opt_ctx.store(&node.base);
33203320
33213321 return node;
33223322}
33233323
3324fn eatToken(tok_it: &ast.Tree.TokenList.Iterator, tree: &ast.Tree, id: @TagType(Token.Id)) ?TokenIndex {
3324fn eatToken(tok_it: *ast.Tree.TokenList.Iterator, tree: *ast.Tree, id: @TagType(Token.Id)) ?TokenIndex {
33253325 const token = ??tok_it.peek();
33263326
33273327 if (token.id == id) {
......@@ -3331,7 +3331,7 @@ fn eatToken(tok_it: &ast.Tree.TokenList.Iterator, tree: &ast.Tree, id: @TagType(
33313331 return null;
33323332}
33333333
3334fn nextToken(tok_it: &ast.Tree.TokenList.Iterator, tree: &ast.Tree) AnnotatedToken {
3334fn nextToken(tok_it: *ast.Tree.TokenList.Iterator, tree: *ast.Tree) AnnotatedToken {
33353335 const result = AnnotatedToken{
33363336 .index = tok_it.index,
33373337 .ptr = ??tok_it.next(),
......@@ -3345,7 +3345,7 @@ fn nextToken(tok_it: &ast.Tree.TokenList.Iterator, tree: &ast.Tree) AnnotatedTok
33453345 }
33463346}
33473347
3348fn prevToken(tok_it: &ast.Tree.TokenList.Iterator, tree: &ast.Tree) void {
3348fn prevToken(tok_it: *ast.Tree.TokenList.Iterator, tree: *ast.Tree) void {
33493349 while (true) {
33503350 const prev_tok = tok_it.prev() ?? return;
33513351 if (prev_tok.id == Token.Id.LineComment) continue;
std/zig/parser_test.zig+26-26
......@@ -529,7 +529,7 @@ test "zig fmt: line comment after doc comment" {
529529test "zig fmt: float literal with exponent" {
530530 try testCanonical(
531531 \\test "bit field alignment" {
532 \\ assert(@typeOf(&blah.b) == &align(1:3:6) const u3);
532 \\ assert(@typeOf(&blah.b) == *align(1:3:6) const u3);
533533 \\}
534534 \\
535535 );
......@@ -1040,7 +1040,7 @@ test "zig fmt: alignment" {
10401040
10411041test "zig fmt: C main" {
10421042 try testCanonical(
1043 \\fn main(argc: c_int, argv: &&u8) c_int {
1043 \\fn main(argc: c_int, argv: **u8) c_int {
10441044 \\ const a = b;
10451045 \\}
10461046 \\
......@@ -1049,7 +1049,7 @@ test "zig fmt: C main" {
10491049
10501050test "zig fmt: return" {
10511051 try testCanonical(
1052 \\fn foo(argc: c_int, argv: &&u8) c_int {
1052 \\fn foo(argc: c_int, argv: **u8) c_int {
10531053 \\ return 0;
10541054 \\}
10551055 \\
......@@ -1062,20 +1062,20 @@ test "zig fmt: return" {
10621062
10631063test "zig fmt: pointer attributes" {
10641064 try testCanonical(
1065 \\extern fn f1(s: &align(&u8) u8) c_int;
1066 \\extern fn f2(s: &&align(1) &const &volatile u8) c_int;
1067 \\extern fn f3(s: &align(1) const &align(1) volatile &const volatile u8) c_int;
1068 \\extern fn f4(s: &align(1) const volatile u8) c_int;
1065 \\extern fn f1(s: *align(*u8) u8) c_int;
1066 \\extern fn f2(s: **align(1) *const *volatile u8) c_int;
1067 \\extern fn f3(s: *align(1) const *align(1) volatile *const volatile u8) c_int;
1068 \\extern fn f4(s: *align(1) const volatile u8) c_int;
10691069 \\
10701070 );
10711071}
10721072
10731073test "zig fmt: slice attributes" {
10741074 try testCanonical(
1075 \\extern fn f1(s: &align(&u8) u8) c_int;
1076 \\extern fn f2(s: &&align(1) &const &volatile u8) c_int;
1077 \\extern fn f3(s: &align(1) const &align(1) volatile &const volatile u8) c_int;
1078 \\extern fn f4(s: &align(1) const volatile u8) c_int;
1075 \\extern fn f1(s: *align(*u8) u8) c_int;
1076 \\extern fn f2(s: **align(1) *const *volatile u8) c_int;
1077 \\extern fn f3(s: *align(1) const *align(1) volatile *const volatile u8) c_int;
1078 \\extern fn f4(s: *align(1) const volatile u8) c_int;
10791079 \\
10801080 );
10811081}
......@@ -1212,18 +1212,18 @@ test "zig fmt: var type" {
12121212
12131213test "zig fmt: functions" {
12141214 try testCanonical(
1215 \\extern fn puts(s: &const u8) c_int;
1216 \\extern "c" fn puts(s: &const u8) c_int;
1217 \\export fn puts(s: &const u8) c_int;
1218 \\inline fn puts(s: &const u8) c_int;
1219 \\pub extern fn puts(s: &const u8) c_int;
1220 \\pub extern "c" fn puts(s: &const u8) c_int;
1221 \\pub export fn puts(s: &const u8) c_int;
1222 \\pub inline fn puts(s: &const u8) c_int;
1223 \\pub extern fn puts(s: &const u8) align(2 + 2) c_int;
1224 \\pub extern "c" fn puts(s: &const u8) align(2 + 2) c_int;
1225 \\pub export fn puts(s: &const u8) align(2 + 2) c_int;
1226 \\pub inline fn puts(s: &const u8) align(2 + 2) c_int;
1215 \\extern fn puts(s: *const u8) c_int;
1216 \\extern "c" fn puts(s: *const u8) c_int;
1217 \\export fn puts(s: *const u8) c_int;
1218 \\inline fn puts(s: *const u8) c_int;
1219 \\pub extern fn puts(s: *const u8) c_int;
1220 \\pub extern "c" fn puts(s: *const u8) c_int;
1221 \\pub export fn puts(s: *const u8) c_int;
1222 \\pub inline fn puts(s: *const u8) c_int;
1223 \\pub extern fn puts(s: *const u8) align(2 + 2) c_int;
1224 \\pub extern "c" fn puts(s: *const u8) align(2 + 2) c_int;
1225 \\pub export fn puts(s: *const u8) align(2 + 2) c_int;
1226 \\pub inline fn puts(s: *const u8) align(2 + 2) c_int;
12271227 \\
12281228 );
12291229}
......@@ -1298,8 +1298,8 @@ test "zig fmt: struct declaration" {
12981298 \\ f1: u8,
12991299 \\ pub f3: u8,
13001300 \\
1301 \\ fn method(self: &Self) Self {
1302 \\ return *self;
1301 \\ fn method(self: *Self) Self {
1302 \\ return self.*;
13031303 \\ }
13041304 \\
13051305 \\ f2: u8,
......@@ -1803,7 +1803,7 @@ const io = std.io;
18031803
18041804var fixed_buffer_mem: [100 * 1024]u8 = undefined;
18051805
1806fn testParse(source: []const u8, allocator: &mem.Allocator, anything_changed: &bool) ![]u8 {
1806fn testParse(source: []const u8, allocator: *mem.Allocator, anything_changed: *bool) ![]u8 {
18071807 var stderr_file = try io.getStdErr();
18081808 var stderr = &io.FileOutStream.init(&stderr_file).stream;
18091809
std/zig/render.zig+62-39
......@@ -13,7 +13,7 @@ pub const Error = error{
1313};
1414
1515/// Returns whether anything changed
16pub fn render(allocator: &mem.Allocator, stream: var, tree: &ast.Tree) (@typeOf(stream).Child.Error || Error)!bool {
16pub fn render(allocator: *mem.Allocator, stream: var, tree: *ast.Tree) (@typeOf(stream).Child.Error || Error)!bool {
1717 comptime assert(@typeId(@typeOf(stream)) == builtin.TypeId.Pointer);
1818
1919 var anything_changed: bool = false;
......@@ -24,13 +24,13 @@ pub fn render(allocator: &mem.Allocator, stream: var, tree: &ast.Tree) (@typeOf(
2424 const StreamError = @typeOf(stream).Child.Error;
2525 const Stream = std.io.OutStream(StreamError);
2626
27 anything_changed_ptr: &bool,
27 anything_changed_ptr: *bool,
2828 child_stream: @typeOf(stream),
2929 stream: Stream,
3030 source_index: usize,
3131 source: []const u8,
3232
33 fn write(iface_stream: &Stream, bytes: []const u8) StreamError!void {
33 fn write(iface_stream: *Stream, bytes: []const u8) StreamError!void {
3434 const self = @fieldParentPtr(MyStream, "stream", iface_stream);
3535
3636 if (!self.anything_changed_ptr.*) {
......@@ -63,9 +63,9 @@ pub fn render(allocator: &mem.Allocator, stream: var, tree: &ast.Tree) (@typeOf(
6363}
6464
6565fn renderRoot(
66 allocator: &mem.Allocator,
66 allocator: *mem.Allocator,
6767 stream: var,
68 tree: &ast.Tree,
68 tree: *ast.Tree,
6969) (@typeOf(stream).Child.Error || Error)!void {
7070 // render all the line comments at the beginning of the file
7171 var tok_it = tree.tokens.iterator(0);
......@@ -90,7 +90,7 @@ fn renderRoot(
9090 }
9191}
9292
93fn renderExtraNewline(tree: &ast.Tree, stream: var, start_col: &usize, node: &ast.Node) !void {
93fn renderExtraNewline(tree: *ast.Tree, stream: var, start_col: *usize, node: *ast.Node) !void {
9494 const first_token = node.firstToken();
9595 var prev_token = first_token;
9696 while (tree.tokens.at(prev_token - 1).id == Token.Id.DocComment) {
......@@ -104,7 +104,7 @@ fn renderExtraNewline(tree: &ast.Tree, stream: var, start_col: &usize, node: &as
104104 }
105105}
106106
107fn renderTopLevelDecl(allocator: &mem.Allocator, stream: var, tree: &ast.Tree, indent: usize, start_col: &usize, decl: &ast.Node) (@typeOf(stream).Child.Error || Error)!void {
107fn renderTopLevelDecl(allocator: *mem.Allocator, stream: var, tree: *ast.Tree, indent: usize, start_col: *usize, decl: *ast.Node) (@typeOf(stream).Child.Error || Error)!void {
108108 switch (decl.id) {
109109 ast.Node.Id.FnProto => {
110110 const fn_proto = @fieldParentPtr(ast.Node.FnProto, "base", decl);
......@@ -214,12 +214,12 @@ fn renderTopLevelDecl(allocator: &mem.Allocator, stream: var, tree: &ast.Tree, i
214214}
215215
216216fn renderExpression(
217 allocator: &mem.Allocator,
217 allocator: *mem.Allocator,
218218 stream: var,
219 tree: &ast.Tree,
219 tree: *ast.Tree,
220220 indent: usize,
221 start_col: &usize,
222 base: &ast.Node,
221 start_col: *usize,
222 base: *ast.Node,
223223 space: Space,
224224) (@typeOf(stream).Child.Error || Error)!void {
225225 switch (base.id) {
......@@ -343,9 +343,13 @@ fn renderExpression(
343343 const prefix_op_node = @fieldParentPtr(ast.Node.PrefixOp, "base", base);
344344
345345 switch (prefix_op_node.op) {
346 ast.Node.PrefixOp.Op.AddrOf => |addr_of_info| {
347 try renderToken(tree, stream, prefix_op_node.op_token, indent, start_col, Space.None); // &
348 if (addr_of_info.align_info) |align_info| {
346 ast.Node.PrefixOp.Op.PtrType => |ptr_info| {
347 const star_offset = switch (tree.tokens.at(prefix_op_node.op_token).id) {
348 Token.Id.AsteriskAsterisk => usize(1),
349 else => usize(0),
350 };
351 try renderTokenOffset(tree, stream, prefix_op_node.op_token, indent, start_col, Space.None, star_offset); // *
352 if (ptr_info.align_info) |align_info| {
349353 const lparen_token = tree.prevToken(align_info.node.firstToken());
350354 const align_token = tree.prevToken(lparen_token);
351355
......@@ -370,19 +374,19 @@ fn renderExpression(
370374 try renderToken(tree, stream, rparen_token, indent, start_col, Space.Space); // )
371375 }
372376 }
373 if (addr_of_info.const_token) |const_token| {
377 if (ptr_info.const_token) |const_token| {
374378 try renderToken(tree, stream, const_token, indent, start_col, Space.Space); // const
375379 }
376 if (addr_of_info.volatile_token) |volatile_token| {
380 if (ptr_info.volatile_token) |volatile_token| {
377381 try renderToken(tree, stream, volatile_token, indent, start_col, Space.Space); // volatile
378382 }
379383 },
380384
381 ast.Node.PrefixOp.Op.SliceType => |addr_of_info| {
385 ast.Node.PrefixOp.Op.SliceType => |ptr_info| {
382386 try renderToken(tree, stream, prefix_op_node.op_token, indent, start_col, Space.None); // [
383387 try renderToken(tree, stream, tree.nextToken(prefix_op_node.op_token), indent, start_col, Space.None); // ]
384388
385 if (addr_of_info.align_info) |align_info| {
389 if (ptr_info.align_info) |align_info| {
386390 const lparen_token = tree.prevToken(align_info.node.firstToken());
387391 const align_token = tree.prevToken(lparen_token);
388392
......@@ -407,10 +411,10 @@ fn renderExpression(
407411 try renderToken(tree, stream, rparen_token, indent, start_col, Space.Space); // )
408412 }
409413 }
410 if (addr_of_info.const_token) |const_token| {
414 if (ptr_info.const_token) |const_token| {
411415 try renderToken(tree, stream, const_token, indent, start_col, Space.Space);
412416 }
413 if (addr_of_info.volatile_token) |volatile_token| {
417 if (ptr_info.volatile_token) |volatile_token| {
414418 try renderToken(tree, stream, volatile_token, indent, start_col, Space.Space);
415419 }
416420 },
......@@ -426,7 +430,7 @@ fn renderExpression(
426430 ast.Node.PrefixOp.Op.NegationWrap,
427431 ast.Node.PrefixOp.Op.UnwrapMaybe,
428432 ast.Node.PrefixOp.Op.MaybeType,
429 ast.Node.PrefixOp.Op.PointerType,
433 ast.Node.PrefixOp.Op.AddressOf,
430434 => {
431435 try renderToken(tree, stream, prefix_op_node.op_token, indent, start_col, Space.None);
432436 },
......@@ -1640,12 +1644,12 @@ fn renderExpression(
16401644}
16411645
16421646fn renderVarDecl(
1643 allocator: &mem.Allocator,
1647 allocator: *mem.Allocator,
16441648 stream: var,
1645 tree: &ast.Tree,
1649 tree: *ast.Tree,
16461650 indent: usize,
1647 start_col: &usize,
1648 var_decl: &ast.Node.VarDecl,
1651 start_col: *usize,
1652 var_decl: *ast.Node.VarDecl,
16491653) (@typeOf(stream).Child.Error || Error)!void {
16501654 if (var_decl.visib_token) |visib_token| {
16511655 try renderToken(tree, stream, visib_token, indent, start_col, Space.Space); // pub
......@@ -1696,12 +1700,12 @@ fn renderVarDecl(
16961700}
16971701
16981702fn renderParamDecl(
1699 allocator: &mem.Allocator,
1703 allocator: *mem.Allocator,
17001704 stream: var,
1701 tree: &ast.Tree,
1705 tree: *ast.Tree,
17021706 indent: usize,
1703 start_col: &usize,
1704 base: &ast.Node,
1707 start_col: *usize,
1708 base: *ast.Node,
17051709 space: Space,
17061710) (@typeOf(stream).Child.Error || Error)!void {
17071711 const param_decl = @fieldParentPtr(ast.Node.ParamDecl, "base", base);
......@@ -1724,12 +1728,12 @@ fn renderParamDecl(
17241728}
17251729
17261730fn renderStatement(
1727 allocator: &mem.Allocator,
1731 allocator: *mem.Allocator,
17281732 stream: var,
1729 tree: &ast.Tree,
1733 tree: *ast.Tree,
17301734 indent: usize,
1731 start_col: &usize,
1732 base: &ast.Node,
1735 start_col: *usize,
1736 base: *ast.Node,
17331737) (@typeOf(stream).Child.Error || Error)!void {
17341738 switch (base.id) {
17351739 ast.Node.Id.VarDecl => {
......@@ -1761,7 +1765,15 @@ const Space = enum {
17611765 BlockStart,
17621766};
17631767
1764fn renderToken(tree: &ast.Tree, stream: var, token_index: ast.TokenIndex, indent: usize, start_col: &usize, space: Space) (@typeOf(stream).Child.Error || Error)!void {
1768fn renderTokenOffset(
1769 tree: *ast.Tree,
1770 stream: var,
1771 token_index: ast.TokenIndex,
1772 indent: usize,
1773 start_col: *usize,
1774 space: Space,
1775 token_skip_bytes: usize,
1776) (@typeOf(stream).Child.Error || Error)!void {
17651777 if (space == Space.BlockStart) {
17661778 if (start_col.* < indent + indent_delta)
17671779 return renderToken(tree, stream, token_index, indent, start_col, Space.Space);
......@@ -1772,7 +1784,7 @@ fn renderToken(tree: &ast.Tree, stream: var, token_index: ast.TokenIndex, indent
17721784 }
17731785
17741786 var token = tree.tokens.at(token_index);
1775 try stream.write(mem.trimRight(u8, tree.tokenSlicePtr(token), " "));
1787 try stream.write(mem.trimRight(u8, tree.tokenSlicePtr(token)[token_skip_bytes..], " "));
17761788
17771789 if (space == Space.NoComment)
17781790 return;
......@@ -1927,12 +1939,23 @@ fn renderToken(tree: &ast.Tree, stream: var, token_index: ast.TokenIndex, indent
19271939 }
19281940}
19291941
1942fn renderToken(
1943 tree: *ast.Tree,
1944 stream: var,
1945 token_index: ast.TokenIndex,
1946 indent: usize,
1947 start_col: *usize,
1948 space: Space,
1949) (@typeOf(stream).Child.Error || Error)!void {
1950 return renderTokenOffset(tree, stream, token_index, indent, start_col, space, 0);
1951}
1952
19301953fn renderDocComments(
1931 tree: &ast.Tree,
1954 tree: *ast.Tree,
19321955 stream: var,
19331956 node: var,
19341957 indent: usize,
1935 start_col: &usize,
1958 start_col: *usize,
19361959) (@typeOf(stream).Child.Error || Error)!void {
19371960 const comment = node.doc_comments ?? return;
19381961 var it = comment.lines.iterator(0);
......@@ -1949,7 +1972,7 @@ fn renderDocComments(
19491972 }
19501973}
19511974
1952fn nodeIsBlock(base: &const ast.Node) bool {
1975fn nodeIsBlock(base: *const ast.Node) bool {
19531976 return switch (base.id) {
19541977 ast.Node.Id.Block,
19551978 ast.Node.Id.If,
......@@ -1961,7 +1984,7 @@ fn nodeIsBlock(base: &const ast.Node) bool {
19611984 };
19621985}
19631986
1964fn nodeCausesSliceOpSpace(base: &ast.Node) bool {
1987fn nodeCausesSliceOpSpace(base: *ast.Node) bool {
19651988 const infix_op = base.cast(ast.Node.InfixOp) ?? return false;
19661989 return switch (infix_op.op) {
19671990 ast.Node.InfixOp.Op.Period => false,
std/zig/tokenizer.zig+4-4
......@@ -200,7 +200,7 @@ pub const Tokenizer = struct {
200200 pending_invalid_token: ?Token,
201201
202202 /// For debugging purposes
203 pub fn dump(self: &Tokenizer, token: &const Token) void {
203 pub fn dump(self: *Tokenizer, token: *const Token) void {
204204 std.debug.warn("{} \"{}\"\n", @tagName(token.id), self.buffer[token.start..token.end]);
205205 }
206206
......@@ -265,7 +265,7 @@ pub const Tokenizer = struct {
265265 SawAtSign,
266266 };
267267
268 pub fn next(self: &Tokenizer) Token {
268 pub fn next(self: *Tokenizer) Token {
269269 if (self.pending_invalid_token) |token| {
270270 self.pending_invalid_token = null;
271271 return token;
......@@ -1089,7 +1089,7 @@ pub const Tokenizer = struct {
10891089 return result;
10901090 }
10911091
1092 fn checkLiteralCharacter(self: &Tokenizer) void {
1092 fn checkLiteralCharacter(self: *Tokenizer) void {
10931093 if (self.pending_invalid_token != null) return;
10941094 const invalid_length = self.getInvalidCharacterLength();
10951095 if (invalid_length == 0) return;
......@@ -1100,7 +1100,7 @@ pub const Tokenizer = struct {
11001100 };
11011101 }
11021102
1103 fn getInvalidCharacterLength(self: &Tokenizer) u3 {
1103 fn getInvalidCharacterLength(self: *Tokenizer) u3 {
11041104 const c0 = self.buffer[self.index];
11051105 if (c0 < 0x80) {
11061106 if (c0 < 0x20 or c0 == 0x7f) {
test/assemble_and_link.zig+1-1
......@@ -1,7 +1,7 @@
11const builtin = @import("builtin");
22const tests = @import("tests.zig");
33
4pub fn addCases(cases: &tests.CompareOutputContext) void {
4pub fn addCases(cases: *tests.CompareOutputContext) void {
55 if (builtin.os == builtin.Os.linux and builtin.arch == builtin.Arch.x86_64) {
66 cases.addAsm("hello world linux x86_64",
77 \\.text
test/build_examples.zig+1-1
......@@ -2,7 +2,7 @@ const tests = @import("tests.zig");
22const builtin = @import("builtin");
33const is_windows = builtin.os == builtin.Os.windows;
44
5pub fn addCases(cases: &tests.BuildExamplesContext) void {
5pub fn addCases(cases: *tests.BuildExamplesContext) void {
66 cases.add("example/hello_world/hello.zig");
77 cases.addC("example/hello_world/hello_libc.zig");
88 cases.add("example/cat/main.zig");
test/cases/align.zig+28-28
......@@ -5,7 +5,7 @@ var foo: u8 align(4) = 100;
55
66test "global variable alignment" {
77 assert(@typeOf(&foo).alignment == 4);
8 assert(@typeOf(&foo) == &align(4) u8);
8 assert(@typeOf(&foo) == *align(4) u8);
99 const slice = (&foo)[0..1];
1010 assert(@typeOf(slice) == []align(4) u8);
1111}
......@@ -30,7 +30,7 @@ var baz: packed struct {
3030} = undefined;
3131
3232test "packed struct alignment" {
33 assert(@typeOf(&baz.b) == &align(1) u32);
33 assert(@typeOf(&baz.b) == *align(1) u32);
3434}
3535
3636const blah: packed struct {
......@@ -40,11 +40,11 @@ const blah: packed struct {
4040} = undefined;
4141
4242test "bit field alignment" {
43 assert(@typeOf(&blah.b) == &align(1:3:6) const u3);
43 assert(@typeOf(&blah.b) == *align(1:3:6) const u3);
4444}
4545
4646test "default alignment allows unspecified in type syntax" {
47 assert(&u32 == &align(@alignOf(u32)) u32);
47 assert(*u32 == *align(@alignOf(u32)) u32);
4848}
4949
5050test "implicitly decreasing pointer alignment" {
......@@ -53,7 +53,7 @@ test "implicitly decreasing pointer alignment" {
5353 assert(addUnaligned(&a, &b) == 7);
5454}
5555
56fn addUnaligned(a: &align(1) const u32, b: &align(1) const u32) u32 {
56fn addUnaligned(a: *align(1) const u32, b: *align(1) const u32) u32 {
5757 return a.* + b.*;
5858}
5959
......@@ -76,7 +76,7 @@ fn testBytesAlign(b: u8) void {
7676 b,
7777 b,
7878 };
79 const ptr = @ptrCast(&u32, &bytes[0]);
79 const ptr = @ptrCast(*u32, &bytes[0]);
8080 assert(ptr.* == 0x33333333);
8181}
8282
......@@ -99,10 +99,10 @@ test "@alignCast pointers" {
9999 expectsOnly1(&x);
100100 assert(x == 2);
101101}
102fn expectsOnly1(x: &align(1) u32) void {
102fn expectsOnly1(x: *align(1) u32) void {
103103 expects4(@alignCast(4, x));
104104}
105fn expects4(x: &align(4) u32) void {
105fn expects4(x: *align(4) u32) void {
106106 x.* += 1;
107107}
108108
......@@ -163,8 +163,8 @@ fn whyWouldYouEverDoThis(comptime align_bytes: u8) align(align_bytes) u8 {
163163
164164test "@ptrCast preserves alignment of bigger source" {
165165 var x: u32 align(16) = 1234;
166 const ptr = @ptrCast(&u8, &x);
167 assert(@typeOf(ptr) == &align(16) u8);
166 const ptr = @ptrCast(*u8, &x);
167 assert(@typeOf(ptr) == *align(16) u8);
168168}
169169
170170test "compile-time known array index has best alignment possible" {
......@@ -175,10 +175,10 @@ test "compile-time known array index has best alignment possible" {
175175 3,
176176 4,
177177 };
178 assert(@typeOf(&array[0]) == &align(4) u8);
179 assert(@typeOf(&array[1]) == &u8);
180 assert(@typeOf(&array[2]) == &align(2) u8);
181 assert(@typeOf(&array[3]) == &u8);
178 assert(@typeOf(&array[0]) == *align(4) u8);
179 assert(@typeOf(&array[1]) == *u8);
180 assert(@typeOf(&array[2]) == *align(2) u8);
181 assert(@typeOf(&array[3]) == *u8);
182182
183183 // because align is too small but we still figure out to use 2
184184 var bigger align(2) = []u64{
......@@ -187,10 +187,10 @@ test "compile-time known array index has best alignment possible" {
187187 3,
188188 4,
189189 };
190 assert(@typeOf(&bigger[0]) == &align(2) u64);
191 assert(@typeOf(&bigger[1]) == &align(2) u64);
192 assert(@typeOf(&bigger[2]) == &align(2) u64);
193 assert(@typeOf(&bigger[3]) == &align(2) u64);
190 assert(@typeOf(&bigger[0]) == *align(2) u64);
191 assert(@typeOf(&bigger[1]) == *align(2) u64);
192 assert(@typeOf(&bigger[2]) == *align(2) u64);
193 assert(@typeOf(&bigger[3]) == *align(2) u64);
194194
195195 // because pointer is align 2 and u32 align % 2 == 0 we can assume align 2
196196 var smaller align(2) = []u32{
......@@ -199,21 +199,21 @@ test "compile-time known array index has best alignment possible" {
199199 3,
200200 4,
201201 };
202 testIndex(&smaller[0], 0, &align(2) u32);
203 testIndex(&smaller[0], 1, &align(2) u32);
204 testIndex(&smaller[0], 2, &align(2) u32);
205 testIndex(&smaller[0], 3, &align(2) u32);
202 testIndex(&smaller[0], 0, *align(2) u32);
203 testIndex(&smaller[0], 1, *align(2) u32);
204 testIndex(&smaller[0], 2, *align(2) u32);
205 testIndex(&smaller[0], 3, *align(2) u32);
206206
207207 // has to use ABI alignment because index known at runtime only
208 testIndex2(&array[0], 0, &u8);
209 testIndex2(&array[0], 1, &u8);
210 testIndex2(&array[0], 2, &u8);
211 testIndex2(&array[0], 3, &u8);
208 testIndex2(&array[0], 0, *u8);
209 testIndex2(&array[0], 1, *u8);
210 testIndex2(&array[0], 2, *u8);
211 testIndex2(&array[0], 3, *u8);
212212}
213fn testIndex(smaller: &align(2) u32, index: usize, comptime T: type) void {
213fn testIndex(smaller: *align(2) u32, index: usize, comptime T: type) void {
214214 assert(@typeOf(&smaller[index]) == T);
215215}
216fn testIndex2(ptr: &align(4) u8, index: usize, comptime T: type) void {
216fn testIndex2(ptr: *align(4) u8, index: usize, comptime T: type) void {
217217 assert(@typeOf(&ptr[index]) == T);
218218}
219219
test/cases/atomics.zig+6-6
......@@ -34,7 +34,7 @@ test "atomicrmw and atomicload" {
3434 testAtomicLoad(&data);
3535}
3636
37fn testAtomicRmw(ptr: &u8) void {
37fn testAtomicRmw(ptr: *u8) void {
3838 const prev_value = @atomicRmw(u8, ptr, AtomicRmwOp.Xchg, 42, AtomicOrder.SeqCst);
3939 assert(prev_value == 200);
4040 comptime {
......@@ -45,7 +45,7 @@ fn testAtomicRmw(ptr: &u8) void {
4545 }
4646}
4747
48fn testAtomicLoad(ptr: &u8) void {
48fn testAtomicLoad(ptr: *u8) void {
4949 const x = @atomicLoad(u8, ptr, AtomicOrder.SeqCst);
5050 assert(x == 42);
5151}
......@@ -54,18 +54,18 @@ test "cmpxchg with ptr" {
5454 var data1: i32 = 1234;
5555 var data2: i32 = 5678;
5656 var data3: i32 = 9101;
57 var x: &i32 = &data1;
58 if (@cmpxchgWeak(&i32, &x, &data2, &data3, AtomicOrder.SeqCst, AtomicOrder.SeqCst)) |x1| {
57 var x: *i32 = &data1;
58 if (@cmpxchgWeak(*i32, &x, &data2, &data3, AtomicOrder.SeqCst, AtomicOrder.SeqCst)) |x1| {
5959 assert(x1 == &data1);
6060 } else {
6161 @panic("cmpxchg should have failed");
6262 }
6363
64 while (@cmpxchgWeak(&i32, &x, &data1, &data3, AtomicOrder.SeqCst, AtomicOrder.SeqCst)) |x1| {
64 while (@cmpxchgWeak(*i32, &x, &data1, &data3, AtomicOrder.SeqCst, AtomicOrder.SeqCst)) |x1| {
6565 assert(x1 == &data1);
6666 }
6767 assert(x == &data3);
6868
69 assert(@cmpxchgStrong(&i32, &x, &data3, &data2, AtomicOrder.SeqCst, AtomicOrder.SeqCst) == null);
69 assert(@cmpxchgStrong(*i32, &x, &data3, &data2, AtomicOrder.SeqCst, AtomicOrder.SeqCst) == null);
7070 assert(x == &data2);
7171}
test/cases/bugs/655.zig+2-2
......@@ -3,10 +3,10 @@ const other_file = @import("655_other_file.zig");
33
44test "function with &const parameter with type dereferenced by namespace" {
55 const x: other_file.Integer = 1234;
6 comptime std.debug.assert(@typeOf(&x) == &const other_file.Integer);
6 comptime std.debug.assert(@typeOf(&x) == *const other_file.Integer);
77 foo(x);
88}
99
10fn foo(x: &const other_file.Integer) void {
10fn foo(x: *const other_file.Integer) void {
1111 std.debug.assert(x.* == 1234);
1212}
test/cases/bugs/828.zig+3-3
......@@ -3,7 +3,7 @@ const CountBy = struct {
33
44 const One = CountBy{ .a = 1 };
55
6 pub fn counter(self: &const CountBy) Counter {
6 pub fn counter(self: *const CountBy) Counter {
77 return Counter{ .i = 0 };
88 }
99};
......@@ -11,13 +11,13 @@ const CountBy = struct {
1111const Counter = struct {
1212 i: usize,
1313
14 pub fn count(self: &Counter) bool {
14 pub fn count(self: *Counter) bool {
1515 self.i += 1;
1616 return self.i <= 10;
1717 }
1818};
1919
20fn constCount(comptime cb: &const CountBy, comptime unused: u32) void {
20fn constCount(comptime cb: *const CountBy, comptime unused: u32) void {
2121 comptime {
2222 var cnt = cb.counter();
2323 if (cnt.i != 0) @compileError("Counter instance reused!");
test/cases/bugs/920.zig+3-3
......@@ -9,10 +9,10 @@ const ZigTable = struct {
99
1010 pdf: fn (f64) f64,
1111 is_symmetric: bool,
12 zero_case: fn (&Random, f64) f64,
12 zero_case: fn (*Random, f64) f64,
1313};
1414
15fn ZigTableGen(comptime is_symmetric: bool, comptime r: f64, comptime v: f64, comptime f: fn (f64) f64, comptime f_inv: fn (f64) f64, comptime zero_case: fn (&Random, f64) f64) ZigTable {
15fn ZigTableGen(comptime is_symmetric: bool, comptime r: f64, comptime v: f64, comptime f: fn (f64) f64, comptime f_inv: fn (f64) f64, comptime zero_case: fn (*Random, f64) f64) ZigTable {
1616 var tables: ZigTable = undefined;
1717
1818 tables.is_symmetric = is_symmetric;
......@@ -45,7 +45,7 @@ fn norm_f(x: f64) f64 {
4545fn norm_f_inv(y: f64) f64 {
4646 return math.sqrt(-2.0 * math.ln(y));
4747}
48fn norm_zero_case(random: &Random, u: f64) f64 {
48fn norm_zero_case(random: *Random, u: f64) f64 {
4949 return 0.0;
5050}
5151
test/cases/cast.zig+21-21
......@@ -3,20 +3,20 @@ const mem = @import("std").mem;
33
44test "int to ptr cast" {
55 const x = usize(13);
6 const y = @intToPtr(&u8, x);
6 const y = @intToPtr(*u8, x);
77 const z = @ptrToInt(y);
88 assert(z == 13);
99}
1010
1111test "integer literal to pointer cast" {
12 const vga_mem = @intToPtr(&u16, 0xB8000);
12 const vga_mem = @intToPtr(*u16, 0xB8000);
1313 assert(@ptrToInt(vga_mem) == 0xB8000);
1414}
1515
1616test "pointer reinterpret const float to int" {
1717 const float: f64 = 5.99999999999994648725e-01;
1818 const float_ptr = &float;
19 const int_ptr = @ptrCast(&const i32, float_ptr);
19 const int_ptr = @ptrCast(*const i32, float_ptr);
2020 const int_val = int_ptr.*;
2121 assert(int_val == 858993411);
2222}
......@@ -28,7 +28,7 @@ test "implicitly cast a pointer to a const pointer of it" {
2828 assert(x == 2);
2929}
3030
31fn funcWithConstPtrPtr(x: &const &i32) void {
31fn funcWithConstPtrPtr(x: *const *i32) void {
3232 x.*.* += 1;
3333}
3434
......@@ -66,11 +66,11 @@ fn Struct(comptime T: type) type {
6666 const Self = this;
6767 x: T,
6868
69 fn pointer(self: &const Self) Self {
69 fn pointer(self: *const Self) Self {
7070 return self.*;
7171 }
7272
73 fn maybePointer(self: ?&const Self) Self {
73 fn maybePointer(self: ?*const Self) Self {
7474 const none = Self{ .x = if (T == void) void{} else 0 };
7575 return (self ?? &none).*;
7676 }
......@@ -80,11 +80,11 @@ fn Struct(comptime T: type) type {
8080const Union = union {
8181 x: u8,
8282
83 fn pointer(self: &const Union) Union {
83 fn pointer(self: *const Union) Union {
8484 return self.*;
8585 }
8686
87 fn maybePointer(self: ?&const Union) Union {
87 fn maybePointer(self: ?*const Union) Union {
8888 const none = Union{ .x = 0 };
8989 return (self ?? &none).*;
9090 }
......@@ -94,11 +94,11 @@ const Enum = enum {
9494 None,
9595 Some,
9696
97 fn pointer(self: &const Enum) Enum {
97 fn pointer(self: *const Enum) Enum {
9898 return self.*;
9999 }
100100
101 fn maybePointer(self: ?&const Enum) Enum {
101 fn maybePointer(self: ?*const Enum) Enum {
102102 return (self ?? &Enum.None).*;
103103 }
104104};
......@@ -107,16 +107,16 @@ test "implicitly cast indirect pointer to maybe-indirect pointer" {
107107 const S = struct {
108108 const Self = this;
109109 x: u8,
110 fn constConst(p: &const &const Self) u8 {
110 fn constConst(p: *const *const Self) u8 {
111111 return (p.*).x;
112112 }
113 fn maybeConstConst(p: ?&const &const Self) u8 {
113 fn maybeConstConst(p: ?*const *const Self) u8 {
114114 return ((??p).*).x;
115115 }
116 fn constConstConst(p: &const &const &const Self) u8 {
116 fn constConstConst(p: *const *const *const Self) u8 {
117117 return (p.*.*).x;
118118 }
119 fn maybeConstConstConst(p: ?&const &const &const Self) u8 {
119 fn maybeConstConstConst(p: ?*const *const *const Self) u8 {
120120 return ((??p).*.*).x;
121121 }
122122 };
......@@ -166,12 +166,12 @@ fn testPeerResolveArrayConstSlice(b: bool) void {
166166}
167167
168168test "integer literal to &const int" {
169 const x: &const i32 = 3;
169 const x: *const i32 = 3;
170170 assert(x.* == 3);
171171}
172172
173173test "string literal to &const []const u8" {
174 const x: &const []const u8 = "hello";
174 const x: *const []const u8 = "hello";
175175 assert(mem.eql(u8, x.*, "hello"));
176176}
177177
......@@ -209,11 +209,11 @@ test "return null from fn() error!?&T" {
209209 const b = returnNullLitFromMaybeTypeErrorRef();
210210 assert((try a) == null and (try b) == null);
211211}
212fn returnNullFromMaybeTypeErrorRef() error!?&A {
213 const a: ?&A = null;
212fn returnNullFromMaybeTypeErrorRef() error!?*A {
213 const a: ?*A = null;
214214 return a;
215215}
216fn returnNullLitFromMaybeTypeErrorRef() error!?&A {
216fn returnNullLitFromMaybeTypeErrorRef() error!?*A {
217217 return null;
218218}
219219
......@@ -312,7 +312,7 @@ test "implicit cast from &const [N]T to []const T" {
312312fn testCastConstArrayRefToConstSlice() void {
313313 const blah = "aoeu";
314314 const const_array_ref = &blah;
315 assert(@typeOf(const_array_ref) == &const [4]u8);
315 assert(@typeOf(const_array_ref) == *const [4]u8);
316316 const slice: []const u8 = const_array_ref;
317317 assert(mem.eql(u8, slice, "aoeu"));
318318}
......@@ -322,7 +322,7 @@ test "var args implicitly casts by value arg to const ref" {
322322}
323323
324324fn foo(args: ...) void {
325 assert(@typeOf(args[0]) == &const [5]u8);
325 assert(@typeOf(args[0]) == *const [5]u8);
326326}
327327
328328test "peer type resolution: error and [N]T" {
test/cases/const_slice_child.zig+3-3
......@@ -1,10 +1,10 @@
11const debug = @import("std").debug;
22const assert = debug.assert;
33
4var argv: &const &const u8 = undefined;
4var argv: *const *const u8 = undefined;
55
66test "const slice child" {
7 const strs = ([]&const u8){
7 const strs = ([]*const u8){
88 c"one",
99 c"two",
1010 c"three",
......@@ -29,7 +29,7 @@ fn bar(argc: usize) void {
2929 foo(args);
3030}
3131
32fn strlen(ptr: &const u8) usize {
32fn strlen(ptr: *const u8) usize {
3333 var count: usize = 0;
3434 while (ptr[count] != 0) : (count += 1) {}
3535 return count;
test/cases/coroutines.zig+3-3
......@@ -154,7 +154,7 @@ test "async function with dot syntax" {
154154test "async fn pointer in a struct field" {
155155 var data: i32 = 1;
156156 const Foo = struct {
157 bar: async<&std.mem.Allocator> fn (&i32) void,
157 bar: async<*std.mem.Allocator> fn (*i32) void,
158158 };
159159 var foo = Foo{ .bar = simpleAsyncFn2 };
160160 const p = (async<std.debug.global_allocator> foo.bar(&data)) catch unreachable;
......@@ -162,7 +162,7 @@ test "async fn pointer in a struct field" {
162162 cancel p;
163163 assert(data == 4);
164164}
165async<&std.mem.Allocator> fn simpleAsyncFn2(y: &i32) void {
165async<*std.mem.Allocator> fn simpleAsyncFn2(y: *i32) void {
166166 defer y.* += 2;
167167 y.* += 1;
168168 suspend;
......@@ -220,7 +220,7 @@ test "break from suspend" {
220220 cancel p;
221221 std.debug.assert(my_result == 2);
222222}
223async fn testBreakFromSuspend(my_result: &i32) void {
223async fn testBreakFromSuspend(my_result: *i32) void {
224224 s: suspend |p| {
225225 break :s;
226226 }
test/cases/enum.zig+5-5
......@@ -56,14 +56,14 @@ test "constant enum with payload" {
5656 shouldBeNotEmpty(full);
5757}
5858
59fn shouldBeEmpty(x: &const AnEnumWithPayload) void {
59fn shouldBeEmpty(x: *const AnEnumWithPayload) void {
6060 switch (x.*) {
6161 AnEnumWithPayload.Empty => {},
6262 else => unreachable,
6363 }
6464}
6565
66fn shouldBeNotEmpty(x: &const AnEnumWithPayload) void {
66fn shouldBeNotEmpty(x: *const AnEnumWithPayload) void {
6767 switch (x.*) {
6868 AnEnumWithPayload.Empty => unreachable,
6969 else => {},
......@@ -750,15 +750,15 @@ test "bit field access with enum fields" {
750750 assert(data.b == B.Four3);
751751}
752752
753fn getA(data: &const BitFieldOfEnums) A {
753fn getA(data: *const BitFieldOfEnums) A {
754754 return data.a;
755755}
756756
757fn getB(data: &const BitFieldOfEnums) B {
757fn getB(data: *const BitFieldOfEnums) B {
758758 return data.b;
759759}
760760
761fn getC(data: &const BitFieldOfEnums) C {
761fn getC(data: *const BitFieldOfEnums) C {
762762 return data.c;
763763}
764764
test/cases/enum_with_members.zig+1-1
......@@ -6,7 +6,7 @@ const ET = union(enum) {
66 SINT: i32,
77 UINT: u32,
88
9 pub fn print(a: &const ET, buf: []u8) error!usize {
9 pub fn print(a: *const ET, buf: []u8) error!usize {
1010 return switch (a.*) {
1111 ET.SINT => |x| fmt.formatIntBuf(buf, x, 10, false, 0),
1212 ET.UINT => |x| fmt.formatIntBuf(buf, x, 10, false, 0),
test/cases/eval.zig+40-6
......@@ -282,7 +282,7 @@ fn fnWithFloatMode() f32 {
282282const SimpleStruct = struct {
283283 field: i32,
284284
285 fn method(self: &const SimpleStruct) i32 {
285 fn method(self: *const SimpleStruct) i32 {
286286 return self.field + 3;
287287 }
288288};
......@@ -367,7 +367,7 @@ test "const global shares pointer with other same one" {
367367 assertEqualPtrs(&hi1[0], &hi2[0]);
368368 comptime assert(&hi1[0] == &hi2[0]);
369369}
370fn assertEqualPtrs(ptr1: &const u8, ptr2: &const u8) void {
370fn assertEqualPtrs(ptr1: *const u8, ptr2: *const u8) void {
371371 assert(ptr1 == ptr2);
372372}
373373
......@@ -418,9 +418,9 @@ test "string literal used as comptime slice is memoized" {
418418}
419419
420420test "comptime slice of undefined pointer of length 0" {
421 const slice1 = (&i32)(undefined)[0..0];
421 const slice1 = (*i32)(undefined)[0..0];
422422 assert(slice1.len == 0);
423 const slice2 = (&i32)(undefined)[100..100];
423 const slice2 = (*i32)(undefined)[100..100];
424424 assert(slice2.len == 0);
425425}
426426
......@@ -472,7 +472,7 @@ test "comptime function with mutable pointer is not memoized" {
472472 }
473473}
474474
475fn increment(value: &i32) void {
475fn increment(value: *i32) void {
476476 value.* += 1;
477477}
478478
......@@ -517,7 +517,7 @@ test "comptime slice of pointer preserves comptime var" {
517517const SingleFieldStruct = struct {
518518 x: i32,
519519
520 fn read_x(self: &const SingleFieldStruct) i32 {
520 fn read_x(self: *const SingleFieldStruct) i32 {
521521 return self.x;
522522 }
523523};
......@@ -576,3 +576,37 @@ test "comptime modification of const struct field" {
576576 assert(res.version == 1);
577577 }
578578}
579
580test "pointer to type" {
581 comptime {
582 var T: type = i32;
583 assert(T == i32);
584 var ptr = &T;
585 assert(@typeOf(ptr) == *type);
586 ptr.* = f32;
587 assert(T == f32);
588 assert(*T == *f32);
589 }
590}
591
592test "slice of type" {
593 comptime {
594 var types_array = []type{ i32, f64, type };
595 for (types_array) |T, i| {
596 switch (i) {
597 0 => assert(T == i32),
598 1 => assert(T == f64),
599 2 => assert(T == type),
600 else => unreachable,
601 }
602 }
603 for (types_array[0..]) |T, i| {
604 switch (i) {
605 0 => assert(T == i32),
606 1 => assert(T == f64),
607 2 => assert(T == type),
608 else => unreachable,
609 }
610 }
611 }
612}
test/cases/field_parent_ptr.zig+2-2
......@@ -24,7 +24,7 @@ const foo = Foo{
2424 .d = -10,
2525};
2626
27fn testParentFieldPtr(c: &const i32) void {
27fn testParentFieldPtr(c: *const i32) void {
2828 assert(c == &foo.c);
2929
3030 const base = @fieldParentPtr(Foo, "c", c);
......@@ -32,7 +32,7 @@ fn testParentFieldPtr(c: &const i32) void {
3232 assert(&base.c == c);
3333}
3434
35fn testParentFieldPtrFirst(a: &const bool) void {
35fn testParentFieldPtrFirst(a: *const bool) void {
3636 assert(a == &foo.a);
3737
3838 const base = @fieldParentPtr(Foo, "a", a);
test/cases/fn_in_struct_in_comptime.zig+3-3
......@@ -1,9 +1,9 @@
11const assert = @import("std").debug.assert;
22
3fn get_foo() fn (&u8) usize {
3fn get_foo() fn (*u8) usize {
44 comptime {
55 return struct {
6 fn func(ptr: &u8) usize {
6 fn func(ptr: *u8) usize {
77 var u = @ptrToInt(ptr);
88 return u;
99 }
......@@ -13,5 +13,5 @@ fn get_foo() fn (&u8) usize {
1313
1414test "define a function in an anonymous struct in comptime" {
1515 const foo = get_foo();
16 assert(foo(@intToPtr(&u8, 12345)) == 12345);
16 assert(foo(@intToPtr(*u8, 12345)) == 12345);
1717}
test/cases/generics.zig+4-4
......@@ -96,8 +96,8 @@ test "generic struct" {
9696fn GenNode(comptime T: type) type {
9797 return struct {
9898 value: T,
99 next: ?&GenNode(T),
100 fn getVal(n: &const GenNode(T)) T {
99 next: ?*GenNode(T),
100 fn getVal(n: *const GenNode(T)) T {
101101 return n.value;
102102 }
103103 };
......@@ -126,11 +126,11 @@ test "generic fn with implicit cast" {
126126 13,
127127 }) == 0);
128128}
129fn getByte(ptr: ?&const u8) u8 {
129fn getByte(ptr: ?*const u8) u8 {
130130 return (??ptr).*;
131131}
132132fn getFirstByte(comptime T: type, mem: []const T) u8 {
133 return getByte(@ptrCast(&const u8, &mem[0]));
133 return getByte(@ptrCast(*const u8, &mem[0]));
134134}
135135
136136const foos = []fn (var) bool{
test/cases/incomplete_struct_param_tld.zig+2-2
......@@ -11,12 +11,12 @@ const B = struct {
1111const C = struct {
1212 x: i32,
1313
14 fn d(c: &const C) i32 {
14 fn d(c: *const C) i32 {
1515 return c.x;
1616 }
1717};
1818
19fn foo(a: &const A) i32 {
19fn foo(a: *const A) i32 {
2020 return a.b.c.d();
2121}
2222
test/cases/math.zig+27-9
......@@ -28,13 +28,27 @@ fn testDivision() void {
2828 assert(divTrunc(f32, -5.0, 3.0) == -1.0);
2929
3030 comptime {
31 assert(1194735857077236777412821811143690633098347576 % 508740759824825164163191790951174292733114988 == 177254337427586449086438229241342047632117600);
32 assert(@rem(-1194735857077236777412821811143690633098347576, 508740759824825164163191790951174292733114988) == -177254337427586449086438229241342047632117600);
33 assert(1194735857077236777412821811143690633098347576 / 508740759824825164163191790951174292733114988 == 2);
34 assert(@divTrunc(-1194735857077236777412821811143690633098347576, 508740759824825164163191790951174292733114988) == -2);
35 assert(@divTrunc(1194735857077236777412821811143690633098347576, -508740759824825164163191790951174292733114988) == -2);
36 assert(@divTrunc(-1194735857077236777412821811143690633098347576, -508740759824825164163191790951174292733114988) == 2);
37 assert(4126227191251978491697987544882340798050766755606969681711 % 10 == 1);
31 assert(
32 1194735857077236777412821811143690633098347576 % 508740759824825164163191790951174292733114988 == 177254337427586449086438229241342047632117600,
33 );
34 assert(
35 @rem(-1194735857077236777412821811143690633098347576, 508740759824825164163191790951174292733114988) == -177254337427586449086438229241342047632117600,
36 );
37 assert(
38 1194735857077236777412821811143690633098347576 / 508740759824825164163191790951174292733114988 == 2,
39 );
40 assert(
41 @divTrunc(-1194735857077236777412821811143690633098347576, 508740759824825164163191790951174292733114988) == -2,
42 );
43 assert(
44 @divTrunc(1194735857077236777412821811143690633098347576, -508740759824825164163191790951174292733114988) == -2,
45 );
46 assert(
47 @divTrunc(-1194735857077236777412821811143690633098347576, -508740759824825164163191790951174292733114988) == 2,
48 );
49 assert(
50 4126227191251978491697987544882340798050766755606969681711 % 10 == 1,
51 );
3852 }
3953}
4054fn div(comptime T: type, a: T, b: T) T {
......@@ -324,8 +338,12 @@ test "big number addition" {
324338
325339test "big number multiplication" {
326340 comptime {
327 assert(45960427431263824329884196484953148229 * 128339149605334697009938835852565949723 == 5898522172026096622534201617172456926982464453350084962781392314016180490567);
328 assert(594491908217841670578297176641415611445982232488944558774612 * 390603545391089362063884922208143568023166603618446395589768 == 232210647056203049913662402532976186578842425262306016094292237500303028346593132411865381225871291702600263463125370016);
341 assert(
342 45960427431263824329884196484953148229 * 128339149605334697009938835852565949723 == 5898522172026096622534201617172456926982464453350084962781392314016180490567,
343 );
344 assert(
345 594491908217841670578297176641415611445982232488944558774612 * 390603545391089362063884922208143568023166603618446395589768 == 232210647056203049913662402532976186578842425262306016094292237500303028346593132411865381225871291702600263463125370016,
346 );
329347 }
330348}
331349
test/cases/misc.zig+24-24
......@@ -252,20 +252,20 @@ test "multiline C string" {
252252}
253253
254254test "type equality" {
255 assert(&const u8 != &u8);
255 assert(*const u8 != *u8);
256256}
257257
258258const global_a: i32 = 1234;
259const global_b: &const i32 = &global_a;
260const global_c: &const f32 = @ptrCast(&const f32, global_b);
259const global_b: *const i32 = &global_a;
260const global_c: *const f32 = @ptrCast(*const f32, global_b);
261261test "compile time global reinterpret" {
262 const d = @ptrCast(&const i32, global_c);
262 const d = @ptrCast(*const i32, global_c);
263263 assert(d.* == 1234);
264264}
265265
266266test "explicit cast maybe pointers" {
267 const a: ?&i32 = undefined;
268 const b: ?&f32 = @ptrCast(?&f32, a);
267 const a: ?*i32 = undefined;
268 const b: ?*f32 = @ptrCast(?*f32, a);
269269}
270270
271271test "generic malloc free" {
......@@ -274,7 +274,7 @@ test "generic malloc free" {
274274}
275275var some_mem: [100]u8 = undefined;
276276fn memAlloc(comptime T: type, n: usize) error![]T {
277 return @ptrCast(&T, &some_mem[0])[0..n];
277 return @ptrCast(*T, &some_mem[0])[0..n];
278278}
279279fn memFree(comptime T: type, memory: []T) void {}
280280
......@@ -357,7 +357,7 @@ const test3_foo = Test3Foo{
357357 },
358358};
359359const test3_bar = Test3Foo{ .Two = 13 };
360fn test3_1(f: &const Test3Foo) void {
360fn test3_1(f: *const Test3Foo) void {
361361 switch (f.*) {
362362 Test3Foo.Three => |pt| {
363363 assert(pt.x == 3);
......@@ -366,7 +366,7 @@ fn test3_1(f: &const Test3Foo) void {
366366 else => unreachable,
367367 }
368368}
369fn test3_2(f: &const Test3Foo) void {
369fn test3_2(f: *const Test3Foo) void {
370370 switch (f.*) {
371371 Test3Foo.Two => |x| {
372372 assert(x == 13);
......@@ -393,7 +393,7 @@ test "pointer comparison" {
393393 const b = &a;
394394 assert(ptrEql(b, b));
395395}
396fn ptrEql(a: &const []const u8, b: &const []const u8) bool {
396fn ptrEql(a: *const []const u8, b: *const []const u8) bool {
397397 return a == b;
398398}
399399
......@@ -446,13 +446,13 @@ fn testPointerToVoidReturnType() error!void {
446446 return a.*;
447447}
448448const test_pointer_to_void_return_type_x = void{};
449fn testPointerToVoidReturnType2() &const void {
449fn testPointerToVoidReturnType2() *const void {
450450 return &test_pointer_to_void_return_type_x;
451451}
452452
453453test "non const ptr to aliased type" {
454454 const int = i32;
455 assert(?&int == ?&i32);
455 assert(?*int == ?*i32);
456456}
457457
458458test "array 2D const double ptr" {
......@@ -463,7 +463,7 @@ test "array 2D const double ptr" {
463463 testArray2DConstDoublePtr(&rect_2d_vertexes[0][0]);
464464}
465465
466fn testArray2DConstDoublePtr(ptr: &const f32) void {
466fn testArray2DConstDoublePtr(ptr: *const f32) void {
467467 assert(ptr[0] == 1.0);
468468 assert(ptr[1] == 2.0);
469469}
......@@ -497,7 +497,7 @@ test "@typeId" {
497497 assert(@typeId(u64) == Tid.Int);
498498 assert(@typeId(f32) == Tid.Float);
499499 assert(@typeId(f64) == Tid.Float);
500 assert(@typeId(&f32) == Tid.Pointer);
500 assert(@typeId(*f32) == Tid.Pointer);
501501 assert(@typeId([2]u8) == Tid.Array);
502502 assert(@typeId(AStruct) == Tid.Struct);
503503 assert(@typeId(@typeOf(1)) == Tid.IntLiteral);
......@@ -540,7 +540,7 @@ test "@typeName" {
540540 };
541541 comptime {
542542 assert(mem.eql(u8, @typeName(i64), "i64"));
543 assert(mem.eql(u8, @typeName(&usize), "&usize"));
543 assert(mem.eql(u8, @typeName(*usize), "*usize"));
544544 // https://github.com/ziglang/zig/issues/675
545545 assert(mem.eql(u8, @typeName(TypeFromFn(u8)), "TypeFromFn(u8)"));
546546 assert(mem.eql(u8, @typeName(Struct), "Struct"));
......@@ -555,7 +555,7 @@ fn TypeFromFn(comptime T: type) type {
555555
556556test "volatile load and store" {
557557 var number: i32 = 1234;
558 const ptr = (&volatile i32)(&number);
558 const ptr = (*volatile i32)(&number);
559559 ptr.* += 1;
560560 assert(ptr.* == 1235);
561561}
......@@ -587,28 +587,28 @@ var global_ptr = &gdt[0];
587587
588588// can't really run this test but we can make sure it has no compile error
589589// and generates code
590const vram = @intToPtr(&volatile u8, 0x20000000)[0..0x8000];
590const vram = @intToPtr(*volatile u8, 0x20000000)[0..0x8000];
591591export fn writeToVRam() void {
592592 vram[0] = 'X';
593593}
594594
595595test "pointer child field" {
596 assert((&u32).Child == u32);
596 assert((*u32).Child == u32);
597597}
598598
599599const OpaqueA = @OpaqueType();
600600const OpaqueB = @OpaqueType();
601601test "@OpaqueType" {
602 assert(&OpaqueA != &OpaqueB);
602 assert(*OpaqueA != *OpaqueB);
603603 assert(mem.eql(u8, @typeName(OpaqueA), "OpaqueA"));
604604 assert(mem.eql(u8, @typeName(OpaqueB), "OpaqueB"));
605605}
606606
607607test "variable is allowed to be a pointer to an opaque type" {
608608 var x: i32 = 1234;
609 _ = hereIsAnOpaqueType(@ptrCast(&OpaqueA, &x));
609 _ = hereIsAnOpaqueType(@ptrCast(*OpaqueA, &x));
610610}
611fn hereIsAnOpaqueType(ptr: &OpaqueA) &OpaqueA {
611fn hereIsAnOpaqueType(ptr: *OpaqueA) *OpaqueA {
612612 var a = ptr;
613613 return a;
614614}
......@@ -692,7 +692,7 @@ test "packed struct, enum, union parameters in extern function" {
692692 }, PackedUnion{ .a = 1 }, PackedEnum.A);
693693}
694694
695export fn testPackedStuff(a: &const PackedStruct, b: &const PackedUnion, c: PackedEnum) void {}
695export fn testPackedStuff(a: *const PackedStruct, b: *const PackedUnion, c: PackedEnum) void {}
696696
697697test "slicing zero length array" {
698698 const s1 = ""[0..];
......@@ -703,8 +703,8 @@ test "slicing zero length array" {
703703 assert(mem.eql(u32, s2, []u32{}));
704704}
705705
706const addr1 = @ptrCast(&const u8, emptyFn);
706const addr1 = @ptrCast(*const u8, emptyFn);
707707test "comptime cast fn to ptr" {
708 const addr2 = @ptrCast(&const u8, emptyFn);
708 const addr2 = @ptrCast(*const u8, emptyFn);
709709 comptime assert(addr1 == addr2);
710710}
test/cases/null.zig+1-1
......@@ -65,7 +65,7 @@ test "if var maybe pointer" {
6565 .d = 1,
6666 }) == 15);
6767}
68fn shouldBeAPlus1(p: &const Particle) u64 {
68fn shouldBeAPlus1(p: *const Particle) u64 {
6969 var maybe_particle: ?Particle = p.*;
7070 if (maybe_particle) |*particle| {
7171 particle.a += 1;
test/cases/reflection.zig+1-1
......@@ -5,7 +5,7 @@ const reflection = this;
55test "reflection: array, pointer, nullable, error union type child" {
66 comptime {
77 assert(([10]u8).Child == u8);
8 assert((&u8).Child == u8);
8 assert((*u8).Child == u8);
99 assert((error!u8).Payload == u8);
1010 assert((?u8).Child == u8);
1111 }
test/cases/slice.zig+1-1
......@@ -1,7 +1,7 @@
11const assert = @import("std").debug.assert;
22const mem = @import("std").mem;
33
4const x = @intToPtr(&i32, 0x1000)[0..0x500];
4const x = @intToPtr(*i32, 0x1000)[0..0x500];
55const y = x[0x100..];
66test "compile time slice of pointer to hard coded address" {
77 assert(@ptrToInt(x.ptr) == 0x1000);
test/cases/struct.zig+14-14
......@@ -43,7 +43,7 @@ const VoidStructFieldsFoo = struct {
4343
4444test "structs" {
4545 var foo: StructFoo = undefined;
46 @memset(@ptrCast(&u8, &foo), 0, @sizeOf(StructFoo));
46 @memset(@ptrCast(*u8, &foo), 0, @sizeOf(StructFoo));
4747 foo.a += 1;
4848 foo.b = foo.a == 1;
4949 testFoo(foo);
......@@ -55,16 +55,16 @@ const StructFoo = struct {
5555 b: bool,
5656 c: f32,
5757};
58fn testFoo(foo: &const StructFoo) void {
58fn testFoo(foo: *const StructFoo) void {
5959 assert(foo.b);
6060}
61fn testMutation(foo: &StructFoo) void {
61fn testMutation(foo: *StructFoo) void {
6262 foo.c = 100;
6363}
6464
6565const Node = struct {
6666 val: Val,
67 next: &Node,
67 next: *Node,
6868};
6969
7070const Val = struct {
......@@ -112,7 +112,7 @@ fn aFunc() i32 {
112112 return 13;
113113}
114114
115fn callStructField(foo: &const Foo) i32 {
115fn callStructField(foo: *const Foo) i32 {
116116 return foo.ptr();
117117}
118118
......@@ -124,7 +124,7 @@ test "store member function in variable" {
124124}
125125const MemberFnTestFoo = struct {
126126 x: i32,
127 fn member(foo: &const MemberFnTestFoo) i32 {
127 fn member(foo: *const MemberFnTestFoo) i32 {
128128 return foo.x;
129129 }
130130};
......@@ -141,7 +141,7 @@ test "member functions" {
141141}
142142const MemberFnRand = struct {
143143 seed: u32,
144 pub fn getSeed(r: &const MemberFnRand) u32 {
144 pub fn getSeed(r: *const MemberFnRand) u32 {
145145 return r.seed;
146146 }
147147};
......@@ -166,7 +166,7 @@ test "empty struct method call" {
166166 assert(es.method() == 1234);
167167}
168168const EmptyStruct = struct {
169 fn method(es: &const EmptyStruct) i32 {
169 fn method(es: *const EmptyStruct) i32 {
170170 return 1234;
171171 }
172172};
......@@ -228,15 +228,15 @@ test "bit field access" {
228228 assert(data.b == 3);
229229}
230230
231fn getA(data: &const BitField1) u3 {
231fn getA(data: *const BitField1) u3 {
232232 return data.a;
233233}
234234
235fn getB(data: &const BitField1) u3 {
235fn getB(data: *const BitField1) u3 {
236236 return data.b;
237237}
238238
239fn getC(data: &const BitField1) u2 {
239fn getC(data: *const BitField1) u2 {
240240 return data.c;
241241}
242242
......@@ -396,8 +396,8 @@ const Bitfields = packed struct {
396396test "native bit field understands endianness" {
397397 var all: u64 = 0x7765443322221111;
398398 var bytes: [8]u8 = undefined;
399 @memcpy(&bytes[0], @ptrCast(&u8, &all), 8);
400 var bitfields = @ptrCast(&Bitfields, &bytes[0]).*;
399 @memcpy(&bytes[0], @ptrCast(*u8, &all), 8);
400 var bitfields = @ptrCast(*Bitfields, &bytes[0]).*;
401401
402402 assert(bitfields.f1 == 0x1111);
403403 assert(bitfields.f2 == 0x2222);
......@@ -415,7 +415,7 @@ test "align 1 field before self referential align 8 field as slice return type"
415415
416416const Expr = union(enum) {
417417 Literal: u8,
418 Question: &Expr,
418 Question: *Expr,
419419};
420420
421421fn alloc(comptime T: type) []T {
test/cases/struct_contains_null_ptr_itself.zig+2-2
......@@ -2,13 +2,13 @@ const std = @import("std");
22const assert = std.debug.assert;
33
44test "struct contains null pointer which contains original struct" {
5 var x: ?&NodeLineComment = null;
5 var x: ?*NodeLineComment = null;
66 assert(x == null);
77}
88
99pub const Node = struct {
1010 id: Id,
11 comment: ?&NodeLineComment,
11 comment: ?*NodeLineComment,
1212
1313 pub const Id = enum {
1414 Root,
test/cases/switch.zig+1-1
......@@ -90,7 +90,7 @@ const SwitchProngWithVarEnum = union(enum) {
9090 Two: f32,
9191 Meh: void,
9292};
93fn switchProngWithVarFn(a: &const SwitchProngWithVarEnum) void {
93fn switchProngWithVarFn(a: *const SwitchProngWithVarEnum) void {
9494 switch (a.*) {
9595 SwitchProngWithVarEnum.One => |x| {
9696 assert(x == 13);
test/cases/this.zig+1-1
......@@ -8,7 +8,7 @@ fn Point(comptime T: type) type {
88 x: T,
99 y: T,
1010
11 fn addOne(self: &Self) void {
11 fn addOne(self: *Self) void {
1212 self.x += 1;
1313 self.y += 1;
1414 }
test/cases/type_info.zig+8-8
......@@ -37,7 +37,7 @@ test "type info: pointer type info" {
3737}
3838
3939fn testPointer() void {
40 const u32_ptr_info = @typeInfo(&u32);
40 const u32_ptr_info = @typeInfo(*u32);
4141 assert(TypeId(u32_ptr_info) == TypeId.Pointer);
4242 assert(u32_ptr_info.Pointer.is_const == false);
4343 assert(u32_ptr_info.Pointer.is_volatile == false);
......@@ -169,14 +169,14 @@ fn testUnion() void {
169169 assert(notag_union_info.Union.fields[1].field_type == u32);
170170
171171 const TestExternUnion = extern union {
172 foo: &c_void,
172 foo: *c_void,
173173 };
174174
175175 const extern_union_info = @typeInfo(TestExternUnion);
176176 assert(extern_union_info.Union.layout == TypeInfo.ContainerLayout.Extern);
177177 assert(extern_union_info.Union.tag_type == @typeOf(undefined));
178178 assert(extern_union_info.Union.fields[0].enum_field == null);
179 assert(extern_union_info.Union.fields[0].field_type == &c_void);
179 assert(extern_union_info.Union.fields[0].field_type == *c_void);
180180}
181181
182182test "type info: struct info" {
......@@ -190,13 +190,13 @@ fn testStruct() void {
190190 assert(struct_info.Struct.layout == TypeInfo.ContainerLayout.Packed);
191191 assert(struct_info.Struct.fields.len == 3);
192192 assert(struct_info.Struct.fields[1].offset == null);
193 assert(struct_info.Struct.fields[2].field_type == &TestStruct);
193 assert(struct_info.Struct.fields[2].field_type == *TestStruct);
194194 assert(struct_info.Struct.defs.len == 2);
195195 assert(struct_info.Struct.defs[0].is_pub);
196196 assert(!struct_info.Struct.defs[0].data.Fn.is_extern);
197197 assert(struct_info.Struct.defs[0].data.Fn.lib_name == null);
198198 assert(struct_info.Struct.defs[0].data.Fn.return_type == void);
199 assert(struct_info.Struct.defs[0].data.Fn.fn_type == fn (&const TestStruct) void);
199 assert(struct_info.Struct.defs[0].data.Fn.fn_type == fn (*const TestStruct) void);
200200}
201201
202202const TestStruct = packed struct {
......@@ -204,9 +204,9 @@ const TestStruct = packed struct {
204204
205205 fieldA: usize,
206206 fieldB: void,
207 fieldC: &Self,
207 fieldC: *Self,
208208
209 pub fn foo(self: &const Self) void {}
209 pub fn foo(self: *const Self) void {}
210210};
211211
212212test "type info: function type info" {
......@@ -227,7 +227,7 @@ fn testFunction() void {
227227 const test_instance: TestStruct = undefined;
228228 const bound_fn_info = @typeInfo(@typeOf(test_instance.foo));
229229 assert(TypeId(bound_fn_info) == TypeId.BoundFn);
230 assert(bound_fn_info.BoundFn.args[0].arg_type == &const TestStruct);
230 assert(bound_fn_info.BoundFn.args[0].arg_type == *const TestStruct);
231231}
232232
233233fn foo(comptime a: usize, b: bool, args: ...) usize {
test/cases/undefined.zig+2-2
......@@ -27,12 +27,12 @@ test "init static array to undefined" {
2727const Foo = struct {
2828 x: i32,
2929
30 fn setFooXMethod(foo: &Foo) void {
30 fn setFooXMethod(foo: *Foo) void {
3131 foo.x = 3;
3232 }
3333};
3434
35fn setFooX(foo: &Foo) void {
35fn setFooX(foo: *Foo) void {
3636 foo.x = 2;
3737}
3838
test/cases/union.zig+8-8
......@@ -68,11 +68,11 @@ test "init union with runtime value" {
6868 assert(foo.int == 42);
6969}
7070
71fn setFloat(foo: &Foo, x: f64) void {
71fn setFloat(foo: *Foo, x: f64) void {
7272 foo.* = Foo{ .float = x };
7373}
7474
75fn setInt(foo: &Foo, x: i32) void {
75fn setInt(foo: *Foo, x: i32) void {
7676 foo.* = Foo{ .int = x };
7777}
7878
......@@ -108,7 +108,7 @@ fn doTest() void {
108108 assert(bar(Payload{ .A = 1234 }) == -10);
109109}
110110
111fn bar(value: &const Payload) i32 {
111fn bar(value: *const Payload) i32 {
112112 assert(Letter(value.*) == Letter.A);
113113 return switch (value.*) {
114114 Payload.A => |x| return x - 1244,
......@@ -147,7 +147,7 @@ test "union(enum(u32)) with specified and unspecified tag values" {
147147 comptime testEnumWithSpecifiedAndUnspecifiedTagValues(MultipleChoice2{ .C = 123 });
148148}
149149
150fn testEnumWithSpecifiedAndUnspecifiedTagValues(x: &const MultipleChoice2) void {
150fn testEnumWithSpecifiedAndUnspecifiedTagValues(x: *const MultipleChoice2) void {
151151 assert(u32(@TagType(MultipleChoice2)(x.*)) == 60);
152152 assert(1123 == switch (x.*) {
153153 MultipleChoice2.A => 1,
......@@ -163,7 +163,7 @@ fn testEnumWithSpecifiedAndUnspecifiedTagValues(x: &const MultipleChoice2) void
163163}
164164
165165const ExternPtrOrInt = extern union {
166 ptr: &u8,
166 ptr: *u8,
167167 int: u64,
168168};
169169test "extern union size" {
......@@ -171,7 +171,7 @@ test "extern union size" {
171171}
172172
173173const PackedPtrOrInt = packed union {
174 ptr: &u8,
174 ptr: *u8,
175175 int: u64,
176176};
177177test "extern union size" {
......@@ -206,7 +206,7 @@ test "cast union to tag type of union" {
206206 comptime testCastUnionToTagType(TheUnion{ .B = 1234 });
207207}
208208
209fn testCastUnionToTagType(x: &const TheUnion) void {
209fn testCastUnionToTagType(x: *const TheUnion) void {
210210 assert(TheTag(x.*) == TheTag.B);
211211}
212212
......@@ -243,7 +243,7 @@ const TheUnion2 = union(enum) {
243243 Item2: i32,
244244};
245245
246fn assertIsTheUnion2Item1(value: &const TheUnion2) void {
246fn assertIsTheUnion2Item1(value: *const TheUnion2) void {
247247 assert(value.* == TheUnion2.Item1);
248248}
249249
test/compare_output.zig+10-10
......@@ -3,10 +3,10 @@ const std = @import("std");
33const os = std.os;
44const tests = @import("tests.zig");
55
6pub fn addCases(cases: &tests.CompareOutputContext) void {
6pub fn addCases(cases: *tests.CompareOutputContext) void {
77 cases.addC("hello world with libc",
88 \\const c = @cImport(@cInclude("stdio.h"));
9 \\export fn main(argc: c_int, argv: &&u8) c_int {
9 \\export fn main(argc: c_int, argv: **u8) c_int {
1010 \\ _ = c.puts(c"Hello, world!");
1111 \\ return 0;
1212 \\}
......@@ -139,7 +139,7 @@ pub fn addCases(cases: &tests.CompareOutputContext) void {
139139 \\ @cInclude("stdio.h");
140140 \\});
141141 \\
142 \\export fn main(argc: c_int, argv: &&u8) c_int {
142 \\export fn main(argc: c_int, argv: **u8) c_int {
143143 \\ if (is_windows) {
144144 \\ // we want actual \n, not \r\n
145145 \\ _ = c._setmode(1, c._O_BINARY);
......@@ -284,9 +284,9 @@ pub fn addCases(cases: &tests.CompareOutputContext) void {
284284 cases.addC("expose function pointer to C land",
285285 \\const c = @cImport(@cInclude("stdlib.h"));
286286 \\
287 \\export fn compare_fn(a: ?&const c_void, b: ?&const c_void) c_int {
288 \\ const a_int = @ptrCast(&align(1) const i32, a ?? unreachable);
289 \\ const b_int = @ptrCast(&align(1) const i32, b ?? unreachable);
287 \\export fn compare_fn(a: ?*const c_void, b: ?*const c_void) c_int {
288 \\ const a_int = @ptrCast(*align(1) const i32, a ?? unreachable);
289 \\ const b_int = @ptrCast(*align(1) const i32, b ?? unreachable);
290290 \\ if (a_int.* < b_int.*) {
291291 \\ return -1;
292292 \\ } else if (a_int.* > b_int.*) {
......@@ -299,7 +299,7 @@ pub fn addCases(cases: &tests.CompareOutputContext) void {
299299 \\export fn main() c_int {
300300 \\ var array = []u32 { 1, 7, 3, 2, 0, 9, 4, 8, 6, 5 };
301301 \\
302 \\ c.qsort(@ptrCast(&c_void, &array[0]), c_ulong(array.len), @sizeOf(i32), compare_fn);
302 \\ c.qsort(@ptrCast(*c_void, &array[0]), c_ulong(array.len), @sizeOf(i32), compare_fn);
303303 \\
304304 \\ for (array) |item, i| {
305305 \\ if (item != i) {
......@@ -324,7 +324,7 @@ pub fn addCases(cases: &tests.CompareOutputContext) void {
324324 \\ @cInclude("stdio.h");
325325 \\});
326326 \\
327 \\export fn main(argc: c_int, argv: &&u8) c_int {
327 \\export fn main(argc: c_int, argv: **u8) c_int {
328328 \\ if (is_windows) {
329329 \\ // we want actual \n, not \r\n
330330 \\ _ = c._setmode(1, c._O_BINARY);
......@@ -344,13 +344,13 @@ pub fn addCases(cases: &tests.CompareOutputContext) void {
344344 \\const Foo = struct {
345345 \\ field1: Bar,
346346 \\
347 \\ fn method(a: &const Foo) bool { return true; }
347 \\ fn method(a: *const Foo) bool { return true; }
348348 \\};
349349 \\
350350 \\const Bar = struct {
351351 \\ field2: i32,
352352 \\
353 \\ fn method(b: &const Bar) bool { return true; }
353 \\ fn method(b: *const Bar) bool { return true; }
354354 \\};
355355 \\
356356 \\pub fn main() void {
test/compile_errors.zig+61-61
......@@ -1,6 +1,6 @@
11const tests = @import("tests.zig");
22
3pub fn addCases(cases: &tests.CompileErrorContext) void {
3pub fn addCases(cases: *tests.CompileErrorContext) void {
44 cases.add(
55 "invalid deref on switch target",
66 \\comptime {
......@@ -109,7 +109,7 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
109109 "@ptrCast discards const qualifier",
110110 \\export fn entry() void {
111111 \\ const x: i32 = 1234;
112 \\ const y = @ptrCast(&i32, &x);
112 \\ const y = @ptrCast(*i32, &x);
113113 \\}
114114 ,
115115 ".tmp_source.zig:3:15: error: cast discards const qualifier",
......@@ -118,7 +118,7 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
118118 cases.add(
119119 "comptime slice of undefined pointer non-zero len",
120120 \\export fn entry() void {
121 \\ const slice = (&i32)(undefined)[0..1];
121 \\ const slice = (*i32)(undefined)[0..1];
122122 \\}
123123 ,
124124 ".tmp_source.zig:2:36: error: non-zero length slice of undefined pointer",
......@@ -126,7 +126,7 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
126126
127127 cases.add(
128128 "type checking function pointers",
129 \\fn a(b: fn (&const u8) void) void {
129 \\fn a(b: fn (*const u8) void) void {
130130 \\ b('a');
131131 \\}
132132 \\fn c(d: u8) void {
......@@ -136,7 +136,7 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
136136 \\ a(c);
137137 \\}
138138 ,
139 ".tmp_source.zig:8:7: error: expected type 'fn(&const u8) void', found 'fn(u8) void'",
139 ".tmp_source.zig:8:7: error: expected type 'fn(*const u8) void', found 'fn(u8) void'",
140140 );
141141
142142 cases.add(
......@@ -594,15 +594,15 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
594594
595595 cases.add(
596596 "attempt to use 0 bit type in extern fn",
597 \\extern fn foo(ptr: extern fn(&void) void) void;
597 \\extern fn foo(ptr: extern fn(*void) void) void;
598598 \\
599599 \\export fn entry() void {
600600 \\ foo(bar);
601601 \\}
602602 \\
603 \\extern fn bar(x: &void) void { }
603 \\extern fn bar(x: *void) void { }
604604 ,
605 ".tmp_source.zig:7:18: error: parameter of type '&void' has 0 bits; not allowed in function with calling convention 'ccc'",
605 ".tmp_source.zig:7:18: error: parameter of type '*void' has 0 bits; not allowed in function with calling convention 'ccc'",
606606 );
607607
608608 cases.add(
......@@ -911,10 +911,10 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
911911
912912 cases.add(
913913 "pointer to noreturn",
914 \\fn a() &noreturn {}
914 \\fn a() *noreturn {}
915915 \\export fn entry() void { _ = a(); }
916916 ,
917 ".tmp_source.zig:1:9: error: pointer to noreturn not allowed",
917 ".tmp_source.zig:1:8: error: pointer to noreturn not allowed",
918918 );
919919
920920 cases.add(
......@@ -985,7 +985,7 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
985985 \\ return a;
986986 \\}
987987 ,
988 ".tmp_source.zig:3:12: error: expected type 'i32', found '&const u8'",
988 ".tmp_source.zig:3:12: error: expected type 'i32', found '*const u8'",
989989 );
990990
991991 cases.add(
......@@ -1446,7 +1446,7 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
14461446
14471447 cases.add(
14481448 "switch expression - switch on pointer type with no else",
1449 \\fn foo(x: &u8) void {
1449 \\fn foo(x: *u8) void {
14501450 \\ switch (x) {
14511451 \\ &y => {},
14521452 \\ }
......@@ -1454,7 +1454,7 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
14541454 \\const y: u8 = 100;
14551455 \\export fn entry() usize { return @sizeOf(@typeOf(foo)); }
14561456 ,
1457 ".tmp_source.zig:2:5: error: else prong required when switching on type '&u8'",
1457 ".tmp_source.zig:2:5: error: else prong required when switching on type '*u8'",
14581458 );
14591459
14601460 cases.add(
......@@ -1501,10 +1501,10 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
15011501 "address of number literal",
15021502 \\const x = 3;
15031503 \\const y = &x;
1504 \\fn foo() &const i32 { return y; }
1504 \\fn foo() *const i32 { return y; }
15051505 \\export fn entry() usize { return @sizeOf(@typeOf(foo)); }
15061506 ,
1507 ".tmp_source.zig:3:30: error: expected type '&const i32', found '&const (integer literal)'",
1507 ".tmp_source.zig:3:30: error: expected type '*const i32', found '*const (integer literal)'",
15081508 );
15091509
15101510 cases.add(
......@@ -1529,10 +1529,10 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
15291529 \\ a: i32,
15301530 \\ b: i32,
15311531 \\
1532 \\ fn member_a(foo: &const Foo) i32 {
1532 \\ fn member_a(foo: *const Foo) i32 {
15331533 \\ return foo.a;
15341534 \\ }
1535 \\ fn member_b(foo: &const Foo) i32 {
1535 \\ fn member_b(foo: *const Foo) i32 {
15361536 \\ return foo.b;
15371537 \\ }
15381538 \\};
......@@ -1543,7 +1543,7 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
15431543 \\ Foo.member_b,
15441544 \\};
15451545 \\
1546 \\fn f(foo: &const Foo, index: usize) void {
1546 \\fn f(foo: *const Foo, index: usize) void {
15471547 \\ const result = members[index]();
15481548 \\}
15491549 \\
......@@ -1692,11 +1692,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
16921692
16931693 cases.add(
16941694 "assign null to non-nullable pointer",
1695 \\const a: &u8 = null;
1695 \\const a: *u8 = null;
16961696 \\
16971697 \\export fn entry() usize { return @sizeOf(@typeOf(a)); }
16981698 ,
1699 ".tmp_source.zig:1:16: error: expected type '&u8', found '(null)'",
1699 ".tmp_source.zig:1:16: error: expected type '*u8', found '(null)'",
17001700 );
17011701
17021702 cases.add(
......@@ -1806,7 +1806,7 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
18061806 \\ One: void,
18071807 \\ Two: i32,
18081808 \\};
1809 \\fn bad_eql_2(a: &const EnumWithData, b: &const EnumWithData) bool {
1809 \\fn bad_eql_2(a: *const EnumWithData, b: *const EnumWithData) bool {
18101810 \\ return a.* == b.*;
18111811 \\}
18121812 \\
......@@ -2011,9 +2011,9 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
20112011 cases.add(
20122012 "wrong number of arguments for method fn call",
20132013 \\const Foo = struct {
2014 \\ fn method(self: &const Foo, a: i32) void {}
2014 \\ fn method(self: *const Foo, a: i32) void {}
20152015 \\};
2016 \\fn f(foo: &const Foo) void {
2016 \\fn f(foo: *const Foo) void {
20172017 \\
20182018 \\ foo.method(1, 2);
20192019 \\}
......@@ -2062,7 +2062,7 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
20622062 cases.add(
20632063 "misspelled type with pointer only reference",
20642064 \\const JasonHM = u8;
2065 \\const JasonList = &JsonNode;
2065 \\const JasonList = *JsonNode;
20662066 \\
20672067 \\const JsonOA = union(enum) {
20682068 \\ JSONArray: JsonList,
......@@ -2113,16 +2113,16 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
21132113 \\ derp.init();
21142114 \\}
21152115 ,
2116 ".tmp_source.zig:14:5: error: expected type 'i32', found '&const Foo'",
2116 ".tmp_source.zig:14:5: error: expected type 'i32', found '*const Foo'",
21172117 );
21182118
21192119 cases.add(
21202120 "method call with first arg type wrong container",
21212121 \\pub const List = struct {
21222122 \\ len: usize,
2123 \\ allocator: &Allocator,
2123 \\ allocator: *Allocator,
21242124 \\
2125 \\ pub fn init(allocator: &Allocator) List {
2125 \\ pub fn init(allocator: *Allocator) List {
21262126 \\ return List {
21272127 \\ .len = 0,
21282128 \\ .allocator = allocator,
......@@ -2143,7 +2143,7 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
21432143 \\ x.init();
21442144 \\}
21452145 ,
2146 ".tmp_source.zig:23:5: error: expected type '&Allocator', found '&List'",
2146 ".tmp_source.zig:23:5: error: expected type '*Allocator', found '*List'",
21472147 );
21482148
21492149 cases.add(
......@@ -2308,17 +2308,17 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
23082308 \\ c: u2,
23092309 \\};
23102310 \\
2311 \\fn foo(bit_field: &const BitField) u3 {
2311 \\fn foo(bit_field: *const BitField) u3 {
23122312 \\ return bar(&bit_field.b);
23132313 \\}
23142314 \\
2315 \\fn bar(x: &const u3) u3 {
2315 \\fn bar(x: *const u3) u3 {
23162316 \\ return x.*;
23172317 \\}
23182318 \\
23192319 \\export fn entry() usize { return @sizeOf(@typeOf(foo)); }
23202320 ,
2321 ".tmp_source.zig:8:26: error: expected type '&const u3', found '&align(1:3:6) const u3'",
2321 ".tmp_source.zig:8:26: error: expected type '*const u3', found '*align(1:3:6) const u3'",
23222322 );
23232323
23242324 cases.add(
......@@ -2441,13 +2441,13 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
24412441 \\ const b = &a;
24422442 \\ return ptrEql(b, b);
24432443 \\}
2444 \\fn ptrEql(a: &[]const u8, b: &[]const u8) bool {
2444 \\fn ptrEql(a: *[]const u8, b: *[]const u8) bool {
24452445 \\ return true;
24462446 \\}
24472447 \\
24482448 \\export fn entry() usize { return @sizeOf(@typeOf(foo)); }
24492449 ,
2450 ".tmp_source.zig:4:19: error: expected type '&[]const u8', found '&const []const u8'",
2450 ".tmp_source.zig:4:19: error: expected type '*[]const u8', found '*const []const u8'",
24512451 );
24522452
24532453 cases.addCase(x: {
......@@ -2493,7 +2493,7 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
24932493
24942494 cases.add(
24952495 "ptrcast to non-pointer",
2496 \\export fn entry(a: &i32) usize {
2496 \\export fn entry(a: *i32) usize {
24972497 \\ return @ptrCast(usize, a);
24982498 \\}
24992499 ,
......@@ -2542,16 +2542,16 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
25422542 "int to ptr of 0 bits",
25432543 \\export fn foo() void {
25442544 \\ var x: usize = 0x1000;
2545 \\ var y: &void = @intToPtr(&void, x);
2545 \\ var y: *void = @intToPtr(*void, x);
25462546 \\}
25472547 ,
2548 ".tmp_source.zig:3:31: error: type '&void' has 0 bits and cannot store information",
2548 ".tmp_source.zig:3:30: error: type '*void' has 0 bits and cannot store information",
25492549 );
25502550
25512551 cases.add(
25522552 "@fieldParentPtr - non struct",
25532553 \\const Foo = i32;
2554 \\export fn foo(a: &i32) &Foo {
2554 \\export fn foo(a: *i32) *Foo {
25552555 \\ return @fieldParentPtr(Foo, "a", a);
25562556 \\}
25572557 ,
......@@ -2563,7 +2563,7 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
25632563 \\const Foo = extern struct {
25642564 \\ derp: i32,
25652565 \\};
2566 \\export fn foo(a: &i32) &Foo {
2566 \\export fn foo(a: *i32) *Foo {
25672567 \\ return @fieldParentPtr(Foo, "a", a);
25682568 \\}
25692569 ,
......@@ -2575,7 +2575,7 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
25752575 \\const Foo = extern struct {
25762576 \\ a: i32,
25772577 \\};
2578 \\export fn foo(a: i32) &Foo {
2578 \\export fn foo(a: i32) *Foo {
25792579 \\ return @fieldParentPtr(Foo, "a", a);
25802580 \\}
25812581 ,
......@@ -2591,7 +2591,7 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
25912591 \\const foo = Foo { .a = 1, .b = 2, };
25922592 \\
25932593 \\comptime {
2594 \\ const field_ptr = @intToPtr(&i32, 0x1234);
2594 \\ const field_ptr = @intToPtr(*i32, 0x1234);
25952595 \\ const another_foo_ptr = @fieldParentPtr(Foo, "b", field_ptr);
25962596 \\}
25972597 ,
......@@ -2682,7 +2682,7 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
26822682
26832683 cases.add(
26842684 "returning address of local variable - simple",
2685 \\export fn foo() &i32 {
2685 \\export fn foo() *i32 {
26862686 \\ var a: i32 = undefined;
26872687 \\ return &a;
26882688 \\}
......@@ -2692,7 +2692,7 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
26922692
26932693 cases.add(
26942694 "returning address of local variable - phi",
2695 \\export fn foo(c: bool) &i32 {
2695 \\export fn foo(c: bool) *i32 {
26962696 \\ var a: i32 = undefined;
26972697 \\ var b: i32 = undefined;
26982698 \\ return if (c) &a else &b;
......@@ -3086,11 +3086,11 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
30863086 \\ bar(&foo.b);
30873087 \\}
30883088 \\
3089 \\fn bar(x: &u32) void {
3089 \\fn bar(x: *u32) void {
30903090 \\ x.* += 1;
30913091 \\}
30923092 ,
3093 ".tmp_source.zig:8:13: error: expected type '&u32', found '&align(1) u32'",
3093 ".tmp_source.zig:8:13: error: expected type '*u32', found '*align(1) u32'",
30943094 );
30953095
30963096 cases.add(
......@@ -3117,13 +3117,13 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
31173117 "increase pointer alignment in @ptrCast",
31183118 \\export fn entry() u32 {
31193119 \\ var bytes: [4]u8 = []u8{0x01, 0x02, 0x03, 0x04};
3120 \\ const ptr = @ptrCast(&u32, &bytes[0]);
3120 \\ const ptr = @ptrCast(*u32, &bytes[0]);
31213121 \\ return ptr.*;
31223122 \\}
31233123 ,
31243124 ".tmp_source.zig:3:17: error: cast increases pointer alignment",
3125 ".tmp_source.zig:3:38: note: '&u8' has alignment 1",
3126 ".tmp_source.zig:3:27: note: '&u32' has alignment 4",
3125 ".tmp_source.zig:3:38: note: '*u8' has alignment 1",
3126 ".tmp_source.zig:3:26: note: '*u32' has alignment 4",
31273127 );
31283128
31293129 cases.add(
......@@ -3169,7 +3169,7 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
31693169 \\ return x == 5678;
31703170 \\}
31713171 ,
3172 ".tmp_source.zig:4:32: error: expected type '&i32', found '&align(1) i32'",
3172 ".tmp_source.zig:4:32: error: expected type '*i32', found '*align(1) i32'",
31733173 );
31743174
31753175 cases.add(
......@@ -3198,20 +3198,20 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
31983198 cases.add(
31993199 "wrong pointer implicitly casted to pointer to @OpaqueType()",
32003200 \\const Derp = @OpaqueType();
3201 \\extern fn bar(d: &Derp) void;
3201 \\extern fn bar(d: *Derp) void;
32023202 \\export fn foo() void {
32033203 \\ var x = u8(1);
3204 \\ bar(@ptrCast(&c_void, &x));
3204 \\ bar(@ptrCast(*c_void, &x));
32053205 \\}
32063206 ,
3207 ".tmp_source.zig:5:9: error: expected type '&Derp', found '&c_void'",
3207 ".tmp_source.zig:5:9: error: expected type '*Derp', found '*c_void'",
32083208 );
32093209
32103210 cases.add(
32113211 "non-const variables of things that require const variables",
32123212 \\const Opaque = @OpaqueType();
32133213 \\
3214 \\export fn entry(opaque: &Opaque) void {
3214 \\export fn entry(opaque: *Opaque) void {
32153215 \\ var m2 = &2;
32163216 \\ const y: u32 = m2.*;
32173217 \\
......@@ -3229,10 +3229,10 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
32293229 \\}
32303230 \\
32313231 \\const Foo = struct {
3232 \\ fn bar(self: &const Foo) void {}
3232 \\ fn bar(self: *const Foo) void {}
32333233 \\};
32343234 ,
3235 ".tmp_source.zig:4:4: error: variable of type '&const (integer literal)' must be const or comptime",
3235 ".tmp_source.zig:4:4: error: variable of type '*(integer literal)' must be const or comptime",
32363236 ".tmp_source.zig:7:4: error: variable of type '(undefined)' must be const or comptime",
32373237 ".tmp_source.zig:8:4: error: variable of type '(integer literal)' must be const or comptime",
32383238 ".tmp_source.zig:9:4: error: variable of type '(float literal)' must be const or comptime",
......@@ -3241,7 +3241,7 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
32413241 ".tmp_source.zig:12:4: error: variable of type 'Opaque' must be const or comptime",
32423242 ".tmp_source.zig:13:4: error: variable of type 'type' must be const or comptime",
32433243 ".tmp_source.zig:14:4: error: variable of type '(namespace)' must be const or comptime",
3244 ".tmp_source.zig:15:4: error: variable of type '(bound fn(&const Foo) void)' must be const or comptime",
3244 ".tmp_source.zig:15:4: error: variable of type '(bound fn(*const Foo) void)' must be const or comptime",
32453245 ".tmp_source.zig:17:4: error: unreachable code",
32463246 );
32473247
......@@ -3397,14 +3397,14 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
33973397 \\
33983398 \\export fn entry() bool {
33993399 \\ var x: i32 = 1;
3400 \\ return bar(@ptrCast(&MyType, &x));
3400 \\ return bar(@ptrCast(*MyType, &x));
34013401 \\}
34023402 \\
3403 \\fn bar(x: &MyType) bool {
3403 \\fn bar(x: *MyType) bool {
34043404 \\ return x.blah;
34053405 \\}
34063406 ,
3407 ".tmp_source.zig:9:13: error: type '&MyType' does not support field access",
3407 ".tmp_source.zig:9:13: error: type '*MyType' does not support field access",
34083408 );
34093409
34103410 cases.add(
......@@ -3535,9 +3535,9 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
35353535 \\export fn entry() void {
35363536 \\ foo("hello",);
35373537 \\}
3538 \\pub extern fn foo(format: &const u8, ...) void;
3538 \\pub extern fn foo(format: *const u8, ...) void;
35393539 ,
3540 ".tmp_source.zig:2:9: error: expected type '&const u8', found '[5]u8'",
3540 ".tmp_source.zig:2:9: error: expected type '*const u8', found '[5]u8'",
35413541 );
35423542
35433543 cases.add(
......@@ -3902,7 +3902,7 @@ pub fn addCases(cases: &tests.CompileErrorContext) void {
39023902 \\ const a = Payload { .A = 1234 };
39033903 \\ foo(a);
39043904 \\}
3905 \\fn foo(a: &const Payload) void {
3905 \\fn foo(a: *const Payload) void {
39063906 \\ switch (a.*) {
39073907 \\ Payload.A => {},
39083908 \\ else => unreachable,
test/gen_h.zig+3-3
......@@ -1,6 +1,6 @@
11const tests = @import("tests.zig");
22
3pub fn addCases(cases: &tests.GenHContext) void {
3pub fn addCases(cases: *tests.GenHContext) void {
44 cases.add("declare enum",
55 \\const Foo = extern enum { A, B, C };
66 \\export fn entry(foo: Foo) void { }
......@@ -54,7 +54,7 @@ pub fn addCases(cases: &tests.GenHContext) void {
5454 cases.add("declare opaque type",
5555 \\export const Foo = @OpaqueType();
5656 \\
57 \\export fn entry(foo: ?&Foo) void { }
57 \\export fn entry(foo: ?*Foo) void { }
5858 ,
5959 \\struct Foo;
6060 \\
......@@ -64,7 +64,7 @@ pub fn addCases(cases: &tests.GenHContext) void {
6464 cases.add("array field-type",
6565 \\const Foo = extern struct {
6666 \\ A: [2]i32,
67 \\ B: [4]&u32,
67 \\ B: [4]*u32,
6868 \\};
6969 \\export fn entry(foo: Foo, bar: [3]u8) void { }
7070 ,
test/runtime_safety.zig+24-24
......@@ -1,8 +1,8 @@
11const tests = @import("tests.zig");
22
3pub fn addCases(cases: &tests.CompareOutputContext) void {
3pub fn addCases(cases: *tests.CompareOutputContext) void {
44 cases.addRuntimeSafety("calling panic",
5 \\pub fn panic(message: []const u8, stack_trace: ?&@import("builtin").StackTrace) noreturn {
5 \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn {
66 \\ @import("std").os.exit(126);
77 \\}
88 \\pub fn main() void {
......@@ -11,7 +11,7 @@ pub fn addCases(cases: &tests.CompareOutputContext) void {
1111 );
1212
1313 cases.addRuntimeSafety("out of bounds slice access",
14 \\pub fn panic(message: []const u8, stack_trace: ?&@import("builtin").StackTrace) noreturn {
14 \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn {
1515 \\ @import("std").os.exit(126);
1616 \\}
1717 \\pub fn main() void {
......@@ -25,7 +25,7 @@ pub fn addCases(cases: &tests.CompareOutputContext) void {
2525 );
2626
2727 cases.addRuntimeSafety("integer addition overflow",
28 \\pub fn panic(message: []const u8, stack_trace: ?&@import("builtin").StackTrace) noreturn {
28 \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn {
2929 \\ @import("std").os.exit(126);
3030 \\}
3131 \\pub fn main() !void {
......@@ -38,7 +38,7 @@ pub fn addCases(cases: &tests.CompareOutputContext) void {
3838 );
3939
4040 cases.addRuntimeSafety("integer subtraction overflow",
41 \\pub fn panic(message: []const u8, stack_trace: ?&@import("builtin").StackTrace) noreturn {
41 \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn {
4242 \\ @import("std").os.exit(126);
4343 \\}
4444 \\pub fn main() !void {
......@@ -51,7 +51,7 @@ pub fn addCases(cases: &tests.CompareOutputContext) void {
5151 );
5252
5353 cases.addRuntimeSafety("integer multiplication overflow",
54 \\pub fn panic(message: []const u8, stack_trace: ?&@import("builtin").StackTrace) noreturn {
54 \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn {
5555 \\ @import("std").os.exit(126);
5656 \\}
5757 \\pub fn main() !void {
......@@ -64,7 +64,7 @@ pub fn addCases(cases: &tests.CompareOutputContext) void {
6464 );
6565
6666 cases.addRuntimeSafety("integer negation overflow",
67 \\pub fn panic(message: []const u8, stack_trace: ?&@import("builtin").StackTrace) noreturn {
67 \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn {
6868 \\ @import("std").os.exit(126);
6969 \\}
7070 \\pub fn main() !void {
......@@ -77,7 +77,7 @@ pub fn addCases(cases: &tests.CompareOutputContext) void {
7777 );
7878
7979 cases.addRuntimeSafety("signed integer division overflow",
80 \\pub fn panic(message: []const u8, stack_trace: ?&@import("builtin").StackTrace) noreturn {
80 \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn {
8181 \\ @import("std").os.exit(126);
8282 \\}
8383 \\pub fn main() !void {
......@@ -90,7 +90,7 @@ pub fn addCases(cases: &tests.CompareOutputContext) void {
9090 );
9191
9292 cases.addRuntimeSafety("signed shift left overflow",
93 \\pub fn panic(message: []const u8, stack_trace: ?&@import("builtin").StackTrace) noreturn {
93 \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn {
9494 \\ @import("std").os.exit(126);
9595 \\}
9696 \\pub fn main() !void {
......@@ -103,7 +103,7 @@ pub fn addCases(cases: &tests.CompareOutputContext) void {
103103 );
104104
105105 cases.addRuntimeSafety("unsigned shift left overflow",
106 \\pub fn panic(message: []const u8, stack_trace: ?&@import("builtin").StackTrace) noreturn {
106 \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn {
107107 \\ @import("std").os.exit(126);
108108 \\}
109109 \\pub fn main() !void {
......@@ -116,7 +116,7 @@ pub fn addCases(cases: &tests.CompareOutputContext) void {
116116 );
117117
118118 cases.addRuntimeSafety("signed shift right overflow",
119 \\pub fn panic(message: []const u8, stack_trace: ?&@import("builtin").StackTrace) noreturn {
119 \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn {
120120 \\ @import("std").os.exit(126);
121121 \\}
122122 \\pub fn main() !void {
......@@ -129,7 +129,7 @@ pub fn addCases(cases: &tests.CompareOutputContext) void {
129129 );
130130
131131 cases.addRuntimeSafety("unsigned shift right overflow",
132 \\pub fn panic(message: []const u8, stack_trace: ?&@import("builtin").StackTrace) noreturn {
132 \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn {
133133 \\ @import("std").os.exit(126);
134134 \\}
135135 \\pub fn main() !void {
......@@ -142,7 +142,7 @@ pub fn addCases(cases: &tests.CompareOutputContext) void {
142142 );
143143
144144 cases.addRuntimeSafety("integer division by zero",
145 \\pub fn panic(message: []const u8, stack_trace: ?&@import("builtin").StackTrace) noreturn {
145 \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn {
146146 \\ @import("std").os.exit(126);
147147 \\}
148148 \\pub fn main() void {
......@@ -154,7 +154,7 @@ pub fn addCases(cases: &tests.CompareOutputContext) void {
154154 );
155155
156156 cases.addRuntimeSafety("exact division failure",
157 \\pub fn panic(message: []const u8, stack_trace: ?&@import("builtin").StackTrace) noreturn {
157 \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn {
158158 \\ @import("std").os.exit(126);
159159 \\}
160160 \\pub fn main() !void {
......@@ -167,7 +167,7 @@ pub fn addCases(cases: &tests.CompareOutputContext) void {
167167 );
168168
169169 cases.addRuntimeSafety("cast []u8 to bigger slice of wrong size",
170 \\pub fn panic(message: []const u8, stack_trace: ?&@import("builtin").StackTrace) noreturn {
170 \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn {
171171 \\ @import("std").os.exit(126);
172172 \\}
173173 \\pub fn main() !void {
......@@ -180,7 +180,7 @@ pub fn addCases(cases: &tests.CompareOutputContext) void {
180180 );
181181
182182 cases.addRuntimeSafety("value does not fit in shortening cast",
183 \\pub fn panic(message: []const u8, stack_trace: ?&@import("builtin").StackTrace) noreturn {
183 \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn {
184184 \\ @import("std").os.exit(126);
185185 \\}
186186 \\pub fn main() !void {
......@@ -193,7 +193,7 @@ pub fn addCases(cases: &tests.CompareOutputContext) void {
193193 );
194194
195195 cases.addRuntimeSafety("signed integer not fitting in cast to unsigned integer",
196 \\pub fn panic(message: []const u8, stack_trace: ?&@import("builtin").StackTrace) noreturn {
196 \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn {
197197 \\ @import("std").os.exit(126);
198198 \\}
199199 \\pub fn main() !void {
......@@ -206,7 +206,7 @@ pub fn addCases(cases: &tests.CompareOutputContext) void {
206206 );
207207
208208 cases.addRuntimeSafety("unwrap error",
209 \\pub fn panic(message: []const u8, stack_trace: ?&@import("builtin").StackTrace) noreturn {
209 \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn {
210210 \\ if (@import("std").mem.eql(u8, message, "attempt to unwrap error: Whatever")) {
211211 \\ @import("std").os.exit(126); // good
212212 \\ }
......@@ -221,7 +221,7 @@ pub fn addCases(cases: &tests.CompareOutputContext) void {
221221 );
222222
223223 cases.addRuntimeSafety("cast integer to global error and no code matches",
224 \\pub fn panic(message: []const u8, stack_trace: ?&@import("builtin").StackTrace) noreturn {
224 \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn {
225225 \\ @import("std").os.exit(126);
226226 \\}
227227 \\pub fn main() void {
......@@ -233,7 +233,7 @@ pub fn addCases(cases: &tests.CompareOutputContext) void {
233233 );
234234
235235 cases.addRuntimeSafety("cast integer to non-global error set and no match",
236 \\pub fn panic(message: []const u8, stack_trace: ?&@import("builtin").StackTrace) noreturn {
236 \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn {
237237 \\ @import("std").os.exit(126);
238238 \\}
239239 \\const Set1 = error{A, B};
......@@ -247,7 +247,7 @@ pub fn addCases(cases: &tests.CompareOutputContext) void {
247247 );
248248
249249 cases.addRuntimeSafety("@alignCast misaligned",
250 \\pub fn panic(message: []const u8, stack_trace: ?&@import("builtin").StackTrace) noreturn {
250 \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn {
251251 \\ @import("std").os.exit(126);
252252 \\}
253253 \\pub fn main() !void {
......@@ -263,7 +263,7 @@ pub fn addCases(cases: &tests.CompareOutputContext) void {
263263 );
264264
265265 cases.addRuntimeSafety("bad union field access",
266 \\pub fn panic(message: []const u8, stack_trace: ?&@import("builtin").StackTrace) noreturn {
266 \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn {
267267 \\ @import("std").os.exit(126);
268268 \\}
269269 \\
......@@ -277,7 +277,7 @@ pub fn addCases(cases: &tests.CompareOutputContext) void {
277277 \\ bar(&f);
278278 \\}
279279 \\
280 \\fn bar(f: &Foo) void {
280 \\fn bar(f: *Foo) void {
281281 \\ f.float = 12.34;
282282 \\}
283283 );
......@@ -287,7 +287,7 @@ pub fn addCases(cases: &tests.CompareOutputContext) void {
287287 cases.addRuntimeSafety("error return trace across suspend points",
288288 \\const std = @import("std");
289289 \\
290 \\pub fn panic(message: []const u8, stack_trace: ?&@import("builtin").StackTrace) noreturn {
290 \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn {
291291 \\ std.os.exit(126);
292292 \\}
293293 \\
test/standalone/brace_expansion/build.zig+1-1
......@@ -1,6 +1,6 @@
11const Builder = @import("std").build.Builder;
22
3pub fn build(b: &Builder) void {
3pub fn build(b: *Builder) void {
44 const main = b.addTest("main.zig");
55 main.setBuildMode(b.standardReleaseOptions());
66
test/standalone/brace_expansion/main.zig+4-4
......@@ -14,7 +14,7 @@ const Token = union(enum) {
1414 Eof,
1515};
1616
17var global_allocator: &mem.Allocator = undefined;
17var global_allocator: *mem.Allocator = undefined;
1818
1919fn tokenize(input: []const u8) !ArrayList(Token) {
2020 const State = enum {
......@@ -73,7 +73,7 @@ const ParseError = error{
7373 OutOfMemory,
7474};
7575
76fn parse(tokens: &const ArrayList(Token), token_index: &usize) ParseError!Node {
76fn parse(tokens: *const ArrayList(Token), token_index: *usize) ParseError!Node {
7777 const first_token = tokens.items[token_index.*];
7878 token_index.* += 1;
7979
......@@ -109,7 +109,7 @@ fn parse(tokens: &const ArrayList(Token), token_index: &usize) ParseError!Node {
109109 }
110110}
111111
112fn expandString(input: []const u8, output: &Buffer) !void {
112fn expandString(input: []const u8, output: *Buffer) !void {
113113 const tokens = try tokenize(input);
114114 if (tokens.len == 1) {
115115 return output.resize(0);
......@@ -139,7 +139,7 @@ fn expandString(input: []const u8, output: &Buffer) !void {
139139
140140const ExpandNodeError = error{OutOfMemory};
141141
142fn expandNode(node: &const Node, output: &ArrayList(Buffer)) ExpandNodeError!void {
142fn expandNode(node: *const Node, output: *ArrayList(Buffer)) ExpandNodeError!void {
143143 assert(output.len == 0);
144144 switch (node.*) {
145145 Node.Scalar => |scalar| {
test/standalone/issue_339/build.zig+1-1
......@@ -1,6 +1,6 @@
11const Builder = @import("std").build.Builder;
22
3pub fn build(b: &Builder) void {
3pub fn build(b: *Builder) void {
44 const obj = b.addObject("test", "test.zig");
55
66 const test_step = b.step("test", "Test the program");
test/standalone/issue_339/test.zig+1-1
......@@ -1,5 +1,5 @@
11const StackTrace = @import("builtin").StackTrace;
2pub fn panic(msg: []const u8, stack_trace: ?&StackTrace) noreturn {
2pub fn panic(msg: []const u8, stack_trace: ?*StackTrace) noreturn {
33 @breakpoint();
44 while (true) {}
55}
test/standalone/issue_794/build.zig+1-1
......@@ -1,6 +1,6 @@
11const Builder = @import("std").build.Builder;
22
3pub fn build(b: &Builder) void {
3pub fn build(b: *Builder) void {
44 const test_artifact = b.addTest("main.zig");
55 test_artifact.addIncludeDir("a_directory");
66
test/standalone/pkg_import/build.zig+1-1
......@@ -1,6 +1,6 @@
11const Builder = @import("std").build.Builder;
22
3pub fn build(b: &Builder) void {
3pub fn build(b: *Builder) void {
44 const exe = b.addExecutable("test", "test.zig");
55 exe.addPackagePath("my_pkg", "pkg.zig");
66
test/standalone/use_alias/build.zig+1-1
......@@ -1,6 +1,6 @@
11const Builder = @import("std").build.Builder;
22
3pub fn build(b: &Builder) void {
3pub fn build(b: *Builder) void {
44 b.addCIncludePath(".");
55
66 const main = b.addTest("main.zig");
test/tests.zig+68-68
......@@ -47,7 +47,7 @@ const test_targets = []TestTarget{
4747
4848const max_stdout_size = 1 * 1024 * 1024; // 1 MB
4949
50pub fn addCompareOutputTests(b: &build.Builder, test_filter: ?[]const u8) &build.Step {
50pub fn addCompareOutputTests(b: *build.Builder, test_filter: ?[]const u8) *build.Step {
5151 const cases = b.allocator.create(CompareOutputContext) catch unreachable;
5252 cases.* = CompareOutputContext{
5353 .b = b,
......@@ -61,7 +61,7 @@ pub fn addCompareOutputTests(b: &build.Builder, test_filter: ?[]const u8) &build
6161 return cases.step;
6262}
6363
64pub fn addRuntimeSafetyTests(b: &build.Builder, test_filter: ?[]const u8) &build.Step {
64pub fn addRuntimeSafetyTests(b: *build.Builder, test_filter: ?[]const u8) *build.Step {
6565 const cases = b.allocator.create(CompareOutputContext) catch unreachable;
6666 cases.* = CompareOutputContext{
6767 .b = b,
......@@ -75,7 +75,7 @@ pub fn addRuntimeSafetyTests(b: &build.Builder, test_filter: ?[]const u8) &build
7575 return cases.step;
7676}
7777
78pub fn addCompileErrorTests(b: &build.Builder, test_filter: ?[]const u8) &build.Step {
78pub fn addCompileErrorTests(b: *build.Builder, test_filter: ?[]const u8) *build.Step {
7979 const cases = b.allocator.create(CompileErrorContext) catch unreachable;
8080 cases.* = CompileErrorContext{
8181 .b = b,
......@@ -89,7 +89,7 @@ pub fn addCompileErrorTests(b: &build.Builder, test_filter: ?[]const u8) &build.
8989 return cases.step;
9090}
9191
92pub fn addBuildExampleTests(b: &build.Builder, test_filter: ?[]const u8) &build.Step {
92pub fn addBuildExampleTests(b: *build.Builder, test_filter: ?[]const u8) *build.Step {
9393 const cases = b.allocator.create(BuildExamplesContext) catch unreachable;
9494 cases.* = BuildExamplesContext{
9595 .b = b,
......@@ -103,7 +103,7 @@ pub fn addBuildExampleTests(b: &build.Builder, test_filter: ?[]const u8) &build.
103103 return cases.step;
104104}
105105
106pub fn addAssembleAndLinkTests(b: &build.Builder, test_filter: ?[]const u8) &build.Step {
106pub fn addAssembleAndLinkTests(b: *build.Builder, test_filter: ?[]const u8) *build.Step {
107107 const cases = b.allocator.create(CompareOutputContext) catch unreachable;
108108 cases.* = CompareOutputContext{
109109 .b = b,
......@@ -117,7 +117,7 @@ pub fn addAssembleAndLinkTests(b: &build.Builder, test_filter: ?[]const u8) &bui
117117 return cases.step;
118118}
119119
120pub fn addTranslateCTests(b: &build.Builder, test_filter: ?[]const u8) &build.Step {
120pub fn addTranslateCTests(b: *build.Builder, test_filter: ?[]const u8) *build.Step {
121121 const cases = b.allocator.create(TranslateCContext) catch unreachable;
122122 cases.* = TranslateCContext{
123123 .b = b,
......@@ -131,7 +131,7 @@ pub fn addTranslateCTests(b: &build.Builder, test_filter: ?[]const u8) &build.St
131131 return cases.step;
132132}
133133
134pub fn addGenHTests(b: &build.Builder, test_filter: ?[]const u8) &build.Step {
134pub fn addGenHTests(b: *build.Builder, test_filter: ?[]const u8) *build.Step {
135135 const cases = b.allocator.create(GenHContext) catch unreachable;
136136 cases.* = GenHContext{
137137 .b = b,
......@@ -145,7 +145,7 @@ pub fn addGenHTests(b: &build.Builder, test_filter: ?[]const u8) &build.Step {
145145 return cases.step;
146146}
147147
148pub fn addPkgTests(b: &build.Builder, test_filter: ?[]const u8, root_src: []const u8, name: []const u8, desc: []const u8, with_lldb: bool) &build.Step {
148pub fn addPkgTests(b: *build.Builder, test_filter: ?[]const u8, root_src: []const u8, name: []const u8, desc: []const u8, with_lldb: bool) *build.Step {
149149 const step = b.step(b.fmt("test-{}", name), desc);
150150 for (test_targets) |test_target| {
151151 const is_native = (test_target.os == builtin.os and test_target.arch == builtin.arch);
......@@ -193,8 +193,8 @@ pub fn addPkgTests(b: &build.Builder, test_filter: ?[]const u8, root_src: []cons
193193}
194194
195195pub const CompareOutputContext = struct {
196 b: &build.Builder,
197 step: &build.Step,
196 b: *build.Builder,
197 step: *build.Step,
198198 test_index: usize,
199199 test_filter: ?[]const u8,
200200
......@@ -217,28 +217,28 @@ pub const CompareOutputContext = struct {
217217 source: []const u8,
218218 };
219219
220 pub fn addSourceFile(self: &TestCase, filename: []const u8, source: []const u8) void {
220 pub fn addSourceFile(self: *TestCase, filename: []const u8, source: []const u8) void {
221221 self.sources.append(SourceFile{
222222 .filename = filename,
223223 .source = source,
224224 }) catch unreachable;
225225 }
226226
227 pub fn setCommandLineArgs(self: &TestCase, args: []const []const u8) void {
227 pub fn setCommandLineArgs(self: *TestCase, args: []const []const u8) void {
228228 self.cli_args = args;
229229 }
230230 };
231231
232232 const RunCompareOutputStep = struct {
233233 step: build.Step,
234 context: &CompareOutputContext,
234 context: *CompareOutputContext,
235235 exe_path: []const u8,
236236 name: []const u8,
237237 expected_output: []const u8,
238238 test_index: usize,
239239 cli_args: []const []const u8,
240240
241 pub fn create(context: &CompareOutputContext, exe_path: []const u8, name: []const u8, expected_output: []const u8, cli_args: []const []const u8) &RunCompareOutputStep {
241 pub fn create(context: *CompareOutputContext, exe_path: []const u8, name: []const u8, expected_output: []const u8, cli_args: []const []const u8) *RunCompareOutputStep {
242242 const allocator = context.b.allocator;
243243 const ptr = allocator.create(RunCompareOutputStep) catch unreachable;
244244 ptr.* = RunCompareOutputStep{
......@@ -254,7 +254,7 @@ pub const CompareOutputContext = struct {
254254 return ptr;
255255 }
256256
257 fn make(step: &build.Step) !void {
257 fn make(step: *build.Step) !void {
258258 const self = @fieldParentPtr(RunCompareOutputStep, "step", step);
259259 const b = self.context.b;
260260
......@@ -321,12 +321,12 @@ pub const CompareOutputContext = struct {
321321
322322 const RuntimeSafetyRunStep = struct {
323323 step: build.Step,
324 context: &CompareOutputContext,
324 context: *CompareOutputContext,
325325 exe_path: []const u8,
326326 name: []const u8,
327327 test_index: usize,
328328
329 pub fn create(context: &CompareOutputContext, exe_path: []const u8, name: []const u8) &RuntimeSafetyRunStep {
329 pub fn create(context: *CompareOutputContext, exe_path: []const u8, name: []const u8) *RuntimeSafetyRunStep {
330330 const allocator = context.b.allocator;
331331 const ptr = allocator.create(RuntimeSafetyRunStep) catch unreachable;
332332 ptr.* = RuntimeSafetyRunStep{
......@@ -340,7 +340,7 @@ pub const CompareOutputContext = struct {
340340 return ptr;
341341 }
342342
343 fn make(step: &build.Step) !void {
343 fn make(step: *build.Step) !void {
344344 const self = @fieldParentPtr(RuntimeSafetyRunStep, "step", step);
345345 const b = self.context.b;
346346
......@@ -382,7 +382,7 @@ pub const CompareOutputContext = struct {
382382 }
383383 };
384384
385 pub fn createExtra(self: &CompareOutputContext, name: []const u8, source: []const u8, expected_output: []const u8, special: Special) TestCase {
385 pub fn createExtra(self: *CompareOutputContext, name: []const u8, source: []const u8, expected_output: []const u8, special: Special) TestCase {
386386 var tc = TestCase{
387387 .name = name,
388388 .sources = ArrayList(TestCase.SourceFile).init(self.b.allocator),
......@@ -396,32 +396,32 @@ pub const CompareOutputContext = struct {
396396 return tc;
397397 }
398398
399 pub fn create(self: &CompareOutputContext, name: []const u8, source: []const u8, expected_output: []const u8) TestCase {
399 pub fn create(self: *CompareOutputContext, name: []const u8, source: []const u8, expected_output: []const u8) TestCase {
400400 return createExtra(self, name, source, expected_output, Special.None);
401401 }
402402
403 pub fn addC(self: &CompareOutputContext, name: []const u8, source: []const u8, expected_output: []const u8) void {
403 pub fn addC(self: *CompareOutputContext, name: []const u8, source: []const u8, expected_output: []const u8) void {
404404 var tc = self.create(name, source, expected_output);
405405 tc.link_libc = true;
406406 self.addCase(tc);
407407 }
408408
409 pub fn add(self: &CompareOutputContext, name: []const u8, source: []const u8, expected_output: []const u8) void {
409 pub fn add(self: *CompareOutputContext, name: []const u8, source: []const u8, expected_output: []const u8) void {
410410 const tc = self.create(name, source, expected_output);
411411 self.addCase(tc);
412412 }
413413
414 pub fn addAsm(self: &CompareOutputContext, name: []const u8, source: []const u8, expected_output: []const u8) void {
414 pub fn addAsm(self: *CompareOutputContext, name: []const u8, source: []const u8, expected_output: []const u8) void {
415415 const tc = self.createExtra(name, source, expected_output, Special.Asm);
416416 self.addCase(tc);
417417 }
418418
419 pub fn addRuntimeSafety(self: &CompareOutputContext, name: []const u8, source: []const u8) void {
419 pub fn addRuntimeSafety(self: *CompareOutputContext, name: []const u8, source: []const u8) void {
420420 const tc = self.createExtra(name, source, undefined, Special.RuntimeSafety);
421421 self.addCase(tc);
422422 }
423423
424 pub fn addCase(self: &CompareOutputContext, case: &const TestCase) void {
424 pub fn addCase(self: *CompareOutputContext, case: *const TestCase) void {
425425 const b = self.b;
426426
427427 const root_src = os.path.join(b.allocator, b.cache_root, case.sources.items[0].filename) catch unreachable;
......@@ -504,8 +504,8 @@ pub const CompareOutputContext = struct {
504504};
505505
506506pub const CompileErrorContext = struct {
507 b: &build.Builder,
508 step: &build.Step,
507 b: *build.Builder,
508 step: *build.Step,
509509 test_index: usize,
510510 test_filter: ?[]const u8,
511511
......@@ -521,27 +521,27 @@ pub const CompileErrorContext = struct {
521521 source: []const u8,
522522 };
523523
524 pub fn addSourceFile(self: &TestCase, filename: []const u8, source: []const u8) void {
524 pub fn addSourceFile(self: *TestCase, filename: []const u8, source: []const u8) void {
525525 self.sources.append(SourceFile{
526526 .filename = filename,
527527 .source = source,
528528 }) catch unreachable;
529529 }
530530
531 pub fn addExpectedError(self: &TestCase, text: []const u8) void {
531 pub fn addExpectedError(self: *TestCase, text: []const u8) void {
532532 self.expected_errors.append(text) catch unreachable;
533533 }
534534 };
535535
536536 const CompileCmpOutputStep = struct {
537537 step: build.Step,
538 context: &CompileErrorContext,
538 context: *CompileErrorContext,
539539 name: []const u8,
540540 test_index: usize,
541 case: &const TestCase,
541 case: *const TestCase,
542542 build_mode: Mode,
543543
544 pub fn create(context: &CompileErrorContext, name: []const u8, case: &const TestCase, build_mode: Mode) &CompileCmpOutputStep {
544 pub fn create(context: *CompileErrorContext, name: []const u8, case: *const TestCase, build_mode: Mode) *CompileCmpOutputStep {
545545 const allocator = context.b.allocator;
546546 const ptr = allocator.create(CompileCmpOutputStep) catch unreachable;
547547 ptr.* = CompileCmpOutputStep{
......@@ -556,7 +556,7 @@ pub const CompileErrorContext = struct {
556556 return ptr;
557557 }
558558
559 fn make(step: &build.Step) !void {
559 fn make(step: *build.Step) !void {
560560 const self = @fieldParentPtr(CompileCmpOutputStep, "step", step);
561561 const b = self.context.b;
562562
......@@ -661,7 +661,7 @@ pub const CompileErrorContext = struct {
661661 warn("\n");
662662 }
663663
664 pub fn create(self: &CompileErrorContext, name: []const u8, source: []const u8, expected_lines: ...) &TestCase {
664 pub fn create(self: *CompileErrorContext, name: []const u8, source: []const u8, expected_lines: ...) *TestCase {
665665 const tc = self.b.allocator.create(TestCase) catch unreachable;
666666 tc.* = TestCase{
667667 .name = name,
......@@ -678,24 +678,24 @@ pub const CompileErrorContext = struct {
678678 return tc;
679679 }
680680
681 pub fn addC(self: &CompileErrorContext, name: []const u8, source: []const u8, expected_lines: ...) void {
681 pub fn addC(self: *CompileErrorContext, name: []const u8, source: []const u8, expected_lines: ...) void {
682682 var tc = self.create(name, source, expected_lines);
683683 tc.link_libc = true;
684684 self.addCase(tc);
685685 }
686686
687 pub fn addExe(self: &CompileErrorContext, name: []const u8, source: []const u8, expected_lines: ...) void {
687 pub fn addExe(self: *CompileErrorContext, name: []const u8, source: []const u8, expected_lines: ...) void {
688688 var tc = self.create(name, source, expected_lines);
689689 tc.is_exe = true;
690690 self.addCase(tc);
691691 }
692692
693 pub fn add(self: &CompileErrorContext, name: []const u8, source: []const u8, expected_lines: ...) void {
693 pub fn add(self: *CompileErrorContext, name: []const u8, source: []const u8, expected_lines: ...) void {
694694 const tc = self.create(name, source, expected_lines);
695695 self.addCase(tc);
696696 }
697697
698 pub fn addCase(self: &CompileErrorContext, case: &const TestCase) void {
698 pub fn addCase(self: *CompileErrorContext, case: *const TestCase) void {
699699 const b = self.b;
700700
701701 for ([]Mode{
......@@ -720,20 +720,20 @@ pub const CompileErrorContext = struct {
720720};
721721
722722pub const BuildExamplesContext = struct {
723 b: &build.Builder,
724 step: &build.Step,
723 b: *build.Builder,
724 step: *build.Step,
725725 test_index: usize,
726726 test_filter: ?[]const u8,
727727
728 pub fn addC(self: &BuildExamplesContext, root_src: []const u8) void {
728 pub fn addC(self: *BuildExamplesContext, root_src: []const u8) void {
729729 self.addAllArgs(root_src, true);
730730 }
731731
732 pub fn add(self: &BuildExamplesContext, root_src: []const u8) void {
732 pub fn add(self: *BuildExamplesContext, root_src: []const u8) void {
733733 self.addAllArgs(root_src, false);
734734 }
735735
736 pub fn addBuildFile(self: &BuildExamplesContext, build_file: []const u8) void {
736 pub fn addBuildFile(self: *BuildExamplesContext, build_file: []const u8) void {
737737 const b = self.b;
738738
739739 const annotated_case_name = b.fmt("build {} (Debug)", build_file);
......@@ -763,7 +763,7 @@ pub const BuildExamplesContext = struct {
763763 self.step.dependOn(&log_step.step);
764764 }
765765
766 pub fn addAllArgs(self: &BuildExamplesContext, root_src: []const u8, link_libc: bool) void {
766 pub fn addAllArgs(self: *BuildExamplesContext, root_src: []const u8, link_libc: bool) void {
767767 const b = self.b;
768768
769769 for ([]Mode{
......@@ -792,8 +792,8 @@ pub const BuildExamplesContext = struct {
792792};
793793
794794pub const TranslateCContext = struct {
795 b: &build.Builder,
796 step: &build.Step,
795 b: *build.Builder,
796 step: *build.Step,
797797 test_index: usize,
798798 test_filter: ?[]const u8,
799799
......@@ -808,26 +808,26 @@ pub const TranslateCContext = struct {
808808 source: []const u8,
809809 };
810810
811 pub fn addSourceFile(self: &TestCase, filename: []const u8, source: []const u8) void {
811 pub fn addSourceFile(self: *TestCase, filename: []const u8, source: []const u8) void {
812812 self.sources.append(SourceFile{
813813 .filename = filename,
814814 .source = source,
815815 }) catch unreachable;
816816 }
817817
818 pub fn addExpectedLine(self: &TestCase, text: []const u8) void {
818 pub fn addExpectedLine(self: *TestCase, text: []const u8) void {
819819 self.expected_lines.append(text) catch unreachable;
820820 }
821821 };
822822
823823 const TranslateCCmpOutputStep = struct {
824824 step: build.Step,
825 context: &TranslateCContext,
825 context: *TranslateCContext,
826826 name: []const u8,
827827 test_index: usize,
828 case: &const TestCase,
828 case: *const TestCase,
829829
830 pub fn create(context: &TranslateCContext, name: []const u8, case: &const TestCase) &TranslateCCmpOutputStep {
830 pub fn create(context: *TranslateCContext, name: []const u8, case: *const TestCase) *TranslateCCmpOutputStep {
831831 const allocator = context.b.allocator;
832832 const ptr = allocator.create(TranslateCCmpOutputStep) catch unreachable;
833833 ptr.* = TranslateCCmpOutputStep{
......@@ -841,7 +841,7 @@ pub const TranslateCContext = struct {
841841 return ptr;
842842 }
843843
844 fn make(step: &build.Step) !void {
844 fn make(step: *build.Step) !void {
845845 const self = @fieldParentPtr(TranslateCCmpOutputStep, "step", step);
846846 const b = self.context.b;
847847
......@@ -935,7 +935,7 @@ pub const TranslateCContext = struct {
935935 warn("\n");
936936 }
937937
938 pub fn create(self: &TranslateCContext, allow_warnings: bool, filename: []const u8, name: []const u8, source: []const u8, expected_lines: ...) &TestCase {
938 pub fn create(self: *TranslateCContext, allow_warnings: bool, filename: []const u8, name: []const u8, source: []const u8, expected_lines: ...) *TestCase {
939939 const tc = self.b.allocator.create(TestCase) catch unreachable;
940940 tc.* = TestCase{
941941 .name = name,
......@@ -951,22 +951,22 @@ pub const TranslateCContext = struct {
951951 return tc;
952952 }
953953
954 pub fn add(self: &TranslateCContext, name: []const u8, source: []const u8, expected_lines: ...) void {
954 pub fn add(self: *TranslateCContext, name: []const u8, source: []const u8, expected_lines: ...) void {
955955 const tc = self.create(false, "source.h", name, source, expected_lines);
956956 self.addCase(tc);
957957 }
958958
959 pub fn addC(self: &TranslateCContext, name: []const u8, source: []const u8, expected_lines: ...) void {
959 pub fn addC(self: *TranslateCContext, name: []const u8, source: []const u8, expected_lines: ...) void {
960960 const tc = self.create(false, "source.c", name, source, expected_lines);
961961 self.addCase(tc);
962962 }
963963
964 pub fn addAllowWarnings(self: &TranslateCContext, name: []const u8, source: []const u8, expected_lines: ...) void {
964 pub fn addAllowWarnings(self: *TranslateCContext, name: []const u8, source: []const u8, expected_lines: ...) void {
965965 const tc = self.create(true, "source.h", name, source, expected_lines);
966966 self.addCase(tc);
967967 }
968968
969 pub fn addCase(self: &TranslateCContext, case: &const TestCase) void {
969 pub fn addCase(self: *TranslateCContext, case: *const TestCase) void {
970970 const b = self.b;
971971
972972 const annotated_case_name = fmt.allocPrint(self.b.allocator, "translate-c {}", case.name) catch unreachable;
......@@ -986,8 +986,8 @@ pub const TranslateCContext = struct {
986986};
987987
988988pub const GenHContext = struct {
989 b: &build.Builder,
990 step: &build.Step,
989 b: *build.Builder,
990 step: *build.Step,
991991 test_index: usize,
992992 test_filter: ?[]const u8,
993993
......@@ -1001,27 +1001,27 @@ pub const GenHContext = struct {
10011001 source: []const u8,
10021002 };
10031003
1004 pub fn addSourceFile(self: &TestCase, filename: []const u8, source: []const u8) void {
1004 pub fn addSourceFile(self: *TestCase, filename: []const u8, source: []const u8) void {
10051005 self.sources.append(SourceFile{
10061006 .filename = filename,
10071007 .source = source,
10081008 }) catch unreachable;
10091009 }
10101010
1011 pub fn addExpectedLine(self: &TestCase, text: []const u8) void {
1011 pub fn addExpectedLine(self: *TestCase, text: []const u8) void {
10121012 self.expected_lines.append(text) catch unreachable;
10131013 }
10141014 };
10151015
10161016 const GenHCmpOutputStep = struct {
10171017 step: build.Step,
1018 context: &GenHContext,
1018 context: *GenHContext,
10191019 h_path: []const u8,
10201020 name: []const u8,
10211021 test_index: usize,
1022 case: &const TestCase,
1022 case: *const TestCase,
10231023
1024 pub fn create(context: &GenHContext, h_path: []const u8, name: []const u8, case: &const TestCase) &GenHCmpOutputStep {
1024 pub fn create(context: *GenHContext, h_path: []const u8, name: []const u8, case: *const TestCase) *GenHCmpOutputStep {
10251025 const allocator = context.b.allocator;
10261026 const ptr = allocator.create(GenHCmpOutputStep) catch unreachable;
10271027 ptr.* = GenHCmpOutputStep{
......@@ -1036,7 +1036,7 @@ pub const GenHContext = struct {
10361036 return ptr;
10371037 }
10381038
1039 fn make(step: &build.Step) !void {
1039 fn make(step: *build.Step) !void {
10401040 const self = @fieldParentPtr(GenHCmpOutputStep, "step", step);
10411041 const b = self.context.b;
10421042
......@@ -1069,7 +1069,7 @@ pub const GenHContext = struct {
10691069 warn("\n");
10701070 }
10711071
1072 pub fn create(self: &GenHContext, filename: []const u8, name: []const u8, source: []const u8, expected_lines: ...) &TestCase {
1072 pub fn create(self: *GenHContext, filename: []const u8, name: []const u8, source: []const u8, expected_lines: ...) *TestCase {
10731073 const tc = self.b.allocator.create(TestCase) catch unreachable;
10741074 tc.* = TestCase{
10751075 .name = name,
......@@ -1084,12 +1084,12 @@ pub const GenHContext = struct {
10841084 return tc;
10851085 }
10861086
1087 pub fn add(self: &GenHContext, name: []const u8, source: []const u8, expected_lines: ...) void {
1087 pub fn add(self: *GenHContext, name: []const u8, source: []const u8, expected_lines: ...) void {
10881088 const tc = self.create("test.zig", name, source, expected_lines);
10891089 self.addCase(tc);
10901090 }
10911091
1092 pub fn addCase(self: &GenHContext, case: &const TestCase) void {
1092 pub fn addCase(self: *GenHContext, case: *const TestCase) void {
10931093 const b = self.b;
10941094 const root_src = os.path.join(b.allocator, b.cache_root, case.sources.items[0].filename) catch unreachable;
10951095
test/translate_c.zig+29-29
......@@ -1,6 +1,6 @@
11const tests = @import("tests.zig");
22
3pub fn addCases(cases: &tests.TranslateCContext) void {
3pub fn addCases(cases: *tests.TranslateCContext) void {
44 cases.add("double define struct",
55 \\typedef struct Bar Bar;
66 \\typedef struct Foo Foo;
......@@ -14,11 +14,11 @@ pub fn addCases(cases: &tests.TranslateCContext) void {
1414 \\};
1515 ,
1616 \\pub const struct_Foo = extern struct {
17 \\ a: ?&Foo,
17 \\ a: ?*Foo,
1818 \\};
1919 \\pub const Foo = struct_Foo;
2020 \\pub const struct_Bar = extern struct {
21 \\ a: ?&Foo,
21 \\ a: ?*Foo,
2222 \\};
2323 );
2424
......@@ -99,7 +99,7 @@ pub fn addCases(cases: &tests.TranslateCContext) void {
9999 cases.add("restrict -> noalias",
100100 \\void foo(void *restrict bar, void *restrict);
101101 ,
102 \\pub extern fn foo(noalias bar: ?&c_void, noalias arg1: ?&c_void) void;
102 \\pub extern fn foo(noalias bar: ?*c_void, noalias arg1: ?*c_void) void;
103103 );
104104
105105 cases.add("simple struct",
......@@ -110,7 +110,7 @@ pub fn addCases(cases: &tests.TranslateCContext) void {
110110 ,
111111 \\const struct_Foo = extern struct {
112112 \\ x: c_int,
113 \\ y: ?&u8,
113 \\ y: ?*u8,
114114 \\};
115115 ,
116116 \\pub const Foo = struct_Foo;
......@@ -141,7 +141,7 @@ pub fn addCases(cases: &tests.TranslateCContext) void {
141141 ,
142142 \\pub const BarB = enum_Bar.B;
143143 ,
144 \\pub extern fn func(a: ?&struct_Foo, b: ?&(?&enum_Bar)) void;
144 \\pub extern fn func(a: ?*struct_Foo, b: ?*(?*enum_Bar)) void;
145145 ,
146146 \\pub const Foo = struct_Foo;
147147 ,
......@@ -151,7 +151,7 @@ pub fn addCases(cases: &tests.TranslateCContext) void {
151151 cases.add("constant size array",
152152 \\void func(int array[20]);
153153 ,
154 \\pub extern fn func(array: ?&c_int) void;
154 \\pub extern fn func(array: ?*c_int) void;
155155 );
156156
157157 cases.add("self referential struct with function pointer",
......@@ -160,7 +160,7 @@ pub fn addCases(cases: &tests.TranslateCContext) void {
160160 \\};
161161 ,
162162 \\pub const struct_Foo = extern struct {
163 \\ derp: ?extern fn(?&struct_Foo) void,
163 \\ derp: ?extern fn(?*struct_Foo) void,
164164 \\};
165165 ,
166166 \\pub const Foo = struct_Foo;
......@@ -172,7 +172,7 @@ pub fn addCases(cases: &tests.TranslateCContext) void {
172172 ,
173173 \\pub const struct_Foo = @OpaqueType();
174174 ,
175 \\pub extern fn some_func(foo: ?&struct_Foo, x: c_int) ?&struct_Foo;
175 \\pub extern fn some_func(foo: ?*struct_Foo, x: c_int) ?*struct_Foo;
176176 ,
177177 \\pub const Foo = struct_Foo;
178178 );
......@@ -219,11 +219,11 @@ pub fn addCases(cases: &tests.TranslateCContext) void {
219219 \\};
220220 ,
221221 \\pub const struct_Bar = extern struct {
222 \\ next: ?&struct_Foo,
222 \\ next: ?*struct_Foo,
223223 \\};
224224 ,
225225 \\pub const struct_Foo = extern struct {
226 \\ next: ?&struct_Bar,
226 \\ next: ?*struct_Bar,
227227 \\};
228228 );
229229
......@@ -233,7 +233,7 @@ pub fn addCases(cases: &tests.TranslateCContext) void {
233233 ,
234234 \\pub const Foo = c_void;
235235 ,
236 \\pub extern fn fun(a: ?&Foo) Foo;
236 \\pub extern fn fun(a: ?*Foo) Foo;
237237 );
238238
239239 cases.add("generate inline func for #define global extern fn",
......@@ -505,7 +505,7 @@ pub fn addCases(cases: &tests.TranslateCContext) void {
505505 \\ return 6;
506506 \\}
507507 ,
508 \\pub export fn and_or_none_bool(a: c_int, b: f32, c: ?&c_void) c_int {
508 \\pub export fn and_or_none_bool(a: c_int, b: f32, c: ?*c_void) c_int {
509509 \\ if ((a != 0) and (b != 0)) return 0;
510510 \\ if ((b != 0) and (c != null)) return 1;
511511 \\ if ((a != 0) and (c != null)) return 2;
......@@ -607,7 +607,7 @@ pub fn addCases(cases: &tests.TranslateCContext) void {
607607 \\pub const struct_Foo = extern struct {
608608 \\ field: c_int,
609609 \\};
610 \\pub export fn read_field(foo: ?&struct_Foo) c_int {
610 \\pub export fn read_field(foo: ?*struct_Foo) c_int {
611611 \\ return (??foo).field;
612612 \\}
613613 );
......@@ -653,8 +653,8 @@ pub fn addCases(cases: &tests.TranslateCContext) void {
653653 \\ return x;
654654 \\}
655655 ,
656 \\pub export fn foo(x: ?&c_ushort) ?&c_void {
657 \\ return @ptrCast(?&c_void, x);
656 \\pub export fn foo(x: ?*c_ushort) ?*c_void {
657 \\ return @ptrCast(?*c_void, x);
658658 \\}
659659 );
660660
......@@ -674,7 +674,7 @@ pub fn addCases(cases: &tests.TranslateCContext) void {
674674 \\ return 0;
675675 \\}
676676 ,
677 \\pub export fn foo() ?&c_int {
677 \\pub export fn foo() ?*c_int {
678678 \\ return null;
679679 \\}
680680 );
......@@ -983,7 +983,7 @@ pub fn addCases(cases: &tests.TranslateCContext) void {
983983 \\ *x = 1;
984984 \\}
985985 ,
986 \\pub export fn foo(x: ?&c_int) void {
986 \\pub export fn foo(x: ?*c_int) void {
987987 \\ (??x).* = 1;
988988 \\}
989989 );
......@@ -1011,7 +1011,7 @@ pub fn addCases(cases: &tests.TranslateCContext) void {
10111011 ,
10121012 \\pub fn foo() c_int {
10131013 \\ var x: c_int = 1234;
1014 \\ var ptr: ?&c_int = &x;
1014 \\ var ptr: ?*c_int = &x;
10151015 \\ return (??ptr).*;
10161016 \\}
10171017 );
......@@ -1021,7 +1021,7 @@ pub fn addCases(cases: &tests.TranslateCContext) void {
10211021 \\ return "bar";
10221022 \\}
10231023 ,
1024 \\pub fn foo() ?&const u8 {
1024 \\pub fn foo() ?*const u8 {
10251025 \\ return c"bar";
10261026 \\}
10271027 );
......@@ -1150,8 +1150,8 @@ pub fn addCases(cases: &tests.TranslateCContext) void {
11501150 \\ return (float *)a;
11511151 \\}
11521152 ,
1153 \\fn ptrcast(a: ?&c_int) ?&f32 {
1154 \\ return @ptrCast(?&f32, a);
1153 \\fn ptrcast(a: ?*c_int) ?*f32 {
1154 \\ return @ptrCast(?*f32, a);
11551155 \\}
11561156 );
11571157
......@@ -1173,7 +1173,7 @@ pub fn addCases(cases: &tests.TranslateCContext) void {
11731173 \\ return !c;
11741174 \\}
11751175 ,
1176 \\pub fn foo(a: c_int, b: f32, c: ?&c_void) c_int {
1176 \\pub fn foo(a: c_int, b: f32, c: ?*c_void) c_int {
11771177 \\ return !(a == 0);
11781178 \\ return !(a != 0);
11791179 \\ return !(b != 0);
......@@ -1194,7 +1194,7 @@ pub fn addCases(cases: &tests.TranslateCContext) void {
11941194 cases.add("const ptr initializer",
11951195 \\static const char *v0 = "0.0.0";
11961196 ,
1197 \\pub var v0: ?&const u8 = c"0.0.0";
1197 \\pub var v0: ?*const u8 = c"0.0.0";
11981198 );
11991199
12001200 cases.add("static incomplete array inside function",
......@@ -1203,14 +1203,14 @@ pub fn addCases(cases: &tests.TranslateCContext) void {
12031203 \\}
12041204 ,
12051205 \\pub fn foo() void {
1206 \\ const v2: &const u8 = c"2.2.2";
1206 \\ const v2: *const u8 = c"2.2.2";
12071207 \\}
12081208 );
12091209
12101210 cases.add("macro pointer cast",
12111211 \\#define NRF_GPIO ((NRF_GPIO_Type *) NRF_GPIO_BASE)
12121212 ,
1213 \\pub const NRF_GPIO = if (@typeId(@typeOf(NRF_GPIO_BASE)) == @import("builtin").TypeId.Pointer) @ptrCast(&NRF_GPIO_Type, NRF_GPIO_BASE) else if (@typeId(@typeOf(NRF_GPIO_BASE)) == @import("builtin").TypeId.Int) @intToPtr(&NRF_GPIO_Type, NRF_GPIO_BASE) else (&NRF_GPIO_Type)(NRF_GPIO_BASE);
1213 \\pub const NRF_GPIO = if (@typeId(@typeOf(NRF_GPIO_BASE)) == @import("builtin").TypeId.Pointer) @ptrCast(*NRF_GPIO_Type, NRF_GPIO_BASE) else if (@typeId(@typeOf(NRF_GPIO_BASE)) == @import("builtin").TypeId.Int) @intToPtr(*NRF_GPIO_Type, NRF_GPIO_BASE) else (*NRF_GPIO_Type)(NRF_GPIO_BASE);
12141214 );
12151215
12161216 cases.add("if on none bool",
......@@ -1231,7 +1231,7 @@ pub fn addCases(cases: &tests.TranslateCContext) void {
12311231 \\ B,
12321232 \\ C,
12331233 \\};
1234 \\pub fn if_none_bool(a: c_int, b: f32, c: ?&c_void, d: enum_SomeEnum) c_int {
1234 \\pub fn if_none_bool(a: c_int, b: f32, c: ?*c_void, d: enum_SomeEnum) c_int {
12351235 \\ if (a != 0) return 0;
12361236 \\ if (b != 0) return 1;
12371237 \\ if (c != null) return 2;
......@@ -1248,7 +1248,7 @@ pub fn addCases(cases: &tests.TranslateCContext) void {
12481248 \\ return 3;
12491249 \\}
12501250 ,
1251 \\pub fn while_none_bool(a: c_int, b: f32, c: ?&c_void) c_int {
1251 \\pub fn while_none_bool(a: c_int, b: f32, c: ?*c_void) c_int {
12521252 \\ while (a != 0) return 0;
12531253 \\ while (b != 0) return 1;
12541254 \\ while (c != null) return 2;
......@@ -1264,7 +1264,7 @@ pub fn addCases(cases: &tests.TranslateCContext) void {
12641264 \\ return 3;
12651265 \\}
12661266 ,
1267 \\pub fn for_none_bool(a: c_int, b: f32, c: ?&c_void) c_int {
1267 \\pub fn for_none_bool(a: c_int, b: f32, c: ?*c_void) c_int {
12681268 \\ while (a != 0) return 0;
12691269 \\ while (b != 0) return 1;
12701270 \\ while (c != null) return 2;