示例#1
0
 internal ErrorPrototype(
     Engine engine,
     Realm realm,
     ErrorConstructor constructor,
     ObjectInstance prototype,
     JsString name,
     ObjectClass objectClass)
     : base(engine, objectClass)
 {
     _realm       = realm;
     _name        = name;
     _constructor = constructor;
     _prototype   = prototype;
 }
示例#2
0
        public static ErrorConstructor CreateErrorConstructor(Engine engine, string name)
        {
            var obj = new ErrorConstructor(engine);
            obj.Extensible = true;
            obj._name = name;

            // The value of the [[Prototype]] internal property of the Error constructor is the Function prototype object (15.11.3)
            obj.Prototype = engine.Function.PrototypeObject;
            obj.PrototypeObject = ErrorPrototype.CreatePrototypeObject(engine, obj, name);

            obj.FastAddProperty("length", 1, false, false, false);

            // The initial value of Error.prototype is the Error prototype object
            obj.FastAddProperty("prototype", obj.PrototypeObject, false, false, false);

            return obj;
        }
示例#3
0
        public static ErrorPrototype CreatePrototypeObject(Engine engine, ErrorConstructor errorConstructor, string name)
        {
            var obj = new ErrorPrototype(engine, name) { Extensible = true };
            obj.FastAddProperty("constructor", errorConstructor, true, false, true);
            obj.FastAddProperty("message", "", true, false, true);

            if (name != "Error")
            {
                obj.Prototype = engine.Error.PrototypeObject;
            }
            else
            {
                obj.Prototype = engine.Object.PrototypeObject;
            }

            return obj;
        }
示例#4
0
        public static ErrorConstructor CreateErrorConstructor(Engine engine, string name)
        {
            var obj = new ErrorConstructor(engine);

            obj.Extensible = true;
            obj._name      = name;

            // The value of the [[Prototype]] internal property of the Error constructor is the Function prototype object (15.11.3)
            obj.Prototype       = engine.Function.PrototypeObject;
            obj.PrototypeObject = ErrorPrototype.CreatePrototypeObject(engine, obj, name);

            obj.SetOwnProperty("length", new PropertyDescriptor(1, PropertyFlag.AllForbidden));

            // The initial value of Error.prototype is the Error prototype object
            obj.SetOwnProperty("prototype", new PropertyDescriptor(obj.PrototypeObject, PropertyFlag.AllForbidden));

            return(obj);
        }
示例#5
0
        public static ErrorConstructor CreateErrorConstructor(Engine engine, string name)
        {
            var obj = new ErrorConstructor(engine);

            obj.Extensible = true;
            obj._name      = name;

            // The value of the [[Prototype]] internal property of the Error constructor is the Function prototype object (15.11.3)
            obj.Prototype       = engine.Function.PrototypeObject;
            obj.PrototypeObject = ErrorPrototype.CreatePrototypeObject(engine, obj, name);

            obj.FastAddProperty("length", 1, false, false, false);

            // The initial value of Error.prototype is the Error prototype object
            obj.FastAddProperty("prototype", obj.PrototypeObject, false, false, false);

            return(obj);
        }
示例#6
0
        public static ErrorPrototype CreatePrototypeObject(Engine engine, ErrorConstructor errorConstructor, JsString name)
        {
            var obj = new ErrorPrototype(engine, name)
            {
                _errorConstructor = errorConstructor,
            };

            if (name._value != "Error")
            {
                obj._prototype = engine.Error.PrototypeObject;
            }
            else
            {
                obj._prototype = engine.Object.PrototypeObject;
            }

            return(obj);
        }
        public static ErrorConstructor CreateErrorConstructor(Engine engine, JsString name)
        {
            var obj = new ErrorConstructor(engine)
            {
                _name      = name,
                _prototype = engine.Function.PrototypeObject
            };

            // The value of the [[Prototype]] internal property of the Error constructor is the Function prototype object (15.11.3)
            obj.PrototypeObject = ErrorPrototype.CreatePrototypeObject(engine, obj, name);

            obj._length = PropertyDescriptor.AllForbiddenDescriptor.NumberOne;

            // The initial value of Error.prototype is the Error prototype object
            obj._prototypeDescriptor = new PropertyDescriptor(obj.PrototypeObject, PropertyFlag.AllForbidden);

            return(obj);
        }
示例#8
0
        public static ErrorPrototype CreatePrototypeObject(Engine engine, ErrorConstructor errorConstructor, string name)
        {
            var obj = new ErrorPrototype(engine, name)
            {
                Extensible = true
            };

            obj.FastAddProperty("constructor", errorConstructor, true, false, true);
            obj.FastAddProperty("message", "", true, false, true);

            if (name != "Error")
            {
                obj.Prototype = engine.Error.PrototypeObject;
            }
            else
            {
                obj.Prototype = engine.Object.PrototypeObject;
            }

            return(obj);
        }
示例#9
0
 public JavaScriptException(ErrorConstructor errorConstructor, string message)
     : base(message)
 {
     _errorObject = errorConstructor.Construct(new JsValue[] { message });
 }
示例#10
0
 public JavaScriptException(ErrorConstructor errorConstructor) : base("")
 {
     _errorObject = errorConstructor.Construct(Arguments.Empty);
 }