#ifndef PORYGONLANG_TABLESCRIPTTYPE_HPP #define PORYGONLANG_TABLESCRIPTTYPE_HPP #include #include "Binder/BoundVariables/BoundVariable.hpp" class TableScriptType : public ScriptType{ const unordered_map* _values; const int _localVariableCount; public: explicit TableScriptType(unordered_map* values, int localVariableCount) : ScriptType(TypeClass::Table), _values(values), _localVariableCount(localVariableCount) {} ~TableScriptType() final{ for (auto i : *_values){ delete i.second; } delete _values; } const bool CanBeIndexedWith(ScriptType* indexer) const final{ return indexer->GetClass() == TypeClass ::String; } const bool CanBeIndexedWithIdentifier(uint32_t hash) const final{ return true; } const shared_ptr GetIndexedType(ScriptType* indexer) const final{ auto stringKey = (StringScriptType*)indexer; if (stringKey->IsKnownAtBind()){ return _values-> at(stringKey->GetHashValue())->GetType(); } throw "TODO: indexing with dynamic keys"; } const shared_ptr GetIndexedType(uint32_t hash) const final{ return _values-> at(hash)->GetType(); } const unordered_map* GetValues() const{ return _values; } const int GetLocalVariableCount() const{ return _localVariableCount; } }; #include "ScriptType.hpp" #endif //PORYGONLANG_TABLESCRIPTTYPE_HPP