Implemented generic for loops
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2019-06-26 16:19:34 +02:00
parent cfd558b718
commit d86e9ba8ae
18 changed files with 325 additions and 44 deletions

View File

@@ -61,7 +61,14 @@ namespace Porygon{
virtual const shared_ptr<ScriptType> GetIndexedType(ScriptType* indexer) const;
virtual const shared_ptr<ScriptType> GetIndexedType(uint32_t hash) const{
throw "Shouldn't be possible";
throw "This type told the binder it can be indexed, but it does not implement the resulting type.";
}
virtual const bool CanBeIterated() const{
return false;
}
virtual shared_ptr<ScriptType> GetIteratorKeyType() const{
throw "This type told the binder it can be iterated, but it does not implement the resulting type.";
}
};
@@ -161,12 +168,22 @@ namespace Porygon{
}
const bool CanBeIndexedWith(ScriptType* indexer) const final{
return indexer->GetClass() == TypeClass ::Number;
if (indexer -> GetClass() != TypeClass::Number)
return false;
auto num =(NumericScriptType*)indexer;
return !(num->IsAwareOfFloat() && num->IsFloat());
}
const shared_ptr<ScriptType> GetIndexedType(ScriptType* indexer) const final{
return _valueType;
}
const bool CanBeIterated() const final{
return true;
}
shared_ptr<ScriptType> GetIteratorKeyType() const final{
return make_shared<StringScriptType>(false, 0);
}
};
}