summaryrefslogtreecommitdiff
path: root/src/ast/macro.hpp
blob: 4696c7320311484f1e758b3e8213ea9a1f794e97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60

#ifndef _AST_MACRO_HPP_
#define _AST_MACRO_HPP_

#include "../parse/tokentree.hpp"
#include "attrs.hpp"

namespace AST {

class MacroInvocation:
    public Serialisable
{
    ::AST::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);
    }

    void clear() {
        m_macro_name = "";
        m_ident = "";
        m_input = TokenTree();
    }

    const ::std::string& name() const { return m_macro_name; }

    const ::std::string& input_ident() const { return m_ident; }
    const TokenTree& input_tt() const { return m_input; }


    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;
    }
};


}

#endif