2025-06-08 15:08:45 +01:00

29 lines
626 B
C++

#include "object.hh"
Object::Object(StringObjectType string_type, const std::string &value) : str{value} {
switch (string_type) {
case StringObjectType::IDENTIFIER:
type = ObjectType::IDENTIFIER;
break;
case StringObjectType::LITERAL:
type = ObjectType::STRING_LIT;
break;
}
}
std::ostream &operator<<(std::ostream &os, const Object &obj) {
switch (obj.type) {
case ObjectType::NIL:
break;
case ObjectType::IDENTIFIER:
case ObjectType::STRING_LIT:
os << obj.str;
break;
case ObjectType::NUMBER:
os << obj.number;
break;
}
return os;
}