Beispiel #1
0
QoreValueList* QoreValueList::reverse() const {
   QoreValueList* l = new QoreValueList;
   l->priv->resize(priv->length);
   for (size_t i = 0; i < priv->length; ++i) {
      QoreValue n = priv->entry[priv->length - i - 1];
      l->priv->entry[i] = n.refSelf();
   }
   return l;
}
Beispiel #2
0
void QoreValueList::merge(const QoreValueList* list) {
   assert(reference_count() == 1);
   int start = priv->length;
   priv->resize(priv->length + list->priv->length);
   for (size_t i = 0; i < list->priv->length; i++) {
      QoreValue p = list->priv->entry[i];
      priv->entry[start + i] = p.refSelf();
      if (p.hasNode() && get_container_obj(p.getInternalNode()))
	 priv->incObjectCount(1);
   }
}
Beispiel #3
0
QoreValue QoreValueList::minValue(ExceptionSink* xsink) const {
   if (!priv->length)
      return QoreValue();
   QoreValue rv = priv->entry[0];

   for (size_t i = 1; i < priv->length; ++i) {
      QoreValue v = priv->entry[i];
      if (QoreLogicalLessThanOperatorNode::doLessThan(v, rv, xsink))
	 rv = v;
      if (*xsink)
	 return QoreValue();
   }
   return rv.refSelf();
}
Beispiel #4
0
QoreValue QoreValueList::maxValue(const ResolvedCallReferenceNode* fr, ExceptionSink* xsink) const {
   if (!priv->length)
      return QoreValue();
   QoreValue rv = priv->entry[0];

   for (size_t i = 1; i < priv->length; ++i) {
      QoreValue v = priv->entry[i];

      safe_qorelist_t args(do_args(v, rv), xsink);
      ValueHolder result(fr->execValue(*args, xsink), xsink);
      if (*xsink)
	 return QoreValue();
      if (result->getAsBigInt() > 0)
	 rv = v;
   }
   return rv.refSelf();
}
Beispiel #5
0
void QoreValueListEvalOptionalRefHolder::evalIntern(const QoreListNode* exp) {
   if (!exp || exp->empty()) {
      val = 0;
      needs_deref = false;
      return;
   }
   val = new QoreValueList;
   needs_deref = true;

   ConstListIterator li(exp);
   while (li.next()) {
      const AbstractQoreNode* v = li.getValue();
      if (!v || v->is_value() || v->getType() == NT_REFERENCE) {
	 QoreValue qv;
	 qv.assignAndSanitize(v);
	 val->push(qv.refSelf());
	 continue;
      }
      val->push(v->evalValue(xsink));
      if (*xsink)
	 return;
   }
   assert(val->size() == exp->size());
}