Rework evaluation to use shared pointers, fix bugs

This commit is contained in:
2019-06-01 21:38:39 +02:00
parent 4408cf00cd
commit 6206fef4c5
17 changed files with 122 additions and 133 deletions

View File

@@ -90,7 +90,7 @@ VariableAssignment BoundScope::AssignVariable(int identifier, const std::shared_
} else{
// Assigning
auto var = this->GetVariable(exists, identifier);
if (var->GetType() != type){
if (var->GetType().get()->operator!=(type.get())){
return VariableAssignment(VariableAssignmentResult::VariableDefinedWithDifferentType, nullptr);
}
return VariableAssignment(VariableAssignmentResult::Ok, new BoundVariableKey(identifier, exists, false));

View File

@@ -1,3 +1,5 @@
#include <utility>
#ifndef PORYGONLANG_BOUNDVARIABLE_HPP
#define PORYGONLANG_BOUNDVARIABLE_HPP
@@ -10,9 +12,7 @@ using namespace std;
class BoundVariable{
std::shared_ptr<ScriptType> _type;
public:
explicit BoundVariable(std::shared_ptr<ScriptType> type) : _type(type){
}
~BoundVariable(){
explicit BoundVariable(std::shared_ptr<ScriptType> type) : _type(std::move(type)){
}
std::shared_ptr<ScriptType> GetType(){