PorygonLang/src/ScriptType.cpp

14 lines
472 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();
}
ScriptType *ScriptType::GetIndexedType(ScriptType *indexer) {
if (_class == TypeClass::String){
return new ScriptType(TypeClass::String);
}
return new ScriptType(TypeClass::Error);
}