Large overhaul of pointers to shared_ptrs, implemented function evaluation
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
#include <utility>
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include <utility>
|
||||
|
||||
#ifndef PORYGONLANG_SCRIPTTYPE_HPP
|
||||
#define PORYGONLANG_SCRIPTTYPE_HPP
|
||||
|
||||
@@ -8,6 +12,8 @@
|
||||
#include <memory>
|
||||
#include "Binder/BoundVariables/BoundVariableKey.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
enum class TypeClass{
|
||||
Error,
|
||||
Nil,
|
||||
@@ -32,11 +38,18 @@ public:
|
||||
return _class;
|
||||
}
|
||||
|
||||
virtual bool operator ==(ScriptType b){
|
||||
virtual bool operator ==(const ScriptType& b){
|
||||
return _class == b._class;
|
||||
};
|
||||
|
||||
virtual bool operator !=(ScriptType b){
|
||||
virtual bool operator ==(ScriptType* b){
|
||||
return _class == b->_class;
|
||||
};
|
||||
|
||||
virtual bool operator !=(const ScriptType& b){
|
||||
return ! (operator==(b));
|
||||
}
|
||||
virtual bool operator !=(ScriptType* b){
|
||||
return ! (operator==(b));
|
||||
}
|
||||
};
|
||||
@@ -62,26 +75,26 @@ public:
|
||||
};
|
||||
|
||||
class FunctionScriptType : public ScriptType{
|
||||
std::shared_ptr<ScriptType> _returnType;
|
||||
std::vector<std::shared_ptr<ScriptType>> _parameterTypes;
|
||||
std::vector<std::shared_ptr<BoundVariableKey>> _parameterKeys;
|
||||
shared_ptr<ScriptType> _returnType;
|
||||
shared_ptr<vector<shared_ptr<ScriptType>>> _parameterTypes;
|
||||
shared_ptr<vector<shared_ptr<BoundVariableKey>>> _parameterKeys;
|
||||
public:
|
||||
FunctionScriptType(std::shared_ptr<ScriptType> returnType, std::vector<std::shared_ptr<ScriptType>> parameterTypes,
|
||||
std::vector<std::shared_ptr<BoundVariableKey>> parameterKeys)
|
||||
FunctionScriptType(std::shared_ptr<ScriptType> returnType, shared_ptr<vector<shared_ptr<ScriptType>>> parameterTypes,
|
||||
shared_ptr<vector<shared_ptr<BoundVariableKey>>> parameterKeys)
|
||||
: ScriptType(TypeClass::Function){
|
||||
_returnType = std::move(returnType);
|
||||
_parameterTypes = std::move(parameterTypes);
|
||||
_parameterKeys = std::move(parameterKeys);
|
||||
}
|
||||
ScriptType* GetReturnType(){
|
||||
return _returnType.get();
|
||||
shared_ptr<ScriptType> GetReturnType(){
|
||||
return _returnType;
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<ScriptType>> GetParameterTypes(){
|
||||
shared_ptr<vector<shared_ptr<ScriptType>>> GetParameterTypes(){
|
||||
return _parameterTypes;
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<BoundVariableKey>> GetParameterKeys(){
|
||||
shared_ptr<vector<shared_ptr<BoundVariableKey>>> GetParameterKeys(){
|
||||
return _parameterKeys;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user