flags
This commit is contained in:
@@ -147,6 +147,10 @@ pub const Instruction = union(enum) {
|
||||
gt,
|
||||
gte,
|
||||
|
||||
// Bitwise
|
||||
bit_and,
|
||||
bit_or,
|
||||
|
||||
// Logic
|
||||
not,
|
||||
|
||||
@@ -451,6 +455,8 @@ pub const Compiler = struct {
|
||||
.lte => .lte,
|
||||
.gt => .gt,
|
||||
.gte => .gte,
|
||||
.bit_and => .bit_and,
|
||||
.bit_or => .bit_or,
|
||||
.and_op, .or_op => unreachable,
|
||||
});
|
||||
}
|
||||
@@ -1026,6 +1032,20 @@ pub const VM = struct {
|
||||
const a = try self.pop();
|
||||
try self.push(try self.arith(a, b, .mod_op));
|
||||
},
|
||||
.bit_and => {
|
||||
const b = try self.pop();
|
||||
const a = try self.pop();
|
||||
if (a == .int_val and b == .int_val) {
|
||||
try self.push(.{ .int_val = a.int_val & b.int_val });
|
||||
} else return error.TypeError;
|
||||
},
|
||||
.bit_or => {
|
||||
const b = try self.pop();
|
||||
const a = try self.pop();
|
||||
if (a == .int_val and b == .int_val) {
|
||||
try self.push(.{ .int_val = a.int_val | b.int_val });
|
||||
} else return error.TypeError;
|
||||
},
|
||||
.negate => {
|
||||
const v = try self.pop();
|
||||
try self.push(switch (v) {
|
||||
|
||||
Reference in New Issue
Block a user