diff options
author | Benjamin Paassen <bpaassen@techfak.uni-bielefeld.de> | 2015-02-08 19:37:51 +0100 |
---|---|---|
committer | Benjamin Paassen <bpaassen@techfak.uni-bielefeld.de> | 2015-02-08 19:37:51 +0100 |
commit | 5eca67b6cab7031d8203b1403ba5cddaef833e76 (patch) | |
tree | ddb626aa00a0da75d038b08025e4c4fd7760ec5c /src/core/model/Domain.cpp | |
parent | c2b9597c49abeef3f333b1bf7221a51019d53668 (diff) |
restructured the FieldDescriptor mechanism.
Diffstat (limited to 'src/core/model/Domain.cpp')
-rw-r--r-- | src/core/model/Domain.cpp | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/src/core/model/Domain.cpp b/src/core/model/Domain.cpp index 55f05b3..f45bd27 100644 --- a/src/core/model/Domain.cpp +++ b/src/core/model/Domain.cpp @@ -179,13 +179,7 @@ bool Descriptor::continuePath(Handle<StructuredClass> target, std::vector<Rooted<Node>> optimum; // use recursive depth-first search from the top to reach the given child // get the list of effective FieldDescriptors. - NodeVector<FieldDescriptor> fields; - if (isa(&RttiTypes::StructuredClass)) { - const StructuredClass *tis = static_cast<const StructuredClass *>(this); - fields = tis->getEffectiveFieldDescriptors(); - } else { - fields = getFieldDescriptors(); - } + NodeVector<FieldDescriptor> fields = getFieldDescriptors(); for (auto &fd : fields) { for (auto &c : fd->getChildren()) { @@ -234,6 +228,30 @@ bool Descriptor::continuePath(Handle<StructuredClass> target, return found; } +int Descriptor::getFieldDescriptorIndex(const std::string &name) const +{ + int f = 0; + for (auto &fd : getFieldDescriptors()) { + if (fd->getName() == name) { + return f; + } + f++; + } + return -1; +} + +int Descriptor::getFieldDescriptorIndex(Handle<FieldDescriptor> fd) const +{ + int f = 0; + for (auto &fd2 : getFieldDescriptors()) { + if (fd == fd2) { + return f; + } + f++; + } + return -1; +} + void Descriptor::addFieldDescriptor(Handle<FieldDescriptor> fd) { // only add it if we need to. @@ -444,14 +462,13 @@ const void StructuredClass::gatherFieldDescriptors( } } -NodeVector<FieldDescriptor> StructuredClass::getEffectiveFieldDescriptors() - const +NodeVector<FieldDescriptor> StructuredClass::getFieldDescriptors() const { // in this case we return a NodeVector of Rooted entries without owner. NodeVector<FieldDescriptor> vec; std::set<std::string> overriddenFields; gatherFieldDescriptors(vec, overriddenFields); - return std::move(vec); + return vec; } /* Class AnnotationClass */ |