mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:07:47 +00:00
Shell: Make resolve_without_cast() return NonnullRefPtr<Value>
This commit is contained in:
parent
420e809fee
commit
e9c602bc83
2 changed files with 10 additions and 12 deletions
|
@ -226,7 +226,7 @@ RefPtr<Value> ListConcatenate::run(RefPtr<Shell> shell)
|
||||||
|
|
||||||
for (auto& element : m_list) {
|
for (auto& element : m_list) {
|
||||||
if (!result) {
|
if (!result) {
|
||||||
result = create<ListValue>({ element->run(shell)->resolve_without_cast(shell).release_nonnull() });
|
result = create<ListValue>({ element->run(shell)->resolve_without_cast(shell) });
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto element_value = element->run(shell)->resolve_without_cast(shell);
|
auto element_value = element->run(shell)->resolve_without_cast(shell);
|
||||||
|
@ -248,7 +248,7 @@ RefPtr<Value> ListConcatenate::run(RefPtr<Shell> shell)
|
||||||
values.append(create<StringValue>(result));
|
values.append(create<StringValue>(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
values.append(element_value.release_nonnull());
|
values.append(element_value);
|
||||||
|
|
||||||
result = create<ListValue>(move(values));
|
result = create<ListValue>(move(values));
|
||||||
}
|
}
|
||||||
|
@ -1904,11 +1904,11 @@ Vector<String> ListValue::resolve_as_list(RefPtr<Shell> shell)
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<Value> ListValue::resolve_without_cast(RefPtr<Shell> shell)
|
NonnullRefPtr<Value> ListValue::resolve_without_cast(RefPtr<Shell> shell)
|
||||||
{
|
{
|
||||||
NonnullRefPtrVector<Value> values;
|
NonnullRefPtrVector<Value> values;
|
||||||
for (auto& value : m_contained_values)
|
for (auto& value : m_contained_values)
|
||||||
values.append(value.resolve_without_cast(shell).release_nonnull());
|
values.append(value.resolve_without_cast(shell));
|
||||||
|
|
||||||
return create<ListValue>(move(values));
|
return create<ListValue>(move(values));
|
||||||
}
|
}
|
||||||
|
@ -1992,13 +1992,11 @@ Vector<String> SimpleVariableValue::resolve_as_list(RefPtr<Shell> shell)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<Value> SimpleVariableValue::resolve_without_cast(RefPtr<Shell> shell)
|
NonnullRefPtr<Value> SimpleVariableValue::resolve_without_cast(RefPtr<Shell> shell)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (auto value = shell->lookup_local_variable(m_name))
|
if (auto value = shell->lookup_local_variable(m_name))
|
||||||
return value;
|
return value.release_nonnull();
|
||||||
|
return *this;
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SpecialVariableValue::~SpecialVariableValue()
|
SpecialVariableValue::~SpecialVariableValue()
|
||||||
|
|
|
@ -168,7 +168,7 @@ class Value : public RefCounted<Value> {
|
||||||
public:
|
public:
|
||||||
virtual Vector<String> resolve_as_list(RefPtr<Shell>) = 0;
|
virtual Vector<String> resolve_as_list(RefPtr<Shell>) = 0;
|
||||||
virtual Vector<Command> resolve_as_commands(RefPtr<Shell>);
|
virtual Vector<Command> resolve_as_commands(RefPtr<Shell>);
|
||||||
virtual RefPtr<Value> resolve_without_cast(RefPtr<Shell>) { return this; }
|
virtual NonnullRefPtr<Value> resolve_without_cast(RefPtr<Shell>) { return *this; }
|
||||||
virtual ~Value();
|
virtual ~Value();
|
||||||
virtual bool is_command() const { return false; }
|
virtual bool is_command() const { return false; }
|
||||||
virtual bool is_glob() const { return false; }
|
virtual bool is_glob() const { return false; }
|
||||||
|
@ -233,7 +233,7 @@ private:
|
||||||
class ListValue final : public Value {
|
class ListValue final : public Value {
|
||||||
public:
|
public:
|
||||||
virtual Vector<String> resolve_as_list(RefPtr<Shell>) override;
|
virtual Vector<String> resolve_as_list(RefPtr<Shell>) override;
|
||||||
virtual RefPtr<Value> resolve_without_cast(RefPtr<Shell>) override;
|
virtual NonnullRefPtr<Value> resolve_without_cast(RefPtr<Shell>) override;
|
||||||
virtual ~ListValue();
|
virtual ~ListValue();
|
||||||
virtual bool is_list() const override { return true; }
|
virtual bool is_list() const override { return true; }
|
||||||
virtual bool is_list_without_resolution() const override { return true; }
|
virtual bool is_list_without_resolution() const override { return true; }
|
||||||
|
@ -286,7 +286,7 @@ private:
|
||||||
class SimpleVariableValue final : public Value {
|
class SimpleVariableValue final : public Value {
|
||||||
public:
|
public:
|
||||||
virtual Vector<String> resolve_as_list(RefPtr<Shell>) override;
|
virtual Vector<String> resolve_as_list(RefPtr<Shell>) override;
|
||||||
RefPtr<Value> resolve_without_cast(RefPtr<Shell>) override;
|
virtual NonnullRefPtr<Value> resolve_without_cast(RefPtr<Shell>) override;
|
||||||
virtual ~SimpleVariableValue();
|
virtual ~SimpleVariableValue();
|
||||||
SimpleVariableValue(String name)
|
SimpleVariableValue(String name)
|
||||||
: m_name(move(name))
|
: m_name(move(name))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue