Added namespaces to most classes, general cleanup
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2019-06-17 18:35:12 +02:00
parent 21d3329c55
commit fde102d954
66 changed files with 4301 additions and 3909 deletions

View File

@@ -8,43 +8,44 @@
using namespace std;
class StringEvalValue : public EvalValue{
u16string _value;
size_t _hash;
public:
explicit StringEvalValue(u16string s){
_value = move(s);
_hash = HashedString::ConstHash (_value.c_str());
}
namespace Porygon::Evaluation {
class StringEvalValue : public EvalValue {
u16string _value;
size_t _hash;
public:
explicit StringEvalValue(u16string s) {
_value = move(s);
_hash = Utilities::HashedString::ConstHash(_value.c_str());
}
const TypeClass GetTypeClass() const final{
return TypeClass ::String;
}
const TypeClass GetTypeClass() const final {
return TypeClass::String;
}
const bool operator ==(EvalValue* b) const final{
if (b->GetTypeClass() != TypeClass::String)
return false;
return this->_hash == b->GetHashCode();
const bool operator==(EvalValue *b) const final {
if (b->GetTypeClass() != TypeClass::String)
return false;
return this->_hash == b->GetHashCode();
};
const u16string *EvaluateString() const final {
return &_value;
}
const shared_ptr<EvalValue> Clone() const final {
return make_shared<StringEvalValue>(_value);
}
const shared_ptr<EvalValue> IndexValue(EvalValue *val) const final {
// Porygon is 1-indexed, so we convert to that.
auto l = val->EvaluateInteger() - 1;
return make_shared<StringEvalValue>(u16string(1, _value[l]));
}
const std::size_t GetHashCode() const final {
return _hash;
}
};
const u16string* EvaluateString() const final{
return &_value;
}
const shared_ptr<EvalValue> Clone() const final{
return make_shared<StringEvalValue>(_value);
}
const shared_ptr<EvalValue> IndexValue(EvalValue* val) const final{
// Porygon is 1-indexed, so we convert to that.
auto l = val->EvaluateInteger() - 1;
return make_shared<StringEvalValue>(u16string(1, _value[l]));
}
const std::size_t GetHashCode() const final{
return _hash;
}
};
}
#endif //PORYGONLANG_STRINGEVALVALUE_HPP