Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(592)

Side by Side Diff: src/inspector/v8-debugger-script.cc

Issue 2663973002: [inspector] added experimental is_module flag for script parsed events (Closed)
Patch Set: rebased Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/inspector/v8-debugger-script.h ('k') | test/inspector/debugger/es6-module-script-parsed.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/inspector/v8-debugger-script.h" 5 #include "src/inspector/v8-debugger-script.h"
6 6
7 #include "src/inspector/inspected-context.h" 7 #include "src/inspector/inspected-context.h"
8 #include "src/inspector/string-util.h" 8 #include "src/inspector/string-util.h"
9 #include "src/inspector/wasm-translation.h" 9 #include "src/inspector/wasm-translation.h"
10 10
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 if (script->Source().ToLocal(&tmp)) { 135 if (script->Source().ToLocal(&tmp)) {
136 m_sourceObj.Reset(m_isolate, tmp); 136 m_sourceObj.Reset(m_isolate, tmp);
137 String16 source = toProtocolString(tmp); 137 String16 source = toProtocolString(tmp);
138 // V8 will not count last line if script source ends with \n. 138 // V8 will not count last line if script source ends with \n.
139 if (source.length() > 1 && source[source.length() - 1] == '\n') { 139 if (source.length() > 1 && source[source.length() - 1] == '\n') {
140 m_endLine++; 140 m_endLine++;
141 m_endColumn = 0; 141 m_endColumn = 0;
142 } 142 }
143 } 143 }
144 144
145 m_isModule = script->IsModule();
146
145 m_script.Reset(m_isolate, script); 147 m_script.Reset(m_isolate, script);
146 } 148 }
147 149
148 bool isLiveEdit() const override { return m_isLiveEdit; } 150 bool isLiveEdit() const override { return m_isLiveEdit; }
151 bool isModule() const override { return m_isModule; }
149 152
150 const String16& sourceMappingURL() const override { 153 const String16& sourceMappingURL() const override {
151 return m_sourceMappingURL; 154 return m_sourceMappingURL;
152 } 155 }
153 156
154 String16 source(v8::Isolate* isolate) const override { 157 String16 source(v8::Isolate* isolate) const override {
155 if (!m_sourceObj.IsEmpty()) 158 if (!m_sourceObj.IsEmpty())
156 return toProtocolString(m_sourceObj.Get(isolate)); 159 return toProtocolString(m_sourceObj.Get(isolate));
157 return V8DebuggerScript::source(isolate); 160 return V8DebuggerScript::source(isolate);
158 } 161 }
(...skipping 25 matching lines...) Expand all
184 String16 GetNameOrSourceUrl(v8::Local<v8::debug::Script> script) { 187 String16 GetNameOrSourceUrl(v8::Local<v8::debug::Script> script) {
185 v8::Local<v8::String> name; 188 v8::Local<v8::String> name;
186 if (script->Name().ToLocal(&name) || script->SourceURL().ToLocal(&name)) 189 if (script->Name().ToLocal(&name) || script->SourceURL().ToLocal(&name))
187 return toProtocolString(name); 190 return toProtocolString(name);
188 return String16(); 191 return String16();
189 } 192 }
190 193
191 String16 m_sourceMappingURL; 194 String16 m_sourceMappingURL;
192 v8::Global<v8::String> m_sourceObj; 195 v8::Global<v8::String> m_sourceObj;
193 bool m_isLiveEdit = false; 196 bool m_isLiveEdit = false;
197 bool m_isModule = false;
194 v8::Global<v8::debug::Script> m_script; 198 v8::Global<v8::debug::Script> m_script;
195 }; 199 };
196 200
197 class WasmVirtualScript : public V8DebuggerScript { 201 class WasmVirtualScript : public V8DebuggerScript {
198 friend class V8DebuggerScript; 202 friend class V8DebuggerScript;
199 203
200 public: 204 public:
201 WasmVirtualScript(v8::Isolate* isolate, WasmTranslation* wasmTranslation, 205 WasmVirtualScript(v8::Isolate* isolate, WasmTranslation* wasmTranslation,
202 v8::Local<v8::debug::WasmScript> script, String16 id, 206 v8::Local<v8::debug::WasmScript> script, String16 id,
203 String16 url, String16 source) 207 String16 url, String16 source)
204 : V8DebuggerScript(isolate, std::move(id), std::move(url)), 208 : V8DebuggerScript(isolate, std::move(id), std::move(url)),
205 m_script(isolate, script), 209 m_script(isolate, script),
206 m_wasmTranslation(wasmTranslation) { 210 m_wasmTranslation(wasmTranslation) {
207 int num_lines = 0; 211 int num_lines = 0;
208 int last_newline = -1; 212 int last_newline = -1;
209 size_t next_newline = source.find('\n', last_newline + 1); 213 size_t next_newline = source.find('\n', last_newline + 1);
210 while (next_newline != String16::kNotFound) { 214 while (next_newline != String16::kNotFound) {
211 last_newline = static_cast<int>(next_newline); 215 last_newline = static_cast<int>(next_newline);
212 next_newline = source.find('\n', last_newline + 1); 216 next_newline = source.find('\n', last_newline + 1);
213 ++num_lines; 217 ++num_lines;
214 } 218 }
215 m_endLine = num_lines; 219 m_endLine = num_lines;
216 m_endColumn = static_cast<int>(source.length()) - last_newline - 1; 220 m_endColumn = static_cast<int>(source.length()) - last_newline - 1;
217 m_source = std::move(source); 221 m_source = std::move(source);
218 } 222 }
219 223
220 const String16& sourceMappingURL() const override { return emptyString(); } 224 const String16& sourceMappingURL() const override { return emptyString(); }
221 bool isLiveEdit() const override { return false; } 225 bool isLiveEdit() const override { return false; }
226 bool isModule() const override { return false; }
222 void setSourceMappingURL(const String16&) override {} 227 void setSourceMappingURL(const String16&) override {}
223 228
224 bool getPossibleBreakpoints( 229 bool getPossibleBreakpoints(
225 const v8::debug::Location& start, const v8::debug::Location& end, 230 const v8::debug::Location& start, const v8::debug::Location& end,
226 std::vector<v8::debug::Location>* locations) override { 231 std::vector<v8::debug::Location>* locations) override {
227 v8::HandleScope scope(m_isolate); 232 v8::HandleScope scope(m_isolate);
228 v8::Local<v8::debug::Script> script = m_script.Get(m_isolate); 233 v8::Local<v8::debug::Script> script = m_script.Get(m_isolate);
229 String16 v8ScriptId = String16::fromInteger(script->Id()); 234 String16 v8ScriptId = String16::fromInteger(script->Id());
230 235
231 v8::debug::Location translatedStart = start; 236 v8::debug::Location translatedStart = start;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 if (m_hash.isEmpty()) m_hash = calculateHash(source(isolate)); 300 if (m_hash.isEmpty()) m_hash = calculateHash(source(isolate));
296 DCHECK(!m_hash.isEmpty()); 301 DCHECK(!m_hash.isEmpty());
297 return m_hash; 302 return m_hash;
298 } 303 }
299 304
300 void V8DebuggerScript::setSourceURL(const String16& sourceURL) { 305 void V8DebuggerScript::setSourceURL(const String16& sourceURL) {
301 m_sourceURL = sourceURL; 306 m_sourceURL = sourceURL;
302 } 307 }
303 308
304 } // namespace v8_inspector 309 } // namespace v8_inspector
OLDNEW
« no previous file with comments | « src/inspector/v8-debugger-script.h ('k') | test/inspector/debugger/es6-module-script-parsed.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698