MCPcopy Create free account
hub / github.com/ElementsProject/elements / writeBit

Function writeBit

src/simplicity/frame.h:80–90  ·  view source on GitHub ↗

Given a write frame, set its cursor's cell to 'bit' and advance the cursor by one cell. * Cells in front of the cursor's final position may be overwritten. * * The function returns the same value as bit. This facilitates using 'writeBit' within an 'if' statement * * if (writeBit(frame, bit)) { ... } else { ... } * * so that one can both decide conditions based on a Boolean value while

Source from the content-addressed store, hash-verified

78 * Precondition: '*frame' is a valid write frame for 1 more cell.
79 */
80static inline bool writeBit(frameItem* frame, bool bit) {
81 simplicity_debug_assert(0 < frame->offset);
82 frame->offset--;
83 UWORD* dst_ptr = frame->edge + frame->offset / UWORD_BIT;
84 if (bit) {
85 *dst_ptr |= (UWORD)((UWORD)1 << (frame->offset % UWORD_BIT));
86 } else {
87 *dst_ptr = LSBclear(*dst_ptr, frame->offset % UWORD_BIT + 1);
88 }
89 return bit;
90}
91
92/* Given a read frame, advance the cursor by 'n' cells.
93 *

Callers 15

simplicity_low_1Function · 0.85
simplicity_high_1Function · 0.85
simplicity_complement_1Function · 0.85
simplicity_and_1Function · 0.85
simplicity_or_1Function · 0.85
simplicity_xor_1Function · 0.85
simplicity_maj_1Function · 0.85
simplicity_xor_xor_1Function · 0.85
simplicity_ch_1Function · 0.85
simplicity_some_1Function · 0.85
simplicity_eq_1Function · 0.85
simplicity_eq_256Function · 0.85

Calls 1

LSBclearFunction · 0.85

Tested by

no test coverage detected