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

Unified Diff: src/objects.h

Issue 1986173002: Refactor script position calculation (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove Script.line_ends Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index 0bce56c402ab7de3f98b3cf605e86f7524676a0c..47e96463e2254d0d7779a75dbc8ff84e9715fe60 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -6418,14 +6418,6 @@ class Script: public Struct {
// resource is accessible. Otherwise, always return true.
inline bool HasValidSource();
- // Convert code offset into column number.
- static int GetColumnNumber(Handle<Script> script, int code_offset);
-
- // Convert code offset into (zero-based) line number.
- // The non-handlified version does not allocate, but may be much slower.
- static int GetLineNumber(Handle<Script> script, int code_offset);
- int GetLineNumber(int code_pos);
-
static Handle<Object> GetNameOrSourceURL(Handle<Script> script);
// Set eval origin for stack trace formatting.
@@ -6438,6 +6430,33 @@ class Script: public Struct {
// Init line_ends array with source code positions of line ends.
static void InitLineEnds(Handle<Script> script);
+ // Convert code offset into column number.
+ static int GetColumnNumber(Handle<Script> script, int code_offset);
+
+ // Convert code offset into (zero-based) line number.
+ // The non-handlified version does not allocate, but may be much slower.
+ static int GetLineNumber(Handle<Script> script, int code_offset);
+ int GetLineNumber(int code_pos);
+
+ // Carries information about a source position.
+ struct PositionInfo {
+ PositionInfo() : line(-1), column(-1), line_start(-1), line_end(-1) {}
+
+ int line; // Zero-based line number.
+ int column; // Zero-based column number.
+ int line_start; // Position of first character in line.
+ int line_end; // Position of last (non-linebreak) character in line.
+ };
+
+ // Retrieves information about the given position, optionally with an offset.
+ // Returns false on failure, and otherwise writes into the given info object
+ // on success.
+ // The static version initializes the line ends array, while the instance
+ // method does not allocate but expects line ends to be initialized.
+ static bool GetPositionInfo(Handle<Script> script, int position,
+ PositionInfo* info, bool with_offset);
+ bool GetPositionInfo(int position, PositionInfo* info, bool with_offset);
+
// Get the JS object wrapping the given script; create it if none exists.
static Handle<JSObject> GetWrapper(Handle<Script> script);

Powered by Google App Engine
This is Rietveld 408576698