예제 #1
0
find_includes::result_type find_includes::operator()(const suite& n) {
    bool outer_suite = m_outer;
    m_outer = false;
    shared_ptr<const suite> rewritten =
        static_pointer_cast<const suite>(this->rewriter::operator()(n));
    if (!outer_suite) {
        return rewritten;
    }

    //We're the outer suite, add include statements
    vector<shared_ptr<const statement> > augmented_statements;
    for(auto i = m_includes.begin();
        i != m_includes.end();
        i++) {
        augmented_statements.push_back(
            make_shared<include>(
                make_shared<literal>(
                    *i)));
    }
    for(auto i = n.begin();
        i != n.end();
        i++) {
        augmented_statements.push_back(i->ptr());
    }
    return make_shared<const suite>(std::move(augmented_statements));
}
예제 #2
0
prune::result_type prune::operator()(const suite& n) {
    vector<shared_ptr<const statement> > stmts;
    auto i = n.end();
    do {
        i--;
        shared_ptr<const statement> rewritten =
            static_pointer_cast<const statement>(
                boost::apply_visitor(*this, *i));
        if (rewritten != shared_ptr<const statement>()) {
            stmts.push_back(rewritten);
        }
    } while (i != n.begin());
    reverse(stmts.begin(), stmts.end());
    return make_shared<const suite>(move(stmts));
}
예제 #3
0
namespace_wrap::result_type namespace_wrap::operator()(const suite& n) {
    vector<shared_ptr<const statement> > stmts;
    for(auto i = n.begin();
        i != n.end();
        i++) {
        //Exclude #include statements from wrapping
        if (detail::isinstance<include>(*i)) {
            stmts.push_back(static_pointer_cast<const statement>(i->ptr()));
        } else {
            vector<shared_ptr<const statement> > wrapping;
            for(; i != n.end() && !detail::isinstance<include>(*i); i++) {
                wrapping.push_back(i->ptr());
            }
            i--;
            stmts.push_back(
                make_shared<const namespace_block>(
                    m_hash,
                    make_shared<const suite>(
                        std::move(wrapping))));
        
        }
    }
    return make_shared<const suite>(std::move(stmts));
}