void AnimationCache::addAnimationsWithDictionary(const ValueMap& dictionary,const std::string& plist) { if ( dictionary.find("animations") == dictionary.end() ) { CCLOG("cocos2d: AnimationCache: No animations were found in provided dictionary."); return; } const Value& animations = dictionary.at("animations"); unsigned int version = 1; if( dictionary.find("properties") != dictionary.end() ) { const ValueMap& properties = dictionary.at("properties").asValueMap(); version = properties.at("format").asInt(); const ValueVector& spritesheets = properties.at("spritesheets").asValueVector(); for(const auto &value : spritesheets) { std::string path = FileUtils::getInstance()->fullPathFromRelativeFile(value.asString(),plist); SpriteFrameCache::getInstance()->addSpriteFramesWithFile(path); } } switch (version) { case 1: parseVersion1(animations.asValueMap()); break; case 2: parseVersion2(animations.asValueMap()); break; default: CCASSERT(false, "Invalid animation format"); } }
void Player::setTagPosition(int x, int y){ auto spriteSize = m_node->getContentSize(); Vec2 dstPos = Vec2(x + spriteSize.width / 2, y); Vec2 tiledPos = tileCoorForPosition(Vec2(dstPos.x, dstPos.y)); int tiledGid = meta->getTileGIDAt(tiledPos); if (tiledGid != 0){ Value properties = m_map->getPropertiesForGID(tiledGid); ValueMap propertiesMap = properties.asValueMap(); if (propertiesMap.find("Collidable") != propertiesMap.end()){ Value prop = propertiesMap.at("Collidable"); if (prop.asString().compare("true") == 0){ return; } } if (propertiesMap.find("food") != propertiesMap.end()){ Value prop = propertiesMap.at("food"); if (prop.asString().compare("true") == 0){ TMXLayer* barrier = m_map->getLayer("barrier"); barrier->removeTileAt(tiledPos); } } } Entity::setTagPosition(x, y); setViewPointByPlayer(); }
// // load file // void Configuration::loadConfigFile(const std::string& filename) { ValueMap dict = FileUtils::getInstance()->getValueMapFromFile(filename); CCASSERT(!dict.empty(), "cannot create dictionary"); // search for metadata bool validMetadata = false; auto metadataIter = dict.find("metadata"); if (metadataIter != dict.end() && metadataIter->second.getType() == Value::Type::MAP) { const auto& metadata = metadataIter->second.asValueMap(); auto formatIter = metadata.find("format"); if (formatIter != metadata.end()) { int format = formatIter->second.asInt(); // Support format: 1 if (format == 1) { validMetadata = true; } } } if (! validMetadata) { CCLOG("Invalid config format for file: %s", filename.c_str()); return; } auto dataIter = dict.find("data"); if (dataIter == dict.end() || dataIter->second.getType() != Value::Type::MAP) { CCLOG("Expected 'data' dict, but not found. Config file: %s", filename.c_str()); return; } // Add all keys in the existing dictionary const auto& dataMap = dataIter->second.asValueMap(); for (auto dataMapIter = dataMap.begin(); dataMapIter != dataMap.end(); ++dataMapIter) { if (_valueDict.find(dataMapIter->first) == _valueDict.end()) _valueDict[dataMapIter->first] = dataMapIter->second; else CCLOG("Key already present. Ignoring '%s'",dataMapIter->first.c_str()); } }
void AppRequests::didFetchAppRequests(const Vector<screw::facebook::GraphRequest *> &requests) { for (GraphRequest *request : requests) { string dataStr = request->getDataString(); Value &v = request->getValue(); FB_LOG_INFO("AppRequests::didFetchAppRequests - data str = %s", dataStr.c_str()); if (dataStr.length()) { ValueMap m; if (JsonUtils::parse(dataStr, m)) { if (m.find(AppRequestsDataTypeKey) == m.end()) { FB_LOG("AppRequests::didFetchAppRequests - request data with no type (be aware) %s", v.getDescription().c_str()); } ValueSetter::set(v, "data", Value(m)); FB_LOG("AppRequests::didFetchAppRequests - parsed data = %s", Value(m).getDescription().c_str()); } else { FB_LOG("AppRequests::didFetchAppRequests - non JSON request data (cleared) %s", v.getDescription().c_str()); ValueSetter::clear(v, "data"); } } _data->set(AppRequestsRequestsKey + "/" + request->getId(), v); //Delete request Request::requestForDelete(request->getId(), nullptr)->execute(); } if (requests.size()) { _data->save(); } }
void PlayLayer::initPointsVector(float offX) { Node *runOfPoint = NULL; int count = 0; ValueMap point; //by char countBuf1[16] = ""; sprintf(countBuf1, "%d", count); auto moneyText = countBuf1; //point = objects->getObject(std::to_string(count)); point = objects->getObject(moneyText); while (point.begin()!= point.end()) { float x = point.at("x").asFloat(); float y = point.at("y").asFloat(); runOfPoint = Node::create(); runOfPoint->setPosition(Point(x - offX, y )); this->pointsVector.pushBack(runOfPoint); count++; //by char countBuf2[16] = ""; sprintf(countBuf2, "%d", count); auto moneyText = countBuf2; //point = objects->getObject( std::to_string(count)); point = objects->getObject( moneyText); } runOfPoint = NULL; }
void UserDataManager::setEntityParameterLevel(EntityType entityType, EntityParameterLevel EntityParameterLevel) { ValueMap entityListParameterMap; if (this->userData.find(USER_DATA_ENTITY_PARAMETER) == this->userData.end()) { entityListParameterMap = ValueMap(); } else { entityListParameterMap = this->userData[USER_DATA_ENTITY_PARAMETER].asValueMap(); } std::string entityTypeString = this->getEntityTypeStringByEntityType(entityType); ValueMap entityParameterMap; if (entityListParameterMap.find(entityTypeString) == entityListParameterMap.end()) { entityParameterMap = ValueMap(); } else { entityParameterMap = entityListParameterMap[entityTypeString].asValueMap(); } entityParameterMap["rank"] = EntityParameterLevel.rank; entityParameterMap["levelHp"] = EntityParameterLevel.hp; entityParameterMap["levelAttack"] = EntityParameterLevel.attack; entityListParameterMap[entityTypeString] = entityParameterMap; this->userData[USER_DATA_ENTITY_PARAMETER] = entityListParameterMap; this->save(); }
Vector<PosBase*> PosLoadUtil::loadPosWithFile(const char* sFilePath, EnumPosType enPosType, Node* container, int iLevel, bool isDebug) { Vector<PosBase*> posList; ValueMap fileDataMap = FileUtils::getInstance()->getValueMapFromFile(sFilePath); //遍历Valuemap for (auto it = fileDataMap.begin(); it != fileDataMap.end();++it){ Value value = it->second; ValueMap data = value.asValueMap(); /* 创建坐标对象 */ PosBase* posBase = NULL; switch (enPosType) { case enTowerPos: posBase = TowerPos::create(Point(data["x"].asInt(), data["y"].asInt()), data["herotype"].asInt(), data["bullettype"].asInt(), isDebug); break; case enMonsterPos: posBase = MonsterPos::create(Point(data["x"].asInt(), data["y"].asInt()), isDebug); break; default: posBase = TowerPos::create(Point(data["x"].asInt(), data["y"].asInt()), data["herotype"].asInt(), data["bullettype"].asInt(), isDebug); break; } posList.pushBack(posBase); if (container != NULL) { container->addChild(posBase, iLevel); } } return posList; }
DayRecord* DayRecords::getDayRecord(int day) { if (_day_records.find(day) == _day_records.end()) { DayRecord* day_rec = new DayRecord(day); std::string filepath = DayRecords::getDataPath(); if (FileUtils::getInstance()->isFileExist(filepath)) { ValueMap data = FileUtils::getInstance()->getValueMapFromFile(filepath); std::string strday = StringUtils::format("%d", day); if (data.find(strday) != data.end()) { ValueMap daydata = data[strday].asValueMap(); day_rec->loadFromValueMap(daydata); _day_records[day] = *day_rec; return &_day_records[day]; } } } else { return &_day_records[day]; } DayRecord* day_rec = new DayRecord(day); _day_records[day] = *day_rec; return &_day_records[day]; }
double petabricks::Heuristic::eval (const ValueMap featureValues) { FormulaPtr evaluated = _formula->clone(); for(ValueMap::const_iterator i=featureValues.begin(), e=featureValues.end(); i!=e; ++i) { const std::string& featureName=i->first; const std::string featureValueStr = jalib::XToString(i->second); evaluated = MaximaWrapper::instance().subst(featureValueStr, featureName, evaluated); } evaluated = MaximaWrapper::instance().toFloat(evaluated); double value = evaluated->value(); //Keep the value within the limits if (value < _min) { return _min; } else if (value > _max) { return _max; } else { return value; } }
void SpriteFrameCache::addSpriteFramesWithFile(const std::string& plist) { CCASSERT(plist.size()>0, "plist filename should not be nullptr"); std::string fullPath = FileUtils::getInstance()->fullPathForFilename(plist); if (fullPath.size() == 0) { // return if plist file doesn't exist CCLOG("cocos2d: SpriteFrameCache: can not find %s", plist.c_str()); return; } if (_loadedFileNames->find(plist) == _loadedFileNames->end()) { ValueMap dict = FileUtils::getInstance()->getValueMapFromFile(fullPath); string texturePath(""); if (dict.find("metadata") != dict.end()) { ValueMap& metadataDict = dict["metadata"].asValueMap(); // try to read texture file name from meta data texturePath = metadataDict["textureFileName"].asString(); } if (!texturePath.empty()) { // build texture path relative to plist file texturePath = FileUtils::getInstance()->fullPathFromRelativeFile(texturePath.c_str(), plist); } else { // build texture path by replacing file extension texturePath = plist; // remove .xxx size_t startPos = texturePath.find_last_of("."); texturePath = texturePath.erase(startPos); // append .png texturePath = texturePath.append(".png"); CCLOG("cocos2d: SpriteFrameCache: Trying to use file %s as texture", texturePath.c_str()); } Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(texturePath.c_str()); if (texture) { addSpriteFramesWithDictionary(dict, texture); _loadedFileNames->insert(plist); } else { CCLOG("cocos2d: SpriteFrameCache: Couldn't load texture"); } } }
bool SpriteFrameCache::reloadTexture(const std::string& plist) { CCASSERT(plist.size()>0, "plist filename should not be nullptr"); auto it = _loadedFileNames->find(plist); if (it != _loadedFileNames->end()) { _loadedFileNames->erase(it); } else { //If one plist has't be loaded, we don't load it here. return false; } std::string fullPath = FileUtils::getInstance()->fullPathForFilename(plist); ValueMap dict = FileUtils::getInstance()->getValueMapFromFile(fullPath); string texturePath(""); if (dict.find("metadata") != dict.end()) { ValueMap& metadataDict = dict["metadata"].asValueMap(); // try to read texture file name from meta data texturePath = metadataDict["textureFileName"].asString(); } if (!texturePath.empty()) { // build texture path relative to plist file texturePath = FileUtils::getInstance()->fullPathFromRelativeFile(texturePath, plist); } else { // build texture path by replacing file extension texturePath = plist; // remove .xxx size_t startPos = texturePath.find_last_of("."); texturePath = texturePath.erase(startPos); // append .png texturePath = texturePath.append(".png"); } Texture2D *texture = nullptr; if (Director::getInstance()->getTextureCache()->reloadTexture(texturePath)) texture = Director::getInstance()->getTextureCache()->getTextureForKey(texturePath); if (texture) { reloadSpriteFramesWithDictionary(dict, texture); _loadedFileNames->insert(plist); } else { CCLOG("cocos2d: SpriteFrameCache: Couldn't load texture"); } return true; }
/// UpdateCallGraphAfterInlining - Once we have cloned code over from a callee /// into the caller, update the specified callgraph to reflect the changes we /// made. Note that it's possible that not all code was copied over, so only /// some edges of the callgraph may remain. static void UpdateCallGraphAfterInlining(CallSite CS, Function::iterator FirstNewBlock, ValueMap<const Value*, Value*> &VMap, InlineFunctionInfo &IFI) { CallGraph &CG = *IFI.CG; const Function *Caller = CS.getInstruction()->getParent()->getParent(); const Function *Callee = CS.getCalledFunction(); CallGraphNode *CalleeNode = CG[Callee]; CallGraphNode *CallerNode = CG[Caller]; // Since we inlined some uninlined call sites in the callee into the caller, // add edges from the caller to all of the callees of the callee. CallGraphNode::iterator I = CalleeNode->begin(), E = CalleeNode->end(); // Consider the case where CalleeNode == CallerNode. CallGraphNode::CalledFunctionsVector CallCache; if (CalleeNode == CallerNode) { CallCache.assign(I, E); I = CallCache.begin(); E = CallCache.end(); } for (; I != E; ++I) { const Value *OrigCall = I->first; ValueMap<const Value*, Value*>::iterator VMI = VMap.find(OrigCall); // Only copy the edge if the call was inlined! if (VMI == VMap.end() || VMI->second == 0) continue; // If the call was inlined, but then constant folded, there is no edge to // add. Check for this case. Instruction *NewCall = dyn_cast<Instruction>(VMI->second); if (NewCall == 0) continue; // Remember that this call site got inlined for the client of // InlineFunction. IFI.InlinedCalls.push_back(NewCall); // It's possible that inlining the callsite will cause it to go from an // indirect to a direct call by resolving a function pointer. If this // happens, set the callee of the new call site to a more precise // destination. This can also happen if the call graph node of the caller // was just unnecessarily imprecise. if (I->second->getFunction() == 0) if (Function *F = CallSite(NewCall).getCalledFunction()) { // Indirect call site resolved to direct call. CallerNode->addCalledFunction(CallSite::get(NewCall), CG[F]); continue; } CallerNode->addCalledFunction(CallSite::get(NewCall), I->second); } // Update the call graph by deleting the edge from Callee to Caller. We must // do this after the loop above in case Caller and Callee are the same. CallerNode->removeCallEdgeFor(CS); }
void Domain::Indices::Partition(const ValueMap& specified, const set<string>& dimensions, ValueMap& results) { ValueMap::const_iterator element; for(element = specified.begin(); element != specified.end(); element++) { if(dimensions.find(element->first) != dimensions.end()) { results[element->first] = element->second; } } }
/// RemapInstruction - Convert the instruction operands from referencing the /// current values into those specified by VMap. static inline void RemapInstruction(Instruction *I, ValueMap<const Value *, Value*> &VMap) { for (unsigned op = 0, E = I->getNumOperands(); op != E; ++op) { Value *Op = I->getOperand(op); ValueMap<const Value *, Value*>::iterator It = VMap.find(Op); if (It != VMap.end()) I->setOperand(op, It->second); } }
void *valmap_find(valmap_t map, LLVMValueRef v) { ValueMap<Value*,void*> *vmap = (ValueMap<Value*,void*>*)map; Value *val = unwrap(v); if(vmap->find(val)==vmap->end()) return NULL; return (*vmap)[val]; }
bool SparseMatrix::optimiseSAMG (bool transposed) { if (!editable) return false; ValueMap trans; // only computed if needed ValueIter begin, end; if (transposed) { for (const auto& it : elem) trans[IJPair(it.first.second,it.first.first)] = it.second; begin = trans.begin(); end = trans.end(); std::swap(nrow,ncol); } else { begin = elem.begin(); end = elem.end(); } size_t nnz = this->size(); A.resize(nnz); JA.resize(nnz); IA.resize(nrow+1,nnz+1); IA[0] = 1; // first row start at index 1 size_t cur_row = 1, ix = 0; for (ValueIter it = begin; it != end; ++it, ix++) { A[ix] = it->second; // storing element value JA[ix] = it->first.second; while (it->first.first > cur_row) IA[cur_row++] = ix+1; } editable = false; elem.clear(); // Erase the editable matrix elements // convert to row storage format required by SAMG (diagonal term first) for (size_t r = 0; r < nrow; r++) { int rstart = IA[r]-1; int rend = IA[r+1]-1; // looking for diagonal element for (int diag_ix = rstart; diag_ix < rend; diag_ix++) if (JA[diag_ix] == (int)(1+r)) { // swapping (if necessary) with first element on this row if (diag_ix > rstart) { std::swap(A[rstart],A[diag_ix]); std::swap(JA[rstart],JA[diag_ix]); } break; } } return true; }
void createTXTRecord_( TXTRecordRef& record ) { TXTRecordCreate( &record, 0, 0 ); for( ValueMapCIter i = data_.begin(); i != data_.end(); ++i ) { const std::string& key = i->first; const std::string& value = i->second; const uint8_t valueSize = value.length() > 255 ? 255 : uint8_t( value.length( )); TXTRecordSetValue( &record, key.c_str(), valueSize, value.c_str( )); } }
void SpriteFrameCache::addSpriteFramesWithDictionary(ValueMap& dict, const std::string &texturePath) { std::string pixelFormatName; if (dict.find("metadata") != dict.end()) { ValueMap& metadataDict = dict.at("metadata").asValueMap(); if (metadataDict.find("pixelFormat") != metadataDict.end()) { pixelFormatName = metadataDict.at("pixelFormat").asString(); } } Texture2D *texture = nullptr; static std::unordered_map<std::string, Texture2D::PixelFormat> pixelFormats = { {"RGBA8888", Texture2D::PixelFormat::RGBA8888}, {"RGBA4444", Texture2D::PixelFormat::RGBA4444}, {"RGB5A1", Texture2D::PixelFormat::RGB5A1}, {"RGBA5551", Texture2D::PixelFormat::RGB5A1}, {"RGB565", Texture2D::PixelFormat::RGB565}, {"A8", Texture2D::PixelFormat::A8}, {"ALPHA", Texture2D::PixelFormat::A8}, {"I8", Texture2D::PixelFormat::I8}, {"AI88", Texture2D::PixelFormat::AI88}, {"ALPHA_INTENSITY", Texture2D::PixelFormat::AI88}, //{"BGRA8888", Texture2D::PixelFormat::BGRA8888}, no Image conversion RGBA -> BGRA {"RGB888", Texture2D::PixelFormat::RGB888} }; auto pixelFormatIt = pixelFormats.find(pixelFormatName); if (pixelFormatIt != pixelFormats.end()) { const Texture2D::PixelFormat pixelFormat = (*pixelFormatIt).second; const Texture2D::PixelFormat currentPixelFormat = Texture2D::getDefaultAlphaPixelFormat(); Texture2D::setDefaultAlphaPixelFormat(pixelFormat); texture = Director::getInstance()->getTextureCache()->addImage(texturePath); Texture2D::setDefaultAlphaPixelFormat(currentPixelFormat); } else { texture = Director::getInstance()->getTextureCache()->addImage(texturePath); } if (texture) { addSpriteFramesWithDictionary(dict, texture); } else { CCLOG("cocos2d: SpriteFrameCache: Couldn't load texture"); } }
void Predator::loadAnimationFromDataFile(const char* animationDataKey){ ValueMap framesData = DataManager::getInstance()->_staticData\ .at("character").asValueMap()\ .at("hamster").asValueMap()\ .at(Value(_id).asString().c_str()).asValueMap()\ .at("animations").asValueMap()\ .at(animationDataKey).asValueMap(); int animationId = _animationsId.size(); _animationsId[std::string(animationDataKey)] = animationId; int animationFrameNum = framesData.at("animation_frame_num").asInt(); bool isAnimationLooping = framesData.at("loop").asBool(); //判断framesData中是否存有"animation_frame_index_start"的信息 bool doesDataIncludeFrameIndexStart = false; for (auto it = framesData.begin(); it != framesData.end(); it++){ if (it->first == std::string("animation_frame_index_start")){ doesDataIncludeFrameIndexStart = true; } } int animationFrameIndexStart; if (doesDataIncludeFrameIndexStart){ animationFrameIndexStart = _animationsFrameIndexStart[std::string(framesData.at("animation_frame_index_start").asString())]; } else{ animationFrameIndexStart = _animationsFrameIndexStart[std::string(animationDataKey)]; } ValueMap animationFrameSequence = framesData.at("animation_frame_sequence").asValueMap(); ValueMap animationDurationSequence = framesData.at("animation_duration_sequence").asValueMap(); _animationFrameSequences[animationId] = new int[animationFrameNum + 1]; _animationDurationSequences[animationId] = new int[animationFrameNum]; for (int animationFrameIndex = 0; animationFrameIndex < animationFrameNum; animationFrameIndex++){ _animationFrameSequences[animationId][animationFrameIndex] = animationFrameSequence[Value(animationFrameIndex).asString().c_str()].asInt() + animationFrameIndexStart; _animationDurationSequences[animationId][animationFrameIndex] = animationDurationSequence[Value(animationFrameIndex).asString().c_str()].asInt(); } if (isAnimationLooping){ _animationFrameSequences[animationId][animationFrameNum] = -1;//循环动画序列结尾标志 } else{ _animationFrameSequences[animationId][animationFrameNum] = -2;//非循环动画序列结尾标志 } }
void DayRecord::loadFromValueMap(ValueMap &map) { _day = map["day"].asInt(); _earned = map["earned"].asDouble(); _spent = map["spent"].asDouble(); _money = map["money"].asFloat(); _diamond = map["diamond"].asInt(); _reputation = map["reputation"].asFloat(); _soldItems.clear(); if (map.find("sold_items") != map.end()) { for (auto iter: map["sold_items"].asValueMap()) { _soldItems[iter.first] = iter.second.asInt(); } } _boughtItems.clear(); if (map.find("bought_items") != map.end()) { for (auto iter: map["bought_items"].asValueMap()) { _boughtItems[iter.first] = iter.second.asInt(); } } }
void Configure::SaveConfigGroup(ValueMap vals) { ofs_.open(conf_path_.c_str(), std::ios::app|std::ios::out); for (ValueMap::iterator it = vals.begin(); it != vals.end(); it++) { std::string title = it->first; if (title.empty()) continue; // title = title.substr(title.find_first_of(" ")+1); ofs_ << title << ": " << it->second << '\n'; } ofs_ << '\n'; ofs_.close(); }
void Histogram::insertZeroBoundaryValues(float xMin, float xMax) { if (_valueMap.empty()) { if (xMin<xMax) { _valueMap[xMin] = 0.0; _valueMap[xMax] = 0.0; } return; } float interval = 1.0f; float min_gap_for_single_insertion = interval*1.5; float min_gap_for_double_insertion = interval*2.5; if (xMin<_valueMap.begin()->first) { _valueMap[xMin] = 0.0; } if (xMax>_valueMap.rbegin()->first) { _valueMap[xMax] = 0.0; } ValueMap::iterator itr = _valueMap.begin(); float previous_x = itr->first; for(; itr != _valueMap.end(); ++itr) { float current_x = itr->first; float gap = current_x-previous_x; if (gap>min_gap_for_double_insertion) { _valueMap[previous_x+interval] = 0.0f; _valueMap[current_x-interval] = 0.0f; } else if (gap>min_gap_for_single_insertion) { _valueMap[(previous_x+current_x)*0.5]=0.0f; } previous_x = current_x; } }
void PlayLayer::initPointsVector(float offX) { Node *runOfPoint = NULL; int count = 0; ValueMap point; point = objects->getObject(std::to_string(count)); while (point.begin()!= point.end()) { float x = point.at("x").asFloat(); float y = point.at("y").asFloat(); runOfPoint = Node::create(); runOfPoint->setPosition(Point(x - offX , y )); this->pointsVector.pushBack(runOfPoint); count++; point = objects->getObject( std::to_string(count)); } runOfPoint = NULL; }
const std::string &getValue(const std::string &name, const std::string &defaultValue) const { ValueMap::const_iterator it = values.find(name); if(it == values.end()) { if ((flags & VALUEMAP_MASK_LOG_NONEXISTING) != 0) { std::string msg = std::string("ParserGroupData::getValue - Given key \""); msg += name; msg += std::string("\" does not exist, returning default value."); Logger::getInstance()->warning(msg.c_str()); } return defaultValue; } int *flag = const_cast<int *>(&((*it).second.second)); *flag |= VALUEMAP_MASK_REFERENCED; return (*it).second.first; }
string paramValueNumber(AstNode* nodep) { // Given a compilcated object create a number to use for param module assignment // Ideally would be relatively stable if design changes (not use pointer value), // and must return same value given same input node // Return must presently be numberic so doesn't collide with 'small' alphanumeric parameter names ValueMap::iterator it = m_valueMap.find(nodep); if (it != m_valueMap.end()) { return cvtToStr(it->second); } else { static int BUCKETS = 1000; V3Hash hash (nodep->name()); int bucket = hash.hshval() % BUCKETS; int offset = 0; NextValueMap::iterator it = m_nextValueMap.find(bucket); if (it != m_nextValueMap.end()) { offset = it->second; it->second = offset + 1; } else { m_nextValueMap.insert(make_pair(bucket, offset + 1)); } int num = bucket + offset * BUCKETS; m_valueMap.insert(make_pair(nodep, num)); return cvtToStr(num); } }
// Try to clone everything in the llvm::Value hierarchy. LLVMValueRef CloneValue(LLVMValueRef Src) { // First, the value may be constant. if (LLVMIsAConstant(Src)) return clone_constant(Src, M); // Function argument should always be in the map already. auto i = VMap.find(Src); if (i != VMap.end()) return i->second; if (!LLVMIsAInstruction(Src)) report_fatal_error("Expected an instruction"); auto Ctx = LLVMGetModuleContext(M); auto Builder = LLVMCreateBuilderInContext(Ctx); auto BB = DeclareBB(LLVMGetInstructionParent(Src)); LLVMPositionBuilderAtEnd(Builder, BB); auto Dst = CloneInstruction(Src, Builder); LLVMDisposeBuilder(Builder); return Dst; }
bool Session::snmpGet( const Identifier &identifier, Value &value, ErrorInfo *error ) { ValueMap vars; IdentifierList ids; ids << identifier; if ( !snmpGet( ids, vars, error ) ) return false; ValueMap::ConstIterator it = vars.find( identifier ); if ( it == vars.end() ) { if ( error ) *error = ErrorInfo( ErrorInfo::ErrMissingVariables ); return false; } value = it.data(); return true; }
void StartScene::addWayPoint() { DataModel *m = DataModel::getModel(); auto objects = this->_tileMap->objectGroupNamed("Objects"); WayPoint *wp = NULL; std::string stringWithFormat = "Waypoint"; int wayPointCounter = 0; ValueMap wayPoint; wayPoint = objects->objectNamed(stringWithFormat + to_string(wayPointCounter)); while (wayPoint.begin() != wayPoint.end()) { int x = wayPoint.at("x").asInt(); int y = wayPoint.at("y").asInt(); wp = WayPoint::create(); wp->setPosition(ccp(x, y)); m->waypoints.pushBack(wp); wayPointCounter++; wayPoint = objects->objectNamed(stringWithFormat + to_string(wayPointCounter)); } wp =NULL; }
const Value * AMDGPUDAGToDAGISel::getBasePointerValue(const Value *V) { if (!V) { return NULL; } const Value *ret = NULL; ValueMap<const Value *, bool> ValueBitMap; std::queue<const Value *, std::list<const Value *> > ValueQueue; ValueQueue.push(V); while (!ValueQueue.empty()) { V = ValueQueue.front(); if (ValueBitMap.find(V) == ValueBitMap.end()) { ValueBitMap[V] = true; if (dyn_cast<Argument>(V) && dyn_cast<PointerType>(V->getType())) { ret = V; break; } else if (dyn_cast<GlobalVariable>(V)) { ret = V; break; } else if (dyn_cast<Constant>(V)) { const ConstantExpr *CE = dyn_cast<ConstantExpr>(V); if (CE) { ValueQueue.push(CE->getOperand(0)); } } else if (const AllocaInst *AI = dyn_cast<AllocaInst>(V)) { ret = AI; break; } else if (const Instruction *I = dyn_cast<Instruction>(V)) { uint32_t numOps = I->getNumOperands(); for (uint32_t x = 0; x < numOps; ++x) { ValueQueue.push(I->getOperand(x)); } } else { assert(!"Found a Value that we didn't know how to handle!"); } } ValueQueue.pop(); } return ret; }
bool EventTrigger::init( class MapLogic* map_logic, const ValueMap& event_data ) { this->setMapLogic( map_logic ); _current_trigger_index = 0; _should_recycle = false; _event_data = event_data; const ValueMap& meta_data = event_data.at( "trigger_meta" ).asValueMap(); auto itr = meta_data.find( "trigger_relation" ); if( itr == meta_data.end() ) { _relation = "then"; } else { _relation = itr->second.asString(); } itr = meta_data.find( "is_repeated" ); if( itr == meta_data.end() ) { _is_repeat = false; } else { _is_repeat = itr->second.asBool(); } itr = event_data.find( "enabled" ); if( itr != event_data.end() ) { this->setEnabled( itr->second.asBool() ); } else { this->setEnabled( true ); } const ValueVector& trigger_data = event_data.at( "triggers" ).asValueVector(); _total_trigger_count = (int)trigger_data.size(); for( auto itr = trigger_data.begin(); itr != trigger_data.end(); ++itr ) { Trigger* trigger = Trigger::create( itr->asValueMap() ); this->addTrigger( trigger ); } return true; }