-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathicodebuilder.h
More file actions
109 lines (84 loc) · 5.69 KB
/
icodebuilder.h
File metadata and controls
109 lines (84 loc) · 5.69 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// SPDX-License-Identifier: Apache-2.0
#pragma once
#include <scratchcpp/compiler.h>
namespace libscratchcpp
{
class Value;
class Variable;
class List;
class ExecutableCode;
class BlockPrototype;
class ICodeBuilder
{
public:
virtual ~ICodeBuilder() { }
virtual std::shared_ptr<ExecutableCode> build() = 0;
virtual CompilerValue *addFunctionCall(const std::string &functionName, Compiler::StaticType returnType, const Compiler::ArgTypes &argTypes, const Compiler::Args &args) = 0;
virtual CompilerValue *addTargetFunctionCall(const std::string &functionName, Compiler::StaticType returnType, const Compiler::ArgTypes &argTypes, const Compiler::Args &args) = 0;
virtual CompilerValue *addFunctionCallWithCtx(const std::string &functionName, Compiler::StaticType returnType, const Compiler::ArgTypes &argTypes, const Compiler::Args &args) = 0;
virtual CompilerConstant *addConstValue(const Value &value) = 0;
virtual CompilerValue *addStringChar(CompilerValue *string, CompilerValue *index) = 0;
virtual CompilerValue *addStringLength(CompilerValue *string) = 0;
virtual CompilerValue *addLoopIndex() = 0;
virtual CompilerValue *addLocalVariableValue(CompilerLocalVariable *variable) = 0;
virtual CompilerValue *addVariableValue(Variable *variable) = 0;
virtual CompilerValue *addListContents(List *list) = 0;
virtual CompilerValue *addListItem(List *list, CompilerValue *index) = 0;
virtual CompilerValue *addListItemIndex(List *list, CompilerValue *item) = 0;
virtual CompilerValue *addListContains(List *list, CompilerValue *item) = 0;
virtual CompilerValue *addListSize(List *list) = 0;
virtual CompilerValue *addProcedureArgument(const std::string &name) = 0;
virtual CompilerValue *createAdd(CompilerValue *operand1, CompilerValue *operand2) = 0;
virtual CompilerValue *createSub(CompilerValue *operand1, CompilerValue *operand2) = 0;
virtual CompilerValue *createMul(CompilerValue *operand1, CompilerValue *operand2) = 0;
virtual CompilerValue *createDiv(CompilerValue *operand1, CompilerValue *operand2) = 0;
virtual CompilerValue *createRandom(CompilerValue *from, CompilerValue *to) = 0;
virtual CompilerValue *createRandomInt(CompilerValue *from, CompilerValue *to) = 0;
virtual CompilerValue *createCmpEQ(CompilerValue *operand1, CompilerValue *operand2) = 0;
virtual CompilerValue *createCmpGT(CompilerValue *operand1, CompilerValue *operand2) = 0;
virtual CompilerValue *createCmpLT(CompilerValue *operand1, CompilerValue *operand2) = 0;
virtual CompilerValue *createStrCmpEQ(CompilerValue *string1, CompilerValue *string2, bool caseSensitive = false) = 0;
virtual CompilerValue *createAnd(CompilerValue *operand1, CompilerValue *operand2) = 0;
virtual CompilerValue *createOr(CompilerValue *operand1, CompilerValue *operand2) = 0;
virtual CompilerValue *createNot(CompilerValue *operand) = 0;
virtual CompilerValue *createMod(CompilerValue *num1, CompilerValue *num2) = 0;
virtual CompilerValue *createRound(CompilerValue *num) = 0;
virtual CompilerValue *createAbs(CompilerValue *num) = 0;
virtual CompilerValue *createFloor(CompilerValue *num) = 0;
virtual CompilerValue *createCeil(CompilerValue *num) = 0;
virtual CompilerValue *createSqrt(CompilerValue *num) = 0;
virtual CompilerValue *createSin(CompilerValue *num) = 0;
virtual CompilerValue *createCos(CompilerValue *num) = 0;
virtual CompilerValue *createTan(CompilerValue *num) = 0;
virtual CompilerValue *createAsin(CompilerValue *num) = 0;
virtual CompilerValue *createAcos(CompilerValue *num) = 0;
virtual CompilerValue *createAtan(CompilerValue *num) = 0;
virtual CompilerValue *createLn(CompilerValue *num) = 0;
virtual CompilerValue *createLog10(CompilerValue *num) = 0;
virtual CompilerValue *createExp(CompilerValue *num) = 0;
virtual CompilerValue *createExp10(CompilerValue *num) = 0;
virtual CompilerValue *createStringConcat(CompilerValue *string1, CompilerValue *string2) = 0;
virtual CompilerValue *createSelect(CompilerValue *cond, CompilerValue *trueValue, CompilerValue *falseValue, Compiler::StaticType valueType) = 0;
virtual CompilerLocalVariable *createLocalVariable(Compiler::StaticType type) = 0;
virtual void createLocalVariableWrite(CompilerLocalVariable *variable, CompilerValue *value) = 0;
virtual void createVariableWrite(Variable *variable, CompilerValue *value) = 0;
virtual void createListClear(List *list) = 0;
virtual void createListRemove(List *list, CompilerValue *index) = 0;
virtual void createListAppend(List *list, CompilerValue *item) = 0;
virtual void createListInsert(List *list, CompilerValue *index, CompilerValue *item) = 0;
virtual void createListReplace(List *list, CompilerValue *index, CompilerValue *item) = 0;
virtual void beginIfStatement(CompilerValue *cond) = 0;
virtual void beginElseBranch() = 0;
virtual void endIf() = 0;
virtual void beginRepeatLoop(CompilerValue *count) = 0;
virtual void beginWhileLoop(CompilerValue *cond) = 0;
virtual void beginRepeatUntilLoop(CompilerValue *cond) = 0;
virtual void beginLoopCondition() = 0;
virtual void endLoop() = 0;
virtual void yield() = 0;
virtual void createStop() = 0;
virtual void createThreadStop() = 0;
virtual void invalidateTarget() = 0;
virtual void createProcedureCall(BlockPrototype *prototype, const Compiler::Args &args) = 0;
};
} // namespace libscratchcpp