Skip to content

Commit 212720b

Browse files
committed
Expand == codegen, add basic != codegen
1 parent 3f3d2f4 commit 212720b

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

starstream_compiler/src/codegen.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,14 @@ impl Compiler {
446446
let rhs = self.visit_expr(func, rhs);
447447
match (lhs, rhs) {
448448
(Intermediate::Error, Intermediate::Error) => Intermediate::Error,
449+
(Intermediate::StackI32, Intermediate::StackI32) => {
450+
func.instructions().i32_eq();
451+
Intermediate::StackBool
452+
}
453+
(Intermediate::StackI64, Intermediate::StackI64) => {
454+
func.instructions().i64_eq();
455+
Intermediate::StackBool
456+
}
449457
(Intermediate::StackF64, Intermediate::StackF64) => {
450458
func.instructions().f64_eq();
451459
Intermediate::StackBool
@@ -456,6 +464,29 @@ impl Compiler {
456464
}
457465
}
458466
}
467+
Expr::NotEquals(lhs, rhs) => {
468+
let lhs = self.visit_expr(func, lhs);
469+
let rhs = self.visit_expr(func, rhs);
470+
match (lhs, rhs) {
471+
(Intermediate::Error, Intermediate::Error) => Intermediate::Error,
472+
(Intermediate::StackI32, Intermediate::StackI32) => {
473+
func.instructions().i32_ne();
474+
Intermediate::StackBool
475+
}
476+
(Intermediate::StackI64, Intermediate::StackI64) => {
477+
func.instructions().i64_ne();
478+
Intermediate::StackBool
479+
}
480+
(Intermediate::StackF64, Intermediate::StackF64) => {
481+
func.instructions().f64_ne();
482+
Intermediate::StackBool
483+
}
484+
(lhs, rhs) => {
485+
self.todo(format!("Expr::Equals({:?}, {:?})", lhs, rhs));
486+
Intermediate::Error
487+
}
488+
}
489+
}
459490
Expr::Add(lhs, rhs) => {
460491
let lhs = self.visit_expr(func, lhs);
461492
let rhs = self.visit_expr(func, rhs);

0 commit comments

Comments
 (0)