Esempio n. 1
0
///////////////////////////////////////
// on qualified name, select direct DB
//
DbIntlog *DbIntlog::FixPathName(Term *t) const
{
    DbIntlog *db = (DbIntlog*)this;
    Term r = *t;

    while (db && r.is_expr(Operator::PATHNAME) && r.getarg(0).type(f_ATOM))
    {
        kstring dbid = r.getarg(0).kstr();

        if (!strcmp(dbid, ".."))
            db = db->m_father;
        else
        {
            DbInherIter itdb(db);
            while ((db = itdb.next()) != 0)
                if (db->GetId() == dbid)
                    break;
        }

        if (db)
            r = r.getarg(1);
    }

    *t = r;
    return db;
}
Esempio n. 2
0
//////////////////////////////////
// list all entries with property
//
void DbIntlog::EntriesWithProperty(DbEntry::scopemode vProp, slist &l) const
{
    if (vProp == DbEntry::local)
    {
        slist_iter i(m_types);
        DbIntlog *db;

        while ((db = (DbIntlog*)i.next()) != 0)
        {
            EntryWithProp *ewp = new EntryWithProp;
            ewp->id = db->GetId();
            ewp->arity = -1;
            l.append(ewp);
        }
    }
    else
    {
        hashtable_iter it(this);
        DbEntry *dbe;

        while ((dbe = (DbEntry*)it.next()) != 0)
            if (dbe->vProp == vProp)
            {
                EntryWithProp *ewp = new EntryWithProp;
                ewp->id = dbe->funct;
                ewp->arity = dbe->arity;
                l.append(ewp);
            }
    }
}
Esempio n. 3
0
void EngineObj::show(ostream &s) const
{
	IntlogExec *eng = all_engines->HtoD(handler);

	if (eng) {
		s << '$' << handler << ':';
		DbIntlog *db = eng->get_db();

		kstring dbid = db->GetId();
		if (unsigned(dbid) != MSR_NULL)
			s << CCP(dbid);

		s << ':';
		DbInherIter ii(db);
		while ((db = ii.next()) != 0) {
			dbid = db->GetId();
			if (unsigned(dbid) != MSR_NULL)
				s << CCP(dbid);
			s << ':';
		}
	} else
		s << '~' << handler;
}
Esempio n. 4
0
////////////////////////////
// look in local types list
//
DbIntlog *DbIntlog::IsLocalInterface(kstring id) const
{
#ifdef _DEBUG
    CCP tstring = id;
#endif

    slist_iter i(m_types);
    DbIntlog *db;

    while ((db = (DbIntlog*)i.next()) != 0)
        if (db->GetId() == id)
            break;

    return db;
}
Esempio n. 5
0
///////////////////////////////////////////////////
// i_end(i_name) (+)
//	pop current DB (interface became instantiable)
//
BtFImpl(i_end, a, p)
{
	Term t;
	if (!(t = p->eval_term(a.getarg(0))).type(f_ATOM)) {
		p->BtErr(BTERR_INVALID_ARG_TYPE);
		return 0;
	}

	DbIntlog *db = p->get_db();
	kstring dbid = db->GetId(), idi = t.kstr();
	if (dbid != idi || (db = db->EndInterface()) == 0) {
		CCP sdb = MemStoreRef(dbid) != MSR_NULL ? dbid : "";
		p->BtErr(BTERR_CANT_ENDINTERF, CCP(idi), sdb);
		return 0;
	}

	p->set_db(db);
	return 1;
}