diff options
author | John Hodge <tpg@mutabah.net> | 2016-03-19 14:51:35 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-03-19 14:51:35 +0800 |
commit | 13e938957698086e77b7a2c8bbcfea9bba76c17a (patch) | |
tree | f3d1eece3c3dd6977635acf375aaa7268962b6ae /src/expand/std_prelude.cpp | |
parent | d9ddf019fe73c78213cddac02c700b6ebf782de4 (diff) | |
download | mrust-13e938957698086e77b7a2c8bbcfea9bba76c17a.tar.gz |
Expand - Handle std/core loading (partially)
Diffstat (limited to 'src/expand/std_prelude.cpp')
-rw-r--r-- | src/expand/std_prelude.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/expand/std_prelude.cpp b/src/expand/std_prelude.cpp new file mode 100644 index 00000000..c8ad6471 --- /dev/null +++ b/src/expand/std_prelude.cpp @@ -0,0 +1,53 @@ +/* + */ +#include <synext.hpp> +#include <ast/crate.hpp> + +class Decorator_NoStd: + public ExpandDecorator +{ +public: + AttrStage stage() const override { return AttrStage::EarlyPre; } + + void handle(const AST::MetaItem& mi, AST::Crate& crate) const override { + if( crate.m_load_std != AST::Crate::LOAD_STD ) { + ERROR(Span()/*mi.span()*/, E0000, "Invalid use of #![no_std] with itself or #![no_core]"); + } + crate.m_load_std = AST::Crate::LOAD_CORE; + } +}; +class Decorator_NoCore: + public ExpandDecorator +{ +public: + AttrStage stage() const override { return AttrStage::EarlyPre; } + + void handle(const AST::MetaItem& mi, AST::Crate& crate) const override { + if( crate.m_load_std != AST::Crate::LOAD_STD ) { + ERROR(Span()/*mi.span()*/, E0000, "Invalid use of #![no_core] with itself or #![no_std]"); + } + crate.m_load_std = AST::Crate::LOAD_NONE; + } +}; +//class Decorator_Prelude: +// public ExpandDecorator +//{ +//public: +// AttrStage stage() const override { return AttrStage::EarlyPre; } +//}; + +class Decorator_NoPrelude: + public ExpandDecorator +{ +public: + AttrStage stage() const override { return AttrStage::EarlyPre; } +}; + + + +STATIC_DECORATOR("no_std", Decorator_NoStd) +STATIC_DECORATOR("no_core", Decorator_NoCore) +//STATIC_DECORATOR("prelude", Decorator_Prelude) + +STATIC_DECORATOR("no_prelude", Decorator_NoPrelude) + |