Implements unknown types
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2019-09-01 20:07:09 +02:00
parent 01e5441d62
commit 0e9c9abf7c
6 changed files with 66 additions and 12 deletions

View File

@@ -77,6 +77,9 @@ namespace Porygon{
}
[[nodiscard]] virtual CastResult CastableTo(const shared_ptr<const ScriptType>& castType, bool explicitCast) const{
if (_class == TypeClass::All){
return CastResult ::UncheckedCast;
}
if (explicitCast)
return CastResult::InvalidCast;
return CastResult::InvalidCast;

View File

@@ -15,9 +15,18 @@ namespace Porygon{
_localVariableCount(localVariableCount)
{}
explicit TableScriptType()
: ScriptType(TypeClass::Table),
_values(nullptr),
_localVariableCount(0)
{}
~TableScriptType() final{
for (auto i : *_values){
delete i.second;
if (_values != nullptr){
for (const auto& i : *_values){
delete i.second;
}
}
delete _values;
}
@@ -33,10 +42,10 @@ namespace Porygon{
shared_ptr<const ScriptType> GetIndexedType(const ScriptType* indexer) const final{
auto stringKey = dynamic_cast<const StringScriptType*>(indexer);
if (stringKey->IsKnownAtBind()){
if (stringKey != nullptr && stringKey->IsKnownAtBind() && _values != nullptr){
return _values-> at(Utilities::HashedString::CreateLookup(stringKey->GetHashValue()))->GetType();
}
throw "TODO: indexing with dynamic keys";
return make_shared<ScriptType>(TypeClass::All);
}
[[nodiscard]] inline shared_ptr<const ScriptType> GetIndexedType(uint32_t hash) const final{
@@ -46,6 +55,16 @@ namespace Porygon{
[[nodiscard]] inline const map<Utilities::HashedString, BoundVariable*>* GetValues() const{
return _values;
}
[[nodiscard]]
bool CanBeIterated() const final {
return true;
}
[[nodiscard]]
shared_ptr<const ScriptType> GetIteratorKeyType() const final {
return make_shared<ScriptType>(TypeClass::All);
}
};
}