MCPcopy Index your code
hub / github.com/expr-lang/expr / extractPointerAndConstantWithPosition

Function extractPointerAndConstantWithPosition

optimizer/sum_range.go:156–172  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
156func 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}

Callers 1

applySumPredicateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…