aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVallahor <vallahor91@gmail.com>2022-05-26 05:26:10 -0300
committerAndrew Kelley <andrew@ziglang.org>2022-07-19 19:10:11 -0700
commite1d55385ff3916f2a522225c41a239068972fdf4 (patch)
treebeb79c91769191969f316bbac5cab6c9ab02890d /src
parent1a4d00d832ea0c23ce053387fdc7b5976828a295 (diff)
downloadzig-e1d55385ff3916f2a522225c41a239068972fdf4.tar.gz
zig-e1d55385ff3916f2a522225c41a239068972fdf4.zip
add: typeof_builtin (not fully implemented)
Diffstat (limited to 'src')
-rw-r--r--src/Autodoc.zig81
1 files changed, 64 insertions, 17 deletions
diff --git a/src/Autodoc.zig b/src/Autodoc.zig
index db462dea92..9a90d03c2c 100644
--- a/src/Autodoc.zig
+++ b/src/Autodoc.zig
@@ -297,8 +297,7 @@ const DocData = struct {
try w.print("\"", .{});
for (kv.key_ptr.*.sub_file_path) |c| {
if (c == '\\') {
- try w.print("\\", .{});
- try w.print("\\", .{});
+ try w.print("\\\\", .{});
} else {
try w.print("{c}", .{c});
}
@@ -1242,6 +1241,42 @@ fn walkInstruction(
.expr = .{ .typeOf = operand_index },
};
},
+ .typeof_builtin => {
+ // @check: @TypeOf(T)
+ // right now it's only showing the T
+ // a way to solve it could be creating a .call
+ // another way is with a flag to handle it on Frontend
+ const pl_node = data[inst_index].pl_node;
+ const extra = file.zir.extraData(Zir.Inst.Block, pl_node.payload_index);
+ const body = file.zir.extra[extra.end..][extra.data.body_len - 1];
+
+ var operand: DocData.WalkResult = try self.walkRef(
+ file,
+ parent_scope,
+ data[body].@"break".operand,
+ false,
+ );
+
+ return operand;
+ },
+ .type_info => {
+ // @check
+ const un_node = data[inst_index].un_node;
+ const operand = try self.walkRef(
+ file,
+ parent_scope,
+ un_node.operand,
+ need_type,
+ );
+
+ const operand_index = self.exprs.items.len;
+ try self.exprs.append(self.arena, operand.expr);
+
+ return DocData.WalkResult{
+ .typeRef = operand.typeRef,
+ .expr = .{ .typeOf = operand_index },
+ };
+ },
.as_node => {
const pl_node = data[inst_index].pl_node;
const extra = file.zir.extraData(Zir.Inst.As, pl_node.payload_index);
@@ -1534,7 +1569,7 @@ fn walkInstruction(
.expr = .{ .call = call_slot_index },
};
},
- .func, .func_inferred => {
+ .func, .func_inferred, .func_extended => {
const type_slot_index = self.types.items.len;
try self.types.append(self.arena, .{ .Unanalyzed = {} });
@@ -2558,12 +2593,14 @@ fn analyzeFunction(
// TODO: handle scope rules for fn parameters
for (fn_info.param_body[0..fn_info.total_params_len]) |param_index| {
switch (tags[param_index]) {
- else => panicWithContext(
- file,
- param_index,
- "TODO: handle `{s}` in walkInstruction.func\n",
- .{@tagName(tags[param_index])},
- ),
+ else => {
+ panicWithContext(
+ file,
+ param_index,
+ "TODO: handle `{s}` in walkInstruction.func\n",
+ .{@tagName(tags[param_index])},
+ );
+ },
.param_anytype, .param_anytype_comptime => {
// TODO: where are the doc comments?
const str_tok = data[param_index].str_tok;
@@ -2848,17 +2885,27 @@ fn walkRef(
};
},
// TODO: dunno what to do with those
+ // .calling_convention_type => {
+ // return DocData.WalkResult{
+ // .typeRef = .{ .type = @enumToInt(Ref.comptime_int_type) },
+ // .expr = .{ .int = .{ .value = 1 } },
+ // };
+ // },
// .calling_convention_c => {
- // return DocData.WalkResult{ .int = .{
- // .type = @enumToInt(Ref.comptime_int_type),
- // .value = 1,
- // } };
+ // return DocData.WalkResult{
+ // .typeRef = .{ .type = @enumToInt(Ref.comptime_int_type) },
+ // .expr = .{ .int = .{ .value = 1 } },
+ // };
// },
// .calling_convention_inline => {
- // return DocData.WalkResult{ .int = .{
- // .type = @enumToInt(Ref.comptime_int_type),
- // .value = 1,
- // } };
+ // return DocData.WalkResult{
+ // .typeRef = .{ .type = @enumToInt(Ref.comptime_int_type) },
+ // .expr = .{ .int = .{ .value = 1 } },
+ // };
+ // // return DocData.WalkResult{ .int = .{
+ // // .type = @enumToInt(Ref.comptime_int_type),
+ // // .value = 1,
+ // // } };
// },
// .generic_poison => {
// return DocData.WalkResult{ .int = .{