1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 20:28:11 +00:00

LibSQL: Convert SQL expression evaluation to use ResultOr

Instead of setting an error in the execution context, we can directly
return that error or the successful value. This lets all callers, who
were already TRY-capable, simply TRY the expression evaluation.
This commit is contained in:
Timothy Flynn 2022-02-10 07:46:36 -05:00 committed by Andreas Kling
parent 2397836f8e
commit f3c6cb40d7
4 changed files with 66 additions and 97 deletions

View file

@ -306,7 +306,7 @@ struct ExecutionContext {
class Expression : public ASTNode {
public:
virtual Value evaluate(ExecutionContext&) const;
virtual ResultOr<Value> evaluate(ExecutionContext&) const;
};
class ErrorExpression final : public Expression {
@ -320,7 +320,7 @@ public:
}
double value() const { return m_value; }
virtual Value evaluate(ExecutionContext&) const override;
virtual ResultOr<Value> evaluate(ExecutionContext&) const override;
private:
double m_value;
@ -334,7 +334,7 @@ public:
}
const String& value() const { return m_value; }
virtual Value evaluate(ExecutionContext&) const override;
virtual ResultOr<Value> evaluate(ExecutionContext&) const override;
private:
String m_value;
@ -355,13 +355,13 @@ private:
class NullLiteral : public Expression {
public:
virtual Value evaluate(ExecutionContext&) const override;
virtual ResultOr<Value> evaluate(ExecutionContext&) const override;
};
class NestedExpression : public Expression {
public:
const NonnullRefPtr<Expression>& expression() const { return m_expression; }
virtual Value evaluate(ExecutionContext&) const override;
virtual ResultOr<Value> evaluate(ExecutionContext&) const override;
protected:
explicit NestedExpression(NonnullRefPtr<Expression> expression)
@ -432,7 +432,7 @@ public:
const String& schema_name() const { return m_schema_name; }
const String& table_name() const { return m_table_name; }
const String& column_name() const { return m_column_name; }
virtual Value evaluate(ExecutionContext&) const override;
virtual ResultOr<Value> evaluate(ExecutionContext&) const override;
private:
String m_schema_name;
@ -475,7 +475,7 @@ public:
}
UnaryOperator type() const { return m_type; }
virtual Value evaluate(ExecutionContext&) const override;
virtual ResultOr<Value> evaluate(ExecutionContext&) const override;
private:
UnaryOperator m_type;
@ -531,7 +531,7 @@ public:
}
BinaryOperator type() const { return m_type; }
virtual Value evaluate(ExecutionContext&) const override;
virtual ResultOr<Value> evaluate(ExecutionContext&) const override;
private:
BinaryOperator m_type;
@ -545,7 +545,7 @@ public:
}
const NonnullRefPtrVector<Expression>& expressions() const { return m_expressions; }
virtual Value evaluate(ExecutionContext&) const override;
virtual ResultOr<Value> evaluate(ExecutionContext&) const override;
private:
NonnullRefPtrVector<Expression> m_expressions;
@ -638,7 +638,7 @@ public:
MatchOperator type() const { return m_type; }
const RefPtr<Expression>& escape() const { return m_escape; }
virtual Value evaluate(ExecutionContext&) const override;
virtual ResultOr<Value> evaluate(ExecutionContext&) const override;
private:
MatchOperator m_type;