| 5037 | |
| 5038 | |
| 5039 | ResultType Script::AddLine(ActionTypeType aActionType, LPTSTR aArg[], int aArgc, LPTSTR aArgMap[], bool aAllArgsAreExpressions) |
| 5040 | // aArg must be a collection of pointers to memory areas that are modifiable, and there |
| 5041 | // must be at least aArgc number of pointers in the aArg array. In v1.0.40, a caller (namely |
| 5042 | // the "macro expansion" for remappings such as "a::b") is allowed to pass a non-NULL value for |
| 5043 | // aArg but a NULL value for aArgMap. |
| 5044 | // Returns OK or FAIL. |
| 5045 | { |
| 5046 | #ifdef _DEBUG |
| 5047 | if (aActionType == ACT_INVALID) |
| 5048 | return ScriptError(_T("DEBUG: BAD AddLine"), aArgc > 0 ? aArg[0] : _T("")); |
| 5049 | #endif |
| 5050 | if (mLastHotFunc) |
| 5051 | { |
| 5052 | if (aActionType != ACT_BLOCK_BEGIN) |
| 5053 | return ScriptError(ERR_HOTKEY_MISSING_BRACE); |
| 5054 | // This is copied from DefineFunc: |
| 5055 | else if (mLastLabel && !mLastLabel->mJumpToLine && !mNoUpdateLabels) |
| 5056 | { |
| 5057 | // There are one or more labels pointing at this function. |
| 5058 | return ScriptError(_T("A label must not point to a function."), mLastLabel->mName); |
| 5059 | } |
| 5060 | mLastHotFunc = nullptr; |
| 5061 | } |
| 5062 | |
| 5063 | DerefList deref; // Will be used to temporarily store the var-deref locations in each arg. |
| 5064 | ArgStruct *new_arg; // We will allocate some dynamic memory for this, then hang it onto the new line. |
| 5065 | LPTSTR this_aArgMap, this_aArg; |
| 5066 | |
| 5067 | ////////////////////////////////////////////////////////// |
| 5068 | // Build the new arg list in dynamic memory. |
| 5069 | // The allocated structs will be attached to the new line. |
| 5070 | ////////////////////////////////////////////////////////// |
| 5071 | if (!aArgc) |
| 5072 | new_arg = NULL; // Just need an empty array in this case. |
| 5073 | else |
| 5074 | { |
| 5075 | new_arg = SimpleHeap::Alloc<ArgStruct>(aArgc); |
| 5076 | |
| 5077 | int i; |
| 5078 | |
| 5079 | for (i = 0; i < aArgc; ++i) |
| 5080 | { |
| 5081 | //////////////// |
| 5082 | // FOR EACH ARG: |
| 5083 | //////////////// |
| 5084 | this_aArg = aArg[i]; // For performance and convenience. |
| 5085 | this_aArgMap = aArgMap ? aArgMap[i] : NULL; // Same. |
| 5086 | ArgStruct &this_new_arg = new_arg[i]; // Same. |
| 5087 | this_new_arg.postfix = NULL; // Set default early, for maintainability. |
| 5088 | |
| 5089 | // Determine whether this arg is ARG_TYPE_NORMAL or ARG_TYPE_OUTPUT_VAR. Blank args are |
| 5090 | // set to ARG_TYPE_NORMAL for maintainability, so ARG_TYPE_OUTPUT_VAR always has a non-null |
| 5091 | // var at runtime. ARG_TYPE_INPUT_VAR is never encountered at this stage; it is only used |
| 5092 | // by certain optimizations in ExpressionToPostfix(), which comes later. |
| 5093 | this_new_arg.type = *this_aArg ? Line::ArgIsVar(aActionType, i, aArgc) : ARG_TYPE_NORMAL; |
| 5094 | |
| 5095 | // All non-blank args are handled by ExpressionToPostfix, except where caller has indicated |
| 5096 | // this action type does not accept an expression (e.g. "goto label"). |
nothing calls this directly
no test coverage detected