Skip to content

Commit f0cbd20

Browse files
committed
Compiler: Add createThreadStop() method
1 parent 2b5a14a commit f0cbd20

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

include/scratchcpp/compiler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ class LIBSCRATCHCPP_EXPORT Compiler
150150

151151
void createYield();
152152
void createStop();
153+
void createThreadStop();
153154
void createStopWithoutSync();
154155

155156
void createProcedureCall(BlockPrototype *prototype, const Compiler::Args &args);

src/engine/compiler.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,12 @@ void Compiler::createStop()
705705
impl->builder->createStop();
706706
}
707707

708+
/*! Creates a stop script instruction. */
709+
void Compiler::createThreadStop()
710+
{
711+
impl->builder->createThreadStop();
712+
}
713+
708714
/*!
709715
* Creates a stop script without synchronization instruction.\n
710716
* Use this if synchronization is not possible at the stop point.

test/compiler/compiler_test.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,6 +1673,20 @@ TEST_F(CompilerTest, CreateStop)
16731673
compile(m_compiler.get(), block.get());
16741674
}
16751675

1676+
TEST_F(CompilerTest, CreateThreadStop)
1677+
{
1678+
1679+
auto block = std::make_shared<Block>("", "");
1680+
1681+
block->setCompileFunction([](Compiler *compiler) -> CompilerValue * {
1682+
EXPECT_CALL(*m_builder, createThreadStop());
1683+
compiler->createThreadStop();
1684+
return nullptr;
1685+
});
1686+
1687+
compile(m_compiler.get(), block.get());
1688+
}
1689+
16761690
TEST_F(CompilerTest, CreateStopWithoutSync)
16771691
{
16781692

0 commit comments

Comments
 (0)