40 lines
1.5 KiB
C++
40 lines
1.5 KiB
C++
#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> ScriptType::GetIndexedType(ScriptType *indexer) const{
|
|
if (_class == TypeClass::String){
|
|
return make_shared<ScriptType>(TypeClass::String);
|
|
}
|
|
return make_shared<ScriptType>(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<shared_ptr<ScriptType>> vector(parameterCount);
|
|
for (int i = 0; i < parameterCount; i++){
|
|
vector[i] = shared_ptr<ScriptType>(parameters[i]);
|
|
}
|
|
return new UserData::UserDataFunctionType(shared_ptr<ScriptType>(returnType), vector);
|
|
}
|
|
}
|
|
}
|
|
|