General cleanup
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2019-07-04 18:24:49 +02:00
parent 0446c1098b
commit bb0a6aba19
20 changed files with 90 additions and 92 deletions

View File

@@ -1,3 +1,5 @@
#include <utility>
#ifndef PORYGONLANG_SCRIPTTYPE_HPP
#define PORYGONLANG_SCRIPTTYPE_HPP
@@ -97,6 +99,17 @@ namespace Porygon{
_hashValue = hashValue;
}
const bool CanBeIndexedWith(ScriptType* indexer) const final{
if (indexer -> GetClass() != TypeClass::Number)
return false;
auto num = dynamic_cast<NumericScriptType*>(indexer);
return !(num->IsAwareOfFloat() && num->IsFloat());
}
const shared_ptr<ScriptType> GetIndexedType(ScriptType* indexer) const final{
return make_shared<StringScriptType>(false, 0);
}
const bool IsKnownAtBind() const{
return _isKnownAtBind;
}
@@ -110,14 +123,14 @@ namespace Porygon{
shared_ptr<ScriptType> _valueType;
// Consider adding a check whether the table actually contains a type if every key is static.
public:
explicit NumericalTableScriptType(shared_ptr<ScriptType> valueType) : ScriptType(TypeClass::Table){
_valueType = std::move(valueType);
explicit NumericalTableScriptType(shared_ptr<ScriptType> valueType)
: ScriptType(TypeClass::Table), _valueType(std::move(valueType)){
}
const bool CanBeIndexedWith(ScriptType* indexer) const final{
if (indexer -> GetClass() != TypeClass::Number)
return false;
auto num =(NumericScriptType*)indexer;
auto num = dynamic_cast<NumericScriptType*>(indexer);
return !(num->IsAwareOfFloat() && num->IsFloat());
}