Example #1
0
QSObject QSObject::getQualified(const QString &name) const
{
  QSObject obj = *this;
  QString s = name;

  // break up dotted notation ns like P1.P2.P3
  while (!s.isEmpty()) {
    int pos = s.find('.');
    if (pos < 0)
      pos = s.length();
    // don't overwrite any existing objects, reuse them
    QString cname = s.left(pos);
    QSObject tmpobj = obj.get(cname);

    // Search the class hieriarchy for member if undefined
    if (!tmpobj.isDefined()) {
      QSClass *base = obj.objectType()->base();
      while (base && !tmpobj.isDefined()) {
        tmpobj = base->get(&obj, cname);
        base = base->base();
      }
      if (!tmpobj.isDefined())
        return env()->createUndefined();
    }
    obj = tmpobj;
    s = s.mid(pos + 1);
  }
  return obj;
}
Example #2
0
void QSResolveNode::check( QSCheckData *c )
{
    if ( !c->directLookupEnabled() )
	return;
    QSClass * cl = c->currentScope();
    QSClass *cont = cl;
    int uplvl = 0;
    int blocks = 0;
    QSMember member;
    while ( cont ) {
	QSMember mem;
	if ( cont->member( 0, ident, &mem ) ) {
	    if ( mem.type()==QSMember::Variable && !mem.isStatic() ) {
		member = mem;
		break;
	    }
	}
	uplvl++;
	cont = cont->enclosingClass();
    }
    if( member.isDefined() ) {

	/* If the containing class has an undefined base, the indexes will be moved
	   when the we call QSAbstractBaseClass::replace() and the lookup info
	   will be crap. Therefore, we don't create it. */
	QSClass *tmp = cont->base();
	while (tmp) {
	    if (tmp->name() == QString::fromLatin1("AbstractBase"))
		return;
	    tmp = tmp->base();
	}

	// Due to special handling of block scopes in the global object...
	if( cont==c->env()->globalClass() )
 	    uplvl+=blocks;
   	info = new QSLookupInfo( uplvl, member );
    }
}