OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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/messages.h" | 5 #include "src/messages.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "src/api.h" | 9 #include "src/api.h" |
10 #include "src/execution.h" | 10 #include "src/execution.h" |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 } | 364 } |
365 | 365 |
366 } // namespace | 366 } // namespace |
367 | 367 |
368 Handle<Object> JSStackFrame::GetScriptNameOrSourceUrl() { | 368 Handle<Object> JSStackFrame::GetScriptNameOrSourceUrl() { |
369 if (!HasScript()) return isolate_->factory()->null_value(); | 369 if (!HasScript()) return isolate_->factory()->null_value(); |
370 return ScriptNameOrSourceUrl(GetScript(), isolate_); | 370 return ScriptNameOrSourceUrl(GetScript(), isolate_); |
371 } | 371 } |
372 | 372 |
373 Handle<Object> JSStackFrame::GetMethodName() { | 373 Handle<Object> JSStackFrame::GetMethodName() { |
374 if (receiver_->IsNull(isolate_) || receiver_->IsUndefined(isolate_)) { | 374 if (receiver_->IsNullOrUndefined(isolate_)) { |
375 return isolate_->factory()->null_value(); | 375 return isolate_->factory()->null_value(); |
376 } | 376 } |
377 | 377 |
378 Handle<JSReceiver> receiver = | 378 Handle<JSReceiver> receiver = |
379 Object::ToObject(isolate_, receiver_).ToHandleChecked(); | 379 Object::ToObject(isolate_, receiver_).ToHandleChecked(); |
380 if (!receiver->IsJSObject()) { | 380 if (!receiver->IsJSObject()) { |
381 return isolate_->factory()->null_value(); | 381 return isolate_->factory()->null_value(); |
382 } | 382 } |
383 | 383 |
384 Handle<JSObject> obj = Handle<JSObject>::cast(receiver); | 384 Handle<JSObject> obj = Handle<JSObject>::cast(receiver); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 } | 421 } |
422 | 422 |
423 if (!result.is_null()) return outer_scope.CloseAndEscape(result); | 423 if (!result.is_null()) return outer_scope.CloseAndEscape(result); |
424 return isolate_->factory()->null_value(); | 424 return isolate_->factory()->null_value(); |
425 } | 425 } |
426 | 426 |
427 Handle<Object> JSStackFrame::GetTypeName() { | 427 Handle<Object> JSStackFrame::GetTypeName() { |
428 // TODO(jgruber): Check for strict/constructor here as in | 428 // TODO(jgruber): Check for strict/constructor here as in |
429 // CallSitePrototypeGetThis. | 429 // CallSitePrototypeGetThis. |
430 | 430 |
431 if (receiver_->IsNull(isolate_) || receiver_->IsUndefined(isolate_)) | 431 if (receiver_->IsNullOrUndefined(isolate_)) |
432 return isolate_->factory()->null_value(); | 432 return isolate_->factory()->null_value(); |
433 | 433 |
434 if (receiver_->IsJSProxy()) return isolate_->factory()->Proxy_string(); | 434 if (receiver_->IsJSProxy()) return isolate_->factory()->Proxy_string(); |
435 | 435 |
436 Handle<JSReceiver> receiver_object = | 436 Handle<JSReceiver> receiver_object = |
437 Object::ToObject(isolate_, receiver_).ToHandleChecked(); | 437 Object::ToObject(isolate_, receiver_).ToHandleChecked(); |
438 return JSReceiver::GetConstructorName(receiver_object); | 438 return JSReceiver::GetConstructorName(receiver_object); |
439 } | 439 } |
440 | 440 |
441 int JSStackFrame::GetLineNumber() { | 441 int JSStackFrame::GetLineNumber() { |
442 DCHECK_LE(0, GetPosition()); | 442 DCHECK_LE(0, GetPosition()); |
443 if (HasScript()) return Script::GetLineNumber(GetScript(), GetPosition()) + 1; | 443 if (HasScript()) return Script::GetLineNumber(GetScript(), GetPosition()) + 1; |
444 return -1; | 444 return -1; |
445 } | 445 } |
446 | 446 |
447 int JSStackFrame::GetColumnNumber() { | 447 int JSStackFrame::GetColumnNumber() { |
448 DCHECK_LE(0, GetPosition()); | 448 DCHECK_LE(0, GetPosition()); |
449 if (HasScript()) { | 449 if (HasScript()) { |
450 return Script::GetColumnNumber(GetScript(), GetPosition()) + 1; | 450 return Script::GetColumnNumber(GetScript(), GetPosition()) + 1; |
451 } | 451 } |
452 return -1; | 452 return -1; |
453 } | 453 } |
454 | 454 |
455 bool JSStackFrame::IsNative() { | 455 bool JSStackFrame::IsNative() { |
456 return HasScript() && GetScript()->type() == Script::TYPE_NATIVE; | 456 return HasScript() && GetScript()->type() == Script::TYPE_NATIVE; |
457 } | 457 } |
458 | 458 |
459 bool JSStackFrame::IsToplevel() { | 459 bool JSStackFrame::IsToplevel() { |
460 return receiver_->IsJSGlobalProxy() || receiver_->IsNull(isolate_) || | 460 return receiver_->IsJSGlobalProxy() || receiver_->IsNullOrUndefined(isolate_); |
461 receiver_->IsUndefined(isolate_); | |
462 } | 461 } |
463 | 462 |
464 bool JSStackFrame::IsConstructor() { | 463 bool JSStackFrame::IsConstructor() { |
465 if (force_constructor_) return true; | 464 if (force_constructor_) return true; |
466 if (!receiver_->IsJSObject()) return false; | 465 if (!receiver_->IsJSObject()) return false; |
467 Handle<Object> constructor = | 466 Handle<Object> constructor = |
468 JSReceiver::GetDataProperty(Handle<JSObject>::cast(receiver_), | 467 JSReceiver::GetDataProperty(Handle<JSObject>::cast(receiver_), |
469 isolate_->factory()->constructor_string()); | 468 isolate_->factory()->constructor_string()); |
470 return constructor.is_identical_to(function_); | 469 return constructor.is_identical_to(function_); |
471 } | 470 } |
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1231 DCHECK(mode != SKIP_UNTIL_SEEN); | 1230 DCHECK(mode != SKIP_UNTIL_SEEN); |
1232 | 1231 |
1233 Handle<Object> no_caller; | 1232 Handle<Object> no_caller; |
1234 Handle<String> msg = FormatMessage(isolate, template_index, arg0, arg1, arg2); | 1233 Handle<String> msg = FormatMessage(isolate, template_index, arg0, arg1, arg2); |
1235 return ErrorUtils::Construct(isolate, constructor, constructor, msg, mode, | 1234 return ErrorUtils::Construct(isolate, constructor, constructor, msg, mode, |
1236 no_caller, false); | 1235 no_caller, false); |
1237 } | 1236 } |
1238 | 1237 |
1239 } // namespace internal | 1238 } // namespace internal |
1240 } // namespace v8 | 1239 } // namespace v8 |
OLD | NEW |