Commit 6e98fa92 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

Rename FormatMessage method

Some windows toolchains contain a macro name 'FormatMessage', making
compilation fail, see e.g.
https://ci.chromium.org/p/v8/builders/try/v8_win64_msvc_compile_rel/b8919741418899023808.

Hence rename {MessageFormatter::FormatMessage} to
{MessageFormatter::Format}.

R=sigurds@chromium.org

Change-Id: I51bd444838be2449bbe848aa0f7f85d73a0a713b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1505456Reviewed-by: 's avatarSigurd Schneider <sigurds@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60098}
parent 14f07a8b
......@@ -180,7 +180,7 @@ Handle<String> MessageHandler::GetMessage(Isolate* isolate,
Handle<Object> data) {
Handle<JSMessageObject> message = Handle<JSMessageObject>::cast(data);
Handle<Object> arg = Handle<Object>(message->argument(), isolate);
return MessageFormatter::FormatMessage(isolate, message->type(), arg);
return MessageFormatter::Format(isolate, message->type(), arg);
}
std::unique_ptr<char[]> MessageHandler::GetLocalizedMessage(
......@@ -1080,12 +1080,11 @@ MaybeHandle<Object> ErrorUtils::FormatStackTrace(Isolate* isolate,
return builder.Finish();
}
Handle<String> MessageFormatter::FormatMessage(Isolate* isolate,
MessageTemplate index,
Handle<Object> arg) {
Handle<String> MessageFormatter::Format(Isolate* isolate, MessageTemplate index,
Handle<Object> arg) {
Factory* factory = isolate->factory();
Handle<String> result_string = Object::NoSideEffectsToString(isolate, arg);
MaybeHandle<String> maybe_result_string = MessageFormatter::FormatMessage(
MaybeHandle<String> maybe_result_string = MessageFormatter::Format(
isolate, index, result_string, factory->empty_string(),
factory->empty_string());
if (!maybe_result_string.ToHandle(&result_string)) {
......@@ -1114,11 +1113,11 @@ const char* MessageFormatter::TemplateString(MessageTemplate index) {
}
}
MaybeHandle<String> MessageFormatter::FormatMessage(Isolate* isolate,
MessageTemplate index,
Handle<String> arg0,
Handle<String> arg1,
Handle<String> arg2) {
MaybeHandle<String> MessageFormatter::Format(Isolate* isolate,
MessageTemplate index,
Handle<String> arg0,
Handle<String> arg1,
Handle<String> arg2) {
const char* template_string = TemplateString(index);
if (template_string == nullptr) {
isolate->ThrowIllegalOperation();
......@@ -1275,9 +1274,9 @@ MaybeHandle<String> ErrorUtils::ToString(Isolate* isolate,
namespace {
Handle<String> FormatMessage(Isolate* isolate, MessageTemplate index,
Handle<Object> arg0, Handle<Object> arg1,
Handle<Object> arg2) {
Handle<String> DoFormatMessage(Isolate* isolate, MessageTemplate index,
Handle<Object> arg0, Handle<Object> arg1,
Handle<Object> arg2) {
Handle<String> arg0_str = Object::NoSideEffectsToString(isolate, arg0);
Handle<String> arg1_str = Object::NoSideEffectsToString(isolate, arg1);
Handle<String> arg2_str = Object::NoSideEffectsToString(isolate, arg2);
......@@ -1285,8 +1284,7 @@ Handle<String> FormatMessage(Isolate* isolate, MessageTemplate index,
isolate->native_context()->IncrementErrorsThrown();
Handle<String> msg;
if (!MessageFormatter::FormatMessage(isolate, index, arg0_str, arg1_str,
arg2_str)
if (!MessageFormatter::Format(isolate, index, arg0_str, arg1_str, arg2_str)
.ToHandle(&msg)) {
DCHECK(isolate->has_pending_exception());
isolate->clear_pending_exception();
......@@ -1314,7 +1312,7 @@ MaybeHandle<Object> ErrorUtils::MakeGenericError(
DCHECK(mode != SKIP_UNTIL_SEEN);
Handle<Object> no_caller;
Handle<String> msg = FormatMessage(isolate, index, arg0, arg1, arg2);
Handle<String> msg = DoFormatMessage(isolate, index, arg0, arg1, arg2);
return ErrorUtils::Construct(isolate, constructor, constructor, msg, mode,
no_caller, false);
}
......
......@@ -277,14 +277,12 @@ class MessageFormatter {
public:
static const char* TemplateString(MessageTemplate index);
static MaybeHandle<String> FormatMessage(Isolate* isolate,
MessageTemplate index,
Handle<String> arg0,
Handle<String> arg1,
Handle<String> arg2);
static Handle<String> FormatMessage(Isolate* isolate, MessageTemplate index,
Handle<Object> arg);
static MaybeHandle<String> Format(Isolate* isolate, MessageTemplate index,
Handle<String> arg0, Handle<String> arg1,
Handle<String> arg2);
static Handle<String> Format(Isolate* isolate, MessageTemplate index,
Handle<Object> arg);
};
......
......@@ -142,9 +142,8 @@ void PendingCompilationErrorHandler::ThrowPendingError(Isolate* isolate,
Handle<String> PendingCompilationErrorHandler::FormatErrorMessageForTest(
Isolate* isolate) const {
return MessageFormatter::FormatMessage(
isolate, error_details_.message(),
error_details_.ArgumentString(isolate));
return MessageFormatter::Format(isolate, error_details_.message(),
error_details_.ArgumentString(isolate));
}
} // namespace internal
......
......@@ -990,8 +990,7 @@ Maybe<bool> ValueSerializer::ThrowIfOutOfMemory() {
void ValueSerializer::ThrowDataCloneError(MessageTemplate index,
Handle<Object> arg0) {
Handle<String> message =
MessageFormatter::FormatMessage(isolate_, index, arg0);
Handle<String> message = MessageFormatter::Format(isolate_, index, arg0);
if (delegate_) {
delegate_->ThrowDataCloneError(Utils::ToLocal(message));
} else {
......
......@@ -1739,8 +1739,8 @@ TEST(FormatMessage) {
Handle<String> arg1 = isolate->factory()->NewStringFromAsciiChecked("arg1");
Handle<String> arg2 = isolate->factory()->NewStringFromAsciiChecked("arg2");
Handle<String> result =
MessageFormatter::FormatMessage(
isolate, MessageTemplate::kPropertyNotFunction, arg0, arg1, arg2)
MessageFormatter::Format(isolate, MessageTemplate::kPropertyNotFunction,
arg0, arg1, arg2)
.ToHandleChecked();
Handle<String> expected = isolate->factory()->NewStringFromAsciiChecked(
"'arg0' returned for property 'arg1' of object 'arg2' is not a function");
......
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