| Index: src/api.cc
|
| diff --git a/src/api.cc b/src/api.cc
|
| index be65add4b2515be163dfbef4c6442204c120681a..69fd81a758d7fb32c1e0c1296d71c3693b0ebbc9 100644
|
| --- a/src/api.cc
|
| +++ b/src/api.cc
|
| @@ -2855,9 +2855,63 @@ int StackTrace::GetFrameCount() const {
|
| return i::Smi::cast(Utils::OpenHandle(this)->length())->value();
|
| }
|
|
|
| +namespace {
|
| +i::Handle<i::JSObject> NewFrameObject(i::Isolate* isolate,
|
| + i::Handle<i::StackFrameInfo> frame) {
|
| + i::Handle<i::JSObject> frame_obj =
|
| + isolate->factory()->NewJSObject(isolate->object_function());
|
| + i::JSObject::AddProperty(
|
| + frame_obj, handle(isolate->heap()->line_string()),
|
| + handle(i::Smi::FromInt(frame->line_number() + 1), isolate), i::NONE);
|
| + i::JSObject::AddProperty(
|
| + frame_obj, handle(isolate->heap()->column_string()),
|
| + handle(i::Smi::FromInt(frame->column_number() + 1), isolate), i::NONE);
|
| + i::JSObject::AddProperty(frame_obj,
|
| + isolate->factory()->InternalizeOneByteString(
|
| + STATIC_CHAR_VECTOR("scriptId")),
|
| + handle(i::Smi::FromInt(frame->script_id()), isolate),
|
| + i::NONE);
|
| + i::JSObject::AddProperty(frame_obj,
|
| + isolate->factory()->InternalizeOneByteString(
|
| + STATIC_CHAR_VECTOR("scriptName")),
|
| + handle(frame->script_name(), isolate), i::NONE);
|
| + i::JSObject::AddProperty(frame_obj,
|
| + isolate->factory()->InternalizeOneByteString(
|
| + STATIC_CHAR_VECTOR("scriptNameOrSourceURL")),
|
| + handle(frame->script_name_or_source_url(), isolate),
|
| + i::NONE);
|
| + i::JSObject::AddProperty(frame_obj,
|
| + isolate->factory()->InternalizeOneByteString(
|
| + STATIC_CHAR_VECTOR("functionName")),
|
| + handle(frame->function_name(), isolate), i::NONE);
|
| + i::JSObject::AddProperty(frame_obj,
|
| + isolate->factory()->InternalizeOneByteString(
|
| + STATIC_CHAR_VECTOR("isEval")),
|
| + isolate->factory()->ToBoolean(frame->is_eval()),
|
| + i::NONE);
|
| + i::JSObject::AddProperty(
|
| + frame_obj,
|
| + isolate->factory()->InternalizeOneByteString(
|
| + STATIC_CHAR_VECTOR("isConstructor")),
|
| + isolate->factory()->ToBoolean(frame->is_constructor()), i::NONE);
|
| + return frame_obj;
|
| +}
|
| +} // namespace
|
|
|
| Local<Array> StackTrace::AsArray() {
|
| - return Utils::ToLocal(Utils::OpenHandle(this));
|
| + i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
|
| + i::Handle<i::JSArray> self = Utils::OpenHandle(this);
|
| + int frame_count = GetFrameCount();
|
| + i::Handle<i::FixedArray> frames =
|
| + isolate->factory()->NewFixedArray(frame_count);
|
| + for (int i = 0; i < frame_count; ++i) {
|
| + auto obj = i::JSReceiver::GetElement(isolate, self, i).ToHandleChecked();
|
| + auto frame = i::Handle<i::StackFrameInfo>::cast(obj);
|
| + i::Handle<i::JSObject> frame_obj = NewFrameObject(isolate, frame);
|
| + frames->set(i, *frame_obj);
|
| + }
|
| + return Utils::ToLocal(isolate->factory()->NewJSArrayWithElements(
|
| + frames, i::FAST_ELEMENTS, frame_count));
|
| }
|
|
|
|
|
|
|