* @brief Allocates a new temporary variable and returns it * * @param Error the error type pointer * @return PSCRIPT_ENGINE_TOKEN */
| 652 | * @return PSCRIPT_ENGINE_TOKEN |
| 653 | */ |
| 654 | PSCRIPT_ENGINE_TOKEN |
| 655 | NewTemp(PSCRIPT_ENGINE_ERROR_TYPE Error) |
| 656 | { |
| 657 | static unsigned int TempID = 0; |
| 658 | int i; |
| 659 | for (i = 0; i < MAX_TEMP_COUNT; i++) |
| 660 | { |
| 661 | if (CurrentUserDefinedFunction->TempMap[i] == 0) |
| 662 | { |
| 663 | TempID = i; |
| 664 | CurrentUserDefinedFunction->TempMap[i] = 1; |
| 665 | break; |
| 666 | } |
| 667 | } |
| 668 | if (i == MAX_TEMP_COUNT) |
| 669 | { |
| 670 | *Error = SCRIPT_ENGINE_ERROR_TEMP_LIST_FULL; |
| 671 | } |
| 672 | PSCRIPT_ENGINE_TOKEN Temp = NewUnknownToken(); |
| 673 | char TempValue[8]; |
| 674 | sprintf(TempValue, "%d", TempID); |
| 675 | strcpy(Temp->Value, TempValue); |
| 676 | Temp->Type = TEMP; |
| 677 | |
| 678 | if (CurrentUserDefinedFunction->MaxTempNumber < (i + 1)) |
| 679 | { |
| 680 | CurrentUserDefinedFunction->MaxTempNumber = i + 1; |
| 681 | } |
| 682 | |
| 683 | return Temp; |
| 684 | } |
| 685 | |
| 686 | /** |
| 687 | * @brief Frees the memory allocated by Temp |
no test coverage detected