tcalc 0.2.0
 
Loading...
Searching...
No Matches
unaryop.hpp
Go to the documentation of this file.
1
12#pragma once
13
14#include <utility>
15
16#include "tcalc/ast/node.hpp"
17
18namespace tcalc::ast {
19
24class UnaryOpNode : public Node
25{
26private:
27 NodePtr<> _operand;
28
29public:
36 : UnaryOpNode{ type, nullptr }
37 {
38 }
39
47 : Node{ type }
48 , _operand{ std::move(operand) }
49 {
50 }
51
52 ~UnaryOpNode() override = default;
53
59 [[nodiscard]] TCALC_INLINE auto& operand() const noexcept { return _operand; }
60
66 TCALC_INLINE auto& operand() noexcept { return _operand; }
67
73 TCALC_INLINE void operand(NodePtr<> operand) noexcept
74 {
75 _operand = std::move(operand);
76 }
77};
78
79}
Base class for AST nodes.
Definition node.hpp:87
TCALC_INLINE auto type() const noexcept
Get the node type.
Definition node.hpp:109
Unary operation node.
Definition unaryop.hpp:25
TCALC_INLINE auto & operand() const noexcept
Get operand.
Definition unaryop.hpp:59
TCALC_INLINE void operand(NodePtr<> operand) noexcept
Set operand.
Definition unaryop.hpp:73
UnaryOpNode(NodeType type, NodePtr<> operand)
Construct a new Unary Op Node object with operand.
Definition unaryop.hpp:46
TCALC_INLINE auto & operand() noexcept
Get operand.
Definition unaryop.hpp:66
UnaryOpNode(NodeType type)
Construct a new Unary Op Node object without operand.
Definition unaryop.hpp:35
Base class for AST nodes.
std::shared_ptr< NT > NodePtr
Shared pointer to a node.
Definition node.hpp:119
NodeType
AST node type.
Definition node.hpp:30