Chromium Code Reviews| 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 = Script::GetPositionInfo(script, position, &info, true); |
|
Yang
2016/05/18 13:23:08
Can we pass an enum value instead of true/false? T
jgruber1
2016/05/19 08:05:24
Good point. Is there an easy way to define an enum
jgruber1
2016/05/19 08:56:01
And done, using the enum on C++ side only.
| |
| 556 // line_number is already shifted by the script_line_offset. | 556 |
| 557 int relative_line_number = line_number - script_line_offset; | 557 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 } | |
| 570 JSObject::AddProperty(stack_frame, column_key_, | 558 JSObject::AddProperty(stack_frame, column_key_, |
| 571 handle(Smi::FromInt(column_offset + 1), isolate_), | 559 handle(Smi::FromInt(info.column + 1), isolate_), |
| 572 NONE); | 560 NONE); |
| 573 } | 561 } |
| 574 JSObject::AddProperty(stack_frame, line_key_, | 562 JSObject::AddProperty(stack_frame, line_key_, |
| 575 handle(Smi::FromInt(line_number + 1), isolate_), | 563 handle(Smi::FromInt(info.line + 1), isolate_), |
| 576 NONE); | 564 NONE); |
| 577 } | 565 } |
| 578 | 566 |
| 579 if (!script_id_key_.is_null()) { | 567 if (!script_id_key_.is_null()) { |
| 580 JSObject::AddProperty(stack_frame, script_id_key_, | 568 JSObject::AddProperty(stack_frame, script_id_key_, |
| 581 handle(Smi::FromInt(script->id()), isolate_), NONE); | 569 handle(Smi::FromInt(script->id()), isolate_), NONE); |
| 582 } | 570 } |
| 583 | 571 |
| 584 if (!script_name_key_.is_null()) { | 572 if (!script_name_key_.is_null()) { |
| 585 JSObject::AddProperty(stack_frame, script_name_key_, | 573 JSObject::AddProperty(stack_frame, script_name_key_, |
| (...skipping 2476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3062 // Then check whether this scope intercepts. | 3050 // Then check whether this scope intercepts. |
| 3063 if ((flag & intercept_mask_)) { | 3051 if ((flag & intercept_mask_)) { |
| 3064 intercepted_flags_ |= flag; | 3052 intercepted_flags_ |= flag; |
| 3065 return true; | 3053 return true; |
| 3066 } | 3054 } |
| 3067 return false; | 3055 return false; |
| 3068 } | 3056 } |
| 3069 | 3057 |
| 3070 } // namespace internal | 3058 } // namespace internal |
| 3071 } // namespace v8 | 3059 } // namespace v8 |
| OLD | NEW |