2021-09-14 20:51:16 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <LibJS/AST.h>
|
|
|
|
#include <LibJS/Forward.h>
|
|
|
|
#include <LibJS/Module.h>
|
|
|
|
#include <LibJS/Parser.h>
|
|
|
|
|
|
|
|
namespace JS {
|
|
|
|
|
|
|
|
// 16.2.1.6 Source Text Module Records, https://tc39.es/ecma262/#sec-source-text-module-records
|
|
|
|
class SourceTextModule final : public Module {
|
|
|
|
public:
|
|
|
|
static Result<NonnullRefPtr<SourceTextModule>, Vector<Parser::Error>> parse(StringView source_text, Realm&, StringView filename = {});
|
|
|
|
virtual ~SourceTextModule();
|
|
|
|
|
2022-01-16 13:16:04 +01:00
|
|
|
Program const& parse_node() const { return *m_ecmascript_code; }
|
|
|
|
|
2021-09-14 20:51:16 +02:00
|
|
|
private:
|
2022-01-18 19:21:42 +01:00
|
|
|
explicit SourceTextModule(Realm&, StringView filename, NonnullRefPtr<Program>);
|
2021-09-14 20:51:16 +02:00
|
|
|
|
|
|
|
NonnullRefPtr<Program> m_ecmascript_code; // [[ECMAScriptCode]]
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|