Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/objects/js-aggregate-error.tq')
-rw-r--r--deps/v8/src/objects/js-aggregate-error.tq81
1 files changed, 81 insertions, 0 deletions
diff --git a/deps/v8/src/objects/js-aggregate-error.tq b/deps/v8/src/objects/js-aggregate-error.tq
new file mode 100644
index 00000000000..efa416e9fb4
--- /dev/null
+++ b/deps/v8/src/objects/js-aggregate-error.tq
@@ -0,0 +1,81 @@
+// Copyright 2020 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include 'src/objects/js-aggregate-error.h'
+
+@generateCppClass
+extern class JSAggregateError extends JSObject {
+ // Only Undefined during AggregateError object creation. In order to make the
+ // field type FixedArray, we'd need to initialize it in ErrorUtils::Construct
+ // (after it, it's too late) which we don't want.
+ errors: FixedArray|Undefined;
+}
+
+namespace error {
+
+transitioning javascript builtin AggregateErrorConstructor(
+ js-implicit context: NativeContext, target: JSFunction,
+ newTarget: JSAny)(...arguments): JSAny {
+ // This function is implementing the spec as suggested by
+ // https://github.com/tc39/proposal-promise-any/pull/59 . FIXME(marja):
+ // change this if the PR is declined.
+
+ // 1. If NewTarget is undefined, let newTarget be the active function
+ // object, else let newTarget be NewTarget.
+ // 2. Let O be ? OrdinaryCreateFromConstructor(newTarget,
+ // "%AggregateError.prototype%", « [[ErrorData]], [[AggregateErrors]] »).
+ // 3. If _message_ is not _undefined_, then
+ // a. Let msg be ? ToString(_message_).
+ // b. Let msgDesc be the PropertyDescriptor { [[Value]]: _msg_,
+ // [[Writable]]: *true*, [[Enumerable]]: *false*, [[Configurable]]: *true*
+ // c. Perform ! DefinePropertyOrThrow(_O_, *"message"*, _msgDesc_).
+ const message: JSAny = arguments[1];
+ const obj: JSAggregateError =
+ ConstructAggregateErrorHelper(context, target, newTarget, message);
+
+ // 4. Let errorsList be ? IterableToList(errors).
+ const errors: JSAny = arguments[0];
+ const errorsArray =
+ iterator::IterableToFixedArrayWithSymbolLookupSlow(errors);
+ // errorsArray must be marked copy-on-write, since the "errors" getter
+ // creates a thin JSArray wrapper around it.
+ MakeFixedArrayCOW(errorsArray);
+
+ // 5. Set O.[[AggregateErrors]] to errorsList.
+ obj.errors = errorsArray;
+
+ // 6. Return O.
+ return obj;
+}
+
+transitioning javascript builtin AggregateErrorPrototypeErrorsGetter(
+ js-implicit context: NativeContext, receiver: JSAny)(): JSAny {
+ // 1. Let E be the this value.
+ // 2. If Type(E) is not Object, throw a TypeError exception.
+ // 3. If E does not have an [[ErrorData]] internal slot, throw a TypeError
+ // exception.
+ // 4. If E does not have an [[AggregateErrors]] internal slot, throw a
+ // TypeError exception.
+ // 5. Return ! CreateArrayFromList(E.[[AggregateErrors]]).
+ typeswitch (receiver) {
+ case (receiver: JSAggregateError): {
+ return array::CreateJSArrayWithElements(
+ UnsafeCast<FixedArray>(receiver.errors));
+ }
+ case (Object): {
+ ThrowTypeError(
+ MessageTemplate::kNotGeneric, 'JSAggregateError.prototype.errors.get',
+ 'AggregateError');
+ }
+ }
+}
+
+extern runtime ConstructAggregateErrorHelper(
+ Context, JSFunction, JSAny, Object): JSAggregateError;
+
+extern runtime ConstructInternalAggregateErrorHelper(
+ Context, Object): JSAggregateError;
+
+extern macro MakeFixedArrayCOW(FixedArray);
+}