readExpr returns the expression to read from a position in the bitmask. Compare ==0 for false or !=0 for true.
(bitoffset int)
| 578 | // readExpr returns the expression to read from a position in the bitmask. |
| 579 | // Compare ==0 for false or !=0 for true. |
| 580 | func (b *bmask) readExpr(bitoffset int) string { |
| 581 | if bitoffset < 0 || bitoffset >= b.bitlen { |
| 582 | panic(fmt.Errorf("bitoffset %d out of range for bitlen %d", bitoffset, b.bitlen)) |
| 583 | } |
| 584 | |
| 585 | var buf bytes.Buffer |
| 586 | buf.Grow(len(b.varname) + 16) |
| 587 | buf.WriteByte('(') |
| 588 | buf.WriteString(b.varname) |
| 589 | if b.bitlen > 64 { |
| 590 | fmt.Fprintf(&buf, "[%d]", (bitoffset / 64)) |
| 591 | } |
| 592 | buf.WriteByte('&') |
| 593 | fmt.Fprintf(&buf, "0x%X", (uint64(1) << (uint64(bitoffset) % 64))) |
| 594 | buf.WriteByte(')') |
| 595 | |
| 596 | return buf.String() |
| 597 | } |
| 598 | |
| 599 | // setStmt returns the statement to set the specified bit in the bitmask. |
| 600 | func (b *bmask) setStmt(bitoffset int) string { |
no test coverage detected