10 #include <llvm/Support/raw_ostream.h>
28 Number(int64_t v) : k_(Kind::NUMBER), v_(v) {}
31 int64_t
Get()
const {
return v_; }
34 void print(llvm::raw_ostream &os)
const;
46 String(
const std::string &v) : k_(Kind::STRING), v_(v) {}
49 const std::string &
Get()
const {
return v_; }
52 void print(llvm::raw_ostream &os)
const;
64 List() : k_(Kind::LIST) {}
66 Number *AddNumber(int64_t v);
67 String *AddString(
const std::string &v);
70 size_t size()
const {
return v_.size(); }
71 const SExp &operator[](
size_t idx)
const {
return v_[idx]; }
74 void print(llvm::raw_ostream &os)
const;
84 SExp() : s_(std::make_unique<Storage>()) {}
85 SExp(int64_t v) : s_(std::make_unique<Storage>(v)) {}
86 SExp(
const std::string &v) : s_(std::make_unique<Storage>(v)) {}
88 SExp(
SExp &&that) : s_(std::move(that.s_)) {}
89 SExp(
const SExp &that) : s_(std::make_unique<Storage>(*that.s_)) {}
101 const List *
AsList()
const;
106 void print(llvm::raw_ostream &os)
const;
120 Storage() {
new (&L) List(); }
121 Storage(int64_t v) {
new (&N) Number(v); }
122 Storage(
const std::string &v) {
new (&S) String(v); }
123 Storage(
const Storage &that);
128 std::unique_ptr<Storage> s_;