std::vector<JSCPropertyPointer> JSCLanguageBase::propertiesForObj(const JSCObjectPointer& object) const { SIAAssert(nullptr != object.get()); std::vector<JSCPropertyPointer> result; result.reserve(object->properties().size()); std::vector<JSCObjectPointer> additionalClasses = findAdditionalClasses(object); bool isLeaf = checkIsLeaf(object); for (const auto& property : object->properties()) { if (isLeaf && checkIsLeaf(property)) { for (const auto& childProperty : propertiesForProperty(property)) { result.push_back(childProperty); } } else if (!isIgnore(property) && !containsPropertyInClasses(property, additionalClasses)) { result.push_back(property); } } for (const auto& additionalClassData : additionalClasses) { JSCObjectPointer additionalClass(new JSCObject(*additionalClassData.get())); auto path = object->path(); path.push_back(additionalClassData->pathName()); additionalClass->setPath(path); result.push_back(additionalClass); } return result; }
bool JSCLanguageBase::checkIsLeaf(const JSCPropertyPointer& property) const { if (JSCProperty_Object == property->type()) { std::string name = std::static_pointer_cast<JSCObject>(property)->rootName(); return m_leafClasses.count(name) > 0; } else if (JSCProperty_Ref == property->type()) { return checkIsLeaf(std::static_pointer_cast<JSCRef>(property)->refProperty()); } else if (JSCProperty_Array == property->type()) { return checkIsLeaf(std::static_pointer_cast<JSCArray>(property)->propertyType()); } return false; }
int FollowLineTilLeaf(void) { StartTask(FollowEdge); int forwards = gatherForwardsData(); for(;;) { if(detectNode(forwards)) { if(checkIsLeaf()) { followingEdge = false; StopTask(FollowEdge); return FOUND_LEAF; } else { forwards = gatherForwardsData(); } } abortTimeslice(); } }