mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-11 18:20:43 +09:00
Shell: Add a 'for' loop
Closes #2760. This commit adds a 'for' loop, and tweaks the syntax slightly to make && bind more tightly than || (allowing for `expr && if_ok || if_bad`) :^)
This commit is contained in:
parent
95fc7dd03a
commit
b6066faa1f
Notes:
sideshowbarker
2024-07-19 04:46:41 +09:00
Author: https://github.com/alimpfard
Commit: b6066faa1f
Pull-request: https://github.com/SerenityOS/serenity/pull/2767
Issue: https://github.com/SerenityOS/serenity/issues/2760
6 changed files with 334 additions and 46 deletions
|
@ -93,6 +93,29 @@ public:
|
|||
void set_local_variable(const String&, RefPtr<AST::Value>);
|
||||
void unset_local_variable(const String&);
|
||||
|
||||
struct LocalFrame {
|
||||
HashMap<String, RefPtr<AST::Value>> local_variables;
|
||||
};
|
||||
|
||||
struct Frame {
|
||||
Frame(Vector<LocalFrame>& frames, const LocalFrame& frame)
|
||||
: frames(frames)
|
||||
, frame(frame)
|
||||
{
|
||||
}
|
||||
~Frame();
|
||||
|
||||
void leak_frame() { should_destroy_frame = false; }
|
||||
|
||||
private:
|
||||
Vector<LocalFrame>& frames;
|
||||
const LocalFrame& frame;
|
||||
bool should_destroy_frame { true };
|
||||
};
|
||||
|
||||
[[nodiscard]] Frame push_frame();
|
||||
void pop_frame();
|
||||
|
||||
static String escape_token(const String& token);
|
||||
static String unescape_token(const String& token);
|
||||
|
||||
|
@ -166,6 +189,7 @@ private:
|
|||
void cache_path();
|
||||
void stop_all_jobs();
|
||||
const Job* m_current_job { nullptr };
|
||||
LocalFrame* find_frame_containing_local_variable(const String& name);
|
||||
|
||||
virtual void custom_event(Core::CustomEvent&) override;
|
||||
|
||||
|
@ -188,7 +212,8 @@ private:
|
|||
bool m_should_ignore_jobs_on_next_exit { false };
|
||||
pid_t m_pid { 0 };
|
||||
|
||||
HashMap<String, RefPtr<AST::Value>> m_local_variables;
|
||||
Vector<LocalFrame> m_local_frames;
|
||||
|
||||
HashMap<String, String> m_aliases;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue