(
&mut self,
s: S,
d: D,
this_id: NodeID,
parent_id: NodeID,
op: &BinOp,
lhs: &Expr,
rhs: &Expr,
)
| 207 | } |
| 208 | |
| 209 | pub fn bin_op( |
| 210 | &mut self, |
| 211 | s: S, |
| 212 | d: D, |
| 213 | this_id: NodeID, |
| 214 | parent_id: NodeID, |
| 215 | op: &BinOp, |
| 216 | lhs: &Expr, |
| 217 | rhs: &Expr, |
| 218 | ) -> io::Result<()> { |
| 219 | if matches!(op, BinOp::And | BinOp::Or) && !(is_expr_boolean(lhs) && is_expr_boolean(rhs)) { |
| 220 | return self.bin_op( |
| 221 | s, |
| 222 | d, |
| 223 | this_id, |
| 224 | parent_id, |
| 225 | op, |
| 226 | &coerce_condition(lhs), |
| 227 | &coerce_condition(rhs), |
| 228 | ); |
| 229 | } |
| 230 | if let BinOp::Of = op { |
| 231 | if let Expr::Name(name) = lhs { |
| 232 | if let Some(QualifiedName::List(qualified_name, _)) = s.qualify_name(d, name) { |
| 233 | return self.list_index(s, d, this_id, parent_id, &qualified_name, rhs); |
| 234 | } |
| 235 | } |
| 236 | } |
| 237 | if let BinOp::In = op { |
| 238 | if let Expr::Name(name) = rhs { |
| 239 | if let Some(QualifiedName::List(qualified_name, _)) = s.qualify_name(d, name) { |
| 240 | return self.list_contains(s, d, this_id, parent_id, &qualified_name, lhs); |
| 241 | } |
| 242 | } |
| 243 | } |
| 244 | let lhs_id = self.id.new_id(); |
| 245 | let rhs_id = self.id.new_id(); |
| 246 | self.begin_node(Node::new(op.opcode(), this_id).parent_id(parent_id))?; |
| 247 | self.begin_inputs()?; |
| 248 | self.input(s, d, op.lhs(), lhs, lhs_id)?; |
| 249 | self.input(s, d, op.rhs(), rhs, rhs_id)?; |
| 250 | self.end_obj()?; // inputs |
| 251 | self.end_obj()?; // node |
| 252 | self.expr(s, d, lhs, lhs_id, this_id)?; |
| 253 | self.expr(s, d, rhs, rhs_id, this_id) |
| 254 | } |
| 255 | |
| 256 | pub fn list_index( |
| 257 | &mut self, |
no test coverage detected