This commit is contained in:
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user