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

Method genCode

src/hx/cppia/Cppia.cpp:1567–1682  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1565
1566 #ifdef CPPIA_JIT
1567 void genCode(CppiaCompiler *compiler, const JitVal &inDest,ExprType destType) HXCPP_OVERRIDE
1568 {
1569 if (type->arrayType)
1570 {
1571 void *func = 0;
1572 switch(type->arrayType)
1573 {
1574 case arrBool: func = (void *)createArrayBool; break;
1575 case arrUnsignedChar: func = (void *)createArrayUChar; break;
1576 case arrInt:func = (void *)createArrayInt; break;
1577 case arrFloat:func = (void *)createArrayFloat; break;
1578 case arrFloat32:func = (void *)createArrayFloat32; break;
1579 case arrString:func = (void *)createArrayString; break;
1580 case arrAny:func = (void *)createArrayAny; break;
1581 case arrObject:func = (void *)createArrayObject; break;
1582 default:
1583 CPPIALOG("Unknown array creation\n");
1584 return;
1585 }
1586
1587 if (args.size()==1)
1588 {
1589 args[0]->genCode(compiler, sJitTemp0, etInt);
1590 compiler->callNative(func,sJitTemp0.as(jtInt));
1591 }
1592 else
1593 compiler->callNative(func,(int)0);
1594 compiler->convert(sJitReturnReg, etObject, inDest, destType);
1595 }
1596 else if (constructor)
1597 {
1598 int n = args.size();
1599 JitTemp argList(compiler,jtPointer);
1600 compiler->callNative((void *)createArrayObject,n);
1601 compiler->move(argList, sJitReturnReg);
1602 for(int a=0;a<n;a++)
1603 {
1604 args[a]->genCode(compiler, sJitTemp2, etObject);
1605
1606 compiler->move(sJitTemp0, argList);
1607 compiler->move(sJitTemp1, sJitTemp0.star(jtPointer, ArrayBase::baseOffset()));
1608 compiler->move(sJitTemp1.star(jtPointer,a*sizeof(void *)), sJitTemp2.as(jtPointer) );
1609 }
1610
1611 compiler->callNative( (void *)runConstructor, (void *)constructor, argList );
1612 compiler->checkException();
1613 compiler->convert(sJitReturnReg, etObject, inDest, destType);
1614 }
1615 else
1616 {
1617 CppiaClassInfo *info = type->cppiaClass;
1618 // return info->createInstance(ctx,args);
1619
1620 #ifdef HXCPP_GC_NURSERY
1621 if (info->dynamicFunctions.size()==0)
1622 {
1623 int size = info->haxeBase->mDataOffset + info->extraData;
1624 // sJitCtx = alloc

Callers

nothing calls this directly

Calls 15

baseOffsetFunction · 0.85
genFunctionCallFunction · 0.85
JitValClass · 0.85
callNativeMethod · 0.80
asMethod · 0.80
convertMethod · 0.80
moveMethod · 0.80
checkExceptionMethod · 0.80
jumpMethod · 0.80
comeFromMethod · 0.80
getHaxeBaseVTableMethod · 0.80
convertResultMethod · 0.80

Tested by

no test coverage detected