} // namespace
AST::Fragment
-MacroBuiltin::assert (Location invoc_locus, AST::MacroInvocData &invoc)
+MacroBuiltin::assert_handler (Location invoc_locus, AST::MacroInvocData &invoc)
{
rust_debug ("assert!() called");
}
AST::Fragment
-MacroBuiltin::file (Location invoc_locus, AST::MacroInvocData &invoc)
+MacroBuiltin::file_handler (Location invoc_locus, AST::MacroInvocData &invoc)
{
auto current_file
= Session::get_instance ().linemap->location_file (invoc_locus);
}
AST::Fragment
-MacroBuiltin::column (Location invoc_locus, AST::MacroInvocData &invoc)
+MacroBuiltin::column_handler (Location invoc_locus, AST::MacroInvocData &invoc)
{
auto current_column
= Session::get_instance ().linemap->location_to_column (invoc_locus);
&'static [u8; N]. */
AST::Fragment
-MacroBuiltin::include_bytes (Location invoc_locus, AST::MacroInvocData &invoc)
+MacroBuiltin::include_bytes_handler (Location invoc_locus,
+ AST::MacroInvocData &invoc)
{
/* Get target filename from the macro invocation, which is treated as a path
relative to the include!-ing file (currently being compiled). */
expression of type &'static str. */
AST::Fragment
-MacroBuiltin::include_str (Location invoc_locus, AST::MacroInvocData &invoc)
+MacroBuiltin::include_str_handler (Location invoc_locus,
+ AST::MacroInvocData &invoc)
{
/* Get target filename from the macro invocation, which is treated as a path
relative to the include!-ing file (currently being compiled). */
/* Expand builtin macro compile_error!("error"), which forces a compile error
during the compile time. */
AST::Fragment
-MacroBuiltin::compile_error (Location invoc_locus, AST::MacroInvocData &invoc)
+MacroBuiltin::compile_error_handler (Location invoc_locus,
+ AST::MacroInvocData &invoc)
{
auto lit_expr
= parse_single_string_literal (invoc.get_delim_tok_tree (), invoc_locus,
into a string with no delimiter. */
AST::Fragment
-MacroBuiltin::concat (Location invoc_locus, AST::MacroInvocData &invoc)
+MacroBuiltin::concat_handler (Location invoc_locus, AST::MacroInvocData &invoc)
{
auto invoc_token_tree = invoc.get_delim_tok_tree ();
MacroInvocLexer lex (invoc_token_tree.to_token_stream ());
compile time. */
AST::Fragment
-MacroBuiltin::env (Location invoc_locus, AST::MacroInvocData &invoc)
+MacroBuiltin::env_handler (Location invoc_locus, AST::MacroInvocData &invoc)
{
auto invoc_token_tree = invoc.get_delim_tok_tree ();
MacroInvocLexer lex (invoc_token_tree.to_token_stream ());
}
AST::Fragment
-MacroBuiltin::cfg (Location invoc_locus, AST::MacroInvocData &invoc)
+MacroBuiltin::cfg_handler (Location invoc_locus, AST::MacroInvocData &invoc)
{
// only parse if not already parsed
if (!invoc.is_parsed ())
scope compile time. */
AST::Fragment
-MacroBuiltin::include (Location invoc_locus, AST::MacroInvocData &invoc)
+MacroBuiltin::include_handler (Location invoc_locus, AST::MacroInvocData &invoc)
{
/* Get target filename from the macro invocation, which is treated as a path
relative to the include!-ing file (currently being compiled). */
}
AST::Fragment
-MacroBuiltin::line (Location invoc_locus, AST::MacroInvocData &invoc)
+MacroBuiltin::line_handler (Location invoc_locus, AST::MacroInvocData &invoc)
{
auto current_line
= Session::get_instance ().linemap->location_to_line (invoc_locus);
* of the `Mappings` class.
*/
-/* If assert is defined as a macro this file will not parse, so undefine this
- before continuing. */
-// TODO: Rename all functions here `*_handler`
-#ifdef assert
-#undef assert
-#endif
-
namespace Rust {
class MacroBuiltin
{
public:
- static AST::Fragment assert (Location invoc_locus,
- AST::MacroInvocData &invoc);
+ static AST::Fragment assert_handler (Location invoc_locus,
+ AST::MacroInvocData &invoc);
- static AST::Fragment file (Location invoc_locus, AST::MacroInvocData &invoc);
+ static AST::Fragment file_handler (Location invoc_locus,
+ AST::MacroInvocData &invoc);
- static AST::Fragment column (Location invoc_locus,
- AST::MacroInvocData &invoc);
+ static AST::Fragment column_handler (Location invoc_locus,
+ AST::MacroInvocData &invoc);
- static AST::Fragment include_bytes (Location invoc_locus,
- AST::MacroInvocData &invoc);
+ static AST::Fragment include_bytes_handler (Location invoc_locus,
+ AST::MacroInvocData &invoc);
- static AST::Fragment include_str (Location invoc_locus,
- AST::MacroInvocData &invoc);
+ static AST::Fragment include_str_handler (Location invoc_locus,
+ AST::MacroInvocData &invoc);
- static AST::Fragment compile_error (Location invoc_locus,
- AST::MacroInvocData &invoc);
+ static AST::Fragment compile_error_handler (Location invoc_locus,
+ AST::MacroInvocData &invoc);
- static AST::Fragment concat (Location invoc_locus,
- AST::MacroInvocData &invoc);
+ static AST::Fragment concat_handler (Location invoc_locus,
+ AST::MacroInvocData &invoc);
- static AST::Fragment env (Location invoc_locus, AST::MacroInvocData &invoc);
+ static AST::Fragment env_handler (Location invoc_locus,
+ AST::MacroInvocData &invoc);
- static AST::Fragment cfg (Location invoc_locus, AST::MacroInvocData &invoc);
+ static AST::Fragment cfg_handler (Location invoc_locus,
+ AST::MacroInvocData &invoc);
- static AST::Fragment include (Location invoc_locus,
- AST::MacroInvocData &invoc);
+ static AST::Fragment include_handler (Location invoc_locus,
+ AST::MacroInvocData &invoc);
- static AST::Fragment line (Location invoc_locus, AST::MacroInvocData &invoc);
+ static AST::Fragment line_handler (Location invoc_locus,
+ AST::MacroInvocData &invoc);
};
} // namespace Rust
static std::map<
std::string, std::function<AST::Fragment (Location, AST::MacroInvocData &)>>
builtin_macros = {
- {"assert", MacroBuiltin::assert},
- {"file", MacroBuiltin::file},
- {"line", MacroBuiltin::line},
- {"column", MacroBuiltin::column},
- {"include_bytes", MacroBuiltin::include_bytes},
- {"include_str", MacroBuiltin::include_str},
- {"compile_error", MacroBuiltin::compile_error},
- {"concat", MacroBuiltin::concat},
- {"env", MacroBuiltin::env},
- {"cfg", MacroBuiltin::cfg},
- {"include", MacroBuiltin::include},
+ {"assert", MacroBuiltin::assert_handler},
+ {"file", MacroBuiltin::file_handler},
+ {"line", MacroBuiltin::line_handler},
+ {"column", MacroBuiltin::column_handler},
+ {"include_bytes", MacroBuiltin::include_bytes_handler},
+ {"include_str", MacroBuiltin::include_str_handler},
+ {"compile_error", MacroBuiltin::compile_error_handler},
+ {"concat", MacroBuiltin::concat_handler},
+ {"env", MacroBuiltin::env_handler},
+ {"cfg", MacroBuiltin::cfg_handler},
+ {"include", MacroBuiltin::include_handler},
};
auto outer_attrs = macro->get_outer_attrs ();