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

Method genCode

src/hx/cppia/Cppia.cpp:2213–2292  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2211
2212 #ifdef CPPIA_JIT
2213 void genCode(CppiaCompiler *compiler, const JitVal &inDest,ExprType destType) HXCPP_OVERRIDE
2214 {
2215 int framePos = compiler->getCurrentFrameSize();
2216 if (thisExpr)
2217 {
2218 thisExpr->genCode(compiler, JitFramePos(framePos,jtPointer), etObject);
2219 genNullReferenceExceptionCheck(compiler, JitFramePos(framePos,jtPointer) );
2220 }
2221 else
2222 compiler->move(JitFramePos(framePos,jtPointer), sJitThis);
2223 compiler->addFrame(etObject);
2224
2225 for(int i=0;i<funcProto->args.size(); i++)
2226 {
2227 ArgInfo &arg = funcProto->args[i];
2228 ExprType baseType = funcProto->cppia.types[ arg.typeId ]->expressionType;
2229 ExprType type = arg.optional && baseType!=etString ? etObject : baseType;
2230
2231 args[i]->genCode( compiler, JitFramePos( compiler->getCurrentFrameSize() ).as( getJitType(type)), type );
2232 compiler->addFrame(type);
2233 }
2234
2235 compiler->restoreFrameSize(framePos);
2236
2237
2238 JitReg thisVal = thisExpr ? sJitTemp0 : sJitThis;
2239 if (thisExpr)
2240 compiler->move( thisVal.as(jtPointer), JitFramePos(framePos,jtPointer) );
2241
2242 // Store new frame in context ...
2243 compiler->add( sJitCtxFrame, sJitFrame, JitVal(framePos) );
2244
2245 TypeData *type = funcProto->cppia.types[funcProto->returnType];
2246 bool isBoolReturn = type->haxeClass==ClassOf<bool>();
2247
2248 if (isInterfaceCall)
2249 {
2250 //sJitTemp1 = ScriptCallable **vtable = thisVal->__GetScriptVTable();
2251 compiler->call( (void *)getScriptVTable,thisVal );
2252 compiler->move( sJitTemp1, sJitReturnReg.as(jtPointer) );
2253 if (thisExpr)
2254 compiler->move( thisVal.as(jtPointer), JitFramePos(framePos,jtPointer) );
2255 }
2256 else
2257 {
2258 //sJitTemp1 = ScriptCallable **vtable = *(ScriptCallable ***)((char *)thisVal +scriptVTableOffset);
2259 compiler->move(sJitTemp1.as(jtPointer), thisVal.star(jtPointer, scriptVTableOffset) );
2260 }
2261
2262 // sJitTemp1 = table[slot]
2263 compiler->move(sJitTemp1, sJitTemp1.star(jtPointer, slot*sizeof(void *)) );
2264
2265 // Implementation may return a more general type, with different byte representation
2266 if (checkInterfaceReturnType)
2267 {
2268 JitTemp actualReturnType(compiler,jtInt);
2269 compiler->move(actualReturnType, sJitTemp1.star(jtInt, offsetof(ScriptCallable,returnType)) );
2270

Callers

nothing calls this directly

Calls 15

JitFramePosClass · 0.85
getJitTypeFunction · 0.85
JitValClass · 0.85
genFunctionResultFunction · 0.85
getCurrentFrameSizeMethod · 0.80
moveMethod · 0.80
addFrameMethod · 0.80
asMethod · 0.80
restoreFrameSizeMethod · 0.80
convertMethod · 0.80
callNativeMethod · 0.80

Tested by

no test coverage detected