blob: 36539fb0e0ac3b14dfaf0249f0baab4a1c7c3a55 (
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
61
|
/*
* MRustC - Mutabah's Rust Compiler
* - By John Hodge (Mutabah/thePowersGang)
*
* parse/interpolated_fragment.hpp
* - An "interpolated fragment", result of parsing e.g. :expr in a macro invocation
*/
#pragma once
#include <cassert>
class TypeRef;
class TokenTree;
namespace AST {
class Pattern;
class Path;
class ExprNode;
class Attribute;
template<typename T> struct Named;
class Item;
};
class InterpolatedFragment
{
public:
enum Type
{
TT,
PAT,
PATH,
TYPE,
EXPR,
STMT,
BLOCK,
META,
ITEM,
} m_type;
// Owned type-pruned pointer
void* m_ptr;
InterpolatedFragment(InterpolatedFragment&& );
InterpolatedFragment& operator=(InterpolatedFragment&& );
//InterpolatedFragment(const InterpolatedFragment& );
InterpolatedFragment(TokenTree );
InterpolatedFragment(::AST::Pattern);
InterpolatedFragment(::AST::Path);
InterpolatedFragment(::TypeRef);
InterpolatedFragment(::AST::Attribute );
InterpolatedFragment(::AST::Named<AST::Item> );
~InterpolatedFragment();
InterpolatedFragment(Type , ::AST::ExprNode*);
TokenTree& as_tt() { assert(m_type == TT); return *reinterpret_cast<TokenTree*>(m_ptr); }
const TokenTree& as_tt() const { assert(m_type == TT); return *reinterpret_cast<TokenTree*>(m_ptr); }
friend ::std::ostream& operator<<(::std::ostream& os, const InterpolatedFragment& x);
};
|