Start adding statements
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
|
||||
std::string Object::to_string() {
|
||||
std::string Object::to_string() const {
|
||||
switch (type) {
|
||||
case ObjectType::NIL:
|
||||
return "nil";
|
||||
@@ -78,25 +78,7 @@ std::ostream &operator<<(std::ostream &os, const ObjectType &type) {
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &os, const Object &obj) {
|
||||
os << "Object(" << obj.type;
|
||||
|
||||
switch (obj.type) {
|
||||
case ObjectType::NIL:
|
||||
break;
|
||||
case ObjectType::BOOL:
|
||||
os << ", " << std::to_string(std::get<bool>(obj.value));
|
||||
break;
|
||||
case ObjectType::IDENTIFIER:
|
||||
case ObjectType::STRING_LIT:
|
||||
os << ", " << std::get<std::string>(obj.value);
|
||||
break;
|
||||
case ObjectType::NUMBER:
|
||||
os << ", " << std::get<double>(obj.value);
|
||||
break;
|
||||
}
|
||||
|
||||
os << ')';
|
||||
|
||||
os << obj.to_string();
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ struct Object {
|
||||
ObjectType::STRING_LIT
|
||||
},
|
||||
value{std::move(value)} {};
|
||||
std::string to_string();
|
||||
std::string to_string() const;
|
||||
bool operator==(const Object &other);
|
||||
bool operator!=(const Object &other);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user