static void mergeBlocks(ir::IRKernel& k, ir::ControlFlowGraph::iterator predecessor, ir::ControlFlowGraph::iterator block) { typedef std::vector<ir::Edge> EdgeVector; // delete the branch at the end of the predecessor auto branch = getBranch(predecessor); if(branch != 0) { delete branch; predecessor->instructions.pop_back(); } // move remaining instructions intro the predecessor predecessor->instructions.insert(predecessor->instructions.end(), block->instructions.begin(), block->instructions.end()); block->instructions.clear(); // track the block's out edges EdgeVector outEdges; for(auto edge = block->out_edges.begin(); edge != block->out_edges.end(); ++edge) { outEdges.push_back(**edge); } // remove the block k.cfg()->remove_block(block); // add the edges back in for(auto edge = outEdges.begin(); edge != outEdges.end(); ++edge) { k.cfg()->insert_edge(ir::Edge(predecessor, edge->tail, edge->type)); } }
static BlockSet getBlocksWithBackwardsBranches(CycleAnalysis* cycleAnalysis) { auto edges = cycleAnalysis->getAllBackEdges(); report(" Getting blocks with backwards branches"); BlockSet backwardsBranchBlocks; for(auto& edge : edges) { if(edge->type != ir::Edge::Branch) continue; auto block = edge->head; if(getBranch(block) == nullptr) continue; backwardsBranchBlocks.insert(block); report(" " << block->label()); } return backwardsBranchBlocks; }
std::string Offer::toJson() const { std::stringstream str_json; str_json << "{\n" << "\t\"id\": \"" << id_int << "\",\n" << "\t\"guid\": \"" << id << "\",\n" << "\t\"title\": \"" << Json::Utils::Escape(title) << "\",\n" << "\t\"description\": \"" << Json::Utils::Escape(description) << "\",\n" << "\t\"price\": \"\",\n" << "\t\"image\": \"" << Json::Utils::Escape(image_url) << "\",\n" << "\t\"swf\": \"" << Json::Utils::Escape(swf) << "\",\n" << "\t\"url\": \"" << Json::Utils::Escape(redirect_url) << "\",\n" << "\t\"token\": \"" << token << "\",\n" << "\t\"rating\": \"" << rating << "\",\n" << "\t\"width\": \"" << width << "\",\n" << "\t\"height\": \"" << height << "\",\n" << "\t\"campaign_id\": \"" << campaign_id << "\",\n" << "\t\"campaign_guid\": \"" << campaign_guid << "\",\n" << "\t\"branch\": \"" << getBranch() << "\"\n" << "}\n"; return str_json.str(); }
void QNodeTreeView::doSelectFC(const FieldContainerPtr &pFC) { if(pFC == getSelectedFC()) return; BranchType branch; QListViewItem *pSelectedItem = this->selectedItem (); if(getBranch(pFC, branch)) { expandBranch(branch); } else { QListViewItem *pItem = findItemInChildren(pFC, pSelectedItem); if(pItem) { this->setSelected (pItem, true); this->ensureItemVisible(pItem ); } } }
void DLVertex :: Print ( std::ostream& o ) const { o << "[d(" << getDepth(true) << "/" << getDepth(false) << "),s(" << getSize(true) << "/" << getSize(false) << "),b(" << getBranch(true) << "/" << getBranch(false) << "),g(" << getGener(true) << "/" << getGener(false) << "),f(" << getFreq(true) << "/" << getFreq(false) << ")] "; o << getTagName(); switch ( Type() ) { case dtAnd: // nothing to do (except for printing operands) case dtSplitConcept: break; case dtTop: // nothing to do case dtNN: return; case dtDataExpr: o << ' ' << *static_cast<const TDataEntry*>(getConcept())->getFacet(); return; case dtDataValue: // named entry -- just like concept names case dtDataType: case dtPConcept: case dtNConcept: case dtPSingleton: case dtNSingleton: o << '(' << getConcept()->getName() << ") " << (isNNameTag(Type()) ? "=" : "[=") << ' ' << getC(); return; case dtLE: o << ' ' << getNumberLE() << ' ' << getRole()->getName() << ' ' << getC(); return; case dtForall: o << ' ' << getRole()->getName() << '{' << getState() << '}' << ' ' << getC(); return; case dtIrr: o << ' ' << getRole()->getName(); return; case dtProj: o << ' ' << getRole()->getName() << ", " << getC() << " => " << getProjRole()->getName(); return; case dtChoose: o << ' ' << getC(); return; default: std::cerr << "Error printing vertex of type " << getTagName() << "(" << Type() << ")"; fpp_unreachable(); } // print operands of the concept constructor for ( const_iterator q = begin(); q != end(); ++q ) o << ' ' << *q; }
//-------------------------------------------------------------- // do a step of colonization. return true if added branch BOOL Colonization::colonize() { BOOL active = false; int branchCount = m_branches.length(); // for each leaf, find the closest branch point within the cutoff radius for (int i = m_leaves.length()-1; i >= 0; i--) { Leaf* leaf = getLeaf(i); if (!leaf->m_active) continue; leaf->m_closest = -1; double closestDist = INT_MAX; for (int j = 0; j < branchCount; j++) { Branch* branch = getBranch(j); // calculate distance mgPoint3 dir(leaf->m_pt); dir.subtract(branch->m_pt); double dist = dir.length(); if (dist < MIN_DISTANCE) { leaf->m_active = false; break; } if (dist > MAX_DISTANCE) continue; if (dist < closestDist) { leaf->m_closest = j; closestDist = dist; } } // update growth of closest branch if (leaf->m_closest != -1) { Branch* branch = getBranch(leaf->m_closest); // calculate vector to branch mgPoint3 dir(leaf->m_pt); dir.subtract(branch->m_pt); dir.normalize(); // double dist = dir.length(); // dist = pow(dist, 1.5); // add normalized vector branch->m_growDir.add(dir); branch->m_growCount++; } } // for each branch for (int j = 0; j < branchCount; j++) { Branch* branch = getBranch(j); // if there's growth, add a new branch if (branch->m_growCount != 0) { // normalize the growth direction branch->m_growDir.scale(1.0/branch->m_growCount); branch->m_growDir.normalize(); branch->m_growDir.scale(GROW_DISTANCE); // create a new branch Branch* twig = new Branch(); twig->m_pt = branch->m_pt; twig->m_pt.add(branch->m_growDir); twig->m_parent = j; twig->m_growDir = mgPoint3(0,0,0); twig->m_growCount = 0; twig->m_area = TWIG_AREA; m_branches.add(twig); // reset growth vector on branch branch->m_growDir = mgPoint3(0,0,0); branch->m_growCount = 0; active = true; } } return active; }