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

Method PerformFunctionCall

sdk/angelscript/source/as_compiler.cpp:17250–17617  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17248
17249
17250void asCCompiler::PerformFunctionCall(int funcId, asCExprContext *ctx, bool isConstructor, asCArray<asCExprContext*> *args, asCObjectType *objType, bool useVariable, int varOffset, int funcPtrVar)
17251{
17252 asCScriptFunction *descr = builder->GetFunctionDescription(funcId);
17253
17254 // A shared object may not call non-shared functions
17255 if( outFunc->IsShared() && !descr->IsShared() )
17256 {
17257 asCString msg;
17258 msg.Format(TXT_SHARED_CANNOT_CALL_NON_SHARED_FUNC_s, descr->GetDeclarationStr().AddressOf());
17259 Error(msg, ctx->exprNode);
17260 }
17261
17262 // Check if the function is private or protected
17263 if (descr->IsPrivate())
17264 {
17265 asCObjectType *type = descr->objectType;
17266 if (type == 0 && descr->traits.GetTrait(asTRAIT_CONSTRUCTOR))
17267 type = CastToObjectType(descr->returnType.GetTypeInfo());
17268
17269 asASSERT(type);
17270
17271 if( (type != outFunc->GetObjectType()) )
17272 {
17273 asCString msg;
17274 msg.Format(TXT_PRIVATE_METHOD_CALL_s, descr->GetDeclarationStr().AddressOf());
17275 Error(msg, ctx->exprNode);
17276 }
17277 }
17278 else if (descr->IsProtected())
17279 {
17280 asCObjectType *type = descr->objectType;
17281 if (type == 0 && descr->traits.GetTrait(asTRAIT_CONSTRUCTOR))
17282 type = CastToObjectType(descr->returnType.GetTypeInfo());
17283
17284 asASSERT(type);
17285
17286 if (!(type == outFunc->objectType || (outFunc->objectType && outFunc->objectType->DerivesFrom(type))))
17287 {
17288 asCString msg;
17289 msg.Format(TXT_PROTECTED_METHOD_CALL_s, descr->GetDeclarationStr().AddressOf());
17290 Error(msg, ctx->exprNode);
17291 }
17292 }
17293
17294 int argSize = descr->GetSpaceNeededForArguments();
17295 if (descr->IsVariadic())
17296 {
17297 // Compute the additional space used for the variadic args
17298 asCDataType variadicType = descr->parameterTypes[descr->parameterTypes.GetLength() - 1];
17299 int sizeOfVariadicArg = variadicType.GetSizeOnStackDWords();
17300
17301 // GetSpaceNeededForArguments already added one variadic arg for the ..., but there might not actually be any
17302 argSize -= sizeOfVariadicArg;
17303
17304 // Add 1 for the arg count
17305 argSize++;
17306
17307 // Add the actual space used for the variadic args

Callers

nothing calls this directly

Calls 15

CastToObjectTypeFunction · 0.85
GetDeclarationStrMethod · 0.80
IsPrivateMethod · 0.80
GetTraitMethod · 0.80
GetTypeInfoMethod · 0.80
IsProtectedMethod · 0.80
IsVariadicMethod · 0.80
GetSizeOnStackDWordsMethod · 0.80
IsObjectHandleMethod · 0.80
SupportHandlesMethod · 0.80

Tested by

no test coverage detected