1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=8 sts=2 et sw=2 tw=80:
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef frontend_Frontend2_h
8 #define frontend_Frontend2_h
10 #include "mozilla/Utf8.h" // mozilla::Utf8Unit
12 #include <stddef.h> // size_t
13 #include <stdint.h> // uint8_t
15 #include "js/CompileOptions.h" // JS::ReadOnlyCompileOptions
16 #include "js/RootingAPI.h" // JS::Handle
17 #include "js/SourceText.h" // JS::SourceText
18 #include "js/UniquePtr.h" // js::UniquePtr
19 #include "vm/JSScript.h" // JSScript
27 class ScriptSourceObject
;
28 class FrontendContext
;
32 struct CompilationInput
;
33 struct ExtensibleCompilationStencil
;
34 struct CompilationGCOutput
;
35 struct CompilationState
;
37 // This is declarated as a class mostly to solve dependency around `friend`
38 // declarations in the simple way.
41 [[nodiscard
]] static bool tryCompileGlobalScriptToExtensibleStencil(
42 JSContext
* cx
, FrontendContext
* fc
, CompilationInput
& input
,
43 JS::SourceText
<mozilla::Utf8Unit
>& srcBuf
,
44 UniquePtr
<ExtensibleCompilationStencil
>& stencilOut
);
47 // Initialize SmooshMonkey globals, such as the logging system.
50 // Use the SmooshMonkey frontend to parse and free the generated AST. Returns
51 // true if no error were detected while parsing.
52 [[nodiscard
]] bool SmooshParseScript(JSContext
* cx
, const uint8_t* bytes
,
54 [[nodiscard
]] bool SmooshParseModule(JSContext
* cx
, const uint8_t* bytes
,
57 } // namespace frontend
61 #endif /* frontend_Frontend2_h */