Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more zig comments #7684

Merged
merged 3 commits into from
Mar 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions src/check/parse/IR.zig
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
//!
//! This file implements the Intermediate Representation (IR) for Roc's parser.
//!
//! The IR provides a structured, tree-based representation of Roc source code after parsing
//!
//! The design uses an arena-based memory allocation strategy with a "multi-list" approach where nodes
//! are stored in a flat list but cross-referenced via indices rather than pointers. This improves
//! memory locality and efficiency.
//!
//! The implementation includes comprehensive facilities for building, manipulating, and traversing
//! the IR, as well as converting it to S-expressions for debugging and visualization.
Comment on lines +1 to +11
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heads up; this part was written by claude and edited by me.


const std = @import("std");
const base = @import("../../base.zig");
const sexpr = @import("../../base/sexpr.zig");
Expand All @@ -19,7 +31,6 @@ tokens: TokenizedBuffer,
store: NodeStore,
errors: []const Diagnostic,

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

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

// Check that all packed structs are 4 bytes size as they as cast to
// and from a u32
Expand Down
2 changes: 1 addition & 1 deletion src/fuzz-cli.zig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! This is just a silly fuzz test to start getting the infra setup.
//! It shows the basic that other fuzz tests likely should build off of.
//! It shows the basics that other fuzz tests likely should build off of.
//!
//! Note: Compiling the fuzz tests requires llvm and does not currently work in our nix shell on all systems.
//!
Expand Down
8 changes: 5 additions & 3 deletions src/types.zig
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub const Primitive = union(enum) {
Crash,
};

/// todo
/// All Roc Int types
pub const Int = enum {
U8,
I8,
Expand All @@ -25,13 +25,15 @@ pub const Int = enum {
U128,
I128,
};
/// todo

/// All Roc Float types
pub const Float = enum {
F32,
F64,
Dec,
};
/// todo

/// Roc Num types; Int and Float
pub const Num = union(enum) {
Int: Int,
Float: Float,
Expand Down
Loading