public ProxyInstance Construct(ObjectInstance target, ObjectInstance handler)
        {
            if (target is ProxyInstance targetProxy && targetProxy._handler is null)
            {
                ExceptionHelper.ThrowTypeError(_engine);
            }
            if (handler is ProxyInstance handlerProxy && handlerProxy._handler is null)
            {
                ExceptionHelper.ThrowTypeError(_engine);
            }
            var instance = new ProxyInstance(Engine, target, handler);

            return(instance);
        }
Пример #2
0
        /// <summary>
        /// https://tc39.es/ecma262/#sec-proxycreate
        /// </summary>
        private ProxyInstance ProxyCreate(JsValue target, JsValue handler)
        {
            if (target is not ObjectInstance targetObject)
            {
                ExceptionHelper.ThrowTypeError(_realm, "Cannot create proxy with a non-object as target");
                return(null);
            }

            if (handler is not ObjectInstance targetHandler)
            {
                ExceptionHelper.ThrowTypeError(_realm, "Cannot create proxy with a non-object as handler");
                return(null);
            }

            var p = new ProxyInstance(Engine, targetObject, targetHandler);

            return(p);
        }