v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
torque.cc
Go to the documentation of this file.
1// Copyright 2017 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
7
8namespace v8 {
9namespace internal {
10namespace torque {
11
13 switch (kind) {
15 return "Torque Error";
17 return "Lint error";
18 }
19}
20
21int WrappedMain(int argc, const char** argv) {
23 options.collect_language_server_data = false;
24 options.force_assert_statements = false;
25
26 std::vector<std::string> files;
27
28 for (int i = 1; i < argc; ++i) {
29 // Check for options
30 std::string argument(argv[i]);
31 if (argument == "-o") {
32 options.output_directory = argv[++i];
33 } else if (argument == "-v8-root") {
34 options.v8_root = std::string(argv[++i]);
35 } else if (argument == "-m32") {
36#ifdef V8_COMPRESS_POINTERS
37 std::cerr << "Pointer compression is incompatible with -m32.\n";
39#else
40 options.force_32bit_output = true;
41#endif
42 } else if (argument == "-annotate-ir") {
43 options.annotate_ir = true;
44 } else if (argument == "-strip-v8-root") {
45 options.strip_v8_root = true;
46 } else {
47 // Strip the v8-root in case it is a prefix of the file path itself.
48 // This is used when building in Google3.
49 if (options.strip_v8_root &&
50 argument.substr(0, options.v8_root.size()) == options.v8_root) {
51 argument = argument.substr(options.v8_root.size() + 1);
52 }
53 // Otherwise it's a .tq file. Remember it for compilation.
54 files.emplace_back(std::move(argument));
55 if (!StringEndsWith(files.back(), ".tq")) {
56 std::cerr << "Unexpected command-line argument \"" << files.back()
57 << "\", expected a .tq file.\n";
59 }
60 }
61 }
62
64
65 // PositionAsString requires the SourceFileMap to be set to
66 // resolve the file name. Needed to report errors and lint warnings.
67 SourceFileMap::Scope source_file_map_scope(*result.source_file_map);
68
69 for (const TorqueMessage& message : result.messages) {
70 if (message.position) {
71 std::cerr << PositionAsString(*message.position) << ": ";
72 }
73
74 std::cerr << ErrorPrefixFor(message.kind) << ": " << message.message
75 << "\n";
76 }
77
78 if (!result.messages.empty()) v8::base::OS::Abort();
79
80 return 0;
81}
82
83} // namespace torque
84} // namespace internal
85} // namespace v8
86
87int main(int argc, const char** argv) {
88 return v8::internal::torque::WrappedMain(argc, argv);
89}
Builtins::Kind kind
Definition builtins.cc:40
static void Abort()
DirectHandle< JSReceiver > options
ZoneVector< RpoNumber > & result
bool StringEndsWith(const std::string &s, const std::string &suffix)
Definition utils.h:361
std::string PositionAsString(SourcePosition pos)
TorqueCompilerResult CompileTorque(const std::string &source, TorqueCompilerOptions options)
std::string ErrorPrefixFor(TorqueMessage::Kind kind)
Definition torque.cc:12
int WrappedMain(int argc, const char **argv)
Definition torque.cc:21
int main(int argc, const char **argv)
Definition torque.cc:87