aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-06-11 23:27:07 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-06-11 23:27:07 +0100
commit42a477cd7c5525607ad093a227f96e42149131c5 (patch)
tree1724c3bc8da2a9d50353467c18fc83d20092fd22
parentee28577088fc168cdf81e1b79ecdc7d7c7f4adc6 (diff)
downloadpaludis-42a477cd7c5525607ad093a227f96e42149131c5.tar.gz
paludis-42a477cd7c5525607ad093a227f96e42149131c5.tar.xz
No need to rewrite specs any more
-rw-r--r--paludis/resolver/Makefile.am2
-rw-r--r--paludis/resolver/decider.cc61
-rw-r--r--paludis/resolver/decider.hh4
-rw-r--r--paludis/resolver/resolver.cc1
-rw-r--r--paludis/resolver/sanitised_dependencies.cc25
-rw-r--r--paludis/resolver/spec_rewriter-fwd.hh32
-rw-r--r--paludis/resolver/spec_rewriter.cc175
-rw-r--r--paludis/resolver/spec_rewriter.hh72
8 files changed, 26 insertions, 346 deletions
diff --git a/paludis/resolver/Makefile.am b/paludis/resolver/Makefile.am
index e334cb5..e00201d 100644
--- a/paludis/resolver/Makefile.am
+++ b/paludis/resolver/Makefile.am
@@ -95,7 +95,6 @@ noinst_HEADERS = \
same_slot.hh same_slot-fwd.hh \
sanitised_dependencies.hh sanitised_dependencies-fwd.hh \
slot_name_or_null.hh slot_name_or_null-fwd.hh \
- spec_rewriter.hh spec_rewriter-fwd.hh \
strongly_connected_component.hh strongly_connected_component-fwd.hh \
suggest_restart.hh suggest_restart-fwd.hh \
unsuitable_candidates.hh unsuitable_candidates-fwd.hh \
@@ -170,7 +169,6 @@ libpaludisresolver_a_SOURCES = \
same_slot.cc \
sanitised_dependencies.cc \
slot_name_or_null.cc \
- spec_rewriter.cc \
strongly_connected_component.cc \
suggest_restart.cc \
unsuitable_candidates.cc \
diff --git a/paludis/resolver/decider.cc b/paludis/resolver/decider.cc
index e0ffad3..3dd19d2 100644
--- a/paludis/resolver/decider.cc
+++ b/paludis/resolver/decider.cc
@@ -19,7 +19,6 @@
#include <paludis/resolver/decider.hh>
#include <paludis/resolver/resolver_functions.hh>
-#include <paludis/resolver/spec_rewriter.hh>
#include <paludis/resolver/resolvent.hh>
#include <paludis/resolver/resolution.hh>
#include <paludis/resolver/constraint.hh>
@@ -91,7 +90,6 @@ namespace paludis
{
const Environment * const env;
const ResolverFunctions fns;
- SpecRewriter rewriter;
const std::shared_ptr<ResolutionsByResolvent> resolutions_by_resolvent;
@@ -99,7 +97,6 @@ namespace paludis
const std::shared_ptr<ResolutionsByResolvent> & l) :
env(e),
fns(f),
- rewriter(env),
resolutions_by_resolvent(l)
{
}
@@ -1879,14 +1876,6 @@ Decider::_get_unmatching_constraints(
return result;
}
-const std::shared_ptr<const RewrittenSpec>
-Decider::rewrite_if_special(
- const PackageOrBlockDepSpec & spec,
- const std::shared_ptr<const Resolvent> & maybe_from) const
-{
- return _imp->rewriter.rewrite_if_special(spec, maybe_from);
-}
-
void
Decider::add_target_with_reason(const PackageOrBlockDepSpec & spec, const std::shared_ptr<const Reason> & reason)
{
@@ -1894,41 +1883,31 @@ Decider::add_target_with_reason(const PackageOrBlockDepSpec & spec, const std::s
_imp->env->trigger_notifier_callback(NotifierCallbackResolverStepEvent());
- const std::shared_ptr<const RewrittenSpec> if_rewritten(rewrite_if_special(spec, make_null_shared_ptr()));
- if (if_rewritten)
- {
- for (Sequence<PackageOrBlockDepSpec>::ConstIterator i(if_rewritten->specs()->begin()), i_end(if_rewritten->specs()->end()) ;
- i != i_end ; ++i)
- add_target_with_reason(*i, reason);
- }
- else
- {
- /* empty resolvents is always ok for blockers, since blocking on things
- * that don't exist is fine */
- bool empty_is_ok(spec.if_block());
- std::shared_ptr<const Resolvents> resolvents;
+ /* empty resolvents is always ok for blockers, since blocking on things
+ * that don't exist is fine */
+ bool empty_is_ok(spec.if_block());
+ std::shared_ptr<const Resolvents> resolvents;
- if (spec.if_package())
- std::tie(resolvents, empty_is_ok) = _get_resolvents_for(*spec.if_package(), reason);
- else
- resolvents = _get_resolvents_for_blocker(*spec.if_block(), reason);
+ if (spec.if_package())
+ std::tie(resolvents, empty_is_ok) = _get_resolvents_for(*spec.if_package(), reason);
+ else
+ resolvents = _get_resolvents_for_blocker(*spec.if_block(), reason);
- if ((! empty_is_ok) && resolvents->empty())
- resolvents = _get_error_resolvents_for(*spec.if_package(), reason);
+ if ((! empty_is_ok) && resolvents->empty())
+ resolvents = _get_error_resolvents_for(*spec.if_package(), reason);
- for (Resolvents::ConstIterator r(resolvents->begin()), r_end(resolvents->end()) ;
- r != r_end ; ++r)
- {
- Context context_2("When adding constraints from target '" + stringify(spec) + "' to resolvent '"
- + stringify(*r) + "':");
+ for (Resolvents::ConstIterator r(resolvents->begin()), r_end(resolvents->end()) ;
+ r != r_end ; ++r)
+ {
+ Context context_2("When adding constraints from target '" + stringify(spec) + "' to resolvent '"
+ + stringify(*r) + "':");
- const std::shared_ptr<Resolution> dep_resolution(_resolution_for_resolvent(*r, true));
- const std::shared_ptr<ConstraintSequence> constraints(_make_constraints_from_target(dep_resolution, spec, reason));
+ const std::shared_ptr<Resolution> dep_resolution(_resolution_for_resolvent(*r, true));
+ const std::shared_ptr<ConstraintSequence> constraints(_make_constraints_from_target(dep_resolution, spec, reason));
- for (ConstraintSequence::ConstIterator c(constraints->begin()), c_end(constraints->end()) ;
- c != c_end ; ++c)
- _apply_resolution_constraint(dep_resolution, *c);
- }
+ for (ConstraintSequence::ConstIterator c(constraints->begin()), c_end(constraints->end()) ;
+ c != c_end ; ++c)
+ _apply_resolution_constraint(dep_resolution, *c);
}
}
diff --git a/paludis/resolver/decider.hh b/paludis/resolver/decider.hh
index e82b29a..8657bf5 100644
--- a/paludis/resolver/decider.hh
+++ b/paludis/resolver/decider.hh
@@ -30,7 +30,6 @@
#include <paludis/resolver/decision-fwd.hh>
#include <paludis/resolver/destination-fwd.hh>
#include <paludis/resolver/unsuitable_candidates-fwd.hh>
-#include <paludis/resolver/spec_rewriter-fwd.hh>
#include <paludis/resolver/resolver_functions-fwd.hh>
#include <paludis/resolver/resolver-fwd.hh>
#include <paludis/resolver/any_child_score-fwd.hh>
@@ -245,9 +244,6 @@ namespace paludis
const std::shared_ptr<const Resolution> &,
const std::shared_ptr<const PackageID> &,
const SanitisedDependency &) const;
-
- const std::shared_ptr<const RewrittenSpec> rewrite_if_special(const PackageOrBlockDepSpec &,
- const std::shared_ptr<const Resolvent> & maybe_from) const;
};
}
}
diff --git a/paludis/resolver/resolver.cc b/paludis/resolver/resolver.cc
index 475d9ad..8bf9f15 100644
--- a/paludis/resolver/resolver.cc
+++ b/paludis/resolver/resolver.cc
@@ -19,7 +19,6 @@
#include <paludis/resolver/resolver.hh>
#include <paludis/resolver/resolver_functions.hh>
-#include <paludis/resolver/spec_rewriter.hh>
#include <paludis/resolver/decider.hh>
#include <paludis/resolver/sanitised_dependencies.hh>
#include <paludis/resolver/reason.hh>
diff --git a/paludis/resolver/sanitised_dependencies.cc b/paludis/resolver/sanitised_dependencies.cc
index 395c675..ac6f50b 100644
--- a/paludis/resolver/sanitised_dependencies.cc
+++ b/paludis/resolver/sanitised_dependencies.cc
@@ -20,7 +20,6 @@
#include <paludis/resolver/sanitised_dependencies.hh>
#include <paludis/resolver/resolver.hh>
#include <paludis/resolver/resolution.hh>
-#include <paludis/resolver/spec_rewriter.hh>
#include <paludis/resolver/decider.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/util/save.hh>
@@ -150,20 +149,13 @@ namespace
{
seen_any = true;
- const std::shared_ptr<const RewrittenSpec> if_rewritten(decider.rewrite_if_special(spec,
- make_shared_copy(our_resolution->resolvent())));
- if (if_rewritten)
- if_rewritten->as_spec_tree()->top()->accept(*this);
+ if (active_sublist)
+ active_sublist->push_back(spec);
else
{
- if (active_sublist)
- active_sublist->push_back(spec);
- else
- {
- std::list<PackageOrBlockDepSpec> l;
- l.push_back(spec);
- child_groups.push_back(l);
- }
+ std::list<PackageOrBlockDepSpec> l;
+ l.push_back(spec);
+ child_groups.push_back(l);
}
}
@@ -351,12 +343,7 @@ namespace
void add(const SanitisedDependency & dep)
{
- const std::shared_ptr<const RewrittenSpec> if_rewritten(decider.rewrite_if_special(dep.spec(),
- make_shared_copy(our_resolution->resolvent())));
- if (if_rewritten)
- if_rewritten->as_spec_tree()->top()->accept(*this);
- else
- sanitised_dependencies.add(dep);
+ sanitised_dependencies.add(dep);
}
SanitisedDependency make_sanitised(const PackageOrBlockDepSpec & spec)
diff --git a/paludis/resolver/spec_rewriter-fwd.hh b/paludis/resolver/spec_rewriter-fwd.hh
deleted file mode 100644
index 87cb30c..0000000
--- a/paludis/resolver/spec_rewriter-fwd.hh
+++ /dev/null
@@ -1,32 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2009 Ciaran McCreesh
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef PALUDIS_GUARD_PALUDIS_RESOLVER_SPEC_REWRITER_FWD_HH
-#define PALUDIS_GUARD_PALUDIS_RESOLVER_SPEC_REWRITER_FWD_HH 1
-
-namespace paludis
-{
- namespace resolver
- {
- struct SpecRewriter;
- struct RewrittenSpec;
- }
-}
-
-#endif
diff --git a/paludis/resolver/spec_rewriter.cc b/paludis/resolver/spec_rewriter.cc
deleted file mode 100644
index 2a7a9db..0000000
--- a/paludis/resolver/spec_rewriter.cc
+++ /dev/null
@@ -1,175 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2009, 2010, 2011 Ciaran McCreesh
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <paludis/resolver/spec_rewriter.hh>
-#include <paludis/resolver/sanitised_dependencies.hh>
-#include <paludis/resolver/resolvent.hh>
-#include <paludis/util/type_list.hh>
-#include <paludis/util/make_shared_copy.hh>
-#include <paludis/util/make_named_values.hh>
-#include <paludis/util/mutex.hh>
-#include <paludis/util/stringify.hh>
-#include <paludis/util/pimp-impl.hh>
-#include <paludis/util/make_null_shared_ptr.hh>
-#include <paludis/spec_tree.hh>
-#include <paludis/dep_spec.hh>
-#include <paludis/environment.hh>
-#include <paludis/selection.hh>
-#include <paludis/generator.hh>
-#include <paludis/filtered_generator.hh>
-#include <paludis/filter.hh>
-#include <paludis/package_id.hh>
-#include <paludis/metadata_key.hh>
-#include <paludis/partially_made_package_dep_spec.hh>
-#include <paludis/elike_blocker.hh>
-#include <map>
-#include <set>
-
-#include "config.h"
-
-using namespace paludis;
-using namespace paludis::resolver;
-
-typedef std::map<QualifiedPackageName, std::set<QualifiedPackageName> > Rewrites;
-
-const std::shared_ptr<const DependencySpecTree>
-RewrittenSpec::as_spec_tree() const
-{
- const std::shared_ptr<DependencySpecTree> result(std::make_shared<DependencySpecTree>(std::make_shared<AllDepSpec>()));
-
- for (Sequence<PackageOrBlockDepSpec>::ConstIterator i(specs()->begin()), i_end(specs()->end()) ;
- i != i_end ; ++i)
- if (i->if_package())
- result->top()->append(i->if_package());
- else
- result->top()->append(i->if_block());
-
- return result;
-}
-
-namespace paludis
-{
- template <>
- struct Imp<SpecRewriter>
- {
- const Environment * const env;
-
- mutable Mutex rewrites_mutex;
- mutable Rewrites rewrites;
- mutable bool has_rewrites;
-
- Imp(const Environment * const e) :
- env(e),
- has_rewrites(false)
- {
- }
- };
-}
-
-SpecRewriter::SpecRewriter(const Environment * const e) :
- _imp(e)
-{
-}
-
-SpecRewriter::~SpecRewriter() = default;
-
-const std::shared_ptr<const RewrittenSpec>
-SpecRewriter::rewrite_if_special(const PackageOrBlockDepSpec & s, const std::shared_ptr<const Resolvent> & maybe_our_resolvent) const
-{
- if (s.if_package() && s.if_package()->package_ptr())
- {
- if (s.if_package()->package_ptr()->category() != CategoryNamePart("virtual"))
- return make_null_shared_ptr();
- _need_rewrites();
-
- Rewrites::const_iterator r(_imp->rewrites.find(*s.if_package()->package_ptr()));
- if (r == _imp->rewrites.end())
- return make_null_shared_ptr();
-
- const std::shared_ptr<RewrittenSpec> result(std::make_shared<RewrittenSpec>(make_named_values<RewrittenSpec>(
- n::specs() = std::make_shared<Sequence<PackageOrBlockDepSpec>>()
- )));
-
- for (std::set<QualifiedPackageName>::const_iterator n(r->second.begin()), n_end(r->second.end()) ;
- n != n_end ; ++n)
- result->specs()->push_back(PackageOrBlockDepSpec(PartiallyMadePackageDepSpec(*s.if_package()).package(*n)));
-
- return result;
- }
- else if (s.if_block() && s.if_block()->blocking().package_ptr())
- {
- if (s.if_block()->blocking().package_ptr()->category() != CategoryNamePart("virtual"))
- return make_null_shared_ptr();
- _need_rewrites();
-
- Rewrites::const_iterator r(_imp->rewrites.find(*s.if_block()->blocking().package_ptr()));
- if (r == _imp->rewrites.end())
- return make_null_shared_ptr();
-
- const std::shared_ptr<RewrittenSpec> result(std::make_shared<RewrittenSpec>(make_named_values<RewrittenSpec>(
- n::specs() = std::make_shared<Sequence<PackageOrBlockDepSpec>>()
- )));
-
- for (std::set<QualifiedPackageName>::const_iterator n(r->second.begin()), n_end(r->second.end()) ;
- n != n_end ; ++n)
- {
- if (maybe_our_resolvent && (*n == maybe_our_resolvent->package()))
- continue;
-
- PackageDepSpec spec(PartiallyMadePackageDepSpec(s.if_block()->blocking()).package(*n));
- auto p(split_elike_blocker(s.if_block()->text()));
- BlockDepSpec b(std::get<1>(p) + stringify(spec), spec);
- b.set_annotations(s.if_block()->maybe_annotations());
- result->specs()->push_back(b);
- }
-
- return result;
- }
- else
- return make_null_shared_ptr();
-}
-
-void
-SpecRewriter::_need_rewrites() const
-{
-#ifdef ENABLE_VIRTUALS_REPOSITORY
- Lock lock(_imp->rewrites_mutex);
- if (_imp->has_rewrites)
- return;
- _imp->has_rewrites = true;
-
- Context context("When performing virtuals rewrites:");
-
- const std::shared_ptr<const PackageIDSequence> ids((*_imp->env)[selection::AllVersionsSorted(
- generator::InRepository(RepositoryName("virtuals")) +
- generator::InRepository(RepositoryName("installed-virtuals"))
- )]);
- for (PackageIDSequence::ConstIterator i(ids->begin()), i_end(ids->end()) ;
- i != i_end ; ++i)
- {
- if (! ((*i)->virtual_for_key()))
- throw InternalError(PALUDIS_HERE, "huh? " + stringify(**i) + " has no virtual_for_key");
- _imp->rewrites.insert(std::make_pair((*i)->name(), std::set<QualifiedPackageName>())).first->second.insert(
- (*i)->virtual_for_key()->parse_value()->name());
- }
-#endif
-}
-
-template class Pimp<resolver::SpecRewriter>;
-
diff --git a/paludis/resolver/spec_rewriter.hh b/paludis/resolver/spec_rewriter.hh
deleted file mode 100644
index f5886f0..0000000
--- a/paludis/resolver/spec_rewriter.hh
+++ /dev/null
@@ -1,72 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2009, 2010, 2011 Ciaran McCreesh
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef PALUDIS_GUARD_PALUDIS_RESOLVER_SPEC_REWRITER_HH
-#define PALUDIS_GUARD_PALUDIS_RESOLVER_SPEC_REWRITER_HH 1
-
-#include <paludis/resolver/spec_rewriter-fwd.hh>
-#include <paludis/resolver/sanitised_dependencies-fwd.hh>
-#include <paludis/resolver/resolvent-fwd.hh>
-#include <paludis/resolver/package_or_block_dep_spec-fwd.hh>
-#include <paludis/util/attributes.hh>
-#include <paludis/util/named_value.hh>
-#include <paludis/util/sequence-fwd.hh>
-#include <paludis/util/pimp.hh>
-#include <paludis/dep_spec-fwd.hh>
-#include <paludis/environment-fwd.hh>
-#include <paludis/spec_tree-fwd.hh>
-
-namespace paludis
-{
- namespace n
- {
- typedef Name<struct name_specs> specs;
- }
-
- namespace resolver
- {
- struct RewrittenSpec
- {
- NamedValue<n::specs, std::shared_ptr<Sequence<PackageOrBlockDepSpec> > > specs;
-
- const std::shared_ptr<const DependencySpecTree> as_spec_tree() const PALUDIS_ATTRIBUTE((warn_unused_result));
- };
-
- class PALUDIS_VISIBLE SpecRewriter
- {
- private:
- Pimp<SpecRewriter> _imp;
-
- private:
- void _need_rewrites() const;
-
- public:
- SpecRewriter(const Environment * const);
- ~SpecRewriter();
-
- const std::shared_ptr<const RewrittenSpec> rewrite_if_special(const PackageOrBlockDepSpec &,
- const std::shared_ptr<const Resolvent> & maybe_from) const PALUDIS_ATTRIBUTE((warn_unused_result));
- };
- }
-
- extern template class Pimp<resolver::SpecRewriter>;
-
-}
-
-#endif