| 347 | bool CheckArgSize(FName fname, FArgumentList &args, int min, int max, FScriptPosition &sc); |
| 348 | |
| 349 | static FxExpression *ResolveGlobalCustomFunction(FxFunctionCall *func, FCompileContext &ctx) |
| 350 | { |
| 351 | auto& ScriptPosition = func->ScriptPosition; |
| 352 | if (func->MethodName == NAME_GetDefaultByType) |
| 353 | { |
| 354 | if (CheckArgSize(NAME_GetDefaultByType, func->ArgList, 1, 1, ScriptPosition)) |
| 355 | { |
| 356 | auto newfunc = new FxGetDefaultByType(func->ArgList[0]); |
| 357 | func->ArgList[0] = nullptr; |
| 358 | delete func; |
| 359 | return newfunc->Resolve(ctx); |
| 360 | } |
| 361 | } |
| 362 | |
| 363 | int min, max, special; |
| 364 | if (func->MethodName == NAME_ACS_NamedExecuteWithResult || func->MethodName == NAME_CallACS) |
| 365 | { |
| 366 | special = -ACS_ExecuteWithResult; |
| 367 | min = 1; |
| 368 | max = 5; |
| 369 | } |
| 370 | else |
| 371 | { |
| 372 | // This alias is needed because Actor has a Teleport function. |
| 373 | if (func->MethodName == NAME_TeleportSpecial) func->MethodName = NAME_Teleport; |
| 374 | special = P_FindLineSpecial(func->MethodName.GetChars(), &min, &max); |
| 375 | } |
| 376 | if (special != 0 && min >= 0) |
| 377 | { |
| 378 | int paramcount = func->ArgList.Size(); |
| 379 | if (ctx.Function == nullptr || ctx.Class == nullptr) |
| 380 | { |
| 381 | ScriptPosition.Message(MSG_ERROR, "Unable to call action special %s from constant declaration", func->MethodName.GetChars()); |
| 382 | delete func; |
| 383 | return nullptr; |
| 384 | } |
| 385 | else if (paramcount < min) |
| 386 | { |
| 387 | ScriptPosition.Message(MSG_ERROR, "Not enough parameters for '%s' (expected %d, got %d)", |
| 388 | func->MethodName.GetChars(), min, paramcount); |
| 389 | delete func; |
| 390 | return nullptr; |
| 391 | } |
| 392 | else if (paramcount > max) |
| 393 | { |
| 394 | ScriptPosition.Message(MSG_ERROR, "too many parameters for '%s' (expected %d, got %d)", |
| 395 | func->MethodName.GetChars(), max, paramcount); |
| 396 | delete func; |
| 397 | return nullptr; |
| 398 | } |
| 399 | FxExpression *self = (ctx.Function && (ctx.Function->Variants[0].Flags & VARF_Method) && isActor(ctx.Class)) ? new FxSelf(ScriptPosition) : (FxExpression*)new FxConstant(ScriptPosition); |
| 400 | FxExpression *x = new FxActionSpecialCall(self, special, func->ArgList, ScriptPosition); |
| 401 | delete func; |
| 402 | return x->Resolve(ctx); |
| 403 | } |
| 404 | return func; |
| 405 | } |
| 406 |
nothing calls this directly
no test coverage detected