Separate out ExpressionStatement::Convert and ::Make.
At http://review.skia.org/469525, I updated ExpressionStatement::Make so that it would report errors in the case of an incomplete expression, but neglected to split it into a Convert/Make pair. Now, like other statements, it has a Convert path (for clean error reporting) and a Make path (for already-error-checked IR construction). Change-Id: Id89b6220beb5d815b5ae5a663b7fc4c0509d0c40 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/532786 Auto-Submit: John Stiles <johnstiles@google.com> Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
This commit is contained in:
parent
6c78b8d3ae
commit
74b72a9b4a
@ -34,12 +34,13 @@ DSLStatement::DSLStatement(DSLBlock block)
|
||||
DSLStatement::DSLStatement(DSLExpression expr) {
|
||||
std::unique_ptr<SkSL::Expression> skslExpr = expr.release();
|
||||
if (skslExpr) {
|
||||
fStatement = SkSL::ExpressionStatement::Make(ThreadContext::Context(), std::move(skslExpr));
|
||||
fStatement = SkSL::ExpressionStatement::Convert(ThreadContext::Context(),
|
||||
std::move(skslExpr));
|
||||
}
|
||||
}
|
||||
|
||||
DSLStatement::DSLStatement(std::unique_ptr<SkSL::Expression> expr)
|
||||
: fStatement(SkSL::ExpressionStatement::Make(ThreadContext::Context(), std::move(expr))) {
|
||||
: fStatement(SkSL::ExpressionStatement::Convert(ThreadContext::Context(), std::move(expr))) {
|
||||
SkASSERT(this->hasValue());
|
||||
}
|
||||
|
||||
|
@ -12,11 +12,19 @@
|
||||
|
||||
namespace SkSL {
|
||||
|
||||
std::unique_ptr<Statement> ExpressionStatement::Make(const Context& context,
|
||||
std::unique_ptr<Expression> expr) {
|
||||
std::unique_ptr<Statement> ExpressionStatement::Convert(const Context& context,
|
||||
std::unique_ptr<Expression> expr) {
|
||||
// Expression-statements need to represent a complete expression.
|
||||
// Report an error on intermediate expressions, like FunctionReference or TypeReference.
|
||||
if (expr->isIncomplete(context)) {
|
||||
return nullptr;
|
||||
}
|
||||
return ExpressionStatement::Make(context, std::move(expr));
|
||||
}
|
||||
|
||||
std::unique_ptr<Statement> ExpressionStatement::Make(const Context& context,
|
||||
std::unique_ptr<Expression> expr) {
|
||||
SkASSERT(!expr->isIncomplete(context));
|
||||
|
||||
if (context.fConfig->fSettings.fOptimize) {
|
||||
// Expression-statements without any side effect can be replaced with a Nop.
|
||||
|
@ -24,8 +24,11 @@ public:
|
||||
: INHERITED(expression->fPosition, kStatementKind)
|
||||
, fExpression(std::move(expression)) {}
|
||||
|
||||
// Creates an SkSL expression-statement. Note that there is never any type-coercion and no error
|
||||
// cases are reported; any Expression can be an ExpressionStatement.
|
||||
// Creates an SkSL expression-statement; reports errors via ErrorReporter.
|
||||
static std::unique_ptr<Statement> Convert(const Context& context,
|
||||
std::unique_ptr<Expression> expr);
|
||||
|
||||
// Creates an SkSL expression-statement; reports errors via assertion.
|
||||
static std::unique_ptr<Statement> Make(const Context& context,
|
||||
std::unique_ptr<Expression> expr);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user