From 48ebcbb06c1535de01ff8e27ce7d11d8cf9ffae8 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sun, 13 Oct 2019 13:45:25 +0800 Subject: Expand - Hackily set the crate name from command line before expand --- src/expand/crate_tags.cpp | 14 +++++++------- src/main.cpp | 4 ++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/expand/crate_tags.cpp b/src/expand/crate_tags.cpp index 849ec459..31bb8abd 100644 --- a/src/expand/crate_tags.cpp +++ b/src/expand/crate_tags.cpp @@ -15,10 +15,10 @@ public: AttrStage stage() const override { return AttrStage::Pre; } void handle(const Span& sp, const AST::Attribute& mi, AST::Crate& crate) const override { - if( crate.m_crate_type != AST::Crate::Type::Unknown ) { - //ERROR(sp, E0000, "Multiple #![crate_type] attributes"); - return ; - } + //if( crate.m_crate_type != AST::Crate::Type::Unknown ) { + // //ERROR(sp, E0000, "Multiple #![crate_type] attributes"); + // return ; + //} if( !mi.has_string() ) { ERROR(sp, E0000, "#![crate_type] requires a string argument"); } @@ -42,9 +42,9 @@ public: AttrStage stage() const override { return AttrStage::Pre; } void handle(const Span& sp, const AST::Attribute& mi, AST::Crate& crate) const override { - if( crate.m_crate_name != "" ) { - ERROR(sp, E0000, "Multiple #![crate_name] attributes"); - } + //if( crate.m_crate_name != "" ) { + // ERROR(sp, E0000, "Multiple #![crate_name] attributes"); + //} if( !mi.has_string() || mi.string() == "" ) { ERROR(sp, E0000, "#![crate_name] requires a non-empty string argument"); } diff --git a/src/main.cpp b/src/main.cpp index 4760f736..e522c682 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -252,6 +252,10 @@ int main(int argc, char *argv[]) crate.load_externs(); }); + if( params.crate_name != "" ) { + crate.m_crate_name = params.crate_name; + } + // Iterate all items in the AST, applying syntax extensions CompilePhaseV("Expand", [&]() { Expand(crate); -- cgit v1.2.3