Box* superRepr(Box* _s) { RELEASE_ASSERT(_s->cls == super_cls, ""); BoxedSuper* s = static_cast<BoxedSuper*>(_s); if (s->obj_type) { return boxStringTwine(llvm::Twine("<super: <class '") + (s->type ? getNameOfClass(s->type) : "NULL") + "'>, <" + getNameOfClass(s->obj_type) + " object>>"); } else { return boxStringTwine(llvm::Twine("<super: <class '") + (s->type ? getNameOfClass(s->type) : "NULL") + "'>, <NULL>>"); } }
// TODO // Combine this with the below? Basically the same logic with different string types... // Also should this go in this file? BoxedString* mangleNameBoxedString(BoxedString* id, BoxedString* private_name) { assert(id); assert(private_name); int len = id->size(); if (len < 2 || id->s()[0] != '_' || id->s()[1] != '_') return id; if ((id->s()[len - 2] == '_' && id->s()[len - 1] == '_') || id->s().find('.') != llvm::StringRef::npos) return id; const char* p = private_name->data(); while (*p == '_') { p++; len--; } if (*p == '\0') return id; return static_cast<BoxedString*>(boxStringTwine("_" + (p + id->s()))); }