aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-12-15 00:15:35 +0000
committerDavid Robillard <d@drobilla.net>2012-12-15 00:15:35 +0000
commit8148e755d3f587e6c212ba90efc151ea07de2703 (patch)
tree81f6276ebaf62bb4ecebf9b9c8cb6e1e15ed1aec
parent2918c1a6ce05325b18874193588b58b40f2691f5 (diff)
downloadresp-8148e755d3f587e6c212ba90efc151ea07de2703.tar.gz
resp-8148e755d3f587e6c212ba90efc151ea07de2703.tar.bz2
resp-8148e755d3f587e6c212ba90efc151ea07de2703.zip
Add Subst::augment function.
git-svn-id: http://svn.drobilla.net/resp/trunk@438 ad02d1e2-f140-0410-9f75-f8b11f17cedd
-rw-r--r--src/resp.hpp1
-rw-r--r--src/unify.cpp10
2 files changed, 11 insertions, 0 deletions
diff --git a/src/resp.hpp b/src/resp.hpp
index 8cdb75e..f4689a0 100644
--- a/src/resp.hpp
+++ b/src/resp.hpp
@@ -534,6 +534,7 @@ struct Subst : public list<Constraint> {
if (s && t) { assert(s != t); push_back(Constraint(s, t)); }
}
static Subst compose(const Subst& delta, const Subst& gamma);
+ void augment(const Subst& subst);
void add(const AST* from, const AST* to) {
assert(from && to);
push_back(Constraint(from, to));
diff --git a/src/unify.cpp b/src/unify.cpp
index a7f7822..48ae1dd 100644
--- a/src/unify.cpp
+++ b/src/unify.cpp
@@ -85,6 +85,16 @@ substitute(const AST* in, const AST* from, const AST* to)
return ret.head;
}
+void
+Subst::augment(const Subst& subst)
+{
+ for (Subst::const_iterator s = subst.begin(); s != subst.end(); ++s) {
+ if (!contains(s->first)) {
+ add(s->first, s->second);
+ }
+ }
+}
+
/// Compose two substitutions (TAPL 22.1.1)
Subst
Subst::compose(const Subst& delta, const Subst& gamma)