예제 #1
0
파일: dict.cpp 프로젝트: Usarak/pyston
Box* dictItems(BoxedDict* self) {
    BoxedList* rtn = new BoxedList();

    for (const auto& p : self->d) {
        BoxedTuple::GCVector elts;
        elts.push_back(p.first);
        elts.push_back(p.second);
        BoxedTuple* t = new BoxedTuple(std::move(elts));
        listAppendInternal(rtn, t);
    }

    return rtn;
}
예제 #2
0
파일: code.cpp 프로젝트: rowhit/pyston
    static Box* varnames(Box* b, void*) {
        RELEASE_ASSERT(b->cls == code_cls, "");
        BoxedCode* code = static_cast<BoxedCode*>(b);

        auto& param_names = code->f->param_names;
        if (!param_names.takes_param_names)
            return EmptyTuple;

        BoxedTuple::GCVector elts;
        for (auto sr : param_names.args)
            elts.push_back(boxString(sr));
        if (param_names.vararg.size())
            elts.push_back(boxString(param_names.vararg));
        if (param_names.kwarg.size())
            elts.push_back(boxString(param_names.kwarg));
        return BoxedTuple::create(elts.size(), &elts[0]);
    }