(this super.Value)
| 520 | } |
| 521 | |
| 522 | func (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 | |
| 544 | type UnaryMinus struct { |
| 545 | sctx *super.Context |
nothing calls this directly
no test coverage detected