| OLD | NEW |
| 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 #include "src/isolate.h" | 5 #include "src/isolate.h" |
| 6 | 6 |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 | 8 |
| 9 #include <fstream> // NOLINT(readability/streams) | 9 #include <fstream> // NOLINT(readability/streams) |
| 10 #include <sstream> | 10 #include <sstream> |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 summ.is_constructor()); | 544 summ.is_constructor()); |
| 545 } | 545 } |
| 546 | 546 |
| 547 Handle<JSObject> NewStackFrameObject(Handle<JSFunction> fun, int position, | 547 Handle<JSObject> NewStackFrameObject(Handle<JSFunction> fun, int position, |
| 548 bool is_constructor) { | 548 bool is_constructor) { |
| 549 Handle<JSObject> stack_frame = | 549 Handle<JSObject> stack_frame = |
| 550 factory()->NewJSObject(isolate_->object_function()); | 550 factory()->NewJSObject(isolate_->object_function()); |
| 551 Handle<Script> script(Script::cast(fun->shared()->script())); | 551 Handle<Script> script(Script::cast(fun->shared()->script())); |
| 552 | 552 |
| 553 if (!line_key_.is_null()) { | 553 if (!line_key_.is_null()) { |
| 554 Script::PositionInfo info; | 554 int script_line_offset = script->line_offset(); |
| 555 bool valid_pos = | 555 int line_number = Script::GetLineNumber(script, position); |
| 556 script->GetPositionInfo(position, &info, Script::WITH_OFFSET); | 556 // line_number is already shifted by the script_line_offset. |
| 557 | 557 int relative_line_number = line_number - script_line_offset; |
| 558 if (!column_key_.is_null() && valid_pos) { | 558 if (!column_key_.is_null() && relative_line_number >= 0) { |
| 559 Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends())); |
| 560 int start = |
| 561 (relative_line_number == 0) |
| 562 ? 0 |
| 563 : Smi::cast(line_ends->get(relative_line_number - 1))->value() + |
| 564 1; |
| 565 int column_offset = position - start; |
| 566 if (relative_line_number == 0) { |
| 567 // For the case where the code is on the same line as the script tag. |
| 568 column_offset += script->column_offset(); |
| 569 } |
| 559 JSObject::AddProperty(stack_frame, column_key_, | 570 JSObject::AddProperty(stack_frame, column_key_, |
| 560 handle(Smi::FromInt(info.column + 1), isolate_), | 571 handle(Smi::FromInt(column_offset + 1), isolate_), |
| 561 NONE); | 572 NONE); |
| 562 } | 573 } |
| 563 JSObject::AddProperty(stack_frame, line_key_, | 574 JSObject::AddProperty(stack_frame, line_key_, |
| 564 handle(Smi::FromInt(info.line + 1), isolate_), | 575 handle(Smi::FromInt(line_number + 1), isolate_), |
| 565 NONE); | 576 NONE); |
| 566 } | 577 } |
| 567 | 578 |
| 568 if (!script_id_key_.is_null()) { | 579 if (!script_id_key_.is_null()) { |
| 569 JSObject::AddProperty(stack_frame, script_id_key_, | 580 JSObject::AddProperty(stack_frame, script_id_key_, |
| 570 handle(Smi::FromInt(script->id()), isolate_), NONE); | 581 handle(Smi::FromInt(script->id()), isolate_), NONE); |
| 571 } | 582 } |
| 572 | 583 |
| 573 if (!script_name_key_.is_null()) { | 584 if (!script_name_key_.is_null()) { |
| 574 JSObject::AddProperty(stack_frame, script_name_key_, | 585 JSObject::AddProperty(stack_frame, script_name_key_, |
| (...skipping 2476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3051 // Then check whether this scope intercepts. | 3062 // Then check whether this scope intercepts. |
| 3052 if ((flag & intercept_mask_)) { | 3063 if ((flag & intercept_mask_)) { |
| 3053 intercepted_flags_ |= flag; | 3064 intercepted_flags_ |= flag; |
| 3054 return true; | 3065 return true; |
| 3055 } | 3066 } |
| 3056 return false; | 3067 return false; |
| 3057 } | 3068 } |
| 3058 | 3069 |
| 3059 } // namespace internal | 3070 } // namespace internal |
| 3060 } // namespace v8 | 3071 } // namespace v8 |
| OLD | NEW |