Chromium Code Reviews| Index: src/inspector/wasm-translation.h |
| diff --git a/src/inspector/wasm-translation.h b/src/inspector/wasm-translation.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..10c2a481a36b6886e399b569f9f36550fbd849b8 |
| --- /dev/null |
| +++ b/src/inspector/wasm-translation.h |
| @@ -0,0 +1,71 @@ |
| +// Copyright 2016 the V8 project authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef V8_INSPECTOR_WASMTRANSLATION_H_ |
| +#define V8_INSPECTOR_WASMTRANSLATION_H_ |
| + |
| +#include <unordered_map> |
| + |
| +#include "include/v8.h" |
| +#include "src/base/macros.h" |
| +#include "src/inspector/string-16.h" |
| + |
| +namespace v8_inspector { |
| + |
| +// Forward declarations. |
| +class V8DebuggerAgentImpl; |
| +class V8DebuggerScript; |
| +struct ScriptBreakpoint; |
| +namespace protocol { |
| +namespace Debugger { |
| +class Location; |
| +} |
| +} |
| + |
| +class WasmTranslation { |
| + public: |
| + enum Mode { Raw, Disassemble }; |
| + |
| + WasmTranslation(v8::Isolate* isolate, V8DebuggerAgentImpl* debugger); |
| + ~WasmTranslation(); |
| + |
| + void SetMode(Mode mode) { mode_ = mode; } |
| + |
| + void AddScript(v8::Local<v8::Object> script_wrapper); |
| + |
| + void Clear(); |
| + |
| + // Translate a protocol-location to artificial wasm scripts. Does nothing for |
| + // non-wasm locations. Returns true if the location was translated, false |
| + // otherwise. |
| + bool Translate(protocol::Debugger::Location* location); |
|
titzer
2016/11/16 14:23:59
Should this be AddTranslation()?
From what I can
Clemens Hammacher
2016/11/16 15:21:19
Updated the documentation and renamed as discussed
|
| + |
| + // Translate raw data to wasm scripts. Line and column are 0-based. |
| + // Does nothing for non-wasm locations. Returns true if the location was |
| + // translated, false otherwise. |
| + bool Translate(String16* script_id, int* line_number, int* column_number); |
| + |
| + // Translate a breakpoint location back from artificial wasm scripts to the |
| + // underlying original script. |
| + // Returns true if the translation was translated, false otherwise. |
| + bool TranslateBack(ScriptBreakpoint* breakpoint); |
|
titzer
2016/11/16 14:23:59
Can you name this method closer to what the commen
Clemens Hammacher
2016/11/16 15:21:19
Changed as discussed offline.
|
| + |
| + private: |
| + class TranslatorImpl; |
| + friend class TranslatorImpl; |
| + |
| + void AddFakeScript(std::unique_ptr<V8DebuggerScript> fake_script, |
| + TranslatorImpl* translator); |
| + |
| + v8::Isolate* isolate_; |
| + V8DebuggerAgentImpl* debugger_agent_; |
| + std::unordered_map<int, std::unique_ptr<TranslatorImpl>> wasm_translators_; |
| + std::unordered_map<String16, TranslatorImpl*> fake_scripts_; |
| + Mode mode_; |
| + DISALLOW_COPY_AND_ASSIGN(WasmTranslation); |
| +}; |
| + |
| +} // namespace v8_inspector |
| + |
| +#endif // V8_INSPECTOR_WASMTRANSLATION_H_ |