| 12107 | |
| 12108 | |
| 12109 | BIF_DECL(BIF_PerformAction) |
| 12110 | { |
| 12111 | ActionTypeType act = _f_callee_id; |
| 12112 | |
| 12113 | // An array of args is constructed containing the var or text of each parameter, |
| 12114 | // which is also placed into sArgDeref[] so ExpandArgs() can be skipped. |
| 12115 | // This function is intended to be transitional; eventually all ACT functions |
| 12116 | // should be converted to BIF. |
| 12117 | ArgStruct arg[MAX_ARGS]; |
| 12118 | |
| 12119 | TCHAR number_buf[MAX_ARGS * MAX_NUMBER_SIZE]; // Enough for worst case. |
| 12120 | |
| 12121 | for (int i = 0; i < aParamCount; ++i) |
| 12122 | { |
| 12123 | arg[i].is_expression = false; |
| 12124 | arg[i].postfix = aParam[i]; // For ArgToInt64() etc. |
| 12125 | arg[i].type = ARG_TYPE_NORMAL; |
| 12126 | arg[i].text = TokenToString(*aParam[i], number_buf + (i * MAX_NUMBER_SIZE)); |
| 12127 | arg[i].deref = NULL; |
| 12128 | Line::sArgDeref[i] = arg[i].text; |
| 12129 | // length won't actually be used. |
| 12130 | //arg[i].length = (ArgLengthType)_tcslen(arg[i].text); |
| 12131 | } |
| 12132 | |
| 12133 | int max_params = aResultToken.func->mParamCount; |
| 12134 | for (int i = aParamCount; i < max_params; ++i) |
| 12135 | Line::sArgDeref[i] = _T(""); |
| 12136 | |
| 12137 | // Since our ArgStructs aren't fully initialized, it isn't safe to call line->ToText(). |
| 12138 | // To avoid that in the event of an error, make g->ExcptMode non-zero so that errors are |
| 12139 | // displayed via UnhandledException(), which locates the proper Line via line number. |
| 12140 | auto outer_excptmode = g->ExcptMode; |
| 12141 | g->ExcptMode |= EXCPTMODE_LINE_WORKAROUND; |
| 12142 | |
| 12143 | // Construct a Line containing the required context for Perform(). |
| 12144 | Line line(0, 0, act, arg, aParamCount); |
| 12145 | |
| 12146 | // PERFORM THE ACTION |
| 12147 | ResultType result = line.Perform(); |
| 12148 | |
| 12149 | if (result == OK) // Can be OK, FAIL or EARLY_EXIT. |
| 12150 | aResultToken.ReturnPtr(_T(""), 0); |
| 12151 | else |
| 12152 | // Pass back the result code (FAIL or EARLY_EXIT). |
| 12153 | aResultToken.SetExitResult(result); |
| 12154 | |
| 12155 | |
| 12156 | g->ExcptMode = outer_excptmode; |
| 12157 | } |
| 12158 | |
| 12159 | |
| 12160 |
no test coverage detected