summaryrefslogtreecommitdiff
path: root/src/expand
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-03-20 11:33:22 +0800
committerJohn Hodge <tpg@mutabah.net>2016-03-20 11:33:22 +0800
commit0ee80748a3dcb97f308e9b0b71c22d28868d12cf (patch)
tree7f626c107244d28261c9fd7faae02ab0c7e9f825 /src/expand
parent13e938957698086e77b7a2c8bbcfea9bba76c17a (diff)
downloadmrust-0ee80748a3dcb97f308e9b0b71c22d28868d12cf.tar.gz
Expand - Handle type size expression
Diffstat (limited to 'src/expand')
-rw-r--r--src/expand/mod.cpp17
1 files changed, 14 insertions, 3 deletions
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<void(const ExpandDecorator& d,const ::AST::MetaItem& a)> f);
void Expand_Mod(bool is_early, ::AST::Crate& crate, LList<const AST::Module*> modstack, ::AST::Path modpath, ::AST::Module& mod);
void Expand_Expr(bool is_early, ::AST::Crate& crate, LList<const AST::Module*> modstack, AST::Expr& node);
+void Expand_Expr(bool is_early, ::AST::Crate& crate, LList<const AST::Module*> modstack, ::std::shared_ptr<AST::ExprNode>& node);
void Register_Synext_Decorator(::std::string name, ::std::unique_ptr<ExpandDecorator> handler) {
g_decorators[name] = mv$(handler);
@@ -196,8 +197,9 @@ void Expand_Type(bool is_early, ::AST::Crate& crate, LList<const AST::Module*> 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<const AST::Module*> modstack, ::std::unique_ptr<AST::ExprNode>& node) {
+void Expand_Expr(bool is_early, ::AST::Crate& crate, LList<const AST::Module*> modstack, ::std::unique_ptr<AST::ExprNode>& node)
+{
auto visitor = CExpandExpr(is_early, crate, modstack);
visitor.visit(node);
}
+void Expand_Expr(bool is_early, ::AST::Crate& crate, LList<const AST::Module*> modstack, ::std::shared_ptr<AST::ExprNode>& 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<const AST::Module*> modstack, AST::Expr& node)
{
auto visitor = CExpandExpr(is_early, crate, modstack);