File tree Expand file tree Collapse file tree 3 files changed +22
-0
lines changed
Expand file tree Collapse file tree 3 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -78,6 +78,8 @@ class LIBSCRATCHCPP_EXPORT Compiler
7878 void createExp ();
7979 void createExp10 ();
8080
81+ void createVariableWrite (Variable *variable);
82+
8183 void moveToIf (std::shared_ptr<Block> substack);
8284 void moveToIfElse (std::shared_ptr<Block> substack1, std::shared_ptr<Block> substack2);
8385 void moveToRepeatLoop (std::shared_ptr<Block> substack);
Original file line number Diff line number Diff line change @@ -256,6 +256,12 @@ void Compiler::createExp10()
256256 impl->builder ->createExp10 ();
257257}
258258
259+ /* ! Creates a variable write operation using the last value. */
260+ void Compiler::createVariableWrite (Variable *variable)
261+ {
262+ impl->builder ->createVariableWrite (variable);
263+ }
264+
259265/* ! Jumps to the given if substack. */
260266void Compiler::moveToIf (std::shared_ptr<Block> substack)
261267{
Original file line number Diff line number Diff line change @@ -557,6 +557,20 @@ TEST_F(CompilerTest, CreateExp10)
557557 compile (compiler, block);
558558}
559559
560+ TEST_F (CompilerTest, CreateVariableWrite)
561+ {
562+ Compiler compiler (&m_engine, &m_target);
563+ auto block = std::make_shared<Block>(" " , " " );
564+
565+ block->setCompileFunction ([](Compiler *compiler) {
566+ auto var = std::make_shared<Variable>(" " , " " );
567+ EXPECT_CALL (*m_builder, createVariableWrite (var.get ()));
568+ compiler->createVariableWrite (var.get ());
569+ });
570+
571+ compile (compiler, block);
572+ }
573+
560574TEST_F (CompilerTest, MoveToIf)
561575{
562576 Compiler compiler (&m_engine, &m_target);
You can’t perform that action at this time.
0 commit comments