| 495 | #endif |
| 496 | |
| 497 | nullres nullcRunFunction(const char* funcName, ...) |
| 498 | { |
| 499 | using namespace NULLC; |
| 500 | NULLC_CHECK_INITIALIZED(false); |
| 501 | |
| 502 | nullres good = true; |
| 503 | |
| 504 | #ifndef NULLC_NO_EXECUTOR |
| 505 | static char errorBuf[512]; |
| 506 | const char* argBuf = NULL; |
| 507 | |
| 508 | unsigned int functionID = ~0u; |
| 509 | // If function is called, find it's index |
| 510 | if(funcName) |
| 511 | { |
| 512 | unsigned int fnameHash = GetStringHash(funcName); |
| 513 | for(int i = (int)linker->exFunctions.size()-1; i >= 0; i--) |
| 514 | { |
| 515 | if(linker->exFunctions[i].nameHash == fnameHash) |
| 516 | { |
| 517 | functionID = i; |
| 518 | break; |
| 519 | } |
| 520 | } |
| 521 | if(functionID == ~0u) |
| 522 | { |
| 523 | SafeSprintf(errorBuf, 512, "ERROR: function %s not found", funcName); |
| 524 | nullcLastError = errorBuf; |
| 525 | return 0; |
| 526 | } |
| 527 | // Copy arguments in argument buffer |
| 528 | va_list args; |
| 529 | va_start(args, funcName); |
| 530 | argBuf = nullcGetArgumentVector(functionID, 0, args); |
| 531 | va_end(args); |
| 532 | if(!argBuf) |
| 533 | return false; |
| 534 | } |
| 535 | #else |
| 536 | (void)funcName; |
| 537 | #endif |
| 538 | if(currExec == NULLC_VM) |
| 539 | { |
| 540 | #ifndef NULLC_NO_EXECUTOR |
| 541 | executor->Run(functionID, argBuf); |
| 542 | const char* error = executor->GetExecError(); |
| 543 | if(error[0] != '\0') |
| 544 | { |
| 545 | good = false; |
| 546 | nullcLastError = error; |
| 547 | } |
| 548 | #endif |
| 549 | }else if(currExec == NULLC_X86){ |
| 550 | #ifdef NULLC_BUILD_X86_JIT |
| 551 | executorX86->Run(functionID, argBuf); |
| 552 | const char* error = executorX86->GetExecError(); |
| 553 | if(error[0] != '\0') |
| 554 | { |