-
-
Notifications
You must be signed in to change notification settings - Fork 338
Basic canonicalize_expr of idents with tests #7806
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
f492e8b
Basic canonicalize_expr of idents with tests
gamebox 94eaaac
BROKEN: CanIR re-design rough draft
gamebox 317e78b
STILL BREAKING - Can Statements
gamebox b3319c0
STILL BREAKING: Fill out more Can IR nodes
gamebox 99fe1d3
Fixed
gamebox 41c6ca8
Fix lints
gamebox db3ee64
Address feedback
gamebox 30bcd46
WIP compiles again
lukewilliamboswell 845ea3c
WIP compiles again
lukewilliamboswell d1dce66
Merge remote-tracking branch 'remote/main' into canonicalize-start
lukewilliamboswell a968750
remove DataSpan file
lukewilliamboswell 05ac3d5
use base.Scratch for Parse.IR.scratch_statements
lukewilliamboswell fce2fc1
use base.Scratch for scratch_tokens in Parse IR
lukewilliamboswell 5421f3d
use base.Scratch for scratch_exprs
lukewilliamboswell d0675bc
use base.Scratch for Parse scratch_patterns, make Scratch top dry
lukewilliamboswell 9021a29
use base.Scratch in Parser scratch_record_fields
lukewilliamboswell 1ed7e2a
use base.Scratch in Parser scratch_pattern_record_fields
lukewilliamboswell e719727
use base.Scratch in Parser scratch_when_branches
lukewilliamboswell c169efe
use base.Scratch in Parser scratch_type_annos
lukewilliamboswell 0b1c2ed
use base.Scratch in Parser scratch_anno_record_fields
lukewilliamboswell 6ad1ec1
use base.Scratch in Parser scratch_exposed_items
lukewilliamboswell 250bed2
use base.Scratch in Parser scratch_where_clauses
lukewilliamboswell 295e63b
use common base.DataSpan
lukewilliamboswell 122ccdc
fix uppercase name for Scratch.zig import
lukewilliamboswell 964d892
rename Self to IR, add some comments
lukewilliamboswell 586f565
try start on Can for Ints
lukewilliamboswell 3808c6a
WIP use snapshots for Can
lukewilliamboswell a261525
WIP implement more Can placeholders
lukewilliamboswell 5620297
add lots of new snapshots to test Can
lukewilliamboswell 6c500da
fix bug with env in Can, implement more sexprs for snapshots
lukewilliamboswell 2a0b566
add more Can SExpr, format type vars using #
lukewilliamboswell c40abe4
fix add and get of type vars in Can Nodes
lukewilliamboswell 4d7870e
cleanup toSExpr for Can Expr's
lukewilliamboswell c80aeab
fix typos, rename expr snapshot folder
lukewilliamboswell ba96581
implement Can for call expressions, and simple strings
lukewilliamboswell e4b9a79
implement psuedo-builtin Str.concat for string interpolation
lukewilliamboswell 6662c99
simplify SExpr for Can Expr's
lukewilliamboswell abf7cc5
implement basic Defs and canonicalize_file
lukewilliamboswell ed13222
improve Can IR, thread region diagnostics through
lukewilliamboswell 203a22d
Merge remote-tracking branch 'remote/main' into canonicalize-start
lukewilliamboswell 9818ceb
refactor Node and NodeStore in Can into separate files
lukewilliamboswell c79f525
Refactor Can.IR -> CIR
lukewilliamboswell dc1b145
rename Can IR -> CIR, remove unused `PendingValueDef`
lukewilliamboswell 72778ca
rename CIR.Expr.RuntimeError and continue refactor to CIR
lukewilliamboswell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
start: u32, | ||
len: u32, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
const std = @import("std"); | ||
const exitOnOom = @import("../collections/utils.zig").exitOnOom; | ||
const DataSpan = @import("./DataSpan.zig"); | ||
|
||
pub fn Scratch(comptime T: type) type { | ||
return struct { | ||
items: std.ArrayListUnmanaged(T), | ||
|
||
const Self = @This(); | ||
const ArrayList = std.ArrayListUnmanaged(T); | ||
|
||
pub fn init(gpa: std.mem.Allocator) Self { | ||
const items = ArrayList.initCapacity(gpa, std.math.ceilPowerOfTwoAssert(usize, 64)) catch |e| exitOnOom(e); | ||
return .{ | ||
.items = items, | ||
}; | ||
} | ||
|
||
pub fn deinit(self: *Self, gpa: std.mem.Allocator) void { | ||
self.items.deinit(gpa); | ||
} | ||
|
||
/// Returns the start position for a new Span of whereClauseIdxs in scratch | ||
pub fn top(self: *Self) u32 { | ||
return @as(u32, @intCast(self.items.len)); | ||
} | ||
|
||
/// Places a new WhereClauseIdx in the scratch. Will panic on OOM. | ||
pub fn append(self: *Self, gpa: std.mem.Allocator, idx: T) void { | ||
self.items.append(gpa, idx) catch |err| exitOnOom(err); | ||
} | ||
|
||
/// Creates a new span starting at start. Moves the items from scratch | ||
/// to extra_data as appropriate. | ||
pub fn spanFromStart(self: *Self, start: u32, gpa: std.mem.Allocator, data: *std.ArrayListUnmanaged(u32)) DataSpan { | ||
const end = self.items.len; | ||
defer self.items.shrinkRetainingCapacity(start); | ||
var i = @as(usize, @intCast(start)); | ||
const data_start = @as(u32, @intCast(data.items.len)); | ||
while (i < end) { | ||
data.append(gpa, self.items[i].id) catch |err| exitOnOom(err); | ||
i += 1; | ||
} | ||
return .{ .span = .{ .start = data_start, .len = @as(u32, @intCast(end)) - start } }; | ||
} | ||
|
||
/// Clears any WhereClauseIds added to scratch from start until the end. | ||
/// Should be used wherever the scratch items will not be used, | ||
/// as in when parsing fails. | ||
pub fn clearFrom(self: *Self, start: u32) void { | ||
self.items.shrinkRetainingCapacity(start); | ||
} | ||
}; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.