diff --git a/spec.emu b/spec.emu index 804a6fe..573f927 100644 --- a/spec.emu +++ b/spec.emu @@ -62,17 +62,6 @@ contributors: Ron Buckton, Ecma International Value and Purpose - - - @@asyncDispose - - - `"Symbol.asyncDispose"` - - - A method that performs explicit resource cleanup on an object. Called by the semantics of AsyncDisposableStack objects. - - @@dispose @@ -149,17 +138,6 @@ contributors: Ron Buckton, Ecma International The prototype of Array iterator objects () - - - %AsyncDisposableStack% - - - `AsyncDisposableStack` - - - The AsyncDisposableStack constructor () - - %AsyncFromSyncIteratorPrototype% @@ -938,10 +916,10 @@ contributors: Ron Buckton, Ecma International [[Hint]] - ~sync-dispose~ or ~async-dispose~. + ~sync-dispose~. - Indicates whether the resources was added by a `using` declaration or DisposableStack object (~sync-dispose~) or an AsyncDisposableStack object (~async-dispose~). + Indicates that the resource was added by a `using` declaration or DisposableStack object. @@ -958,6 +936,9 @@ contributors: Ron Buckton, Ecma International + + Currently, the only allowed value for [[Hint]] is ~sync-dispose~. + @@ -965,7 +946,7 @@ contributors: Ron Buckton, Ecma International AddDisposableResource ( _disposable_ : an object with a [[DisposableResourceStack]] internal slot, _V_ : an ECMAScript language value, - _hint_ : either ~sync-dispose~ or ~async-dispose~, + _hint_ : ~sync-dispose~, optional _method_ : a function object, ) @@ -985,13 +966,16 @@ contributors: Ron Buckton, Ecma International 1. Append _resource_ to _disposable_.[[DisposableResourceStack]]. 1. Return NormalCompletion(~empty~). + + Currently, the only allowed value for _hint_ is ~sync-dispose~. +

CreateDisposableResource ( _V_ : an Object or *undefined*, - _hint_ : either ~sync-dispose~ or ~async-dispose~, + _hint_ : ~sync-dispose~, optional _method_ : a function object, )

@@ -1005,42 +989,44 @@ contributors: Ron Buckton, Ecma International 1. If IsCallable(_method_) is *false*, throw a *TypeError* exception. 1. Return the DisposableResource Record { [[ResourceValue]]: _V_, [[Hint]]: _hint_, [[DisposeMethod]]: _method_ }. + + Currently, the only allowed value for _hint_ is ~sync-dispose~. +

GetDisposeMethod ( _V_ : an Object, - _hint_ : either ~sync-dispose~ or ~async-dispose~, + _hint_ : ~sync-dispose~, )

- 1. If _hint_ is ~async-dispose~, then - 1. Let _method_ be ? GetMethod(_V_, @@asyncDispose). - 1. If _method_ is *undefined*, then - 1. Set _method_ to ? GetMethod(_V_, @@dispose). - 1. Else, - 1. Let _method_ be ? GetMethod(_V_, @@dispose). + 1. Let _method_ be ? GetMethod(_V_, @@dispose). 1. Return _method_. + + Currently, the only allowed value for _hint_ is ~sync-dispose~. +

Dispose ( _V_ : an Object or *undefined*, - _hint_ : either ~sync-dispose~ or ~async-dispose~, + _hint_ : ~sync-dispose~, _method_ : a function object, )

- 1. Let _result_ be ? Call(_method_, _V_). - 1. If _hint_ is ~async-dispose~ and _result_ is not *undefined*, then - 1. Perform ? Await(_result_). + 1. Perform ? Call(_method_, _V_). 1. Return *undefined*. + + Currently, the only allowed value for _hint_ is ~sync-dispose~. +
@@ -3493,36 +3479,6 @@ contributors: Ron Buckton, Ecma International - - -

The %AsyncIteratorPrototype% Object

- - - -

%AsyncIteratorPrototype% [ @@asyncDispose ] ( )

-

The following steps are taken:

- - 1. Let _O_ be the *this* value. - 1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%). - 1. Let _return_ be GetMethod(_O_, `"return"`). - 1. IfAbruptRejectPromise(_return_, _promiseCapability_). - 1. If _return_ is *undefined*, then - 1. Perform ! Call(_promiseCapability_.[[Resolve]], *undefined*, « *undefined* »). - 1. Else, - 1. Let _result_ be Call(_return_, _O_, « *undefined* »). - 1. IfAbruptRejectPromise(_result_, _promiseCapability_). - 1. Let _resultWrapper_ be Completion(PromiseResolve(%Promise%, _result_)). - 1. IfAbruptRejectPromise(_resultWrapper_, _promiseCapability_). - 1. Let _unwrap_ be a new Abstract Closure that performs the following steps when called: - 1. Return *undefined*. - 1. Let _onFulfilled_ be CreateBuiltinFunction(_unwrap_, 1, "", « »). - 1. Perform PerformPromiseThen(_resultWrapper_, _onFulfilled_, *undefined*, _promiseCapability_). - 1. Return _promiseCapability_.[[Promise]]. - -

The value of the *"name"* property of this function is *"[Symbol.asyncDispose]"*.

-
-
-
@@ -3531,7 +3487,6 @@ contributors: Ron Buckton, Ecma International

Common Resource Management Interfaces

-

An interface is a set of property keys whose associated values match a specific specification. Any object that provides all the properties as described by an interface's specification conforms to that interface. An interface is not represented by a distinct object. There may be many separately implemented objects that conform to any interface. An individual object may conform to multiple interfaces.

The Disposable Interface

@@ -3568,39 +3523,6 @@ contributors: Ron Buckton, Ecma International
- -

The AsyncDisposable Interface

-

The AsyncDisposable interface includes the property described in :

- - - - - - - - - - - - - - -
- Property - - Value - - Requirements -
- `@@asyncDispose` - - A function that returns a promise. - -

Invoking this method notifies the AsyncDisposable object that the caller does not intend to continue to use this object. This method should perform any necessary logic to perform explicit clean-up of the resource including, but not limited to, file system handles, streams, host objects, etc. When an exception is thrown from this method, it typically means that the resource could not be explicitly freed. An AsyncDisposable object is not considered "disposed" until the resulting Promise has been fulfilled.

-

If called more than once on the same object, the function should not throw an exception. However, this requirement is not enforced.

-
-
-
@@ -3803,212 +3725,6 @@ contributors: Ron Buckton, Ecma International - - -

AsyncDisposableStack Objects

-

An AsyncDisposableStack is an object that can be used to contain one or more resources that should be asynchronously disposed together.

-

Any AsyncDisposableStack object is in one of two mutually exclusive states: disposed or pending:

- - - -

The AsyncDisposableStack Constructor

-

The AsyncDisposableStack constructor:

-
    -
  • is %AsyncDisposableStack%.
  • -
  • is the initial value of the *"AsyncDisposableStack"* property of the global object.
  • -
  • creates and initializes a new AsyncDisposableStack when called as a constructor.
  • -
  • is not intended to be called as a function and will throw an exception when called in that manner.
  • -
  • may be used as the value in an `extends` clause of a class definition. Subclass constructors that intend to inherit the specified AsyncDisposableStack behaviour must include a `super` call to the AsyncDisposableStack constructor to create and initialize the subclass instance with the internal state necessary to support the `AsyncDisposableStack` and `AsyncDisposableStack.prototype` built-in methods.
  • -
- - -

AsyncDisposableStack ( )

-

When the `AsyncDisposableStack` function is called, the following steps are taken:

- - 1. If NewTarget is *undefined*, throw a *TypeError* exception. - 1. Let _asyncDisposableStack_ be ? OrdinaryCreateFromConstructor(NewTarget, *"%AsyncDisposableStack.prototype%"*, « [[AsyncDisposableState]], [[DisposableResourceStack]] »). - 1. Set _asyncDisposableStack_.[[AsyncDisposableState]] to ~pending~. - 1. Set _asyncDisposableStack_.[[DisposableResourceStack]] to a new empty List. - 1. Return _asyncDisposableStack_. - -
-
- - -

Properties of the AsyncDisposableStack Constructor

-

The AsyncDisposableStack constructor:

-
    -
  • Has a [[Prototype]] internal slot whose value is %Function.prototype%.
  • -
-
- - -

Properties of the AsyncDisposableStack Prototype Object

-

The AsyncDisposableStack prototype object:

-
    -
  • is %AsyncDisposableStack.prototype%.
  • -
  • has a [[Prototype]] internal slot whose value is %Object.prototype%.
  • -
  • is an ordinary object.
  • -
  • does not have an [[AsyncDisposableState]] internal slot or any of the other internal slots of AsyncDisposableStack instances.
  • -
- - -

get AsyncDisposableStack.prototype.disposed

-

`AsyncDisposableStack.prototype.disposed` is an accessor property whose set accessor function is *undefined*. Its get accessor function performs the following steps:

- - 1. Let _asyncDisposableStack_ be the *this* value. - 1. Perform ? RequireInternalSlot(_asyncDisposableStack_, [[AsyncDisposableState]]). - 1. If _asyncDisposableStack_.[[AsyncDisposableState]] is ~disposed~, return *true*. - 1. Otherwise, return *false*. - -
- - -

AsyncDisposableStack.prototype.disposeAsync()

-

When the `disposeAsync` method is called, the following steps are taken:

- - 1. Let _asyncDisposableStack_ be the *this* value. - 1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%). - 1. If _asyncDisposableStack_ does not have an [[AsyncDisposableState]] internal slot, then - 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « a newly created *TypeError* object »). - 1. Return _promiseCapability_.[[Promise]]. - 1. If _asyncDisposableStack_.[[AsyncDisposableState]] is ~disposed~, then - 1. Perform ! Call(_promiseCapability_.[[Resolve]], *undefined*, « *undefined* »). - 1. Return _promiseCapability_.[[Promise]]. - 1. Set _asyncDisposableStack_.[[AsyncDisposableState]] to ~disposed~. - 1. Let _result_ be DisposeResources(_asyncDisposableStack_, NormalCompletion(*undefined*)). - 1. IfAbruptRejectPromise(_result_, _promiseCapability_). - 1. Perform ! Call(_promiseCapability_.[[Resolve]], *undefined*, « _result_ »). - 1. Return _promiseCapability_.[[Promise]]. - -
- - -

AsyncDisposableStack.prototype.use( _value_ )

-

When the `use` function is called with one argument, the following steps are taken:

- - 1. Let _asyncDisposableStack_ be the *this* value. - 1. Perform ? RequireInternalSlot(_asyncDisposableStack_, [[AsyncDisposableState]]). - 1. If _asyncDisposableStack_.[[AsyncDisposableState]] is ~disposed~, throw a *ReferenceError* exception. - 1. If _value_ is neither *null* nor *undefined*, then - 1. If Type(_value_) is not Object, throw a *TypeError* exception. - 1. Let _method_ be GetDisposeMethod(_value_, ~async-dispose~). - 1. If _method_ is *undefined*, then - 1. Throw a *TypeError* exception. - 1. Else, - 1. Perform ? AddDisposableResource(_disposableStack_, _value_, ~async-dispose~, _method_). - 1. Return _value_. - -
- - -

AsyncDisposableStack.prototype.adopt( _value_, _onDisposeAsync_ )

-

When the `adopt` function is called with two arguments, the following steps are taken:

- - 1. Let _asyncDisposableStack_ be the *this* value. - 1. Perform ? RequireInternalSlot(_asyncDisposableStack_, [[AsyncDisposableState]]). - 1. If _asyncDisposableStack_.[[AsyncDisposableState]] is ~disposed~, throw a *ReferenceError* exception. - 1. If IsCallable(_onDisposeAsync_) is *false*, throw a *TypeError* exception. - 1. Let _F_ be a new built-in function object as defined in . - 1. Set _F_.[[Argument]] to _value_. - 1. Set _F_.[[OnDisposeAsyncCallback]] to _onDisposeAsync_. - 1. Perform ? AddDisposableResource(_asyncDisposableStack_, *undefined*, ~async-dispose~, _F_). - 1. Return _value_. - - - -

AsyncDisposableStack Adopt Callback Functions

-

An AsyncDisposableStack adopt callback function is an anonymous built-in function that has [[Argument]] and [[OnDisposeAsyncCallback]] internal slots.

-

When an AsyncDisposableStack adopt callback function is called, the following steps are taken:

- - 1. Let _F_ be the active function object. - 1. Assert: IsCallable(_F_.[[OnDisposeAsyncCallback]]) is *true*. - 1. Return Call(_F_.[[OnDisposeAsyncCallback]], *undefined*, « _F_.[[Argument]] »). - -
-
- - -

AsyncDisposableStack.prototype.defer( _onDisposeAsync_ )

-

When the `defer` function is called with one argument, the following steps are taken:

- - 1. Let _asyncDisposableStack_ be the *this* value. - 1. Perform ? RequireInternalSlot(_asyncDisposableStack_, [[AsyncDisposableState]]). - 1. If _asyncDisposableStack_.[[AsyncDisposableState]] is ~disposed~, throw a *ReferenceError* exception. - 1. If IsCallable(_onDisposeAsync_) is *false*, throw a *TypeError* exception. - 1. Perform ? AddDisposableResource(_asyncDisposableStack_, *undefined*, ~async-dispose~, _onDisposeAsync_). - 1. Return *undefined*. - -
- - -

AsyncDisposableStack.prototype.move()

-

When the `move` function is called, the following steps are taken:

- - 1. Let _asyncDisposableStack_ be the *this* value. - 1. Perform ? RequireInternalSlot(_asyncDisposableStack_, [[AsyncDisposableState]]). - 1. If _asyncDisposableStack_.[[AsyncDisposableState]] is ~disposed~, throw a *ReferenceError* exception. - 1. Let _newAsyncDisposableStack_ be ? OrdinaryCreateFromConstructor(%AsyncDisposableStack%, *"%AsyncDisposableStack.prototype%"*, « [[AsyncDisposableState]], [[DisposableResourceStack]] »). - 1. Set _newAsyncDisposableStack_.[[AsyncDisposableState]] to ~pending~. - 1. Set _newAsyncDisposableStack_.[[DisposableResourceStack]] to _asyncDisposableStack_.[[DisposableResourceStack]]. - 1. Set _asyncDisposableStack_.[[DisposableResourceStack]] to a new empty List. - 1. Set _asyncDisposableStack_.[[AsyncDisposableState]] to ~disposed~. - 1. Return _newAsyncDisposableStack_. - -
- - -

AsyncDisposableStack.prototype [ @@asyncDispose ] ()

-

The initial value of the @@asyncDispose property is %AsyncDisposableStack.prototype.disposeAsync%, defined in .

-
- - -

AsyncDisposableStack.prototype [ @@toStringTag ]

-

The initial value of the `@@toStringTag` property is the String value *"AsyncDisposableStack"*.

-

This property has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *true* }.

-
-
- - -

Properties of AsyncDisposableStack Instances

-

AsyncDisposableStack instances are ordinary objects that inherit properties from the AsyncDisposableStack prototype object (the intrinsic %AsyncDisposableStack.prototype%). AsyncDisposableStack instances are initially created with internal slots described in .

- - - - - - - - - - - - - - - - -
- Internal Slot - - Description -
- [[AsyncDisposableState]] - - One of ~pending~ or ~disposed~. Governs how a disposable stack will react to incoming calls to its `@@asyncDispose` method. -
- [[DisposableResourceStack]] - - A List of DisposableResource records. -
-
-
-
-
-

Generator Objects