#include "Script.hpp" #include "UserData/UserDataFunctionType.hpp" namespace Porygon{ const bool ScriptType::CanBeIndexedWith(ScriptType *indexer) const{ // String type is the only simple script type we want to return _class == TypeClass::String && indexer->_class == TypeClass::Number && !((NumericScriptType*)indexer)->IsFloat(); } const shared_ptr ScriptType::GetIndexedType(ScriptType *indexer) const{ if (_class == TypeClass::String){ return make_shared(TypeClass::String); } return make_shared(TypeClass::Error); } extern "C"{ ScriptType* CreateScriptType(Porygon::TypeClass t){ return new ScriptType(t); } ScriptType* CreateNumericScriptType(bool isAware, bool isFloat){ return new NumericScriptType(isAware, isFloat); } ScriptType* CreateStringScriptType(bool knownAtBind, uint32_t hash){ return new StringScriptType(knownAtBind, hash); } ScriptType* CreateUserDataFunctionScriptType(ScriptType* returnType, ScriptType* parameters[], size_t parameterCount){ vector> vector(parameterCount); for (int i = 0; i < parameterCount; i++){ vector[i] = shared_ptr(parameters[i]); } return new UserData::UserDataFunctionType(shared_ptr(returnType), vector); } } }