Implements indexing, currently can only be used with strings
This commit is contained in:
13
src/ScriptType.cpp
Normal file
13
src/ScriptType.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#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);
|
||||
}
|
||||
Reference in New Issue
Block a user