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-repeat.tq')
-rw-r--r--deps/v8/src/builtins/string-repeat.tq106
1 files changed, 51 insertions, 55 deletions
diff --git a/deps/v8/src/builtins/string-repeat.tq b/deps/v8/src/builtins/string-repeat.tq
index e3e72ae7b58..e1e33eb53ab 100644
--- a/deps/v8/src/builtins/string-repeat.tq
+++ b/deps/v8/src/builtins/string-repeat.tq
@@ -3,76 +3,72 @@
// found in the LICENSE file.
namespace string {
- const kBuiltinName: constexpr string = 'String.prototype.repeat';
+const kBuiltinName: constexpr string = 'String.prototype.repeat';
- builtin StringRepeat(implicit context: Context)(string: String, count: Smi):
- String {
- assert(count >= 0);
- assert(string != kEmptyString);
+builtin StringRepeat(implicit context: Context)(
+ string: String, count: Smi): String {
+ assert(count >= 0);
+ assert(string != kEmptyString);
- let result: String = kEmptyString;
- let powerOfTwoRepeats: String = string;
- let n: intptr = Convert<intptr>(count);
+ let result: String = kEmptyString;
+ let powerOfTwoRepeats: String = string;
+ let n: intptr = Convert<intptr>(count);
- while (true) {
- if ((n & 1) == 1) result = result + powerOfTwoRepeats;
+ while (true) {
+ if ((n & 1) == 1) result = result + powerOfTwoRepeats;
- n = n >> 1;
- if (n == 0) break;
+ n = n >> 1;
+ if (n == 0) break;
- powerOfTwoRepeats = powerOfTwoRepeats + powerOfTwoRepeats;
- }
-
- return result;
+ powerOfTwoRepeats = powerOfTwoRepeats + powerOfTwoRepeats;
}
- // https://tc39.github.io/ecma262/#sec-string.prototype.repeat
- transitioning javascript builtin StringPrototypeRepeat(
- js-implicit context: NativeContext,
- receiver: JSAny)(count: JSAny): String {
- // 1. Let O be ? RequireObjectCoercible(this value).
- // 2. Let S be ? ToString(O).
- const s: String = ToThisString(receiver, kBuiltinName);
+ return result;
+}
- try {
- // 3. Let n be ? ToInteger(count).
- typeswitch (ToInteger_Inline(count)) {
- case (n: Smi): {
- // 4. If n < 0, throw a RangeError exception.
- if (n < 0) goto InvalidCount;
+// https://tc39.github.io/ecma262/#sec-string.prototype.repeat
+transitioning javascript builtin StringPrototypeRepeat(
+ js-implicit context: NativeContext, receiver: JSAny)(count: JSAny): String {
+ // 1. Let O be ? RequireObjectCoercible(this value).
+ // 2. Let S be ? ToString(O).
+ const s: String = ToThisString(receiver, kBuiltinName);
- // 6. If n is 0, return the empty String.
- if (n == 0 || s.length_uint32 == 0) goto EmptyString;
+ try {
+ // 3. Let n be ? ToInteger(count).
+ typeswitch (ToInteger_Inline(count)) {
+ case (n: Smi): {
+ // 4. If n < 0, throw a RangeError exception.
+ if (n < 0) goto InvalidCount;
- if (n > kStringMaxLength) goto InvalidStringLength;
+ // 6. If n is 0, return the empty String.
+ if (n == 0 || s.length_uint32 == 0) goto EmptyString;
- // 7. Return the String value that is made from n copies of S appended
- // together.
- return StringRepeat(s, n);
- }
- case (heapNum: HeapNumber): deferred {
- assert(IsNumberNormalized(heapNum));
- const n = LoadHeapNumberValue(heapNum);
+ if (n > kStringMaxLength) goto InvalidStringLength;
+
+ // 7. Return the String value that is made from n copies of S appended
+ // together.
+ return StringRepeat(s, n);
+ }
+ case (heapNum: HeapNumber): deferred {
+ assert(IsNumberNormalized(heapNum));
+ const n = LoadHeapNumberValue(heapNum);
- // 4. If n < 0, throw a RangeError exception.
- // 5. If n is +∞, throw a RangeError exception.
- if (n == V8_INFINITY || n < 0.0) goto InvalidCount;
+ // 4. If n < 0, throw a RangeError exception.
+ // 5. If n is +∞, throw a RangeError exception.
+ if (n == V8_INFINITY || n < 0.0) goto InvalidCount;
- // 6. If n is 0, return the empty String.
- if (s.length_uint32 == 0) goto EmptyString;
+ // 6. If n is 0, return the empty String.
+ if (s.length_uint32 == 0) goto EmptyString;
- goto InvalidStringLength;
- }
+ goto InvalidStringLength;
}
}
- label EmptyString {
- return kEmptyString;
- }
- label InvalidCount deferred {
- ThrowRangeError(MessageTemplate::kInvalidCountValue, count);
- }
- label InvalidStringLength deferred {
- ThrowInvalidStringLength(context);
- }
+ } label EmptyString {
+ return kEmptyString;
+ } label InvalidCount deferred {
+ ThrowRangeError(MessageTemplate::kInvalidCountValue, count);
+ } label InvalidStringLength deferred {
+ ThrowInvalidStringLength(context);
}
}
+}