Example #1
0
 /// <summary>Returns a new instance of the appropriate class of an object based on its object ID.</summary>
 /// <param name="objectID">The object ID of the new object.</param>
 public static GeneralObject GetNewObjectInstance(SpecialObjectType objectID) => GetNewObjectInstance((int)objectID);
Example #2
0
        internal ScriptObject OrdinaryCreateFromConstructor([NotNull] ScriptObject constructor, [NotNull] ScriptObject defaultPrototype, SpecialObjectType specialObjectType = SpecialObjectType.None)
        {
            //https://tc39.github.io/ecma262/#sec-ordinarycreatefromconstructor
            var prototype = GetPrototypeFromConstructor(constructor, defaultPrototype);

            return(ObjectCreate(prototype, specialObjectType));
        }
Example #3
0
        internal static ScriptObject ObjectCreate([NotNull] Realm realm, [CanBeNull] ScriptObject prototype, SpecialObjectType specialObjectType = SpecialObjectType.None)
        {
            //https://tc39.github.io/ecma262/#sec-objectcreate

            return(new ScriptObject(realm, prototype, true, specialObjectType));
        }
Example #4
0
 /// <summary>Creates a new instance of the <seealso cref="ObjectIDAttribute"/> attribute.</summary>
 /// <param name="objectID">The object ID of the <seealso cref="SpecialObject"/>.</param>
 public ObjectIDAttribute(SpecialObjectType objectID) : this((int)objectID)
 {
 }
Example #5
0
        internal ScriptObject([NotNull] Realm realm, [CanBeNull] ScriptObject prototype, bool extensible, SpecialObjectType specialObjectType)
        {
            Realm             = realm;
            this.prototype    = prototype;
            SpecialObjectType = specialObjectType;
            IsExtensible      = extensible;

            switch (specialObjectType)
            {
            case SpecialObjectType.None:
            case SpecialObjectType.ArgumentsObject:
            case SpecialObjectType.TypedArray:
                break;

            case SpecialObjectType.IteratedList:
                specialValue = new IteratorInternals();
                break;

            case SpecialObjectType.ArrayIterator:
                specialValue = new ArrayIteratorInternals();
                break;

            case SpecialObjectType.Date:
            case SpecialObjectType.Number:
                specialValue = new BasicInternal <double>();
                break;

            case SpecialObjectType.Boolean:
                specialValue = new BasicInternal <bool>();
                break;

            case SpecialObjectType.Symbol:
                specialValue = new BasicInternal <Symbol>();
                break;

            case SpecialObjectType.Error:
                specialValue = new BasicInternal <ErrorData>();
                break;

            case SpecialObjectType.ArrayBuffer:
                specialValue = new ArrayBufferInternals();
                break;

            case SpecialObjectType.DataView:
                specialValue = new DataViewInternals();
                break;

            case SpecialObjectType.RegExp:
                specialValue = new RegExpInternals();
                break;

            case SpecialObjectType.RevocableProxy:
                specialValue = new BasicInternal <ScriptObject>();
                break;

            case SpecialObjectType.PromiseCapability:
                specialValue = new PromiseCapability();
                break;

            case SpecialObjectType.Promise:
                specialValue = new PromiseInternals();
                break;

            case SpecialObjectType.PromiseState:
                specialValue = new PromiseStateInternals();
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(specialObjectType), specialObjectType, null);
            }
        }
Example #6
0
 internal ScriptFunctionObject([NotNull] Realm realm, [CanBeNull] ScriptObject prototype, bool extensible, [NotNull] Func <ScriptArguments, ScriptValue> callback, SpecialObjectType type) :
     base(realm, prototype, extensible, type)
 {
     this.callback   = callback;
     FunctionKind    = FunctionKind.Normal;
     ConstructorKind = ConstructorKind.None;
 }