#ifndef PORYGONLANG_BOUNDFUNCTIONCALLEXPRESSION_HPP
#define PORYGONLANG_BOUNDFUNCTIONCALLEXPRESSION_HPP

#include "BoundExpression.hpp"

namespace Porygon::Binder {
    class BoundFunctionCallExpression : public Porygon::Binder::BoundExpression {
        const BoundExpression *_functionExpression;
        const vector<BoundExpression *> _parameters;
        const Porygon::GenericFunctionOption *_option;
    public:
        BoundFunctionCallExpression(BoundExpression *functionExpression, vector<BoundExpression *> parameters,
                                    Porygon::GenericFunctionOption *option, shared_ptr<const Porygon::ScriptType> result,
                                    unsigned int start, unsigned int length)
                : BoundExpression(start, length, move(result)), _functionExpression(functionExpression),
                  _parameters(move(parameters)), _option(option) {}

        ~BoundFunctionCallExpression() final {
            delete _functionExpression;
            for (auto p : _parameters) {
                delete p;
            }
        }

        [[nodiscard]]
        inline Porygon::Binder::BoundExpressionKind GetKind() const final {
            return Porygon::Binder::BoundExpressionKind::FunctionCall;
        }

        [[nodiscard]]
        inline const BoundExpression *GetFunctionExpression() const {
            return _functionExpression;
        }

        [[nodiscard]]
        inline const vector<BoundExpression *> *GetParameters() const {
            return &_parameters;
        }

        [[nodiscard]]
        inline const Porygon::GenericFunctionOption *GetFunctionOption() const {
            return _option;
        }
    };
}

#include "BoundExpression.hpp"

#endif //PORYGONLANG_BOUNDFUNCTIONCALLEXPRESSION_HPP
