1
2
3
4
5
6 #ifndef CMAJOR_SYMBOLS_CONSTANT_SYMBOL_INCLUDED
7 #define CMAJOR_SYMBOLS_CONSTANT_SYMBOL_INCLUDED
8 #include <cmajor/symbols/Symbol.hpp>
9 #include <cmajor/symbols/Value.hpp>
10
11 namespace cmajor { namespace symbols {
12
13 class ConstantSymbol : public Symbol
14 {
15 public:
16 ConstantSymbol(const Span& span_, const boost::uuids::uuid& sourceModuleId_, const std::u32string& name_);
17 void Write(SymbolWriter& writer) override;
18 void Read(SymbolReader& reader) override;
19 void EmplaceType(TypeSymbol* typeSymbol, int index) override;
20 void Accept(SymbolCollector* collector) override;
21 void Dump(CodeFormatter& formatter) override;
22 std::string TypeString() const override { return "constant"; }
23 std::string Syntax() const override;
24 void SetSpecifiers(Specifiers specifiers);
25 void ComputeMangledName() override;
26 bool Evaluating() const { return evaluating; }
27 void SetEvaluating() { evaluating = true; }
28 void ResetEvaluating() { evaluating = false; }
29 const TypeSymbol* GetType() const { return type; }
30 TypeSymbol* GetType() { return type; }
31 void SetType(TypeSymbol* typeSymbol) { type = typeSymbol; }
32 void SetValue(Value* value_);
33 Value* GetValue();
34 void* ArrayIrObject(Emitter& emitter, bool create);
35 void* StructureIrObject(Emitter& emitter, bool create);
36 std::u32string Info() const override { return Name(); }
37 const char* ClassName() const override { return "ConstantSymbol"; }
38 void SetStrValue(const std::u32string& strValue_) { strValue = strValue_; }
39 const std::u32string& StrValue() const { return strValue; }
40 void Check() override;
41 std::string GetSymbolCategoryStr() const override { return "CN"; }
42 std::string GetSymbolCategoryDescription() const override { return "constant"; }
43 std::string GetSymbolHelp() const override;
44 private:
45 TypeSymbol* type;
46 std::unique_ptr<Value> value;
47 bool evaluating;
48 uint32_t sizeOfValue;
49 uint32_t valuePos;
50 std::string filePathReadFrom;
51 std::u32string strValue;
52 };
53
54 } }
55
56 #endif // CMAJOR_SYMBOLS_CONSTANT_SYMBOL_INCLUDED