MCPcopy
hub / github.com/expr-lang/expr / equalBinaryNode

Method equalBinaryNode

compiler/compiler.go:627–647  ·  view source on GitHub ↗
(node *ast.BinaryNode)

Source from the content-addressed store, hash-verified

625}
626
627func (c *compiler) equalBinaryNode(node *ast.BinaryNode) {
628 l := kind(node.Left.Type())
629 r := kind(node.Right.Type())
630
631 leftIsSimple := isSimpleType(node.Left)
632 rightIsSimple := isSimpleType(node.Right)
633 leftAndRightAreSimple := leftIsSimple && rightIsSimple
634
635 c.compile(node.Left)
636 c.derefInNeeded(node.Left)
637 c.compile(node.Right)
638 c.derefInNeeded(node.Right)
639
640 if l == r && l == reflect.Int && leftAndRightAreSimple {
641 c.emit(OpEqualInt)
642 } else if l == r && l == reflect.String && leftAndRightAreSimple {
643 c.emit(OpEqualString)
644 } else {
645 c.emit(OpEqual)
646 }
647}
648
649func isSimpleType(node ast.Node) bool {
650 if node == nil {

Callers 1

BinaryNodeMethod · 0.95

Calls 6

compileMethod · 0.95
derefInNeededMethod · 0.95
emitMethod · 0.95
isSimpleTypeFunction · 0.85
kindFunction · 0.70
TypeMethod · 0.65

Tested by

no test coverage detected