feat: choice expression nodes extended to full content parsing
This commit is contained in:
parent
066369cc13
commit
aad95a75ee
8 changed files with 380 additions and 165 deletions
65
src/Sema.zig
65
src/Sema.zig
|
|
@ -709,28 +709,21 @@ fn irChoiceBr(sema: *Sema, builder: *Builder, inst: Ir.Inst.Index) InnerError!vo
|
|||
|
||||
for (options_slice) |option_index| {
|
||||
const case_extra = sema.ir.extraData(Ir.Inst.ChoiceBr.Case, @intFromEnum(option_index));
|
||||
const lhs_slice = sema.ir.bodySlice(
|
||||
case_extra.end,
|
||||
case_extra.data.lhs_len,
|
||||
);
|
||||
const mhs_slice = sema.ir.bodySlice(
|
||||
case_extra.end + case_extra.data.lhs_len,
|
||||
case_extra.data.mhs_len,
|
||||
);
|
||||
|
||||
const case_label = try builder.addLabel();
|
||||
branch_labels.appendAssumeCapacity(case_label);
|
||||
|
||||
try builder.addByteOp(.stream_mark);
|
||||
|
||||
switch (case_extra.data.operand_1) {
|
||||
.none => {},
|
||||
else => |content| {
|
||||
const content_inst = sema.resolveInst(content);
|
||||
try builder.ensureLoad(content_inst);
|
||||
try builder.addByteOp(.stream_push);
|
||||
},
|
||||
}
|
||||
switch (case_extra.data.operand_2) {
|
||||
.none => {},
|
||||
else => |content| {
|
||||
const content_inst = sema.resolveInst(content);
|
||||
try builder.ensureLoad(content_inst);
|
||||
try builder.addByteOp(.stream_push);
|
||||
},
|
||||
}
|
||||
|
||||
_ = try analyzeBodyInner(sema, builder, lhs_slice, false);
|
||||
_ = try analyzeBodyInner(sema, builder, mhs_slice, false);
|
||||
try builder.addFixupAbsolute(.br_push, case_label);
|
||||
}
|
||||
|
||||
|
|
@ -740,26 +733,28 @@ fn irChoiceBr(sema: *Sema, builder: *Builder, inst: Ir.Inst.Index) InnerError!vo
|
|||
|
||||
for (options_slice, branch_labels.items) |option_index, label| {
|
||||
const case_extra = sema.ir.extraData(Ir.Inst.ChoiceBr.Case, @intFromEnum(option_index));
|
||||
const body_slice = sema.ir.bodySlice(case_extra.end, case_extra.data.body_len);
|
||||
const lhs_slice = sema.ir.bodySlice(
|
||||
case_extra.end,
|
||||
case_extra.data.lhs_len,
|
||||
);
|
||||
const rhs_slice = sema.ir.bodySlice(
|
||||
case_extra.end +
|
||||
case_extra.data.lhs_len +
|
||||
case_extra.data.mhs_len,
|
||||
case_extra.data.rhs_len,
|
||||
);
|
||||
const body_slice = sema.ir.bodySlice(
|
||||
case_extra.end +
|
||||
case_extra.data.lhs_len +
|
||||
case_extra.data.mhs_len +
|
||||
case_extra.data.rhs_len,
|
||||
case_extra.data.body_len,
|
||||
);
|
||||
|
||||
builder.setLabel(label);
|
||||
|
||||
switch (case_extra.data.operand_1) {
|
||||
.none => {},
|
||||
else => |content| {
|
||||
const content_inst = sema.resolveInst(content);
|
||||
try builder.ensureLoad(content_inst);
|
||||
try builder.addByteOp(.stream_push);
|
||||
},
|
||||
}
|
||||
switch (case_extra.data.operand_3) {
|
||||
.none => {},
|
||||
else => |content| {
|
||||
const content_inst = sema.resolveInst(content);
|
||||
try builder.ensureLoad(content_inst);
|
||||
try builder.addByteOp(.stream_push);
|
||||
},
|
||||
}
|
||||
_ = try analyzeBodyInner(sema, builder, lhs_slice, false);
|
||||
_ = try analyzeBodyInner(sema, builder, rhs_slice, false);
|
||||
try builder.addByteOp(.stream_line);
|
||||
_ = try analyzeBodyInner(sema, builder, body_slice, false);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue