diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ast/ast.cpp | 16 | ||||
-rw-r--r-- | src/ast/ast.hpp | 59 | ||||
-rw-r--r-- | src/ast/attrs.hpp | 10 | ||||
-rw-r--r-- | src/ast/crate.cpp | 2 | ||||
-rw-r--r-- | src/ast/generics.hpp | 24 | ||||
-rw-r--r-- | src/ast/path.hpp | 78 | ||||
-rw-r--r-- | src/ast/pattern.hpp | 20 | ||||
-rw-r--r-- | src/convert/ast_iterate.cpp | 26 | ||||
-rw-r--r-- | src/convert/resolve.cpp | 24 | ||||
-rw-r--r-- | src/convert/typecheck_expr.cpp | 4 | ||||
-rw-r--r-- | src/dump_as_rust.cpp | 20 | ||||
-rw-r--r-- | src/expand/derive.cpp | 2 | ||||
-rw-r--r-- | src/expand/macro_rules.cpp | 2 | ||||
-rw-r--r-- | src/expand/mod.cpp | 40 | ||||
-rw-r--r-- | src/include/tagged_union.hpp | 16 | ||||
-rw-r--r-- | src/types.hpp | 48 |
16 files changed, 188 insertions, 203 deletions
diff --git a/src/ast/ast.cpp b/src/ast/ast.cpp index 16fad76e..72b4455c 100644 --- a/src/ast/ast.cpp +++ b/src/ast/ast.cpp @@ -320,7 +320,7 @@ void Module::iterate_functions(fcn_visitor_t *visitor, const Crate& crate) TU_MATCH_DEF(::AST::Item, (item.data), (e),
( ),
(Function,
- visitor(crate, *this, e.e);
+ visitor(crate, *this, e);
)
)
}
@@ -346,21 +346,21 @@ Module::ItemRef Module::find_item(const ::std::string& needle, bool allow_leaves (None,
break;
),
- (Module, return ItemRef(e.e); ),
+ (Module, return ItemRef(e); ),
(Crate, return ItemRef(e.name); ),
- (Type, return ItemRef(e.e); ),
- (Struct, return ItemRef(e.e); ),
- (Enum, return ItemRef(e.e); ),
- (Trait, return ItemRef(e.e); ),
+ (Type, return ItemRef(e); ),
+ (Struct, return ItemRef(e); ),
+ (Enum, return ItemRef(e); ),
+ (Trait, return ItemRef(e); ),
(Function,
if( allow_leaves )
- return ItemRef(e.e);
+ return ItemRef(e);
else
DEBUG("Skipping function, leaves not allowed");
),
(Static,
if( allow_leaves )
- return ItemRef(e.e);
+ return ItemRef(e);
else
DEBUG("Skipping function, leaves not allowed");
)
diff --git a/src/ast/ast.hpp b/src/ast/ast.hpp index 886766ff..fd72552a 100644 --- a/src/ast/ast.hpp +++ b/src/ast/ast.hpp @@ -227,15 +227,15 @@ public: TAGGED_UNION_EX(EnumVariantData, (: public Serialisable), Value,
(
- (Value, (
+ (Value, struct {
::AST::Expr m_value;
- )),
- (Tuple, (
+ }),
+ (Tuple, struct {
::std::vector<TypeRef> m_sub_types;
- )),
- (Struct, (
+ }),
+ (Struct, struct {
::std::vector<StructItem> m_fields;
- ))
+ })
),
(), (),
(
@@ -319,12 +319,12 @@ public: TAGGED_UNION_EX(StructData, (: public Serialisable), Struct,
(
- (Tuple, (
+ (Tuple, struct {
::std::vector<TupleItem> ents;
- )),
- (Struct, (
+ }),
+ (Struct, struct {
::std::vector<StructItem> ents;
- ))
+ })
),
(),(),
(
@@ -593,34 +593,19 @@ private: TAGGED_UNION_EX(Item, (: public Serialisable), None,
(
- (None, (
- )),
- (Module, (
- Module e;
- )),
- (Crate, (
+ (None, struct {} ),
+ (Module, Module),
+ (Crate, struct {
::std::string name;
- )),
-
- (Type, (
- TypeAlias e;
- )),
- (Struct, (
- Struct e;
- )),
- (Enum, (
- Enum e;
- )),
- (Trait, (
- Trait e;
- )),
-
- (Function, (
- Function e;
- )),
- (Static, (
- Static e;
- ))
+ }),
+
+ (Type, TypeAlias),
+ (Struct, Struct),
+ (Enum, Enum),
+ (Trait, Trait),
+
+ (Function, Function),
+ (Static, Static)
),
(, attrs(mv$(x.attrs))), (attrs = mv$(x.attrs);),
diff --git a/src/ast/attrs.hpp b/src/ast/attrs.hpp index b7b7f91c..6a6cdaa7 100644 --- a/src/ast/attrs.hpp +++ b/src/ast/attrs.hpp @@ -40,13 +40,13 @@ public: TAGGED_UNION(MetaItemData, None, - (None, ()), - (String, ( + (None, struct {}), + (String, struct { ::std::string val; - )), - (List, ( + }), + (List, struct { ::std::vector<MetaItem> sub_items; - )) + }) ); class MetaItem: diff --git a/src/ast/crate.cpp b/src/ast/crate.cpp index 135c2ae7..38bf92c3 100644 --- a/src/ast/crate.cpp +++ b/src/ast/crate.cpp @@ -15,7 +15,7 @@ namespace { TU_MATCH_DEF(::AST::Item, (sm.data), (e), ( ), (Module, - iterate_module(e.e, fcn); + iterate_module(e, fcn); ) ) } diff --git a/src/ast/generics.hpp b/src/ast/generics.hpp index ad205a21..288de0a3 100644 --- a/src/ast/generics.hpp +++ b/src/ast/generics.hpp @@ -33,36 +33,36 @@ public: TAGGED_UNION_EX( GenericBound, (: public Serialisable), Lifetime, ( // Lifetime bound: 'test must be valid for 'bound - (Lifetime, ( + (Lifetime, struct { ::std::string test; ::std::string bound; - )), + }), // Type lifetime bound - (TypeLifetime, ( + (TypeLifetime, struct { TypeRef type; ::std::string bound; - )), + }), // Standard trait bound: "Type: [for<'a>] Trait" - (IsTrait, ( + (IsTrait, struct { TypeRef type; ::std::vector< ::std::string> hrls; // Higher-ranked lifetimes AST::Path trait; - )), + }), // Removed trait bound: "Type: ?Trait" - (MaybeTrait, ( + (MaybeTrait, struct { TypeRef type; AST::Path trait; - )), + }), // Negative trait bound: "Type: !Trait" - (NotTrait, ( + (NotTrait, struct { TypeRef type; AST::Path trait; - )), + }), // Type equality: "Type = Replacement" - (Equality, ( + (Equality, struct { TypeRef type; TypeRef replacement; - )) + }) ), (), (), diff --git a/src/ast/path.hpp b/src/ast/path.hpp index 1260ece3..d2f6302e 100644 --- a/src/ast/path.hpp +++ b/src/ast/path.hpp @@ -29,49 +29,49 @@ class Static; class Function; TAGGED_UNION(PathBinding, Unbound, - (Unbound, ( - )), - (Module, ( + (Unbound, struct { + }), + (Module, struct { const Module* module_; - )), - (Enum, ( + }), + (Enum, struct { const Enum* enum_; - )), - (Struct, ( + }), + (Struct, struct { const Struct* struct_; - )), - (Trait, ( + }), + (Trait, struct { const Trait* trait_; - )), - (Static, ( + }), + (Static, struct { const Static* static_; - )), - (Function, ( + }), + (Function, struct { const Function* func_; - )), - (EnumVar, ( + }), + (EnumVar, struct { const Enum* enum_; unsigned int idx; - )), - (TypeAlias, ( + }), + (TypeAlias, struct { const TypeAlias* alias_; - )), - (StructMethod, ( + }), + (StructMethod, struct { const Struct* struct_; ::std::string name; - )), - (TraitMethod, ( + }), + (TraitMethod, struct { const Trait* struct_; ::std::string name; - )), + }), - (TypeParameter, ( + (TypeParameter, struct { unsigned int level; unsigned int idx; - )), - (Variable, ( + }), + (Variable, struct { unsigned int slot; - )) + }) ); extern ::std::ostream& operator<<(::std::ostream& os, const PathBinding& x); @@ -103,28 +103,28 @@ class Path: { public: TAGGED_UNION(Class, Invalid, - (Invalid, ()), - (Local, ( // Variable / Type param (resolved) + (Invalid, struct {}), + (Local, struct { // Variable / Type param (resolved) ::std::string name; - ) ), - (Relative, ( // General relative + } ), + (Relative, struct { // General relative ::std::vector<PathNode> nodes; - ) ), - (Self, ( // Module-relative + } ), + (Self, struct { // Module-relative ::std::vector<PathNode> nodes; - ) ), - (Super, ( // Parent-relative + } ), + (Super, struct { // Parent-relative unsigned int count; ::std::vector<PathNode> nodes; - ) ), - (Absolute, ( // Absolute + } ), + (Absolute, struct { // Absolute ::std::vector<PathNode> nodes; - ) ), - (UFCS, ( // Type-relative + } ), + (UFCS, struct { // Type-relative ::std::unique_ptr<TypeRef> type; ::std::unique_ptr<TypeRef> trait; ::std::vector<PathNode> nodes; - ) ) + } ) ); private: diff --git a/src/ast/pattern.hpp b/src/ast/pattern.hpp index b844eba9..b8e86b70 100644 --- a/src/ast/pattern.hpp +++ b/src/ast/pattern.hpp @@ -25,16 +25,16 @@ public: BIND_MUTREF, }; TAGGED_UNION(Data, Any, - (MaybeBind, () ), - (Macro, (unique_ptr<::AST::MacroInvocation> inv;) ), - (Any, () ), - (Box, (unique_ptr<Pattern> sub;) ), - (Ref, (bool mut; unique_ptr<Pattern> sub;) ), - (Value, (unique_ptr<ExprNode> start; unique_ptr<ExprNode> end;) ), - (Tuple, (::std::vector<Pattern> sub_patterns;) ), - (StructTuple, (Path path; ::std::vector<Pattern> sub_patterns;) ), - (Struct, (Path path; ::std::vector< ::std::pair< ::std::string,Pattern> > sub_patterns;) ), - (Slice, (::std::vector<Pattern> leading; ::std::string extra_bind; ::std::vector<Pattern> trailing;) ) + (MaybeBind, struct { } ), + (Macro, struct { unique_ptr<::AST::MacroInvocation> inv; } ), + (Any, struct { } ), + (Box, struct { unique_ptr<Pattern> sub; } ), + (Ref, struct { bool mut; unique_ptr<Pattern> sub; } ), + (Value, struct { unique_ptr<ExprNode> start; unique_ptr<ExprNode> end; } ), + (Tuple, struct { ::std::vector<Pattern> sub_patterns; } ), + (StructTuple, struct { Path path; ::std::vector<Pattern> sub_patterns; } ), + (Struct, struct { Path path; ::std::vector< ::std::pair< ::std::string, Pattern> > sub_patterns; } ), + (Slice, struct { ::std::vector<Pattern> leading; ::std::string extra_bind; ::std::vector<Pattern> trailing; } ) ); private: ::std::string m_binding; diff --git a/src/convert/ast_iterate.cpp b/src/convert/ast_iterate.cpp index 66ff0516..5909d689 100644 --- a/src/convert/ast_iterate.cpp +++ b/src/convert/ast_iterate.cpp @@ -314,31 +314,31 @@ void CASTIterator::handle_module(AST::Path path, AST::Module& mod) ), (Struct, DEBUG("Handling struct " << item.name); - handle_struct(path + item.name, e.e); + handle_struct(path + item.name, e); ), (Enum, DEBUG("Handling enum " << item.name); - handle_enum(path + item.name, e.e); + handle_enum(path + item.name, e); ), (Trait, DEBUG("Handling trait " << item.name); - handle_trait(path + item.name, e.e); + handle_trait(path + item.name, e); ), (Type, DEBUG("Handling alias " << item.name); - handle_alias(path + item.name, e.e); + handle_alias(path + item.name, e); ), (Static, DEBUG("handling static " << item.name); - handle_type(e.e.type()); - if( e.e.value().is_valid() ) + handle_type(e.type()); + if( e.value().is_valid() ) { - handle_expr(e.e.value().node()); + handle_expr(e.value().node()); } ), (Function, DEBUG("Handling function '" << item.name << "'"); - handle_function(path + item.name, e.e); + handle_function(path + item.name, e); ), (Module, // Skip, done after all items @@ -358,7 +358,7 @@ void CASTIterator::handle_module(AST::Path path, AST::Module& mod) for( auto& item : mod.items() ) { if(!item.data.is_Module()) continue; - auto& submod = item.data.as_Module().e; + auto& submod = item.data.as_Module(); DEBUG("Handling submod '" << item.name << "'"); handle_module(path + item.name, submod); } @@ -449,11 +449,11 @@ void CASTIterator::handle_impl(AST::Path modpath, AST::Impl& impl) ), (Type, DEBUG("- Type '" << it.name << "'"); - handle_type( e.e.type() ); + handle_type( e.type() ); ), (Function, DEBUG("- Function '" << it.name << "'"); - handle_function(AST::Path(AST::Path::TagRelative(), { AST::PathNode(it.name) }), e.e); + handle_function(AST::Path(AST::Path::TagRelative(), { AST::PathNode(it.name) }), e); ) ) } @@ -523,10 +523,10 @@ void CASTIterator::handle_trait(AST::Path path, AST::Trait& trait) // TODO: Can trait associated types have default types? ), (Static, - handle_type(e.e.type()); + handle_type(e.type()); ), (Function, - handle_function( path + i.name, e.e ); + handle_function( path + i.name, e ); ) ) } diff --git a/src/convert/resolve.cpp b/src/convert/resolve.cpp index f9115e0b..cfe77e84 100644 --- a/src/convert/resolve.cpp +++ b/src/convert/resolve.cpp @@ -65,14 +65,14 @@ class CPathResolver: TAGGED_UNION(SelfType, None,
- (None, ()),
- (Type, (
+ (None, struct {}),
+ (Type, struct {
TypeRef type;
- )),
- (Trait, (
+ }),
+ (Trait, struct {
AST::Path path;
const AST::Trait* trait;
- ))
+ })
);
::std::vector<SelfType> m_self_type;
@@ -164,7 +164,7 @@ private: if( it->module ) {
for( const auto& i : it->module->items() ) {
if( !i.data.is_Trait() ) continue ;
- const auto& t = i.data.as_Trait().e;
+ const auto& t = i.data.as_Trait();
auto trait_path = it->module_path + i.name;
DEBUG("t = " << trait_path);
ret.push_back( ::std::pair<AST::Path, const AST::Trait&>(trait_path, t) );
@@ -174,7 +174,7 @@ private: for( const auto& i : m_module->items() ) {
if( !i.data.is_Trait() ) continue ;
- const auto& t = i.data.as_Trait().e;
+ const auto& t = i.data.as_Trait();
auto trait_path = m_module_path + i.name;
DEBUG("(mod) t = " << trait_path);
ret.push_back( ::std::pair<AST::Path, const AST::Trait&>(trait_path, t) );
@@ -1189,7 +1189,7 @@ void CPathResolver::handle_path_ufcs(const Span& span, AST::Path& path, CASTIter // Ignore?
),
(Function,
- path.bind_function(e.e, path.nodes()[0].args());
+ path.bind_function(e, path.nodes()[0].args());
info.trait = make_unique_ptr( TypeRef(TypeRef::TagInvalid(), span) );
return true;
)
@@ -1388,7 +1388,7 @@ bool CPathResolver::find_trait_item(const Span& span, const AST::Path& path, AST ),
(Function,
out_is_method = true;
- out_ptr = &e.e;
+ out_ptr = &e;
out_trait_path = AST::Path(path);
DEBUG("Fcn, out_trait_path = " << out_trait_path);
return true;
@@ -1777,7 +1777,7 @@ void ResolvePaths_HandleModule_Use(const AST::Crate& crate, const AST::Path& mod for(auto& item : mod.items()) {
if( item.data.is_Module() ) {
- ResolvePaths_HandleModule_Use(crate, modpath + item.name, item.data.as_Module().e);
+ ResolvePaths_HandleModule_Use(crate, modpath + item.name, item.data.as_Module());
}
}
}
@@ -1795,7 +1795,7 @@ void SetCrateName_Mod(const AST::Crate& crate, ::std::string name, AST::Module& {
for(auto& item : mod.items()) {
if( item.data.is_Module() ) {
- SetCrateName_Mod(crate, name, item.data.as_Module().e);
+ SetCrateName_Mod(crate, name, item.data.as_Module());
}
}
// Imports 'use' statements
@@ -1809,7 +1809,7 @@ void SetCrateName_Mod(const AST::Crate& crate, ::std::string name, AST::Module& // TODO: All other types
for(auto& item : mod.items()) {
if( item.data.is_Function() ) {
- SetCrateName_Type(crate, name, item.data.as_Function().e.rettype());
+ SetCrateName_Type(crate, name, item.data.as_Function().rettype());
}
}
}
diff --git a/src/convert/typecheck_expr.cpp b/src/convert/typecheck_expr.cpp index 4afb64c9..59e9a4aa 100644 --- a/src/convert/typecheck_expr.cpp +++ b/src/convert/typecheck_expr.cpp @@ -506,7 +506,7 @@ void CTC_NodeVisitor::visit(AST::ExprNode_CallMethod& node) { if( i.name == name && i.data.is_Function() ) { - fcnp = &i.data.as_Function().e; + fcnp = &i.data.as_Function(); break; } } @@ -524,7 +524,7 @@ void CTC_NodeVisitor::visit(AST::ExprNode_CallMethod& node) { if( i.name == name && i.data.is_Function() ) { - fcnp = &i.data.as_Function().e; + fcnp = &i.data.as_Function(); break; } } diff --git a/src/dump_as_rust.cpp b/src/dump_as_rust.cpp index 42cbf48e..45ca55e0 100644 --- a/src/dump_as_rust.cpp +++ b/src/dump_as_rust.cpp @@ -562,7 +562,7 @@ void RustPrinter::handle_module(const AST::Module& mod) for( const auto& item : mod.items() ) { if( !item.data.is_Module() ) continue ; - const auto& e = item.data.as_Module().e; + const auto& e = item.data.as_Module(); m_os << "\n"; m_os << indent() << (item.is_pub ? "pub " : "") << "mod " << item.name << "\n"; @@ -577,7 +577,7 @@ void RustPrinter::handle_module(const AST::Module& mod) for( const auto& item : mod.items() ) { if( !item.data.is_Type() ) continue ; - const auto& e = item.data.as_Type().e; + const auto& e = item.data.as_Type(); if(need_nl) { m_os << "\n"; @@ -595,7 +595,7 @@ void RustPrinter::handle_module(const AST::Module& mod) for( const auto& item : mod.items() ) { if( !item.data.is_Struct() ) continue ; - const auto& e = item.data.as_Struct().e; + const auto& e = item.data.as_Struct(); m_os << "\n"; m_os << indent() << (item.is_pub ? "pub " : "") << "struct " << item.name; @@ -605,7 +605,7 @@ void RustPrinter::handle_module(const AST::Module& mod) for( const auto& item : mod.items() ) { if( !item.data.is_Enum() ) continue ; - const auto& e = item.data.as_Enum().e; + const auto& e = item.data.as_Enum(); m_os << "\n"; m_os << indent() << (item.is_pub ? "pub " : "") << "enum " << item.name; @@ -615,7 +615,7 @@ void RustPrinter::handle_module(const AST::Module& mod) for( const auto& item : mod.items() ) { if( !item.data.is_Trait() ) continue ; - const auto& e = item.data.as_Trait().e; + const auto& e = item.data.as_Trait(); m_os << "\n"; m_os << indent() << (item.is_pub ? "pub " : "") << "trait " << item.name; @@ -625,7 +625,7 @@ void RustPrinter::handle_module(const AST::Module& mod) for( const auto& item : mod.items() ) { if( !item.data.is_Static() ) continue ; - const auto& e = item.data.as_Static().e; + const auto& e = item.data.as_Static(); if(need_nl) { m_os << "\n"; @@ -646,7 +646,7 @@ void RustPrinter::handle_module(const AST::Module& mod) for( const auto& item : mod.items() ) { if( !item.data.is_Function() ) continue ; - const auto& e = item.data.as_Function().e; + const auto& e = item.data.as_Function(); m_os << "\n"; handle_function(item.is_pub, item.name, e); @@ -673,10 +673,10 @@ void RustPrinter::handle_module(const AST::Module& mod) throw ::std::runtime_error("Unexpected item type in impl block"); ), (Type, - m_os << indent() << "type " << it.name << " = " << e.e.type() << ";\n"; + m_os << indent() << "type " << it.name << " = " << e.type() << ";\n"; ), (Function, - handle_function(it.is_pub, it.name, e.e); + handle_function(it.is_pub, it.name, e); ) ) } @@ -958,7 +958,7 @@ void RustPrinter::handle_trait(const AST::Trait& s) m_os << indent() << "type " << i.name << ";\n"; ), (Function, - handle_function(false, i.name, e.e); + handle_function(false, i.name, e); ) ) } diff --git a/src/expand/derive.cpp b/src/expand/derive.cpp index 0096f809..6b52982d 100644 --- a/src/expand/derive.cpp +++ b/src/expand/derive.cpp @@ -162,7 +162,7 @@ public: ( ), (Struct, - derive_item(mod, attr, path, e.e); + derive_item(mod, attr, path, e); ) ) } diff --git a/src/expand/macro_rules.cpp b/src/expand/macro_rules.cpp index d5423cb4..562b1468 100644 --- a/src/expand/macro_rules.cpp +++ b/src/expand/macro_rules.cpp @@ -34,7 +34,7 @@ class CMacroUseHandler: if( !i.is_Module() ) throw ::std::runtime_error("ERROR: Use of #[macro_use] on non-module"); - const auto& submod = i.as_Module().e; + const auto& submod = i.as_Module(); if( mi.has_sub_items() ) { diff --git a/src/expand/mod.cpp b/src/expand/mod.cpp index ea7e143e..399f74b2 100644 --- a/src/expand/mod.cpp +++ b/src/expand/mod.cpp @@ -486,15 +486,15 @@ void Expand_Mod(bool is_early, ::AST::Crate& crate, LList<const AST::Module*> mo // Skip, nothing ), (Module, - LList<const AST::Module*> sub_modstack(&modstack, &e.e); - Expand_Mod(is_early, crate, sub_modstack, path, e.e); + LList<const AST::Module*> sub_modstack(&modstack, &e); + Expand_Mod(is_early, crate, sub_modstack, path, e); ), (Crate, // Can't recurse into an `extern crate` ), (Struct, - TU_MATCH(AST::StructData, (e.e.m_data), (sd), + TU_MATCH(AST::StructData, (e.m_data), (sd), (Struct, for(auto it = sd.ents.begin(); it != sd.ents.end(); ) { auto& si = *it; @@ -524,7 +524,7 @@ void Expand_Mod(bool is_early, ::AST::Crate& crate, LList<const AST::Module*> mo ) ), (Enum, - for(auto& var : e.e.variants()) { + for(auto& var : e.variants()) { Expand_Attrs(var.m_attrs, stage_pre (is_early), [&](const auto& d, const auto& a){ d.handle(a, crate, var); }); TU_MATCH(::AST::EnumVariantData, (var.m_data), (e), (Value, @@ -553,7 +553,7 @@ void Expand_Mod(bool is_early, ::AST::Crate& crate, LList<const AST::Module*> mo } ), (Trait, - for(auto& ti : e.e.items()) + for(auto& ti : e.items()) { auto attrs = mv$(ti.data.attrs); Expand_Attrs(attrs, stage_pre(is_early), crate, AST::Path(), mod, ti.data); @@ -564,18 +564,18 @@ void Expand_Mod(bool is_early, ::AST::Crate& crate, LList<const AST::Module*> mo ), (None, ), (Function, - for(auto& arg : e.e.args()) { + for(auto& arg : e.args()) { Expand_Pattern(is_early, crate, modstack, mod, arg.first); Expand_Type(is_early, crate, modstack, mod, arg.second); } - Expand_Type(is_early, crate, modstack, mod, e.e.rettype()); - Expand_Expr(is_early, crate, modstack, e.e.code()); + Expand_Type(is_early, crate, modstack, mod, e.rettype()); + Expand_Expr(is_early, crate, modstack, e.code()); ), (Static, - Expand_Expr(is_early, crate, modstack, e.e.value()); + Expand_Expr(is_early, crate, modstack, e.value()); ), (Type, - Expand_Type(is_early, crate, modstack, mod, e.e.type()); + Expand_Type(is_early, crate, modstack, mod, e.type()); ) ) @@ -585,19 +585,19 @@ void Expand_Mod(bool is_early, ::AST::Crate& crate, LList<const AST::Module*> mo } ), (Type, - Expand_Type(is_early, crate, modstack, mod, e.e.type()); + Expand_Type(is_early, crate, modstack, mod, e.type()); ), (Function, - for(auto& arg : e.e.args()) { + for(auto& arg : e.args()) { Expand_Pattern(is_early, crate, modstack, mod, arg.first); Expand_Type(is_early, crate, modstack, mod, arg.second); } - Expand_Type(is_early, crate, modstack, mod, e.e.rettype()); - Expand_Expr(is_early, crate, modstack, e.e.code()); + Expand_Type(is_early, crate, modstack, mod, e.rettype()); + Expand_Expr(is_early, crate, modstack, e.code()); ), (Static, - Expand_Expr(is_early, crate, modstack, e.e.value()); + Expand_Expr(is_early, crate, modstack, e.value()); ) ) @@ -661,18 +661,18 @@ void Expand_Mod(bool is_early, ::AST::Crate& crate, LList<const AST::Module*> mo ), (None, ), (Function, - for(auto& arg : e.e.args()) { + for(auto& arg : e.args()) { Expand_Pattern(is_early, crate, modstack, mod, arg.first); Expand_Type(is_early, crate, modstack, mod, arg.second); } - Expand_Type(is_early, crate, modstack, mod, e.e.rettype()); - Expand_Expr(is_early, crate, modstack, e.e.code()); + Expand_Type(is_early, crate, modstack, mod, e.rettype()); + Expand_Expr(is_early, crate, modstack, e.code()); ), (Static, - Expand_Expr(is_early, crate, modstack, e.e.value()); + Expand_Expr(is_early, crate, modstack, e.value()); ), (Type, - Expand_Type(is_early, crate, modstack, mod, e.e.type()); + Expand_Type(is_early, crate, modstack, mod, e.type()); ) ) diff --git a/src/include/tagged_union.hpp b/src/include/tagged_union.hpp index 7019f34e..88b07d82 100644 --- a/src/include/tagged_union.hpp +++ b/src/include/tagged_union.hpp @@ -79,7 +79,7 @@ #define TU_GMA(...) TU_GM(TU_DISPA, __VA_ARGS__) // Sizes of structures -#define TU_SO(name, _) sizeof(TU_DATANAME(name)) +#define TU_SO(name, ...) sizeof(TU_DATANAME(name)) #define MAX2(a, b) (a < b ? b : a) #define MAXS2(a, b) (TU_SO a < TU_SO b ? TU_SO b : TU_SO a) #define MAXS3(a, b, c) MAX2(MAXS2(a, b), TU_SO c) @@ -130,28 +130,28 @@ __type& as_##__tag() { assert(m_tag == TAG_##__tag); return reinterpret_cast<__type&>(m_data); } \ __type unwrap_##__tag() { assert(m_tag == TAG_##__tag); return ::std::move(reinterpret_cast<__type&>(m_data)); } \ // Define a tagged union constructor -#define TU_CONS(__name, name, _) TU_CONS_I(__name, name, TU_DATANAME(name)) +#define TU_CONS(__name, name, ...) TU_CONS_I(__name, name, TU_DATANAME(name)) // Type definitions #define TU_EXP(...) __VA_ARGS__ -#define TU_TYPEDEF(name, content) struct TU_DATANAME(name) { TU_EXP content; };/* +#define TU_TYPEDEF(name, ...) typedef __VA_ARGS__ TU_DATANAME(name);/* */ -#define TU_TAG(name, _) TAG_##name, +#define TU_TAG(name, ...) TAG_##name, // Destructor internals -#define TU_DEST_CASE(tag, _) case TAG_##tag: as_##tag().~TU_DATANAME(tag)(); break;/* +#define TU_DEST_CASE(tag, ...) case TAG_##tag: as_##tag().~TU_DATANAME(tag)(); break;/* */ // move constructor internals -#define TU_MOVE_CASE(tag, _) case TAG_##tag: new(m_data) TU_DATANAME(tag)(x.unwrap_##tag()); break;/* +#define TU_MOVE_CASE(tag, ...) case TAG_##tag: new(m_data) TU_DATANAME(tag)(x.unwrap_##tag()); break;/* */ // "tag_to_str" internals -#define TU_TOSTR_CASE(tag,_) case TAG_##tag: return #tag;/* +#define TU_TOSTR_CASE(tag,...) case TAG_##tag: return #tag;/* */ // "tag_from_str" internals -#define TU_FROMSTR_CASE(tag,_) else if(str == #tag) return TAG_##tag;/* +#define TU_FROMSTR_CASE(tag,...) else if(str == #tag) return TAG_##tag;/* */ #define MAXS(...) TU_GM(MAXS,__VA_ARGS__)(__VA_ARGS__) diff --git a/src/types.hpp b/src/types.hpp index 66121d37..ba20aa26 100644 --- a/src/types.hpp +++ b/src/types.hpp @@ -58,45 +58,45 @@ struct Type_Function: };
TAGGED_UNION(TypeData, None,
- (None, ()),
- (Any, ()),
- (Unit, ()),
- (Macro, (
+ (None, struct { }),
+ (Any, struct { }),
+ (Unit, struct { }),
+ (Macro, struct {
::AST::MacroInvocation inv;
- )),
- (Primitive, (
+ }),
+ (Primitive, struct {
enum eCoreType core_type;
- )),
- (Function, (
- Type_Function info;
- )),
- (Tuple, (
+ }),
+ (Function, struct {
+ Type_Function info;
+ }),
+ (Tuple, struct {
::std::vector<TypeRef> inner_types;
- )),
- (Borrow, (
+ }),
+ (Borrow, struct {
bool is_mut;
::std::unique_ptr<TypeRef> inner;
- )),
- (Pointer, (
+ }),
+ (Pointer, struct {
bool is_mut;
::std::unique_ptr<TypeRef> inner;
- )),
- (Array, (
+ }),
+ (Array, struct {
::std::unique_ptr<TypeRef> inner;
::std::shared_ptr<AST::ExprNode> size;
- )),
- (Generic, (
+ }),
+ (Generic, struct {
::std::string name;
unsigned int level;
const ::AST::GenericParams* params;
- )),
- (Path, (
+ }),
+ (Path, struct {
AST::Path path;
- )),
- (TraitObject, (
+ }),
+ (TraitObject, struct {
::std::vector<::std::string> hrls;
::std::vector<AST::Path> traits;
- ))
+ })
);
/// A type
|