MCPcopy Create free account
hub / github.com/HaxeFoundation/hxcpp / genCode

Method genCode

src/hx/cppia/ArrayBuiltin.cpp:223–381  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

221
222
223 void genCode(CppiaCompiler *compiler, const JitVal &inDest, ExprType destType) HXCPP_OVERRIDE
224 {
225 ExprType elemType = (ExprType)ExprTypeOf<ELEM>::value;
226 ExprType rightHandType;
227 switch((int)FUNC::op)
228 {
229 case aoMult:
230 case aoDiv:
231 case aoSub:
232 case aoMod:
233 rightHandType = etFloat;
234 break;
235
236 case aoAnd:
237 case aoOr:
238 case aoXOr:
239 case aoShl:
240 case aoShr:
241 case aoUShr:
242 rightHandType = etInt;
243
244 default:
245 rightHandType = elemType;
246 }
247
248 if ((int)FUNC::op==aoSet)
249 {
250 JitTemp thisVal(compiler,jtPointer);
251 thisExpr->genCode(compiler, thisVal, etObject);
252
253 // sJitTemp1 = index
254 JitTemp index(compiler,jtInt);
255 args[0]->genCode(compiler, index, etInt);
256
257 // Right-hand-size
258 JitTemp value(compiler,getJitType(rightHandType));
259 args[1]->genCode(compiler, value, rightHandType);
260
261 compiler->move(sJitTemp1,index);
262
263 // sJitTemp0 = this
264 compiler->move(sJitTemp0, thisVal);
265
266
267 // Check length..
268 JumpId lengthOk = compiler->compare( cmpI_LESS, sJitTemp1.as(jtInt),
269 sJitTemp0.star(jtInt, ArrayBase::lengthOffset()) );
270
271
272 JumpId enough = compiler->compare( cmpI_LESS, sJitTemp1.as(jtInt),
273 sJitTemp0.star(jtInt, ArrayBase::allocOffset()) );
274 // Make some room
275 compiler->callNative( (void *)array_expand_size, sJitTemp0.as(jtPointer), sJitTemp1.as(jtInt) );
276 // sJitTemp0 is still this, restore length...
277 compiler->move( sJitTemp1,index);
278
279 compiler->comeFrom(enough);
280

Callers 1

genCodeMethod · 0.45

Calls 15

getJitTypeFunction · 0.85
lengthOffsetFunction · 0.85
allocOffsetFunction · 0.85
baseOffsetFunction · 0.85
genWriteBarrierFunction · 0.85
moveMethod · 0.80
asMethod · 0.80
callNativeMethod · 0.80
comeFromMethod · 0.80
atRegMethod · 0.80
multMethod · 0.80
convertMethod · 0.80

Tested by

no test coverage detected