- // no. of arguments for constructor
- putDirectWithoutTransition(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly | DontEnum | DontDelete);
+JSCell* JSC_HOST_CALL stringFromCharCode(ExecState* exec, int32_t arg)
+{
+ return jsSingleCharacterString(exec, arg);
+}
+
+static EncodedJSValue JSC_HOST_CALL stringFromCodePoint(ExecState* exec)
+{
+ unsigned length = exec->argumentCount();
+ StringBuilder builder;
+ builder.reserveCapacity(length);
+
+ for (unsigned i = 0; i < length; ++i) {
+ double codePointAsDouble = exec->uncheckedArgument(i).toNumber(exec);
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
+
+ uint32_t codePoint = static_cast<uint32_t>(codePointAsDouble);
+
+ if (codePoint != codePointAsDouble || codePoint > UCHAR_MAX_VALUE)
+ return throwVMError(exec, createRangeError(exec, ASCIILiteral("Arguments contain a value that is out of range of code points")));
+
+ if (U_IS_BMP(codePoint))
+ builder.append(static_cast<UChar>(codePoint));
+ else {
+ builder.append(U16_LEAD(codePoint));
+ builder.append(U16_TRAIL(codePoint));
+ }
+ }
+
+ return JSValue::encode(jsString(exec, builder.toString()));