Implemented generic for loops
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -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);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user