using Jint.Native;
namespace Jint.Runtime.Interop
{
///
/// Reference resolver allows customizing behavior for reference resolving. This can be useful in cases where
/// you want to ignore long chain of property accesses that might throw if anything is null or undefined.
/// An example of such is var a = obj.field.subField.value
. Custom resolver could accept chain to return
/// null/undefined on first occurrence.
///
public interface IReferenceResolver
{
///
/// When unresolvable reference occurs, check if another value can be provided instead of it.
///
///
/// A reference error will be thrown if this method return false.
///
/// The current engine instance.
/// The reference that is being processed.
/// Value that should be used instead of undefined.
/// Whether to use instead of undefined.
bool TryUnresolvableReference(Engine engine, Reference reference, out JsValue value);
///
/// When property reference is being processed, resolve to other value if needed.
///
/// The current engine instance.
/// The reference that is being processed.
/// Value that should be used instead of reference target.
/// Whether to use instead of reference's value.
bool TryPropertyReference(Engine engine, Reference reference, ref JsValue value);
///
/// When evaluating a function call and a target that is not an object is encountered,
/// custom implementation can return a value to call.
///
///
/// A reference error will be thrown if this method return false.
///
/// The current engine instance.
/// The callee.
/// Value that should be used when this method return true. Should be .
/// Whether to use instead of undefined.
bool TryGetCallable(Engine engine, object callee, out JsValue value);
///
/// Check whether objects property value is valid.
///
/// The value to check
/// Whether to accept the value.
bool CheckCoercible(JsValue value);
}
}