unsigned int PolynomialMod2::BitCount() const { unsigned wordCount = WordCount(); if (wordCount) return (wordCount-1)*WORD_BITS + BitPrecision(reg[wordCount-1]); else return 0; }
unsigned int PolynomialMod2::ByteCount() const { unsigned wordCount = WordCount(); if (wordCount) return (wordCount-1)*WORD_SIZE + BytePrecision(reg[wordCount-1]); else return 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; } }
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 }
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; }
/** * 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()); } } }
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; }
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 ""; }
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; }
BVUnit * BVFixed::EndUnit() { return &this->data[WordCount()]; }
BVIndex BVFixed::WordCount() const { return WordCount(Length()); }
void BVFixed::ClearAll() { ZeroMemory(&this->data[0], WordCount() * sizeof(BVUnit)); }
void BVFixed::SetAll() { memset(&this->data[0], -1, WordCount() * sizeof(BVUnit)); ClearEnd(); }
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; }