mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:47:44 +00:00
LibJS: Generate bytecode for entering nested lexical environments
This adds a new PushLexicalEnvironment instruction that creates a new LexicalEnvironment and pushes it on the VM's scope stack. There is no corresponding PopLexicalEnvironment instruction yet, so this will behave incorrectly with let/const scopes for example.
This commit is contained in:
parent
d560ee118d
commit
c3c68399b5
4 changed files with 92 additions and 1 deletions
|
@ -14,6 +14,7 @@
|
|||
#include <LibJS/Bytecode/Register.h>
|
||||
#include <LibJS/Bytecode/StringTable.h>
|
||||
#include <LibJS/Heap/Cell.h>
|
||||
#include <LibJS/Runtime/ScopeObject.h>
|
||||
#include <LibJS/Runtime/Value.h>
|
||||
|
||||
namespace JS::Bytecode::Op {
|
||||
|
@ -453,6 +454,19 @@ public:
|
|||
private:
|
||||
Label m_resume_target;
|
||||
};
|
||||
|
||||
class PushLexicalEnvironment final : public Instruction {
|
||||
public:
|
||||
PushLexicalEnvironment(HashMap<u32, Variable> variables)
|
||||
: Instruction(Type::PushLexicalEnvironment)
|
||||
, m_variables(move(variables))
|
||||
{
|
||||
}
|
||||
void execute(Bytecode::Interpreter&) const;
|
||||
String to_string(Bytecode::Executable const&) const;
|
||||
|
||||
HashMap<u32, Variable> m_variables;
|
||||
};
|
||||
}
|
||||
|
||||
namespace JS::Bytecode {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue