Build a stack frame for the given class node if one is needed (which occurs if and only if there are child nodes). Otherwise, return None.
(
&self,
ast: &ClassInduct<'a>,
)
| 404 | /// Build a stack frame for the given class node if one is needed (which |
| 405 | /// occurs if and only if there are child nodes). Otherwise, return None. |
| 406 | fn induct_class( |
| 407 | &self, |
| 408 | ast: &ClassInduct<'a>, |
| 409 | ) -> Option<ClassFrame<'a>> { |
| 410 | match *ast { |
| 411 | ClassInduct::Item(&ast::ClassSetItem::Bracketed(ref x)) => { |
| 412 | match x.kind { |
| 413 | ast::ClassSet::Item(ref item) => { |
| 414 | Some(ClassFrame::Union { |
| 415 | head: item, |
| 416 | tail: &[], |
| 417 | }) |
| 418 | } |
| 419 | ast::ClassSet::BinaryOp(ref op) => { |
| 420 | Some(ClassFrame::Binary { op: op }) |
| 421 | } |
| 422 | } |
| 423 | } |
| 424 | ClassInduct::Item(&ast::ClassSetItem::Union(ref x)) => { |
| 425 | if x.items.is_empty() { |
| 426 | None |
| 427 | } else { |
| 428 | Some(ClassFrame::Union { |
| 429 | head: &x.items[0], |
| 430 | tail: &x.items[1..], |
| 431 | }) |
| 432 | } |
| 433 | } |
| 434 | ClassInduct::BinaryOp(op) => { |
| 435 | Some(ClassFrame::BinaryLHS { |
| 436 | op: op, |
| 437 | lhs: &op.lhs, |
| 438 | rhs: &op.rhs, |
| 439 | }) |
| 440 | } |
| 441 | _ => None, |
| 442 | } |
| 443 | } |
| 444 | |
| 445 | /// Pops the given frame. If the frame has an additional inductive step, |
| 446 | /// then return it, otherwise return `None`. |