Commit 31eca73d authored by Simon Zünd's avatar Simon Zünd Committed by Commit Bot

[torque] Fix all current lint errors in Torque code

To make the changes in base.tq work, there were 2 changes needed on
the C++ side:
  - calls to "FromConstexpr" are generated by the compiler for
    implicit conversions.
  - type switch is desugared and uses "Cast"

R=jgruber@chromium.org, tebbi@chromium.org

Change-Id: I085f1a393f93e501e6bbcaeacb0d6568259a4714
Reviewed-on: https://chromium-review.googlesource.com/1219629
Commit-Queue: Simon Zünd <szuend@google.com>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55794}
parent 44202a1b
......@@ -4,7 +4,7 @@
module array {
macro ConvertToRelativeIndex(index: Number, length: Number): Number {
return index < 0 ? max(index + length, 0) : min(index, length);
return index < 0 ? Max(index + length, 0) : Min(index, length);
}
// https://tc39.github.io/ecma262/#sec-array.prototype.copyWithin
......@@ -17,32 +17,32 @@ module array {
const length: Number = GetLengthProperty(context, object);
// 3. Let relativeTarget be ? ToInteger(target).
const relative_target: Number = ToInteger_Inline(context, arguments[0]);
const relativeTarget: Number = ToInteger_Inline(context, arguments[0]);
// 4. If relativeTarget < 0, let to be max((len + relativeTarget), 0);
// else let to be min(relativeTarget, len).
let to: Number = ConvertToRelativeIndex(relative_target, length);
let to: Number = ConvertToRelativeIndex(relativeTarget, length);
// 5. Let relativeStart be ? ToInteger(start).
const relative_start: Number = ToInteger_Inline(context, arguments[1]);
const relativeStart: Number = ToInteger_Inline(context, arguments[1]);
// 6. If relativeStart < 0, let from be max((len + relativeStart), 0);
// else let from be min(relativeStart, len).
let from: Number = ConvertToRelativeIndex(relative_start, length);
let from: Number = ConvertToRelativeIndex(relativeStart, length);
// 7. If end is undefined, let relativeEnd be len;
// else let relativeEnd be ? ToInteger(end).
let relative_end: Number = length;
let relativeEnd: Number = length;
if (arguments[2] != Undefined) {
relative_end = ToInteger_Inline(context, arguments[2]);
relativeEnd = ToInteger_Inline(context, arguments[2]);
}
// 8. If relativeEnd < 0, let final be max((len + relativeEnd), 0);
// else let final be min(relativeEnd, len).
const final: Number = ConvertToRelativeIndex(relative_end, length);
const final: Number = ConvertToRelativeIndex(relativeEnd, length);
// 9. Let count be min(final-from, len-to).
let count: Number = min(final - from, length - to);
let count: Number = Min(final - from, length - to);
// 10. If from<to and to<from+count, then.
let direction: Number = 1;
......@@ -63,15 +63,15 @@ module array {
// a. Let fromKey be ! ToString(from).
// b. Let toKey be ! ToString(to).
// c. Let fromPresent be ? HasProperty(O, fromKey).
const from_present: Boolean = HasProperty(context, object, from);
const fromPresent: Boolean = HasProperty(context, object, from);
// d. If fromPresent is true, then.
if (from_present == True) {
if (fromPresent == True) {
// i. Let fromVal be ? Get(O, fromKey).
const from_val: Object = GetProperty(context, object, from);
const fromVal: Object = GetProperty(context, object, from);
// ii. Perform ? Set(O, toKey, fromVal, true).
SetProperty(context, object, to, from_val);
SetProperty(context, object, to, fromVal);
} else {
// i. Perform ? DeletePropertyOrThrow(O, toKey).
DeleteProperty(context, object, to, kStrict);
......
......@@ -5,10 +5,10 @@
module array {
macro ArrayForEachTorqueContinuation(
context: Context, o: JSReceiver, len: Number, callbackfn: Callable,
thisArg: Object, initial_k: Number): Object {
thisArg: Object, initialK: Number): Object {
// 5. Let k be 0.
// 6. Repeat, while k < len
for (let k: Number = initial_k; k < len; k = k + 1) {
for (let k: Number = initialK; k < len; k = k + 1) {
// 6a. Let Pk be ! ToString(k).
// k is guaranteed to be a positive integer, hence ToString is
// side-effect free and HasProperty/GetProperty do the conversion inline.
......@@ -33,10 +33,10 @@ module array {
javascript builtin ArrayForEachLoopEagerDeoptContinuation(
context: Context, receiver: Object, callback: Object, thisArg: Object,
initialK: Object, length: Object): Object {
// The unsafe cast is safe because all continuation points in forEach are
// The unsafe Cast is safe because all continuation points in forEach are
// after the ToObject(O) call that ensures we are dealing with a
// JSReceiver.
const jsreceiver: JSReceiver = unsafe_cast<JSReceiver>(receiver);
const jsreceiver: JSReceiver = UnsafeCast<JSReceiver>(receiver);
return ArrayForEachLoopContinuation(
context, jsreceiver, callback, thisArg, Undefined, jsreceiver, initialK,
length, Undefined);
......@@ -45,10 +45,10 @@ module array {
javascript builtin ArrayForEachLoopLazyDeoptContinuation(
context: Context, receiver: Object, callback: Object, thisArg: Object,
initialK: Object, length: Object, result: Object): Object {
// The unsafe cast is safe because all continuation points in forEach are
// The unsafe Cast is safe because all continuation points in forEach are
// after the ToObject(O) call that ensures we are dealing with a
// JSReceiver.
const jsreceiver: JSReceiver = unsafe_cast<JSReceiver>(receiver);
const jsreceiver: JSReceiver = UnsafeCast<JSReceiver>(receiver);
return ArrayForEachLoopContinuation(
context, jsreceiver, callback, thisArg, Undefined, jsreceiver, initialK,
length, Undefined);
......@@ -60,12 +60,12 @@ module array {
to: Object): Object {
try {
const callbackfn: Callable =
cast<Callable>(callback) otherwise Unexpected;
const k: Number = cast<Number>(initialK) otherwise Unexpected;
const number_length: Number = cast<Number>(length) otherwise Unexpected;
Cast<Callable>(callback) otherwise Unexpected;
const k: Number = Cast<Number>(initialK) otherwise Unexpected;
const numberLength: Number = Cast<Number>(length) otherwise Unexpected;
return ArrayForEachTorqueContinuation(
context, receiver, number_length, callbackfn, thisArg, k);
context, receiver, numberLength, callbackfn, thisArg, k);
}
label Unexpected {
unreachable;
......@@ -112,8 +112,8 @@ module array {
Bailout(Smi) {
let k: Smi = 0;
try {
const smi_len: Smi = cast<Smi>(len) otherwise Slow;
const a: JSArray = cast<JSArray>(o) otherwise Slow;
const smiLen: Smi = Cast<Smi>(len) otherwise Slow;
const a: JSArray = Cast<JSArray>(o) otherwise Slow;
const map: Map = a.map;
if (!IsPrototypeInitialArrayPrototype(context, map)) goto Slow;
......@@ -122,10 +122,10 @@ module array {
if (IsElementsKindGreaterThan(elementsKind, HOLEY_ELEMENTS)) {
VisitAllElements<FixedDoubleArray>(
context, a, smi_len, callbackfn, thisArg)
context, a, smiLen, callbackfn, thisArg)
otherwise Bailout;
} else {
VisitAllElements<FixedArray>(context, a, smi_len, callbackfn, thisArg)
VisitAllElements<FixedArray>(context, a, smiLen, callbackfn, thisArg)
otherwise Bailout;
}
}
......@@ -154,7 +154,7 @@ module array {
goto TypeError;
}
const callbackfn: Callable =
cast<Callable>(arguments[0]) otherwise TypeError;
Cast<Callable>(arguments[0]) otherwise TypeError;
// 4. If thisArg is present, let T be thisArg; else let T be undefined.
const thisArg: Object = arguments.length > 1 ? arguments[1] : Undefined;
......@@ -165,8 +165,8 @@ module array {
return FastArrayForEach(context, o, len, callbackfn, thisArg)
otherwise Bailout;
}
label Bailout(k_value: Smi) {
k = k_value;
label Bailout(kValue: Smi) {
k = kValue;
}
return ArrayForEachTorqueContinuation(
......
......@@ -9,7 +9,7 @@ module array {
LoadWithHoleCheck<FixedArray>(elements: FixedArrayBase, index: Smi): Object
labels IfHole {
const elements: FixedArray = unsafe_cast<FixedArray>(elements);
const elements: FixedArray = UnsafeCast<FixedArray>(elements);
const element: Object = elements[index];
if (element == Hole) goto IfHole;
return element;
......@@ -18,7 +18,7 @@ module array {
LoadWithHoleCheck<FixedDoubleArray>(
elements: FixedArrayBase, index: Smi): Object
labels IfHole {
const elements: FixedDoubleArray = unsafe_cast<FixedDoubleArray>(elements);
const elements: FixedDoubleArray = UnsafeCast<FixedDoubleArray>(elements);
const element: float64 = LoadDoubleWithHoleCheck(elements, index)
otherwise IfHole;
return AllocateHeapNumberWithValue(element);
......@@ -63,7 +63,7 @@ module array {
if (n >= 0) {
// a. If n is -0, let k be +0; else let k be min(n, len - 1).
// If n was -0 it got truncated to 0.0, so taking the minimum is fine.
k = min(n, length - 1);
k = Min(n, length - 1);
} else {
// a. Let k be len + n.
k = length + n;
......@@ -76,12 +76,12 @@ module array {
from: Number): Object
labels Slow {
EnsureFastJSArray(context, receiver) otherwise Slow;
const array: JSArray = unsafe_cast<JSArray>(receiver);
const array: JSArray = UnsafeCast<JSArray>(receiver);
const length: Smi = array.length_fast;
if (length == 0) return SmiConstant(-1);
const fromSmi: Smi = cast<Smi>(from) otherwise Slow;
const fromSmi: Smi = Cast<Smi>(from) otherwise Slow;
const kind: ElementsKind = array.map.elements_kind;
if (IsFastSmiOrTaggedElementsKind(kind)) {
return FastArrayLastIndexOf<FixedArray>(
......@@ -100,10 +100,10 @@ module array {
// 7. Repeat, while k >= 0.
while (k >= 0) {
// a. Let kPresent be ? HasProperty(O, ! ToString(k)).
const k_present: Boolean = HasProperty(context, object, k);
const kPresent: Boolean = HasProperty(context, object, k);
// b. If kPresent is true, then.
if (k_present == True) {
if (kPresent == True) {
// i. Let elementK be ? Get(O, ! ToString(k)).
const element: Object = GetProperty(context, object, k);
......
......@@ -8,20 +8,20 @@ module array {
LoadElement<FastPackedSmiElements, Smi>(
elements: FixedArrayBase, index: Smi): Smi {
const elems: FixedArray = unsafe_cast<FixedArray>(elements);
return unsafe_cast<Smi>(elems[index]);
const elems: FixedArray = UnsafeCast<FixedArray>(elements);
return UnsafeCast<Smi>(elems[index]);
}
LoadElement<FastPackedObjectElements, Object>(
elements: FixedArrayBase, index: Smi): Object {
const elems: FixedArray = unsafe_cast<FixedArray>(elements);
const elems: FixedArray = UnsafeCast<FixedArray>(elements);
return elems[index];
}
LoadElement<FastPackedDoubleElements, float64>(
elements: FixedArrayBase, index: Smi): float64 {
try {
const elems: FixedDoubleArray = unsafe_cast<FixedDoubleArray>(elements);
const elems: FixedDoubleArray = UnsafeCast<FixedDoubleArray>(elements);
return LoadDoubleWithHoleCheck(elems, index) otherwise Hole;
}
label Hole {
......@@ -36,19 +36,19 @@ module array {
StoreElement<FastPackedSmiElements, Smi>(
elements: FixedArrayBase, index: Smi, value: Smi) {
const elems: FixedArray = unsafe_cast<FixedArray>(elements);
const elems: FixedArray = UnsafeCast<FixedArray>(elements);
StoreFixedArrayElementSmi(elems, index, value, SKIP_WRITE_BARRIER);
}
StoreElement<FastPackedObjectElements, Object>(
elements: FixedArrayBase, index: Smi, value: Object) {
const elems: FixedArray = unsafe_cast<FixedArray>(elements);
const elems: FixedArray = UnsafeCast<FixedArray>(elements);
elems[index] = value;
}
StoreElement<FastPackedDoubleElements, float64>(
elements: FixedArrayBase, index: Smi, value: float64) {
const elems: FixedDoubleArray = unsafe_cast<FixedDoubleArray>(elements);
const elems: FixedDoubleArray = UnsafeCast<FixedDoubleArray>(elements);
assert(value == Float64SilenceNaN(value));
StoreFixedDoubleArrayElementWithSmiIndex(elems, index, value);
......@@ -63,10 +63,10 @@ module array {
let upper: Smi = length - 1;
while (lower < upper) {
const lower_value: T = LoadElement<Accessor, T>(elements, lower);
const upper_value: T = LoadElement<Accessor, T>(elements, upper);
StoreElement<Accessor, T>(elements, lower, upper_value);
StoreElement<Accessor, T>(elements, upper, lower_value);
const lowerValue: T = LoadElement<Accessor, T>(elements, lower);
const upperValue: T = LoadElement<Accessor, T>(elements, upper);
StoreElement<Accessor, T>(elements, lower, upperValue);
StoreElement<Accessor, T>(elements, upper, lowerValue);
++lower;
--upper;
}
......@@ -90,48 +90,48 @@ module array {
let upper: Number = length - 1;
while (lower < upper) {
let lower_value: Object = Undefined;
let upper_value: Object = Undefined;
let lowerValue: Object = Undefined;
let upperValue: Object = Undefined;
// b. Let upperP be ! ToString(upper).
// c. Let lowerP be ! ToString(lower).
// d. Let lowerExists be ? HasProperty(O, lowerP).
const lower_exists: Boolean = HasProperty(context, object, lower);
const lowerExists: Boolean = HasProperty(context, object, lower);
// e. If lowerExists is true, then.
if (lower_exists == True) {
if (lowerExists == True) {
// i. Let lowerValue be ? Get(O, lowerP).
lower_value = GetProperty(context, object, lower);
lowerValue = GetProperty(context, object, lower);
}
// f. Let upperExists be ? HasProperty(O, upperP).
const upper_exists: Boolean = HasProperty(context, object, upper);
const upperExists: Boolean = HasProperty(context, object, upper);
// g. If upperExists is true, then.
if (upper_exists == True) {
if (upperExists == True) {
// i. Let upperValue be ? Get(O, upperP).
upper_value = GetProperty(context, object, upper);
upperValue = GetProperty(context, object, upper);
}
// h. If lowerExists is true and upperExists is true, then
if (lower_exists == True && upper_exists == True) {
if (lowerExists == True && upperExists == True) {
// i. Perform ? Set(O, lowerP, upperValue, true).
SetProperty(context, object, lower, upper_value);
SetProperty(context, object, lower, upperValue);
// ii. Perform ? Set(O, upperP, lowerValue, true).
SetProperty(context, object, upper, lower_value);
} else if (lower_exists == False && upper_exists == True) {
SetProperty(context, object, upper, lowerValue);
} else if (lowerExists == False && upperExists == True) {
// i. Perform ? Set(O, lowerP, upperValue, true).
SetProperty(context, object, lower, upper_value);
SetProperty(context, object, lower, upperValue);
// ii. Perform ? DeletePropertyOrThrow(O, upperP).
DeleteProperty(context, object, upper, kStrict);
} else if (lower_exists == True && upper_exists == False) {
} else if (lowerExists == True && upperExists == False) {
// i. Perform ? DeletePropertyOrThrow(O, lowerP).
DeleteProperty(context, object, lower, kStrict);
// ii. Perform ? Set(O, upperP, lowerValue, true).
SetProperty(context, object, upper, lower_value);
SetProperty(context, object, upper, lowerValue);
}
// l. Increase lower by 1.
......@@ -144,7 +144,7 @@ module array {
}
macro TryFastPackedArrayReverse(receiver: Object) labels Slow {
const array: JSArray = cast<JSArray>(receiver) otherwise Slow;
const array: JSArray = Cast<JSArray>(receiver) otherwise Slow;
const kind: ElementsKind = array.map.elements_kind;
if (kind == PACKED_SMI_ELEMENTS) {
......
......@@ -10,7 +10,7 @@ module array {
macro Extract<FixedArrayType : type>(
elements: FixedArrayBase, first: Smi, count: Smi,
capacity: Smi): FixedArrayType {
return unsafe_cast<FixedArrayType>(
return UnsafeCast<FixedArrayType>(
ExtractFixedArray(elements, first, count, capacity));
}
......@@ -18,9 +18,9 @@ module array {
elements: FixedArrayBase, first: Smi, count: Smi,
capacity: Smi): FixedDoubleArray {
if (elements == kEmptyFixedArray) {
return AllocateZeroedFixedDoubleArray(convert<intptr>(capacity));
return AllocateZeroedFixedDoubleArray(Convert<intptr>(capacity));
}
return unsafe_cast<FixedDoubleArray>(
return UnsafeCast<FixedDoubleArray>(
ExtractFixedArray(elements, first, count, capacity));
}
......@@ -47,11 +47,11 @@ module array {
let k: Smi = actualStart;
if (insertCount > 0) {
const typedNewElements: FixedArrayType =
unsafe_cast<FixedArrayType>(newElements);
UnsafeCast<FixedArrayType>(newElements);
for (let e: Object of args [2: ]) {
// The argument elements were already validated to be an appropriate
// {ElementType} to store in {FixedArrayType}.
typedNewElements[k++] = unsafe_cast<ElementType>(e);
typedNewElements[k++] = UnsafeCast<ElementType>(e);
}
}
......@@ -59,9 +59,9 @@ module array {
let count: Smi = length - actualStart - actualDeleteCount;
while (count > 0) {
const typedElements: FixedArrayType =
unsafe_cast<FixedArrayType>(elements);
UnsafeCast<FixedArrayType>(elements);
const typedNewElements: FixedArrayType =
unsafe_cast<FixedArrayType>(newElements);
UnsafeCast<FixedArrayType>(newElements);
CopyArrayElement(typedElements, typedNewElements, k - lengthDelta, k);
k++;
count--;
......@@ -72,7 +72,7 @@ module array {
// is pre-filled with holes.
if (elements == newElements) {
const typedNewElements: FixedArrayType =
unsafe_cast<FixedArrayType>(newElements);
UnsafeCast<FixedArrayType>(newElements);
const limit: Smi = elements.length;
while (k < limit) {
StoreArrayHole(typedNewElements, k);
......@@ -90,14 +90,14 @@ module array {
actualDeleteCountNumber: Number): Object
labels Bailout {
const originalLength: Smi =
cast<Smi>(originalLengthNumber) otherwise Bailout;
const actualStart: Smi = cast<Smi>(actualStartNumber) otherwise Bailout;
Cast<Smi>(originalLengthNumber) otherwise Bailout;
const actualStart: Smi = Cast<Smi>(actualStartNumber) otherwise Bailout;
const actualDeleteCount: Smi =
cast<Smi>(actualDeleteCountNumber) otherwise Bailout;
Cast<Smi>(actualDeleteCountNumber) otherwise Bailout;
const lengthDelta: Smi = insertCount - actualDeleteCount;
const newLength: Smi = originalLength + lengthDelta;
const a: JSArray = cast<JSArray>(o) otherwise Bailout;
const a: JSArray = Cast<JSArray>(o) otherwise Bailout;
const map: Map = a.map;
if (!IsPrototypeInitialArrayPrototype(context, map)) goto Bailout;
......@@ -112,7 +112,7 @@ module array {
for (let e: Object of args [2: ]) {
if (IsFastSmiElementsKind(elementsKind)) {
if (TaggedIsNotSmi(e)) {
const heapObject: HeapObject = unsafe_cast<HeapObject>(e);
const heapObject: HeapObject = UnsafeCast<HeapObject>(e);
elementsKind = IsHeapNumber(heapObject) ?
AllowDoubleElements(elementsKind) :
AllowNonNumberElements(elementsKind);
......@@ -125,12 +125,12 @@ module array {
}
if (elementsKind != oldElementsKind) {
const smi_elements_kind: Smi = convert<Smi>(convert<int32>(elementsKind));
TransitionElementsKindWithKind(context, a, smi_elements_kind);
const smiElementsKind: Smi = Convert<Smi>(Convert<int32>(elementsKind));
TransitionElementsKindWithKind(context, a, smiElementsKind);
}
// Make sure that the length hasn't been changed by side-effect.
const length: Smi = cast<Smi>(a.length) otherwise Bailout;
const length: Smi = Cast<Smi>(a.length) otherwise Bailout;
if (originalLength != length) goto Bailout;
const deletedResult: JSArray =
......@@ -343,8 +343,8 @@ module array {
// 0);
// else let actualStart be min(relativeStart, len).
const actualStart: Number = relativeStart < 0 ?
max((len + relativeStart), 0) :
min(relativeStart, len);
Max((len + relativeStart), 0) :
Min(relativeStart, len);
let insertCount: Smi;
let actualDeleteCount: Number;
......@@ -363,18 +363,18 @@ module array {
// 7. Else,
} else {
// a. Let insertCount be the Number of actual arguments minus 2.
insertCount = convert<Smi>(arguments.length) - 2;
insertCount = Convert<Smi>(arguments.length) - 2;
// b. Let dc be ? ToInteger(deleteCount).
const deleteCount: Object = arguments[1];
const dc: Number = ToInteger_Inline(context, deleteCount);
// c. Let actualDeleteCount be min(max(dc, 0), len - actualStart).
actualDeleteCount = min(max(dc, 0), len - actualStart);
actualDeleteCount = Min(Max(dc, 0), len - actualStart);
}
// 8. If len + insertCount - actualDeleteCount > 2^53-1, throw a
// Bailout exception.
const new_length: Number = len + insertCount - actualDeleteCount;
if (new_length > kMaxSafeInteger) {
const newLength: Number = len + insertCount - actualDeleteCount;
if (newLength > kMaxSafeInteger) {
ThrowTypeError(context, kInvalidArrayLength, start);
}
......
......@@ -9,7 +9,7 @@ module array {
context: Context, receiver: Object, arguments: constexpr Arguments): never
labels Slow {
EnsureFastJSArray(context, receiver) otherwise Slow;
const array: JSArray = unsafe_cast<JSArray>(receiver);
const array: JSArray = UnsafeCast<JSArray>(receiver);
EnsureWriteableFastElements(array);
const map: Map = array.map;
......@@ -18,7 +18,7 @@ module array {
tail ArrayUnshift(
context, LoadTargetFromFrame(), Undefined,
convert<int32>(arguments.length));
Convert<int32>(arguments.length));
}
macro GenericArrayUnshift(
......@@ -31,12 +31,12 @@ module array {
const length: Number = GetLengthProperty(context, object);
// 3. Let argCount be the number of actual arguments.
const arg_count: Smi = convert<Smi>(arguments.length);
const argCount: Smi = Convert<Smi>(arguments.length);
// 4. If argCount > 0, then.
if (arg_count > 0) {
if (argCount > 0) {
// a. If len + argCount > 2**53 - 1, throw a TypeError exception.
if (length + arg_count > kMaxSafeInteger) {
if (length + argCount > kMaxSafeInteger) {
ThrowTypeError(context, kInvalidArrayLength);
}
......@@ -49,18 +49,18 @@ module array {
const from: Number = k - 1;
// ii. Let to be ! ToString(k + argCount - 1).
const to: Number = k + arg_count - 1;
const to: Number = k + argCount - 1;
// iii. Let fromPresent be ? HasProperty(O, from).
const from_present: Boolean = HasProperty(context, object, from);
const fromPresent: Boolean = HasProperty(context, object, from);
// iv. If fromPresent is true, then
if (from_present == True) {
if (fromPresent == True) {
// 1. Let fromValue be ? Get(O, from).
const from_value: Object = GetProperty(context, object, from);
const fromValue: Object = GetProperty(context, object, from);
// 2. Perform ? Set(O, to, fromValue, true).
SetProperty(context, object, to, from_value);
SetProperty(context, object, to, fromValue);
} else {
// 1. Perform ? DeletePropertyOrThrow(O, to).
DeleteProperty(context, object, to, kStrict);
......@@ -76,9 +76,9 @@ module array {
// e. Let items be a List whose elements are, in left to right order,
// the arguments that were passed to this function invocation.
// f. Repeat, while items is not empty
while (j < arg_count) {
while (j < argCount) {
// ii .Perform ? Set(O, ! ToString(j), E, true).
SetProperty(context, object, j, arguments[convert<intptr>(j)]);
SetProperty(context, object, j, arguments[Convert<intptr>(j)]);
// iii. Increase j by 1.
++j;
......@@ -86,11 +86,11 @@ module array {
}
// 5. Perform ? Set(O, "length", len + argCount, true).
const new_length: Number = length + arg_count;
SetProperty(context, object, kLengthString, new_length);
const newLength: Number = length + argCount;
SetProperty(context, object, kLengthString, newLength);
// 6. Return length + arg_count.
return new_length;
// 6. Return length + argCount.
return newLength;
}
// https://tc39.github.io/ecma262/#sec-array.prototype.unshift
......
......@@ -16,7 +16,7 @@ module array {
macro GetLengthProperty(context: Context, o: Object): Number {
if (BranchIfFastJSArray(o, context)) {
const a: JSArray = unsafe_cast<JSArray>(o);
const a: JSArray = UnsafeCast<JSArray>(o);
return a.length_fast;
} else
deferred {
......@@ -42,7 +42,7 @@ module array {
macro IsJSArray(o: Object): bool {
try {
const array: JSArray = cast<JSArray>(o) otherwise NotArray;
const array: JSArray = Cast<JSArray>(o) otherwise NotArray;
return true;
}
label NotArray {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -15,7 +15,7 @@ namespace v8 {
namespace internal {
namespace torque {
static constexpr const char* const kFromConstexprMacroName = "from_constexpr";
static constexpr const char* const kFromConstexprMacroName = "FromConstexpr";
static constexpr const char* kTrueLabelName = "_True";
static constexpr const char* kFalseLabelName = "_False";
......
......@@ -557,7 +557,7 @@ base::Optional<ParseResult> MakeTypeswitchStatement(
BlockStatement* case_block;
if (i < cases.size() - 1) {
value = MakeNode<CallExpression>(
"cast", false, std::vector<TypeExpression*>{cases[i].type},
"Cast", false, std::vector<TypeExpression*>{cases[i].type},
std::vector<Expression*>{value},
std::vector<std::string>{"_NextCase"});
case_block = MakeNode<BlockStatement>();
......
......@@ -36,7 +36,7 @@ module test {
}
macro TestConstexpr1() {
check(from_constexpr<bool>(IsFastElementsKind(PACKED_SMI_ELEMENTS)));
check(FromConstexpr<bool>(IsFastElementsKind(PACKED_SMI_ELEMENTS)));
}
macro TestConstexprIf() {
......@@ -46,10 +46,10 @@ module test {
}
macro TestConstexprReturn() {
check(from_constexpr<bool>(ElementsKindTestHelper3(UINT8_ELEMENTS)));
check(from_constexpr<bool>(ElementsKindTestHelper3(UINT16_ELEMENTS)));
check(!from_constexpr<bool>(ElementsKindTestHelper3(UINT32_ELEMENTS)));
check(from_constexpr<bool>(!ElementsKindTestHelper3(UINT32_ELEMENTS)));
check(FromConstexpr<bool>(ElementsKindTestHelper3(UINT8_ELEMENTS)));
check(FromConstexpr<bool>(ElementsKindTestHelper3(UINT16_ELEMENTS)));
check(!FromConstexpr<bool>(ElementsKindTestHelper3(UINT32_ELEMENTS)));
check(FromConstexpr<bool>(!ElementsKindTestHelper3(UINT32_ELEMENTS)));
}
macro TestGotoLabel(): Boolean {
......@@ -177,8 +177,8 @@ module test {
}
macro TestVariableRedeclaration(context: Context): Boolean {
let var1: int31 = from_constexpr<bool>(42 == 0) ? 0 : 1;
let var2: int31 = from_constexpr<bool>(42 == 0) ? 1 : 0;
let var1: int31 = FromConstexpr<bool>(42 == 0) ? 0 : 1;
let var2: int31 = FromConstexpr<bool>(42 == 0) ? 1 : 0;
return True;
}
......@@ -204,7 +204,7 @@ module test {
macro TestUnsafeCast(c: Context, n: Number): Boolean {
if (TaggedIsSmi(n)) {
let m: Smi = unsafe_cast<Smi>(n);
let m: Smi = UnsafeCast<Smi>(n);
check(TestHelperPlus1(c, m) == 11);
return True;
......@@ -213,8 +213,8 @@ module test {
}
macro TestHexLiteral() {
check(convert<intptr>(0xffff) + 1 == 0x10000);
check(convert<intptr>(-0xffff) == -65535);
check(Convert<intptr>(0xffff) + 1 == 0x10000);
check(Convert<intptr>(-0xffff) == -65535);
}
macro TestLargeIntegerLiterals(c: Context) {
......@@ -245,16 +245,16 @@ module test {
macro TestLocalConstBindings() {
const x : constexpr int31 = 3;
const x_smi : Smi = x;
const xSmi : Smi = x;
{
const x : Smi = x + from_constexpr<Smi>(1);
check(x == x_smi + 1);
const x_smi : Smi = x;
check(x == x_smi);
const x : Smi = x + FromConstexpr<Smi>(1);
check(x == xSmi + 1);
const xSmi : Smi = x;
check(x == xSmi);
check(x == 4);
}
check(x_smi == 3);
check(x == x_smi);
check(xSmi == 3);
check(x == xSmi);
}
struct TestStructA {
......@@ -273,12 +273,12 @@ module test {
}
macro TestStruct2(): TestStructA {
return TestStructA{unsafe_cast<FixedArray>(kEmptyFixedArray), 27, 31};
return TestStructA{UnsafeCast<FixedArray>(kEmptyFixedArray), 27, 31};
}
macro TestStruct3(): TestStructA {
let a: TestStructA =
TestStructA{unsafe_cast<FixedArray>(kEmptyFixedArray), 13, 5};
TestStructA{UnsafeCast<FixedArray>(kEmptyFixedArray), 13, 5};
let b: TestStructA = a;
let c: TestStructA = TestStruct2();
a.i = TestStruct1(c);
......@@ -287,7 +287,7 @@ module test {
d.x = a;
d = TestStructB{a, 7};
let e: TestStructA = d.x;
let f: Smi = TestStructA{unsafe_cast<FixedArray>(kEmptyFixedArray), 27, 31}.i;
let f: Smi = TestStructA{UnsafeCast<FixedArray>(kEmptyFixedArray), 27, 31}.i;
f = TestStruct2().i;
return a;
}
......@@ -415,9 +415,9 @@ module test {
typeswitch (IncrementIfSmi<(Number|FixedArray)>(x)) {
case (x : Smi) {
result = result + convert<int32>(x);
result = result + Convert<int32>(x);
} case (a : FixedArray) {
result = result + convert<int32>(a.length);
result = result + Convert<int32>(a.length);
} case (x : HeapNumber) {
result = result + 7;
}
......@@ -427,10 +427,10 @@ module test {
}
macro TestTypeswitch() {
check(TypeswitchExample(from_constexpr<Smi>(5)) == 26);
check(TypeswitchExample(FromConstexpr<Smi>(5)) == 26);
const a : FixedArray = AllocateZeroedFixedArray(3);
check(TypeswitchExample(a) == 13);
check(TypeswitchExample(from_constexpr<Number>(0.5)) == 27);
check(TypeswitchExample(FromConstexpr<Number>(0.5)) == 27);
}
macro ExampleGenericOverload<A: type>(o : Object) : A {
......@@ -441,10 +441,10 @@ module test {
}
macro TestGenericOverload() {
const x_smi : Smi = 5;
const x_object : Object = x_smi;
check(ExampleGenericOverload<Smi>(x_smi) == 6);
check(unsafe_cast<Smi>(ExampleGenericOverload<Object>(x_object)) == 5);
const xSmi : Smi = 5;
const xObject : Object = xSmi;
check(ExampleGenericOverload<Smi>(xSmi) == 6);
check(UnsafeCast<Smi>(ExampleGenericOverload<Object>(xObject)) == 5);
}
macro BoolToBranch(x : bool) : never labels Taken, NotTaken {
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment