This commit is contained in:
@@ -20,16 +20,16 @@ namespace Porygon::Evaluation {
|
||||
};
|
||||
|
||||
class EvaluationScriptFunctionOption : public GenericFunctionOption{
|
||||
const std::shared_ptr<BoundBlockStatement> _innerBlock;
|
||||
const std::shared_ptr<const BoundBlockStatement> _innerBlock;
|
||||
const std::shared_ptr<EvaluationScope> _scope;
|
||||
|
||||
public:
|
||||
EvaluationScriptFunctionOption(shared_ptr<BoundBlockStatement> innerBlock, shared_ptr<EvaluationScope> scope)
|
||||
EvaluationScriptFunctionOption(shared_ptr<const BoundBlockStatement> innerBlock, shared_ptr<EvaluationScope> scope)
|
||||
: _innerBlock(std::move(innerBlock)), _scope(std::move(scope)) {
|
||||
}
|
||||
~EvaluationScriptFunctionOption() final = default;
|
||||
|
||||
inline const std::shared_ptr<BoundBlockStatement> &GetInnerBlock() const {
|
||||
inline std::shared_ptr<const BoundBlockStatement> GetInnerBlock() const {
|
||||
return _innerBlock;
|
||||
}
|
||||
|
||||
@@ -40,47 +40,53 @@ namespace Porygon::Evaluation {
|
||||
|
||||
class GenericFunctionEvalValue : public EvalValue{
|
||||
protected:
|
||||
const shared_ptr<GenericFunctionScriptType> _type;
|
||||
const shared_ptr<const GenericFunctionScriptType> _type;
|
||||
const size_t _hash;
|
||||
vector<shared_ptr<GenericFunctionOption>> _options;
|
||||
vector<shared_ptr<GenericFunctionOption>>* _options;
|
||||
public:
|
||||
GenericFunctionEvalValue(shared_ptr<GenericFunctionScriptType> type, size_t hash)
|
||||
GenericFunctionEvalValue(shared_ptr<const GenericFunctionScriptType> type, size_t hash)
|
||||
: _type(move(type)),
|
||||
_hash(hash){
|
||||
_hash(hash), _options(new vector<shared_ptr<GenericFunctionOption>>()){
|
||||
}
|
||||
|
||||
const shared_ptr<EvalValue> Clone() const final {
|
||||
GenericFunctionEvalValue(const GenericFunctionEvalValue& _) = delete;
|
||||
GenericFunctionEvalValue() = delete;
|
||||
GenericFunctionEvalValue& operator =(GenericFunctionEvalValue v) = delete;
|
||||
|
||||
[[nodiscard]]
|
||||
shared_ptr<const EvalValue> Clone() const final {
|
||||
auto t = make_shared<GenericFunctionEvalValue>(_type, _hash);
|
||||
for (const auto& o: _options){
|
||||
t->_options.push_back(o);
|
||||
for (const auto& o: *_options){
|
||||
t->_options->push_back(o);
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
inline void RegisterOption(GenericFunctionOption* option){
|
||||
_options.push_back(shared_ptr<GenericFunctionOption>(option));
|
||||
inline void RegisterOption(GenericFunctionOption* option) const{
|
||||
_options->push_back(shared_ptr<GenericFunctionOption>(option));
|
||||
}
|
||||
|
||||
inline const std::shared_ptr<ScriptType> GetType() const {
|
||||
inline std::shared_ptr<const ScriptType> GetType() const {
|
||||
return _type;
|
||||
}
|
||||
|
||||
inline const TypeClass GetTypeClass() const final {
|
||||
inline TypeClass GetTypeClass() const final {
|
||||
return TypeClass::Function;
|
||||
}
|
||||
|
||||
const bool operator==(EvalValue *b) const final {
|
||||
bool operator==(const EvalValue *b) const final {
|
||||
if (b->GetTypeClass() != TypeClass::Function)
|
||||
return false;
|
||||
return this->_hash == ((GenericFunctionEvalValue *) b)->_hash;
|
||||
};
|
||||
|
||||
inline const std::size_t GetHashCode() const final {
|
||||
inline std::size_t GetHashCode() const final {
|
||||
return _hash;
|
||||
}
|
||||
|
||||
inline const shared_ptr<GenericFunctionOption> GetOption(const size_t id) const{
|
||||
return this->_options.at(id);
|
||||
[[nodiscard]]
|
||||
inline shared_ptr<const GenericFunctionOption> GetOption(const size_t id) const{
|
||||
return this->_options->at(id);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user