diff options
Diffstat (limited to 'src/MoonP/ast.hpp')
-rw-r--r-- | src/MoonP/ast.hpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/MoonP/ast.hpp b/src/MoonP/ast.hpp index 8bcfc21..b56cfde 100644 --- a/src/MoonP/ast.hpp +++ b/src/MoonP/ast.hpp | |||
@@ -399,6 +399,18 @@ public: | |||
399 | node->release(); | 399 | node->release(); |
400 | } | 400 | } |
401 | 401 | ||
402 | bool swap(ast_node* node, ast_node* other) { | ||
403 | for (auto it = m_objects.begin(); it != m_objects.end(); ++it) { | ||
404 | if (*it == node) { | ||
405 | *it = other; | ||
406 | other->retain(); | ||
407 | node->release(); | ||
408 | return true; | ||
409 | } | ||
410 | } | ||
411 | return false; | ||
412 | } | ||
413 | |||
402 | const node_container& objects() const { | 414 | const node_container& objects() const { |
403 | return m_objects; | 415 | return m_objects; |
404 | } | 416 | } |