Chromium Code Reviews| 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 "src/api.h" | 7 #include "src/api.h" |
| 8 #include "src/bootstrapper.h" | |
| 8 #include "src/execution.h" | 9 #include "src/execution.h" |
| 9 #include "src/isolate-inl.h" | 10 #include "src/isolate-inl.h" |
| 10 #include "src/keys.h" | 11 #include "src/keys.h" |
| 11 #include "src/string-builder.h" | 12 #include "src/string-builder.h" |
| 12 #include "src/wasm/wasm-module.h" | 13 #include "src/wasm/wasm-module.h" |
| 13 | 14 |
| 14 namespace v8 { | 15 namespace v8 { |
| 15 namespace internal { | 16 namespace internal { |
| 16 | 17 |
| 17 MessageLocation::MessageLocation(Handle<Script> script, int start_pos, | 18 MessageLocation::MessageLocation(Handle<Script> script, int start_pos, |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 440 builder.AppendString(arg); | 441 builder.AppendString(arg); |
| 441 } | 442 } |
| 442 } else { | 443 } else { |
| 443 builder.AppendCharacter(*c); | 444 builder.AppendCharacter(*c); |
| 444 } | 445 } |
| 445 } | 446 } |
| 446 | 447 |
| 447 return builder.Finish(); | 448 return builder.Finish(); |
| 448 } | 449 } |
| 449 | 450 |
| 451 Object* ConstructError(Isolate* isolate, Handle<JSFunction> target, | |
|
Yang
2016/07/19 15:06:47
Let's return a MaybeHandle<Object> here.
jgruber
2016/07/20 14:48:39
Done.
| |
| 452 Handle<Object> new_target, Handle<Object> message) { | |
| 453 // 1. If NewTarget is undefined, let newTarget be the active function object, | |
| 454 // else let newTarget be NewTarget. | |
| 455 | |
| 456 Handle<JSReceiver> new_target_recv = | |
| 457 new_target->IsJSReceiver() ? Handle<JSReceiver>::cast(new_target) | |
| 458 : Handle<JSReceiver>::cast(target); | |
| 459 | |
| 460 // 2. Let O be ? OrdinaryCreateFromConstructor(newTarget, "%ErrorPrototype%", | |
| 461 // « [[ErrorData]] »). | |
| 462 Handle<JSObject> err; | |
| 463 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, err, | |
| 464 JSObject::New(target, new_target_recv)); | |
| 465 | |
| 466 // 3. If message is not undefined, then | |
| 467 // a. Let msg be ? ToString(message). | |
| 468 // b. Let msgDesc be the PropertyDescriptor{[[Value]]: msg, [[Writable]]: | |
| 469 // true, [[Enumerable]]: false, [[Configurable]]: true}. | |
| 470 // c. Perform ! DefinePropertyOrThrow(O, "message", msgDesc). | |
| 471 // 4. Return O. | |
| 472 | |
| 473 if (!message->IsUndefined(isolate)) { | |
| 474 Handle<String> msg_string; | |
| 475 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, msg_string, | |
| 476 Object::ToString(isolate, message)); | |
| 477 RETURN_FAILURE_ON_EXCEPTION( | |
| 478 isolate, | |
| 479 JSObject::SetOwnPropertyIgnoreAttributes( | |
| 480 err, isolate->factory()->message_string(), msg_string, DONT_ENUM)); | |
| 481 } | |
| 482 | |
| 483 // Capture the stack trace unless we're setting up. | |
| 484 if (!isolate->bootstrapper()->IsActive()) { | |
| 485 // Optionally capture a more detailed stack trace for the message. | |
| 486 RETURN_FAILURE_ON_EXCEPTION(isolate, | |
| 487 isolate->CaptureAndSetDetailedStackTrace(err)); | |
| 488 // Capture a simple stack trace for the stack property. | |
| 489 RETURN_FAILURE_ON_EXCEPTION(isolate, | |
| 490 isolate->CaptureAndSetSimpleStackTrace(err)); | |
| 491 } | |
| 492 | |
| 493 return *err; | |
| 494 } | |
| 450 | 495 |
| 451 } // namespace internal | 496 } // namespace internal |
| 452 } // namespace v8 | 497 } // namespace v8 |
| OLD | NEW |