| ... | @@ -3283,18 +3283,28 @@ fn typeOf( | ... | @@ -3283,18 +3283,28 @@ fn typeOf( |
| 3283 | node: ast.Node.Index, | 3283 | node: ast.Node.Index, |
| 3284 | params: []const ast.Node.Index, | 3284 | params: []const ast.Node.Index, |
| 3285 | ) InnerError!zir.Inst.Ref { | 3285 | ) InnerError!zir.Inst.Ref { |
| 3286 | if (true) @panic("TODO update for zir-memory-layout"); | | |
| 3287 | if (params.len < 1) { | 3286 | if (params.len < 1) { |
| 3288 | return mod.failTok(scope, builtin_token, "expected at least 1 argument, found 0", .{}); | 3287 | return mod.failTok(scope, builtin_token, "expected at least 1 argument, found 0", .{}); |
| 3289 | } | 3288 | } |
| | 3289 | const gz = scope.getGenZir(); |
| 3290 | if (params.len == 1) { | 3290 | if (params.len == 1) { |
| 3291 | return rvalue(mod, scope, rl, try addZIRUnOp(mod, scope, src, .typeof, try expr(mod, scope, .none, params[0]))); | 3291 | return rvalue( |
| | 3292 | mod, |
| | 3293 | scope, |
| | 3294 | rl, |
| | 3295 | try gz.addUnTok(.typeof, try expr(mod, scope, .none, params[0]), node), |
| | 3296 | node, |
| | 3297 | ); |
| 3292 | } | 3298 | } |
| 3293 | const arena = scope.arena(); | 3299 | const arena = scope.arena(); |
| 3294 | var items = try arena.alloc(zir.Inst.Ref, params.len); | 3300 | var items = try arena.alloc(zir.Inst.Ref, params.len); |
| 3295 | for (params) |param, param_i| | 3301 | for (params) |param, param_i| |
| 3296 | items[param_i] = try expr(mod, scope, .none, param); | 3302 | items[param_i] = try expr(mod, scope, .none, param); |
| 3297 | return rvalue(mod, scope, rl, try addZIRInst(mod, scope, src, zir.Inst.TypeOfPeer, .{ .items = items }, .{})); | 3303 | |
| | 3304 | const result = try gz.addPlNode(.typeof_peer, node, zir.Inst.MultiOp{ .operands_len = @intCast(u32, params.len) }); |
| | 3305 | try gz.zir_code.extra.appendSlice(gz.zir_code.gpa, items); |
| | 3306 | |
| | 3307 | return rvalue(mod, scope, rl, result, node); |
| 3298 | } | 3308 | } |
| 3299 | | 3309 | |
| 3300 | fn builtinCall( | 3310 | fn builtinCall( |