BitVecForeachReverseIdx

Table of Contents

BitVecForeachReverseIdx

Description

Iterate over each bit var of given bitvector bv at each index idx into the bitvector. The variables var and idx declared and defined by this macro. idx will start from bv->length - 1 and will go till 0

Parameters

NameDirectionDescription
bvin,outBitvector to iterate over.
varinName of variable to be used which’ll contain bit value at iterated index idx
idxinName of variable to be used for iterating over indices.

Usage example (Cross-references)

    ///           invalid index access) will result in a fatal log message and program termination.
    ///
    #define BitVecForeachReverse(bv, var, body) BitVecForeachReverseIdx((bv), (var), (____iter___), {body})
    
    ///
    // Test BitVecForeachReverseIdx macro
    bool test_bitvec_foreach_reverse_idx(void) {
    printf("Testing BitVecForeachReverseIdx macro\n");
    
    BitVec bv = BitVecInit();
    bool first_bit_is_false = false; // Should be last bit when iterating in reverse
    
    BitVecForeachReverseIdx(&bv, bit, idx, {
    if (count == 0) {
    first_bit_is_false = (bit == false) && (idx == 3);
    count3++;
    });
    BitVecForeachReverseIdx(&bv, bitval, i, {
    (void)bitval;
    count4++;
    // Test BitVecForeachReverseIdx macro
    bool test_bitvec_foreach_reverse_idx(void) {
    printf("Testing BitVecForeachReverseIdx macro\n");
    
    BitVec bv = BitVecInit();
    bool first_bit_is_false = false; // Should be last bit when iterating in reverse
    
    BitVecForeachReverseIdx(&bv, bit, idx, {
    if (count == 0) {
    first_bit_is_false = (bit == false) && (idx == 3);
    count3++;
    });
    BitVecForeachReverseIdx(&bv, bitval, i, {
    (void)bitval;
    count4++;

Share :