MCPcopy Create free account
hub / github.com/anjo76/angelscript / PrepareFunctionCall

Method PrepareFunctionCall

sdk/angelscript/source/as_compiler.cpp:2312–2355  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2310}
2311
2312int asCCompiler::PrepareFunctionCall(int funcId, asCByteCode *bc, asCArray<asCExprContext *> &args)
2313{
2314 // When a match has been found, compile the final byte code using correct parameter types
2315 asCScriptFunction *descr = builder->GetFunctionDescription(funcId);
2316
2317 asASSERT( (descr->IsVariadic() && args.GetLength() >= descr->parameterTypes.GetLength() - 1) || descr->parameterTypes.GetLength() == args.GetLength() );
2318
2319 // If the function being called is the opAssign or copy constructor for the same type
2320 // as the argument, then we should avoid making temporary copy of the argument
2321 bool makingCopy = false;
2322 if( descr->parameterTypes.GetLength() == 1 &&
2323 descr->parameterTypes[0].IsEqualExceptRefAndConst(args[0]->type.dataType) &&
2324 (((descr->name == "opAssign" || descr->name == "$beh0") && descr->objectType && descr->objectType == args[0]->type.dataType.GetTypeInfo()) ||
2325 (descr->objectType == 0 && args[0]->type.dataType.GetTypeInfo() && descr->name == args[0]->type.dataType.GetTypeInfo()->name)) )
2326 makingCopy = true;
2327
2328 // Add code for arguments
2329 asCExprContext e(engine);
2330 for( int n = (int)args.GetLength()-1; n >= 0; n-- )
2331 {
2332 // Make sure PrepareArgument doesn't use any variable that is already
2333 // being used by the argument or any of the following argument expressions
2334 int l = int(reservedVariables.GetLength());
2335 for( int m = n; m >= 0; m-- )
2336 args[m]->bc.GetVarsUsed(reservedVariables);
2337
2338 asUINT realParamIdx = n;
2339 if (descr->IsVariadic())
2340 {
2341 if (n >= (int)descr->parameterTypes.GetLength() - 1)
2342 realParamIdx = descr->parameterTypes.GetLength() - 1;
2343 }
2344
2345 int r = PrepareArgument2(&e, args[n], &descr->parameterTypes[realParamIdx], true, descr->inOutFlags[realParamIdx], makingCopy);
2346 reservedVariables.SetLength(l);
2347
2348 if (r < 0)
2349 return r;
2350 }
2351
2352 bc->AddCode(&e.bc);
2353
2354 return 0;
2355}
2356
2357void asCCompiler::MoveArgsToStack(int funcId, asCByteCode *bc, asCArray<asCExprContext *> &args, bool addOneToOffset)
2358{

Callers

nothing calls this directly

Calls 8

IsVariadicMethod · 0.80
GetTypeInfoMethod · 0.80
GetVarsUsedMethod · 0.80
GetLengthMethod · 0.45
SetLengthMethod · 0.45
AddCodeMethod · 0.45

Tested by

no test coverage detected