mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:17:35 +00:00
LibJS: Add a mode to parse JS as a module
In a module strict mode should be enabled at the start of parsing and we allow import and export statements.
This commit is contained in:
parent
d6d7d11590
commit
7613c22b06
8 changed files with 38 additions and 15 deletions
|
@ -168,8 +168,14 @@ private:
|
|||
|
||||
class Program final : public ScopeNode {
|
||||
public:
|
||||
explicit Program(SourceRange source_range)
|
||||
enum class Type {
|
||||
Script,
|
||||
Module
|
||||
};
|
||||
|
||||
explicit Program(SourceRange source_range, Type program_type)
|
||||
: ScopeNode(source_range)
|
||||
, m_type(program_type)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -178,10 +184,13 @@ public:
|
|||
bool is_strict_mode() const { return m_is_strict_mode; }
|
||||
void set_strict_mode() { m_is_strict_mode = true; }
|
||||
|
||||
Type type() const { return m_type; }
|
||||
|
||||
private:
|
||||
virtual bool is_program() const override { return true; }
|
||||
|
||||
bool m_is_strict_mode { false };
|
||||
Type m_type { Type::Script };
|
||||
};
|
||||
|
||||
class BlockStatement final : public ScopeNode {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue