astgen: fix result location for sliced objects

This commit is contained in:
Isaac Freund 2021-03-26 23:39:29 +01:00
parent 22338d7816
commit a217ad59c7
No known key found for this signature in database
GPG Key ID: 86DED400DDFD7A11

View File

@ -436,7 +436,7 @@ pub fn expr(mod: *Module, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) In
.@"for" => return forExpr(mod, scope, rl, node, tree.forFull(node)),
.slice_open => {
const lhs = try expr(mod, scope, .{ .ty = .usize_type }, node_datas[node].lhs);
const lhs = try expr(mod, scope, .ref, node_datas[node].lhs);
const start = try expr(mod, scope, .{ .ty = .usize_type }, node_datas[node].rhs);
const result = try gz.addPlNode(.slice_start, node, zir.Inst.SliceStart{
.lhs = lhs,
@ -445,7 +445,7 @@ pub fn expr(mod: *Module, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) In
return rvalue(mod, scope, rl, result, node);
},
.slice => {
const lhs = try expr(mod, scope, .{ .ty = .usize_type }, node_datas[node].lhs);
const lhs = try expr(mod, scope, .ref, node_datas[node].lhs);
const extra = tree.extraData(node_datas[node].rhs, ast.Node.Slice);
const start = try expr(mod, scope, .{ .ty = .usize_type }, extra.start);
const end = try expr(mod, scope, .{ .ty = .usize_type }, extra.end);
@ -457,7 +457,7 @@ pub fn expr(mod: *Module, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) In
return rvalue(mod, scope, rl, result, node);
},
.slice_sentinel => {
const lhs = try expr(mod, scope, .{ .ty = .usize_type }, node_datas[node].lhs);
const lhs = try expr(mod, scope, .ref, node_datas[node].lhs);
const extra = tree.extraData(node_datas[node].rhs, ast.Node.SliceSentinel);
const start = try expr(mod, scope, .{ .ty = .usize_type }, extra.start);
const end = try expr(mod, scope, .{ .ty = .usize_type }, extra.end);