diff options
author | AnotherTest <ali.mpfard@gmail.com> | 2021-01-18 10:06:13 +0330 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-01-19 08:19:43 +0100 |
commit | 5ec139e7280e6beca4a15d5ab7dc24fa105905ad (patch) | |
tree | 085e31cfc72c22f727a530cfb27b62c359c237ce /Userland/Shell/AST.cpp | |
parent | 50473003be354d0f5bf07606dd22c4c3ac68ab6d (diff) | |
download | serenity-5ec139e7280e6beca4a15d5ab7dc24fa105905ad.zip |
Shell: Make 'if' expressions return the unevaluated value of blocks
This makes it possible to actually put them in a sequence and cast them
to commands.
Diffstat (limited to 'Userland/Shell/AST.cpp')
-rw-r--r-- | Userland/Shell/AST.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Userland/Shell/AST.cpp b/Userland/Shell/AST.cpp index d461b9fd6d..93dc4fee8e 100644 --- a/Userland/Shell/AST.cpp +++ b/Userland/Shell/AST.cpp @@ -1690,12 +1690,18 @@ IfCond::IfCond(Position position, Optional<Position> else_position, NonnullRefPt if (m_true_branch) { auto true_branch = m_true_branch.release_nonnull(); - m_true_branch = create<AST::Execute>(true_branch->position(), true_branch); + if (true_branch->is_execute()) + m_true_branch = static_ptr_cast<AST::Execute>(true_branch)->command(); + else + m_true_branch = move(true_branch); } if (m_false_branch) { auto false_branch = m_false_branch.release_nonnull(); - m_false_branch = create<AST::Execute>(false_branch->position(), false_branch); + if (false_branch->is_execute()) + m_false_branch = static_ptr_cast<AST::Execute>(false_branch)->command(); + else + m_false_branch = move(false_branch); } } |