Skip to content

Is xdemangle.hpp redundant ? #179

@anutosh491

Description

@anutosh491

I see that xdemangle.hpp provides the demangle function.

const char* demangle(const char* name) noexcept;
const char* demangle(const std::string& name) noexcept;

This should technically be used in xinspect in the implementation of find_type (as done for xeus-cling)

But we are currently using find_type_slow (the function name suggests this might not be the best approach ?!)

std::string find_type_slow(const std::string& expression) {
static unsigned long long var_count = 0;
if (auto *type = Cpp::GetType(expression))
return Cpp::GetQualifiedName(type);
// Here we might need to deal with integral types such as 3.14.
std::string id = "__Xeus_GetType_" + std::to_string(var_count++);
std::string using_clause = "using " + id + " = __typeof__(" + expression + ");\n";
if (!Cpp::Declare(using_clause.c_str(), /*silent=*/false)) {
Cpp::TCppScope_t lookup = Cpp::GetNamed(id, nullptr);
Cpp::TCppType_t lookup_ty = Cpp::GetTypeFromScope(lookup);
return Cpp::GetQualifiedCompleteName(Cpp::GetCanonicalType(lookup_ty));
}
return "";
}

But if we are not trying to implement a "find_type_fast" and are comfortable with what we have, let's get rid of xdemangle.hpp ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs triageUsed in auto labelling of new issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions