• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef ECMASCRIPT_DEBUGGER_HOT_RELOAD_MANAGER_H
17 #define ECMASCRIPT_DEBUGGER_HOT_RELOAD_MANAGER_H
18 
19 #include "ecmascript/jspandafile/js_pandafile.h"
20 #include "ecmascript/jspandafile/debug_info_extractor.h"
21 
22 namespace panda::ecmascript::tooling {
23 class HotReloadManager {
24 public:
HotReloadManager(const EcmaVM * vm)25     explicit HotReloadManager(const EcmaVM *vm) : vm_(vm) {}
26     ~HotReloadManager() = default;
27 
28     NO_COPY_SEMANTIC(HotReloadManager);
29     NO_MOVE_SEMANTIC(HotReloadManager);
30 
31     void NotifyPatchLoaded(const JSPandaFile *baseFile, const JSPandaFile *patchFile);
32     void NotifyPatchUnloaded(const JSPandaFile *patchFile);
33 
34     DebugInfoExtractor *GetPatchExtractor(const std::string &url) const;
35     const JSPandaFile *GetBaseJSPandaFile(const JSPandaFile *jsPandaFile) const;
36 
37 private:
38     void ExtractPatch(const JSPandaFile *jsPandaFile);
39 
40     const EcmaVM *vm_;
41     CUnorderedMap<const JSPandaFile *, const JSPandaFile *> baseJSPandaFiles_ {};
42     CUnorderedMap<std::string, DebugInfoExtractor *> patchExtractors_ {};
43 };
44 }  // namespace panda::ecmascript::tooling
45 #endif  // ECMASCRIPT_DEBUGGER_HOT_RELOAD_MANAGER_H
46