void getSuccessors(SNode& node, std::vector<SNode>* s, std::vector<double>* c) {
	SNode reachableNode;
	for (int deltaX = -1; deltaX <= 1; ++deltaX) {
		for (int deltaY = -1; deltaY <= 1; ++deltaY) {
			if (deltaX == 0 && deltaY == 0 && node.velocityVector.first == 0 && node.velocityVector.second == 0) {
				continue;
			}

			reachableNode.position = std::make_pair(node.position.first + node.velocityVector.first + deltaX,
				node.position.second + node.velocityVector.second + deltaY);

			reachableNode.velocityVector = std::make_pair(node.velocityVector.first + deltaX,
				node.velocityVector.second + deltaY);

			reachableNode.setDirection(deltaX, deltaY);

			if (reachableNode.position.first > 0 &&
				reachableNode.position.second > 0 &&
				reachableNode.position.first < aStarStaticMap->sizeOnXaxis() &&
				reachableNode.position.second < aStarStaticMap->sizeOnYaxis() /*&&
																			  aStarStaticMap->canPlayerMoveFromThisPositionWithSuchVector(node.position.first,
																			  node.position.second,
																			  reachableNode.velocityVector.first,
																			  reachableNode.velocityVector.second)*/)
			{
				//std::cout << "ReachableNode: " << reachableNode.position.first << " " << reachableNode.position.second << std::endl;
				s->push_back(reachableNode);
				c->push_back(1);
			}
		}
	}
}
示例#2
0
void DerivationWriter :: copySwitching(SNode node)
{
   SNode current = node.firstChild();
   while (current != lxNone) {
      Symbol symbol = (Symbol)current.type;
      switch (symbol) {
         case nsSwitchOption:
         case nsBiggerSwitchOption:
         case nsLessSwitchOption:
            _writer.newBookmark();
            unpackChildren(current);
            if (symbol == nsBiggerSwitchOption) {
               _writer.insert(lxOption, GREATER_MESSAGE_ID);
            }
            else if (symbol == nsLessSwitchOption) {
               _writer.insert(lxOption, LESS_MESSAGE_ID);
            }
            else _writer.insert(lxOption, EQUAL_MESSAGE_ID);
            _writer.closeNode();
            _writer.removeBookmark();
            break;
         case nsLastSwitchOption:
            _writer.newBookmark();
            unpackChildren(current);
            _writer.insert(lxElse);
            _writer.closeNode();
            _writer.removeBookmark();
            break;
         default:
            break;
      }
      current = current.nextNode();
   }
}
示例#3
0
int Client::list(const string& path, vector<SNode>& attr)
{
   string revised_path = Metadata::revisePath(path);

   SectorMsg msg;
   msg.resize(65536);
   msg.setType(101);
   msg.setKey(m_iKey);
   msg.setData(0, revised_path.c_str(), revised_path.length() + 1);

   Address serv;
   m_Routing.lookup(revised_path, serv);
   login(serv.m_strIP, serv.m_iPort);

   if (m_GMP.rpc(serv.m_strIP.c_str(), serv.m_iPort, &msg, &msg) < 0)
      return SectorError::E_CONNECTION;

   if (msg.getType() < 0)
      return *(int32_t*)(msg.getData());

   string filelist = msg.getData();

   unsigned int s = 0;
   while (s < filelist.length())
   {
      int t = filelist.find(';', s);
      SNode sn;
      sn.deserialize(filelist.substr(s, t - s).c_str());
      attr.insert(attr.end(), sn);
      s = t + 1;
   }

   return attr.size();
}
示例#4
0
void DerivationWriter :: copyVariable(SNode node)
{
   SNode local = node.firstChild();

   _writer.newNode(lxVariable);

   if (_hints != lxNone) {
      copyHints(_hints);
      _hints = lxNone;
   }

   unpackNode(local, 0);
   _writer.closeNode();

   SNode current = node.findChild((LexicalType)nsAssigning);
   if (current != lxNone) {
      _writer.newNode(lxExpression);
      _writer.appendNode(lxAssign);
      unpackNode(local, 1);

      unpackChildren(current);

      _writer.closeNode();
   }
}
示例#5
0
ref_t ModuleScope :: resolveClosure(ref_t closureMessage, ref_t outputRef, ident_t ns)
{
   ref_t signRef = 0;
   module->resolveAction(getAction(closureMessage), signRef);

   int paramCount = getParamCount(closureMessage);

   IdentifierString closureName(module->resolveReference(closureTemplateReference));
   if (signRef == 0) {
      if (paramCount > 0) {
         closureName.appendInt(paramCount);
      }

      if (isWeakReference(closureName)) {
         return module->mapReference(closureName, true);
      }
      else return mapFullReference(closureName, true);
   }
   else {   
      ref_t signatures[ARG_COUNT];
      size_t signLen = module->resolveSignature(signRef, signatures);

      List<SNode> parameters;
      SyntaxTree dummyTree;
      SyntaxWriter dummyWriter(dummyTree);
      dummyWriter.newNode(lxRoot);
      
      for (size_t i = 0; i < signLen; i++) {
         dummyWriter.appendNode(lxTarget, signatures[i]);
      }
      if (outputRef) {
         dummyWriter.appendNode(lxTarget, outputRef);
      }
      // if the output signature is not provided - use the super class
      else dummyWriter.appendNode(lxTarget, superReference);

      dummyWriter.closeNode();

      SNode paramNode = dummyTree.readRoot().firstChild();
      while (paramNode != lxNone) {
         parameters.add(paramNode);

         paramNode = paramNode.nextNode();
      }

      closureName.append('#');
      closureName.appendInt(paramCount + 1);

      ref_t templateReference = 0;
      if (isWeakReference(closureName)) {
         templateReference = module->mapReference(closureName, true);
      }
      else templateReference = mapFullReference(closureName, true);

      if (templateReference) {
         return generateTemplate(templateReference, parameters, ns, false);
      }
      else return superReference;
   }
}
示例#6
0
void CompilerLogic :: injectNewOperation(SNode node, _CompilerScope& scope, int operation, ref_t elementType, ref_t targetRef)
{
   SNode operationNode = node.injectNode((LexicalType)operation, targetRef);

   int size = defineStructSize(scope, targetRef, elementType, false);
   if (size != 0)
      operationNode.appendNode(lxSize, size);
}
示例#7
0
/** first
  0 - FALSE - call to handel nodes with next priority / order
  1 - TRUE (default) - first call for this object
*/
bool INode::childTopDown(bool first)
{
#ifdef DEBUGMSG
  qDebug("#  INode::childTopDown (%s) cont_td (this %p) first: %d", (const char *) name(), this, first);
    qDebug("##(xxx) INode::childTopDown (%s) (this %p) #childcount %d, ordercount %d, aktivorder %d, aktivcount %d, truncation %d",
      (const char *) name(), this, childcount_,ordercount_,aktivorder_,aktivcount_,truncation());
#endif
  SNode *el; // hilfspointer
  if (first) {// first call of 'childTopDown' for this object
    childList_ = &(sNode_->children()); // liste der subknoten erzeugen
    childcount_ = childList_->count(); // anzahl aller (noch) zu bearbeitenden knoten
    aktivorder_=-1; // prioritaet der zu bearbeitenden nodes
    if (childcount_ == 0) { //no sub nodes
      aktivcount_ = 0;
      execBottomUp();             //execState(BU);// BottomUp
      return 0;
    }
  } else { // recursiv call of 'childTopDown' for this object
    if (aktivcount_ > 0 || ordercount_ > 0 ) return 1;
    if (childcount_ <= 0) return 0;//all sub nodes are handled
    if (truncation()) return 0; //all sub nodes are handelt or node is trash
  }

  //Praemisse (ordercount_ == 0) && (childcount_ > 0)
  while (ordercount_ == 0) {
    aktivorder_ ++;
    for (el = childList_->first(); el != 0; el = childList_->next())
      if(el->order() == aktivorder_) ordercount_++; // anzahl der nodes der aktuellen prioritaet
  }
#ifdef DEBUGMSG
    qDebug("## INode::childTopDown (%s) (this %p) #childs %d, ordercount %d, aktivorder %d, aktivcount_ %d",
      (const char *) name(), this, childcount_, ordercount_, aktivorder_,aktivcount_);
#endif

    INode *inode;
    for (el = childList_->first(); el != 0; el = childList_->next()) {
      if (truncation()) { //bedingungen nicht mehr erfüllt
        aktivcount_ = 0;
        execBottomUp();             //execState(BU);// BottomUp
        return 0;
      }
      if (el->order() == aktivorder_) {
        incrementCount(); //einer mehr in der queue -> siehe decrementCount()
        childcount_--; ordercount_--; //aktuelle wird gleich bearbeitet
        inode = new INode(el);    //new INode
        CHECK_PTR(inode);
        inode->status(HI);
        inode->execState(TD);
        childLink(inode);         // remount node in the tree
        inode->execTopDown();     //start topdown operator
        //childcount_--; ordercount_--; //aktuelle wird gleich bearbeitet
//!MP25.07.2001 inode might be deleted
//!      analysis_->nodeChange(inode);  //info to the rest of the world
        analysis_->nodeChange(0);
      }
    }
  return 1;
}
示例#8
0
int Slave::report(const string& master_ip, const int& master_port, const int32_t& transid, const vector<string>& filelist, const int& change)
{
   vector<string> serlist;
   for (vector<string>::const_iterator i = filelist.begin(); i != filelist.end(); ++ i)
   {
      struct stat s;
      if (-1 == stat((m_strHomeDir + *i).c_str(), &s))
         continue;

      SNode sn;
      sn.m_strName = *i;
      sn.m_bIsDir = S_ISDIR(s.st_mode) ? 1 : 0;
      sn.m_llTimeStamp = s.st_mtime;
      sn.m_llSize = s.st_size;

      char buf[1024];
      sn.serialize(buf);

      //update local
      Address addr;
      addr.m_strIP = "127.0.0.1";
      addr.m_iPort = 0;
      m_pLocalFile->update(buf, addr, change);

      serlist.push_back(buf);
   }

   if (serlist.empty())
      return 0;

   SectorMsg msg;
   msg.setType(1);
   msg.setKey(0);
   msg.setData(0, (char*)&transid, 4);
   msg.setData(4, (char*)&m_iSlaveID, 4);
   msg.setData(8, (char*)&change, 4);
   int32_t num = serlist.size();
   msg.setData(12, (char*)&num, 4);
   int pos = 16;
   for (vector<string>::iterator i = serlist.begin(); i != serlist.end(); ++ i)
   {
      int32_t bufsize = i->length() + 1;
      msg.setData(pos, (char*)&bufsize, 4);
      msg.setData(pos + 4, i->c_str(), bufsize);
      pos += bufsize + 4;
   }

   cout << "report " << master_ip << " " << master_port << " " << num << endl;

   if (m_GMP.rpc(master_ip.c_str(), master_port, &msg, &msg) < 0)
      return -1;

   if (msg.getType() < 0)
      return *(int32_t*)msg.getData();

   return 1;
}
示例#9
0
void DerivationWriter :: unpackChildren(SNode node, int mode)
{
   SNode current = node.firstChild();
   while (current != lxNone) {
      unpackNode(current, mode);

      current = current.nextNode();
   }
}
示例#10
0
int main()
{
	
	//prueba del constructor por omision
	SNode<int> node;
	SNode<int> * aux = new SNode<int>;
	cout<<"Valores por omision"<<endl;
	printSNode(&node);cout<<endl;
	printSNode(aux);cout<<endl;
	
	//constructores por copia
	SNode<int> node1(10);
	SNode<int> * aux1 = new SNode<int>(20);
	cout<<"Valores por copia"<<endl;
	printSNode(&node1);cout<<endl;
	printSNode(aux1);cout<<endl;
	
	//insertamos elementos en una lista simple
	SNode<int> lista;
	for(int i = 0; i < 10 ; i++)
	{
		lista.insertNext(i);
	}
	cout<<"Valores de la lista"<<endl;
	imprimirLista(lista);
	
	//insertamos elementos en una lista simple de manera ordenada
	SNode<int> listaOrdenada;
	for(int i = 0; i < 10 ; i++)
	{
		listaOrdenada.orderedInsertion(i);
	}
	cout<<"Valores de lista Ordenada"<<endl;
	imprimirLista(listaOrdenada);
	
	//utilizamos el iterador sobre nodo
	cout<<"Valores lista ordenada usando iterador"<<endl;
	for(SNode<int>::Iterator it(&listaOrdenada); it.hasCurrent(); it.next())
	{
		cout<<it.getCurrent()->getData()<<" ";
	}
	cout<<endl;
	
	cout<<"Valores lista ordenada"<<endl;
	simpleSort(lista);
	//quickSort(lista);
	
	imprimirLista(lista);
	
	cout<<"Valores minimo de la lista"<<endl;
	cout<<searchMin(&lista)<<endl;	
	
	delete aux;
	delete aux1;
	return 0;
}
示例#11
0
		void							TMCtrl::capture(AnimCtrl* animctrl, void* opaque)
		{
			if(!_node.valid())
				return;

			SNode* n = _node.get_unsafe();
			_pos_captured = n->pos();
			_rot_captured = n->rot();
			_scale_captured = n->scale();
		}
SNode SNode::multiplyParenthesesInProduct() const {
  ENTERMETHOD();
  CHECKNODETYPE(*this,NT_PRODUCT);

  const FactorArray &a = getFactorArray();
  const size_t       n = a.size();
  FactorArray        newFactorArray(a.getTree(), n);
  for(size_t i = 0; i < n; i++) {
    SNode f = a[i];
    newFactorArray *= powerExp(f.base().multiplyParentheses(), f.exponent().multiplyParentheses());
  }

  BitSet done(newFactorArray.size() + 1);
  do {
    FactorArray tmp = newFactorArray;
    newFactorArray.clear();
    done.setCapacity(tmp.size() + 1);
    done.clear();
    for(size_t i1 = 1; i1 < tmp.size(); i1++) {
      if(done.contains(i1)) continue;
      SNode f1 = tmp[i1];
      if((f1.base().getSymbol() == SUM) && !f1.exponent().isOne()) {
        continue;
      }
      for(size_t i2 = 0; i2 < i1; i2++) {
        if(done.contains(i1)) break;
        if(done.contains(i2)) continue;
        SNode f2 = tmp[i2];
        if((f2.base().getSymbol() == SUM) && !f2.exponent().isOne()) {
          continue;
        }
        if(f1.base().getSymbol() == SUM) {
          newFactorArray *= multiplyFactorSum(f2, f1.base());
          done.add(i1);
          done.add(i2);
        } else if(f2.base().getSymbol() == SUM) {
          newFactorArray *= multiplyFactorSum(f1, f2.base());
          done.add(i1);
          done.add(i2);
        }
      }
    }
    for(size_t i = 0; i < tmp.size(); i++) {
      if(!done.contains(i)) {
        newFactorArray *= tmp[i];
      }
    }
  } while(!done.isEmpty());
  SNode result = productExp(newFactorArray);
  RETURNNODE( result );
}
示例#13
0
void CompilerLogic :: injectVariableAssigning(SNode node, _CompilerScope& scope, _Compiler& compiler, ref_t targetRef, ref_t& type, bool paramMode)
{
   ClassInfo info;
   defineClassInfo(scope, info, targetRef);

   node.setArgument(defineStructSize(info, false));
   //HOTFIX : allowing to assign a reference variable
   if (!node.argument && paramMode) {
      // replace the parameter with the field expression
      compiler.injectFieldExpression(node.firstChild(lxObjectMask));

      type = info.fieldTypes.get(0).value2;
   }
}
示例#14
0
void SyntaxTree :: copyNode(SyntaxTree::Writer& writer, SyntaxTree::Node node)
{
   SNode current = node.firstChild();
   while (current != lxNone) {
      if (current.strArgument >= 0) {
         writer.newNode(current.type, current.identifier());
      }
      else writer.newNode(current.type, current.argument);

      copyNode(writer, current);

      writer.closeNode();

      current = current.nextNode();
   }
}
示例#15
0
SyntaxTree::Node SyntaxTree :: findTerminalInfo(SyntaxTree::Node node)
{
   if (node.existChild(lxRow))
      return node;

   SNode current = node.firstChild();
   while (current != lxNone) {
      SNode terminalNode = findTerminalInfo(current);
      if (terminalNode != lxNone)
         return terminalNode;

      current = current.nextNode();
   }

   return current;
}
示例#16
0
void SyntaxTree :: copyNode(SyntaxTree::Node source, SyntaxTree::Node destination)
{
   SNode current = source.firstChild();
   while (current != lxNone) {
      if (current.strArgument >= 0) {
         if (source.tree == destination.tree) {
            // HOTFIX : literal argument could be corrupted by reallocating the string buffer,
            // so the special routine should be used
            copyNode(current, destination.appendStrNode(current.type, current.strArgument));
         }
         else copyNode(current, destination.appendNode(current.type, current.identifier()));
      }
      else copyNode(current, destination.appendNode(current.type, current.argument));

      current = current.nextNode();
   }
}
示例#17
0
bool CompilerLogic :: optimizeEmbeddableGet(_CompilerScope& scope, _Compiler& compiler, SNode node)
{
   SNode callNode = node.findSubNode(lxDirectCalling, lxSDirctCalling);
   SNode callTarget = callNode.findChild(lxCallTarget);

   ClassInfo info;
   defineClassInfo(scope, info, callTarget.argument);

   ref_t subject = info.methodHints.get(Attribute(callNode.argument, maEmbeddableGet));
   // if it is possible to replace get&subject operation with eval&subject2:local
   if (subject != 0) {
      compiler.injectEmbeddableGet(node, callNode, subject);

      return true;
   }
   else return false;
}
示例#18
0
void DerivationWriter :: copyObject(SNode node, int mode)
{
   int exprCounter = 0;
   SNode current = node.firstChild();
   while (current != lxNone) {
      if (current == nsExpression)
         exprCounter++;

      unpackNode(current, mode);

      current = current.nextNode();
   }

   if (mode == 1 && exprCounter > 1) {
      _writer.insert(lxExpression);
      _writer.closeNode();
   }
}
示例#19
0
void SyntaxTree :: moveNodes(Writer& writer, SyntaxTree& buffer)
{
   SNode current = buffer.readRoot();
   while (current != lxNone) {
      if (current != lxIdle) {
         if (current.strArgument >= 0) {
            writer.newNode(current.type, current.identifier());
         }
         else writer.newNode(current.type, current.argument);

         SyntaxTree::copyNode(writer, current);
         writer.closeNode();

         current = lxIdle;
      }
      current = current.nextNode();
   }
}
示例#20
0
//////////
//
// Called to delete the indicated node
//
//////
	void iNode_delete(SNode** root, bool tlDeleteSelf)
	{
		SNode* node;


		// Make sure our environment is sane
		if (root && (node = *root))
		{
			//////////
			// Delete the op if need be
			//////
#ifdef iOp_politelyDelete
				if (node->opData)
				{
					// Delete op chain
					iOp_politelyDelete(&node->opData->op, false);

					// Delete the variable chain
					if (node->opData->firstVariable)
						iVariable_politelyDelete_chain(&node->opData->firstVariable, true);
				}
#endif


			//////////
			// Physically release the node if need be
			//////
				if (tlDeleteSelf)
				{
					// Pass everything which points through it to its mirror, and disconnect any nodes that don't pass through
					iNode_orphanize(root);

					// Delete any extra data
					if (node->_extraData_deleteFunc)
						node->extraData_deleteFunc(node);

					// Physically release it
					*root = NULL;
					free(node);
				}

		}
	}
示例#21
0
void DerivationWriter :: copyHints(SNode current)
{
   while (((LexicalType)current.type) == nsHint) {
      _writer.newNode(lxAttribute);
      unpackChildren(current);
      _writer.closeNode();

      current = current.nextNode();
   }
}
示例#22
0
void DerivationWriter :: writeSymbol(Symbol symbol)
{
   if (symbol != nsNone) {
      if (_level > 0) {
         SyntaxWriter tempWriter(_buffer);

         tempWriter.newNode((LexicalType)symbol);
      }
      else _writer.newNode((LexicalType)symbol);

      _level++;
   }
   else {
      _level--;
      if (_level > 0) {
         SyntaxWriter tempWriter(_buffer);

         tempWriter.closeNode();

         if (_level == 1) {
            SNode root = _buffer.readRoot();

            // hints should be injected into the buffer
            if ((LexicalType)root.type == nsHint) {
               if (_hints == lxNone)
                  _hints = root;

               // skipping hints
               while ((LexicalType)root.type == nsHint)
                  root = root.nextNode();
            }
            if (root.type != lxNone) {
               unpackNode(root, 0);
               _buffer.clear();
            }
         }
            
      }
      else _writer.closeNode();
   }
}
static char* VSearchStr( char* s, char* end, SNode* list ) //считается, что после end есть строка длины(list)-1
{
	for ( ; s < end; s++ )
		if ( list[0].Eq( *s ) )
		{
			char* t = s + 1;
			SNode* p = list + 1;

			while ( true )
			{
				if ( !p->a ) { return s; }

				if ( !p->Eq( *t ) ) { break; }

				t++;
				p++;
			}
		}

	return 0;
}
示例#24
0
void imprimirLista(SNode<int> & lista)
{
	SNode<int> * aux = &lista;
	aux = lista.getNext();
	while(aux != &lista)
	{
		cout<<aux->getData()<<" ";
		
		aux = aux->getNext();
	}
	cout<<endl;
}
示例#25
0
void CompilerLogic :: injectVirtualCode(SNode node, _CompilerScope& scope, ClassInfo& info, _Compiler& compiler)
{
   SNode templateNode = node.appendNode(lxTemplate);

   // auto generate get&type message if required
   ClassMap::Iterator c_it = scope.typifiedClasses.getIt(node.argument);
   while (!c_it.Eof()) {
      if (c_it.key() == node.argument) {
         int message = encodeMessage(*c_it, GET_MESSAGE_ID, 0);

         SNode methodNode = templateNode.appendNode(lxClassMethod, message);

         compiler.injectVirtualReturningMethod(methodNode, THIS_VAR);
      }
      c_it++;
   }

   // generate enumeration list
   if ((info.header.flags & elDebugMask) == elEnumList && test(info.header.flags, elNestedClass)) {
      compiler.generateEnumListMember(scope, info.header.parentRef, node.argument);
   }
}
示例#26
0
bool CompilerLogic :: optimizeEmbeddable(SNode node, _CompilerScope& scope)
{
   // check if it is a virtual call
   if (node == lxDirectCalling && getVerb(node.argument) == GET_MESSAGE_ID && getParamCount(node.argument) == 0) {
      SNode callTarget = node.findChild(lxCallTarget);

      ClassInfo info;
      defineClassInfo(scope, info, callTarget.argument);
      if (info.methodHints.get(Attribute(node.argument, maEmbeddableIdle)) == -1) {
         // if it is an idle call, remove it
         node = lxExpression;

         return true;
      }
   }

   return false;
}
SNode SNode::multiplyFactorSum(SNode factor, SNode sum) const {
  ENTERMETHOD2(factor,sum);
  CHECKNODETYPE(factor,NT_POWER);
  CHECKNODETYPE(sum   ,NT_SUM  );

  if((factor.base().getSymbol() == SUM) && factor.exponent().isOne()) {
    RETURNNODE(multiplySumSum(factor.base(),sum));
  } else {
    const AddentArray &sa = sum.getAddentArray();
    AddentArray        tmp(sa.getTree(),sa.size());
    for(size_t i = 0; i < sa.size(); i++) {
      SNode e = sa[i];
      tmp.add(addentExp(factor * e.left(),e.isPositive()));
    }
    RETURNNODE( sumExp(tmp) );
  }
}
示例#28
0
void CompilerLogic :: optimizeEmbeddableBoxing(_CompilerScope& scope, _Compiler& compiler, SNode node, ref_t targetRef, bool assingingMode)
{
   SNode exprNode = node.findSubNodeMask(lxObjectMask);   
   if (exprNode == lxFieldAddress && exprNode.argument > 0 && !assingingMode) {
      bool variable = !isReadonly(scope, targetRef);

      compiler.injectLocalBoxing(exprNode, node.argument);

      node = variable ? lxLocalUnboxing : lxExpression;
   }
   else if (exprNode == lxFieldAddress && node.argument < 4 && node.argument > 0) {
      bool variable = !isReadonly(scope, targetRef);

      compiler.injectLocalBoxing(exprNode, node.argument);

      node = (variable && !assingingMode) ? lxLocalUnboxing : lxExpression;
   }
   else node = lxExpression;
}
示例#29
0
void CompilerLogic :: injectOperation(SNode node, _CompilerScope& scope, _Compiler& compiler, int operator_id, int operationType, ref_t& reference, ref_t type)
{
   int size = 0;
   if (operationType == lxBinArrOp) {
      // HOTFIX : define an item size for the binary array operations
      size = -defineStructSize(scope, V_BINARYARRAY, type);
   }

   if (reference == V_BINARY && type != 0) {
      reference = scope.attributeHints.get(type);
   }
   else if (reference == V_OBJECT && type != 0) {
      reference = scope.attributeHints.get(type);
   }

   bool inverting = IsInvertedOperator(operator_id);

   SNode operationNode = node.injectNode((LexicalType)operationType, operator_id);
   if (size != 0) {
      // HOTFIX : inject an item size for the binary array operations
      operationNode.appendNode(lxSize, size);
   }

   if (reference == V_FLAG) {      
      if (!scope.branchingInfo.reference) {
         // HOTFIX : resolve boolean symbols
         ref_t dummy;
         resolveBranchOperation(scope, compiler, IF_MESSAGE_ID, scope.boolReference, dummy);
      }

      reference = scope.branchingInfo.reference;
      if (inverting) {
         operationNode.appendNode(lxIfValue, scope.branchingInfo.falseRef);
         operationNode.appendNode(lxElseValue, scope.branchingInfo.trueRef);
      }
      else {
         operationNode.appendNode(lxIfValue, scope.branchingInfo.trueRef);
         operationNode.appendNode(lxElseValue, scope.branchingInfo.falseRef);
      }
   }
}
示例#30
0
int Client::stat(const string& path, SNode& attr)
{
   string revised_path = Metadata::revisePath(path);

   SectorMsg msg;
   msg.resize(65536);
   msg.setType(102);
   msg.setKey(m_iKey);
   msg.setData(0, revised_path.c_str(), revised_path.length() + 1);

   Address serv;
   m_Routing.lookup(revised_path, serv);
   login(serv.m_strIP, serv.m_iPort);

   if (m_GMP.rpc(serv.m_strIP.c_str(), serv.m_iPort, &msg, &msg) < 0)
      return SectorError::E_CONNECTION;

   if (msg.getType() < 0)
      return *(int32_t*)(msg.getData());

   attr.deserialize(msg.getData());

   int n = (msg.m_iDataLength - SectorMsg::m_iHdrSize - 128) / 68;
   char* al = msg.getData() + 128;

   for (int i = 0; i < n; ++ i)
   {
      Address addr;
      addr.m_strIP = al + 68 * i;
      addr.m_iPort = *(int32_t*)(al + 68 * i + 64);
      attr.m_sLocation.insert(addr);
   }

   // check local cache: updated files may not be sent to the master yet
   m_StatCache.stat(path, attr);

   return 0;
}