PorygonLang/src/Evaluator/EvalValues/StringEvalValue.hpp

39 lines
850 B
C++
Raw Normal View History

#ifndef PORYGONLANG_STRINGEVALVALUE_HPP
#define PORYGONLANG_STRINGEVALVALUE_HPP
#include <string>
#include "EvalValue.hpp"
using namespace std;
class StringEvalValue : public EvalValue{
string _value;
std::shared_ptr<ScriptType> _type;
public:
explicit StringEvalValue(string s){
_value = move(s);
_type = std::make_shared<ScriptType>(TypeClass::String);
}
std::shared_ptr<ScriptType> GetType() final{
return _type;
};
bool operator ==(EvalValue* b) final{
if (b->GetType()->GetClass() != TypeClass::String)
return false;
return this->_value == b->EvaluateString();
};
string EvaluateString() final{
return _value;
}
EvalValue* Clone() final{
return new StringEvalValue(_value);
}
};
#endif //PORYGONLANG_STRINGEVALVALUE_HPP