1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:07:35 +00:00

LibJS: Replace ASTNode::class_name() with RTTI

This is only used for debugging anyway, so performance doesn't matter
too much.
This commit is contained in:
Andreas Kling 2021-01-17 09:21:15 +01:00
parent 647cfcb641
commit 4da913bfab
2 changed files with 11 additions and 117 deletions

View file

@ -25,6 +25,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <AK/Demangle.h>
#include <AK/HashMap.h>
#include <AK/HashTable.h>
#include <AK/ScopeGuard.h>
@ -51,6 +52,12 @@
namespace JS {
String ASTNode::class_name() const
{
// NOTE: We strip the "JS::" prefix.
return demangle(typeid(*this).name()).substring(4);
}
static void update_function_name(Value value, const FlyString& name, HashTable<JS::Cell*>& visited)
{
if (!value.is_object())
@ -1155,7 +1162,7 @@ void NullLiteral::dump(int indent) const
outln("null");
}
void FunctionNode::dump(int indent, const char* class_name) const
void FunctionNode::dump(int indent, const String& class_name) const
{
print_indent(indent);
outln("{} '{}'", class_name, name());