Implements support for functions with the same name, but different parameters
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2019-06-29 19:59:42 +02:00
parent 24c560b52d
commit db2d731b06
23 changed files with 362 additions and 204 deletions

View File

@@ -1,7 +1,3 @@
#include <utility>
#include <utility>
#ifndef PORYGONLANG_SCRIPTTYPE_HPP
#define PORYGONLANG_SCRIPTTYPE_HPP
@@ -110,55 +106,6 @@ namespace Porygon{
}
};
class GenericFunctionScriptType : public ScriptType{
shared_ptr<ScriptType> _returnType;
vector<shared_ptr<ScriptType>> _parameterTypes;
public:
GenericFunctionScriptType(std::shared_ptr<ScriptType> returnType, vector<shared_ptr<ScriptType>> parameterTypes)
: ScriptType(TypeClass::Function){
_returnType = std::move(returnType);
_parameterTypes = std::move(parameterTypes);
}
const shared_ptr<ScriptType> GetReturnType() const{
return _returnType;
}
void SetReturnType(shared_ptr<ScriptType> t){
_returnType = std::move(t);
}
const vector<shared_ptr<ScriptType>> GetParameterTypes() const{
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;
}
const int GetScopeIndex() const{
return _scopeIndex;
}
const bool IsScriptFunction() const final{
return true;
}
};
class NumericalTableScriptType : public ScriptType{
shared_ptr<ScriptType> _valueType;
// Consider adding a check whether the table actually contains a type if every key is static.