aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/idstringlist.cc19
-rw-r--r--common/idstringlist.h3
2 files changed, 22 insertions, 0 deletions
diff --git a/common/idstringlist.cc b/common/idstringlist.cc
index 9900f92a..6f6f8cd0 100644
--- a/common/idstringlist.cc
+++ b/common/idstringlist.cc
@@ -58,4 +58,23 @@ std::string IdStringList::str(const Context *ctx) const
return s;
}
+IdStringList IdStringList::concat(IdStringList a, IdStringList b)
+{
+ IdStringList result(a.size() + b.size());
+ for (size_t i = 0; i < a.size(); i++)
+ result.ids[i] = a[i];
+ for (size_t i = 0; i < b.size(); i++)
+ result.ids[a.size() + i] = b[i];
+ return result;
+}
+
+IdStringList IdStringList::slice(size_t s, size_t e) const
+{
+ NPNR_ASSERT(e >= s);
+ IdStringList result(e - s);
+ for (size_t i = 0; i < result.size(); i++)
+ result.ids[i] = ids[s + i];
+ return result;
+}
+
NEXTPNR_NAMESPACE_END
diff --git a/common/idstringlist.h b/common/idstringlist.h
index 6a6a554d..24a46731 100644
--- a/common/idstringlist.h
+++ b/common/idstringlist.h
@@ -64,6 +64,9 @@ struct IdStringList
}
return false;
}
+
+ static IdStringList concat(IdStringList a, IdStringList b);
+ IdStringList slice(size_t s, size_t e) const;
};
NEXTPNR_NAMESPACE_END