extractPointerAndConstantWithPosition extracts pointer (#) and integer constant from a binary node. Returns (pointer, constant, pointerOnLeft) or (nil, nil, false) if not matching the expected pattern.
(binary *BinaryNode)
| 154 | // extractPointerAndConstantWithPosition extracts pointer (#) and integer constant from a binary node. |
| 155 | // Returns (pointer, constant, pointerOnLeft) or (nil, nil, false) if not matching the expected pattern. |
| 156 | func extractPointerAndConstantWithPosition(binary *BinaryNode) (*PointerNode, *IntegerNode, bool) { |
| 157 | // Try left=pointer, right=constant |
| 158 | if pointer, ok := binary.Left.(*PointerNode); ok && pointer.Name == "" { |
| 159 | if constant, ok := binary.Right.(*IntegerNode); ok { |
| 160 | return pointer, constant, true |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | // Try left=constant, right=pointer |
| 165 | if constant, ok := binary.Left.(*IntegerNode); ok { |
| 166 | if pointer, ok := binary.Right.(*PointerNode); ok && pointer.Name == "" { |
| 167 | return pointer, constant, false |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | return nil, nil, false |
| 172 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…