1
2
3
4
5
6 #include <cmajor/binder/SystemDefaultAttributeProcessor.hpp>
7 #include <cmajor/symbols/Exception.hpp>
8 #include <soulng/util/Unicode.hpp>
9
10 namespace cmajor { namespace binder {
11
12 using namespace soulng::unicode;
13
14 SystemDefaultAttributeProcessor::SystemDefaultAttributeProcessor() : AttributeProcessor(U"system_default")
15 {
16 }
17
18 void SystemDefaultAttributeProcessor::TypeCheck(AttributeNode* attribute, Symbol* symbol)
19 {
20 if (symbol->IsFunctionSymbol())
21 {
22 FunctionSymbol* functionSymbol = static_cast<FunctionSymbol*>(symbol);
23 if (attribute->Value().empty() || attribute->Value() == U"true")
24 {
25 functionSymbol->SetSystemDefault();
26 }
27 else if (attribute->Value() != U"false")
28 {
29 throw Exception("unknown attribute value '" + ToUtf8(attribute->Value()) + "' for attribute '" + ToUtf8(attribute->Name()) + "'", attribute->GetSpan(), attribute->ModuleId());
30 }
31 }
32 else
33 {
34 AttributeProcessor::TypeCheck(attribute, symbol);
35 }
36 }
37
38 } }