Implements binding and evaluating function declarations
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
|
||||
#ifndef PORYGONLANG_SCRIPTTYPE_HPP
|
||||
#define PORYGONLANG_SCRIPTTYPE_HPP
|
||||
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
enum class TypeClass{
|
||||
Error,
|
||||
Nil,
|
||||
@@ -55,4 +57,41 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class FunctionScriptType : public ScriptType{
|
||||
ScriptType* _returnType;
|
||||
std::vector<ScriptType*> _parameterTypes;
|
||||
std::vector<int> _parameterKeys;
|
||||
int _scopeId;
|
||||
public:
|
||||
FunctionScriptType(ScriptType* returnType, std::vector<ScriptType*> parameterTypes, std::vector<int> parameterKeys, int scopeId)
|
||||
: ScriptType(TypeClass::Function){
|
||||
_returnType = returnType;
|
||||
_parameterTypes = std::move(parameterTypes);
|
||||
_parameterKeys = std::move(parameterKeys);
|
||||
_scopeId = scopeId;
|
||||
}
|
||||
~FunctionScriptType() final{
|
||||
delete _returnType;
|
||||
for (auto t: _parameterTypes){
|
||||
delete t;
|
||||
}
|
||||
}
|
||||
|
||||
ScriptType* GetReturnType(){
|
||||
return _returnType;
|
||||
}
|
||||
|
||||
std::vector<ScriptType*> GetParameterTypes(){
|
||||
return _parameterTypes;
|
||||
}
|
||||
|
||||
std::vector<int> GetParameterKeys(){
|
||||
return _parameterKeys;
|
||||
}
|
||||
|
||||
int GetScopeId(){
|
||||
return _scopeId;
|
||||
}
|
||||
};
|
||||
|
||||
#endif //PORYGONLANG_SCRIPTTYPE_HPP
|
||||
|
||||
Reference in New Issue
Block a user