diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ast/dump.cpp | 9 | ||||
-rw-r--r-- | src/parse/root.cpp | 6 |
2 files changed, 10 insertions, 5 deletions
diff --git a/src/ast/dump.cpp b/src/ast/dump.cpp index 15fb6c4a..4773a845 100644 --- a/src/ast/dump.cpp +++ b/src/ast/dump.cpp @@ -9,6 +9,7 @@ #include <ast/ast.hpp> #include <ast/expr.hpp> #include <main_bindings.hpp> +#include <hir/hir.hpp> // ABI_RUST - TODO: Move elsewhere? #include <fstream> #include <cpp_unpack.h> @@ -1083,8 +1084,12 @@ void RustPrinter::handle_function(bool is_pub, const ::std::string& name, const { m_os << indent(); m_os << (is_pub ? "pub " : ""); - // TODO: Unsafe - // TODO: Const + if( f.is_const() ) + m_os << "const "; + if( f.is_unsafe() ) + m_os << "unsafe "; + if( f.abi() != ABI_RUST ) + m_os << "extern \"" << f.abi() << "\" "; m_os << "fn " << name; print_params(f.params()); m_os << "("; diff --git a/src/parse/root.cpp b/src/parse/root.cpp index 13009014..5a244543 100644 --- a/src/parse/root.cpp +++ b/src/parse/root.cpp @@ -1163,7 +1163,7 @@ AST::ExternBlock Parse_ExternBlock(TokenStream& lex, ::std::string abi, ::AST::M }
PUTBACK(tok, lex);
- AST::ExternBlock rv { mv$(abi) };
+ AST::ExternBlock rv { abi };
while( GET_TOK(tok, lex) != TOK_BRACE_CLOSE )
{
@@ -1189,8 +1189,8 @@ AST::ExternBlock Parse_ExternBlock(TokenStream& lex, ::std::string abi, ::AST::M GET_CHECK_TOK(tok, lex, TOK_IDENT);
auto name = mv$(tok.str());
// parse function as prototype
- // - no self, "safe" and not const
- auto i = ::AST::Item( Parse_FunctionDef(lex, abi, false, true, false,false) );
+ // - no self, is prototype, is unsafe and not const
+ auto i = ::AST::Item( Parse_FunctionDef(lex, abi, false, true, true,false) );
GET_CHECK_TOK(tok, lex, TOK_SEMICOLON);
i.attrs = mv$(meta_items);
|