PorygonLang/src/ScriptType.cpp

14 lines
501 B
C++
Raw Normal View History

#include "Script.hpp"
bool ScriptType::CanBeIndexedWith(ScriptType *indexer) {
// String type is the only simple script type we want to
return _class == TypeClass::String && indexer->_class == TypeClass::Number && !((NumericScriptType*)indexer)->IsFloat();
}
2019-06-09 18:15:09 +00:00
shared_ptr<ScriptType> ScriptType::GetIndexedType(ScriptType *indexer) {
if (_class == TypeClass::String){
2019-06-09 18:15:09 +00:00
return make_shared<ScriptType>(TypeClass::String);
}
2019-06-09 18:15:09 +00:00
return make_shared<ScriptType>(TypeClass::Error);
}