Rework function evaluation scope to handle tables
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#include <utility>
|
||||
|
||||
#include <utility>
|
||||
|
||||
#ifndef PORYGONLANG_SCRIPTFUNCTIONEVALVALUE_HPP
|
||||
#define PORYGONLANG_SCRIPTFUNCTIONEVALVALUE_HPP
|
||||
|
||||
@@ -9,24 +11,30 @@
|
||||
#include "EvalValue.hpp"
|
||||
#include "../../Binder/BoundStatements/BoundStatement.hpp"
|
||||
#include "../Evaluator.hpp"
|
||||
#include "../EvaluationScope/EvaluationScope.hpp"
|
||||
|
||||
|
||||
class ScriptFunctionEvalValue : public EvalValue{
|
||||
std::shared_ptr<BoundBlockStatement> _innerBlock;
|
||||
std::shared_ptr<FunctionScriptType> _type;
|
||||
std::shared_ptr<EvaluationScope> _scope;
|
||||
std::size_t _hash;
|
||||
explicit ScriptFunctionEvalValue(std::shared_ptr<BoundBlockStatement> innerBlock, std::shared_ptr<FunctionScriptType> type, size_t hash)
|
||||
explicit ScriptFunctionEvalValue(std::shared_ptr<BoundBlockStatement> innerBlock, std::shared_ptr<EvaluationScope> scope,
|
||||
std::shared_ptr<FunctionScriptType> type, size_t hash)
|
||||
: _type(std::move(type))
|
||||
{
|
||||
_innerBlock = std::move(innerBlock);
|
||||
_scope = std::move(scope);
|
||||
_hash = hash;
|
||||
}
|
||||
|
||||
public:
|
||||
explicit ScriptFunctionEvalValue(std::shared_ptr<BoundBlockStatement> innerBlock, std::shared_ptr<FunctionScriptType> type)
|
||||
explicit ScriptFunctionEvalValue(std::shared_ptr<BoundBlockStatement> innerBlock, std::shared_ptr<EvaluationScope> scope,
|
||||
std::shared_ptr<FunctionScriptType> type)
|
||||
: _type(std::move(type))
|
||||
{
|
||||
_innerBlock = std::move(innerBlock);
|
||||
_scope = std::move(scope);
|
||||
_hash = rand();
|
||||
}
|
||||
|
||||
@@ -35,7 +43,7 @@ public:
|
||||
}
|
||||
|
||||
shared_ptr<EvalValue> Clone() final{
|
||||
return shared_ptr<ScriptFunctionEvalValue>(new ScriptFunctionEvalValue(_innerBlock, _type, _hash));
|
||||
return shared_ptr<ScriptFunctionEvalValue>(new ScriptFunctionEvalValue(_innerBlock, _scope, _type, _hash));
|
||||
}
|
||||
|
||||
|
||||
@@ -49,11 +57,13 @@ public:
|
||||
return _innerBlock;
|
||||
}
|
||||
|
||||
std::size_t GetHashCode(){
|
||||
std::size_t GetHashCode() final{
|
||||
return _hash;
|
||||
}
|
||||
|
||||
|
||||
std::shared_ptr<EvaluationScope> GetScope(){
|
||||
return _scope;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user