using Jint.Native.Promise;
namespace Jint;
public partial class Engine
{
public AdvancedOperations Advanced { get; }
public class AdvancedOperations
{
private readonly Engine _engine;
internal AdvancedOperations(Engine engine)
{
_engine = engine;
}
///
/// Gets current stack trace that is active in engine.
///
public string StackTrace
{
get
{
var lastSyntaxElement = _engine._lastSyntaxElement;
if (lastSyntaxElement is null)
{
return string.Empty;
}
return _engine.CallStack.BuildCallStackString(lastSyntaxElement.Location);
}
}
///
/// Initializes list of references of called functions
///
public void ResetCallStack()
{
_engine.ResetCallStack();
}
///
/// Forcefully processes the current task queues (micro and regular), this API may break and change behavior!
///
public void ProcessTasks()
{
_engine.RunAvailableContinuations();
}
///
/// EXPERIMENTAL! Subject to change.
///
/// Registers a promise within the currently running EventLoop (has to be called within "ExecuteWithEventLoop" call).
/// Note that ExecuteWithEventLoop will not trigger "onFinished" callback until ALL manual promises are settled.
///
/// NOTE: that resolve and reject need to be called withing the same thread as "ExecuteWithEventLoop".
/// The API assumes that the Engine is called from a single thread.
///
/// a Promise instance and functions to either resolve or reject it
public ManualPromise RegisterPromise()
{
return _engine.RegisterPromise();
}
}
}