本文整理汇总了C++中Prefix类的典型用法代码示例。如果您正苦于以下问题:C++ Prefix类的具体用法?C++ Prefix怎么用?C++ Prefix使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Prefix类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateInstruction
Instruction* Jcc::CreateInstruction(unsigned char* memLoc, Processor* proc) {
unsigned char* opLoc = memLoc;
char buf[65];
std::string inst;
Prefix* pre = Prefix::GetPrefix(memLoc);
unsigned int preSize = 0;
unsigned int opcodeOffset = 0;
Instruction* newJcc = 0;
if(pre) {
opLoc += preSize = pre->GetLength();
}
unsigned int val = (int)*(opLoc + 1);
if(*opLoc == TWO_BYTE_OPCODE) {
preSize++;
opLoc++;
opcodeOffset = TWO_BYTE_OFFSET;
val = (int)*(opLoc + 1) + ((int)*(opLoc + 2) << 8);
}
Operand* src = 0;
switch(*opLoc - opcodeOffset) {
case JA:
case JAE:
case JB:
case JBE:
case JCXZ:
case JE:
case JG:
case JGE:
case JL:
case JLE:
case JNE:
case JNO:
case JNP:
case JNS:
case JO:
case JP:
case JS:
GETINST(preSize + 1 + (opcodeOffset == TWO_BYTE_OFFSET ? 2 : 1));
src = new ImmediateOperand(val, opcodeOffset == TWO_BYTE_OFFSET ? 2 : 1);
snprintf(buf, 65, "%s %s", _GetStr(*opLoc - opcodeOffset), src->GetDisasm().c_str());
newJcc = new Jcc(pre, buf, inst, (unsigned char)*opLoc - opcodeOffset);
newJcc->SetOperand(Operand::SRC, src);
break;
default:
break;
}
return newJcc;
}
示例2: AddEntry
void AddEntry(Prefix& prefix, const string& suffix)
{
if (prefix.size() == PREFIX_LENGTH) {
dictionary[prefix].push_back(suffix);
prefix.pop_front();
}
prefix.push_back(suffix);
}
示例3: add
// add: add word to suffix list, update prefix
void add(Prefix& prefix, const string& s)
{
if (prefix.size() == NPREF) {
statetab[prefix].push_back(s);
prefix.pop_front();
}
prefix.push_back(s);
}
示例4: add
void add(Prefix& prefix, string& new_word)
{
if(prefix.size() == prefix_len_)
{
state_list[prefix].push_back(new_word);
prefix.pop_front();
}
prefix.push_back(new_word);
}
示例5: CreateInstruction
Instruction* In::CreateInstruction(Memory::MemoryOffset& memLoc, Processor* proc) {
Memory::MemoryOffset opLoc = memLoc;
char buf[65];
std::string inst;
Prefix* pre = Prefix::GetPrefix(memLoc);
unsigned int preSize = 0;
Instruction* newIn = 0;
if(pre) {
opLoc += preSize = pre->GetLength();
}
switch(*opLoc) {
case IN_AL_IMM8:
case IN_AX_IMM8:
{
eRegisters reg = *opLoc == IN_AL_IMM8 ? REG_AL : REG_AX;
Operand* src = new ImmediateOperand(*(opLoc + 1), 1, (opLoc + 1).getOffset());
Operand* dst = new RegisterOperand(reg, proc);
GETINST(preSize + 2);
snprintf(buf, 65, "IN %s, %s",reg == REG_AX ? "AX" : "AL", src->GetDisasm().c_str());
newIn = new In(pre, buf, inst, (int)*opLoc);
newIn->SetOperand(Operand::SRC, src);
newIn->SetOperand(Operand::DST, dst);
break;
}
case IN_AL_DX:
case IN_AX_DX:
{
eRegisters reg = *opLoc == IN_AL_DX ? REG_AL : REG_AX;
Operand* src = new RegisterOperand(REG_DX, proc);
Operand* dst = new RegisterOperand(reg, proc);
GETINST(preSize + 1);
snprintf(buf, 65, "IN %s, DX", reg == REG_AX ? "AX" : "AL");
newIn = new In(pre, buf, inst, (int)*opLoc);
newIn->SetOperand(Operand::SRC, src);
newIn->SetOperand(Operand::DST, dst);
break;
}
}
return newIn;
}
示例6: CreateInstruction
Instruction* Out::CreateInstruction(unsigned char* memLoc, Processor* proc) {
unsigned char* opLoc = memLoc;
char buf[65];
std::string inst;
Prefix* pre = Prefix::GetPrefix(memLoc);
unsigned int preSize = 0;
Instruction* newOut = 0;
if(pre) {
opLoc += preSize = pre->GetLength();
}
switch(*opLoc) {
case OUT_IMM8_AL:
case OUT_IMM8_AX:
{
eRegisters reg = *opLoc == OUT_IMM8_AL ? REG_AL : REG_AX;
Operand* dst = new ImmediateOperand(*(opLoc + 1), 1);
Operand* src = new RegisterOperand(reg, proc);
GETINST(preSize + 2);
snprintf(buf, 65, "OUT %s, %s", dst->GetDisasm().c_str(), reg == REG_AX ? "AX" : "AL");
newOut = new Out(pre, buf, inst, (int)*opLoc);
newOut->SetOperand(Operand::SRC, src);
newOut->SetOperand(Operand::DST, dst);
break;
}
case OUT_DX_AL:
case OUT_DX_AX:
{
eRegisters reg = *opLoc == OUT_DX_AL ? REG_AL : REG_AX;
Operand* dst = new RegisterOperand(REG_DX, proc);
Operand* src = new RegisterOperand(reg, proc);
GETINST(preSize + 1);
snprintf(buf, 65, "OUT DX, %s", reg == REG_AX ? "AX" : "AL");
newOut = new Out(pre, buf, inst, (int)*opLoc);
newOut->SetOperand(Operand::SRC, src);
newOut->SetOperand(Operand::DST, dst);
break;
}
}
return newOut;
}
示例7: generate
// generate: produce output, one word per line
void generate(int nwords)
{
Prefix prefix;
int i;
for (i = 0; i < NPREF; i++)
add(prefix, NONWORD);
for (i = 0; i < nwords; i++) {
vector<string>& suf = statetab[prefix];
const string& w = suf[rand() % suf.size()];
if (w == NONWORD)
break;
cout << w << "\n";
prefix.pop_front(); // advance
prefix.push_back(w);
}
}
示例8: QDialog
GameDialog::GameDialog(QWidget *parent, QString path, corelib *lib) :
QDialog(parent),
ui(new Ui::GameDialog),
_path (path)
{
Prefix *prefix = new Prefix (this, path, lib);
ui->setupUi(this);
//setting the UI
if (qApp->arguments().length() > 1)
ui->lblIcon->setPixmap(QPixmap(path + "/icon"));
else
ui->lblIcon->setPixmap(getIcoFromDisc());
ui->lblIcon->setText("");
ui->lblName->setText(tr("A Microsoft Windows(r) application is found on this disc. <br><br><b>%1</b><br><br> Would you like to install it? ").arg(prefix->name()));
ui->lblDesc->setText(prefix->note());
}
示例9: CreateInstruction
Instruction* Cwd::CreateInstruction(Memory::MemoryOffset& memLoc, Processor*) {
Memory::MemoryOffset opLoc = memLoc;
char buf[65];
std::string inst;
Prefix* pre = Prefix::GetPrefix(memLoc);
unsigned int preSize = 0;
if(pre) {
opLoc += preSize = pre->GetLength();
}
if(*opLoc == CWD) {
snprintf(buf, 65, "CWD");
GETINST(preSize + 1);
return new Cwd(pre, buf, inst, (int)*opLoc);
}
return 0;
}
示例10: SetupCacheEntry
static void
SetupCacheEntry(LookupCacheV4* aLookupCache,
const nsCString& aCompletion,
bool aNegExpired = false,
bool aPosExpired = false)
{
FullHashResponseMap map;
Prefix prefix;
prefix.FromPlaintext(aCompletion);
CachedFullHashResponse* response = map.LookupOrAdd(prefix.ToUint32());
response->negativeCacheExpirySec =
aNegExpired ? EXPIRED_TIME_SEC : NOTEXPIRED_TIME_SEC;
response->fullHashes.Put(GeneratePrefix(aCompletion, COMPLETE_SIZE),
aPosExpired ? EXPIRED_TIME_SEC : NOTEXPIRED_TIME_SEC);
aLookupCache->AddFullHashResponseToCache(map);
}
示例11: generate
void generate(int ows, size_t pl)
{
outwords_ = ows;
prefix_len_ = pl;
string buff;
Prefix prefix;
for(size_t j=0; j < prefix_len_; ++j)
{
prefix.push_back("\n");
}
ifstream infile (filename_);
while(!getline(infile,buff).eof())
{
parse_words(prefix, buff);
}
gen_output();
}
示例12: TEST
// This testcase check if an cache entry whose negative cache time is expired
// and it doesn't have any postive cache entries in it, it should be removed
// from cache after calling |Has|.
TEST(UrlClassifierCaching, NegativeCacheExpireV2)
{
_PrefixArray array = { GeneratePrefix(NEG_CACHE_EXPIRED_URL, 8) };
UniquePtr<LookupCacheV2> cache = SetupLookupCache<LookupCacheV2>(array);
nsCOMPtr<nsICryptoHash> cryptoHash = do_CreateInstance(NS_CRYPTO_HASH_CONTRACTID);
MissPrefixArray misses;
Prefix* prefix = misses.AppendElement(fallible);
prefix->FromPlaintext(NEG_CACHE_EXPIRED_URL);
AddCompleteArray dummy;
cache->AddGethashResultToCache(dummy, misses, EXPIRED_TIME_SEC);
// Ensure it is in cache in the first place.
EXPECT_EQ(cache->IsInCache(prefix->ToUint32()), true);
// It should be removed after calling Has API.
TestCache<LookupCacheV2>(NEG_CACHE_EXPIRED_URL, true, false, false, cache.get());
}
示例13: GenerateText
void GenerateText(int wordCount, ofstream& outFile)
{
Prefix prefix;
int i;
for (i = 0; i < PREFIX_LENGTH; i++){
AddEntry(prefix, NONWORD);
}
for (i = 0; i < wordCount; i++) {
vector<string>& suffix = dictionary[prefix];
const string& word = suffix[rand() % suffix.size()];
if (word == NONWORD){
break;
}
outFile << word << " ";
//shift the prefix by a word, to keep generating.
prefix.pop_front();
prefix.push_back(word);
}
}
示例14: getPrefixFromWC
Prefix getPrefixFromWC(VEC coord)
{
Prefix pfx;
Orientation ori(SYMMETRY_HEXAGONAL);
if (coord.y > 0)
{
if (!(coord * VEC(COS30, -SIN30) > 0 && coord.x>0)){
ori.rotate(VP);
pfx.rotate(VP);
}
} else {
ori.rotate(VN);
pfx.rotate(VN);
}
VEC vertexpoint_[3];
double dist[3];
vertexpoint_[0] = ori.getWCFromOC(VEC(0, 0)) - coord;
vertexpoint_[1] = ori.getWCFromOC(VEC(COS30, -SIN30)) - coord;
vertexpoint_[2] = ori.getWCFromOC(VEC(COS30, SIN30)) - coord;
for (int i=0; i<3; i++)
dist[i] = vertexpoint_[i]*vertexpoint_[i];
if (dist[1] < dist[0])
pfx.rotate((dist[2]<dist[1])? FN: FP);
else if (dist[2] < dist[0])
pfx.rotate(FN);
for (int i=0; i<3; i++)
{
if (ori.getOCFromWC(coord).x > COS30)
return Prefix();
}
return pfx;
}
示例15: test
void SymmetryObject::test()
{
Prefix diff;
edge edgeA, edgeB;
/*edgeA.fr.index = 0;
edgeA.fr.Pfx;
edgeA.to.index = FACE_CENTERED;
edgeA.to.Pfx.rotate(FN);
edgeB.fr.index = FACE_CENTERED;
edgeB.fr.Pfx.rotate(FN);
edgeB.to.index = 0;
edgeB.to.Pfx.rotate(FN);*/
edgeA.fr.index = 0;
//edgeA.fr.Pfx;
edgeA.to.index = 0;
edgeA.to.Pfx.rotate(FN);
edgeA.to.Pfx.rotate(VN);
cout << "edgeA: ";
edgeA.print();
cout << endl;
//cout << "edgeB: " << edgeB.toString() << endl;
if (edgeA.isOppositeOf(edgeA, &diff))
{
cout << "is opposite: ";
diff.print();
cout << endl;
} else {
cout << "not opposite" << endl;
}
}