using System; using System.Collections; using System.Collections.Generic; using Jint.Native; using Jint.Runtime.Environments; namespace Jint.Runtime.Debugger { /// /// Scope information, bindings, and values for a single scope in the scope chain /// public sealed class DebugScope { private readonly EnvironmentRecord _record; private readonly List _bindingNames; internal DebugScope(DebugScopeType type, EnvironmentRecord record, List bindingNames, bool isTopLevel) { ScopeType = type; _record = record; _bindingNames = bindingNames; IsTopLevel = isTopLevel; } /// /// The type of scope. Scope types are the same as defined by Chrome devtools protocol. /// public DebugScopeType ScopeType { get; } /// /// For block scopes, indicates whether this scope is at the top level of a containing function. /// /// /// Block scopes at the top level of a function are combined with Local scope in Chromium and devtools protocol. /// This property facilitates implementing the same "flattening" in e.g. a UI. Because empty scopes are excluded in the scope chain, /// top level cannot be determined from the scope chain order alone. /// public bool IsTopLevel { get; } /// /// Names of all non-shadowed bindings in the scope. /// public IReadOnlyList BindingNames => _bindingNames; /// /// Retrieves the value of a specific binding. Note that some bindings (e.g. uninitialized let) may return null. /// /// Binding name /// Value of the binding public JsValue GetBindingValue(string name) { return _record.GetBindingValue(name, strict: false); } } }