-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathinstructionbuilder.cpp
More file actions
52 lines (45 loc) · 1.48 KB
/
Copy pathinstructionbuilder.cpp
File metadata and controls
52 lines (45 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// SPDX-License-Identifier: Apache-2.0
#include "instructionbuilder.h"
#include "functions.h"
#include "math.h"
#include "comparison.h"
#include "string.h"
#include "logic.h"
#include "control.h"
#include "variables.h"
#include "lists.h"
#include "procedures.h"
#include "../llvminstruction.h"
#include "../llvmbuildutils.h"
using namespace libscratchcpp;
using namespace libscratchcpp::llvmins;
InstructionBuilder::InstructionBuilder(LLVMBuildUtils &utils) :
m_utils(utils)
{
// Create groups
m_groups.push_back(std::make_shared<Functions>(utils));
m_groups.push_back(std::make_shared<Math>(utils));
m_groups.push_back(std::make_shared<Comparison>(utils));
m_groups.push_back(std::make_shared<String>(utils));
m_groups.push_back(std::make_shared<Logic>(utils));
m_groups.push_back(std::make_shared<Control>(utils));
m_groups.push_back(std::make_shared<Variables>(utils));
m_groups.push_back(std::make_shared<Lists>(utils));
m_groups.push_back(std::make_shared<Procedures>(utils));
}
LLVMInstruction *InstructionBuilder::process(LLVMInstruction *ins)
{
// Process all groups
for (const auto &group : m_groups) {
ProcessResult result = group->process(ins);
if (result.match) {
#ifndef LLVM_INTEGER_SUPPORT
if (ins->functionReturnReg)
ins->functionReturnReg->isInt = m_utils.builder().getInt1(false);
#endif
return result.next;
}
}
assert(false); // instruction not found
return ins;
}