summaryrefslogtreecommitdiff
path: root/src/expand/std_prelude.cpp
blob: c8ad6471f340d06a0d53c81d6cfae4dbed38cd63 (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
/*
 */
#include <synext.hpp>
#include <ast/crate.hpp>

class Decorator_NoStd:
    public ExpandDecorator
{
public:
    AttrStage stage() const override { return AttrStage::EarlyPre; }
    
    void handle(const AST::MetaItem& mi, AST::Crate& crate) const override {
        if( crate.m_load_std != AST::Crate::LOAD_STD ) {
            ERROR(Span()/*mi.span()*/, E0000, "Invalid use of #![no_std] with itself or #![no_core]");
        }
        crate.m_load_std = AST::Crate::LOAD_CORE;
    }
};
class Decorator_NoCore:
    public ExpandDecorator
{
public:
    AttrStage stage() const override { return AttrStage::EarlyPre; }
    
    void handle(const AST::MetaItem& mi, AST::Crate& crate) const override {
        if( crate.m_load_std != AST::Crate::LOAD_STD ) {
            ERROR(Span()/*mi.span()*/, E0000, "Invalid use of #![no_core] with itself or #![no_std]");
        }
        crate.m_load_std = AST::Crate::LOAD_NONE;
    }
};
//class Decorator_Prelude:
//    public ExpandDecorator
//{
//public:
//    AttrStage stage() const override { return AttrStage::EarlyPre; }
//};

class Decorator_NoPrelude:
    public ExpandDecorator
{
public:
    AttrStage stage() const override { return AttrStage::EarlyPre; }
};



STATIC_DECORATOR("no_std", Decorator_NoStd)
STATIC_DECORATOR("no_core", Decorator_NoCore)
//STATIC_DECORATOR("prelude", Decorator_Prelude)

STATIC_DECORATOR("no_prelude", Decorator_NoPrelude)