Implements binding and evaluating function declarations

This commit is contained in:
2019-06-01 12:33:52 +02:00
parent c407ba2f50
commit 6936b26cae
11 changed files with 215 additions and 10 deletions

View File

@@ -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