1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef mozilla_dom_PrecompiledScript_h
7 #define mozilla_dom_PrecompiledScript_h
9 #include "mozilla/dom/BindingDeclarations.h"
10 #include "mozilla/dom/PrecompiledScriptBinding.h"
11 #include "mozilla/RefPtr.h"
13 #include "js/experimental/JSStencil.h"
14 #include "js/TypeDecls.h"
17 #include "nsCycleCollectionParticipant.h"
18 #include "nsISupports.h"
19 #include "nsWrapperCache.h"
22 class ReadOnlyCompileOptions
;
27 class PrecompiledScript
: public nsISupports
, public nsWrapperCache
{
28 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
29 NS_DECL_CYCLE_COLLECTION_SKIPPABLE_WRAPPERCACHE_CLASS(PrecompiledScript
)
31 explicit PrecompiledScript(nsISupports
* aParent
, RefPtr
<JS::Stencil
> aStencil
,
32 JS::ReadOnlyCompileOptions
& aOptions
);
34 void ExecuteInGlobal(JSContext
* aCx
, JS::Handle
<JSObject
*> aGlobal
,
35 const ExecuteInGlobalOptions
& aOptions
,
36 JS::MutableHandle
<JS::Value
> aRval
, ErrorResult
& aRv
);
38 void GetUrl(nsAString
& aUrl
);
40 bool HasReturnValue();
42 nsISupports
* GetParentObject() const { return mParent
; }
44 virtual JSObject
* WrapObject(JSContext
* aCx
,
45 JS::Handle
<JSObject
*> aGivenProto
) override
;
48 virtual ~PrecompiledScript() = default;
51 bool IsBlackForCC(bool aTracingNeeded
);
53 nsCOMPtr
<nsISupports
> mParent
;
55 RefPtr
<JS::Stencil
> mStencil
;
57 const bool mHasReturnValue
;
61 } // namespace mozilla
63 #endif // mozilla_dom_PrecompiledScript_h