1
2
3
4
5
6 #include <sngcpp/symbols/ParameterSymbol.hpp>
7 #include <sngcpp/symbols/FunctionSymbol.hpp>
8 #include <soulng/util/Unicode.hpp>
9
10 namespace sngcpp { namespace symbols {
11
12 using namespace soulng::unicode;
13
14 ParameterSymbol::ParameterSymbol(const Span& span_, const std::u32string& name_) : Symbol(span_, name_), type(nullptr)
15 {
16 }
17
18 std::u32string ParameterSymbol::IdStr()
19 {
20 std::u32string idStr = Symbol::IdStr();
21 if (Parent()->IsFunctionSymbol())
22 {
23 FunctionSymbol* function = static_cast<FunctionSymbol*>(Parent());
24 std::u32string functionIndexStr = ToUtf32(std::to_string(function->Index()));
25 idStr.append(1, '.').append(functionIndexStr);
26 }
27 else
28 {
29 throw std::runtime_error("function symbol expected");
30 }
31 return idStr;
32 }
33
34 std::std::unique_ptr<sngxml::dom::Element>ParameterSymbol::CreateElement()
35 {
36 std::unique_ptr<sngxml::dom::Element> parameterElement(new sngxml::dom::Element(U"parameter"));
37 parameterElement->SetAttribute(U"type", type->Id());
38 return parameterElement;
39 }
40
41 } }