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

LibJS: Implement basic execution of "switch" statements

The "break" keyword now unwinds to the nearest ScopeType::Breakable.
There's no support for break labels yet, but we'll get there too.
This commit is contained in:
Andreas Kling 2020-03-29 14:34:25 +02:00
parent 1923051c5b
commit 2285f84596
6 changed files with 57 additions and 2 deletions

View file

@ -42,6 +42,7 @@ enum class ScopeType {
Function,
Block,
Try,
Breakable,
};
struct Variable {
@ -78,6 +79,7 @@ public:
Heap& heap() { return m_heap; }
void unwind(ScopeType type) { m_unwind_until = type; }
bool should_unwind() const { return m_unwind_until != ScopeType::None; }
Optional<Value> get_variable(const FlyString& name);
void set_variable(const FlyString& name, Value, bool first_assignment = false);