Skip to content

Commit

Permalink
Used shared pointers instead of unique pointers.
Browse files Browse the repository at this point in the history
  • Loading branch information
nthnn committed Oct 26, 2024
1 parent af9bbb2 commit 82b5288
Show file tree
Hide file tree
Showing 43 changed files with 175 additions and 175 deletions.
2 changes: 1 addition & 1 deletion include/zhivo/ast/ASTNode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

class ASTNode {
protected:
std::unique_ptr<Token> address = nullptr;
std::shared_ptr<Token> address = nullptr;

public:
ASTNode() : address(nullptr) {}
Expand Down
4 changes: 2 additions & 2 deletions include/zhivo/ast/ASTNodeException.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@

class ASTNodeException final : public std::runtime_error {
private:
std::unique_ptr<Token> address;
std::shared_ptr<Token> address;

public:
explicit ASTNodeException(
std::unique_ptr<Token> _address,
std::shared_ptr<Token> _address,
const std::string& message) :
std::runtime_error(message),
address(std::move(_address)) {}
Expand Down
4 changes: 2 additions & 2 deletions include/zhivo/ast/TerminativeSignal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ class TerminativeReturnSignal : public std::exception {

class TerminativeThrowSignal : public std::exception {
private:
std::unique_ptr<Token> address;
std::shared_ptr<Token> address;
DynamicObject value;

public:
TerminativeThrowSignal(std::unique_ptr<Token> _address, DynamicObject _value) :
TerminativeThrowSignal(std::shared_ptr<Token> _address, DynamicObject _value) :
address(std::move(_address)),
value(std::move(_value)) {}

Expand Down
10 changes: 5 additions & 5 deletions include/zhivo/ast/expression/ArrayAccessExpression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@

class ArrayAccessExpression final : public ASTNode {
private:
std::unique_ptr<ASTNode> array;
std::unique_ptr<ASTNode> index;
std::shared_ptr<ASTNode> array;
std::shared_ptr<ASTNode> index;

public:
explicit ArrayAccessExpression(
std::unique_ptr<Token> _address,
std::unique_ptr<ASTNode> _array,
std::unique_ptr<ASTNode> _index
std::shared_ptr<Token> _address,
std::shared_ptr<ASTNode> _array,
std::shared_ptr<ASTNode> _index
) : array(std::move(_array)),
index(std::move(_index)) {
this->address = std::move(_address);
Expand Down
6 changes: 3 additions & 3 deletions include/zhivo/ast/expression/ArrayExpression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@

class ArrayExpression final : public ASTNode {
private:
std::vector<std::unique_ptr<ASTNode>> elements;
std::vector<std::shared_ptr<ASTNode>> elements;

public:
explicit ArrayExpression(
std::unique_ptr<Token> _address,
std::vector<std::unique_ptr<ASTNode>> _elements
std::shared_ptr<Token> _address,
std::vector<std::shared_ptr<ASTNode>> _elements
) : elements(std::move(_elements)) {
this->address = std::move(_address);
}
Expand Down
10 changes: 5 additions & 5 deletions include/zhivo/ast/expression/BinaryExpression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

class BinaryExpression final : public ASTNode {
private:
std::unique_ptr<ASTNode> left;
std::unique_ptr<ASTNode> right;
std::shared_ptr<ASTNode> left;
std::shared_ptr<ASTNode> right;
std::string op;

DynamicObject applyStringOp(DynamicObject& lValue, DynamicObject& rValue);
Expand All @@ -39,10 +39,10 @@ class BinaryExpression final : public ASTNode {

public:
explicit BinaryExpression(
std::unique_ptr<Token> _address,
std::unique_ptr<ASTNode> _left,
std::shared_ptr<Token> _address,
std::shared_ptr<ASTNode> _left,
std::string _op,
std::unique_ptr<ASTNode> _right
std::shared_ptr<ASTNode> _right
) : left(std::move(_left)),
right(std::move(_right)),
op(_op) {
Expand Down
6 changes: 3 additions & 3 deletions include/zhivo/ast/expression/BlockExpression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@

class BlockExpression final : public ASTNode {
private:
std::vector<std::unique_ptr<ASTNode>> statements;
std::vector<std::shared_ptr<ASTNode>> statements;

public:
explicit BlockExpression(
std::unique_ptr<Token> _address,
std::vector<std::unique_ptr<ASTNode>> _statements
std::shared_ptr<Token> _address,
std::vector<std::shared_ptr<ASTNode>> _statements
) : statements(std::move(_statements)) {
this->address = std::move(_address);
}
Expand Down
2 changes: 1 addition & 1 deletion include/zhivo/ast/expression/BooleanLiteralExpression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class BooleanLiteralExpression final : public ASTNode {

public:
explicit BooleanLiteralExpression(
std::unique_ptr<Token> _address,
std::shared_ptr<Token> _address,
bool _value
) : value(_value) {
this->address = std::move(_address);
Expand Down
18 changes: 9 additions & 9 deletions include/zhivo/ast/expression/CatchHandleExpression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@

class CatchHandleExpression final : public ASTNode {
private:
std::unique_ptr<ASTNode> catchBlock;
std::unique_ptr<ASTNode> handleBlock;
std::unique_ptr<Token> handler;
std::unique_ptr<ASTNode> finalBlock;
std::shared_ptr<ASTNode> catchBlock;
std::shared_ptr<ASTNode> handleBlock;
std::shared_ptr<Token> handler;
std::shared_ptr<ASTNode> finalBlock;

public:
explicit CatchHandleExpression(
std::unique_ptr<Token> _address,
std::unique_ptr<ASTNode> _catchBlock,
std::unique_ptr<ASTNode> _handleBlock,
std::unique_ptr<Token> _handler,
std::unique_ptr<ASTNode> _finalBlock
std::shared_ptr<Token> _address,
std::shared_ptr<ASTNode> _catchBlock,
std::shared_ptr<ASTNode> _handleBlock,
std::shared_ptr<Token> _handler,
std::shared_ptr<ASTNode> _finalBlock
) : catchBlock(std::move(_catchBlock)),
handleBlock(std::move(_handleBlock)),
handler(std::move(_handler)),
Expand Down
10 changes: 5 additions & 5 deletions include/zhivo/ast/expression/FunctionCallExpression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@

class FunctionCallExpression final : public ASTNode {
private:
std::unique_ptr<ASTNode> callable;
std::vector<std::unique_ptr<ASTNode>> arguments;
std::shared_ptr<ASTNode> callable;
std::vector<std::shared_ptr<ASTNode>> arguments;

public:
explicit FunctionCallExpression(
std::unique_ptr<Token> _address,
std::unique_ptr<ASTNode> _callable,
std::vector<std::unique_ptr<ASTNode>> _arguments
std::shared_ptr<Token> _address,
std::shared_ptr<ASTNode> _callable,
std::vector<std::shared_ptr<ASTNode>> _arguments
) : callable(std::move(_callable)),
arguments(std::move(_arguments)) {
this->address = std::move(_address);
Expand Down
10 changes: 5 additions & 5 deletions include/zhivo/ast/expression/FunctionDeclarationExpression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@

class FunctionDeclarationExpression final : public ASTNode {
private:
std::vector<std::unique_ptr<Token>> parameters;
std::unique_ptr<ASTNode> body;
std::vector<std::shared_ptr<Token>> parameters;
std::shared_ptr<ASTNode> body;

public:
explicit FunctionDeclarationExpression(
std::unique_ptr<Token> _address,
std::vector<std::unique_ptr<Token>> _parameters,
std::unique_ptr<ASTNode> _body
std::shared_ptr<Token> _address,
std::vector<std::shared_ptr<Token>> _parameters,
std::shared_ptr<ASTNode> _body
) : parameters(std::move(_parameters)),
body(std::move(_body)) {
this->address = std::move(_address);
Expand Down
6 changes: 3 additions & 3 deletions include/zhivo/ast/expression/GroupedExpression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@

class GroupedExpression final : public ASTNode {
private:
std::unique_ptr<ASTNode> expression;
std::shared_ptr<ASTNode> expression;

public:
explicit GroupedExpression(
std::unique_ptr<Token> _address,
std::unique_ptr<ASTNode> _expression
std::shared_ptr<Token> _address,
std::shared_ptr<ASTNode> _expression
) : expression(std::move(_expression)) {
this->address = std::move(_address);
}
Expand Down
14 changes: 7 additions & 7 deletions include/zhivo/ast/expression/IfElseExpression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@

class IfElseExpression final : public ASTNode {
private:
std::unique_ptr<ASTNode> condition;
std::unique_ptr<ASTNode> thenBranch;
std::unique_ptr<ASTNode> elseBranch;
std::shared_ptr<ASTNode> condition;
std::shared_ptr<ASTNode> thenBranch;
std::shared_ptr<ASTNode> elseBranch;

public:
explicit IfElseExpression(
std::unique_ptr<Token> _address,
std::unique_ptr<ASTNode> _condition,
std::unique_ptr<ASTNode> _thenBranch,
std::unique_ptr<ASTNode> _elseBranch
std::shared_ptr<Token> _address,
std::shared_ptr<ASTNode> _condition,
std::shared_ptr<ASTNode> _thenBranch,
std::shared_ptr<ASTNode> _elseBranch
) : condition(std::move(_condition)),
thenBranch(std::move(_thenBranch)),
elseBranch(std::move(_elseBranch)) {
Expand Down
18 changes: 9 additions & 9 deletions include/zhivo/ast/expression/LoopExpression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@

class LoopExpression final : public ASTNode {
private:
std::unique_ptr<ASTNode> initial;
std::unique_ptr<ASTNode> condition;
std::unique_ptr<ASTNode> postexpr;
std::unique_ptr<ASTNode> body;
std::shared_ptr<ASTNode> initial;
std::shared_ptr<ASTNode> condition;
std::shared_ptr<ASTNode> postexpr;
std::shared_ptr<ASTNode> body;

public:
explicit LoopExpression(
std::unique_ptr<Token> _address,
std::unique_ptr<ASTNode> _initial,
std::unique_ptr<ASTNode> _condition,
std::unique_ptr<ASTNode> _postexpr,
std::unique_ptr<ASTNode> _body
std::shared_ptr<Token> _address,
std::shared_ptr<ASTNode> _initial,
std::shared_ptr<ASTNode> _condition,
std::shared_ptr<ASTNode> _postexpr,
std::shared_ptr<ASTNode> _body
) : initial(std::move(_initial)),
condition(std::move(_condition)),
postexpr(std::move(_postexpr)),
Expand Down
2 changes: 1 addition & 1 deletion include/zhivo/ast/expression/MaybeExpression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

class MaybeExpression final : public ASTNode {
public:
explicit MaybeExpression(std::unique_ptr<Token> _address) {
explicit MaybeExpression(std::shared_ptr<Token> _address) {
this->address = std::move(_address);
}

Expand Down
10 changes: 5 additions & 5 deletions include/zhivo/ast/expression/NilCoalescingExpression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@

class NilCoalescingExpression final : public ASTNode {
private:
std::unique_ptr<ASTNode> left;
std::unique_ptr<ASTNode> right;
std::shared_ptr<ASTNode> left;
std::shared_ptr<ASTNode> right;

public:
explicit NilCoalescingExpression(
std::unique_ptr<Token> _address,
std::unique_ptr<ASTNode> _left,
std::unique_ptr<ASTNode> _right
std::shared_ptr<Token> _address,
std::shared_ptr<ASTNode> _left,
std::shared_ptr<ASTNode> _right
) : left(std::move(_left)),
right(std::move(_right)) {
this->address = std::move(_address);
Expand Down
2 changes: 1 addition & 1 deletion include/zhivo/ast/expression/NilLiteralExpression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

class NilLiteralExpression final : public ASTNode {
public:
explicit NilLiteralExpression(std::unique_ptr<Token> _address) {
explicit NilLiteralExpression(std::shared_ptr<Token> _address) {
this->address = std::move(_address);
}

Expand Down
2 changes: 1 addition & 1 deletion include/zhivo/ast/expression/NumberLiteralExpression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class NumberLiteralExpression final : public ASTNode {

public:
explicit NumberLiteralExpression(
std::unique_ptr<Token> _address,
std::shared_ptr<Token> _address,
double _value
) : value(_value) {
this->address = std::move(_address);
Expand Down
6 changes: 3 additions & 3 deletions include/zhivo/ast/expression/ParallelExpression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@

class ParallelExpression final : public ASTNode {
private:
std::unique_ptr<ASTNode> expression;
std::shared_ptr<ASTNode> expression;

public:
explicit ParallelExpression(
std::unique_ptr<Token> _address,
std::unique_ptr<ASTNode> _expression
std::shared_ptr<Token> _address,
std::shared_ptr<ASTNode> _expression
) : expression(std::move(_expression)) {
this->address = std::move(_address);
}
Expand Down
10 changes: 5 additions & 5 deletions include/zhivo/ast/expression/RandomExpression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@

class RandomExpression final : public ASTNode {
private:
std::unique_ptr<ASTNode> thenBranch;
std::unique_ptr<ASTNode> elseBranch;
std::shared_ptr<ASTNode> thenBranch;
std::shared_ptr<ASTNode> elseBranch;

public:
explicit RandomExpression(
std::unique_ptr<Token> _address,
std::unique_ptr<ASTNode> _thenBranch,
std::unique_ptr<ASTNode> _elseBranch
std::shared_ptr<Token> _address,
std::shared_ptr<ASTNode> _thenBranch,
std::shared_ptr<ASTNode> _elseBranch
) : thenBranch(std::move(_thenBranch)),
elseBranch(std::move(_elseBranch)) {
this->address = std::move(_address);
Expand Down
2 changes: 1 addition & 1 deletion include/zhivo/ast/expression/RegexExpression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class RegexExpression final : public ASTNode {
std::string regExpression;
public:
explicit RegexExpression(
std::unique_ptr<Token> _address,
std::shared_ptr<Token> _address,
std::string& _regExpression
) : regExpression(std::move(_regExpression)) {
this->address = std::move(_address);
Expand Down
6 changes: 3 additions & 3 deletions include/zhivo/ast/expression/RenderExpression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@

class RenderExpression final : public ASTNode {
private:
std::unique_ptr<ASTNode> expression;
std::shared_ptr<ASTNode> expression;
bool newLine;
bool errorStream;

public:
explicit RenderExpression(
std::unique_ptr<Token> _address,
std::shared_ptr<Token> _address,
bool _newLine,
bool _errorStream,
std::unique_ptr<ASTNode> _expression
std::shared_ptr<ASTNode> _expression
) : expression(std::move(_expression)),
newLine(_newLine),
errorStream(_errorStream) {
Expand Down
2 changes: 1 addition & 1 deletion include/zhivo/ast/expression/StringLiteralExpression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class StringLiteralExpression final : public ASTNode {

public:
explicit StringLiteralExpression(
std::unique_ptr<Token> _address,
std::shared_ptr<Token> _address,
std::string _value
) : value(_value) {
this->address = std::move(_address);
Expand Down
6 changes: 3 additions & 3 deletions include/zhivo/ast/expression/TypeExpression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@

class TypeExpression final : public ASTNode {
private:
std::unique_ptr<ASTNode> expression;
std::shared_ptr<ASTNode> expression;

public:
explicit TypeExpression(
std::unique_ptr<Token> _address,
std::unique_ptr<ASTNode> _expression
std::shared_ptr<Token> _address,
std::shared_ptr<ASTNode> _expression
) : expression(std::move(_expression)) {
this->address = std::move(_address);
}
Expand Down
Loading

0 comments on commit 82b5288

Please sign in to comment.