mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:57:44 +00:00
LibJS: Integrate labels into the Interpreter
The interpreter now considers a statement or block's label when considering whether or not to break. All statements can be labelled.
This commit is contained in:
parent
03615a7872
commit
d52ea37717
6 changed files with 87 additions and 21 deletions
|
@ -91,9 +91,18 @@ public:
|
|||
|
||||
Heap& heap() { return m_heap; }
|
||||
|
||||
void unwind(ScopeType type) { m_unwind_until = type; }
|
||||
void unwind(ScopeType type, FlyString label = {})
|
||||
{
|
||||
m_unwind_until = type;
|
||||
m_unwind_until_label = label;
|
||||
}
|
||||
void stop_unwind() { m_unwind_until = ScopeType::None; }
|
||||
bool should_unwind_until(ScopeType type) const { return m_unwind_until == type; }
|
||||
bool should_unwind_until(ScopeType type, FlyString label) const
|
||||
{
|
||||
if (m_unwind_until_label.is_null())
|
||||
return m_unwind_until == type;
|
||||
return m_unwind_until == type && m_unwind_until_label == label;
|
||||
}
|
||||
bool should_unwind() const { return m_unwind_until != ScopeType::None; }
|
||||
|
||||
Value get_variable(const FlyString& name);
|
||||
|
@ -189,6 +198,7 @@ private:
|
|||
Exception* m_exception { nullptr };
|
||||
|
||||
ScopeType m_unwind_until { ScopeType::None };
|
||||
FlyString m_unwind_until_label;
|
||||
|
||||
Console m_console;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue