mirror of
https://github.com/RGBCube/serenity
synced 2025-07-02 20:22:13 +00:00
LibJS: Implement const variable declarations
This also tightens the means of redeclaration of a variable by proxy, since we now have a way of knowing how a variable was initially declared, we can check if it was declared using `let` or `const` and not tolerate redeclaration like we did previously.
This commit is contained in:
parent
8557bc56f7
commit
ee5a49e2fe
5 changed files with 46 additions and 13 deletions
|
@ -30,6 +30,7 @@
|
|||
#include <AK/Vector.h>
|
||||
#include <LibJS/Forward.h>
|
||||
#include <LibJS/Heap.h>
|
||||
#include <LibJS/Value.h>
|
||||
|
||||
namespace JS {
|
||||
|
||||
|
@ -38,10 +39,15 @@ enum class ScopeType {
|
|||
Block,
|
||||
};
|
||||
|
||||
struct Variable {
|
||||
Value value;
|
||||
DeclarationType declaration_type;
|
||||
};
|
||||
|
||||
struct ScopeFrame {
|
||||
ScopeType type;
|
||||
const ScopeNode& scope_node;
|
||||
HashMap<String, Value> variables;
|
||||
HashMap<String, Variable> variables;
|
||||
};
|
||||
|
||||
class Interpreter {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue