MCPcopy
hub / github.com/tinylib/msgp / readExpr

Method readExpr

gen/spec.go:580–597  ·  view source on GitHub ↗

readExpr returns the expression to read from a position in the bitmask. Compare ==0 for false or !=0 for true.

(bitoffset int)

Source from the content-addressed store, hash-verified

578// readExpr returns the expression to read from a position in the bitmask.
579// Compare ==0 for false or !=0 for true.
580func (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.
600func (b *bmask) setStmt(bitoffset int) string {

Callers 4

mapstructMethod · 0.95
mapstructMethod · 0.95
structmapMethod · 0.95
structAsMapMethod · 0.95

Calls 3

WriteByteMethod · 0.80
WriteStringMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected