} // ArrayConstructorFunction // Implementation for calling the Array constructor as a constructor. public static object ArrayConstructor(object this_, params object[] args) { JArrayObject arrayObj = new JArrayObject(); if (args.Length == 1 && JObject.Typeof(args[0]) == "number") { // Treat the one argument as a length, and create an array of // that length. UInt32 newLength = JConvert.ToUInt32(args[0]); if (newLength != JConvert.ToNumber(args[0])) throw new RangeError("array length in constructor is outside the UInt32 range"); arrayObj.arrayLength = newLength; } else { // Create an array with the entries specified in the args array. foreach (object curArg in args) arrayObj.entries.Add(curArg); arrayObj.arrayLength = (uint) args.Length; } return arrayObj; } // ArrayConstructor
} // LookupProperty // Perform the [[Construct]] operation on this object. public override object Construct(JObject this_, params object[] args) { if (constructImp != null) { JObject newObj = new JObject(InstancePrototype, this, "Object"); object temp = constructImp(newObj, args); if (JObject.Typeof(temp) == "object") return temp; else return newObj; } else throw new TypeError("Construct called for an object with no [[Construct]] operation"); } // Construct