aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2020-12-30 22:31:56 -0700
committerAndrew Kelley <andrew@ziglang.org>2020-12-30 21:41:02 -0800
commit3f7d9b5fc19e4081236b3b63aebbc80e1b17f5b5 (patch)
treea577bd97edf5d5da357d576c777861d443210aec /src/Compilation.zig
parent133da8692e80532797dd91b32539cf2175280a95 (diff)
downloadzig-3f7d9b5fc19e4081236b3b63aebbc80e1b17f5b5.tar.gz
zig-3f7d9b5fc19e4081236b3b63aebbc80e1b17f5b5.zip
stage2: rework Value Payload layout
This is the same as the previous commit but for Value instead of Type. Add `Value.castTag` and note that it is preferable to call than `Value.cast`. This matches other abstractions in the codebase. Added a convenience function `Value.Tag.create` which really cleans up the callsites of creating `Value` objects. `Value` tags can now share payload types. This is in preparation for another improvement that I want to do.
Diffstat (limited to 'src/Compilation.zig')
-rw-r--r--src/Compilation.zig11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig
index 11c8303fac..cd3db84ec2 100644
--- a/src/Compilation.zig
+++ b/src/Compilation.zig
@@ -1457,11 +1457,12 @@ pub fn performAllTheWork(self: *Compilation) error{ TimerUnsupported, OutOfMemor
.complete, .codegen_failure_retryable => {
const module = self.bin_file.options.module.?;
- if (decl.typed_value.most_recent.typed_value.val.cast(Value.Payload.Function)) |payload| {
- switch (payload.func.analysis) {
- .queued => module.analyzeFnBody(decl, payload.func) catch |err| switch (err) {
+ if (decl.typed_value.most_recent.typed_value.val.castTag(.function)) |payload| {
+ const func = payload.data;
+ switch (func.analysis) {
+ .queued => module.analyzeFnBody(decl, func) catch |err| switch (err) {
error.AnalysisFail => {
- assert(payload.func.analysis != .in_progress);
+ assert(func.analysis != .in_progress);
continue;
},
error.OutOfMemory => return error.OutOfMemory,
@@ -1475,7 +1476,7 @@ pub fn performAllTheWork(self: *Compilation) error{ TimerUnsupported, OutOfMemor
var decl_arena = decl.typed_value.most_recent.arena.?.promote(module.gpa);
defer decl.typed_value.most_recent.arena.?.* = decl_arena.state;
log.debug("analyze liveness of {}\n", .{decl.name});
- try liveness.analyze(module.gpa, &decl_arena.allocator, payload.func.analysis.success);
+ try liveness.analyze(module.gpa, &decl_arena.allocator, func.analysis.success);
}
assert(decl.typed_value.most_recent.typed_value.ty.hasCodeGenBits());