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_BLOCK
|
|
|
|
#define SKSL_DSL_BLOCK
|
|
|
|
|
2021-03-04 19:30:25 +00:00
|
|
|
#include "include/private/SkSLDefines.h"
|
2022-03-18 20:40:58 +00:00
|
|
|
#include "include/private/SkTArray.h"
|
2021-03-04 19:30:25 +00:00
|
|
|
#include "include/sksl/DSLStatement.h"
|
2022-04-07 20:17:06 +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-07-09 19:35:23 +00:00
|
|
|
class Block;
|
2021-06-10 21:17:11 +00:00
|
|
|
class SymbolTable;
|
2021-01-22 20:18:25 +00:00
|
|
|
|
|
|
|
namespace dsl {
|
|
|
|
|
|
|
|
class DSLBlock {
|
|
|
|
public:
|
|
|
|
template<class... Statements>
|
|
|
|
DSLBlock(Statements... statements) {
|
|
|
|
fStatements.reserve_back(sizeof...(statements));
|
2022-05-18 01:43:31 +00:00
|
|
|
((void)fStatements.push_back(DSLStatement(statements.release()).release()), ...);
|
2021-01-22 20:18:25 +00:00
|
|
|
}
|
|
|
|
|
2021-05-06 14:47:06 +00:00
|
|
|
DSLBlock(DSLBlock&& other) = default;
|
|
|
|
|
2022-04-07 20:17:06 +00:00
|
|
|
DSLBlock(SkSL::StatementArray statements, std::shared_ptr<SymbolTable> symbols = nullptr,
|
2022-04-08 15:37:08 +00:00
|
|
|
Position pos = {});
|
2021-05-06 14:47:06 +00:00
|
|
|
|
2022-04-07 20:17:06 +00:00
|
|
|
DSLBlock(SkTArray<DSLStatement> statements, std::shared_ptr<SymbolTable> symbols = nullptr,
|
2022-04-08 15:37:08 +00:00
|
|
|
Position pos = {});
|
2021-05-06 14:47:06 +00:00
|
|
|
|
|
|
|
~DSLBlock();
|
2021-04-16 17:39:58 +00:00
|
|
|
|
|
|
|
DSLBlock& operator=(DSLBlock&& other) {
|
|
|
|
fStatements = std::move(other.fStatements);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2021-01-22 20:18:25 +00:00
|
|
|
void append(DSLStatement stmt);
|
|
|
|
|
2021-07-09 19:35:23 +00:00
|
|
|
std::unique_ptr<SkSL::Block> release();
|
2021-01-22 20:18:25 +00:00
|
|
|
|
2021-05-06 14:47:06 +00:00
|
|
|
private:
|
2021-01-22 20:18:25 +00:00
|
|
|
SkSL::StatementArray fStatements;
|
2021-05-06 14:47:06 +00:00
|
|
|
std::shared_ptr<SkSL::SymbolTable> fSymbols;
|
2022-04-07 20:17:06 +00:00
|
|
|
Position fPosition;
|
2021-01-22 20:18:25 +00:00
|
|
|
|
|
|
|
friend class DSLStatement;
|
|
|
|
friend class DSLFunction;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dsl
|
|
|
|
|
|
|
|
} // namespace SkSL
|
|
|
|
|
|
|
|
#endif
|