Skip to content

Commit 4c56441

Browse files
committed
Compiler: Add createStopWithoutSync() method
1 parent 35b6ca5 commit 4c56441

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

include/scratchcpp/compiler.h

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

149149
void createYield();
150150
void createStop();
151+
void createStopWithoutSync();
151152

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

src/engine/compiler.cpp

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

708+
/*!
709+
* Creates a stop script without synchronization instruction.\n
710+
* Use this if synchronization is not possible at the stop point.
711+
* \note Only use this when everything is synchronized, e. g. after a function call.
712+
*/
713+
void Compiler::createStopWithoutSync()
714+
{
715+
impl->builder->createStopWithoutSync();
716+
}
717+
708718
/*! Creates a call to the procedure with the given prototype. */
709719
void Compiler::createProcedureCall(BlockPrototype *prototype, const libscratchcpp::Compiler::Args &args)
710720
{

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

0 commit comments

Comments
 (0)