MCPcopy Create free account
hub / github.com/AutoHotkey/AutoHotkey / PreparseExpressions

Method PreparseExpressions

source/script.cpp:7418–7456  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7416
7417
7418ResultType Script::PreparseExpressions(Line *aStartingLine)
7419{
7420 for (Line *line = aStartingLine; line; line = line->mNextLine) // For each line.
7421 {
7422 // Skip any function bodies.
7423 while (line->mActionType == ACT_BLOCK_BEGIN && line->mAttribute)
7424 if ( !(line = line->mRelatedLine) )
7425 return OK;
7426 if (line->mActionType == ACT_BLOCK_END && line->mAttribute)
7427 return OK; // End of this function.
7428
7429 mCurrLine = line; // For error reporting in FindVar() and perhaps other places.
7430
7431 if (line->mActionType == ACT_CATCH)
7432 {
7433 // Preparse Catch's output var at this stage so it has the proper assign-local effect.
7434 // Don't parse the class names yet since that might parse a given name as global when it
7435 // should be local due to a subsequent assignment. Delaying it ensures CATCH's classes
7436 // are always consistent with other references in the function, and ensures that adding
7437 // local classes in future won't necessitate a change in behaviour.
7438 if (!PreparseCatchVar(line))
7439 return FAIL;
7440 continue;
7441 }
7442
7443 for (int i = 0; i < line->mArgc; ++i) // For each arg.
7444 {
7445 ArgStruct &this_arg = line->mArg[i]; // For performance and convenience.
7446 if (!this_arg.is_expression) // Plain text; i.e. goto/break/continue label.
7447 continue;
7448 ASSERT(!this_arg.postfix);
7449 // Otherwise, convert the expression text to postfix form and set is_expression
7450 // based on whether the arg should be evaluated by ExpandExpression():
7451 if (!line->ExpressionToPostfix(this_arg)) // Doing this here, after the script has been loaded, might improve the compactness/adjacent-ness of the compiled expressions in memory, which might improve performance due to CPU caching.
7452 return FAIL; // The function above already displayed the error msg.
7453 }
7454 }
7455 return OK;
7456}
7457
7458
7459

Callers

nothing calls this directly

Calls 2

ExpressionToPostfixMethod · 0.80
IsBuiltInMethod · 0.45

Tested by

no test coverage detected