Skip to content

Commit 0887e59

Browse files
committed
Store more info about used procedures
1 parent 60cef4c commit 0887e59

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

src/engine/internal/llvm/instructions/procedures.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ LLVMInstruction *Procedures::buildCallProcedure(LLVMInstruction *ins)
4444
llvm::FunctionType *type = m_utils.scriptFunctionType(ins->procedurePrototype);
4545
std::vector<llvm::Value *> args;
4646

47-
m_utils.compilerCtx()->addUsedProcedure(name);
47+
m_utils.compilerCtx()->addUsedProcedure(ins->procedurePrototype, name, type);
4848

4949
llvm::FunctionType *funcType = m_utils.scriptFunctionType(nullptr);
5050
int passArgCount = funcType->getNumParams();

src/engine/internal/llvm/llvmcompilercontext.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ const std::unordered_map<function_id_t, LLVMExecutableCode *> &LLVMCompilerConte
6565
return m_codeMap;
6666
}
6767

68-
void LLVMCompilerContext::addUsedProcedure(const std::string &functionName)
68+
void LLVMCompilerContext::addUsedProcedure(BlockPrototype *prototype, const std::string &functionName, llvm::FunctionType *functionType)
6969
{
70-
m_usedProcedures.insert(functionName);
70+
m_usedProcedures[prototype] = { functionName, functionType };
7171
}
7272

7373
function_id_t LLVMCompilerContext::getNextFunctionId()

src/engine/internal/llvm/llvmcompilercontext.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88

99
#include <scratchcpp/compilercontext.h>
1010

11-
#include <unordered_set>
11+
#include <unordered_map>
1212

1313
namespace libscratchcpp
1414
{
1515

1616
class ExecutionContext;
1717
class ValueData;
1818
class List;
19+
class BlockPrototype;
1920
class LLVMExecutableCode;
2021

2122
// NOTE: Change this in LLVMTypes as well
@@ -34,7 +35,7 @@ class LLVMCompilerContext : public CompilerContext
3435
void addCode(LLVMExecutableCode *code);
3536
const std::unordered_map<function_id_t, LLVMExecutableCode *> &codeMap() const;
3637

37-
void addUsedProcedure(const std::string &functionName);
38+
void addUsedProcedure(BlockPrototype *prototype, const std::string &functionName, llvm::FunctionType *functionType);
3839

3940
function_id_t getNextFunctionId();
4041

@@ -94,7 +95,7 @@ class LLVMCompilerContext : public CompilerContext
9495
llvm::StructType *m_stringPtrType = nullptr;
9596
llvm::Type *m_functionIdType = nullptr;
9697

97-
std::unordered_set<std::string> m_usedProcedures;
98+
std::unordered_map<BlockPrototype *, std::pair<std::string, llvm::FunctionType *>> m_usedProcedures; // function name, function type
9899
};
99100

100101
} // namespace libscratchcpp

0 commit comments

Comments
 (0)