Beispiel #1
0
//------------------------------------------------------------------------------
void TreeDrawer::CalcCoordinates ()
{
	double l = t->GetNumLeaves();
    leafGap = height / (l - 1.0);
	if (rooted)
    	nodeGap = width / l;
    else
    	nodeGap = width / (l - 1.0);
	leafCount = 0;

    if (rooted)
    {
    	// Allow for edge below root
    	left += nodeGap;
        width -= nodeGap;
    }

    NodeIterator <Node> n (t->GetRoot());
    Node *q = n.begin();
    while (q)
    {
    	if (q->IsLeaf ())
        {
        	CalcLeaf (q);
        }
        else
        {
			CalcInternal (q);
        }

        q = n.next();
    }

}
Beispiel #2
0
WordGraph::WordGraph(const WordGraph &o)
    : QObject(o.parent()), m_disabledNodes(o.m_disabledNodes), m_disabledEdges(o.m_disabledEdges),
      m_centralNodeId(o.m_centralNodeId), m_signalsEnabled(false)
{
    ConstNodeIterator nodeIterEnd = o.m_nodes.constEnd();
    ConstNodeIterator nodeIter;
    for (nodeIter = o.m_nodes.constBegin(); nodeIter != nodeIterEnd; ++nodeIter) {
        m_nodes[nodeIter.key()] = nodeIter.value()->clone();
        m_nodes[nodeIter.key()]->m_graph = this;
    }

    ConstEdgeIterator edgeIterEnd = o.m_edges.constEnd();
    ConstEdgeIterator edgeIter;
    for (edgeIter = o.m_edges.constBegin(); edgeIter != edgeIterEnd; ++edgeIter) {
        Edge *cloneEdge = edgeIter.value()->clone();
        cloneEdge->m_graph = this;
        cloneEdge->m_source = m_nodes[cloneEdge->m_source->id()];
        cloneEdge->m_dest = m_nodes[cloneEdge->m_dest->id()];
        m_edges[edgeIter.key()] = cloneEdge;
    }

    // Replace each node edges with this graph edges.
    NodeIterator myNodeIterEnd = m_nodes.end();
    for (NodeIterator iter = m_nodes.begin(); iter != myNodeIterEnd; ++iter) {
        QSet<Edge*> newEdges;
        QSet<Edge*> curEdges = iter.value()->edges();
        foreach (Edge *edge, curEdges)
            newEdges << m_edges[edge->id()];

        iter.value()->m_edges = newEdges;
    }
}
JSValue jsNodeIteratorPointerBeforeReferenceNode(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
    JSNodeIterator* castedThis = static_cast<JSNodeIterator*>(asObject(slot.slotBase()));
    UNUSED_PARAM(exec);
    NodeIterator* imp = static_cast<NodeIterator*>(castedThis->impl());
    return jsBoolean(imp->pointerBeforeReferenceNode());
}
Beispiel #4
0
void PullSend::Execute() {
  if (_resched) {
    Action* ps_event = new PullSend(_node, _sched, _net, _resched);
    _sched.after(ps_rate, ps_event);
  }

  LitterNode& lnode = dynamic_cast<LitterNode&>(_node);
  if (lnode.getOnline() == false) return;

  int end = _sched.getCurrentTime();
  int start = lnode.getLastPull();
  lnode.setLastPull(_sched.getCurrentTime());

  int delay = 0;
  NodeIterator* ni = lnode.getNeighborIT();
  while (ni->moveNext()) {
    Node* neighbor = ni->current();
    LitterNode& dest = dynamic_cast<LitterNode&>(*neighbor);
    if (dest.getOnline() == true) {
      Action* pr_event = new PullRcv(*neighbor, _node, _sched, _net, start, 
                                      end);
      LitterNetwork& lnet = dynamic_cast<LitterNetwork&>(_net);
      lnet.send(lnode, dest, *pr_event, _sched, delay++);
      lnode.stats.pulltx++;
    }
  }
}
JSValue jsNodeIteratorReferenceNode(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
    JSNodeIterator* castedThis = static_cast<JSNodeIterator*>(asObject(slot.slotBase()));
    UNUSED_PARAM(exec);
    NodeIterator* imp = static_cast<NodeIterator*>(castedThis->impl());
    return toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->referenceNode()));
}
Beispiel #6
0
void CheckGap::send(Node& node, int start, int end) {
  LitterNode& lnode = dynamic_cast<LitterNode&>(_node);
  LitterNode& dnode = dynamic_cast<LitterNode&>(node);

  lnode.stats.gapfound++;

  if (dnode.getOnline() == true) {
    Action* pr_event = new GapRcv(node, _node, _sched, _net,
                                    start, end, node);
    LitterNetwork& lnet = dynamic_cast<LitterNetwork&>(_net);
    lnet.send(lnode, dnode, *pr_event, _sched);
    lnode.stats.gaptx++;
  }
  else {
    NodeIterator* ni = lnode.getNeighborIT();
    while (ni->moveNext()) {
      Node* neighbor = ni->current();
      LitterNode& dest = dynamic_cast<LitterNode&>(*neighbor);
      if (dest.getOnline() == true) {
        LitterNetwork& lnet = dynamic_cast<LitterNetwork&>(_net);
        if ( lnet.isNeighbor(dnode, dest)) {
          Action* pr_event = new GapRcv(*neighbor, _node, _sched, _net,
                                          start, end, node);
          lnet.send(lnode, dest, *pr_event, _sched);
          lnode.stats.gaptx++;
          break;
        }
      }
    }
  }
}
//-----------------------------------------------------------------------------
TEST(conduit_blueprint_mcarray_examples, mcarray_xyz)
{
    // we are using one node to hold group of example mcarrays purely out of 
    // convenience
    Node dsets;
    index_t npts = 100;
    
    blueprint::mcarray::examples::xyz("interleaved",
                                  npts,
                                  dsets["interleaved"]);

    blueprint::mcarray::examples::xyz("separate",
                                  npts,
                                  dsets["separate"]);

    blueprint::mcarray::examples::xyz("contiguous",
                                  npts,
                                  dsets["contiguous"]);
    NodeIterator itr = dsets.children();
    
    while(itr.has_next())
    {
        Node info;
        Node &mcarray = itr.next();
        std::string name = itr.name();
        // TODO: tests!
    }
}
Beispiel #8
0
JSValue* JSNodeIteratorPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
{
    if (!thisObj->inherits(&JSNodeIterator::info))
      return throwError(exec, TypeError);

    NodeIterator* imp = static_cast<NodeIterator*>(static_cast<JSNodeIterator*>(thisObj)->impl());

    switch (id) {
    case JSNodeIterator::NextNodeFuncNum: {
        ExceptionCode ec = 0;


        KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->nextNode(ec)));
        setDOMException(exec, ec);
        return result;
    }
    case JSNodeIterator::PreviousNodeFuncNum: {
        ExceptionCode ec = 0;


        KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->previousNode(ec)));
        setDOMException(exec, ec);
        return result;
    }
    case JSNodeIterator::DetachFuncNum: {

        imp->detach();
        return jsUndefined();
    }
    }
    return 0;
}
Beispiel #9
0
Node *FEMesh::closestNode(const double x, const double y, const double z=0)
#endif
{
  double min=1.;   // (initial value provided to suppress compiler warnings)
  Node *node, *thenode=0;
  for(NodeIterator ni = node_iterator(); !ni.end(); ++ni) {
    node = ni.node();
    double dx = node->position()(0) - x;
    double dy = node->position()(1) - y;
#if DIM==2
    double dist = dx*dx + dy*dy;
#elif DIM==3
    double dz = node->position()(2) - z;
    double dist = dx*dx + dy*dy + dz*dz;
#endif
    if (ni.begin()) {
      min = dist;
      thenode = node;
    }
    else {
      if (dist <= min) {
	min = dist;
	thenode = node;
      }
    }
  }
  return thenode;
}
Beispiel #10
0
//------------------------------------------------------------------------------
void RectangleTreeDrawer::CalcCoordinates ()
{
	t->MakeNodeList();
    maxDepth = 0;
    // Clear internal node depths
    for (int i = t->GetNumLeaves(); i < t->GetNumNodes(); i++)
    {
    	(*t)[i]->SetDepth(0);
    }
    for (int i = 0; i < t->GetNumLeaves();  i++)
    {
    	NodePtr p = (*t)[i]->GetAnc();
        int count = 1;
        while (p)
        {
        	if (count > p->GetDepth())
            {
            	p->SetDepth(count);
                if (count > maxDepth)
                	maxDepth = count;
            }
            count++;
            p = p->GetAnc();
        }
    }

 	double l = t->GetNumLeaves();
    leafGap = height / (l - 1.0);
	l = maxDepth + 1.0;
	if (rooted)
    	nodeGap = width / l;
    else
    	nodeGap = width / (l - 1.0);
	leafCount = 0;

    if (rooted)
    {
    	// Allow for edge below root
    	left += nodeGap;
        width -= nodeGap;
    }

    NodeIterator <Node> n (t->GetRoot());
    Node *q = n.begin();
    while (q)
    {
    	if (q->IsLeaf ())
        {
        	CalcLeaf (q);
        }
        else
        {
			CalcInternal (q);
        }

        q = n.next();
    }

}
Beispiel #11
0
JSValue jsNodeIteratorWhatToShow(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSNodeIterator* castedThis = static_cast<JSNodeIterator*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    NodeIterator* imp = static_cast<NodeIterator*>(castedThis->impl());
    JSValue result = jsNumber(imp->whatToShow());
    return result;
}
Beispiel #12
0
JSValue jsNodeIteratorReferenceNode(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSNodeIterator* castedThis = static_cast<JSNodeIterator*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    NodeIterator* imp = static_cast<NodeIterator*>(castedThis->impl());
    JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->referenceNode()));
    return result;
}
Beispiel #13
0
JSValue jsNodeIteratorPointerBeforeReferenceNode(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSNodeIterator* castedThis = static_cast<JSNodeIterator*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    NodeIterator* imp = static_cast<NodeIterator*>(castedThis->impl());
    JSValue result = jsBoolean(imp->pointerBeforeReferenceNode());
    return result;
}
Beispiel #14
0
void PFLCFG::ResetValid(void)
{
	NodeIterator i = FirstNode();
	for (; i != LastNode(); i++)
	{
		BBType *bb = i.current()->NodeInfo;
		bb->Valid = false;
	}
}
Beispiel #15
0
bool LitterNetwork::isNeighbor(LitterNode& source, LitterNode& dest) {
  NodeIterator* ni = source.getNeighborIT();
  while (ni->moveNext()) {
    if (ni->current() == &dest) {
      return true;
    }
  }
  return false;
}
Beispiel #16
0
JSValue* jsNodeIteratorPrototypeFunctionDetach(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
    if (!thisValue->isObject(&JSNodeIterator::s_info))
        return throwError(exec, TypeError);
    JSNodeIterator* castedThisObj = static_cast<JSNodeIterator*>(thisValue);
    NodeIterator* imp = static_cast<NodeIterator*>(castedThisObj->impl());

    imp->detach();
    return jsUndefined();
}
Beispiel #17
0
JSValue JSC_HOST_CALL jsNodeIteratorPrototypeFunctionDetach(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
{
    UNUSED_PARAM(args);
    if (!thisValue.isObject(&JSNodeIterator::s_info))
        return throwError(exec, TypeError);
    JSNodeIterator* castedThisObj = static_cast<JSNodeIterator*>(asObject(thisValue));
    NodeIterator* imp = static_cast<NodeIterator*>(castedThisObj->impl());

    imp->detach();
    return jsUndefined();
}
Beispiel #18
0
//------------------------------------------------------------------------------
void TreeOrder::Order ()
{
    NodeIterator <Node> n (t->GetRoot());
    Node *q = n.begin();
    while (q)
    {
    	if (!q->IsLeaf ())
			SortDescendants (q);

        q = n.next();
    }
}
Beispiel #19
0
EncodedJSValue JSC_HOST_CALL jsNodeIteratorPrototypeFunctionDetach(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSNodeIterator::s_info))
        return throwVMTypeError(exec);
    JSNodeIterator* castedThis = static_cast<JSNodeIterator*>(asObject(thisValue));
    ASSERT_GC_OBJECT_INHERITS(castedThis, &JSNodeIterator::s_info);
    NodeIterator* imp = static_cast<NodeIterator*>(castedThis->impl());

    imp->detach();
    return JSValue::encode(jsUndefined());
}
Beispiel #20
0
status_t
platform_get_boot_partition(struct stage2_args *args, Node *device,
	NodeList *list, boot::Partition **_partition)
{
	NodeIterator iterator = list->GetIterator();
	boot::Partition *partition = NULL;
	while ((partition = (boot::Partition *)iterator.Next()) != NULL) {
		// ToDo: just take the first partition for now
		*_partition = partition;
		return B_OK;
	}

	return B_ENTRY_NOT_FOUND;
}
Beispiel #21
0
Partition::~Partition()
{
	TRACE(("%p Partition::~Partition\n", this));

	// Tell the children that their parent is gone

	NodeIterator iterator = gPartitions.GetIterator();
	Partition *child;

	while ((child = (Partition *)iterator.Next()) != NULL) {
		if (child->Parent() == this)
			child->SetParent(NULL);
	}

	close(fFD);
}
Beispiel #22
0
EncodedJSValue JSC_HOST_CALL jsNodeIteratorPrototypeFunctionPreviousNode(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSNodeIterator::s_info))
        return throwVMTypeError(exec);
    JSNodeIterator* castedThis = static_cast<JSNodeIterator*>(asObject(thisValue));
    ASSERT_GC_OBJECT_INHERITS(castedThis, &JSNodeIterator::s_info);
    NodeIterator* imp = static_cast<NodeIterator*>(castedThis->impl());
    ExceptionCode ec = 0;


    JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->previousNode(exec, ec)));
    setDOMException(exec, ec);
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    return JSValue::encode(result);
}
void ReachingDefinitionAnalysis:: FinalizeCFG( AstInterface& fa)
{
  ReachingDefinitions in = g->get_empty_set();
  for (AstInterface::AstNodeList::iterator p = pars.begin();
       p != pars.end(); ++p) {
      AstNodePtr cur = *p;
      std::string name;
      AstNodePtr scope;
      if (fa.IsVarRef(cur, 0, &name, &scope))
         g->add_def( in, name, scope, std::pair<AstNodePtr,AstNodePtr>(cur,AST_NULL));
  } 
  NodeIterator p = GetNodeIterator();
  (*p)->finalize( fa, *g, a, &in);
  for ( ++p;!p.ReachEnd(); ++p) {
    (*p)->finalize(fa, *g, a);
  }
}
Beispiel #24
0
void PostSend::Execute() {
  LitterNode& lnode = dynamic_cast<LitterNode&>(_node);
  if (lnode.getOnline() == false) return;

  NodeIterator* ni = lnode.getNeighborIT();
  PostMsg* msg = new PostMsg(_node, _sched.getCurrentTime());

  assert(lnode.addPost(msg));
  lnode.stats.lpostcount++;

  while (ni->moveNext()) {
    Node* neighbor = ni->current();
    LitterNode& dest = dynamic_cast<LitterNode&>(*neighbor);
    if (dest.getOnline() == true) {
      Action* pr_event = new PostRcv(*neighbor, *msg, _sched, _net, 1);
      LitterNetwork& lnet = dynamic_cast<LitterNetwork&>(_net);
      lnet.send(lnode, dest, *pr_event, _sched);
      lnode.stats.posttx++;
    }
  }
}
Beispiel #25
0
void PFLCFG::RemoveDeadNodes(void)
{
	bool changed = true;
	//uint32 round = 0;
	while (changed)
	{
		NodeIterator i = FirstNode();
		changed = false;
		for (; i != LastNode(); i++)
		{
			BBType *bb = i.current()->NodeInfo;
			if (bb->Kind != BB_CFG_ENTRY && bb->Valid)
			{
				if (i.current()->GetPredecessors().empty())
				{
					changed = true;
					bb->Valid = false;
				}
			}
		}
		if (changed)
		{
			NodeIterator i = FirstNode();
			for(; i != LastNode(); i++)
			{
				BBType *bb = i.current()->NodeInfo;
				if (!bb->Valid)
				{ 
					list<node_t*> &succ = bb->getNode()->GetSuccessors();
					list<node_t*>::iterator k = succ.begin();
					for (; k != succ.end(); k++)
						DeleteEdge(*(*k), *bb->getNode());
					//delete bb;
					//Graph.DeleteNode(*i.current());
				}
			}
		}
	}
}
Beispiel #26
0
//------------------------------------------------------------------------------
void TreeDrawer::Draw ()
{
    NodeIterator <Node> n (t->GetRoot());
    Node *q = n.begin();
    while (q)
    {
    	if (q->IsLeaf ())
        {
        	DrawLeaf (q);
        }
        else
        {
			DrawInternal (q);
        }

        q = n.next();
    }
    if (rooted)
    {
    	DrawRoot ();
    }
}
Beispiel #27
0
//------------------------------------------------------------------------------
void AlphaOrder::Order ()
{
    NodeIterator <Node> n (t->GetRoot());
    Node *q = n.begin();
    while (q)
    {
    	if (q->IsLeaf ())
        	labels[q] = q->GetLabel();
        q = n.next();
    }
	q = n.begin();
    while (q)
    while (q)
    {
    	if (!q->IsLeaf ())
        {
			SortDescendants (q);
            labels[q] = labels[q->GetChild()];
        }

        q = n.next();
    }
}
Beispiel #28
0
//------------------------------------------------------------------------------
TreeDrawer::TreeDrawer (Tree *tree)
{
	t = tree;
    rooted = true;
    showInternalLabels = true;
    showLeafLabels = true;
    left = 0.0;
    top = 0.0;
    width = 400.0;
    height = 400.0;
    leafCount = 0;
    NodeIterator <Node> n (t->GetRoot());
    Node *q = n.begin();
    while (q)
    {
    	if (q->IsLeaf ())
        {
        	point p;
        	node_coordinates[q] = p;
        }
        q = n.next();
    }
}
Beispiel #29
0
bool Scene::Add( freyja::Node* node )
{
	bool ret = false;

	if ( node )
	{
		mstl::String key = node->GetType();
		SceneResource* resource = mResourceDict.find( key );

		if ( resource )
		{
			bool found = false;
			for ( NodeIterator it = resource->GetIterator(), end = it.end(); it != end; it++ )
			{
				if ( *it == node )
				{
					found = true;
					break;
				}
			}

			if ( !found )
			{					
				// FIXME: Check for name collision!
				node->SetScene( this );
				resource->GetList().push_back( node );
				key = node->GetName();
				resource->GetDictionary().insert( key, node );
			}

			ret = true;
		}
	}

	return ret;
}
Beispiel #30
0
/*! Gets the boot device, scans all of its partitions, gets the
	boot partition, and mounts its file system.

	\param args The stage 2 arguments.
	\param _bootVolume On success set to the boot volume.
	\return \c B_OK on success, another error code otherwise.
*/
status_t
get_boot_file_system(stage2_args* args, BootVolume& _bootVolume)
{
	status_t error = platform_add_boot_device(args, &gBootDevices);
	if (error != B_OK)
		return error;

	NodeIterator iterator = gBootDevices.GetIterator();
	while (iterator.HasNext()) {
		Node *device = iterator.Next();

		error = add_partitions_for(device, false, true);
		if (error != B_OK)
			continue;

		NodeList bootPartitions;
		error = platform_get_boot_partitions(args, device, &gPartitions, &bootPartitions);
		if (error != B_OK)
			continue;

		NodeIterator partitionIterator = bootPartitions.GetIterator();
		while (partitionIterator.HasNext()) {
			Partition *partition = (Partition*)partitionIterator.Next();

			Directory *fileSystem;
			error = partition->Mount(&fileSystem, true);
			if (error != B_OK) {
				// this partition doesn't contain any known file system; we
				// don't need it anymore
				gPartitions.Remove(partition);
				delete partition;
				continue;
			}

			// init the BootVolume
			error = _bootVolume.SetTo(fileSystem);
			if (error != B_OK)
				continue;

			sBootDevice = device;
			return B_OK;
		}
	}

	return B_ERROR;
}