| Index: src/js/string.js
|
| diff --git a/src/js/string.js b/src/js/string.js
|
| index f0b970a0490d830a9b4b9e5a23bc16ed00d0aefc..ede5f881604b4ab2abaacba6c7a0a29be5db383e 100644
|
| --- a/src/js/string.js
|
| +++ b/src/js/string.js
|
| @@ -54,6 +54,30 @@
|
| throw MakeTypeError(kNotGeneric, 'String.prototype.valueOf');
|
| }
|
| return %_ValueOf(this);
|
| +}
|
| +
|
| +
|
| +// ECMA-262, section 15.5.4.4
|
| +function StringCharAtJS(pos) {
|
| + CHECK_OBJECT_COERCIBLE(this, "String.prototype.charAt");
|
| +
|
| + var result = %_StringCharAt(this, pos);
|
| + if (%_IsSmi(result)) {
|
| + result = %_StringCharAt(TO_STRING(this), TO_INTEGER(pos));
|
| + }
|
| + return result;
|
| +}
|
| +
|
| +
|
| +// ECMA-262 section 15.5.4.5
|
| +function StringCharCodeAtJS(pos) {
|
| + CHECK_OBJECT_COERCIBLE(this, "String.prototype.charCodeAt");
|
| +
|
| + var result = %_StringCharCodeAt(this, pos);
|
| + if (!%_IsSmi(result)) {
|
| + result = %_StringCharCodeAt(TO_STRING(this), TO_INTEGER(pos));
|
| + }
|
| + return result;
|
| }
|
|
|
|
|
| @@ -833,6 +857,13 @@
|
|
|
| // -------------------------------------------------------------------
|
|
|
| +// Set the String function and constructor.
|
| +%FunctionSetPrototype(GlobalString, new GlobalString());
|
| +
|
| +// Set up the constructor property on the String prototype object.
|
| +%AddNamedProperty(
|
| + GlobalString.prototype, "constructor", GlobalString, DONT_ENUM);
|
| +
|
| // Set up the non-enumerable functions on the String object.
|
| utils.InstallFunctions(GlobalString, DONT_ENUM, [
|
| "fromCharCode", StringFromCharCode,
|
| @@ -844,6 +875,8 @@
|
| utils.InstallFunctions(GlobalString.prototype, DONT_ENUM, [
|
| "valueOf", StringValueOf,
|
| "toString", StringToString,
|
| + "charAt", StringCharAtJS,
|
| + "charCodeAt", StringCharCodeAtJS,
|
| "codePointAt", StringCodePointAt,
|
| "concat", StringConcat,
|
| "endsWith", StringEndsWith,
|
| @@ -889,6 +922,7 @@
|
|
|
| utils.Export(function(to) {
|
| to.ExpandReplacement = ExpandReplacement;
|
| + to.StringCharAt = StringCharAtJS;
|
| to.StringIndexOf = StringIndexOf;
|
| to.StringLastIndexOf = StringLastIndexOf;
|
| to.StringMatch = StringMatchJS;
|
|
|