Exemplo n.º 1
0
unsigned int PolynomialMod2::BitCount() const
{
	unsigned wordCount = WordCount();
	if (wordCount)
		return (wordCount-1)*WORD_BITS + BitPrecision(reg[wordCount-1]);
	else
		return 0;
}
Exemplo n.º 2
0
unsigned int PolynomialMod2::ByteCount() const
{
	unsigned wordCount = WordCount();
	if (wordCount)
		return (wordCount-1)*WORD_SIZE + BytePrecision(reg[wordCount-1]);
	else
		return 0;
}
Exemplo n.º 3
0
/**
* Gets the number of bytes required to represent this RInteger.
* 
* @return	The size of the integer in bytes.
* 
*/
EXPORT_C TUint TInteger::ByteCount() const
	{
	TUint wordCount = WordCount();
	if(wordCount)
		{
		return (wordCount-1)*WORD_SIZE + BytePrecision((Ptr())[wordCount-1]);
		}
	else 
		{
		return 0;
		}
	}
Exemplo n.º 4
0
void
BVFixed::Copy(const BVFixed*bv)
{
    AssertBV(bv);
    Assert(len >= bv->len);

#if 1
    js_memcpy_s(&this->data[0], WordCount() * sizeof(BVUnit), &bv->data[0], bv->WordCount() * sizeof(BVUnit));
#else
    this->for_each(bv, &BVUnit::Copy);
#endif
}
Exemplo n.º 5
0
EXPORT_C TInteger& TInteger::operator <<=(TUint aBits)
	{
	const TUint wordCount = WordCount();
	const TUint shiftWords = aBits / WORD_BITS;
	const TUint shiftBits = aBits % WORD_BITS;

	CleanGrowL(wordCount+BitsToWords(aBits));
	ShiftWordsLeftByWords(Ptr(), wordCount + shiftWords, shiftWords);
	ShiftWordsLeftByBits(Ptr()+shiftWords, wordCount + BitsToWords(shiftBits), 
		shiftBits);
	return *this;
	}
Exemplo n.º 6
0
/** 
* Get the number of bits required to represent this RInteger.
* 
* @return	The size of the integer in bits.
* 
*/
EXPORT_C TUint TInteger::BitCount() const
	{
	TUint wordCount = WordCount();
	if(wordCount)
		{
		return (wordCount-1)*WORD_BITS + BitPrecision(Ptr()[wordCount-1]);
		}
	else 
		{
		return 0;
		}
	}
 /*
    Convert literal data to value data.
 */
 void 
 IMAPSimpleCommandParser::UnliteralData()
 {
    for (int i = 0; i < WordCount(); i++)
    {
       shared_ptr<IMAPSimpleWord> pWord = Word(i);
       if (pWord->Clammerized())
       {
          if (!pWord->LiteralData().IsEmpty())
             pWord->Value(pWord->LiteralData());
       }
    }
 }
Exemplo n.º 8
0
EXPORT_C TInteger& TInteger::operator++()
	{
	if(NotNegative())
		{
		if(Increment(Ptr(), Size()))
			{
			CleanGrowL(2*Size());
			(Ptr())[Size()/2]=1;
			}
		}
	else
		{
		DecrementNoCarry(Ptr(), Size());
		if(WordCount()==0)
			{
			this->CopyL(Zero());
			}
		}
	return *this;
	}
Exemplo n.º 9
0
void
BVFixed::CopyBits(const BVFixed * bv, BVIndex i)
{
    AssertBV(bv);
    BVIndex offset = BVUnit::Offset(i);
    BVIndex position = BVUnit::Position(i);
    BVIndex len = bv->WordCount() - position;
    BVIndex copylen = min(WordCount(), len);
    if (offset == 0)
    {
        js_memcpy_s(&this->data[0], copylen * sizeof(BVUnit), &bv->data[BVUnit::Position(i)], copylen * sizeof(BVUnit));
    }
    else
    {
        BVIndex pos = position;
        for (BVIndex j = 0; j < copylen; j++)
        {
            Assert(pos < bv->WordCount());
            this->data[j] = bv->data[pos];
            this->data[j].ShiftRight(offset);

            pos++;
            if (pos >= bv->WordCount())
            {
                break;
            }
            BVUnit temp = bv->data[pos];
            temp.ShiftLeft(BVUnit::BitsPerWord - offset);
            this->data[j].Or(temp);
        }
    }
#if DBG
    for (BVIndex curr = i; curr < i + this->Length(); curr++)
    {
        Assert(this->Test(curr - i) == bv->Test(curr));
    }
#endif
}
   String 
   IMAPSimpleCommandParser::GetParamValue(shared_ptr<IMAPCommandArgument> pArguments, int iParamIndex)
   //---------------------------------------------------------------------------()
   // DESCRIPTION:
   // Returns a parameter by it's index.
   //---------------------------------------------------------------------------()
   {
      iParamIndex++;
      int iWordCount = WordCount();
      int iLiteralIndex = 0;

      for (int i = 1; i < iWordCount; i++)
      {
         shared_ptr<IMAPSimpleWord> pWord = Word(i);

         if (!pWord)
            return "";

         if (pWord->Clammerized())
         {
            if (i == iParamIndex)
               return pArguments->Literal(iLiteralIndex);
               
            iLiteralIndex++;
         }
         else
         {
            if (i == iParamIndex)
            {
               String sValue = pWord->Value();
               return sValue;
            }
         }
      }

      return "";
   }
Exemplo n.º 11
0
EXPORT_C TInteger& TInteger::operator <<=(TUint aBits)
	{
	const TUint wordCount = WordCount();
	const TUint shiftWords = aBits / WORD_BITS;
	const TUint shiftBits = aBits % WORD_BITS;

	CleanGrowL(wordCount+BitsToWords(aBits));
	ShiftWordsLeftByWords(Ptr(), wordCount + shiftWords, shiftWords);
	ShiftWordsLeftByBits(Ptr()+shiftWords, wordCount + BitsToWords(shiftBits), 
		shiftBits);
	return *this;
	}

EXPORT_C TInteger& TInteger::operator >>=(TUint aBits)
	{
	const TUint wordCount = WordCount();
	const TUint shiftWords = aBits / WORD_BITS;
	const TUint shiftBits = aBits % WORD_BITS;

	ShiftWordsRightByWords(Ptr(), wordCount, shiftWords);
	if(wordCount > shiftWords)
		{
		ShiftWordsRightByBits(Ptr(), wordCount - shiftWords, shiftBits);
		}
	if(IsNegative() && WordCount()==0) // avoid negative 0
		{
		SetSign(EPositive);
		}
	return *this;
	}
Exemplo n.º 12
0
BVUnit *
BVFixed::EndUnit()
{
    return &this->data[WordCount()];
}
Exemplo n.º 13
0
BVIndex
BVFixed::WordCount() const
{
    return WordCount(Length());
}
Exemplo n.º 14
0
void
BVFixed::ClearAll()
{
    ZeroMemory(&this->data[0], WordCount() * sizeof(BVUnit));
}
Exemplo n.º 15
0
void
BVFixed::SetAll()
{
    memset(&this->data[0], -1, WordCount() * sizeof(BVUnit));
    ClearEnd();
}
Exemplo n.º 16
0
void Read_Blif_N_Pl(ifstream &bliff, ifstream &plf)
{

/* First section of this file read blif file and store the information to gate_vec0 and gate_map0 */	
	string line;
	int FLAG = 0;	// use this indicator to deal with multiple lines of input (later output maybe)
	while (getline(bliff,line)) 
	{
		if (line.length()<=1) continue;
		if (line[0]=='#') continue;
//		cout<<line<<endl;
		
		istringstream sword(line);
		string temp;
		while (sword>>temp) 
		{
			if (temp==".model") break;
			else if ( (temp==".inputs")||(FLAG==1) ) 
			{	
			//	cout<<WordCount(line)<<endl;
				if (FLAG != 1) 
				{	for (int i=0; i<WordCount(line)-1; i++) 
					{	sword>>temp;
						if (temp != "\\") 
						{
						//	cout<<temp<<endl;		
							gate *temp_gate_ptr = new gate;
							temp_gate_ptr->setGateInfo(temp,"PRI_INPUT",60,100);
							gate_vec0.push_back(temp_gate_ptr);
							gate_map0[temp] = temp_gate_ptr;
						
							FLAG = 0;
						}
						else if (temp == "\\") 
						{	
							FLAG = 1;
						}
					}
				}
				else if (FLAG == 1) 
				{	
					do{
						if (temp !="\\") 
						{
							gate *temp_gate_ptr = new gate;
							temp_gate_ptr->setGateInfo(temp,"PRI_INPUT",60,100);
							gate_vec0.push_back(temp_gate_ptr);
							gate_map0[temp] = temp_gate_ptr;
						
							FLAG = 0;
						}
						else if (temp == "\\") {
							FLAG = 1;
						}
					} while (sword>>temp);	

				}
			}
			else if (temp==".outputs") break;
			else if (temp==".end") break;
			else if (temp==".gate") 
			{ 
				gate *temp_gate_ptr = new gate;
				sword>>temp;
				string temptype=temp;
//				cout<<temptype<<" "<<WordCount(line)<<endl;
				for(int i=0; i<WordCount(line)-3; i++) 
				{
					sword>>temp;
					temp_gate_ptr->ipt_nodes.push_back(temp.substr(temp.find_first_of("=")+1));
//					cout<<temp<<" ";
				}
				sword>>temp;
//				cout<<temp<<endl;
				temp_gate_ptr->setGateInfo(temp.substr(temp.find_first_of("=")+1), temptype, 60, 100);

				gate_vec0.push_back(temp_gate_ptr);
				gate_map0[temp.substr(temp.find_first_of("=")+1)] = temp_gate_ptr;
			}