| OLD | NEW | 
| (Empty) |  | 
 |   1 // Copyright 2016 the V8 project authors. All rights reserved. | 
 |   2 // Use of this source code is governed by a BSD-style license that can be | 
 |   3 // found in the LICENSE file. | 
 |   4  | 
 |   5 #ifndef V8_INSPECTOR_WASMTRANSLATION_H_ | 
 |   6 #define V8_INSPECTOR_WASMTRANSLATION_H_ | 
 |   7  | 
 |   8 #include <unordered_map> | 
 |   9  | 
 |  10 #include "include/v8.h" | 
 |  11 #include "src/base/macros.h" | 
 |  12 #include "src/inspector/string-16.h" | 
 |  13  | 
 |  14 namespace v8_inspector { | 
 |  15  | 
 |  16 // Forward declarations. | 
 |  17 class V8Debugger; | 
 |  18 class V8DebuggerScript; | 
 |  19 struct ScriptBreakpoint; | 
 |  20 namespace protocol { | 
 |  21 namespace Debugger { | 
 |  22 class Location; | 
 |  23 } | 
 |  24 } | 
 |  25  | 
 |  26 class WasmTranslation { | 
 |  27  public: | 
 |  28   enum Mode { Raw, Disassemble }; | 
 |  29  | 
 |  30   WasmTranslation(v8::Isolate* isolate, V8Debugger* debugger); | 
 |  31   ~WasmTranslation(); | 
 |  32  | 
 |  33   // Set translation mode. | 
 |  34   void SetMode(Mode mode) { mode_ = mode; } | 
 |  35  | 
 |  36   // Make a wasm script known to the translation. Only locations referencing a | 
 |  37   // registered script will be translated by the Translate functions below. | 
 |  38   void AddScript(v8::Local<v8::Object> script_wrapper); | 
 |  39  | 
 |  40   // Clear all registered scripts. | 
 |  41   void Clear(); | 
 |  42  | 
 |  43   // Translate a location as generated by V8 to a location that should be sent | 
 |  44   // over protocol. | 
 |  45   // Does nothing for locations referencing a script which was not registered | 
 |  46   // before via AddScript. | 
 |  47   // Line and column are 0-based. | 
 |  48   // The context group id specifies the context of the script. | 
 |  49   // If the script was registered and the respective wasm function was not seen | 
 |  50   // before, a new artificial script representing this function will be created | 
 |  51   // and made public to the frontend. | 
 |  52   // Returns true if the location was translated, false otherwise. | 
 |  53   bool TranslateWasmScriptLocationToProtocolLocation(String16* script_id, | 
 |  54                                                      int* line_number, | 
 |  55                                                      int* column_number, | 
 |  56                                                      int context_group_id); | 
 |  57  | 
 |  58   // Translate back from protocol locations (potentially referencing artificial | 
 |  59   // scripts for individual wasm functions) to locations that make sense to V8. | 
 |  60   // Does nothing if the location was not generated by the translate method | 
 |  61   // above. | 
 |  62   // Returns true if the location was translated, false otherwise. | 
 |  63   bool TranslateProtocolLocationToWasmScriptLocation(String16* script_id, | 
 |  64                                                      int* line_number, | 
 |  65                                                      int* column_number); | 
 |  66  | 
 |  67  private: | 
 |  68   class TranslatorImpl; | 
 |  69   friend class TranslatorImpl; | 
 |  70  | 
 |  71   void AddFakeScript(std::unique_ptr<V8DebuggerScript> fake_script, | 
 |  72                      TranslatorImpl* translator, int context_group_id); | 
 |  73  | 
 |  74   v8::Isolate* isolate_; | 
 |  75   V8Debugger* debugger_; | 
 |  76   std::unordered_map<int, std::unique_ptr<TranslatorImpl>> wasm_translators_; | 
 |  77   std::unordered_map<String16, TranslatorImpl*> fake_scripts_; | 
 |  78   Mode mode_; | 
 |  79  | 
 |  80   DISALLOW_COPY_AND_ASSIGN(WasmTranslation); | 
 |  81 }; | 
 |  82  | 
 |  83 }  // namespace v8_inspector | 
 |  84  | 
 |  85 #endif  // V8_INSPECTOR_WASMTRANSLATION_H_ | 
| OLD | NEW |