From 0ee80748a3dcb97f308e9b0b71c22d28868d12cf Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sun, 20 Mar 2016 11:33:22 +0800 Subject: Expand - Handle type size expression --- src/expand/mod.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/expand/mod.cpp b/src/expand/mod.cpp index 3b46736f..ea7e143e 100644 --- a/src/expand/mod.cpp +++ b/src/expand/mod.cpp @@ -16,6 +16,7 @@ void Expand_Attrs(const ::AST::MetaItems& attrs, AttrStage stage, ::std::function f); void Expand_Mod(bool is_early, ::AST::Crate& crate, LList modstack, ::AST::Path modpath, ::AST::Module& mod); void Expand_Expr(bool is_early, ::AST::Crate& crate, LList modstack, AST::Expr& node); +void Expand_Expr(bool is_early, ::AST::Crate& crate, LList modstack, ::std::shared_ptr& node); void Register_Synext_Decorator(::std::string name, ::std::unique_ptr handler) { g_decorators[name] = mv$(handler); @@ -196,8 +197,9 @@ void Expand_Type(bool is_early, ::AST::Crate& crate, LList m ), (Array, Expand_Type(is_early, crate, modstack, mod, *e.inner); - // TODO: Array size expression - //Expand_Expr(is_early, crate, modstack, e.size); + if( e.size ) { + Expand_Expr(is_early, crate, modstack, e.size); + } ), (Generic, ), @@ -412,10 +414,19 @@ struct CExpandExpr: } }; -void Expand_Expr(bool is_early, ::AST::Crate& crate, LList modstack, ::std::unique_ptr& node) { +void Expand_Expr(bool is_early, ::AST::Crate& crate, LList modstack, ::std::unique_ptr& node) +{ auto visitor = CExpandExpr(is_early, crate, modstack); visitor.visit(node); } +void Expand_Expr(bool is_early, ::AST::Crate& crate, LList modstack, ::std::shared_ptr& node) +{ + auto visitor = CExpandExpr(is_early, crate, modstack); + node->visit(visitor); + if( visitor.replacement ) { + node.reset( visitor.replacement.release() ); + } +} void Expand_Expr(bool is_early, ::AST::Crate& crate, LList modstack, AST::Expr& node) { auto visitor = CExpandExpr(is_early, crate, modstack); -- cgit v1.2.3