type logicop::check_types(env &E) { type lhs_type = lhs->check_types(E); type rhs_type = rhs->check_types(E); if( lhs_type == rhs_type ) return lhs_type; // check this !! else if( (lhs_type == tINTEGER) && (rhs_type == tINTEGER) ) return tINTEGER; else { cout << "Type error : " << get_short_description() << " between " << lhs->get_short_description() << " (" << lhs_type.get_name() << ") and " << rhs->get_short_description() << " (" << rhs_type.get_name() << ") is not allowed." << endl; // FAIL FAIL FAIL FAIL FAIL !!!! return tVOID; } }
type mathop::check_types(env &E) { if (!lhs || !rhs) { cout << "INTERNAL ERROR: incomplete tree on mathop." << endl; exit(1); } type lhs_type = (lhs->check_types(E)); type rhs_type = (rhs->check_types(E)); if( (lhs_type == tFLOAT) && (rhs_type == tFLOAT) || ((lhs_type == tFLOAT) && (rhs_type == tINTEGER)) || ((lhs_type == tINTEGER) && (rhs_type == tFLOAT))) return tFLOAT; else if( (lhs_type == tINTEGER) && (rhs_type == tINTEGER) ) return tINTEGER; else { // FAIL FAIL FAIL FAIL !!!! cout << "Type error : math op " << flush << get_short_description() << flush << " between " << flush << lhs->get_short_description() << flush << " (" << lhs_type.get_name() << flush << ") and " << flush << rhs->get_short_description() << flush << " (" << flush << rhs_type.get_name() << flush << ") not allowed." << endl; return tVOID; } }
static gboolean backend_search_package_thread (PkBackend *backend) { const gchar *search; PkBitfield filters; search = pk_backend_get_string (backend, "search"); filters = (PkBitfield) pk_backend_get_uint (backend, "filters"); pk_backend_set_percentage (backend, PK_BACKEND_PERCENTAGE_INVALID); pk_backend_set_allow_cancel (backend, true); matcher *m_matcher = new matcher(string(search)); if (m_matcher->hasError()) { egg_debug("Regex compilation error"); delete m_matcher; pk_backend_finished (backend); return false; } aptcc *m_apt = new aptcc(backend, _cancel); pk_backend_set_pointer(backend, "aptcc_obj", m_apt); if (m_apt->init()) { egg_debug ("Failed to create apt cache"); delete m_matcher; delete m_apt; pk_backend_finished (backend); return false; } if (_error->PendingError() == true) { delete m_matcher; delete m_apt; pk_backend_finished (backend); return false; } pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); pkgDepCache::Policy Plcy; vector<pair<pkgCache::PkgIterator, pkgCache::VerIterator> > output; if (pk_backend_get_bool (backend, "search_details")) { for (pkgCache::PkgIterator pkg = m_apt->packageCache->PkgBegin(); !pkg.end(); ++pkg) { if (_cancel) { break; } // Ignore packages that exist only due to dependencies. if (pkg.VersionList().end() && pkg.ProvidesList().end()) { continue; } if (m_matcher->matches(pkg.Name())) { // Don't insert virtual packages instead add what it provides pkgCache::VerIterator ver = m_apt->find_ver(pkg); if (ver.end() == false) { output.push_back(pair<pkgCache::PkgIterator, pkgCache::VerIterator>(pkg, ver)); } else { // iterate over the provides list for (pkgCache::PrvIterator Prv = pkg.ProvidesList(); Prv.end() == false; Prv++) { ver = m_apt->find_ver(Prv.OwnerPkg()); // check to see if the provided package isn't virtual too if (ver.end() == false) { // we add the package now because we will need to // remove duplicates later anyway output.push_back(pair<pkgCache::PkgIterator, pkgCache::VerIterator>(Prv.OwnerPkg(), ver)); } } } } else { // Don't insert virtual packages instead add what it provides pkgCache::VerIterator ver = m_apt->find_ver(pkg); if (ver.end() == false) { if (m_matcher->matches(get_default_short_description(ver, m_apt->packageRecords)) || m_matcher->matches(get_default_long_description(ver, m_apt->packageRecords)) || m_matcher->matches(get_short_description(ver, m_apt->packageRecords)) || m_matcher->matches(get_long_description(ver, m_apt->packageRecords))) { output.push_back(pair<pkgCache::PkgIterator, pkgCache::VerIterator>(pkg, ver)); } } else { // iterate over the provides list for (pkgCache::PrvIterator Prv = pkg.ProvidesList(); Prv.end() == false; Prv++) { ver = m_apt->find_ver(Prv.OwnerPkg()); // check to see if the provided package isn't virtual too if (ver.end() == false) { // we add the package now because we will need to // remove duplicates later anyway if (m_matcher->matches(Prv.OwnerPkg().Name()) || m_matcher->matches(get_default_short_description(ver, m_apt->packageRecords)) || m_matcher->matches(get_default_long_description(ver, m_apt->packageRecords)) || m_matcher->matches(get_short_description(ver, m_apt->packageRecords)) || m_matcher->matches(get_long_description(ver, m_apt->packageRecords))) { output.push_back(pair<pkgCache::PkgIterator, pkgCache::VerIterator>(Prv.OwnerPkg(), ver)); } } } } } } } else { for (pkgCache::PkgIterator pkg = m_apt->packageCache->PkgBegin(); !pkg.end(); ++pkg) { if (_cancel) { break; } // Ignore packages that exist only due to dependencies. if (pkg.VersionList().end() && pkg.ProvidesList().end()) { continue; } if (m_matcher->matches(pkg.Name())) { // Don't insert virtual packages instead add what it provides pkgCache::VerIterator ver = m_apt->find_ver(pkg); if (ver.end() == false) { output.push_back(pair<pkgCache::PkgIterator, pkgCache::VerIterator>(pkg, ver)); } else { // iterate over the provides list for (pkgCache::PrvIterator Prv = pkg.ProvidesList(); Prv.end() == false; Prv++) { ver = m_apt->find_ver(Prv.OwnerPkg()); // check to see if the provided package isn't virtual too if (ver.end() == false) { // we add the package now because we will need to // remove duplicates later anyway output.push_back(pair<pkgCache::PkgIterator, pkgCache::VerIterator>(Prv.OwnerPkg(), ver)); } } } } } } // It's faster to emmit the packages here than in the matching part m_apt->emit_packages(output, filters); delete m_matcher; delete m_apt; pk_backend_set_percentage (backend, 100); pk_backend_finished (backend); return true; }