(&self, f: &mut fmt::Formatter<'_>)
| 1098 | pub fn is_one(&self) -> bool { |
| 1099 | match self { |
| 1100 | Constant::I8(i) => *i == 1, |
| 1101 | Constant::I16(i) => *i == 1, |
| 1102 | Constant::I32(i) => *i == 1, |
| 1103 | Constant::I64(i) => *i == 1, |
| 1104 | Constant::F32(f) => *f == 1.0, |
| 1105 | Constant::F64(f) => *f == 1.0, |
| 1106 | Constant::Char(c) => *c == '1', |
| 1107 | Constant::Boolean(b) => *b, |
| 1108 | _ => false, // Null, String, Array, Instance are not one |
| 1109 | } |
| 1110 | } |
| 1111 | |
| 1112 | // Helper to get a zero constant of a type compatible with an operand |
| 1113 | // there's NO Integer, Float type use I8, F32, F64 etc. etc. |
| 1114 | pub fn zero_for_operand(op: &Operand) -> Option<Constant> { |
| 1115 | match op { |
| 1116 | Operand::Constant(Constant::I8(_)) => Some(Constant::I8(0)), |
| 1117 | Operand::Constant(Constant::I16(_)) => Some(Constant::I16(0)), |
| 1118 | Operand::Constant(Constant::I32(_)) => Some(Constant::I32(0)), |
| 1119 | Operand::Constant(Constant::I64(_)) => Some(Constant::I64(0)), |
| 1120 | Operand::Constant(Constant::F32(_)) => Some(Constant::F32(0.0)), |
| 1121 | Operand::Constant(Constant::F64(_)) => Some(Constant::F64(0.0)), |
| 1122 | Operand::Constant(Constant::Char(_)) => Some(Constant::Char('\0')), |
nothing calls this directly
no outgoing calls
no test coverage detected