Commit 5a2cb2e1 authored by Bill Budge's avatar Bill Budge Committed by Commit Bot

[torque] Clean up some namespacing in conversions.tq

- Moves some CSA macros back into the global namespace, and uses
  Torque's new global namespace feature to disambiguate the calls.

Bug: v8:9891
Change-Id: I6a94ee04daed1e6a8f672b2eaa12161ab998f14c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2216932Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Commit-Queue: Bill Budge <bbudge@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68017}
parent 9569d3f9
......@@ -292,7 +292,7 @@ transitioning macro ArrayJoinImpl<T: type>(implicit context: Context)(
next = str;
}
case (num: Number): {
next = number::NumberToString(num);
next = NumberToString(num);
}
case (obj: JSAny): {
if (IsNullOrUndefined(obj)) continue;
......
......@@ -614,6 +614,13 @@ extern macro StringCharCodeAt(String, uintptr): int32;
extern runtime StringCompareSequence(Context, String, String, Number): Boolean;
extern macro StringFromSingleCharCode(int32): String;
extern macro NumberToString(Number): String;
extern macro StringToNumber(String): Number;
extern macro NonNumberToNumber(implicit context: Context)(JSAnyNotNumber):
Number;
extern macro NonNumberToNumeric(implicit context: Context)(JSAnyNotNumber):
Numeric;
extern macro Equal(JSAny, JSAny, Context): Boolean;
macro Equal(implicit context: Context)(left: JSAny, right: JSAny): Boolean {
return Equal(left, right);
......
......@@ -15,7 +15,7 @@ transitioning macro ToStringImpl(context: Context, o: JSAny): String {
while (true) {
typeswitch (result) {
case (num: Number): {
return number::NumberToString(num);
return NumberToString(num);
}
case (str: String): {
return str;
......
......@@ -6,15 +6,6 @@ namespace runtime {
extern transitioning runtime ToStringRT(Context, BigInt): String;
}
// A namespace to disambiguate calls with the same name as a JS Builtin.
namespace csa {
extern macro StringToNumber(String): Number;
extern macro NonNumberToNumber(implicit context: Context)(JSAnyNotNumber):
Number;
extern macro NonNumberToNumeric(implicit context: Context)(JSAnyNotNumber):
Numeric;
}
extern enum OrdinaryToPrimitiveHint { kString, kNumber }
extern macro OrdinaryToPrimitive(implicit context: Context)(
......@@ -23,17 +14,17 @@ extern macro OrdinaryToPrimitive(implicit context: Context)(
namespace conversion {
builtin StringToNumber(implicit context: Context)(input: String): Number {
return csa::StringToNumber(input);
return ::StringToNumber(input);
}
builtin NonNumberToNumber(implicit context: Context)(input: JSAnyNotNumber):
Number {
return csa::NonNumberToNumber(input);
return ::NonNumberToNumber(input);
}
builtin NonNumberToNumeric(implicit context: Context)(input: JSAnyNotNumber):
Numeric {
return csa::NonNumberToNumeric(input);
return ::NonNumberToNumeric(input);
}
builtin ToNumeric(implicit context: Context)(input: JSAny): Numeric {
......@@ -42,14 +33,14 @@ builtin ToNumeric(implicit context: Context)(input: JSAny): Numeric {
return n;
}
case (h: JSAnyNotNumber): {
return NonNumberToNumeric(h);
return conversion::NonNumberToNumeric(h);
}
}
}
// ES section #sec-tostring-applied-to-the-number-type
builtin NumberToString(implicit context: Context)(input: Number): String {
return number::NumberToString(input);
return ::NumberToString(input);
}
// ES6 section 7.1.2 ToBoolean ( argument )
......@@ -76,7 +67,7 @@ builtin ToLength(implicit context: Context)(input: JSAny): Number {
return ChangeFloat64ToTagged(value);
}
case (h: JSAnyNotNumber): {
x = csa::NonNumberToNumber(h);
x = ::NonNumberToNumber(h);
}
}
}
......@@ -92,7 +83,7 @@ transitioning builtin ToName(implicit context: Context)(input: JSAny): Name {
return n;
}
case (n: Number): {
return number::NumberToString(n);
return ::NumberToString(n);
}
case (b: BigInt): {
// We don't have a fast-path for BigInt currently, so just
......
......@@ -55,8 +55,6 @@ extern macro MinusInfinityStringConstant(): String;
const kAsciiZero: constexpr int32 = 48; // '0' (ascii)
const kAsciiLowerCaseA: constexpr int32 = 97; // 'a' (ascii)
extern macro NumberToString(Number): String;
transitioning macro ThisNumberValue(implicit context: Context)(
receiver: JSAny, method: constexpr string): Number {
return UnsafeCast<Number>(
......
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