internal static bool CreateMethodProperty([NotNull] ScriptObject obj, ScriptValue property, ScriptValue value)
        {
            //https://tc39.github.io/ecma262/#sec-createmethodproperty
            Debug.Assert(IsPropertyKey(property));
            var newDescriptor = new PropertyDescriptor(value, true, false, true);

            return(obj.DefineOwnProperty(property, newDescriptor));
        }
        internal void DefinePropertyOrThrow([NotNull] ScriptObject obj, ScriptValue property, [NotNull] PropertyDescriptor descriptor)
        {
            //https://tc39.github.io/ecma262/#sec-definepropertyorthrow
            Debug.Assert(IsPropertyKey(property));
            var success = obj.DefineOwnProperty(property, descriptor);

            if (!success)
            {
                throw CreateTypeError();
            }
        }
Exemple #3
0
 public static void DefineAccessorProperty([NotNull] ScriptObject scriptObject, ScriptValue property, [CanBeNull] ScriptFunctionObject get, [CanBeNull] ScriptFunctionObject set, bool enumerable = false, bool configurable = true)
 {
     scriptObject.DefineOwnProperty(property, new PropertyDescriptor(get == null ? null : (ScriptValue?)(ScriptValue)get,
                                                                     set == null ? null : (ScriptValue?)(ScriptValue)set,
                                                                     enumerable, configurable));
 }
Exemple #4
0
 public static void DefineDataProperty([NotNull] ScriptObject scriptObject, ScriptValue property, ScriptValue value, bool writable = true, bool enumerable = false, bool configurable = true)
 {
     scriptObject.DefineOwnProperty(property, new PropertyDescriptor(value, writable, enumerable, configurable));
 }