Skip to content

Commit 0590e47

Browse files
Merge pull request #7684 from roc-lang/improve-zig-comments
more zig comments
2 parents 8ad20f8 + da83509 commit 0590e47

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

src/check/parse/IR.zig

+21-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
//!
2+
//! This file implements the Intermediate Representation (IR) for Roc's parser.
3+
//!
4+
//! The IR provides a structured, tree-based representation of Roc source code after parsing
5+
//!
6+
//! The design uses an arena-based memory allocation strategy with a "multi-list" approach where nodes
7+
//! are stored in a flat list but cross-referenced via indices rather than pointers. This improves
8+
//! memory locality and efficiency.
9+
//!
10+
//! The implementation includes comprehensive facilities for building, manipulating, and traversing
11+
//! the IR, as well as converting it to S-expressions for debugging and visualization.
12+
113
const std = @import("std");
214
const base = @import("../../base.zig");
315
const sexpr = @import("../../base/sexpr.zig");
@@ -19,7 +31,6 @@ tokens: TokenizedBuffer,
1931
store: NodeStore,
2032
errors: []const Diagnostic,
2133

22-
/// deinit the IR's memory
2334
pub fn deinit(self: *IR) void {
2435
defer self.tokens.deinit();
2536
defer self.store.deinit();
@@ -2706,8 +2717,15 @@ pub fn resolve(self: *IR, token: TokenIdx) []const u8 {
27062717
return self.source[@intCast(range.start.offset)..@intCast(range.end.offset)];
27072718
}
27082719

2709-
/// todo -- I'm not sure what this is
2710-
pub const ImportRhs = packed struct { aliased: u1, qualified: u1, num_exposes: u30 };
2720+
/// Contains properties of the thing to the right of the `import` keyword.
2721+
pub const ImportRhs = packed struct {
2722+
/// e.g. 1 in case `SomeModule` is an alias in `import SomeModule exposing [...]`
2723+
aliased: u1,
2724+
/// 1 in case the import is qualified, e.g. `pf` in `import pf.Stdout ...`
2725+
qualified: u1,
2726+
/// The number of things in the exposes list. e.g. 3 in `import SomeModule exposing [a1, a2, a3]`
2727+
num_exposes: u30,
2728+
};
27112729

27122730
// Check that all packed structs are 4 bytes size as they as cast to
27132731
// and from a u32

src/fuzz-cli.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! This is just a silly fuzz test to start getting the infra setup.
2-
//! It shows the basic that other fuzz tests likely should build off of.
2+
//! It shows the basics that other fuzz tests likely should build off of.
33
//!
44
//! Note: Compiling the fuzz tests requires llvm and does not currently work in our nix shell on all systems.
55
//!

src/types.zig

+5-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub const Primitive = union(enum) {
1212
Crash,
1313
};
1414

15-
/// todo
15+
/// All Roc Int types
1616
pub const Int = enum {
1717
U8,
1818
I8,
@@ -25,13 +25,15 @@ pub const Int = enum {
2525
U128,
2626
I128,
2727
};
28-
/// todo
28+
29+
/// All Roc Float types
2930
pub const Float = enum {
3031
F32,
3132
F64,
3233
Dec,
3334
};
34-
/// todo
35+
36+
/// Roc Num types; Int and Float
3537
pub const Num = union(enum) {
3638
Int: Int,
3739
Float: Float,

0 commit comments

Comments
 (0)