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

Method genCode

src/hx/cppia/Cppia.cpp:1299–1402  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1297 }
1298
1299 void genCode(CppiaCompiler *compiler, const JitVal &inDest,ExprType destType) HXCPP_OVERRIDE
1300 {
1301 if (destType==etNull || destType==etVoid)
1302 {
1303 value->genCode(compiler);
1304 return;
1305 }
1306
1307 if (op==castInt)
1308 {
1309 if (destType==etInt)
1310 value->genCode(compiler, inDest, destType);
1311 else
1312 {
1313 value->genCode(compiler, sJitTemp0, etInt);
1314 compiler->convert(sJitTemp0, etInt, inDest, destType);
1315 }
1316 }
1317 else if (op==castFloat)
1318 {
1319 if (destType==etFloat)
1320 value->genCode(compiler, inDest, destType);
1321 else
1322 {
1323 value->genCode(compiler, sJitTempF0, etFloat);
1324 compiler->convert(sJitTempF0, etFloat, inDest, destType);
1325 }
1326 }
1327 else if (op==castString)
1328 {
1329 if (destType==etString)
1330 value->genCode(compiler, inDest, destType);
1331 else
1332 {
1333 JitTemp temp(compiler,jtString);
1334 value->genCode(compiler, temp, etString);
1335 compiler->convert(temp, etString, inDest, destType );
1336 }
1337 }
1338 else if (op==castBool)
1339 {
1340 value->genCode(compiler, sJitTemp0, etInt);
1341
1342 JumpId isZero = compiler->compare(cmpI_EQUAL,sJitTemp0.as(jtInt),(int)0);
1343 if (destType==etInt)
1344 compiler->move(inDest.as(jtInt),1);
1345 else if (destType==etObject)
1346 compiler->move(inDest.as(jtPointer),(void *)Dynamic(true).mPtr);
1347 else
1348 {
1349 compiler->move(inDest.as(jtInt),String(true).length);
1350 compiler->move(inDest.as(jtPointer)+StringOffset::Ptr,(void *)String(true).raw_ptr());
1351 }
1352 JumpId done = compiler->jump();
1353
1354 compiler->comeFrom(isZero);
1355
1356 if (destType==etInt)

Callers

nothing calls this directly

Calls 13

convertMethod · 0.80
asMethod · 0.80
moveMethod · 0.80
jumpMethod · 0.80
comeFromMethod · 0.80
callNativeMethod · 0.80
checkExceptionMethod · 0.80
convertReturnRegMethod · 0.80
returnNullMethod · 0.80
DynamicClass · 0.50
StringClass · 0.50
genCodeMethod · 0.45

Tested by

no test coverage detected