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

Side by Side Diff: src/js/messages.js

Issue 2224973002: Move remaining Message functions to C++ (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 4 years, 4 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/js/macros.py ('k') | src/objects.h » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 // ------------------------------------------------------------------- 5 // -------------------------------------------------------------------
6 6
7 (function(global, utils) { 7 (function(global, utils) {
8 8
9 %CheckIsBootstrapping(); 9 %CheckIsBootstrapping();
10 10
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 "source_url", 66 "source_url",
67 "source_mapping_url", 67 "source_mapping_url",
68 "line_offset", 68 "line_offset",
69 "column_offset" 69 "column_offset"
70 ], [ 70 ], [
71 "locationFromPosition", ScriptLocationFromPosition, 71 "locationFromPosition", ScriptLocationFromPosition,
72 "nameOrSourceURL", ScriptNameOrSourceURL, 72 "nameOrSourceURL", ScriptNameOrSourceURL,
73 ] 73 ]
74 ); 74 );
75 75
76 // -------------------------------------------------------------------
77 // Message
78
79 function GetLineNumber(message) {
80 var start_position = %MessageGetStartPosition(message);
81 if (start_position == -1) return kNoLineNumberInfo;
82 var script = %MessageGetScript(message);
83 var location = script.locationFromPosition(start_position, true);
84 if (location == null) return kNoLineNumberInfo;
85 return location.line + 1;
86 }
87
88
89 //Returns the offset of the given position within the containing line.
90 function GetColumnNumber(message) {
91 var script = %MessageGetScript(message);
92 var start_position = %MessageGetStartPosition(message);
93 var location = script.locationFromPosition(start_position, true);
94 if (location == null) return -1;
95 return location.column;
96 }
97
98
99 // Returns the source code line containing the given source
100 // position, or the empty string if the position is invalid.
101 function GetSourceLine(message) {
102 var script = %MessageGetScript(message);
103 var start_position = %MessageGetStartPosition(message);
104 var location = script.locationFromPosition(start_position, true);
105 if (location == null) return "";
106 return location.sourceText;
107 }
108
109 %InstallToContext([
110 "message_get_column_number", GetColumnNumber,
111 "message_get_line_number", GetLineNumber,
112 "message_get_source_line", GetSourceLine,
113 ]);
114
115 }); 76 });
OLDNEW
« no previous file with comments | « src/js/macros.py ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698