Skip to content

Commit d87d6f0

Browse files
committed
Use raw pointers for loop var/list write instructions
1 parent bfd3b0c commit d87d6f0

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/engine/internal/llvm/llvmcodebuilder.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1742,7 +1742,7 @@ void LLVMCodeBuilder::createVariableWrite(Variable *variable, CompilerValue *val
17421742

17431743
if (m_loopScope >= 0) {
17441744
auto scope = m_loopScopes[m_loopScope];
1745-
m_variablePtrs[variable].loopVariableWrites[scope.get()].push_back(m_instructionList.back());
1745+
m_variablePtrs[variable].loopVariableWrites[scope.get()].push_back(m_instructions.last());
17461746
}
17471747

17481748
m_variableInstructions.push_back(m_instructions.last());
@@ -1779,7 +1779,7 @@ void LLVMCodeBuilder::createListAppend(List *list, CompilerValue *item)
17791779

17801780
if (m_loopScope >= 0) {
17811781
auto scope = m_loopScopes[m_loopScope];
1782-
m_listPtrs[list].loopListWrites[scope.get()].push_back(m_instructionList.back());
1782+
m_listPtrs[list].loopListWrites[scope.get()].push_back(m_instructions.last());
17831783
}
17841784

17851785
m_listInstructions.push_back(m_instructions.last());
@@ -1796,7 +1796,7 @@ void LLVMCodeBuilder::createListInsert(List *list, CompilerValue *index, Compile
17961796

17971797
if (m_loopScope >= 0) {
17981798
auto scope = m_loopScopes[m_loopScope];
1799-
m_listPtrs[list].loopListWrites[scope.get()].push_back(m_instructionList.back());
1799+
m_listPtrs[list].loopListWrites[scope.get()].push_back(m_instructions.last());
18001800
}
18011801

18021802
m_listInstructions.push_back(m_instructions.last());
@@ -1813,7 +1813,7 @@ void LLVMCodeBuilder::createListReplace(List *list, CompilerValue *index, Compil
18131813

18141814
if (m_loopScope >= 0) {
18151815
auto scope = m_loopScopes[m_loopScope];
1816-
m_listPtrs[list].loopListWrites[scope.get()].push_back(m_instructionList.back());
1816+
m_listPtrs[list].loopListWrites[scope.get()].push_back(m_instructions.last());
18171817
}
18181818

18191819
m_listInstructions.push_back(m_instructions.last());
@@ -2656,7 +2656,7 @@ bool LLVMCodeBuilder::isVarOrListTypeSafe(LLVMInstruction *ins, Compiler::Static
26562656
const auto &writes = it->second;
26572657

26582658
for (auto w : writes)
2659-
lastWrites.push_back(w.get());
2659+
lastWrites.push_back(w);
26602660
}
26612661

26622662
if (checkScope->childScopes.empty())

src/engine/internal/llvm/llvmlistptr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ struct LLVMListPtr
2828
Compiler::StaticType type = Compiler::StaticType::Unknown;
2929

3030
// Used in build phase to check the type safety of lists in loops
31-
std::unordered_map<LLVMLoopScope *, std::vector<std::shared_ptr<LLVMInstruction>>> loopListWrites; // loop scope, write instructions
31+
std::unordered_map<LLVMLoopScope *, std::vector<LLVMInstruction *>> loopListWrites; // loop scope, write instructions
3232
};
3333

3434
} // namespace libscratchcpp

src/engine/internal/llvm/llvmvariableptr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ struct LLVMVariablePtr
2727
bool changed = false;
2828

2929
// Used in build phase to check the type safety of variables in loops
30-
std::unordered_map<LLVMLoopScope *, std::vector<std::shared_ptr<LLVMInstruction>>> loopVariableWrites; // loop scope, write instructions
30+
std::unordered_map<LLVMLoopScope *, std::vector<LLVMInstruction *>> loopVariableWrites; // loop scope, write instructions
3131
};
3232

3333
} // namespace libscratchcpp

0 commit comments

Comments
 (0)