Implements userdata function support
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#include <utility>
|
||||
|
||||
#include <utility>
|
||||
|
||||
|
||||
#ifndef PORYGONLANG_SCRIPTTYPE_HPP
|
||||
#define PORYGONLANG_SCRIPTTYPE_HPP
|
||||
@@ -101,20 +103,16 @@ namespace Porygon{
|
||||
}
|
||||
};
|
||||
|
||||
class FunctionScriptType : public ScriptType{
|
||||
class GenericFunctionScriptType : public ScriptType{
|
||||
shared_ptr<ScriptType> _returnType;
|
||||
vector<shared_ptr<ScriptType>> _parameterTypes;
|
||||
vector<shared_ptr<Binder::BoundVariableKey>> _parameterKeys;
|
||||
int _scopeIndex;
|
||||
public:
|
||||
FunctionScriptType(std::shared_ptr<ScriptType> returnType, vector<shared_ptr<ScriptType>> parameterTypes,
|
||||
vector<shared_ptr<Binder::BoundVariableKey>> parameterKeys, int scopeIndex)
|
||||
: ScriptType(TypeClass::Function){
|
||||
GenericFunctionScriptType(std::shared_ptr<ScriptType> returnType, vector<shared_ptr<ScriptType>> parameterTypes)
|
||||
: ScriptType(TypeClass::Function){
|
||||
_returnType = std::move(returnType);
|
||||
_parameterTypes = std::move(parameterTypes);
|
||||
_parameterKeys = std::move(parameterKeys);
|
||||
_scopeIndex = scopeIndex;
|
||||
}
|
||||
|
||||
const shared_ptr<ScriptType> GetReturnType() const{
|
||||
return _returnType;
|
||||
}
|
||||
@@ -127,6 +125,20 @@ namespace Porygon{
|
||||
return _parameterTypes;
|
||||
}
|
||||
|
||||
virtual const bool IsScriptFunction() const = 0;
|
||||
};
|
||||
|
||||
class FunctionScriptType : public GenericFunctionScriptType{
|
||||
vector<shared_ptr<Binder::BoundVariableKey>> _parameterKeys;
|
||||
int _scopeIndex;
|
||||
public:
|
||||
FunctionScriptType(std::shared_ptr<ScriptType> returnType, vector<shared_ptr<ScriptType>> parameterTypes,
|
||||
vector<shared_ptr<Binder::BoundVariableKey>> parameterKeys, int scopeIndex)
|
||||
: GenericFunctionScriptType(std::move(returnType), parameterTypes){
|
||||
_parameterKeys = std::move(parameterKeys);
|
||||
_scopeIndex = scopeIndex;
|
||||
}
|
||||
|
||||
const vector<shared_ptr<Binder::BoundVariableKey>> GetParameterKeys() const{
|
||||
return _parameterKeys;
|
||||
}
|
||||
@@ -134,6 +146,10 @@ namespace Porygon{
|
||||
const int GetScopeIndex() const{
|
||||
return _scopeIndex;
|
||||
}
|
||||
|
||||
const bool IsScriptFunction() const final{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class NumericalTableScriptType : public ScriptType{
|
||||
|
||||
Reference in New Issue
Block a user