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)); } }
internal ArrowFunctionInstance( Engine engine, JintFunctionDefinition function, LexicalEnvironment scope, bool strict) : base(engine, function, scope, strict ? FunctionThisMode.Strict : FunctionThisMode.Lexical) { _function = function; PreventExtensions(); _prototype = Engine.Function.PrototypeObject; _length = new LazyPropertyDescriptor(() => JsNumber.Create(function.Initialize(engine, this).Length), PropertyFlag.Configurable); }
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)); } }