本文整理汇总了C++中Pattern::setNumTokens方法的典型用法代码示例。如果您正苦于以下问题:C++ Pattern::setNumTokens方法的具体用法?C++ Pattern::setNumTokens怎么用?C++ Pattern::setNumTokens使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pattern
的用法示例。
在下文中一共展示了Pattern::setNumTokens方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writePattern
Pattern* IRWriter::writePattern(Pattern* pattern, map<string, Port*>* ports){
map<string, Port*>::iterator itPort;
Pattern* newPattern = new Pattern();
//Add number of tokens for each ports
map<Port*, ConstantInt*>::iterator itTokens;
map<Port*, ConstantInt*>* numTokens = pattern->getNumTokensMap();
for (itTokens = numTokens->begin(); itTokens != numTokens->end(); itTokens++) {
Port* src = itTokens->first;
itPort = ports->find(src->getName());
// Find destination port
Port* dst;
itPort = ports->find(src->getName());
if (itPort == ports->end()){
dst = new Port(src->getName(), src->getType(), instance);
ports->insert(pair<string, Port*>(src->getName(), dst));
}else{
dst = itPort->second;
dst->setInstance(instance);
}
newPattern->setNumTokens(dst, itTokens->second);
}
//Add variable map for each ports
map<Port*, Variable*>::iterator itVar;
map<Port*, Variable*>* varMap = pattern->getVariableMap();
for (itVar = varMap->begin(); itVar != varMap->end(); itVar++) {
//Get corresponding port in instance
Port* src = itVar->first;
itPort = ports->find(src->getName());
// Find destination port
Port* dst;
itPort = ports->find(src->getName());
if (itPort == ports->end()){
dst = new Port(src->getName(), src->getType(), instance);
ports->insert(pair<string, Port*>(src->getName(), dst));
}else{
dst = itPort->second;
dst->setInstance(instance);
}
// Add variable to pattern
newPattern->setVariable(dst, dst->getPtrVar());
}
return newPattern;
}