Class PromiseLibrary

java.lang.Object
com.oracle.truffle.api.nodes.Node
com.oracle.truffle.api.library.Library
com.oracle.truffle.js.api.PromiseLibrary
All Implemented Interfaces:
com.oracle.truffle.api.nodes.NodeInterface, Cloneable

public abstract class PromiseLibrary extends com.oracle.truffle.api.library.Library
Promise library provides operations on and information about JavaScript Promise objects.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    State of a promise.

    Nested classes/interfaces inherited from class com.oracle.truffle.api.nodes.Node

    com.oracle.truffle.api.nodes.Node.Child, com.oracle.truffle.api.nodes.Node.Children
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static com.oracle.truffle.api.library.LibraryFactory<PromiseLibrary>
    Returns the library factory for the promise library.
    getState(Object promise)
    Returns the state of the promise.
    Returns the uncached automatically dispatched version of the promise library.
    boolean
    isPromise(Object object)
    Returns true if the object is JavaScript Promise, returns false otherwise.
    void
    Marks the promise as handled (to avoid warnings/errors from its potential unhandled rejection).

    Methods inherited from class com.oracle.truffle.api.library.Library

    accepts

    Methods inherited from class com.oracle.truffle.api.nodes.Node

    accept, adoptChildren, atomic, atomic, copy, deepCopy, getChildren, getCost, getDebugProperties, getDescription, getEncapsulatingSourceSection, getLock, getParent, getRootNode, getSourceSection, insert, insert, isAdoptable, isSafelyReplaceableBy, notifyInserted, onReplace, replace, replace, reportPolymorphicSpecialize, reportReplace, toString

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • PromiseLibrary

      public PromiseLibrary()
  • Method Details

    • getFactory

      public static com.oracle.truffle.api.library.LibraryFactory<PromiseLibrary> getFactory()
      Returns the library factory for the promise library.
    • getUncached

      public static PromiseLibrary getUncached()
      Returns the uncached automatically dispatched version of the promise library.
    • isPromise

      public boolean isPromise(Object object)
      Returns true if the object is JavaScript Promise, returns false otherwise.
    • getState

      public PromiseLibrary.State getState(Object promise) throws com.oracle.truffle.api.interop.UnsupportedMessageException
      Returns the state of the promise. Throws UnsupportedMessageException when the receiver is not isPromise(Object).
      Throws:
      com.oracle.truffle.api.interop.UnsupportedMessageException
    • markHandled

      public void markHandled(Object promise) throws com.oracle.truffle.api.interop.UnsupportedMessageException
      Marks the promise as handled (to avoid warnings/errors from its potential unhandled rejection). It should be invoked before the promise is rejected. Throws UnsupportedMessageException when the receiver is not isPromise(Object).
      Throws:
      com.oracle.truffle.api.interop.UnsupportedMessageException