2021-01-22 20:18:25 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2021 Google LLC.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SKSL_DSL_STATEMENT
|
|
|
|
#define SKSL_DSL_STATEMENT
|
|
|
|
|
|
|
|
#include "include/core/SkTypes.h"
|
2021-03-09 18:10:59 +00:00
|
|
|
#include "include/private/SkSLStatement.h"
|
2022-04-20 20:51:26 +00:00
|
|
|
#include "include/sksl/SkSLPosition.h"
|
2021-01-22 20:18:25 +00:00
|
|
|
|
|
|
|
#include <memory>
|
2022-03-18 20:40:58 +00:00
|
|
|
#include <utility>
|
2021-01-22 20:18:25 +00:00
|
|
|
|
|
|
|
namespace SkSL {
|
|
|
|
|
2021-02-02 18:44:27 +00:00
|
|
|
class Expression;
|
2021-01-22 20:18:25 +00:00
|
|
|
|
|
|
|
namespace dsl {
|
|
|
|
|
|
|
|
class DSLBlock;
|
|
|
|
class DSLExpression;
|
|
|
|
|
|
|
|
class DSLStatement {
|
|
|
|
public:
|
2021-03-04 19:30:25 +00:00
|
|
|
DSLStatement();
|
2021-01-22 20:18:25 +00:00
|
|
|
|
|
|
|
DSLStatement(DSLExpression expr);
|
|
|
|
|
|
|
|
DSLStatement(DSLBlock block);
|
|
|
|
|
|
|
|
DSLStatement(DSLStatement&&) = default;
|
|
|
|
|
2021-09-17 22:49:49 +00:00
|
|
|
DSLStatement(std::unique_ptr<SkSL::Expression> expr);
|
|
|
|
|
2022-05-31 14:36:14 +00:00
|
|
|
DSLStatement(std::unique_ptr<SkSL::Statement> stmt, Position pos);
|
|
|
|
|
|
|
|
DSLStatement(std::unique_ptr<SkSL::Statement> stmt);
|
|
|
|
|
2021-02-17 16:17:56 +00:00
|
|
|
~DSLStatement();
|
2021-01-22 20:18:25 +00:00
|
|
|
|
2021-05-06 14:47:06 +00:00
|
|
|
DSLStatement& operator=(DSLStatement&& other) = default;
|
|
|
|
|
2022-04-20 20:51:26 +00:00
|
|
|
Position position() {
|
|
|
|
SkASSERT(this->hasValue());
|
|
|
|
return fStatement->fPosition;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setPosition(Position pos) {
|
|
|
|
SkASSERT(this->hasValue());
|
|
|
|
fStatement->fPosition = pos;
|
|
|
|
}
|
|
|
|
|
2021-08-31 20:12:40 +00:00
|
|
|
bool hasValue() { return fStatement != nullptr; }
|
2021-06-25 16:31:44 +00:00
|
|
|
|
2021-01-22 20:18:25 +00:00
|
|
|
std::unique_ptr<SkSL::Statement> release() {
|
2021-08-31 20:12:40 +00:00
|
|
|
SkASSERT(this->hasValue());
|
2021-01-22 20:18:25 +00:00
|
|
|
return std::move(fStatement);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2021-08-31 20:12:40 +00:00
|
|
|
std::unique_ptr<SkSL::Statement> releaseIfPossible() {
|
2021-06-25 16:31:44 +00:00
|
|
|
return std::move(fStatement);
|
|
|
|
}
|
|
|
|
|
2021-01-22 20:18:25 +00:00
|
|
|
std::unique_ptr<SkSL::Statement> fStatement;
|
|
|
|
|
|
|
|
friend class DSLBlock;
|
|
|
|
friend class DSLCore;
|
2021-02-17 16:17:56 +00:00
|
|
|
friend class DSLExpression;
|
2021-02-09 20:22:57 +00:00
|
|
|
friend class DSLWriter;
|
2021-04-19 14:55:18 +00:00
|
|
|
friend DSLStatement operator,(DSLStatement left, DSLStatement right);
|
2021-01-22 20:18:25 +00:00
|
|
|
};
|
|
|
|
|
2021-04-19 14:55:18 +00:00
|
|
|
DSLStatement operator,(DSLStatement left, DSLStatement right);
|
|
|
|
|
2021-01-22 20:18:25 +00:00
|
|
|
} // namespace dsl
|
|
|
|
|
|
|
|
} // namespace SkSL
|
|
|
|
|
|
|
|
#endif
|