mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:57:45 +00:00
LibJS: Actually leave the current function scope on "return"
We now unwind until the nearest function-level scope on the scope stack when executing a return statement.
This commit is contained in:
parent
df524203b2
commit
494df52961
3 changed files with 13 additions and 6 deletions
|
@ -37,6 +37,7 @@
|
|||
namespace JS {
|
||||
|
||||
enum class ScopeType {
|
||||
None,
|
||||
Function,
|
||||
Block,
|
||||
};
|
||||
|
@ -74,7 +75,7 @@ public:
|
|||
|
||||
Heap& heap() { return m_heap; }
|
||||
|
||||
void do_return();
|
||||
void unwind(ScopeType type) { m_unwind_until = type; }
|
||||
|
||||
Value get_variable(const FlyString& name);
|
||||
void set_variable(const FlyString& name, Value, bool first_assignment = false);
|
||||
|
@ -114,6 +115,8 @@ private:
|
|||
Object* m_string_prototype { nullptr };
|
||||
Object* m_object_prototype { nullptr };
|
||||
Object* m_array_prototype { nullptr };
|
||||
|
||||
ScopeType m_unwind_until { ScopeType::None };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue