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 int script_line_offset = script->line_offset(); | 554 Script::PositionInfo info; |
555 int line_number = Script::GetLineNumber(script, position); | 555 bool valid_pos = |
556 // line_number is already shifted by the script_line_offset. | 556 script->GetPositionInfo(position, &info, Script::WITH_OFFSET); |
557 int relative_line_number = line_number - script_line_offset; | 557 |
558 if (!column_key_.is_null() && relative_line_number >= 0) { | 558 if (!column_key_.is_null() && valid_pos) { |
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 } | |
570 JSObject::AddProperty(stack_frame, column_key_, | 559 JSObject::AddProperty(stack_frame, column_key_, |
571 handle(Smi::FromInt(column_offset + 1), isolate_), | 560 handle(Smi::FromInt(info.column + 1), isolate_), |
572 NONE); | 561 NONE); |
573 } | 562 } |
574 JSObject::AddProperty(stack_frame, line_key_, | 563 JSObject::AddProperty(stack_frame, line_key_, |
575 handle(Smi::FromInt(line_number + 1), isolate_), | 564 handle(Smi::FromInt(info.line + 1), isolate_), |
576 NONE); | 565 NONE); |
577 } | 566 } |
578 | 567 |
579 if (!script_id_key_.is_null()) { | 568 if (!script_id_key_.is_null()) { |
580 JSObject::AddProperty(stack_frame, script_id_key_, | 569 JSObject::AddProperty(stack_frame, script_id_key_, |
581 handle(Smi::FromInt(script->id()), isolate_), NONE); | 570 handle(Smi::FromInt(script->id()), isolate_), NONE); |
582 } | 571 } |
583 | 572 |
584 if (!script_name_key_.is_null()) { | 573 if (!script_name_key_.is_null()) { |
585 JSObject::AddProperty(stack_frame, script_name_key_, | 574 JSObject::AddProperty(stack_frame, script_name_key_, |
(...skipping 2489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3075 // Then check whether this scope intercepts. | 3064 // Then check whether this scope intercepts. |
3076 if ((flag & intercept_mask_)) { | 3065 if ((flag & intercept_mask_)) { |
3077 intercepted_flags_ |= flag; | 3066 intercepted_flags_ |= flag; |
3078 return true; | 3067 return true; |
3079 } | 3068 } |
3080 return false; | 3069 return false; |
3081 } | 3070 } |
3082 | 3071 |
3083 } // namespace internal | 3072 } // namespace internal |
3084 } // namespace v8 | 3073 } // namespace v8 |
OLD | NEW |