11// SPDX-License-Identifier: Apache-2.0
22
3+ #include < scratchcpp/compilerlocalvariable.h>
4+
35#include " cppcodebuilder.h"
6+ #include " cppexecutablecode.h"
47#include " cppconstant.h"
58#include " ../typeutils.h"
69
@@ -15,22 +18,22 @@ CppCodeBuilder::CppCodeBuilder(CppCompilerContext *ctx, BlockPrototype *procedur
1518
1619std::shared_ptr<ExecutableCode> CppCodeBuilder::build ()
1720{
18- return nullptr ;
21+ return std::make_shared<CppExecutableCode>(m_ctx) ;
1922}
2023
2124CompilerValue *CppCodeBuilder::addFunctionCall (const std::string &functionName, Compiler::StaticType returnType, const Compiler::ArgTypes &argTypes, const Compiler::Args &args)
2225{
23- return nullptr ;
26+ return addConstValue ( Value ()) ;
2427}
2528
2629CompilerValue *CppCodeBuilder::addTargetFunctionCall (const std::string &functionName, Compiler::StaticType returnType, const Compiler::ArgTypes &argTypes, const Compiler::Args &args)
2730{
28- return nullptr ;
31+ return addConstValue ( Value ()) ;
2932}
3033
3134CompilerValue *CppCodeBuilder::addFunctionCallWithCtx (const std::string &functionName, Compiler::StaticType returnType, const Compiler::ArgTypes &argTypes, const Compiler::Args &args)
3235{
33- return nullptr ;
36+ return addConstValue ( Value ()) ;
3437}
3538
3639CompilerConstant *CppCodeBuilder::addConstValue (const Value &value)
@@ -42,217 +45,221 @@ CompilerConstant *CppCodeBuilder::addConstValue(const Value &value)
4245
4346CompilerValue *CppCodeBuilder::addStringChar (CompilerValue *string, CompilerValue *index)
4447{
45- return nullptr ;
48+ return addConstValue ( Value ()) ;
4649}
4750
4851CompilerValue *CppCodeBuilder::addStringLength (CompilerValue *string)
4952{
50- return nullptr ;
53+ return addConstValue ( Value ()) ;
5154}
5255
5356CompilerValue *CppCodeBuilder::addLoopIndex ()
5457{
55- return nullptr ;
58+ return addConstValue ( Value ()) ;
5659}
5760
5861CompilerValue *CppCodeBuilder::addLocalVariableValue (CompilerLocalVariable *variable)
5962{
60- return nullptr ;
63+ return addConstValue ( Value ()) ;
6164}
6265
6366CompilerValue *CppCodeBuilder::addVariableValue (Variable *variable)
6467{
65- return nullptr ;
68+ return addConstValue ( Value ()) ;
6669}
6770
6871CompilerValue *CppCodeBuilder::addListContents (List *list)
6972{
70- return nullptr ;
73+ return addConstValue ( Value ()) ;
7174}
7275
7376CompilerValue *CppCodeBuilder::addListItem (List *list, CompilerValue *index)
7477{
75- return nullptr ;
78+ return addConstValue ( Value ()) ;
7679}
7780
7881CompilerValue *CppCodeBuilder::addListItemIndex (List *list, CompilerValue *item)
7982{
80- return nullptr ;
83+ return addConstValue ( Value ()) ;
8184}
8285
8386CompilerValue *CppCodeBuilder::addListContains (List *list, CompilerValue *item)
8487{
85- return nullptr ;
88+ return addConstValue ( Value ()) ;
8689}
8790
8891CompilerValue *CppCodeBuilder::addListSize (List *list)
8992{
90- return nullptr ;
93+ return addConstValue ( Value ()) ;
9194}
9295
9396CompilerValue *CppCodeBuilder::addProcedureArgument (const std::string &name)
9497{
95- return nullptr ;
98+ return addConstValue ( Value ()) ;
9699}
97100
98101CompilerValue *CppCodeBuilder::createAdd (CompilerValue *operand1, CompilerValue *operand2)
99102{
100- return nullptr ;
103+ return addConstValue ( Value ()) ;
101104}
102105
103106CompilerValue *CppCodeBuilder::createSub (CompilerValue *operand1, CompilerValue *operand2)
104107{
105- return nullptr ;
108+ return addConstValue ( Value ()) ;
106109}
107110
108111CompilerValue *CppCodeBuilder::createMul (CompilerValue *operand1, CompilerValue *operand2)
109112{
110- return nullptr ;
113+ return addConstValue ( Value ()) ;
111114}
112115
113116CompilerValue *CppCodeBuilder::createDiv (CompilerValue *operand1, CompilerValue *operand2)
114117{
115- return nullptr ;
118+ return addConstValue ( Value ()) ;
116119}
117120
118121CompilerValue *CppCodeBuilder::createRandom (CompilerValue *from, CompilerValue *to)
119122{
120- return nullptr ;
123+ return addConstValue ( Value ()) ;
121124}
122125
123126CompilerValue *CppCodeBuilder::createRandomInt (CompilerValue *from, CompilerValue *to)
124127{
125- return nullptr ;
128+ return addConstValue ( Value ()) ;
126129}
127130
128131CompilerValue *CppCodeBuilder::createCmpEQ (CompilerValue *operand1, CompilerValue *operand2)
129132{
130- return nullptr ;
133+ return addConstValue ( Value ()) ;
131134}
132135
133136CompilerValue *CppCodeBuilder::createCmpGT (CompilerValue *operand1, CompilerValue *operand2)
134137{
135- return nullptr ;
138+ return addConstValue ( Value ()) ;
136139}
137140
138141CompilerValue *CppCodeBuilder::createCmpLT (CompilerValue *operand1, CompilerValue *operand2)
139142{
140- return nullptr ;
143+ return addConstValue ( Value ()) ;
141144}
142145
143146CompilerValue *CppCodeBuilder::createStrCmpEQ (CompilerValue *string1, CompilerValue *string2, bool caseSensitive)
144147{
145- return nullptr ;
148+ return addConstValue ( Value ()) ;
146149}
147150
148151CompilerValue *CppCodeBuilder::createAnd (CompilerValue *operand1, CompilerValue *operand2)
149152{
150- return nullptr ;
153+ return addConstValue ( Value ()) ;
151154}
152155
153156CompilerValue *CppCodeBuilder::createOr (CompilerValue *operand1, CompilerValue *operand2)
154157{
155- return nullptr ;
158+ return addConstValue ( Value ()) ;
156159}
157160
158161CompilerValue *CppCodeBuilder::createNot (CompilerValue *operand)
159162{
160- return nullptr ;
163+ return addConstValue ( Value ()) ;
161164}
162165
163166CompilerValue *CppCodeBuilder::createMod (CompilerValue *num1, CompilerValue *num2)
164167{
165- return nullptr ;
168+ return addConstValue ( Value ()) ;
166169}
167170
168171CompilerValue *CppCodeBuilder::createRound (CompilerValue *num)
169172{
170- return nullptr ;
173+ return addConstValue ( Value ()) ;
171174}
172175
173176CompilerValue *CppCodeBuilder::createAbs (CompilerValue *num)
174177{
175- return nullptr ;
178+ return addConstValue ( Value ()) ;
176179}
177180
178181CompilerValue *CppCodeBuilder::createFloor (CompilerValue *num)
179182{
180- return nullptr ;
183+ return addConstValue ( Value ()) ;
181184}
182185
183186CompilerValue *CppCodeBuilder::createCeil (CompilerValue *num)
184187{
185- return nullptr ;
188+ return addConstValue ( Value ()) ;
186189}
187190
188191CompilerValue *CppCodeBuilder::createSqrt (CompilerValue *num)
189192{
190- return nullptr ;
193+ return addConstValue ( Value ()) ;
191194}
192195
193196CompilerValue *CppCodeBuilder::createSin (CompilerValue *num)
194197{
195- return nullptr ;
198+ return addConstValue ( Value ()) ;
196199}
197200
198201CompilerValue *CppCodeBuilder::createCos (CompilerValue *num)
199202{
200- return nullptr ;
203+ return addConstValue ( Value ()) ;
201204}
202205
203206CompilerValue *CppCodeBuilder::createTan (CompilerValue *num)
204207{
205- return nullptr ;
208+ return addConstValue ( Value ()) ;
206209}
207210
208211CompilerValue *CppCodeBuilder::createAsin (CompilerValue *num)
209212{
210- return nullptr ;
213+ return addConstValue ( Value ()) ;
211214}
212215
213216CompilerValue *CppCodeBuilder::createAcos (CompilerValue *num)
214217{
215- return nullptr ;
218+ return addConstValue ( Value ()) ;
216219}
217220
218221CompilerValue *CppCodeBuilder::createAtan (CompilerValue *num)
219222{
220- return nullptr ;
223+ return addConstValue ( Value ()) ;
221224}
222225
223226CompilerValue *CppCodeBuilder::createLn (CompilerValue *num)
224227{
225- return nullptr ;
228+ return addConstValue ( Value ()) ;
226229}
227230
228231CompilerValue *CppCodeBuilder::createLog10 (CompilerValue *num)
229232{
230- return nullptr ;
233+ return addConstValue ( Value ()) ;
231234}
232235
233236CompilerValue *CppCodeBuilder::createExp (CompilerValue *num)
234237{
235- return nullptr ;
238+ return addConstValue ( Value ()) ;
236239}
237240
238241CompilerValue *CppCodeBuilder::createExp10 (CompilerValue *num)
239242{
240- return nullptr ;
243+ return addConstValue ( Value ()) ;
241244}
242245
243246CompilerValue *CppCodeBuilder::createStringConcat (CompilerValue *string1, CompilerValue *string2)
244247{
245- return nullptr ;
248+ return addConstValue ( Value ()) ;
246249}
247250
248251CompilerValue *CppCodeBuilder::createSelect (CompilerValue *cond, CompilerValue *trueValue, CompilerValue *falseValue, Compiler::StaticType valueType)
249252{
250- return nullptr ;
253+ return addConstValue ( Value ()) ;
251254}
252255
253256CompilerLocalVariable *CppCodeBuilder::createLocalVariable (Compiler::StaticType type)
254257{
255- return nullptr ;
258+ // TODO: Complete this
259+ CompilerValue *ptr = addConstValue (Value ());
260+ auto var = std::make_shared<CompilerLocalVariable>(ptr);
261+ m_localVars.push_back (var);
262+ return var.get ();
256263}
257264
258265void CppCodeBuilder::createLocalVariableWrite (CompilerLocalVariable *variable, CompilerValue *value)
0 commit comments