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

Method link

src/hx/cppia/Cppia.cpp:3290–3454  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3288
3289 const char *getName() HXCPP_OVERRIDE { return "CallMember"; }
3290 CppiaExpr *link(CppiaModule &inModule) HXCPP_OVERRIDE
3291 {
3292 if (fieldId==0)
3293 return linkSuperCall(inModule);
3294
3295 TypeData *type = inModule.types[classId];
3296 String field = inModule.strings[fieldId];
3297
3298 //CPPIALOG(" linking call %s::%s\n", type->name.out_str(), field.out_str());
3299
3300 CppiaExpr *replace = 0;
3301
3302 if (type->arrayType)
3303 {
3304 replace = createArrayBuiltin(this, type->arrayType, thisExpr, field, args);
3305 if (!replace)
3306 {
3307 if (field!=HX_CSTRING("__SetField") && field!=HX_CSTRING("__Field") && field!=HX_CSTRING("__Index"))
3308 {
3309 CPPIALOG("Bad array field '%s'\n", field.out_str());
3310 inModule.where(this);
3311 throw "Unknown array field name";
3312 }
3313 }
3314 }
3315
3316
3317 if (!replace && type->cppiaClass)
3318 {
3319 if (callSuperField)
3320 {
3321 // Bind now ...
3322 ScriptCallable *func = (ScriptCallable *)type->cppiaClass->findFunction(false, fieldId) ;
3323 if (func)
3324 replace = new CallFunExpr( this, thisExpr, func, args, true );
3325 }
3326 else
3327 {
3328 int vtableSlot = type->cppiaClass->findFunctionSlot(fieldId);
3329
3330 //CPPIALOG(" vslot %d\n", vtableSlot);
3331 if (vtableSlot!=-1)
3332 {
3333 CppiaFunction *funcProto = type->cppiaClass->findVTableFunction(fieldId);
3334 int scriptPos = type->cppiaClass->getScriptVTableOffset();
3335 replace = new CallMemberVTable( this, thisExpr, vtableSlot, scriptPos, funcProto, type->cppiaClass->isInterface, args );
3336 }
3337 }
3338
3339 // Try interface function implemented in host only...
3340 if (!replace)
3341 {
3342 std::vector<ScriptNamedFunction *> &nativeInterfaceFuncs = type->cppiaClass->nativeInterfaceFunctions;
3343 for(int i=0;i<nativeInterfaceFuncs.size();i++)
3344 {
3345 if (!strcmp(nativeInterfaceFuncs[i]->name,field.utf8_str()))
3346 {
3347 //CPPIALOG(" found native interface function %s\n", field.out_str() );

Callers

nothing calls this directly

Calls 10

createArrayBuiltinFunction · 0.85
createStringBuiltinFunction · 0.85
whereMethod · 0.80
findFunctionSlotMethod · 0.80
findVTableFunctionMethod · 0.80
getScriptVTableOffsetMethod · 0.80
utf8_strMethod · 0.80
findFunctionMethod · 0.45
sizeMethod · 0.45
linkMethod · 0.45

Tested by

no test coverage detected