mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:07:34 +00:00
LibJS/Bytecode: Leave BlockDeclarationInstantiation in C++
Instead of implementing this AO in bytecode, we now have an instruction for it that simply invokes the C++ implementation. This allows us to simplify Bytecode::Generator quite a bit by removing all the variable scope tracking.
This commit is contained in:
parent
4684d3fe54
commit
ac246d764d
6 changed files with 56 additions and 91 deletions
|
@ -136,36 +136,11 @@ public:
|
|||
};
|
||||
struct LexicalScope {
|
||||
SurroundingScopeKind kind;
|
||||
BindingMode mode;
|
||||
HashTable<IdentifierTableIndex> known_bindings;
|
||||
};
|
||||
|
||||
void register_binding(IdentifierTableIndex identifier, BindingMode mode = BindingMode::Lexical)
|
||||
{
|
||||
m_variable_scopes.last_matching([&](auto& x) { return x.mode == BindingMode::Global || x.mode == mode; })->known_bindings.set(identifier);
|
||||
}
|
||||
bool has_binding(IdentifierTableIndex identifier, Optional<BindingMode> const& specific_binding_mode = {}) const
|
||||
{
|
||||
for (auto index = m_variable_scopes.size(); index > 0; --index) {
|
||||
auto& scope = m_variable_scopes[index - 1];
|
||||
void block_declaration_instantiation(ScopeNode const&);
|
||||
|
||||
if (scope.mode != BindingMode::Global && specific_binding_mode.value_or(scope.mode) != scope.mode)
|
||||
continue;
|
||||
|
||||
if (scope.known_bindings.contains(identifier))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool has_binding_in_current_scope(IdentifierTableIndex identifier) const
|
||||
{
|
||||
if (m_variable_scopes.is_empty())
|
||||
return false;
|
||||
|
||||
return m_variable_scopes.last().known_bindings.contains(identifier);
|
||||
}
|
||||
|
||||
void begin_variable_scope(BindingMode mode = BindingMode::Lexical, SurroundingScopeKind kind = SurroundingScopeKind::Block);
|
||||
void begin_variable_scope();
|
||||
void end_variable_scope();
|
||||
|
||||
enum class BlockBoundaryType {
|
||||
|
@ -239,7 +214,6 @@ private:
|
|||
FunctionKind m_enclosing_function_kind { FunctionKind::Normal };
|
||||
Vector<LabelableScope> m_continuable_scopes;
|
||||
Vector<LabelableScope> m_breakable_scopes;
|
||||
Vector<LexicalScope> m_variable_scopes;
|
||||
Vector<BlockBoundaryType> m_boundaries;
|
||||
Vector<Register> m_home_objects;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue