internal ScriptFunctionInstance( Engine engine, JintFunctionDefinition function, LexicalEnvironment scope, FunctionThisMode thisMode) : base(engine, function, scope, thisMode) { _function = function; _prototype = _engine.Function.PrototypeObject; _length = new LazyPropertyDescriptor(() => JsNumber.Create(function.Initialize(engine, this).Length), PropertyFlag.Configurable); var proto = new ObjectInstanceWithConstructor(engine, this) { _prototype = _engine.Object.PrototypeObject }; _prototypeDescriptor = new PropertyDescriptor(proto, PropertyFlag.OnlyWritable); if (!function.Strict && !engine._isStrict) { DefineOwnProperty(CommonProperties.Arguments, engine._callerCalleeArgumentsThrowerConfigurable); DefineOwnProperty(CommonProperties.Caller, new PropertyDescriptor(Undefined, PropertyFlag.Configurable)); } }
protected FunctionInstance( Engine engine, JsString name, FunctionThisMode thisMode = FunctionThisMode.Global, ObjectClass objectClass = ObjectClass.Function) : base(engine, objectClass) { _name = name; _thisMode = thisMode; }
protected FunctionInstance( Engine engine, JintFunctionDefinition function, LexicalEnvironment scope, FunctionThisMode thisMode) : this(engine, !(string.IsNullOrEmpty(function.Name) || function.Name.Trim() == "") ? new JsString(function.Name) : null, thisMode) { _functionDefinition = function; _environment = scope; }
internal FunctionInstance( Engine engine, JintFunctionDefinition function, LexicalEnvironment scope, FunctionThisMode thisMode) : this(engine, !string.IsNullOrWhiteSpace(function.Name) ? new JsString(function.Name) : null, thisMode) { _functionDefinition = function; _environment = scope; }
internal FunctionInstance( Engine engine, JsString name, FunctionThisMode thisMode = FunctionThisMode.Global, ObjectClass objectClass = ObjectClass.Function) : base(engine, objectClass) { if (!(name is null)) { _nameDescriptor = new PropertyDescriptor(name, PropertyFlag.Configurable); } _thisMode = thisMode; }
internal FunctionInstance( Engine engine, Realm realm, JsString name, FunctionThisMode thisMode = FunctionThisMode.Global, ObjectClass objectClass = ObjectClass.Function) : base(engine, objectClass) { if (name is not null) { _nameDescriptor = new PropertyDescriptor(name, PropertyFlag.Configurable); } _realm = realm; _thisMode = thisMode; _scriptOrModule = _engine.GetActiveScriptOrModule(); }
internal ScriptFunctionInstance( Engine engine, JintFunctionDefinition function, EnvironmentRecord scope, FunctionThisMode thisMode, ObjectInstance proto = null) : base(engine, engine.Realm, function, scope, thisMode) { _prototype = proto ?? _engine.Realm.Intrinsics.Function.PrototypeObject; _length = new LazyPropertyDescriptor(null, _ => JsNumber.Create(function.Initialize(this).Length), PropertyFlag.Configurable); if (!function.Strict && !engine._isStrict && function.Function is not ArrowFunctionExpression) { DefineOwnProperty(CommonProperties.Arguments, new GetSetPropertyDescriptor.ThrowerPropertyDescriptor(engine, PropertyFlag.Configurable | PropertyFlag.CustomJsValue)); DefineOwnProperty(CommonProperties.Caller, new PropertyDescriptor(Undefined, PropertyFlag.Configurable)); } }