Implements basic numerical tables
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2019-06-09 20:15:09 +02:00
parent ec2419bc7d
commit 081def0be0
21 changed files with 324 additions and 24 deletions

View File

@@ -1,8 +1,3 @@
#include <utility>
#include <utility>
#include <utility>
#ifndef PORYGONLANG_SCRIPTTYPE_HPP
#define PORYGONLANG_SCRIPTTYPE_HPP
@@ -55,7 +50,7 @@ public:
virtual bool CanBeIndexedWith(ScriptType* indexer);
virtual ScriptType* GetIndexedType(ScriptType* indexer);
virtual shared_ptr<ScriptType> GetIndexedType(ScriptType* indexer);
};
class NumericScriptType : public ScriptType{
@@ -109,4 +104,24 @@ public:
}
};
class TableScriptType : public ScriptType{
shared_ptr<ScriptType> _keyType;
shared_ptr<ScriptType> _valueType;
// Consider adding a check whether the table actually contains a type if every key is static.
public:
TableScriptType(shared_ptr<ScriptType> keyType, shared_ptr<ScriptType> valueType) : ScriptType(TypeClass::Table){
_keyType = std::move(keyType);
_valueType = std::move(valueType);
}
bool CanBeIndexedWith(ScriptType* indexer) final{
return _keyType.get()->operator==(indexer);
}
shared_ptr<ScriptType> GetIndexedType(ScriptType* indexer) final{
return _valueType;
}
};
#endif //PORYGONLANG_SCRIPTTYPE_HPP