| ... | @@ -33,14 +33,14 @@ pub const Error = struct { | ... | @@ -33,14 +33,14 @@ pub const Error = struct { |
| 33 | node_or_offset: u32, | 33 | node_or_offset: u32, |
| 34 | notes: []Note, | 34 | notes: []Note, |
| 35 | | 35 | |
| 36 | const InitOptions = struct { | 36 | const Options = struct { |
| 37 | msg: []const u8, | 37 | msg: []const u8, |
| 38 | token: Ast.OptionalTokenIndex, | 38 | token: Ast.OptionalTokenIndex, |
| 39 | node_or_offset: u32, | 39 | node_or_offset: u32, |
| 40 | notes: []Note, | 40 | notes: []Note, |
| 41 | }; | 41 | }; |
| 42 | | 42 | |
| 43 | fn init(ast: *const Ast, options: InitOptions) Error { | 43 | fn init(ast: *const Ast, options: Error.Options) Error { |
| 44 | return .{ | 44 | return .{ |
| 45 | .msg = options.msg, | 45 | .msg = options.msg, |
| 46 | .loc = astLoc(ast, options.token, options.node_or_offset), | 46 | .loc = astLoc(ast, options.token, options.node_or_offset), |
| ... | @@ -74,13 +74,13 @@ pub const Error = struct { | ... | @@ -74,13 +74,13 @@ pub const Error = struct { |
| 74 | /// Otherwise, this is a byte offset into `token`. | 74 | /// Otherwise, this is a byte offset into `token`. |
| 75 | node_or_offset: u32, | 75 | node_or_offset: u32, |
| 76 | | 76 | |
| 77 | const InitOptions = struct { | 77 | const Options = struct { |
| 78 | msg: []const u8, | 78 | msg: []const u8, |
| 79 | token: Ast.OptionalTokenIndex, | 79 | token: Ast.OptionalTokenIndex, |
| 80 | node_or_offset: u32, | 80 | node_or_offset: u32, |
| 81 | }; | 81 | }; |
| 82 | | 82 | |
| 83 | fn init(ast: *const Ast, options: @This().InitOptions) @This() { | 83 | fn init(ast: *const Ast, options: Note.Options) @This() { |
| 84 | return .{ | 84 | return .{ |
| 85 | .msg = options.msg, | 85 | .msg = options.msg, |
| 86 | .loc = astLoc(ast, options.token, options.node_or_offset), | 86 | .loc = astLoc(ast, options.token, options.node_or_offset), |
| ... | @@ -200,7 +200,7 @@ pub const Errors = struct { | ... | @@ -200,7 +200,7 @@ pub const Errors = struct { |
| 200 | }; | 200 | }; |
| 201 | }; | 201 | }; |
| 202 | | 202 | |
| 203 | pub const FromSliceOptions = struct { | 203 | pub const Options = struct { |
| 204 | /// Used for scratch allocations. | 204 | /// Used for scratch allocations. |
| 205 | gpa: Allocator, | 205 | gpa: Allocator, |
| 206 | /// Used for allocating errors and results. | 206 | /// Used for allocating errors and results. |
| ... | @@ -218,7 +218,7 @@ pub const FromSliceOptions = struct { | ... | @@ -218,7 +218,7 @@ pub const FromSliceOptions = struct { |
| 218 | /// | 218 | /// |
| 219 | /// Human readable errors are written to `options.errors`. `options.arena` owns the errors, and any | 219 | /// Human readable errors are written to `options.errors`. `options.arena` owns the errors, and any |
| 220 | /// pointers that are part of `T`. | 220 | /// pointers that are part of `T`. |
| 221 | pub fn fromSlice(T: type, options: FromSliceOptions) error{ OutOfMemory, ParseZon }!T { | 221 | pub fn fromSlice(T: type, options: Options) error{ OutOfMemory, ParseZon }!T { |
| 222 | var value: T = undefined; | 222 | var value: T = undefined; |
| 223 | try fromSliceInner(T, &value, false, options); | 223 | try fromSliceInner(T, &value, false, options); |
| 224 | return value; | 224 | return value; |
| ... | @@ -264,7 +264,7 @@ test fromSlice { | ... | @@ -264,7 +264,7 @@ test fromSlice { |
| 264 | | 264 | |
| 265 | /// Like `fromSlice` but the result type may not contain pointers, allowing it to outlive | 265 | /// Like `fromSlice` but the result type may not contain pointers, allowing it to outlive |
| 266 | /// `options.arena`. | 266 | /// `options.arena`. |
| 267 | pub fn fromSliceNoAlloc(T: type, options: FromSliceOptions) error{ OutOfMemory, ParseZon }!T { | 267 | pub fn fromSliceNoAlloc(T: type, options: Options) error{ OutOfMemory, ParseZon }!T { |
| 268 | comptime assert(!requiresAllocator(T)); | 268 | comptime assert(!requiresAllocator(T)); |
| 269 | return fromSlice(T, options); | 269 | return fromSlice(T, options); |
| 270 | } | 270 | } |
| ... | @@ -277,7 +277,7 @@ pub fn fromSliceNoAlloc(T: type, options: FromSliceOptions) error{ OutOfMemory, | ... | @@ -277,7 +277,7 @@ pub fn fromSliceNoAlloc(T: type, options: FromSliceOptions) error{ OutOfMemory, |
| 277 | pub fn updateFromSlice( | 277 | pub fn updateFromSlice( |
| 278 | T: type, | 278 | T: type, |
| 279 | value: *T, | 279 | value: *T, |
| 280 | options: FromSliceOptions, | 280 | options: Options, |
| 281 | ) error{ OutOfMemory, ParseZon }!void { | 281 | ) error{ OutOfMemory, ParseZon }!void { |
| 282 | try fromSliceInner(T, value, true, options); | 282 | try fromSliceInner(T, value, true, options); |
| 283 | } | 283 | } |
| ... | @@ -348,7 +348,7 @@ test updateFromSlice { | ... | @@ -348,7 +348,7 @@ test updateFromSlice { |
| 348 | pub fn updateFromSliceNoAlloc( | 348 | pub fn updateFromSliceNoAlloc( |
| 349 | T: type, | 349 | T: type, |
| 350 | value: *T, | 350 | value: *T, |
| 351 | options: FromSliceOptions, | 351 | options: Options, |
| 352 | ) error{ OutOfMemory, ParseZon }!void { | 352 | ) error{ OutOfMemory, ParseZon }!void { |
| 353 | comptime assert(!requiresAllocator(T)); | 353 | comptime assert(!requiresAllocator(T)); |
| 354 | try fromSliceInner(T, value, true, options); | 354 | try fromSliceInner(T, value, true, options); |
| ... | @@ -358,7 +358,7 @@ fn fromSliceInner( | ... | @@ -358,7 +358,7 @@ fn fromSliceInner( |
| 358 | T: type, | 358 | T: type, |
| 359 | value: *T, | 359 | value: *T, |
| 360 | initialized: bool, | 360 | initialized: bool, |
| 361 | options: FromSliceOptions, | 361 | options: Options, |
| 362 | ) error{ OutOfMemory, ParseZon }!void { | 362 | ) error{ OutOfMemory, ParseZon }!void { |
| 363 | var errors: std.ArrayList(Error) = .empty; | 363 | var errors: std.ArrayList(Error) = .empty; |
| 364 | defer options.errors.items = errors.items; | 364 | defer options.errors.items = errors.items; |