• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2020 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include 'src/objects/js-objects.h'
6
7namespace error {
8
9transitioning javascript builtin AggregateErrorConstructor(
10    js-implicit context: NativeContext, target: JSFunction,
11    newTarget: JSAny)(...arguments): JSAny {
12  // 1. If NewTarget is undefined, let newTarget be the active function
13  // object, else let newTarget be NewTarget.
14  // 2. Let O be ? OrdinaryCreateFromConstructor(newTarget,
15  // "%AggregateError.prototype%", « [[ErrorData]], [[AggregateErrors]] »).
16  // 3. If _message_ is not _undefined_, then
17  //   a. Let msg be ? ToString(_message_).
18  //   b. Let msgDesc be the PropertyDescriptor { [[Value]]: _msg_,
19  //   [[Writable]]: *true*, [[Enumerable]]: *false*, [[Configurable]]: *true*
20  //   c. Perform ! DefinePropertyOrThrow(_O_, *"message"*, _msgDesc_).
21  const message: JSAny = arguments[1];
22  const options: JSAny = arguments[2];
23  const obj: JSObject = ConstructAggregateErrorHelper(
24      context, target, newTarget, message, options);
25
26  // 4. Let errorsList be ? IterableToList(errors).
27  const errors: JSAny = arguments[0];
28  const errorsList = iterator::IterableToListWithSymbolLookup(errors);
29
30  // 5. Perform ! DefinePropertyOrThrow(_O_, `"errors"`, Property Descriptor {
31  // [[Configurable]]: *true*, [[Enumerable]]: *false*, [[Writable]]: *true*,
32  // [[Value]]: ! CreateArrayFromList(_errorsList_) }).
33  SetOwnPropertyIgnoreAttributes(
34      obj, ErrorsStringConstant(), errorsList,
35      SmiConstant(PropertyAttributes::DONT_ENUM));
36
37  // 6. Return O.
38  return obj;
39}
40
41extern transitioning runtime ConstructAggregateErrorHelper(
42    Context, JSFunction, JSAny, Object, Object): JSObject;
43
44extern transitioning runtime ConstructInternalAggregateErrorHelper(
45    Context, Object): JSObject;
46}
47