(node *ast.ChainNode)
| 658 | } |
| 659 | |
| 660 | func (c *compiler) ChainNode(node *ast.ChainNode) { |
| 661 | c.chains = append(c.chains, []int{}) |
| 662 | c.compile(node.Node) |
| 663 | for _, ph := range c.chains[len(c.chains)-1] { |
| 664 | c.patchJump(ph) // If chain activated jump here (got nit somewhere). |
| 665 | } |
| 666 | parent := c.nodeParent() |
| 667 | if binary, ok := parent.(*ast.BinaryNode); ok && binary.Operator == "??" { |
| 668 | // If chain is used in nil coalescing operator, we can omit |
| 669 | // nil push at the end of the chain. The ?? operator will |
| 670 | // handle it. |
| 671 | } else { |
| 672 | // We need to put the nil on the stack, otherwise "typed" |
| 673 | // nil will be used as a result of the chain. |
| 674 | j := c.emit(OpJumpIfNotNil, placeholder) |
| 675 | c.emit(OpPop) |
| 676 | c.emit(OpNil) |
| 677 | c.patchJump(j) |
| 678 | } |
| 679 | c.chains = c.chains[:len(c.chains)-1] |
| 680 | } |
| 681 | |
| 682 | func (c *compiler) MemberNode(node *ast.MemberNode) { |
| 683 | var env Nature |
no test coverage detected