public static ArgumentsInstance CreateArgumentsObject(Engine engine, FunctionInstance func, string[] names, JsValue[] args, EnvironmentRecord env, bool strict) { var len = args.Length; var obj = new ArgumentsInstance(engine); obj.Prototype = engine.Object.PrototypeObject; obj.Extensible = true; obj.FastAddProperty("length", len, true, false, true); obj.Strict = strict; 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]; obj.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) { obj.ParameterMap = map; } // step 13 if (!strict) { obj.FastAddProperty("callee",func, true, false, true); } // step 14 else { var thrower = engine.Function.ThrowTypeError; obj.DefineOwnProperty("caller", new PropertyDescriptor(get: thrower, set: thrower, enumerable:false, configurable:false), false); obj.DefineOwnProperty("callee", new PropertyDescriptor(get: thrower, set: thrower, enumerable: false, configurable: false), false); } return obj; }
public LexicalEnvironment(EnvironmentRecord record, LexicalEnvironment outer) { _record = record; _outer = outer; }