diff options
author | John Hodge <tpg@mutabah.net> | 2017-01-22 12:13:44 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2017-01-22 12:13:44 +0800 |
commit | 4776f2c628c7c421e71ff89e732ae8aa7dae321f (patch) | |
tree | 87b10532e441495a6b9757a7d519c3f3662b8c1d /src/expand/lang_item.cpp | |
parent | 5176f09f270c088fdf1bf6f0baea629bed21a4ba (diff) | |
download | mrust-4776f2c628c7c421e71ff89e732ae8aa7dae321f.tar.gz |
Trans - #[start] attribute
Diffstat (limited to 'src/expand/lang_item.cpp')
-rw-r--r-- | src/expand/lang_item.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/expand/lang_item.cpp b/src/expand/lang_item.cpp index a995aec0..0a5c87f5 100644 --- a/src/expand/lang_item.cpp +++ b/src/expand/lang_item.cpp @@ -201,8 +201,30 @@ public: } }; +class Decorator_Start: + public ExpandDecorator +{ +public: + AttrStage stage() const override { return AttrStage::Post; } + void handle(const Span& sp, const AST::MetaItem& attr, AST::Crate& crate, const AST::Path& path, AST::Module& mod, AST::Item& i) const override + { + TU_IFLET(::AST::Item, i, Function, e, + auto rv = crate.m_lang_items.insert(::std::make_pair( ::std::string("mrustc-start"), ::AST::Path(path) )); + if( !rv.second ) + { + const auto& other_path = rv.first->second; + ERROR(sp, E0000, "Duplicate definition of #[start] - " << other_path << " and " << path); + } + ) + else { + ERROR(sp, E0000, "#[start] on non-function " << path); + } + } +}; + STATIC_DECORATOR("lang", Decorator_LangItem) STATIC_DECORATOR("main", Decorator_Main); +STATIC_DECORATOR("start", Decorator_Start); |