|
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
|
2 * vim: set ts=8 sts=4 et sw=4 tw=99: |
|
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/. */ |
|
6 |
|
7 #ifndef frontend_BytecodeCompiler_h |
|
8 #define frontend_BytecodeCompiler_h |
|
9 |
|
10 #include "NamespaceImports.h" |
|
11 |
|
12 class JSLinearString; |
|
13 |
|
14 namespace js { |
|
15 |
|
16 class AutoNameVector; |
|
17 class LazyScript; |
|
18 class LifoAlloc; |
|
19 struct SourceCompressionTask; |
|
20 |
|
21 namespace frontend { |
|
22 |
|
23 JSScript * |
|
24 CompileScript(ExclusiveContext *cx, LifoAlloc *alloc, |
|
25 HandleObject scopeChain, HandleScript evalCaller, |
|
26 const ReadOnlyCompileOptions &options, SourceBufferHolder &srcBuf, |
|
27 JSString *source_ = nullptr, unsigned staticLevel = 0, |
|
28 SourceCompressionTask *extraSct = nullptr); |
|
29 |
|
30 bool |
|
31 CompileLazyFunction(JSContext *cx, Handle<LazyScript*> lazy, const jschar *chars, size_t length); |
|
32 |
|
33 bool |
|
34 CompileFunctionBody(JSContext *cx, MutableHandleFunction fun, |
|
35 const ReadOnlyCompileOptions &options, |
|
36 const AutoNameVector &formals, JS::SourceBufferHolder &srcBuf); |
|
37 bool |
|
38 CompileStarGeneratorBody(JSContext *cx, MutableHandleFunction fun, |
|
39 const ReadOnlyCompileOptions &options, |
|
40 const AutoNameVector &formals, JS::SourceBufferHolder &srcBuf); |
|
41 |
|
42 ScriptSourceObject * |
|
43 CreateScriptSourceObject(ExclusiveContext *cx, const ReadOnlyCompileOptions &options); |
|
44 |
|
45 /* |
|
46 * This should be called while still on the main thread if compilation will |
|
47 * occur on a worker thread. |
|
48 */ |
|
49 void |
|
50 MaybeCallSourceHandler(JSContext *cx, const ReadOnlyCompileOptions &options, |
|
51 JS::SourceBufferHolder &srcBuf); |
|
52 |
|
53 /* |
|
54 * True if str consists of an IdentifierStart character, followed by one or |
|
55 * more IdentifierPart characters, i.e. it matches the IdentifierName production |
|
56 * in the language spec. |
|
57 * |
|
58 * This returns true even if str is a keyword like "if". |
|
59 * |
|
60 * Defined in TokenStream.cpp. |
|
61 */ |
|
62 bool |
|
63 IsIdentifier(JSLinearString *str); |
|
64 |
|
65 /* True if str is a keyword. Defined in TokenStream.cpp. */ |
|
66 bool |
|
67 IsKeyword(JSLinearString *str); |
|
68 |
|
69 /* GC marking. Defined in Parser.cpp. */ |
|
70 void |
|
71 MarkParser(JSTracer *trc, AutoGCRooter *parser); |
|
72 |
|
73 } /* namespace frontend */ |
|
74 } /* namespace js */ |
|
75 |
|
76 #endif /* frontend_BytecodeCompiler_h */ |