Reviewers: jochen,
Description:
Put getter functions on Script line-endings objects
This is a step towards having Blink no longer look directly at the
line endings array. That prevented
https://codereview.chromium.org/1137683003/
from landing. Next step, after the roll, will be using these
functions in Blink.
[email protected]
BUG=
Please review this at https://codereview.chromium.org/1213783002/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+22, -3 lines):
M src/messages.js
M test/cctest/test-debug.cc
Index: src/messages.js
diff --git a/src/messages.js b/src/messages.js
index
5cd10563242ab1e9ec1ba7b51f06e5bf9208cc2d..d7ca7cd6479bd85bbdecf3647dc941ae4c9460a1
100644
--- a/src/messages.js
+++ b/src/messages.js
@@ -396,6 +396,16 @@ function ScriptLineCount() {
/**
+ * Returns the position of the nth line end.
+ * @return {number}
+ * Zero-based position of the nth line end in the script.
+ */
+function ScriptLineEnd(n) {
+ return this.line_ends[n];
+}
+
+
+/**
* If sourceURL comment is available returns sourceURL comment contents.
* Otherwise, script name is returned. See
*
http://fbug.googlecode.com/svn/branches/firebug1.1/docs/ReleaseNotes_1.1.txt
@@ -426,7 +436,8 @@ utils.SetUpLockedPrototype(Script, [
"sourceSlice", ScriptSourceSlice,
"sourceLine", ScriptSourceLine,
"lineCount", ScriptLineCount,
- "nameOrSourceURL", ScriptNameOrSourceURL
+ "nameOrSourceURL", ScriptNameOrSourceURL,
+ "lineEnd", ScriptLineEnd
]
);
Index: test/cctest/test-debug.cc
diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc
index
6ff7656f2577c837a1c8d2ae3dc8b82e82c4385b..853c9bbf145898ec4bb7d3193a498f7a7effd22f
100644
--- a/test/cctest/test-debug.cc
+++ b/test/cctest/test-debug.cc
@@ -6000,12 +6000,20 @@ TEST(DebugGetLoadedScripts) {
bool allow_natives_syntax = i::FLAG_allow_natives_syntax;
i::FLAG_allow_natives_syntax = true;
EnableDebugger();
- CompileRun(
+ v8::Local<v8::Value> result = CompileRun(
"var scripts = %DebugGetLoadedScripts();"
"var count = scripts.length;"
"for (var i = 0; i < count; ++i) {"
- " scripts[i].line_ends;"
+ " var lines = scripts[i].lineCount();"
+ " if (lines < 1) throw 'lineCount';"
+ " var last = -1;"
+ " for (var j = 0; j < lines; ++j) {"
+ " var end = scripts[i].lineEnd(j)) {"
+ " if (last >= end) throw 'lineEnd';"
+ " last = end;"
+ " }";
"}");
+ CHECK(!result.is_null());
DisableDebugger();
// Must not crash while accessing line_ends.
i::FLAG_allow_natives_syntax = allow_natives_syntax;
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.