示例#1
0
void QoreValueList::insert(QoreValue val) {
   assert(reference_count() == 1);
   priv->resize(priv->length + 1);
   if (priv->length - 1)
      memmove(priv->entry + 1, priv->entry, sizeof(QoreValue) * (priv->length - 1));
   priv->entry[0] = val;
   if (val.hasNode() && get_container_obj(val.getInternalNode()))
      priv->incObjectCount(1);
}
示例#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);
   }
}
示例#3
0
QoreValue VarRefNode::evalValueImpl(bool& needs_deref, ExceptionSink* xsink) const {
   QoreValue v;
   if (type == VT_LOCAL) {
      printd(5, "VarRefNode::evalImpl() this: %p lvar %p (%s)\n", this, ref.id, ref.id->getName());
      v = ref.id->evalValue(needs_deref, xsink);
   }
   else if (type == VT_CLOSURE) {
      printd(5, "VarRefNode::evalImpl() this: %p closure var %p (%s)\n", this, ref.id, ref.id->getName());
      ClosureVarValue *val = thread_get_runtime_closure_var(ref.id);
      v = val->evalValue(needs_deref, xsink);
   }
   else if (type == VT_LOCAL_TS) {
      printd(5, "VarRefNode::evalImpl() this: %p local thread-safe var %p (%s)\n", this, ref.id, ref.id->getName());
      ClosureVarValue *val = thread_find_closure_var(ref.id->getName());
      v = val->evalValue(needs_deref, xsink);
   }
   else if (type == VT_IMMEDIATE)
      v = ref.cvv->evalValue(needs_deref, xsink);
   else {
      assert(needs_deref);
      printd(5, "VarRefNode::evalImpl() this: %p global var: %p (%s)\n", this, ref.var, ref.var->getName());
      v = ref.var->eval();
   }

   AbstractQoreNode* n = v.getInternalNode();
   if (n && n->getType() == NT_REFERENCE) {
      ReferenceNode* r = reinterpret_cast<ReferenceNode*>(n);
      bool nd;
      QoreValue nv = r->evalValue(nd, xsink);
      if (needs_deref)
	 discard(v.getInternalNode(), xsink);
      needs_deref = nd;
      return v = nv;
   }

   return v;
}
示例#4
0
bool OrNothingTypeInfo::acceptInputImpl(QoreValue& n, ExceptionSink *xsink) const {
   qore_type_t t = n.getType();
   if (t == NT_NOTHING)
      return true;
   if (t == NT_NULL) {
      discard(n.assign((AbstractQoreNode*)0), xsink);
      return true;
   }

   if (qc) {
      if (t != NT_OBJECT)
	 return false;
      const QoreClass* n_qc = reinterpret_cast<const QoreObject*>(n.getInternalNode())->getClass();
      return qore_class_private::runtimeCheckCompatibleClass(*qc, *n_qc);
   }

   return t == qt;
}
示例#5
0
int QoreTypeInfo::runtimeAcceptInputIntern(bool &priv_error, QoreValue& n) const {
   qore_type_t nt = n.getType();

   if (qt != nt)
      return -1;

   if (qt != NT_OBJECT || !qc)
      return 0;

   bool priv;
   if (reinterpret_cast<const QoreObject*>(n.getInternalNode())->getClass()->getClass(*qc, priv)) {
      if (!priv)
	 return 0;

      // check private access if required class is privately
      // inherited in the input argument's class
      if (qore_class_private::runtimeCheckPrivateClassAccess(*qc))
	 return 0;

      priv_error = true;
   }

   return -1;
}
示例#6
0
QoreValue copy_value_and_resolve_lvar_refs(QoreValue& n, ExceptionSink* xsink) {
   if (!n.hasNode())
      return n;
   return copy_and_resolve_lvar_refs(n.getInternalNode(), xsink);
}