Shell: Make resolve_without_cast() return NonnullRefPtr<Value>

This commit is contained in:
Andreas Kling 2020-08-07 09:36:15 +02:00
parent 420e809fee
commit e9c602bc83
Notes: sideshowbarker 2024-07-19 04:10:27 +09:00
2 changed files with 10 additions and 12 deletions

View File

@ -226,7 +226,7 @@ RefPtr<Value> ListConcatenate::run(RefPtr<Shell> shell)
for (auto& element : m_list) {
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;
}
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(element_value.release_nonnull());
values.append(element_value);
result = create<ListValue>(move(values));
}
@ -1904,11 +1904,11 @@ Vector<String> ListValue::resolve_as_list(RefPtr<Shell> shell)
return values;
}
RefPtr<Value> ListValue::resolve_without_cast(RefPtr<Shell> shell)
NonnullRefPtr<Value> ListValue::resolve_without_cast(RefPtr<Shell> shell)
{
NonnullRefPtrVector<Value> 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));
}
@ -1992,13 +1992,11 @@ Vector<String> SimpleVariableValue::resolve_as_list(RefPtr<Shell> shell)
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))
return value;
return this;
return value.release_nonnull();
return *this;
}
SpecialVariableValue::~SpecialVariableValue()

View File

@ -168,7 +168,7 @@ class Value : public RefCounted<Value> {
public:
virtual Vector<String> resolve_as_list(RefPtr<Shell>) = 0;
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 bool is_command() const { return false; }
virtual bool is_glob() const { return false; }
@ -233,7 +233,7 @@ private:
class ListValue final : public Value {
public:
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 bool is_list() const override { return true; }
virtual bool is_list_without_resolution() const override { return true; }
@ -286,7 +286,7 @@ private:
class SimpleVariableValue final : public Value {
public:
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();
SimpleVariableValue(String name)
: m_name(move(name))