Skip to content

Commit b47b952

Browse files
authored
Update instruction.rs
1 parent 2f933a8 commit b47b952

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

src/compiler/translator/ir/src/instruction.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ mod const_fold {
7171
int_op: IntOp,
7272
uint_op: UintOp,
7373
bool_op: BoolOp,
74-
) -> Option<ConstantId> // 改为返回 Option
74+
) -> ConstantId
7575
where
7676
FloatOp: Fn(f32, f32) -> f32 + Copy,
7777
IntOp: Fn(i32, i32) -> i32 + Copy,
@@ -83,24 +83,24 @@ mod const_fold {
8383

8484
match (&lhs.value, &rhs.value) {
8585
(&ConstantValue::Float(f1), &ConstantValue::Float(f2)) => {
86-
Some(ir_meta.get_constant_float(float_op(f1, f2)))
86+
ir_meta.get_constant_float(float_op(f1, f2))
8787
}
8888
(&ConstantValue::Int(i1), &ConstantValue::Int(i2)) => {
89-
Some(ir_meta.get_constant_int(int_op(i1, i2)))
89+
ir_meta.get_constant_int(int_op(i1, i2))
9090
}
9191
(&ConstantValue::Uint(u1), &ConstantValue::Uint(u2)) => {
92-
Some(ir_meta.get_constant_uint(uint_op(u1, u2)))
92+
ir_meta.get_constant_uint(uint_op(u1, u2))
9393
}
9494
(&ConstantValue::Bool(b1), &ConstantValue::Bool(b2)) => {
95-
Some(ir_meta.get_constant_bool(bool_op(b1, b2)))
95+
ir_meta.get_constant_bool(bool_op(b1, b2))
9696
}
9797
(&ConstantValue::YuvCsc(_), &ConstantValue::YuvCsc(_)) => {
98-
eprintln!("Warning: Ops not allowed on YUV CSC constants");
99-
None
98+
eprintln!("Error: Binary operation not allowed on YUV CSC constants");
99+
ir_meta.get_constant_int(0) // 返回默认值 0
100100
}
101101
_ => {
102-
eprintln!("Warning: Expected scalars when constant folding a binary op");
103-
None
102+
eprintln!("Error: Expected scalars when constant folding a binary op");
103+
ir_meta.get_constant_int(0) // 返回默认值 0
104104
}
105105
}
106106
}

0 commit comments

Comments
 (0)