1 // Copyright 2019 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 5 #ifndef V8_TORQUE_TORQUE_COMPILER_H_ 6 #define V8_TORQUE_TORQUE_COMPILER_H_ 7 8 #include "src/torque/ast.h" 9 #include "src/torque/contextual.h" 10 #include "src/torque/server-data.h" 11 #include "src/torque/source-positions.h" 12 #include "src/torque/utils.h" 13 14 namespace v8 { 15 namespace internal { 16 namespace torque { 17 18 struct TorqueCompilerOptions { 19 std::string output_directory = ""; 20 std::string v8_root = ""; 21 bool collect_language_server_data = false; 22 23 // assert(...) are only generated for debug builds. The provide 24 // language server support for statements inside asserts, this flag 25 // can force generate them. 26 bool force_assert_statements = false; 27 28 // Forge (Google3) can only run 64-bit executables. As Torque runs as part 29 // of the build process, we need a "cross-compile" mode when we target 32-bit 30 // architectures. Note that this does not needed in Chromium/V8 land, since we 31 // always build with the same bit width as the target architecture. 32 bool force_32bit_output = false; 33 }; 34 35 struct TorqueCompilerResult { 36 // Map translating SourceIds to filenames. This field is 37 // set on errors, so the SourcePosition of the error can be 38 // resolved. 39 base::Optional<SourceFileMap> source_file_map; 40 41 // Eagerly collected data needed for the LanguageServer. 42 // Set the corresponding options flag to enable. 43 LanguageServerData language_server_data; 44 45 // Errors collected during compilation. 46 std::vector<TorqueMessage> messages; 47 }; 48 49 V8_EXPORT_PRIVATE TorqueCompilerResult 50 CompileTorque(const std::string& source, TorqueCompilerOptions options); 51 TorqueCompilerResult CompileTorque(std::vector<std::string> files, 52 TorqueCompilerOptions options); 53 54 } // namespace torque 55 } // namespace internal 56 } // namespace v8 57 58 #endif // V8_TORQUE_TORQUE_COMPILER_H_ 59