MCPcopy Create free account
hub / github.com/brimdata/super / Eval

Method Eval

runtime/sam/expr/eval.go:522–542  ·  view source on GitHub ↗
(this super.Value)

Source from the content-addressed store, hash-verified

520}
521
522func (m *Modulo) Eval(this super.Value) super.Value {
523 lhsVal, rhsVal, typ, errVal := m.operands.evalAndPromote(this)
524 if errVal != nil {
525 return *errVal
526 }
527 switch id := typ.ID(); {
528 case super.IsUnsigned(id):
529 v := toUint(rhsVal)
530 if v == 0 {
531 return m.sctx.NewError(DivideByZero)
532 }
533 return super.NewUint(typ, lhsVal.Uint()%v)
534 case super.IsSigned(id):
535 v := toInt(rhsVal)
536 if v == 0 {
537 return m.sctx.NewError(DivideByZero)
538 }
539 return super.NewInt(typ, toInt(lhsVal)%v)
540 }
541 return m.sctx.NewErrorf("type %s incompatible with '%%' operator", sup.FormatType(typ))
542}
543
544type UnaryMinus struct {
545 sctx *super.Context

Callers

nothing calls this directly

Calls 12

IsUnsignedFunction · 0.92
NewUintFunction · 0.92
IsSignedFunction · 0.92
NewIntFunction · 0.92
FormatTypeFunction · 0.92
toUintFunction · 0.85
toIntFunction · 0.85
evalAndPromoteMethod · 0.80
NewErrorMethod · 0.80
NewErrorfMethod · 0.80
IDMethod · 0.65
UintMethod · 0.45

Tested by

no test coverage detected