summaryrefslogtreecommitdiff
path: root/src/ast/ast.hpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-02-27 10:06:54 +0800
committerJohn Hodge <tpg@mutabah.net>2016-02-27 10:06:54 +0800
commitd1d84ced588b40bdec67ee8bdb184a31d3ae9e7d (patch)
treee85de4bd13f8b5e50f43550613d835ecfeeb5b78 /src/ast/ast.hpp
parentd8d5791b465a8b095deecf7a80f022cfbdd23518 (diff)
downloadmrust-d1d84ced588b40bdec67ee8bdb184a31d3ae9e7d.tar.gz
Parse/impl - Handle macro invocations
Diffstat (limited to 'src/ast/ast.hpp')
-rw-r--r--src/ast/ast.hpp72
1 files changed, 38 insertions, 34 deletions
diff --git a/src/ast/ast.hpp b/src/ast/ast.hpp
index 4165b34d..2aea5ac1 100644
--- a/src/ast/ast.hpp
+++ b/src/ast/ast.hpp
@@ -214,6 +214,40 @@ using ItemList = ::std::vector<Item<T> >;
typedef Item<TypeRef> StructItem;
class Crate;
+class MacroInvocation:
+ public Serialisable
+{
+ MetaItems m_attrs;
+ ::std::string m_macro_name;
+ ::std::string m_ident;
+ TokenTree m_input;
+public:
+ MacroInvocation()
+ {
+ }
+
+ MacroInvocation(MetaItems attrs, ::std::string macro, ::std::string ident, TokenTree input):
+ m_attrs( mv$(attrs) ),
+ m_macro_name( mv$(macro) ),
+ m_ident( mv$(ident) ),
+ m_input( mv$(input) )
+ {
+ }
+
+ static ::std::unique_ptr<MacroInvocation> from_deserialiser(Deserialiser& s) {
+ auto i = new MacroInvocation;
+ s.item( *i );
+ return ::std::unique_ptr<MacroInvocation>(i);
+ }
+
+ SERIALISABLE_PROTOTYPES();
+
+ friend ::std::ostream& operator<<(::std::ostream& os, const MacroInvocation& x) {
+ os << x.m_attrs << x.m_macro_name << "! " << x.m_ident << x.m_input;
+ return os;
+ }
+};
+
class TypeAlias:
public Serialisable
{
@@ -511,6 +545,7 @@ class Impl:
ItemList<TypeRef> m_types;
ItemList<Function> m_functions;
ItemList<Static> m_statics;
+ ::std::vector<MacroInvocation> m_macro_invocations;
::std::vector< ::std::pair< ::std::vector<TypeRef>, Impl > > m_concrete_impls;
public:
@@ -529,6 +564,9 @@ public:
void add_static(bool is_public, ::std::string name, Static v) {
m_statics.push_back( Item<Static>( mv$(name), mv$(v), is_public ) );
}
+ void add_macro_invocation( MacroInvocation inv ) {
+ m_macro_invocations.push_back( mv$(inv) );
+ }
const ImplDef& def() const { return m_def; }
const ItemList<Function>& functions() const { return m_functions; }
@@ -558,40 +596,6 @@ class Module;
typedef void fcn_visitor_t(const AST::Crate& crate, const AST::Module& mod, Function& fcn);
-class MacroInvocation:
- public Serialisable
-{
- MetaItems m_attrs;
- ::std::string m_macro_name;
- ::std::string m_ident;
- TokenTree m_input;
-public:
- MacroInvocation()
- {
- }
-
- MacroInvocation(MetaItems attrs, ::std::string macro, ::std::string ident, TokenTree input):
- m_attrs( mv$(attrs) ),
- m_macro_name( mv$(macro) ),
- m_ident( mv$(ident) ),
- m_input( mv$(input) )
- {
- }
-
- static ::std::unique_ptr<MacroInvocation> from_deserialiser(Deserialiser& s) {
- auto i = new MacroInvocation;
- s.item( *i );
- return ::std::unique_ptr<MacroInvocation>(i);
- }
-
- SERIALISABLE_PROTOTYPES();
-
- friend ::std::ostream& operator<<(::std::ostream& os, const MacroInvocation& x) {
- os << x.m_attrs << x.m_macro_name << "! " << x.m_ident << x.m_input;
- return os;
- }
-};
-
/// Representation of a parsed (and being converted) function
class Module:
public Serialisable