diff options
author | John Hodge <tpg@mutabah.net> | 2016-09-29 13:51:13 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-09-29 13:51:13 +0800 |
commit | 8257316b6954c2de7a69d8272d295d34b7c5a20c (patch) | |
tree | 573af6736325698bef964c2b5006a4802e4f47f0 | |
parent | e7282f3b1595936af4553a72beee6a296780a33e (diff) | |
download | mrust-8257316b6954c2de7a69d8272d295d34b7c5a20c.tar.gz |
HIR - Add variadic marking to functions, and propagate unsafe/const markings
-rw-r--r-- | src/hir/deserialise.cpp | 1 | ||||
-rw-r--r-- | src/hir/from_ast.cpp | 4 | ||||
-rw-r--r-- | src/hir/hir.hpp | 1 | ||||
-rw-r--r-- | src/hir/serialise.cpp | 1 | ||||
-rw-r--r-- | src/hir_expand/closures.cpp | 6 | ||||
-rw-r--r-- | src/parse/root.cpp | 2 |
6 files changed, 9 insertions, 6 deletions
diff --git a/src/hir/deserialise.cpp b/src/hir/deserialise.cpp index fcfaeda1..fa34ce85 100644 --- a/src/hir/deserialise.cpp +++ b/src/hir/deserialise.cpp @@ -550,6 +550,7 @@ namespace { read_bool(), deserialise_genericparams(), deserialise_fcnargs(), + read_bool(), deserialise_type(), deserialise_exprptr() }; diff --git a/src/hir/from_ast.cpp b/src/hir/from_ast.cpp index 4dd6fe92..d80c1ed1 100644 --- a/src/hir/from_ast.cpp +++ b/src/hir/from_ast.cpp @@ -987,9 +987,9 @@ namespace { // TODO: ABI and unsafety/constness return ::HIR::Function { receiver, - "rust", false, false, + f.abi(), f.is_unsafe(), f.is_const(), LowerHIR_GenericParams(f.params(), nullptr), // TODO: If this is a method, then it can add the Self: Sized bound - mv$(args), + mv$(args), f.is_variadic(), LowerHIR_Type( f.rettype() ), LowerHIR_Expr( f.code() ) }; diff --git a/src/hir/hir.hpp b/src/hir/hir.hpp index 5c7f5a30..e1406067 100644 --- a/src/hir/hir.hpp +++ b/src/hir/hir.hpp @@ -108,6 +108,7 @@ public: GenericParams m_params; args_t m_args; + bool m_variadic; TypeRef m_return; ExprPtr m_code; diff --git a/src/hir/serialise.cpp b/src/hir/serialise.cpp index 0b581a27..8aece163 100644 --- a/src/hir/serialise.cpp +++ b/src/hir/serialise.cpp @@ -751,6 +751,7 @@ namespace { write_count(fcn.m_args.size()); for(const auto& a : fcn.m_args) serialise(a.second); + write_bool(fcn.m_variadic); serialise(fcn.m_return); DEBUG("m_args = " << fcn.m_args); diff --git a/src/hir_expand/closures.cpp b/src/hir_expand/closures.cpp index d3f39f19..7ca4fd25 100644 --- a/src/hir_expand/closures.cpp +++ b/src/hir_expand/closures.cpp @@ -261,7 +261,7 @@ namespace { make_vec2( ::std::make_pair(::HIR::Pattern { {false, ::HIR::PatternBinding::Type::Move, "self", 0}, {} }, ::HIR::TypeRef("Self", 0xFFFF)), mv$( args_argent ) - ), + ), false, ret_ty.clone(), mv$(code) } } @@ -297,7 +297,7 @@ namespace { ::HIR::TypeRef::new_borrow( ::HIR::BorrowType::Unique, ::HIR::TypeRef("Self", 0xFFFF) ) ), mv$( args_argent ) - ), + ), false, ret_ty.clone(), mv$(code) } } @@ -331,7 +331,7 @@ namespace { ::HIR::TypeRef::new_borrow( ::HIR::BorrowType::Shared, ::HIR::TypeRef("Self", 0xFFFF) ) ), mv$(args_argent) - ), + ), false, ret_ty.clone(), mv$(code) } } diff --git a/src/parse/root.cpp b/src/parse/root.cpp index 6755c99a..29b3f28a 100644 --- a/src/parse/root.cpp +++ b/src/parse/root.cpp @@ -1027,7 +1027,7 @@ void Parse_Impl_Item(TokenStream& lex, AST::Impl& impl) case TOK_RWORD_CONST:
{
GET_TOK(tok, lex);
- if( tok.type() != TOK_RWORD_FN && tok.type() != TOK_RWORD_UNSAFE )
+ if( tok.type() != TOK_RWORD_FN && tok.type() != TOK_RWORD_UNSAFE && !fn_is_unsafe )
{
CHECK_TOK(tok, TOK_IDENT);
auto name = mv$(tok.str());
|