Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/builtins/string-substr.tq')
-rw-r--r--deps/v8/src/builtins/string-substr.tq61
1 files changed, 30 insertions, 31 deletions
diff --git a/deps/v8/src/builtins/string-substr.tq b/deps/v8/src/builtins/string-substr.tq
index 917bee691e0..068c4437ca6 100644
--- a/deps/v8/src/builtins/string-substr.tq
+++ b/deps/v8/src/builtins/string-substr.tq
@@ -4,40 +4,39 @@
namespace string {
- // String.prototype.substr ( start, length )
- // ES6 #sec-string.prototype.substr
- transitioning javascript builtin StringPrototypeSubstr(
- js-implicit context: NativeContext,
- receiver: JSAny)(...arguments): String {
- const methodName: constexpr string = 'String.prototype.substr';
- // 1. Let O be ? RequireObjectCoercible(this value).
- // 2. Let S be ? ToString(O).
- const string: String = ToThisString(receiver, methodName);
+// String.prototype.substr ( start, length )
+// ES6 #sec-string.prototype.substr
+transitioning javascript builtin StringPrototypeSubstr(
+ js-implicit context: NativeContext, receiver: JSAny)(...arguments): String {
+ const methodName: constexpr string = 'String.prototype.substr';
+ // 1. Let O be ? RequireObjectCoercible(this value).
+ // 2. Let S be ? ToString(O).
+ const string: String = ToThisString(receiver, methodName);
- // 5. Let size be the number of code units in S.
- const size: uintptr = string.length_uintptr;
+ // 5. Let size be the number of code units in S.
+ const size: uintptr = string.length_uintptr;
- // 3. Let intStart be ? ToInteger(start).
- // 6. If intStart < 0, set intStart to max(size + intStart, 0).
- const start = arguments[0];
- const initStart: uintptr =
- start != Undefined ? ConvertToRelativeIndex(start, size) : 0;
+ // 3. Let intStart be ? ToInteger(start).
+ // 6. If intStart < 0, set intStart to max(size + intStart, 0).
+ const start = arguments[0];
+ const initStart: uintptr =
+ start != Undefined ? ConvertToRelativeIndex(start, size) : 0;
- // 4. If length is undefined,
- // let end be +∞; otherwise let end be ? ToInteger(length).
- // 7. Let resultLength be min(max(end, 0), size - intStart).
- const length = arguments[1];
- const lengthLimit = size - initStart;
- assert(lengthLimit <= size);
- const resultLength: uintptr = length != Undefined ?
- ClampToIndexRange(length, lengthLimit) :
- lengthLimit;
+ // 4. If length is undefined,
+ // let end be +∞; otherwise let end be ? ToInteger(length).
+ // 7. Let resultLength be min(max(end, 0), size - intStart).
+ const length = arguments[1];
+ const lengthLimit = size - initStart;
+ assert(lengthLimit <= size);
+ const resultLength: uintptr = length != Undefined ?
+ ClampToIndexRange(length, lengthLimit) :
+ lengthLimit;
- // 8. If resultLength ≤ 0, return the empty String "".
- if (resultLength == 0) return EmptyStringConstant();
+ // 8. If resultLength ≤ 0, return the empty String "".
+ if (resultLength == 0) return EmptyStringConstant();
- // 9. Return the String value containing resultLength consecutive code units
- // from S beginning with the code unit at index intStart.
- return SubString(string, initStart, initStart + resultLength);
- }
+ // 9. Return the String value containing resultLength consecutive code units
+ // from S beginning with the code unit at index intStart.
+ return SubString(string, initStart, initStart + resultLength);
+}
}