1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 08:57:47 +00:00

LibJS: Allow multiple labels on the same statement

Since there are only a number of statements where labels can actually be
used we now also only store labels when necessary.
Also now tracks the first continue usage of a label since this might not
be valid but that can only be determined after we have parsed the
statement.
Also ensures the correct error does not get wiped by load_state.
This commit is contained in:
davidot 2021-09-18 23:01:54 +02:00 committed by Linus Groh
parent bfc1b4ba61
commit 79caca8ca2
7 changed files with 194 additions and 47 deletions

View file

@ -193,11 +193,13 @@ public:
m_unwind_until = ScopeType::None;
m_unwind_until_label = {};
}
bool should_unwind_until(ScopeType type, HashTable<FlyString> const& labels) const
bool should_unwind_until(ScopeType type, Vector<FlyString> const& labels) const
{
if (m_unwind_until_label.is_null())
return m_unwind_until == type;
return m_unwind_until == type && labels.contains(m_unwind_until_label);
return m_unwind_until == type && any_of(labels.begin(), labels.end(), [&](FlyString const& label) {
return m_unwind_until_label == label;
});
}
bool should_unwind() const { return m_unwind_until != ScopeType::None; }