1 | /* |
2 | * Copyright (C) 1999-2001 Harri Porten ([email protected]) |
3 | * Copyright (C) 2001 Peter Kelly ([email protected]) |
4 | * Copyright (C) 2003-2019 Apple Inc. All rights reserved. |
5 | * |
6 | * This library is free software; you can redistribute it and/or |
7 | * modify it under the terms of the GNU Library General Public |
8 | * License as published by the Free Software Foundation; either |
9 | * version 2 of the License, or (at your option) any later version. |
10 | * |
11 | * This library is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | * Library General Public License for more details. |
15 | * |
16 | * You should have received a copy of the GNU Library General Public License |
17 | * along with this library; see the file COPYING.LIB. If not, write to |
18 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 | * Boston, MA 02110-1301, USA. |
20 | * |
21 | */ |
22 | |
23 | #pragma once |
24 | |
25 | #include "CallData.h" |
26 | #include "JSCJSValue.h" |
27 | #include <wtf/FileSystem.h> |
28 | #include <wtf/NakedPtr.h> |
29 | |
30 | namespace JSC { |
31 | |
32 | class BytecodeCacheError; |
33 | class CachedBytecode; |
34 | class CallFrame; |
35 | class Exception; |
36 | class JSObject; |
37 | class ParserError; |
38 | class SourceCode; |
39 | class Symbol; |
40 | class VM; |
41 | class JSInternalPromise; |
42 | |
43 | JS_EXPORT_PRIVATE bool checkSyntax(VM&, const SourceCode&, ParserError&); |
44 | JS_EXPORT_PRIVATE bool checkSyntax(JSGlobalObject*, const SourceCode&, JSValue* exception = 0); |
45 | JS_EXPORT_PRIVATE bool checkModuleSyntax(JSGlobalObject*, const SourceCode&, ParserError&); |
46 | |
47 | JS_EXPORT_PRIVATE RefPtr<CachedBytecode> generateProgramBytecode(VM&, const SourceCode&, FileSystem::PlatformFileHandle fd, BytecodeCacheError&); |
48 | JS_EXPORT_PRIVATE RefPtr<CachedBytecode> generateModuleBytecode(VM&, const SourceCode&, FileSystem::PlatformFileHandle fd, BytecodeCacheError&); |
49 | |
50 | JS_EXPORT_PRIVATE JSValue evaluate(JSGlobalObject*, const SourceCode&, JSValue thisValue, NakedPtr<Exception>& returnedException); |
51 | inline JSValue evaluate(JSGlobalObject* globalObject, const SourceCode& sourceCode, JSValue thisValue = JSValue()) |
52 | { |
53 | NakedPtr<Exception> unused; |
54 | return evaluate(globalObject, sourceCode, thisValue, unused); |
55 | } |
56 | |
57 | JS_EXPORT_PRIVATE JSValue profiledEvaluate(JSGlobalObject*, ProfilingReason, const SourceCode&, JSValue thisValue, NakedPtr<Exception>& returnedException); |
58 | inline JSValue profiledEvaluate(JSGlobalObject* globalObject, ProfilingReason reason, const SourceCode& sourceCode, JSValue thisValue = JSValue()) |
59 | { |
60 | NakedPtr<Exception> unused; |
61 | return profiledEvaluate(globalObject, reason, sourceCode, thisValue, unused); |
62 | } |
63 | |
64 | JS_EXPORT_PRIVATE JSValue evaluateWithScopeExtension(JSGlobalObject*, const SourceCode&, JSObject* scopeExtension, NakedPtr<Exception>& returnedException); |
65 | |
66 | // Load the module source and evaluate it. |
67 | JS_EXPORT_PRIVATE JSInternalPromise* loadAndEvaluateModule(JSGlobalObject*, Symbol* moduleId, JSValue parameters, JSValue scriptFetcher); |
68 | JS_EXPORT_PRIVATE JSInternalPromise* loadAndEvaluateModule(JSGlobalObject*, const String& moduleName, JSValue parameters, JSValue scriptFetcher); |
69 | JS_EXPORT_PRIVATE JSInternalPromise* loadAndEvaluateModule(JSGlobalObject*, const SourceCode&, JSValue scriptFetcher); |
70 | |
71 | // Fetch the module source, and instantiate the module record. |
72 | JS_EXPORT_PRIVATE JSInternalPromise* loadModule(JSGlobalObject*, const String& moduleName, JSValue parameters, JSValue scriptFetcher); |
73 | JS_EXPORT_PRIVATE JSInternalPromise* loadModule(JSGlobalObject*, const SourceCode&, JSValue scriptFetcher); |
74 | |
75 | // Link and evaluate the already linked module. This function is called in a sync manner. |
76 | JS_EXPORT_PRIVATE JSValue linkAndEvaluateModule(JSGlobalObject*, const Identifier& moduleKey, JSValue scriptFetcher); |
77 | |
78 | JS_EXPORT_PRIVATE JSInternalPromise* importModule(JSGlobalObject*, const Identifier& moduleKey, JSValue parameters, JSValue scriptFetcher); |
79 | |
80 | } // namespace JSC |
81 | |