Example #1
0
void initSProps(HTS& env, const Class* cls) {
  cls->initSPropHandles();
  if (rds::isPersistentHandle(cls->sPropInitHandle())) return;
  ifThen(
    env,
    [&] (Block* taken) {
      gen(env, CheckInitSProps, taken, ClassData(cls));
    },
    [&] {
      hint(env, Block::Hint::Unlikely);
      gen(env, InitSProps, ClassData(cls));
    }
  );
}
Example #2
0
SSATmp* allocObjFast(HTS& env, const Class* cls) {
  auto registerObj = [&] (SSATmp* obj) {
    if (RuntimeOption::EnableObjDestructCall && cls->getDtor()) {
      gen(env, RegisterLiveObj, obj);
    }
    return obj;
  };

  // If it's an extension class with a custom instance initializer,
  // that init function does all the work.
  if (cls->instanceCtor()) {
    auto const obj = gen(env, ConstructInstance, ClassData(cls));
    return registerObj(obj);
  }

  // Make sure our property init vectors are all set up.
  const bool props = cls->pinitVec().size() > 0;
  const bool sprops = cls->numStaticProperties() > 0;
  assert((props || sprops) == cls->needInitialization());
  if (cls->needInitialization()) {
    if (props) initProps(env, cls);
    if (sprops) initSProps(env, cls);
  }

  /*
   * Allocate the object.  This must happen after we do sinits for consistency
   * with the interpreter about o_id assignments.  Also, the prop
   * initialization above can throw, so we don't want to have the object
   * allocated already.
   */
  auto const ssaObj = gen(env, NewInstanceRaw, ClassData(cls));

  // Initialize the properties
  gen(env, InitObjProps, ClassData(cls), ssaObj);

  // Call a custom initializer if one exists
  if (cls->callsCustomInstanceInit()) {
    return registerObj(gen(env, CustomInstanceInit, ssaObj));
  }

  return registerObj(ssaObj);
}
void Data::getClassesReady()
{
    //qDebug() << "classesready";
    QDomDocument doc("Classes");
    if (doc.setContent(this->m_reply)) {
        QDomElement root = doc.documentElement();
        QDomNode node = root.firstChild();
        //qDebug() << "root="<< node.nodeName();

        this->m_classes.clear();
        while (!node.isNull()) {
            QDomElement e = node.toElement();
            if ((!e.isNull()) && (e.tagName() == "CLASS")) {
                this->m_classes.append(
                            ClassData(e.attribute("classCode"), e.attribute("number").toInt(), e.attribute("teacher")));
            }
            node = node.nextSibling();
        }
    }
    emit this->classesReady();
}