/**
 * Removes specified instructions if they have the same exception node.
 * @param oinst - exception creating instruction
 * @param iinst - constructor call instruction
 * @return <code>true</code> if instruction were removed;
 *         <code>false<code> otherwise.
 */
bool
LazyExceptionOpt::removeInsts(Inst* oinst,Inst* iinst) {
    ControlFlowGraph& fg = irManager.getFlowGraph();
    Edge* oedge = oinst->getNode()->getExceptionEdge();
    Edge* iedge = iinst->getNode()->getExceptionEdge();
    Node* otn = oedge->getTargetNode();
    Node* itn = iedge->getTargetNode();

    if (otn!=itn) {
#ifdef _DEBUG
        if (Log::isEnabled()) {
            Log::out() << "    removeInsts: diff.exc.edges for obj&init ";
            Log::out() << otn->getId() << "  "  << itn->getId() << std::endl;
            Log::out() << "   ";
            oinst->print(Log::out());
            Log::out() << std::endl;
            Log::out() << "   ";
            iinst->print(Log::out());
            Log::out() << std::endl;
        }
#endif
        return false;
    }
    oinst->unlink();
    iinst->unlink();
    if (otn->getInEdges().size() > 1) {
        fg.removeEdge(oedge);
    } else
        removeNode(otn);
    if (itn->getInEdges().size() > 1) {
        fg.removeEdge(iedge);
    } else
        removeNode(itn);
    return true;
}
Example #2
0
 void testUnlabelledNode() {
     for (int i = 0; i < 10; i++) {
         int* val = new int(i);
         Node<int> node = Node<int>(*val);
         ASSERT(node.getId() == i, "Id should be same i:" << i << "Id: " << node.getId());
         ASSERT(node.getLabel() == Node<int>::DEFAULT_LABEL, "Label Wrongly initialized Label:" << node.getLabel());
         ASSERT(node.getValue() == *val, "Value set wrong val: " << *val << " Node Val: " << node.getValue());
     }
     cout << "testUnlabelledNode Done!" << endl;
 }
Example #3
0
void IpfCfgCodeSelector::genExceptionEdge(U_32 tailNodeId, 
                                          U_32 headNodeId, 
                                          double prob) {

    Node *tailNode = nodes[tailNodeId];
    Node *headNode = nodes[headNodeId];

    IPF_LOG << "    Generate Exception     edge node" << tailNode->getId();
    IPF_LOG << " -> node" << headNode->getId() << endl;
    Edge *edge = new(mm) Edge(tailNode, headNode, prob, EDGE_DISPATCH);
    edge->insert();
}
Example #4
0
inline void
_ITM_transaction::registerOnCommit(_ITM_userCommitFunction f,
                                  _ITM_transactionId_t tid, void* arg)
{
    Node* scope = inner();
    while (scope->getId() > tid) {
        scope = inner();
    }

    assert(scope->getId() == tid && "asked for a scope that doesn't exist");
    scope->registerOnCommit(f, arg);
}
Example #5
0
RaftConsensus::Connection::Ptr RaftConsensus::findOrCreateConnection(Node& node)
{
  Connection::Ptr pConnection;
  pConnection = findConnection(node.getId());
  if (!pConnection)
  {
    pConnection = createConnection(node);
    if (pConnection)
    {
      storeConnection(node.getId(), pConnection);
    }
  }
  return pConnection;
}
Example #6
0
void IpfCfgCodeSelector::genCatchEdge(U_32  tailNodeId, 
                                      U_32  headNodeId, 
                                      U_32  priority, 
                                      Type   *exceptionType, 
                                      double  prob) {

    Node *tailNode = nodes[tailNodeId];
    Node *headNode = nodes[headNodeId];

    IPF_LOG << "    Generate Catch         edge node" << tailNode->getId();
    IPF_LOG << " -> node" << headNode->getId() << endl;

    ExceptionEdge *edge = new(mm) ExceptionEdge(tailNode, headNode, prob, exceptionType, priority);
    edge->insert();
}
void makeVector_b (Graph *g)
{
	Node *ptr;
	b = new double[g->getTotalNodes()];
	ptr = g->getListNodes();
	while (ptr != NULL)
	{
		// Condição de Neumann
		if (ptr->getNumEdges() == 1 && !ptr->getStimulus())
			b[ptr->getId()-1] = 0.0;
		else
			b[ptr->getId()-1] = ptr->getVolume()->V_star;
		ptr = ptr->getNext();
	}
}
Example #8
0
bool Board::killMarble(Marble * marbleToKill){
    if(marbleToKill != NULL){
        Node * marbleNode = marbleToKill->getMyNode();
        Node * deadNode = nodes[firstFreeDeadMarble]; // get an empty dead node
        deadNode->setMarble(marbleToKill); // put the marble in it
        marbleNode->setMarble(NULL); // set the previous node marble to null
        deadNode->getMarble()->setMyNode(deadNode);
        cout << "killed " << marbleNode->getId() << " to " << deadNode->getId() << endl;
        firstFreeDeadMarble++ ;
        return true;
    }
    else{
        cout << "No marble to kill !" << endl;
        return false;
    }
}
Example #9
0
	void insert(Node val)
	{
		if (isEmpty() || val.getG() < start->getG())
		{
			Node * temp = start;
			start = new Node;
			start->next = temp;
			start->depth = val.depth;
			start->g = val.g;
			start->parent = val.parent;
			start->state = val.state;
			start->id = val.id;
		}
		else
		{
			Node * p = start;
			while (p->next != NULL && p->next->getDepth() < val.getDepth())
				p = p->next;

			Node * temp = p->next;

			p->next = new Node;
			p = p->next;
			p->next = temp;
			p->depth = val.depth;
			p->g = val.g;
			p->parent = val.parent;
			p->state = val.state;
			p->id = val.getId();

		}
	}
Example #10
0
void Tetgen::removeSuperTetra()
{
	Node* pnd;

	int n = getSize();
	for(int i = 0; i < n; i++)
	{
		getTetra(i)->setState(0);
		for(int j = 0; j < 4; j++)
		{
			pnd = getTetra(i)->getNode(j);
			if(pnd->getId() < 0)
			{
				getTetra(i)->setState(-1);
				break;
			}
		}
	}
	removeTetrahedra();

	for(int i = 0; i < 4; i++)
	{
		delete sptet_nd[i];
		sptet_nd[i] = NULL;
	}
}
// Update layoutValue information for all successors of node that have not yet been laid out. 
// If a successor is a dispatch node, recursively process its successors, since 
// dispatch nodes are not being laid out.
void TopDownLayout::processSuccLayoutValue(Node *node,  BasicBlock * layoutSucc) {
    const Edges& outEdges = node->getOutEdges();
    for (Edges::const_iterator ite = outEdges.begin(), ende = outEdges.end(); ite!=ende; ++ite) {
        Edge* edge = *ite;
        Node *succ = edge->getTargetNode();
        if (succ->isDispatchNode()) {
            processSuccLayoutValue(succ, layoutSucc);
        } else if (succ->isBlockNode()) {
            TopDownLayoutBlockInfo* succInfo = blockInfos[succ->getId()];
            if (succ != layoutSucc && !succInfo->isLayouted()) {
                if (succInfo->isLayoutNeighbour()) { //remove from sorted map and insert latter to sort again.
                    neighboursBlocks.erase(succInfo);
                } 
                succInfo->layoutValue+=node->getExecCount() * edge->getEdgeProb();
                succInfo->state = TopDownLayoutBlockInfo::LAYOUT_NEIGHBOUR;
                neighboursBlocks.insert(succInfo);

                if (Log::isEnabled()) {
                    Log::out() << "Block ";
                    IRPrinter::printNodeName(Log::out(), succInfo->block);
                    Log::out() << " is in neighbors set." << std::endl;
                }
            }
        } 
    }
}
Example #12
0
string TreeTemplateTools::nodeToParenthesis(const Node& node, bool writeId)
{
  ostringstream s;
  if (node.hasNoSon())
  {
    s << node.getName();
  }
  else
  {
    s << "(";
    s << nodeToParenthesis(*node[0], writeId);
    for (int i = 1; i < static_cast<int>(node.getNumberOfSons()); i++)
    {
      s << "," << nodeToParenthesis(*node[i], writeId);
    }
    s << ")";
  }
  if (writeId)
  {
    if (node.hasNoSon())
      s << "_";
    s << node.getId();
  }
  else
  {
    if (node.hasBranchProperty(TreeTools::BOOTSTRAP))
      s << (dynamic_cast<const Number<double>*>(node.getBranchProperty(TreeTools::BOOTSTRAP))->getValue());
  }
  if (node.hasDistanceToFather())
    s << ":" << node.getDistanceToFather();
  return s.str();
}
Example #13
0
unsigned int Node::getSonPosition(const Node & son) const throw (NodeNotFoundException)
{
  for(unsigned int i = 0; i < _sons.size(); i++) {
    if(_sons[i] == &son) return i;
  }
  throw NodeNotFoundException("Son not found", TextTools::toString(son.getId()));
}
Example #14
0
/// This is supposed to clear the scopes up to the specified ID, without
/// checking for conflicts. This can't be implemented by RSTM yet.
inline void
_ITM_transaction::commitToId(_ITM_transactionId_t id) {
    assert(false && "commitToId not yet implemented.");
    for (Node* scope = inner(); scope->getId() > id; scope = inner()) {
        // rstm_merge_scopes_without_aborting
        scope->commit();
        leave();
    }
}
Example #15
0
/** \author	20140416 - Magnus Øverbø	
	* \brief	Displays the inforation about the weight link
	*	
	*	Prints the weights id number, the linked nodes ID, the value of the weight,
	*	the nodes input value and the nodes output value.  Then it moves to the
	*	next weight in the list and repeats the process
	**/
void Weight::display(){
	cout << "\n     "	<< right	<< setw(3) 	<<	id 							//weight id
			 << " [ "			<< right	<< setw(3)	<<	to->getId() 		//linked nodes id
			 << "   "			<< left		<< setw(11) <<	weight					//weight value
			 << "   " 		<< left		<< setw(11)	<<	to->getInput()	//linked nodes in
			 << "   " 		<< left		<< setw(11)	<<	to->getOutput()	// and output val
			 << " ]";
	if( next != NULL )	next->display();	//go to next weight and print it
}
Example #16
0
void TreeTemplateTools::getBranchProperties(Node& node, const string& propertyName, map<int, Clonable*>& properties)
{
  if (node.hasBranchProperty(propertyName))
    properties[node.getId()] = node.getBranchProperty(propertyName);
  for (size_t i = 0; i < node.getNumberOfSons(); i++)
  {
    getBranchProperties(*node.getSon(i), propertyName, properties);
  }
}
Example #17
0
QMimeData* TreeModel::mimeData(const QModelIndexList &indexes) const
{
	QMimeData *mimeData = new QMimeData();
	// only one node can be selected at a time
	Node *node = getItem(indexes.first());
	if (node)
		mimeData->setData("application/silence-nodeid", node->getId().toByteArray());
	return mimeData;
}
Example #18
0
U_32  IpfCfgCodeSelector::genUnwindNode(U_32 numInEdges, 
                                          U_32 numOutEdges, 
                                          double cnt) {

    Node *node = new(mm) Node(mm, opndManager->getNextNodeId(), (U_32) cnt, NODE_UNWIND);
    nodes.push_back(node);

    IPF_LOG << endl << "    Generate Unwind node" << node->getId() << endl;
    return nodes.size()-1;
}
Example #19
0
Node* Crowd::makeNewNode(double x,double y,double z,double density)
{
	Node* pnd;

	pnd = GpNode::makeNewNode(x,y,z,density);

	binlist.push_back(pnd->getId() - 1);

	return pnd;
}
Example #20
0
// for command "CANCEL [name]"
void File::cancel_name(string text)
{
	// extract name in text
	string name = getName(text);
	
	// search for the node to be deleted
	Node* node = BST_name->find(name);
	Node* root = BST_name->getRoot();
	
	// return if node do not exists 
	if(!node) {
		cout << "Do not exists!" << endl << endl;	
		return;
	}

	// pop a node in queue if reservatio status is 'confirm' 
	if(!Queue_wait->isEmpty()) queueSize--;
	if(!node->reserved()) {
		Queue_wait->remove(node);
	}
	else {
		Node* queueNode = Queue_wait->pop();
		if(queueNode) queueNode->setReserved();
	}
	
	// print result
	print_separator();
	outputStream << node->getName() << "\t"
				<< node->getPhoneNum() << "\t\t"
				<< node->getId() << "\t\t\t"
				<< "cancel" << endl << endl;
			
	cout << node->getName() << "\t"
			<< node->getPhoneNum() << "\t\t"
			<< node->getId() << "\t\t\t"
			<< "cancel" << endl << endl;

	treeSize--;
	BST_name->remove(root, node->getName(), false);
	BST_phoneNum->remove(root, node->getPhoneNum(), false);
	BST_id->remove(root, node->getId(), true);
}
Example #21
0
U_32 IpfCfgCodeSelector::genDispatchNode(U_32 numInEdges, 
                                           U_32 numOutEdges, 
                                           const StlVector<MethodDesc*>& inlineInfo,
                                           double cnt) {

    Node *node = new(mm) Node(mm, opndManager->getNextNodeId(), (U_32) cnt, NODE_DISPATCH);
    nodes.push_back(node);

    IPF_LOG << endl << "    Generate Dispatch node" << node->getId() << endl;
    return nodes.size()-1;
}
Example #22
0
size_t ParametrizableTree::buildIndex_(Node& node, size_t nPar)
{
  size_t npar = nPar;
  
  if (node.hasFather()) {
    index_[node.getId()] = npar;
  
    double d = minimumBrLen_;
    if (!node.hasDistanceToFather())
    {
      ApplicationTools::displayWarning("Missing branch length " + TextTools::toString(node.getId()) + ". Value is set to " + TextTools::toString(minimumBrLen_));
      node.setDistanceToFather(minimumBrLen_);
    }
    else
    {
      d = node.getDistanceToFather();
      if (d < minimumBrLen_)
      {
        ApplicationTools::displayWarning("Branch length " + TextTools::toString(node.getId()) + " is too small: " + TextTools::toString(d) + ". Value is set to " + TextTools::toString(minimumBrLen_));
        node.setDistanceToFather(minimumBrLen_);
        d = minimumBrLen_;
      }
      if (d > maximumBrLen_)
      {
        ApplicationTools::displayWarning("Branch length " + TextTools::toString(node.getId()) + " is too big: " + TextTools::toString(d) + ". Value is set to " + TextTools::toString(maximumBrLen_));
        node.setDistanceToFather(maximumBrLen_);
        d = maximumBrLen_;
      }
    }
    //if (!hasParameter("BrLen" + TextTools::toString(node.getId()))){
    addParameter_(new Parameter("BrLen" + TextTools::toString(node.getId()), d, brLenConstraint_->clone(), true)); // Attach constraint to avoid clonage problems!
    //}
    npar++;
  }
    
  //Now apply recursively:
  for (unsigned int i = 0; i < node.getNumberOfSons(); ++i)
    npar = buildIndex_(*node[i], npar);

  return npar;
}
Example #23
0
RouteNode::RouteNode(Node node, int prevWayId, double rating, double distanceFromStart, RouteNode *prevNode, bool routing, PartitionFile *pf) :
                                                    Node(node.getId(), node.getCell(), node.getLon(), node.getLat(), pf),
                                                                                prevWayId(prevWayId),
                                                                                rating(rating),
                                                                                distanceFromStart(distanceFromStart),
                                                                                routing(routing),
                                                                                prevNode(prevNode) {
    ways = node.getWays();
    boundaryEdges = node.getBoundaryEdges();
    routingEdges = node.getRoutingEdges();
    part = node.getPartitionFile();
}
Example #24
0
bool InWayNodeFilter::isFiltered(const Node& n) const
{
  bool found = _nids.find(n.getId()) != _nids.end();
  if (_type == KeepMatches)
  {
    return !found;
  }
  else
  {
    return found;
  }
}
Example #25
0
// Get all paths from src and destination using recursive
void Graph::__form_path(Node& src, Node& dest, std::vector<Path>& nPathList,
        Path& nPath)
{
    src.set_visited(true);
    nPath.push_back(src.getId());

    if (src.getId() == dest.getId()) {
        nPathList.push_back(nPath);
    }
    else {
        NodeIDList outNodes = src.get_adjency_list(OUT);
        for (int i = 0; i < outNodes.size(); ++i) {
            Node* node = get_node_from_id(outNodes[i]);
            if ( (node) && (!(node->is_visited())) ) {
                __form_path(*node, dest, nPathList, nPath);
            }
        }
    }
    src.set_visited(false);
    nPath.pop_back();
}
Example #26
0
// for command "CANCEL [phone]"
void File::cancel_phoneNum(string text)
{
	// extract phone number in text
	string phoneNum = getPhoneNum(text);

	// searh for the node to be deleted
	Node* node = BST_phoneNum->find(phoneNum);
	Node* root = BST_phoneNum->getRoot();

	// if node do not exists return
	if(!node) {
		cout << "Do not exists!" << endl << endl;	
		return;
	}

	if(!Queue_wait->isEmpty()) queueSize--;
	if(!node->reserved()) {
		Queue_wait->remove(node);
	}
	else {
		Node* queueNode = Queue_wait->pop();
		if(queueNode) queueNode->setReserved();
	}
	
	// print result
	print_separator();
	outputStream << node->getName() << "\t"
			<< node->getPhoneNum() << "\t\t"
			<< node->getId() << "\t\t\t"
			<< "cancel" << endl << endl;
			
	cout << node->getName() << "\t"
			<< node->getPhoneNum() << "\t\t"
			<< node->getId() << "\t\t\t"
			<< "cancel" << endl << endl;
			
	BST_name->remove(root, node->getName(), false);
	BST_phoneNum->remove(root, node->getPhoneNum(), false);
	BST_id->remove(root, node->getId(), true);
}
Example #27
0
string SwitchNodeGenerator::generateCode(NclDocument* nclDocument) {
    string ret = "<switch id=\"" + this->getId() + "\" >";

    Node* defaultNode = this->getDefaultNode();
    if (defaultNode != NULL) {
        ret += "<defaultComponent component=\"" + defaultNode->getId() + "\" />";
    }

    vector<Node*>* nodes = this->getNodes();
    vector<Node*>::iterator itNode;
    itNode = nodes->begin();
    while (itNode != nodes->end()) {
        Node* node = *itNode;
        if (node->instanceOf("ReferNode")) {
            ReferNode* referNode = (ReferNode*)node;
            ret += GeneratorUtil::referNodeCodeGenerate(referNode, nclDocument);
        } else if (node->instanceOf("ContextNode")) {
            ContextNode * contextNode = (ContextNode*)node;
            ret+= static_cast<ContextNodeGenerator*>(contextNode)->generateCode(nclDocument) + "\n";
        } else if (node->instanceOf("ContentNode")) {
            ContentNode* contentNode = (ContentNode*)node;
            ret+= static_cast<ContentNodeGenerator*>(contentNode)->generateCode() + "\n";
        } else if (node->instanceOf("SwitchNode")) {
            SwitchNode* switchNode = (SwitchNode*) node;
            ret+= static_cast<SwitchNodeGenerator*>(switchNode)->generateCode(nclDocument) + "\n";
        }
        itNode++;
    }

    unsigned int numRules = this->getNumRules();
    if (numRules > 0) {
        for (int index = 0; index < numRules; index++) {
            Rule* rule = this->getRule(index);
            Node* node = this->getNode(rule);
            ret += "<bindRule rule=\"" + rule->getId() + "\" ";
            ret += "constituent=\"" + descriptor->getId() + "\" />\n";
        }
    }

    vector<Port*>* ports = this->getPorts();
    vector<Port*>::iterator itPorts;
    itPorts = ports->begin();
    while (itPorts != ports->end()) {
        Port* port = *itPorts;
        if (port->instanceOf("SwitchPort")) {
            SwitchPort* switchPort = (SwitchPort*) port;
            ret += (static_cast<SwitchPortGenerator*>(switchPort))->generateCode() + "\n";
        }
    }
    ret += "</switch>\n";
    return ret;
}
Example #28
0
bool SwitchNode::removeNode( Node *node ) {
	int i, size;
	Node *auxNode;

	size = CompositeNode::nodes->size();
	for (i = 0; i < size; i++) {
		auxNode = (Node*) (*CompositeNode::nodes)[i];
		if (auxNode->getId() == node->getId()) {
			return removeNode( i );
		}
	}
	return false;
}
Example #29
0
// Delete node from graph that results in removing all edges that
// the given node links with other node
void Graph::delete_node(Node& node)
{
    NodeIDList adj_list = node.get_adjency_list();
    for (int i = 0; i < adj_list.size(); ++i) {
        NodeListIter nIter = __mNodes.find(adj_list[i]);
        if (nIter != __mNodes.end()) {
            (nIter->second)->remove_edge_with_node(node, ALL);
        }
    }
    node.unlink_all_edges();
    // Remove from the Nodes list
    __mNodes.erase(node.getId());
}
Example #30
0
        void testLabelledNode() {
            for (int i = 0; i < 10; i++) {
                int* val = new int(i);
                string label = Node<int>::createRandomLabels(i);
                Node<int> node = Node<int>(*val, label);

                ASSERT(node.getId() == i + 10, "Id should be same i:" << i << "Id: " << node.getId());
                ASSERT(node.getLabel() == label, "Label Wrongly initialized Label: " << label << " Node Label: " << node.getLabel());
                ASSERT(node.getValue() == *val, "Value set wrong val: " << *val << " Node Val: " << node.getValue());
            }

            cout << "testLabelledNode Done!" << endl;
        }