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
78
78
void createExp ();
79
79
void createExp10 ();
80
80
81
+ void createVariableWrite (Variable *variable);
82
+
81
83
void moveToIf (std::shared_ptr<Block> substack);
82
84
void moveToIfElse (std::shared_ptr<Block> substack1, std::shared_ptr<Block> substack2);
83
85
void moveToRepeatLoop (std::shared_ptr<Block> substack);
Original file line number Diff line number Diff line change @@ -256,6 +256,12 @@ void Compiler::createExp10()
256
256
impl->builder ->createExp10 ();
257
257
}
258
258
259
+ /* ! Creates a variable write operation using the last value. */
260
+ void Compiler::createVariableWrite (Variable *variable)
261
+ {
262
+ impl->builder ->createVariableWrite (variable);
263
+ }
264
+
259
265
/* ! Jumps to the given if substack. */
260
266
void Compiler::moveToIf (std::shared_ptr<Block> substack)
261
267
{
Original file line number Diff line number Diff line change @@ -557,6 +557,20 @@ TEST_F(CompilerTest, CreateExp10)
557
557
compile (compiler, block);
558
558
}
559
559
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
+
560
574
TEST_F (CompilerTest, MoveToIf)
561
575
{
562
576
Compiler compiler (&m_engine, &m_target);
You can’t perform that action at this time.
0 commit comments