mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:47:36 +00:00
LibJS: Add VM::dump_scope_chain()
This is a handy helper that dumps the current scope chain, starting at the innermost scope.
This commit is contained in:
parent
4c8df58e08
commit
0d2aba07aa
2 changed files with 14 additions and 0 deletions
|
@ -622,4 +622,17 @@ void VM::dump_backtrace() const
|
|||
dbgln("-> {}", m_call_stack[i]->function_name);
|
||||
}
|
||||
|
||||
void VM::dump_scope_chain() const
|
||||
{
|
||||
for (auto* scope = current_scope(); scope; scope = scope->parent()) {
|
||||
dbgln("+> {} ({:p})", scope->class_name(), scope);
|
||||
if (is<LexicalEnvironment>(*scope)) {
|
||||
auto& lexical_environment = static_cast<LexicalEnvironment const&>(*scope);
|
||||
for (auto& variable : lexical_environment.variables()) {
|
||||
dbgln(" {}", variable.key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue