Commit 79aae815 authored by sgjesse@chromium.org's avatar sgjesse@chromium.org

During the refactoring in r1461 and adding of script ids in r1468 the...

During the refactoring in r1461 and adding of script ids in r1468 the propagation of a boolean flag was missing. This caused the line numbers retreived through ScriptMirror objects to ignore the resource line offset information in the script.

Added an explicit false parameter where the parameter was previously left out.

Added a test case for this.


Review URL: http://codereview.chromium.org/43130

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1499 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent c7f24589
......@@ -521,7 +521,7 @@ Debug.setBreakPoint = function(func, opt_line, opt_column, opt_condition) {
source_position += %FunctionGetScriptSourcePosition(func);
// Find line and column for the position in the script and set a script
// break point from that.
var location = script.locationFromPosition(source_position);
var location = script.locationFromPosition(source_position, false);
return this.setScriptBreakPointById(script.id,
location.line, location.column,
opt_condition);
......
......@@ -302,7 +302,7 @@ Script.prototype.locationFromLine = function (opt_line, opt_column, opt_offset_p
var offset_position = opt_offset_position || 0;
if (line < 0 || column < 0 || offset_position < 0) return null;
if (line == 0) {
return this.locationFromPosition(offset_position + column);
return this.locationFromPosition(offset_position + column, false);
} else {
// Find the line where the offset position is located
var lineCount = this.lineCount();
......@@ -519,7 +519,7 @@ SourceSlice.prototype.sourceText = function () {
// Returns the offset of the given position within the containing
// line.
function GetPositionInLine(message) {
var location = message.script.locationFromPosition(message.startPos);
var location = message.script.locationFromPosition(message.startPos, false);
if (location == null) return -1;
location.restrict();
return message.startPos - location.start;
......
......@@ -1592,8 +1592,9 @@ ScriptMirror.prototype.lineCount = function() {
};
ScriptMirror.prototype.locationFromPosition = function(position) {
return this.script_.locationFromPosition(position);
ScriptMirror.prototype.locationFromPosition = function(
position, include_resource_offset) {
return this.script_.locationFromPosition(position, include_resource_offset);
}
......
......@@ -3720,6 +3720,17 @@ TEST(CallFunctionInDebugger) {
// Test that a function with closure can be run in the debugger.
v8::Script::Compile(v8::String::New("CheckClosure()"))->Run();
// Test that the source line is correct when there is a line offset.
v8::ScriptOrigin origin(v8::String::New("test"),
v8::Integer::New(7));
v8::Script::Compile(v8::String::New("CheckSourceLine(7)"), &origin)->Run();
v8::Script::Compile(v8::String::New("function f() {\n"
" CheckSourceLine(8)\n"
" CheckSourceLine(9)\n"
" CheckSourceLine(10)\n"
"}; f()"), &origin)->Run();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment