-
Notifications
You must be signed in to change notification settings - Fork 0
/
SymbolReference.h
56 lines (42 loc) · 1.04 KB
/
SymbolReference.h
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
#ifndef SYMBOLREFERENCE_H
#define SYMBOLREFERENCE_H
#include <memory>
#include <vector>
#include <iostream>
#include "Expression.h"
class SymbolReference : public Expression
{
std::wstring symbolName;
public:
SymbolReference(std::wstring symbolName) : symbolName(symbolName)
{
}
std::wstring getSymbolName() const
{
return symbolName;
}
virtual picojson::value asJson(std::shared_ptr<Substitution> subs, bool forConditionSection) const
{
if (subs->HasSubstitute(symbolName))
{
return subs->Substitute(symbolName, forConditionSection);
}
std::map<std::wstring, picojson::value> obj;
obj[L"Ref"] = picojson::value(symbolName);
return picojson::value(obj);
}
virtual ExpressionForm getForm() const
{
return SYMBOL_REFERENCE;
}
virtual std::wstring getType(std::shared_ptr<Substitution> subs) const
{
if (subs->HasTypeMapping(symbolName))
{
return subs->GetType(symbolName);
}
std::wcerr << "The symbol '" << symbolName << "' is not defined" << std::endl;
exit(EXIT_FAILURE);
}
};
#endif // SYMBOLREFERENCE_H