@@ -21,67 +21,75 @@ namespace rift {
21
21
22
22
class Visitor {
23
23
public:
24
- explicit Visitor (Object const & variables) noexcept : m_variables(variables) {}
24
+ explicit Visitor (Object const & variables) noexcept ;
25
+
26
+ using VisitorResultImpl = geode::Result<Value&, RuntimeError>;
25
27
26
28
// / @brief Visit a node and evaluate its value.
27
29
// / @param node the node to visit
28
30
// / @return the result of the evaluation as a VisitorResult containing the value or an error
29
31
[[nodiscard]] VisitorResult visit (Node const & node) noexcept ;
30
32
33
+ private:
34
+ // / @brief Visit a node and evaluate its value.
35
+ // / @param node the node to visit
36
+ // / @return the result of the evaluation as a VisitorResult containing the value or an error
37
+ [[nodiscard]] VisitorResultImpl visitImpl (Node const & node) noexcept ;
38
+
31
39
// / @brief Visit a root node and evaluate its value.
32
40
// / @param node the root node to visit
33
41
// / @return the result of the evaluation as a VisitorResult containing the value
34
- [[nodiscard]] VisitorResult visit (RootNode const & node) noexcept ;
42
+ [[nodiscard]] VisitorResultImpl visit (RootNode const & node) noexcept ;
35
43
36
44
// / @brief Visit an identifier node and evaluate its value.
37
45
// / @param node the identifier node to visit
38
46
// / @return the result of the evaluation as a VisitorResult containing the value
39
- [[nodiscard]] VisitorResult visit (IdentifierNode const & node) noexcept ;
47
+ [[nodiscard]] VisitorResultImpl visit (IdentifierNode const & node) noexcept ;
40
48
41
49
// / @brief Visit a binary node and evaluate its value.
42
50
// / @param node the binary node to visit
43
51
// / @return the result of the evaluation as a VisitorResult containing the value
44
- [[nodiscard]] VisitorResult visit (BinaryNode const & node) noexcept ;
52
+ [[nodiscard]] VisitorResultImpl visit (BinaryNode const & node) noexcept ;
45
53
46
54
// / @brief Visit a unary node and evaluate its value.
47
55
// / @param node the unary node to visit
48
56
// / @return the result of the evaluation as a VisitorResult containing the value
49
- [[nodiscard]] VisitorResult visit (UnaryNode const & node) noexcept ;
57
+ [[nodiscard]] VisitorResultImpl visit (UnaryNode const & node) noexcept ;
50
58
51
59
// / @brief Visit a ternary node and evaluate its value.
52
60
// / @param node the ternary node to visit
53
61
// / @return the result of the evaluation as a VisitorResult containing the value
54
- [[nodiscard]] VisitorResult visit (TernaryNode const & node) noexcept ;
62
+ [[nodiscard]] VisitorResultImpl visit (TernaryNode const & node) noexcept ;
55
63
56
64
// / @brief Visit a call node and evaluate its value.
57
65
// / @param node the call node to visit
58
66
// / @return the result of the evaluation as a VisitorResult containing the value
59
- [[nodiscard]] VisitorResult visit (CallNode const & node) noexcept ;
67
+ [[nodiscard]] VisitorResultImpl visit (CallNode const & node) noexcept ;
60
68
61
69
// / @brief Visit an accessor node and evaluate its value.
62
70
// / @param node the accessor node to visit
63
71
// / @return the result of the evaluation as a VisitorResult containing the value
64
- [[nodiscard]] VisitorResult visit (AccessorNode const & node) noexcept ;
72
+ [[nodiscard]] VisitorResultImpl visit (AccessorNode const & node) noexcept ;
65
73
66
74
// / @brief Visit an indexer node and evaluate its value.
67
75
// / @param node the indexer node to visit
68
76
// / @return the result of the evaluation as a VisitorResult containing the value
69
- [[nodiscard]] VisitorResult visit (IndexerNode const & node) noexcept ;
77
+ [[nodiscard]] VisitorResultImpl visit (IndexerNode const & node) noexcept ;
70
78
71
79
// / @brief Visit a for loop node and evaluate its value.
72
80
// / @param node the for loop node to visit
73
81
// / @return the result of the evaluation as a VisitorResult containing the value
74
- [[nodiscard]] VisitorResult visit (ForNode const & node) noexcept ;
82
+ [[nodiscard]] VisitorResultImpl visit (ForNode const & node) noexcept ;
75
83
76
84
// / @brief Visit a script node and evaluate its value.
77
85
// / @param node the script node to visit
78
86
// / @return the result of the evaluation as a VisitorResult containing the value
79
- [[nodiscard]] VisitorResult visit (ScriptNode const & node) noexcept ;
87
+ [[nodiscard]] VisitorResultImpl visit (ScriptNode const & node) noexcept ;
80
88
81
89
// / @brief Visit an assign node and evaluate its value.
82
90
// / @param node the assign node to visit
83
91
// / @return the result of the evaluation as a VisitorResult containing the value
84
- [[nodiscard]] VisitorResult visit (AssignNode const & node) noexcept ;
92
+ [[nodiscard]] VisitorResultImpl visit (AssignNode const & node) noexcept ;
85
93
86
94
private:
87
95
std::reference_wrapper<Object const > m_variables;
0 commit comments