cloud9_root/src/third_party/stp/src/simplifier/constantBitP/ConstantBitPropagation.cpp
// get the current value from the map. If no value is in the map. Make a new value.
get the current value from the map. If no value is in the map. Make a new value.
get the current value from the map . If no value is in the map . Make a new value .
FixedBits*
    ConstantBitPropagation::getCurrentFixedBits(const ASTNode& n)
    {
      assert (NULL != fixedMap);
      NodeToFixedBitsMap::NodeToFixedBitsMapType::iterator it = fixedMap->map->find(n);
      if (it != fixedMap->map->end())
        {
          return it->second;
        }
      int bw;
      if (0 == n.GetValueWidth())
        {
          bw = 1;
        }
      else
        {
          bw = n.GetValueWidth();
        }
      FixedBits* output = new FixedBits(bw, (BOOLEAN_TYPE == n.GetType()));
      if (BVCONST == n.GetKind() || BITVECTOR == n.GetKind())
        {
          CBV cbv = n.GetBVConst();
          for (unsigned int j = 0; j < n.GetValueWidth(); j++)
            {
              output->setFixed(j, true);
              output->setValue(j, CONSTANTBV::BitVector_bit_test(cbv, j));
            }
        }
      else if (TRUE == n.GetKind())
        {
          output->setFixed(0, true);
          output->setValue(0, true);
        }
      else if (FALSE == n.GetKind())
        {
          output->setFixed(0, true);
          output->setValue(0, false);
        }
       fixedMap->map->insert(pair<ASTNode, FixedBits*> (n, output));
      return output;
    }
FixedBits * ConstantBitPropagation :: getCurrentFixedBits ( const ASTNode & n ) { assert ( NULL != fixedMap ) ; NodeToFixedBitsMap :: NodeToFixedBitsMapType :: iterator it = fixedMap -> map -> find ( n ) ; if ( it != fixedMap -> map -> end ( ) ) { return it -> second ; } int bw ; if ( 0 == n . GetValueWidth ( ) ) { bw = 1 ; } else { bw = n . GetValueWidth ( ) ; } FixedBits * output = new FixedBits ( bw , ( BOOLEAN_TYPE == n . GetType ( ) ) ) ; if ( BVCONST == n . GetKind ( ) || BITVECTOR == n . GetKind ( ) ) { CBV cbv = n . GetBVConst ( ) ; for ( unsigned int j = 0 ; j < n . GetValueWidth ( ) ; j ++ ) { output -> setFixed ( j , true ) ; output -> setValue ( j , CONSTANTBV :: BitVector_bit_test ( cbv , j ) ) ; } } else if ( TRUE == n . GetKind ( ) ) { output -> setFixed ( 0 , true ) ; output -> setValue ( 0 , true ) ; } else if ( FALSE == n . GetKind ( ) ) { output -> setFixed ( 0 , true ) ; output -> setValue ( 0 , false ) ; } fixedMap -> map -> insert ( pair < ASTNode , FixedBits * > ( n , output ) ) ; return output ; }
get the current value from the map.
get the current value from the map .
// the CBV doesn't leak. it is a copy of the cbv inside the node.