diff --git a/src/Binder/Binder.cpp b/src/Binder/Binder.cpp index 82fbe47..59b51ab 100644 --- a/src/Binder/Binder.cpp +++ b/src/Binder/Binder.cpp @@ -124,6 +124,8 @@ namespace Porygon::Binder { return ScriptType::BoolType; case HashedString::ConstHash("string"): return StringScriptType::Dynamic; + case HashedString::ConstHash(("any")): + return ScriptType::AnyType; case HashedString::ConstHash("table"): return make_shared(); default: diff --git a/src/ScriptTypes/FunctionScriptType.hpp b/src/ScriptTypes/FunctionScriptType.hpp index f9cead8..e640ef5 100644 --- a/src/ScriptTypes/FunctionScriptType.hpp +++ b/src/ScriptTypes/FunctionScriptType.hpp @@ -41,7 +41,7 @@ namespace Porygon { return false; } for (size_t i = 0; i < parameters->size(); i++){ - if (_parameterTypes[i]->GetClass() == TypeClass::All) + if (_parameterTypes[i]->GetClass() == TypeClass::Any) continue; auto parameter = parameters->at(i); const auto& parameterType = parameter->GetType(); diff --git a/src/ScriptTypes/ScriptType.cpp b/src/ScriptTypes/ScriptType.cpp index 3cfbd39..786eedd 100644 --- a/src/ScriptTypes/ScriptType.cpp +++ b/src/ScriptTypes/ScriptType.cpp @@ -8,6 +8,7 @@ namespace Porygon{ shared_ptr ScriptType::BoolType = make_shared(TypeClass::Bool); shared_ptr ScriptType::NilType = make_shared(TypeClass::Nil); + shared_ptr ScriptType::AnyType = make_shared(TypeClass::Any); shared_ptr NumericScriptType::AwareInt = make_shared(true, false); shared_ptr NumericScriptType::AwareFloat = make_shared(true, true); shared_ptr NumericScriptType::Unaware = make_shared(false, false); @@ -20,7 +21,7 @@ namespace Porygon{ bool ScriptType::operator==(const shared_ptr &b) const { if (_class == TypeClass::Nil){ auto bClass = b->_class; - if (bClass == TypeClass::UserData || bClass == TypeClass::String || bClass == TypeClass::All) + if (bClass == TypeClass::UserData || bClass == TypeClass::String || bClass == TypeClass::Any) return true; } return _class == b->_class; @@ -47,7 +48,7 @@ namespace Porygon{ } CastResult ScriptType::CastableTo(const shared_ptr &castType, bool explicitCast) const { - if (_class == TypeClass::All){ + if (_class == TypeClass::Any){ return CastResult ::UncheckedCast; } if (explicitCast) @@ -66,7 +67,7 @@ namespace Porygon{ case TypeClass::Function: return "function"; case TypeClass::UserData: return "userdata"; case TypeClass::Table: return "table"; - case TypeClass::All: return "all"; + case TypeClass::Any: return "all"; } throw exception(); } diff --git a/src/ScriptTypes/ScriptType.hpp b/src/ScriptTypes/ScriptType.hpp index 3f9f60f..3d86141 100644 --- a/src/ScriptTypes/ScriptType.hpp +++ b/src/ScriptTypes/ScriptType.hpp @@ -19,7 +19,7 @@ namespace Porygon{ Function, UserData, Table, - All, + Any, }; class ScriptType{ @@ -27,6 +27,7 @@ namespace Porygon{ public: static shared_ptr BoolType; static shared_ptr NilType; + static shared_ptr AnyType; explicit ScriptType(TypeClass c){ _class = c; diff --git a/src/ScriptTypes/TableScriptType.hpp b/src/ScriptTypes/TableScriptType.hpp index e40b53c..5c823ed 100644 --- a/src/ScriptTypes/TableScriptType.hpp +++ b/src/ScriptTypes/TableScriptType.hpp @@ -45,7 +45,7 @@ namespace Porygon{ if (stringKey != nullptr && stringKey->IsKnownAtBind() && _values != nullptr){ return _values-> at(Utilities::HashedString::CreateLookup(stringKey->GetHashValue()))->GetType(); } - return make_shared(TypeClass::All); + return make_shared(TypeClass::Any); } [[nodiscard]] inline shared_ptr GetIndexedType(uint32_t hash) const final{ @@ -63,7 +63,7 @@ namespace Porygon{ [[nodiscard]] shared_ptr GetIteratorKeyType() const final { - return make_shared(TypeClass::All); + return make_shared(TypeClass::Any); } }; } diff --git a/src/StandardLibraries/BasicLibrary.hpp b/src/StandardLibraries/BasicLibrary.hpp index e507bdd..4850882 100644 --- a/src/StandardLibraries/BasicLibrary.hpp +++ b/src/StandardLibraries/BasicLibrary.hpp @@ -91,7 +91,7 @@ namespace Porygon::StandardLibraries{ return new Evaluation::StringEvalValue(parameter); } static shared_ptr GetToStringFuncType(){ - return GetFuncType(StringScriptType::Dynamic, {{make_shared(TypeClass::All)}}); + return GetFuncType(StringScriptType::Dynamic, {{make_shared(TypeClass::Any)}}); } //endregion //region Type @@ -108,12 +108,12 @@ namespace Porygon::StandardLibraries{ case TypeClass::Function: return new Evaluation::StringEvalValue(u"function"); case TypeClass::UserData: return new Evaluation::StringEvalValue(u"userdata"); case TypeClass::Table: return new Evaluation::StringEvalValue(u"table"); - case TypeClass::All: return new Evaluation::StringEvalValue(u"all"); + case TypeClass::Any: return new Evaluation::StringEvalValue(u"all"); } throw exception(); } static shared_ptr GetTypeFuncType(){ - return GetFuncType(StringScriptType::Dynamic,{{make_shared(TypeClass::All)}}); + return GetFuncType(StringScriptType::Dynamic,{{make_shared(TypeClass::Any)}}); } //endregion //region IsFloat