summaryrefslogtreecommitdiff
path: root/src/expand/std_prelude.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-10-22 10:31:16 +0800
committerJohn Hodge <tpg@mutabah.net>2016-10-22 16:00:27 +0800
commit5a20d91b53d7889a5be8ed9dabeccbac0371f121 (patch)
treee66c887acbb3f15ee560851792f964939ade8470 /src/expand/std_prelude.cpp
parente29fa8f3a2b429ed2da10bd941c52cb80c8bc859 (diff)
downloadmrust-5a20d91b53d7889a5be8ed9dabeccbac0371f121.tar.gz
Expand - #[prelude_import] support
Diffstat (limited to 'src/expand/std_prelude.cpp')
-rw-r--r--src/expand/std_prelude.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/expand/std_prelude.cpp b/src/expand/std_prelude.cpp
index 4499dc6d..81eecf7f 100644
--- a/src/expand/std_prelude.cpp
+++ b/src/expand/std_prelude.cpp
@@ -52,11 +52,29 @@ public:
}
};
+class Decorator_PreludeImport:
+ public ExpandDecorator
+{
+public:
+ AttrStage stage() const override { return AttrStage::Post; }
+
+ void handle(const Span& sp, const AST::MetaItem& mi, ::AST::Crate& crate, const AST::Path& path, AST::Module& mod, AST::Item&i) const override {
+ if( i.is_Use() ) {
+ const auto& p = i.as_Use().path;
+ // TODO: Ensure that this statement is a glob (has a name of "")
+ crate.m_prelude_path = AST::Path(p);
+ }
+ else {
+ ERROR(sp, E0000, "Invalid use of #[no_prelude] on non-module");
+ }
+ }
+};
STATIC_DECORATOR("no_std", Decorator_NoStd)
STATIC_DECORATOR("no_core", Decorator_NoCore)
-//STATIC_DECORATOR("prelude", Decorator_Prelude)
+//STATIC_DECORATOR("prelude", Decorator_Prelude) // mrustc
+STATIC_DECORATOR("prelude_import", Decorator_PreludeImport) // rustc
STATIC_DECORATOR("no_prelude", Decorator_NoPrelude)