예제 #1
0
std::list<std::string> name_flattener::flatten(const name& n) const {
    const auto& l(n.location());
    std::list<std::string> r(l.external_modules());

    for (const auto& m : l.model_modules())
        r.push_back(m);

    for (const auto& m : l.internal_modules())
        r.push_back(m);


    if (!detect_model_name_)
        return r;

    /* if the name belongs to the model's module, we need to remove the
     * module's simple name from the module path (it is in both the
     * module path and it is also the module's simple name).
     */
    const bool no_internal_modules(l.internal_modules().empty());
    const bool has_model_modules(!l.model_modules().empty());
    const bool is_model_name(no_internal_modules && has_model_modules &&
                             n.simple() == l.model_modules().back());

    if (is_model_name)
        r.pop_back();

    return r;
}
예제 #2
0
name name_factory::build_attribute_name(const name& owner_name,
    const std::string& simple_name) const {

    location l(owner_name.location());
    l.element(owner_name.simple());

    name n;
    n.location(l);
    n.simple(simple_name);
    name_builder b(n);
    return b.build();
}
예제 #3
0
name name_factory::build_promoted_module_name(const name& model_name,
    const name& element_name) const {
    name n;
    n.simple(element_name.simple());

    const auto& l(element_name.location());
    if (!l.internal_modules().empty())
        n.location().model_modules().push_back(l.internal_modules().front());

    n.location().external_modules(model_name.location().external_modules());

    name_builder b(n);
    return b.build();
}
예제 #4
0
name name_factory::build_element_in_module(const name& module_name,
    const std::string& simple_name) const {
    yarn::name n;
    n.simple(simple_name);

    const auto& l(module_name.location());
    n.location().model_modules(l.model_modules());
    n.location().external_modules(l.external_modules());

    auto pp(l.internal_modules());
    pp.push_back(module_name.simple());
    n.location().internal_modules(pp);

    name_builder b(n);
    return b.build();
}
예제 #5
0
void dehydrator::dehydrate_name(const name& n, std::ostream& s) const {
    formatters::utility_formatter uf(s);
    s << " { ";
    uf.insert_quoted("simple_name");
    s << " : ";
    uf.insert_quoted(n.simple());

    const auto& l(n.location());
    if (!l.internal_modules().empty()) {
        s << comma_space;
        uf.insert_quoted("internal_modules");
        s << " : ";
        uf.insert_quoted(join(l.internal_modules(), scope));
    }
    s << " } ";
}
예제 #6
0
inline bool operator<(const name& lhs, const name& rhs) {
    return
        (lhs.location() < rhs.location() ||
            (lhs.location() == rhs.location() &&
                (lhs.simple() < rhs.simple())));
}