mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-04 12:16:10 +00:00
ast: Remove no-arg constructor for ast::LoopStatement
In a near-future change, AST nodes, such as ast::BlockStatement will no longer be std::unique_ptrs, and will have to be constructed and owned by an external class. This means AST nodes can no longer allocate default child nodes. Bug: tint:322 Change-Id: I3db9b3c037896f07b84b14b7b8d4da0f066b69b0 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32679 Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
parent
b29b09fba6
commit
6a788df30e
@ -17,11 +17,6 @@
|
|||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
|
||||||
LoopStatement::LoopStatement()
|
|
||||||
: Statement(),
|
|
||||||
body_(std::make_unique<BlockStatement>()),
|
|
||||||
continuing_(std::make_unique<BlockStatement>()) {}
|
|
||||||
|
|
||||||
LoopStatement::LoopStatement(std::unique_ptr<BlockStatement> body,
|
LoopStatement::LoopStatement(std::unique_ptr<BlockStatement> body,
|
||||||
std::unique_ptr<BlockStatement> continuing)
|
std::unique_ptr<BlockStatement> continuing)
|
||||||
: Statement(), body_(std::move(body)), continuing_(std::move(continuing)) {}
|
: Statement(), body_(std::move(body)), continuing_(std::move(continuing)) {}
|
||||||
|
@ -27,8 +27,6 @@ namespace ast {
|
|||||||
/// A loop statement
|
/// A loop statement
|
||||||
class LoopStatement : public Statement {
|
class LoopStatement : public Statement {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
|
||||||
LoopStatement();
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param body the body statements
|
/// @param body the body statements
|
||||||
/// @param continuing the continuing statements
|
/// @param continuing the continuing statements
|
||||||
|
@ -58,7 +58,7 @@ TEST_F(LoopStatementTest, Creation_WithSource) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(LoopStatementTest, IsLoop) {
|
TEST_F(LoopStatementTest, IsLoop) {
|
||||||
LoopStatement l;
|
LoopStatement l(create<BlockStatement>(), create<BlockStatement>());
|
||||||
EXPECT_TRUE(l.IsLoop());
|
EXPECT_TRUE(l.IsLoop());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2207,7 +2207,10 @@ bool FunctionEmitter::EmitSwitchStart(const BlockInfo& block_info) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool FunctionEmitter::EmitLoopStart(const Construct* construct) {
|
bool FunctionEmitter::EmitLoopStart(const Construct* construct) {
|
||||||
auto* loop = AddStatement(std::make_unique<ast::LoopStatement>())->AsLoop();
|
auto* loop = AddStatement(std::make_unique<ast::LoopStatement>(
|
||||||
|
std::make_unique<ast::BlockStatement>(),
|
||||||
|
std::make_unique<ast::BlockStatement>()))
|
||||||
|
->AsLoop();
|
||||||
PushNewStatementBlock(
|
PushNewStatementBlock(
|
||||||
construct, construct->end_id,
|
construct, construct->end_id,
|
||||||
[loop](StatementBlock* s) { loop->set_body(std::move(s->statements_)); });
|
[loop](StatementBlock* s) { loop->set_body(std::move(s->statements_)); });
|
||||||
|
@ -40,7 +40,8 @@ TEST_F(BuilderTest, Loop_Empty) {
|
|||||||
// loop {
|
// loop {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
ast::LoopStatement expr;
|
ast::LoopStatement expr(create<ast::BlockStatement>(),
|
||||||
|
create<ast::BlockStatement>());
|
||||||
|
|
||||||
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
|
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
|
||||||
b.push_function(Function{});
|
b.push_function(Function{});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user