[torque-ls] Fix sort-order of torque files for compilation

This CL moves frames.tq and arguments.tq to the front of the file
list when compiling Torque files.

Note that order independent compilation will most likely be
implemented in the near future, at which point this code becomes
obsolete.

R=tebbi@chromium.org

Bug: v8:8880
Change-Id: I7e32637925c28202f9b017a568bc06ae5bd595b1
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1561210
Reviewed-by: Tobias Tebbi <tebbi@chromium.org>
Commit-Queue: Simon Zünd <szuend@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60746}
This commit is contained in:
Simon Zünd 2019-04-10 12:53:34 +02:00 committed by Commit Bot
parent b6e65be98f
commit 293f7a3488

View File

@ -126,24 +126,23 @@ void HandleTorqueFileListNotification(TorqueFileListNotification notification) {
// We only consider file URIs (there shouldn't be anything else).
// Internally we store the URI instead of the path, eliminating the need
// to encode it again.
if (auto maybe_path = FileUriDecode(file_json.ToString())) {
files.push_back(file_json.ToString());
Logger::Log(" ", *maybe_path, "\n");
}
files.push_back(file_json.ToString());
Logger::Log(" ", file_json.ToString(), "\n");
}
// The Torque compiler expects to see some files first,
// we need to order them in the correct way.
std::sort(files.begin(), files.end(),
[](const std::string& a, const std::string& b) {
if (a.find("base.tq") != std::string::npos) return true;
if (b.find("base.tq") != std::string::npos) return false;
if (a.find("array.tq") != std::string::npos) return true;
if (b.find("array.tq") != std::string::npos) return false;
return false;
});
// TODO(szuend): Remove this, once the compiler doesn't require the input
// files to be in a specific order.
std::vector<std::string> sort_to_front = {"base.tq", "frames.tq",
"arguments.tq", "array.tq"};
std::sort(files.begin(), files.end(), [&](std::string a, std::string b) {
for (const std::string& fixed_file : sort_to_front) {
if (a.find(fixed_file) != std::string::npos) return true;
if (b.find(fixed_file) != std::string::npos) return false;
}
return a < b;
});
RecompileTorque();
}