public static ArgumentsInstance CreateArgumentsObject(Engine engine, FunctionInstance func, string[] names, JsValue[] args, EnvironmentRecord env, bool strict) { var obj = new ArgumentsInstance(engine, self => { var len = args.Length; self.FastAddProperty("length", len, true, false, true); var map = engine.Object.Construct(Arguments.Empty); var mappedNamed = new List<string>(); var indx = 0; while (indx <= len - 1) { var indxStr = TypeConverter.ToString(indx); var val = args[indx]; self.FastAddProperty(indxStr, val, true, true, true); if (indx < names.Length) { var name = names[indx]; if (!strict && !mappedNamed.Contains(name)) { mappedNamed.Add(name); Func<JsValue, JsValue> g = n => env.GetBindingValue(name, false); var p = new Action<JsValue, JsValue>((n, o) => env.SetMutableBinding(name, o, true)); map.DefineOwnProperty(indxStr, new ClrAccessDescriptor(engine, g, p) { Configurable = true }, false); } } indx++; } // step 12 if (mappedNamed.Count > 0) { self.ParameterMap = map; } // step 13 if (!strict) { self.FastAddProperty("callee", func, true, false, true); } // step 14 else { var thrower = engine.Function.ThrowTypeError; self.DefineOwnProperty("caller", new PropertyDescriptor(get: thrower, set: thrower, enumerable: false, configurable: false), false); self.DefineOwnProperty("callee", new PropertyDescriptor(get: thrower, set: thrower, enumerable: false, configurable: false), false); } }); // These properties are pre-initialized as their don't trigger // the EnsureInitialized() event and are cheap obj.Prototype = engine.Object.PrototypeObject; obj.Extensible = true; obj.Strict = strict; return obj; }
internal ExecutionContext( IScriptOrModule?scriptOrModule, EnvironmentRecord lexicalEnvironment, EnvironmentRecord variableEnvironment, PrivateEnvironmentRecord?privateEnvironment, Realm realm, FunctionInstance?function = null) { ScriptOrModule = scriptOrModule; LexicalEnvironment = lexicalEnvironment; VariableEnvironment = variableEnvironment; PrivateEnvironment = privateEnvironment; Realm = realm; Function = function; }
public void Setup(EnvironmentRecord record, LexicalEnvironment outer) { Record = record; Outer = outer; }
public LexicalEnvironment(EnvironmentRecord record, LexicalEnvironment outer) { _record = record; _outer = outer; }
public ExecutionContext UpdateVariableEnvironment(EnvironmentRecord variableEnvironment) { return(new ExecutionContext(ScriptOrModule, LexicalEnvironment, variableEnvironment, PrivateEnvironment, Realm, Function)); }
public LexicalEnvironment(EnvironmentRecord record, LexicalEnvironment outer) { _record = record; _outer = outer; }
public LexicalEnvironment(Engine engine, EnvironmentRecord record, LexicalEnvironment outer) { _engine = engine; _record = record; _outer = outer; }
internal static bool TryGetIdentifierEnvironmentWithBinding( EnvironmentRecord env, in EnvironmentRecord.BindingName name,