1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-16 10:34:58 +00:00

LibJS: Add some helpers and use them to re-implement Console functions

Also add const overloads for some getters.

Also const-qualify Interpreter::join_arguments().
This commit is contained in:
Emanuele Torre 2020-05-04 14:18:15 +02:00 committed by Andreas Kling
parent 92815f313a
commit bc7ed4524e
4 changed files with 47 additions and 21 deletions

View file

@ -262,7 +262,7 @@ const GlobalObject& Interpreter::global_object() const
return static_cast<const GlobalObject&>(*m_global_object);
}
String Interpreter::join_arguments()
String Interpreter::join_arguments() const
{
StringBuilder joined_arguments;
for (size_t i = 0; i < argument_count(); ++i) {
@ -273,4 +273,13 @@ String Interpreter::join_arguments()
return joined_arguments.build();
}
Vector<String> Interpreter::get_trace() const
{
Vector<String> trace;
// -2 to skip the console.trace() call frame
for (ssize_t i = m_call_stack.size() - 2; i >= 0; --i)
trace.append(m_call_stack[i].function_name);
return trace;
}
}