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

Method PreparseCatchVar

source/script.cpp:7675–7709  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7673
7674
7675ResultType Script::PreparseCatchVar(Line *aLine)
7676{
7677 if (!aLine->mArgc)
7678 return OK;
7679 auto args = SimpleHeap::Alloc<CatchStatementArgs>();
7680 args->output_var = nullptr;
7681 args->prototype = nullptr;
7682 args->prototype_count = 0;
7683 aLine->mAttribute = args;
7684 LPTSTR cp = aLine->mArg->text + aLine->mArg->length;
7685 for (LPTSTR min_space_position = aLine->mArg->text + 2;;)
7686 {
7687 --cp;
7688 if (cp < min_space_position)
7689 return OK;
7690 if (IS_SPACE_OR_TAB(*cp))
7691 break;
7692 if (!IS_IDENTIFIER_CHAR(*cp))
7693 //return *cp == '.' ? OK : aLine->LineError(ERR_EXPR_SYNTAX);
7694 return OK; // Leave error reporting to PreparseCatchClass().
7695 }
7696 LPTSTR var_name = cp + 1;
7697 cp = omit_trailing_whitespace(aLine->mArg->text + 1, cp);
7698 if (ctolower(*cp) == 's' && ctolower(cp[-1]) == 'a' && (cp - 1 == aLine->mArg->text || IS_SPACE_OR_TAB(cp[-2])))
7699 {
7700 Var *var;
7701 if ( !(var = FindOrAddVar(var_name, 0, FINDVAR_FOR_WRITE))
7702 || !aLine->ValidateVarUsage(var, Script::VARREF_OUTPUT_VAR) )
7703 return FAIL;
7704 var->MarkAssignedSomewhere();
7705 args->output_var = var;
7706 aLine->mArg->length = ArgLengthType((cp - 1) - aLine->mArg->text);
7707 }
7708 return OK;
7709}
7710
7711
7712

Callers

nothing calls this directly

Calls 4

omit_trailing_whitespaceFunction · 0.85
ctolowerFunction · 0.85
ValidateVarUsageMethod · 0.80
MarkAssignedSomewhereMethod · 0.80

Tested by

no test coverage detected