TEST(BlockTest, FindEdgeRecursive) { // To recurse, need two entries in block map, no instructions in // the block that have a name, a branch instruction to the second // block and a named instruction in the second block. When // calling findEdge with the first block, the id of the // instruction with a name in the second block should be returned. llvm::LLVMContext context; llvm::BasicBlock* fbblock = llvm::BasicBlock::Create(context); llvm::BasicBlock* sbblock = llvm::BasicBlock::Create(context); llvm::BranchInst* finstruction = llvm::BranchInst::Create(sbblock); llvm::BranchInst* sinstruction = llvm::BranchInst::Create(fbblock); pBlock fblock(new Block(0)); pBlock sblock(new Block(1)); pNode fnode(new Node(0)); pNode snode(new Node(1)); fbblock->getInstList().push_back(finstruction); sbblock->getInstList().push_back(sinstruction); fblock->appendNode(fnode); sblock->appendNode(snode); fnode->setInstruction(finstruction); snode->setInstruction(sinstruction); snode->setNodeLabel("test_label"); std::map<llvm::BasicBlock*, pBlock> blocks; blocks.insert(std::pair<llvm::BasicBlock*, pBlock>(fbblock, fblock)); blocks.insert(std::pair<llvm::BasicBlock*, pBlock>(sbblock, sblock)); ASSERT_EQ(1, fblock->findEdge(fbblock, blocks)); }
// split_nodes cannot have predecessors // they do not reject messages and always forward. // they reject edge reversals from successors. void TestSplitNode() { typedef tbb::flow::split_node<tbb::flow::tuple<int> > snode_type; tbb::flow::graph g; snode_type snode(g); tbb::flow::function_node<int> rcvr(g,tbb::flow::unlimited, receiverBody<int>()); REMARK("Testing split_node\n"); ASSERT(tbb::flow::output_port<0>(snode).my_successors.empty(), "Constructed split_node has successors"); // tbb::flow::output_port<0>(snode) tbb::flow::make_edge(tbb::flow::output_port<0>(snode), rcvr); ASSERT(!(tbb::flow::output_port<0>(snode).my_successors.empty()), "after make_edge, split_node has no successor."); snode.try_put(tbb::flow::tuple<int>(1)); g.wait_for_all(); g.reset(); ASSERT(!(tbb::flow::output_port<0>(snode).my_successors.empty()), "after reset(), split_node has no successor."); g.reset(tbb::flow::rf_clear_edges); ASSERT(tbb::flow::output_port<0>(snode).my_successors.empty(), "after reset(rf_clear_edges), split_node has a successor."); }
/*public*/ void Root::insert(const Envelope *itemEnv, void* item) { #if GEOS_DEBUG std::cerr<< "Root("<<this<<")::insert("<<itemEnv->toString()<<", "<<item<<") called"<<std::endl; #endif int index = getSubnodeIndex(itemEnv, origin); // if index is -1, itemEnv must cross the X or Y axis. if (index==-1) { #if GEOS_DEBUG std::cerr<<" -1 subnode index"<<std::endl; #endif add(item); return; } /* * the item must be contained in one quadrant, so insert it into the * tree for that quadrant (which may not yet exist) */ Node *node = subnode[index]; #if GEOS_DEBUG std::cerr<<"("<<this<<") subnode["<<index<<"] @ "<<node<<std::endl; #endif /* * If the subquad doesn't exist or this item is not contained in it, * have to expand the tree upward to contain the item. */ if (node==NULL || !node->getEnvelope()->contains(itemEnv)) { std::auto_ptr<Node> snode (node); // may be NULL node = 0; subnode[index] = 0; std::auto_ptr<Node> largerNode = Node::createExpanded(snode, *itemEnv); #if GEOS_DEBUG std::cerr<<"("<<this<<") created expanded node " << largerNode.get() << " containing previously reported subnode" << std::endl; #endif // Previous subnode was passed as a child of the larger one assert(!subnode[index]); subnode[index] = largerNode.release(); } #if GEOS_DEBUG std::cerr<<"("<<this<<") calling insertContained with subnode " << subnode[index] << std::endl; #endif /* * At this point we have a subquad which exists and must contain * contains the env for the item. Insert the item into the tree. */ insertContained(subnode[index], itemEnv, item); #if GEOS_DEBUG std::cerr<<"("<<this<<") done calling insertContained with subnode " << subnode[index] << std::endl; #endif //System.out.println("depth = " + root.depth() + " size = " + root.size()); //System.out.println(" size = " + size()); }
int main(int argc, char* argv[]) { if (!setupGLFW()) return 1; glfwWindowHint(GLFW_SAMPLES, 4); setupCoreGL(); #ifndef __APPLE__ const char* exePath = dirname(argv[0]); const char* resPath = "/Resources/"; const int newPathLen = strlen(exePath) + strlen(resPath) + 1; char newPath[newPathLen]; strcpy(newPath, exePath); strcat(newPath, resPath); int cwdError; if ((cwdError = chdir(newPath)) != 0) { perror(newPath); return 1; } #endif set_log_file(fopen("../Logs/uf.log", "a")); setDebug(DEBUG); setBind(DEBUG); #ifdef FULLSCREEN GLFWmonitor* monitor = glfwGetPrimaryMonitor(); const GLFWvidmode* vidmode = glfwGetVideoMode(monitor); int width = vidmode->width; int height = vidmode->height; const char* title = "Ultra Fighters"; GLFWwindow* window = glfwCreateWindow(width, height, title, monitor, NULL); #else int width = 640; int height = 480; const char* title = "Ultra Fighters"; GLFWwindow* window = glfwCreateWindow(width, height, title, NULL, NULL); #endif if (!window) { log_msg(LOG_ERROR, "GLFW3 window creation failed.\n"); return 1; } glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); char cwd[PATH_MAX]; getcwd(cwd, sizeof(cwd)); log_msg(LOG_INFO, "#####################################\n"); log_msg(LOG_INFO, "Started Ultra Fighters!\n"); log_msg(LOG_INFO, "Current Working Directory: %s\n", cwd); log_msg(LOG_INFO, "Started loop!\n"); GameScene scene(window); std::ifstream levelFile("levelname.txt"); std::string levelName; std::getline(levelFile, levelName); WavefrontObject room(levelName.c_str()); scene.addChild(&room); HUD hud; scene.addChild(&hud); SphereNode snode(glm::vec3(-2, 2, 4), 0.75); // @temp scene.addChild(&snode); // @temp Loop loop = Loop(&scene); loop.start(); while (!glfwGetKey(window, GLFW_KEY_ESCAPE) && !glfwWindowShouldClose(window)) { glfwPollEvents(); } log_msg(LOG_INFO, "Stopping program...\n"); loop.stop(); glfwTerminate(); return 0; }