48 using Tokens = std::vector<parser::Token>;
58 const std::string source_;
59 const std::string filepath_;
60 const std::string filename;
63 const std::vector<std::string> file_list_;
68 .default_filename = filepath_.substr(filepath_.find_last_of(
'/') + 1)};
75 void report_error(
Token tok,
const std::string &message)
77 error_handler.
report(tok, message);
80 void report_error(
int row,
int column,
const std::string &line,
const std::string &message)
82 error_handler.
report(row, column, line, message);
85 struct SourceManager {
87 std::vector<std::unique_ptr<Parser>> parsers_;
94 return *parsers_.emplace_back(std::make_unique<Parser>(error_handler));
100 return include_id_++;
106 const std::string &filepath,
108 const std::vector<std::string> &file_list)
111 filename(filepath_.substr(filepath_.find_last_of(
'/') + 1)),
112 file_list_(file_list),
123 std::optional<parser::ErrorHandler::Error>
error;
134 std::vector<std::string> &visited_files);
151 Result convert_bsl();
152 Result convert_info();
153 Result convert_glsl();
154 Result convert_msl();
165 std::string disabled_code_mutation(
const std::string &
str);
166 void disabled_code_mutation(
Parser &
parser,
bool new_bsl_compiler =
false);
168 template<
typename ParserT>
void cleanup_whitespace(ParserT &
parser,
bool do_leading =
false);
194 void parse_builtins(
const std::string &
str,
const std::string &
filename,
bool pure_glsl =
false);
199 std::string threadgroup_variables_parse_and_remove(
const std::string &
str);
200 void threadgroup_variables_parse_and_remove(
Parser &
parser);
202 void scan_external_symbols(SourceManager &sources,
204 std::vector<std::string> &visited_files);
306 void lower_method_calls(
Parser &
parser,
bool with_prefix =
true);
338 void lower_comma_separated_declarations(
Parser &
parser);
344 void lower_initializer_implicit_types_ast(
Parser &
parser);
376 void lower_union_accessor_templates_ast(
Parser &
parser);
412 void lower_tests(
Parser &
parser,
const std::string &prefix =
"");
414 void lower_resource_macro_placeholder_ast(
Parser &
parser);
419 std::string argument_decorator_macro_injection(
const std::string &
str);
421 std::string array_constructor_macro_injection(
const std::string &
str);
424 std::string matrix_constructor_mutation(
const std::string &
str);
430 int static_array_size(
const Scope &
array,
int fallback_value);
439 const Token method_end);
443 void lower_template_instantiation(
446 const Token method_end,
447 const Token &inst_start,
448 const Scope &inst_args,
450 const Token &symbol_name,
451 const std::vector<std::string> &arg_list,
452 const std::string &fn_decl,
453 const bool all_template_args_in_function_signature);
459 const std::string &filepath);
464 const std::string &filepath);