mirror of
https://github.com/ziglang/zig.git
synced 2024-11-15 00:26:57 +00:00
autodoc: Compare operators
This commit is contained in:
parent
2b92c5a23e
commit
3bbf08e98a
@ -1405,6 +1405,30 @@ var zigAnalysis;
|
||||
operator += "**";
|
||||
break;
|
||||
}
|
||||
case "cmp_eq": {
|
||||
operator += "==";
|
||||
break;
|
||||
}
|
||||
case "cmp_neq": {
|
||||
operator += "!=";
|
||||
break;
|
||||
}
|
||||
case "cmp_gt": {
|
||||
operator += ">";
|
||||
break;
|
||||
}
|
||||
case "cmp_gte": {
|
||||
operator += ">=";
|
||||
break;
|
||||
}
|
||||
case "cmp_lt": {
|
||||
operator += "<";
|
||||
break;
|
||||
}
|
||||
case "cmp_lte": {
|
||||
operator += "<=";
|
||||
break;
|
||||
}
|
||||
default:
|
||||
console.log("operator not handled yet or doesn't exist!");
|
||||
}
|
||||
|
@ -1278,6 +1278,50 @@ fn walkInstruction(
|
||||
.expr = .{ .binOpIndex = binop_index },
|
||||
};
|
||||
},
|
||||
// compare operators
|
||||
.cmp_eq,
|
||||
.cmp_neq,
|
||||
.cmp_gt,
|
||||
.cmp_gte,
|
||||
.cmp_lt,
|
||||
.cmp_lte,
|
||||
=> {
|
||||
const pl_node = data[inst_index].pl_node;
|
||||
const extra = file.zir.extraData(Zir.Inst.Bin, pl_node.payload_index);
|
||||
|
||||
const binop_index = self.exprs.items.len;
|
||||
try self.exprs.append(self.arena, .{ .binOp = .{ .lhs = 0, .rhs = 0 } });
|
||||
|
||||
var lhs: DocData.WalkResult = try self.walkRef(
|
||||
file,
|
||||
parent_scope,
|
||||
parent_line,
|
||||
extra.data.lhs,
|
||||
false,
|
||||
);
|
||||
var rhs: DocData.WalkResult = try self.walkRef(
|
||||
file,
|
||||
parent_scope,
|
||||
parent_line,
|
||||
extra.data.rhs,
|
||||
false,
|
||||
);
|
||||
|
||||
const lhs_index = self.exprs.items.len;
|
||||
try self.exprs.append(self.arena, lhs.expr);
|
||||
const rhs_index = self.exprs.items.len;
|
||||
try self.exprs.append(self.arena, rhs.expr);
|
||||
self.exprs.items[binop_index] = .{ .binOp = .{
|
||||
.name = @tagName(tags[inst_index]),
|
||||
.lhs = lhs_index,
|
||||
.rhs = rhs_index,
|
||||
} };
|
||||
|
||||
return DocData.WalkResult{
|
||||
.typeRef = .{ .type = @enumToInt(Ref.bool_type) },
|
||||
.expr = .{ .binOpIndex = binop_index },
|
||||
};
|
||||
},
|
||||
|
||||
// builtin functions
|
||||
.align_of,
|
||||
|
Loading…
Reference in New Issue
Block a user