Commit e0c1ca5a authored by Tobias Tebbi's avatar Tobias Tebbi Committed by Commit Bot

[torque] fix formatting of union types

The Torque formatter script did a hack to put spaces arount the | of
union types. This was broken when the inserted comment ended up on the
end of a line. For this reason, and since it doesn't make sense to
fight the Google-wide TypeScript style for union types, this CL reverts
to not putting spaces around union types.

Bug: v8:7793
Change-Id: Ic0acf9e1da82540432a8e21b58497a6a7d523b9c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1871604
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Reviewed-by: 's avatarJoshua Litt <joshualitt@chromium.org>
Reviewed-by: 's avatarMichael Stanton <mvstanton@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64536}
parent 38da4d19
......@@ -67,7 +67,7 @@ namespace array {
transitioning builtin ArrayReduceRightLoopContinuation(implicit context:
Context)(
_receiver: JSReceiver, callbackfn: Callable,
initialAccumulator: JSAny | TheHole, o: JSReceiver, initialK: Number,
initialAccumulator: JSAny|TheHole, o: JSReceiver, initialK: Number,
_length: Number): JSAny {
let accumulator = initialAccumulator;
......@@ -118,8 +118,8 @@ namespace array {
transitioning macro FastArrayReduceRight(implicit context: Context)(
o: JSReceiver, len: Number, callbackfn: Callable,
initialAccumulator: JSAny | TheHole): JSAny
labels Bailout(Number, JSAny | TheHole) {
initialAccumulator: JSAny|TheHole): JSAny
labels Bailout(Number, JSAny|TheHole) {
let accumulator = initialAccumulator;
const smiLen = Cast<Smi>(len) otherwise goto Bailout(len - 1, accumulator);
const fastO = Cast<FastJSArrayForRead>(o)
......@@ -178,14 +178,14 @@ namespace array {
// exception. (This case is handled at the end of
// ArrayReduceRightLoopContinuation).
const initialValue: JSAny | TheHole =
const initialValue: JSAny|TheHole =
arguments.length > 1 ? arguments[1] : TheHole;
try {
return FastArrayReduceRight(o, len, callbackfn, initialValue)
otherwise Bailout;
}
label Bailout(value: Number, accumulator: JSAny | TheHole) {
label Bailout(value: Number, accumulator: JSAny|TheHole) {
return ArrayReduceRightLoopContinuation(
o, callbackfn, accumulator, o, value, len);
}
......
......@@ -66,7 +66,7 @@ namespace array {
transitioning builtin ArrayReduceLoopContinuation(implicit context: Context)(
_receiver: JSReceiver, callbackfn: Callable,
initialAccumulator: JSAny | TheHole, o: JSReceiver, initialK: Number,
initialAccumulator: JSAny|TheHole, o: JSReceiver, initialK: Number,
length: Number): JSAny {
let accumulator = initialAccumulator;
......@@ -117,8 +117,8 @@ namespace array {
transitioning macro FastArrayReduce(implicit context: Context)(
o: JSReceiver, len: Number, callbackfn: Callable,
initialAccumulator: JSAny | TheHole): JSAny
labels Bailout(Number, JSAny | TheHole) {
initialAccumulator: JSAny|TheHole): JSAny
labels Bailout(Number, JSAny|TheHole) {
const k = 0;
let accumulator = initialAccumulator;
Cast<Smi>(len) otherwise goto Bailout(k, accumulator);
......@@ -178,14 +178,14 @@ namespace array {
// exception. (This case is handled at the end of
// ArrayReduceLoopContinuation).
const initialValue: JSAny | TheHole =
const initialValue: JSAny|TheHole =
arguments.length > 1 ? arguments[1] : TheHole;
try {
return FastArrayReduce(o, len, callbackfn, initialValue)
otherwise Bailout;
}
label Bailout(value: Number, accumulator: JSAny | TheHole) {
label Bailout(value: Number, accumulator: JSAny|TheHole) {
return ArrayReduceLoopContinuation(
o, callbackfn, accumulator, o, value, len);
}
......
This diff is collapsed.
......@@ -33,8 +33,8 @@ type FrameBase extends RawPtr constexpr 'void*';
type StandardFrame extends FrameBase constexpr 'void*';
type ArgumentsAdaptorFrame extends FrameBase constexpr 'void*';
type StubFrame extends FrameBase constexpr 'void*';
type FrameWithArguments = StandardFrame | ArgumentsAdaptorFrame;
type Frame = FrameWithArguments | StubFrame;
type FrameWithArguments = StandardFrame|ArgumentsAdaptorFrame;
type Frame = FrameWithArguments|StubFrame;
extern macro LoadFramePointer(): Frame;
extern macro LoadParentFramePointer(): Frame;
......@@ -67,7 +67,7 @@ operator '.caller' macro LoadCallerFromFrame(f: Frame): Frame {
return %RawDownCast<Frame>(result);
}
type ContextOrFrameType = Context | FrameType;
type ContextOrFrameType = Context|FrameType;
Cast<ContextOrFrameType>(implicit context: Context)(o: Object):
ContextOrFrameType
labels CastError {
......
......@@ -48,7 +48,7 @@ namespace iterator {
transitioning builtin GetIteratorWithFeedback(
context: Context, receiver: JSAny, loadSlot: Smi, callSlot: Smi,
feedback: Undefined | FeedbackVector): JSAny {
feedback: Undefined|FeedbackVector): JSAny {
let iteratorMethod: JSAny;
typeswitch (feedback) {
case (Undefined): {
......@@ -65,7 +65,7 @@ namespace iterator {
transitioning builtin CallIteratorWithFeedback(
context: Context, receiver: JSAny, iteratorMethod: JSAny, callSlot: Smi,
feedback: Undefined | FeedbackVector): JSAny {
feedback: Undefined|FeedbackVector): JSAny {
const callSlotUnTagged: uintptr = Unsigned(SmiUntag(callSlot));
CollectCallFeedback(iteratorMethod, context, feedback, callSlotUnTagged);
const iteratorCallable: Callable = Cast<Callable>(iteratorMethod)
......
......@@ -72,7 +72,7 @@ namespace object {
transitioning macro
ObjectSetPrototypeOfThrow(implicit context: Context)(
object: JSAny, proto: JSReceiver | Null): JSAny {
object: JSAny, proto: JSReceiver|Null): JSAny {
const objectJSReceiver = Cast<JSReceiver>(object) otherwise return object;
const objectJSProxy = Cast<JSProxy>(objectJSReceiver)
otherwise return runtime::JSReceiverSetPrototypeOfThrow(
......@@ -83,7 +83,7 @@ namespace object {
transitioning macro
ObjectSetPrototypeOfDontThrow(implicit context: Context)(
object: JSAny, proto: JSReceiver | Null): JSAny {
object: JSAny, proto: JSReceiver|Null): JSAny {
const objectJSReceiver = Cast<JSReceiver>(object) otherwise return False;
const objectJSProxy = Cast<JSProxy>(objectJSReceiver)
otherwise return runtime::JSReceiverSetPrototypeOfDontThrow(
......@@ -122,7 +122,7 @@ namespace object {
// 5. If status is false, throw a TypeError exception.
// 6. Return O.
typeswitch (proto) {
case (proto: JSReceiver | Null): {
case (proto: JSReceiver|Null): {
return object::ObjectSetPrototypeOfThrow(object, proto);
}
case (JSAny): {
......
......@@ -7,8 +7,9 @@
// https://tc39.es/ecma262/#sec-promise-abstract-operations
namespace promise {
extern macro PromiseBuiltinsAssembler::TriggerPromiseReactions(
implicit context: Context)(
Smi | PromiseReaction, JSAny, constexpr PromiseReactionType): void;
implicit context:
Context)(Smi|PromiseReaction, JSAny, constexpr PromiseReactionType):
void;
// https://tc39.es/ecma262/#sec-fulfillpromise
transitioning builtin
......
......@@ -19,7 +19,7 @@ namespace proxy {
// https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-set-p-v-receiver
transitioning builtin
ProxySetProperty(implicit context: Context)(
proxy: JSProxy, name: PropertyKey | PrivateSymbol, value: JSAny,
proxy: JSProxy, name: PropertyKey|PrivateSymbol, value: JSAny,
receiverValue: JSAny): JSAny {
// 1. Assert: IsPropertyKey(P) is true.
assert(TaggedIsNotSmi(name));
......
......@@ -10,7 +10,7 @@ namespace proxy {
// https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-setprototypeof-v
transitioning builtin
ProxySetPrototypeOf(implicit context: Context)(
proxy: JSProxy, proto: Null | JSReceiver, doThrow: Boolean): JSAny {
proxy: JSProxy, proto: Null|JSReceiver, doThrow: Boolean): JSAny {
PerformStackCheck();
const kTrapName: constexpr string = 'setPrototypeOf';
try {
......@@ -63,7 +63,7 @@ namespace proxy {
}
ThrowTypeError(kProxySetPrototypeOfNonExtensible);
}
label TrapUndefined(target: JSAny, proto: JSReceiver | Null) {
label TrapUndefined(target: JSAny, proto: JSReceiver|Null) {
// 7.a. Return ? target.[[SetPrototypeOf]]().
if (doThrow == True) {
return object::ObjectSetPrototypeOfThrow(target, proto);
......
......@@ -37,7 +37,7 @@ namespace reflect {
const objectJSReceiver = Cast<JSReceiver>(object)
otherwise ThrowTypeError(kCalledOnNonObject, 'Reflect.setPrototypeOf');
typeswitch (proto) {
case (proto: JSReceiver | Null): {
case (proto: JSReceiver|Null): {
return object::ObjectSetPrototypeOfDontThrow(objectJSReceiver, proto);
}
case (JSAny): {
......
......@@ -10,7 +10,7 @@ namespace regexp {
SubString(implicit context: Context)(String, Smi, Smi): String;
extern runtime RegExpExecMultiple(implicit context: Context)(
JSRegExp, String, RegExpMatchInfo, JSArray): Null | JSArray;
JSRegExp, String, RegExpMatchInfo, JSArray): Null|JSArray;
extern transitioning runtime
RegExpReplaceRT(Context, JSReceiver, String, Object): String;
extern transitioning runtime
......@@ -86,7 +86,7 @@ namespace regexp {
const kInitialCapacity: Smi = 16;
const kInitialLength: Smi = 0;
const result: Null | JSArray = RegExpExecMultiple(
const result: Null|JSArray = RegExpExecMultiple(
regexp, string, GetRegExpLastMatchInfo(),
AllocateJSArray(
PACKED_ELEMENTS, GetFastPackedElementsJSArrayMap(),
......
......@@ -9,7 +9,7 @@ namespace typed_array {
transitioning macro ReduceAllElements(implicit context: Context)(
array: typed_array::AttachedJSTypedArray, callbackfn: Callable,
initialValue: JSAny | TheHole): JSAny {
initialValue: JSAny|TheHole): JSAny {
let witness = typed_array::NewAttachedJSTypedArrayWitness(array);
const length: uintptr = witness.Get().length;
let accumulator = initialValue;
......
......@@ -10,7 +10,7 @@ namespace typed_array {
transitioning macro ReduceRightAllElements(implicit context: Context)(
array: typed_array::AttachedJSTypedArray, callbackfn: Callable,
initialValue: JSAny | TheHole): JSAny {
initialValue: JSAny|TheHole): JSAny {
let witness = typed_array::NewAttachedJSTypedArrayWitness(array);
const length: uintptr = witness.Get().length;
let accumulator = initialValue;
......
......@@ -18,7 +18,7 @@ extern class JSDateTimeFormat extends JSObject {
icu_locale: Foreign; // Managed<icu::Locale>
icu_simple_date_format: Foreign; // Managed<icu::SimpleDateFormat>
icu_date_interval_format: Foreign; // Managed<icu::DateIntervalFormat>
bound_format: JSFunction | Undefined;
bound_format: JSFunction|Undefined;
flags: Smi;
}
......@@ -32,7 +32,7 @@ extern class JSNumberFormat extends JSObject {
locale: String;
icu_number_formatter:
Foreign; // Managed<icu::number::LocalizedNumberFormatter>
bound_format: JSFunction | Undefined;
bound_format: JSFunction|Undefined;
flags: Smi;
}
......@@ -70,15 +70,15 @@ extern class JSV8BreakIterator extends JSObject {
locale: String;
break_iterator: Foreign; // Managed<icu::BreakIterator>;
unicode_string: Foreign; // Managed<icu::UnicodeString>;
bound_adopt_text: Undefined | JSFunction;
bound_first: Undefined | JSFunction;
bound_next: Undefined | JSFunction;
bound_current: Undefined | JSFunction;
bound_break_type: Undefined | JSFunction;
bound_adopt_text: Undefined|JSFunction;
bound_first: Undefined|JSFunction;
bound_next: Undefined|JSFunction;
bound_current: Undefined|JSFunction;
bound_break_type: Undefined|JSFunction;
break_iterator_type: Smi;
}
extern class JSCollator extends JSObject {
icu_collator: Foreign; // Managed<icu::Collator>
bound_compare: Undefined | JSFunction;
bound_compare: Undefined|JSFunction;
}
......@@ -465,7 +465,7 @@ namespace test {
}
}
type NumberOrFixedArray = Number | FixedArray;
type NumberOrFixedArray = Number|FixedArray;
macro TypeswitchExample(implicit context: Context)(x: NumberOrFixedArray):
int32 {
let result: int32 = 0;
......
......@@ -47,7 +47,7 @@ namespace array {
initialReceiverLength: Number;
// If the user provided a comparison function, it is stored here.
userCmpFn: Undefined | Callable;
userCmpFn: Undefined|Callable;
// Function pointer to the comparison function. This can either be a builtin
// that calls the user-provided comparison function or "SortDefault", which
......@@ -132,7 +132,7 @@ namespace array {
}
transitioning macro NewSortState(implicit context: Context)(
receiver: JSReceiver, comparefn: Undefined | Callable,
receiver: JSReceiver, comparefn: Undefined|Callable,
initialReceiverLength: Number): SortState {
const sortComparePtr =
comparefn != Undefined ? SortCompareUserFn : SortCompareDefault;
......@@ -214,7 +214,7 @@ namespace array {
// it is first requested, but it has always at least this size.
const kSortStateTempSize: Smi = 32;
type LoadFn = builtin(Context, SortState, Smi) => (JSAny | TheHole);
type LoadFn = builtin(Context, SortState, Smi) => (JSAny|TheHole);
type StoreFn = builtin(Context, SortState, Smi, JSAny) => Smi;
type DeleteFn = builtin(Context, SortState, Smi) => Smi;
type CanUseSameAccessorFn = builtin(Context, JSReceiver, Map, Number) =>
......@@ -228,28 +228,28 @@ namespace array {
// through a hole.
transitioning builtin Load<ElementsAccessor: type>(
context: Context, sortState: SortState, index: Smi): JSAny | TheHole {
context: Context, sortState: SortState, index: Smi): JSAny|TheHole {
const receiver = sortState.receiver;
if (!HasProperty_Inline(receiver, index)) return TheHole;
return GetProperty(receiver, index);
}
Load<FastSmiElements>(context: Context, sortState: SortState, index: Smi):
JSAny | TheHole {
JSAny|TheHole {
const object = UnsafeCast<JSObject>(sortState.receiver);
const elements = UnsafeCast<FixedArray>(object.elements);
return UnsafeCast<(JSAny | TheHole)>(elements.objects[index]);
}
Load<FastObjectElements>(context: Context, sortState: SortState, index: Smi):
JSAny | TheHole {
JSAny|TheHole {
const object = UnsafeCast<JSObject>(sortState.receiver);
const elements = UnsafeCast<FixedArray>(object.elements);
return UnsafeCast<(JSAny | TheHole)>(elements.objects[index]);
}
Load<FastDoubleElements>(context: Context, sortState: SortState, index: Smi):
JSAny | TheHole {
JSAny|TheHole {
try {
const object = UnsafeCast<JSObject>(sortState.receiver);
const elements = UnsafeCast<FixedDoubleArray>(object.elements);
......@@ -1306,7 +1306,7 @@ namespace array {
// are ignored.
let numberOfUndefined: Smi = 0;
for (let i: Smi = 0; i < receiverLength; ++i) {
const element: JSAny | TheHole = loadFn(context, sortState, i);
const element: JSAny|TheHole = loadFn(context, sortState, i);
if (element == TheHole) {
// Do nothing for holes. The result is that elements are
......
......@@ -24,14 +24,6 @@ def preprocess(input):
input = re.sub(r'\bcase\s*(\([^{]*\))\s*:\s*deferred\s*{', r' if /*cAsEdEfF*/ \1 {', input)
input = re.sub(r'\bcase\s*(\([^{]*\))\s*:\s*{', r' if /*cA*/ \1 {', input)
# Add extra space around | operators to fix union types later.
while True:
old = input
input = re.sub(r'(\w+\s*)\|(\s*\w+)',
r'\1|/**/\2', input)
if old == input:
break;
input = re.sub(r'\bgenerates\s+\'([^\']+)\'\s*',
r'_GeNeRaTeS00_/*\1@*/', input)
input = re.sub(r'\bconstexpr\s+\'([^\']+)\'\s*',
......@@ -77,13 +69,6 @@ def postprocess(output):
output = re.sub(r'jS_iMpLiCiT_',
r"js-implicit ", output)
while True:
old = output
output = re.sub(r'(\w+)\s{0,1}\|\s{0,1}/\*\*/(\s*\w+)',
r'\1 |\2', output)
if old == output:
break;
output = re.sub(kPercentEscape, r'%', output)
return output
......
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