project
stringclasses
633 values
commit_id
stringlengths
7
81
target
int64
0
1
func
stringlengths
5
484k
cwe
stringclasses
131 values
big_vul_idx
float64
0
189k
idx
int64
0
522k
hash
stringlengths
34
39
size
float64
1
24k
message
stringlengths
0
11.5k
dataset
stringclasses
1 value
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
void Parser::SetNestedFuncEscapes() const { if (m_sourceContextInfo ? !PHASE_OFF_RAW(Js::DisableStackFuncOnDeferredEscapePhase, m_sourceContextInfo->sourceContextId, m_currentNodeFunc->sxFnc.functionId) : !PHASE_OFF1(Js::DisableStackFuncOnDeferredEscapePhase)) { m_currentNodeFunc->sxFnc.SetNestedFuncEscapes(); } }
CWE-119
null
517,474
224220791296553042297068775617416089052
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
void Parser::ParseImportClause(ModuleImportOrExportEntryList* importEntryList, bool parsingAfterComma) { bool parsedNamespaceOrNamedImport = false; switch (m_token.tk) { case tkID: // This is the default binding identifier. // If we already saw a comma in the import clause, this is a syntax error. if (parsingAfterComma) { Error(ERRsyntax); } if (buildAST) { IdentPtr localName = m_token.GetIdentifier(m_phtbl); IdentPtr importName = wellKnownPropertyPids._default; CreateModuleImportDeclNode(localName); AddModuleImportOrExportEntry(importEntryList, importName, localName, nullptr, nullptr); } break; case tkLCurly: // This begins a list of named imports. ParseNamedImportOrExportClause<buildAST>(importEntryList, false); parsedNamespaceOrNamedImport = true; break; case tkStar: // This begins a namespace import clause. // "* as ImportedBinding" // Token following * must be the identifier 'as' m_pscan->Scan(); if (m_token.tk != tkID || wellKnownPropertyPids.as != m_token.GetIdentifier(m_phtbl)) { Error(ERRsyntax); } // Token following 'as' must be a binding identifier. m_pscan->Scan(); ChkCurTokNoScan(tkID, ERRsyntax); if (buildAST) { IdentPtr localName = m_token.GetIdentifier(m_phtbl); IdentPtr importName = wellKnownPropertyPids._star; CreateModuleImportDeclNode(localName); AddModuleImportOrExportEntry(importEntryList, importName, localName, nullptr, nullptr); } parsedNamespaceOrNamedImport = true; break; default: Error(ERRsyntax); } m_pscan->Scan(); if (m_token.tk == tkComma) { // There cannot be more than one comma in a module import clause. // There cannot be a namespace import or named imports list on the left of the comma in a module import clause. if (parsingAfterComma || parsedNamespaceOrNamedImport) { Error(ERRsyntax); } m_pscan->Scan(); ParseImportClause<buildAST>(importEntryList, true); } }
CWE-119
null
517,475
61583565192861764316361781534746696051
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ParseNodePtr Parser::ParseSuper(ParseNodePtr pnode, bool fAllowCall) { ParseNodePtr currentNodeFunc = GetCurrentFunctionNode(); if (buildAST) { pnode = CreateNodeWithScanner<knopSuper>(); } m_pscan->ScanForcingPid(); switch (m_token.tk) { case tkDot: // super.prop case tkLBrack: // super[foo] case tkLParen: // super(args) break; default: Error(ERRInvalidSuper); break; } if (!fAllowCall && (m_token.tk == tkLParen)) { Error(ERRInvalidSuper); // new super() is not allowed } else if (this->m_parsingSuperRestrictionState == ParsingSuperRestrictionState_SuperCallAndPropertyAllowed) { // Any super access is good within a class constructor } else if (this->m_parsingSuperRestrictionState == ParsingSuperRestrictionState_SuperPropertyAllowed) { if (m_token.tk == tkLParen) { if ((this->m_grfscr & fscrEval) == fscrNil) { // Cannot call super within a class member Error(ERRInvalidSuper); } else { Js::JavascriptFunction * caller = nullptr; if (Js::JavascriptStackWalker::GetCaller(&caller, m_scriptContext)) { Js::FunctionBody * callerBody = caller->GetFunctionBody(); Assert(callerBody); if (!callerBody->GetFunctionInfo()->GetAllowDirectSuper()) { Error(ERRInvalidSuper); } } } } } else { // Anything else is an error Error(ERRInvalidSuper); } currentNodeFunc->sxFnc.SetHasSuperReference(TRUE); CHAKRATEL_LANGSTATS_INC_LANGFEATURECOUNT(Super, m_scriptContext); return pnode; }
CWE-119
null
517,476
177474028921974901269914685799028152696
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ParseNodePtr Parser::ParseTry() { ParseNodePtr pnode = nullptr; StmtNest stmt; Assert(tkTRY == m_token.tk); if (buildAST) { pnode = CreateNode(knopTry); } m_pscan->Scan(); if (tkLCurly != m_token.tk) { Error(ERRnoLcurly); } PushStmt<buildAST>(&stmt, pnode, knopTry, nullptr, nullptr); ParseNodePtr pnodeBody = ParseStatement<buildAST>(); if (buildAST) { pnode->sxTry.pnodeBody = pnodeBody; if (pnode->sxTry.pnodeBody) pnode->ichLim = pnode->sxTry.pnodeBody->ichLim; } PopStmt(&stmt); return pnode; }
CWE-119
null
517,477
336168989833755445370694046991130577570
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
void Parser::PopFuncBlockScope(ParseNodePtr *ppnodeScopeSave, ParseNodePtr *ppnodeExprScopeSave) { Assert(m_ppnodeExprScope == nullptr || *m_ppnodeExprScope == nullptr); m_ppnodeExprScope = ppnodeExprScopeSave; AssertMem(m_ppnodeScope); Assert(nullptr == *m_ppnodeScope); m_ppnodeScope = ppnodeScopeSave; }
CWE-119
null
517,478
47537829513805036486014531672603513948
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
void Parser::ValidateFormals() { ParseFncFormals<false>(nullptr, nullptr, fFncNoFlgs); // Eat the tkRParen. The ParseFncDeclHelper caller expects to see it. m_pscan->Scan(); }
CWE-119
null
517,479
31098626080988274400833497449332481984
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
BOOL Parser::DeferredParse(Js::LocalFunctionId functionId) { if ((m_grfscr & fscrDeferFncParse) != 0) { if (m_stoppedDeferredParse) { return false; } if (PHASE_OFF_RAW(Js::DeferParsePhase, m_sourceContextInfo->sourceContextId, functionId)) { return false; } if (PHASE_FORCE_RAW(Js::DeferParsePhase, m_sourceContextInfo->sourceContextId, functionId)) { return true; } #if ENABLE_PROFILE_INFO #ifndef DISABLE_DYNAMIC_PROFILE_DEFER_PARSE if (m_sourceContextInfo->sourceDynamicProfileManager != nullptr) { Js::ExecutionFlags flags = m_sourceContextInfo->sourceDynamicProfileManager->IsFunctionExecuted(functionId); return flags != Js::ExecutionFlags_Executed; } #endif #endif return true; } return false; }
CWE-119
null
517,480
317121926790633614968648359933421129942
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ParseNodePtr Parser::GenerateEmptyConstructor(bool extends) { ParseNodePtr pnodeFnc; // Create the node. pnodeFnc = CreateNode(knopFncDecl); pnodeFnc->sxFnc.ClearFlags(); pnodeFnc->sxFnc.SetNested(NULL != m_currentNodeFunc); pnodeFnc->sxFnc.SetStrictMode(); pnodeFnc->sxFnc.SetDeclaration(TRUE); pnodeFnc->sxFnc.SetIsMethod(TRUE); pnodeFnc->sxFnc.SetIsClassMember(TRUE); pnodeFnc->sxFnc.SetIsClassConstructor(TRUE); pnodeFnc->sxFnc.SetIsBaseClassConstructor(!extends); pnodeFnc->sxFnc.SetHasNonThisStmt(); pnodeFnc->sxFnc.SetIsGeneratedDefault(TRUE); pnodeFnc->ichLim = m_pscan->IchLimTok(); pnodeFnc->ichMin = m_pscan->IchMinTok(); pnodeFnc->sxFnc.cbLim = m_pscan->IecpLimTok(); pnodeFnc->sxFnc.cbMin = m_pscan->IecpMinTok(); pnodeFnc->sxFnc.astSize = 0; pnodeFnc->sxFnc.lineNumber = m_pscan->LineCur(); pnodeFnc->sxFnc.functionId = (*m_nextFunctionId); pnodeFnc->sxFnc.pid = nullptr; pnodeFnc->sxFnc.hint = nullptr; pnodeFnc->sxFnc.hintOffset = 0; pnodeFnc->sxFnc.hintLength = 0; pnodeFnc->sxFnc.isNameIdentifierRef = true; pnodeFnc->sxFnc.nestedFuncEscapes = false; pnodeFnc->sxFnc.pnodeName = nullptr; pnodeFnc->sxFnc.pnodeScopes = nullptr; pnodeFnc->sxFnc.pnodeParams = nullptr; pnodeFnc->sxFnc.pnodeVars = nullptr; pnodeFnc->sxFnc.pnodeBody = nullptr; pnodeFnc->sxFnc.nestedCount = 0; pnodeFnc->sxFnc.pnodeNext = nullptr; pnodeFnc->sxFnc.pnodeRest = nullptr; pnodeFnc->sxFnc.deferredStub = nullptr; pnodeFnc->sxFnc.funcInfo = nullptr; // In order to (re-)defer the default constructor, we need to, for instance, track // deferred class expression the way we track function expression, since we lose the part of the source // that tells us which we have. pnodeFnc->sxFnc.canBeDeferred = false; #ifdef DBG pnodeFnc->sxFnc.deferredParseNextFunctionId = *(this->m_nextFunctionId); #endif AppendFunctionToScopeList(true, pnodeFnc); if (m_nextFunctionId) { (*m_nextFunctionId)++; } // Update the count of functions nested in the current parent. if (m_pnestedCount) { (*m_pnestedCount)++; } if (!buildAST) { return NULL; } if (m_pscan->IchMinTok() >= m_pscan->IchMinLine()) { // In scenarios involving defer parse IchMinLine() can be incorrect for the first line after defer parse pnodeFnc->sxFnc.columnNumber = m_pscan->IchMinTok() - m_pscan->IchMinLine(); } else if (m_currentNodeFunc) { // For the first line after defer parse, compute the column relative to the column number // of the lexically parent function. ULONG offsetFromCurrentFunction = m_pscan->IchMinTok() - m_currentNodeFunc->ichMin; pnodeFnc->sxFnc.columnNumber = m_currentNodeFunc->sxFnc.columnNumber + offsetFromCurrentFunction; } else { // if there is no current function, lets give a default of 0. pnodeFnc->sxFnc.columnNumber = 0; } int32 * pAstSizeSave = m_pCurrentAstSize; m_pCurrentAstSize = &(pnodeFnc->sxFnc.astSize); // Make this the current function. ParseNodePtr pnodeFncSave = m_currentNodeFunc; m_currentNodeFunc = pnodeFnc; ParseNodePtr argsId = nullptr; ParseNodePtr *lastNodeRef = nullptr; ParseNodePtr pnodeBlock = StartParseBlock<buildAST>(PnodeBlockType::Parameter, ScopeType_Parameter); if (extends) { // constructor(...args) { super(...args); } // ^^^^^^^ ParseNodePtr *const ppnodeVarSave = m_ppnodeVar; m_ppnodeVar = &pnodeFnc->sxFnc.pnodeVars; IdentPtr pidargs = m_phtbl->PidHashNameLen(_u("args"), sizeof("args") - 1); ParseNodePtr pnodeT = CreateVarDeclNode(pidargs, STFormal); pnodeT->sxVar.sym->SetIsNonSimpleParameter(true); pnodeFnc->sxFnc.pnodeRest = pnodeT; PidRefStack *ref = this->PushPidRef(pidargs); argsId = CreateNameNode(pidargs, pnodeFnc->ichMin, pnodeFnc->ichLim); argsId->sxPid.symRef = ref->GetSymRef(); m_ppnodeVar = ppnodeVarSave; } ParseNodePtr pnodeInnerBlock = StartParseBlock<buildAST>(PnodeBlockType::Function, ScopeType_FunctionBody); pnodeBlock->sxBlock.pnodeScopes = pnodeInnerBlock; pnodeFnc->sxFnc.pnodeBodyScope = pnodeInnerBlock; pnodeFnc->sxFnc.pnodeScopes = pnodeBlock; if (extends) { // constructor(...args) { super(...args); } // ^^^^^^^^^^^^^^^ Assert(argsId); ParseNodePtr spreadArg = CreateUniNode(knopEllipsis, argsId, pnodeFnc->ichMin, pnodeFnc->ichLim); ParseNodePtr superRef = CreateNodeWithScanner<knopSuper>(); pnodeFnc->sxFnc.SetHasSuperReference(TRUE); ParseNodePtr callNode = CreateCallNode(knopCall, superRef, spreadArg); callNode->sxCall.spreadArgCount = 1; AddToNodeList(&pnodeFnc->sxFnc.pnodeBody, &lastNodeRef, callNode); } AddToNodeList(&pnodeFnc->sxFnc.pnodeBody, &lastNodeRef, CreateNodeWithScanner<knopEndCode>()); FinishParseBlock(pnodeInnerBlock); FinishParseBlock(pnodeBlock); m_currentNodeFunc = pnodeFncSave; m_pCurrentAstSize = pAstSizeSave; return pnodeFnc; }
CWE-119
null
517,481
104822226099016251281926757122616804855
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ParseNodePtr PnFnc::GetBodyScope() const { if (this->pnodeBodyScope == nullptr) { return nullptr; } Assert(this->pnodeBodyScope->nop == knopBlock && this->pnodeBodyScope->sxBlock.pnodeNext == nullptr); return this->pnodeBodyScope->sxBlock.pnodeScopes; }
CWE-119
null
517,482
307072074050536529241263630941909506048
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ParseNodePtr Parser::CreateCallNode(OpCode nop, ParseNodePtr pnode1, ParseNodePtr pnode2) { charcount_t ichMin; charcount_t ichLim; if (nullptr == pnode1) { Assert(nullptr == pnode2); ichMin = m_pscan->IchMinTok(); ichLim = m_pscan->IchLimTok(); } else { if (nullptr == pnode2) { ichMin = pnode1->ichMin; ichLim = pnode1->ichLim; } else { ichMin = pnode1->ichMin; ichLim = pnode2->ichLim; } if (pnode1->nop == knopDot || pnode1->nop == knopIndex) { this->CheckArguments(pnode1->sxBin.pnode1); } } return CreateCallNode(nop, pnode1, pnode2, ichMin, ichLim); }
CWE-119
null
517,483
16856729147461453848533636952040220992
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
Parser::MemberNameToTypeMap* Parser::CreateMemberNameMap(ArenaAllocator* pAllocator) { Assert(pAllocator); return Anew(pAllocator, MemberNameToTypeMap, pAllocator, 5); }
CWE-119
null
517,484
120159691143158456069712678283964319226
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
void Parser::DeferOrEmitPotentialSpreadError(ParseNodePtr pnodeT) { if (m_parenDepth > 0) { if (m_token.tk == tkRParen) { if (!m_deferEllipsisError) { // Capture only the first error instance. m_pscan->Capture(&m_EllipsisErrLoc); m_deferEllipsisError = true; } } else { Error(ERRUnexpectedEllipsis); } } else { Error(ERRInvalidSpreadUse); } }
CWE-119
null
517,485
117028878842811523810502912723011334011
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
Parser::~Parser(void) { if (m_scriptContext == nullptr || m_scriptContext->GetGuestArena() == nullptr) { // If the scriptContext or guestArena have gone away, there is no point clearing each item of this list. // Just reset it so that destructor of the SList will be no-op m_registeredRegexPatterns.Reset(); } if (this->m_hasParallelJob) { #if ENABLE_BACKGROUND_PARSING // Let the background threads know that they can decommit their arena pages. BackgroundParser *bgp = m_scriptContext->GetBackgroundParser(); Assert(bgp); if (bgp->Processor()->ProcessesInBackground()) { JsUtil::BackgroundJobProcessor *processor = static_cast<JsUtil::BackgroundJobProcessor*>(bgp->Processor()); bool result = processor->IterateBackgroundThreads([&](JsUtil::ParallelThreadData *threadData)->bool { threadData->canDecommit = true; return false; }); Assert(result); } #endif } Release(); }
CWE-119
null
517,486
282525132640669546220400294261500968411
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
HRESULT Parser::ParseCesu8Source(__out ParseNodePtr* parseTree, LPCUTF8 pSrc, size_t length, ULONG grfsrc, CompileScriptException *pse, Js::LocalFunctionId * nextFunctionId, SourceContextInfo * sourceContextInfo) { m_functionBody = nullptr; m_parseType = ParseType_Upfront; return ParseSourceInternal( parseTree, pSrc, 0, length, 0, false, grfsrc, pse, nextFunctionId, 0, sourceContextInfo); }
CWE-119
null
517,487
246383080641124343378301347648823124993
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
bool Parser::IsES6DestructuringEnabled() const { return m_scriptContext->GetConfig()->IsES6DestructuringEnabled(); }
CWE-119
null
517,488
257284146474935405144600890219106419226
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
template<bool buildAST> void Parser::ParseComputedName(ParseNodePtr* ppnodeName, LPCOLESTR* ppNameHint, LPCOLESTR* ppFullNameHint, uint32 *pNameLength, uint32 *pShortNameOffset) { m_pscan->Scan(); ParseNodePtr pnodeNameExpr = ParseExpr<buildAST>(koplCma, nullptr, TRUE, FALSE, *ppNameHint, pNameLength, pShortNameOffset); if (buildAST) { *ppnodeName = CreateNodeT<knopComputedName>(pnodeNameExpr->ichMin, pnodeNameExpr->ichLim); (*ppnodeName)->sxUni.pnode1 = pnodeNameExpr; } if (ppFullNameHint && buildAST && CONFIG_FLAG(UseFullName)) { *ppFullNameHint = FormatPropertyString(*ppNameHint, pnodeNameExpr, pNameLength, pShortNameOffset); } ChkCurTokNoScan(tkRBrack, ERRnoRbrack); }
CWE-119
null
517,489
40140880629670449026936334452892807473
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
void ParseNode::Dump() { switch(nop) { case knopFncDecl: case knopProg: LPCOLESTR name = Js::Constants::AnonymousFunction; if(this->sxFnc.pnodeName) { name = this->sxFnc.pnodeName->sxVar.pid->Psz(); } Output::Print(_u("%s (%d) [%d, %d]:\n"), name, this->sxFnc.functionId, this->sxFnc.lineNumber, this->sxFnc.columnNumber); Output::Print(_u("hasArguments: %s callsEval:%s childCallsEval:%s HasReferenceableBuiltInArguments:%s ArgumentsObjectEscapes:%s HasWith:%s HasThis:%s HasOnlyThis:%s \n"), IsTrueOrFalse(this->sxFnc.HasHeapArguments()), IsTrueOrFalse(this->sxFnc.CallsEval()), IsTrueOrFalse(this->sxFnc.ChildCallsEval()), IsTrueOrFalse(this->sxFnc.HasReferenceableBuiltInArguments()), IsTrueOrFalse(this->sxFnc.GetArgumentsObjectEscapes()), IsTrueOrFalse(this->sxFnc.HasWithStmt()), IsTrueOrFalse(this->sxFnc.HasThisStmt()), IsTrueOrFalse(this->sxFnc.HasOnlyThisStmts())); if(this->sxFnc.funcInfo) { this->sxFnc.funcInfo->Dump(); } break; } }
CWE-119
null
517,490
195411534923658945117733236593812693458
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ParseNodePtr Parser::PnodeLabel(IdentPtr pid, ParseNodePtr pnodeLabels) { AssertMem(pid); AssertNodeMemN(pnodeLabels); StmtNest *pstmt; ParseNodePtr pnodeT; // Look in the statement stack. for (pstmt = m_pstmtCur; nullptr != pstmt; pstmt = pstmt->pstmtOuter) { AssertNodeMem(pstmt->pnodeStmt); AssertNodeMemN(pstmt->pnodeLab); for (pnodeT = pstmt->pnodeLab; nullptr != pnodeT; pnodeT = pnodeT->sxLabel.pnodeNext) { Assert(knopLabel == pnodeT->nop); if (pid == pnodeT->sxLabel.pid) return pnodeT; } } // Also look in the pnodeLabels list. for (pnodeT = pnodeLabels; nullptr != pnodeT; pnodeT = pnodeT->sxLabel.pnodeNext) { Assert(knopLabel == pnodeT->nop); if (pid == pnodeT->sxLabel.pid) return pnodeT; } return nullptr; }
CWE-119
null
517,491
272478058902123540999864215681620635860
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ParseNodePtr Parser::ParseDestructuredLiteral(tokens declarationType, bool isDecl, bool topLevel/* = true*/, DestructuringInitializerContext initializerContext/* = DIC_None*/, bool allowIn/* = true*/, BOOL *forInOfOkay/* = nullptr*/, BOOL *nativeForOkay/* = nullptr*/) { ParseNodePtr pnode = nullptr; Assert(IsPossiblePatternStart()); if (m_token.tk == tkLCurly) { pnode = ParseDestructuredObjectLiteral<buildAST>(declarationType, isDecl, topLevel); } else { pnode = ParseDestructuredArrayLiteral<buildAST>(declarationType, isDecl, topLevel); } return ParseDestructuredInitializer<buildAST>(pnode, isDecl, topLevel, initializerContext, allowIn, forInOfOkay, nativeForOkay); }
CWE-119
null
517,492
123393843705246868906347255608966581202
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ParseNodePtr Parser::ParseVariableDeclaration( tokens declarationType, charcount_t ichMin, BOOL fAllowIn/* = TRUE*/, BOOL* pfForInOk/* = nullptr*/, BOOL singleDefOnly/* = FALSE*/, BOOL allowInit/* = TRUE*/, BOOL isTopVarParse/* = TRUE*/, BOOL isFor/* = FALSE*/, BOOL* nativeForOk /*= nullptr*/) { ParseNodePtr pnodeThis = nullptr; ParseNodePtr pnodeInit; ParseNodePtr pnodeList = nullptr; ParseNodePtr *lastNodeRef = nullptr; LPCOLESTR pNameHint = nullptr; uint32 nameHintLength = 0; uint32 nameHintOffset = 0; Assert(declarationType == tkVAR || declarationType == tkCONST || declarationType == tkLET); for (;;) { if (IsES6DestructuringEnabled() && IsPossiblePatternStart()) { pnodeThis = ParseDestructuredLiteral<buildAST>(declarationType, true, !!isTopVarParse, DIC_None, !!fAllowIn, pfForInOk, nativeForOk); if (pnodeThis != nullptr) { pnodeThis->ichMin = ichMin; } } else { if (m_token.tk != tkID) { IdentifierExpectedError(m_token); } IdentPtr pid = m_token.GetIdentifier(m_phtbl); Assert(pid); pNameHint = pid->Psz(); nameHintLength = pid->Cch(); nameHintOffset = 0; if (pid == wellKnownPropertyPids.let && (declarationType == tkCONST || declarationType == tkLET)) { Error(ERRLetIDInLexicalDecl, pnodeThis); } if (declarationType == tkVAR) { pnodeThis = CreateVarDeclNode(pid, STVariable); } else if (declarationType == tkCONST) { pnodeThis = CreateBlockScopedDeclNode(pid, knopConstDecl); CHAKRATEL_LANGSTATS_INC_LANGFEATURECOUNT(Const, m_scriptContext); } else { pnodeThis = CreateBlockScopedDeclNode(pid, knopLetDecl); CHAKRATEL_LANGSTATS_INC_LANGFEATURECOUNT(Let, m_scriptContext); } if (pid == wellKnownPropertyPids.arguments && m_currentNodeFunc) { // This var declaration may change the way an 'arguments' identifier in the function is resolved if (declarationType == tkVAR) { m_currentNodeFunc->grfpn |= PNodeFlags::fpnArguments_varDeclaration; } else { if (GetCurrentBlockInfo()->pnodeBlock->sxBlock.blockType == Function) { // Only override arguments if we are at the function block level. m_currentNodeFunc->grfpn |= PNodeFlags::fpnArguments_overriddenByDecl; } } } if (pnodeThis) { pnodeThis->ichMin = ichMin; } m_pscan->Scan(); if (m_token.tk == tkAsg) { if (!allowInit) { Error(ERRUnexpectedDefault); } if (pfForInOk && (declarationType == tkLET || declarationType == tkCONST || IsStrictMode())) { *pfForInOk = FALSE; } m_pscan->Scan(); pnodeInit = ParseExpr<buildAST>(koplCma, nullptr, fAllowIn, FALSE, pNameHint, &nameHintLength, &nameHintOffset); if (buildAST) { AnalysisAssert(pnodeThis); pnodeThis->sxVar.pnodeInit = pnodeInit; pnodeThis->ichLim = pnodeInit->ichLim; if (pnodeInit->nop == knopFncDecl) { Assert(nameHintLength >= nameHintOffset); pnodeInit->sxFnc.hint = pNameHint; pnodeInit->sxFnc.hintLength = nameHintLength; pnodeInit->sxFnc.hintOffset = nameHintOffset; pnodeThis->sxVar.pid->GetTopRef()->isFuncAssignment = true; } else { this->CheckArguments(pnodeInit); } pNameHint = nullptr; } //Track var a =, let a= , const a = // This is for FixedFields Constant Heuristics if (pnodeThis && pnodeThis->sxVar.pnodeInit != nullptr) { pnodeThis->sxVar.sym->PromoteAssignmentState(); if (m_currentNodeFunc && pnodeThis->sxVar.sym->GetIsFormal()) { m_currentNodeFunc->sxFnc.SetHasAnyWriteToFormals(true); } } } else if (declarationType == tkCONST /*pnodeThis->nop == knopConstDecl*/ && !singleDefOnly && !(isFor && TokIsForInOrForOf())) { Error(ERRUninitializedConst); } } if (singleDefOnly) { return pnodeThis; } if (buildAST) { AddToNodeListEscapedUse(&pnodeList, &lastNodeRef, pnodeThis); } if (m_token.tk != tkComma) { return pnodeList; } if (pfForInOk) { // don't allow "for (var a, b in c)" *pfForInOk = FALSE; } m_pscan->Scan(); ichMin = m_pscan->IchMinTok(); } }
CWE-119
null
517,493
173696219013840999306492012480133105696
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
bool PnBlock::HasBlockScopedContent() const { // A block has its own content if a let, const, or function is declared there. if (this->pnodeLexVars != nullptr || this->blockType == Parameter) { return true; } // The enclosing scopes can contain functions and other things, so walk the list // looking specifically for functions. for (ParseNodePtr pnode = this->pnodeScopes; pnode;) { switch (pnode->nop) { case knopFncDecl: return true; case knopBlock: pnode = pnode->sxBlock.pnodeNext; break; case knopCatch: pnode = pnode->sxCatch.pnodeNext; break; case knopWith: pnode = pnode->sxWith.pnodeNext; break; default: Assert(UNREACHED); return true; } } return false; }
CWE-119
null
517,494
336318161412808883577001935653058642232
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ParseNodePtr Parser::GetRightSideNodeFromPattern(ParseNodePtr pnode) { Assert(pnode != nullptr); ParseNodePtr rightNode = nullptr; OpCode op = pnode->nop; if (op == knopObject) { rightNode = ConvertObjectToObjectPattern(pnode); } else if (op == knopArray) { rightNode = ConvertArrayToArrayPattern(pnode); } else { rightNode = pnode; if (op == knopName) { TrackAssignment<true>(pnode, nullptr); } } return rightNode; }
CWE-119
null
517,495
290132031277158397778939016395837016145
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
void Parser::Error(HRESULT hr, charcount_t ichMin, charcount_t ichLim) { m_pscan->SetErrorPosition(ichMin, ichLim); Error(hr); }
CWE-119
null
517,496
101908797271900833926106720196872877552
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
BOOL Parser::NodeIsEvalName(ParseNodePtr pnode) { //WOOB 1107758 Special case of indirect eval binds to local scope in standards mode return pnode->nop == knopName && (pnode->sxPid.pid == wellKnownPropertyPids.eval); }
CWE-119
null
517,497
178272053304425554362919587356346827454
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
BOOL Parser::IsDeferredFnc() { if (m_grfscr & fscrDeferredFnc) { m_grfscr &= ~fscrDeferredFnc; return true; } return false; }
CWE-119
null
517,498
203585893409116672160604501031271029737
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
void Parser::FinishDeferredFunction(ParseNodePtr pnodeScopeList) { VisitFunctionsInScope(pnodeScopeList, [this](ParseNodePtr pnodeFnc) { Assert(pnodeFnc->nop == knopFncDecl); // Non-simple params (such as default) require a good amount of logic to put vars on appriopriate scopes. ParseFncDecl handles it // properly (both on defer and non-defer case). This is to avoid write duplicated logic here as well. Function with non-simple-param // will remain deferred untill they are called. if (pnodeFnc->sxFnc.pnodeBody == nullptr && !pnodeFnc->sxFnc.HasNonSimpleParameterList()) { // Go back and generate an AST for this function. JS_ETW_INTERNAL(EventWriteJSCRIPT_PARSE_FUNC(this->GetScriptContext(), pnodeFnc->sxFnc.functionId, /*Undefer*/TRUE)); ParseNodePtr pnodeFncSave = this->m_currentNodeFunc; this->m_currentNodeFunc = pnodeFnc; ParseNodePtr pnodeFncExprBlock = nullptr; if (pnodeFnc->sxFnc.pnodeName && !pnodeFnc->sxFnc.IsDeclaration()) { // Set up the named function expression symbol so references inside the function can be bound. ParseNodePtr pnodeName = pnodeFnc->sxFnc.pnodeName; Assert(pnodeName->nop == knopVarDecl); Assert(pnodeName->sxVar.pnodeNext == nullptr); pnodeFncExprBlock = this->StartParseBlock<true>(PnodeBlockType::Function, ScopeType_FuncExpr); PidRefStack *ref = this->PushPidRef(pnodeName->sxVar.pid); pnodeName->sxVar.symRef = ref->GetSymRef(); ref->SetSym(pnodeName->sxVar.sym); Scope *fncExprScope = pnodeFncExprBlock->sxBlock.scope; fncExprScope->AddNewSymbol(pnodeName->sxVar.sym); pnodeFnc->sxFnc.scope = fncExprScope; } ParseNodePtr pnodeBlock = this->StartParseBlock<true>(PnodeBlockType::Parameter, ScopeType_Parameter); pnodeFnc->sxFnc.pnodeScopes = pnodeBlock; m_ppnodeScope = &pnodeBlock->sxBlock.pnodeScopes; pnodeBlock->sxBlock.pnodeStmt = pnodeFnc; // Add the args to the scope, since we won't re-parse those. Scope *scope = pnodeBlock->sxBlock.scope; auto addArgsToScope = [&](ParseNodePtr pnodeArg) { if (pnodeArg->IsVarLetOrConst()) { PidRefStack *ref = this->PushPidRef(pnodeArg->sxVar.pid); pnodeArg->sxVar.symRef = ref->GetSymRef(); if (ref->GetSym() != nullptr) { // Duplicate parameter in a configuration that allows them. // The symbol is already in the scope, just point it to the right declaration. Assert(ref->GetSym() == pnodeArg->sxVar.sym); ref->GetSym()->SetDecl(pnodeArg); } else { ref->SetSym(pnodeArg->sxVar.sym); scope->AddNewSymbol(pnodeArg->sxVar.sym); } } }; MapFormals(pnodeFnc, addArgsToScope); MapFormalsFromPattern(pnodeFnc, addArgsToScope); ParseNodePtr pnodeInnerBlock = this->StartParseBlock<true>(PnodeBlockType::Function, ScopeType_FunctionBody); pnodeFnc->sxFnc.pnodeBodyScope = pnodeInnerBlock; // Set the parameter block's child to the function body block. *m_ppnodeScope = pnodeInnerBlock; ParseNodePtr *ppnodeScopeSave = nullptr; ParseNodePtr *ppnodeExprScopeSave = nullptr; ppnodeScopeSave = m_ppnodeScope; // This synthetic block scope will contain all the nested scopes. m_ppnodeScope = &pnodeInnerBlock->sxBlock.pnodeScopes; pnodeInnerBlock->sxBlock.pnodeStmt = pnodeFnc; // Keep nested function declarations and expressions in the same list at function scope. // (Indicate this by nulling out the current function expressions list.) ppnodeExprScopeSave = m_ppnodeExprScope; m_ppnodeExprScope = nullptr; // Shouldn't be any temps in the arg list. Assert(*m_ppnodeVar == nullptr); // Start the var list. pnodeFnc->sxFnc.pnodeVars = nullptr; m_ppnodeVar = &pnodeFnc->sxFnc.pnodeVars; if (scope != nullptr && !pnodeFnc->sxFnc.IsAsync()) { if (scope->GetCanMergeWithBodyScope()) { scope->ForEachSymbol([this](Symbol* paramSym) { PidRefStack* ref = PushPidRef(paramSym->GetPid()); ref->SetSym(paramSym); }); } else { OUTPUT_TRACE_DEBUGONLY(Js::ParsePhase, _u("The param and body scope of the function %s cannot be merged\n"), pnodeFnc->sxFnc.pnodeName ? pnodeFnc->sxFnc.pnodeName->sxVar.pid->Psz() : _u("Anonymous function")); // Add a new symbol reference for each formal in the param scope to the body scope. scope->ForEachSymbol([this](Symbol* param) { OUTPUT_TRACE_DEBUGONLY(Js::ParsePhase, _u("Creating a duplicate symbol for the parameter %s in the body scope\n"), param->GetPid()->Psz()); ParseNodePtr paramNode = this->CreateVarDeclNode(param->GetPid(), STVariable, false, nullptr, false); Assert(paramNode && paramNode->sxVar.sym->GetScope()->GetScopeType() == ScopeType_FunctionBody); paramNode->sxVar.sym->SetHasInit(true); }); } } Assert(m_currentNodeNonLambdaFunc == nullptr); m_currentNodeNonLambdaFunc = pnodeFnc; this->FinishFncNode(pnodeFnc); Assert(pnodeFnc == m_currentNodeNonLambdaFunc); m_currentNodeNonLambdaFunc = nullptr; m_ppnodeExprScope = ppnodeExprScopeSave; AssertMem(m_ppnodeScope); Assert(nullptr == *m_ppnodeScope); m_ppnodeScope = ppnodeScopeSave; this->FinishParseBlock(pnodeInnerBlock); this->AddArgumentsNodeToVars(pnodeFnc); this->FinishParseBlock(pnodeBlock); if (pnodeFncExprBlock) { this->FinishParseBlock(pnodeFncExprBlock); } this->m_currentNodeFunc = pnodeFncSave; } }); }
CWE-119
null
517,499
25984058328850564029430861992728829082
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
void Parser::OutOfMemory() { throw ParseExceptionObject(ERRnoMemory); }
CWE-119
null
517,500
152456570242437671954329160595618400056
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
HRESULT Parser::ParseUtf8Source(__out ParseNodePtr* parseTree, LPCUTF8 pSrc, size_t length, ULONG grfsrc, CompileScriptException *pse, Js::LocalFunctionId * nextFunctionId, SourceContextInfo * sourceContextInfo) { m_functionBody = nullptr; m_parseType = ParseType_Upfront; return ParseSourceInternal( parseTree, pSrc, 0, length, 0, true, grfsrc, pse, nextFunctionId, 0, sourceContextInfo); }
CWE-119
null
517,501
110868938946575614720579132492735301551
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ParseNodePtr Parser::CreateUniNode(OpCode nop, ParseNodePtr pnode1, charcount_t ichMin,charcount_t ichLim) { Assert(!this->m_deferringAST); DebugOnly(VerifyNodeSize(nop, kcbPnUni)); ParseNodePtr pnode = (ParseNodePtr)m_nodeAllocator.Alloc(kcbPnUni); Assert(m_pCurrentAstSize != NULL); *m_pCurrentAstSize += kcbPnUni; InitNode(nop, pnode); pnode->sxUni.pnode1 = pnode1; pnode->ichMin = ichMin; pnode->ichLim = ichLim; return pnode; }
CWE-119
null
517,502
34547131078315662364491974559780296499
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ParseNodePtr Parser::ConvertMemberToMemberPattern(ParseNodePtr pnodeMember) { if (pnodeMember->nop == knopObjectPatternMember) { return pnodeMember; } Assert(pnodeMember->nop == knopMember || pnodeMember->nop == knopMemberShort); ParseNodePtr rightNode = GetRightSideNodeFromPattern(pnodeMember->sxBin.pnode2); ParseNodePtr resultNode = CreateBinNode(knopObjectPatternMember, pnodeMember->sxBin.pnode1, rightNode); resultNode->ichMin = pnodeMember->ichMin; resultNode->ichLim = pnodeMember->ichLim; return resultNode; }
CWE-119
null
517,503
22834973503180784158827173458205832253
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ParseNodePtr Parser::ConvertToPattern(ParseNodePtr pnode) { if (pnode != nullptr) { if (pnode->nop == knopArray) { ConvertArrayToArrayPattern(pnode); } else if (pnode->nop == knopObject) { pnode = ConvertObjectToObjectPattern(pnode); } } return pnode; }
CWE-119
null
517,504
426825671854301080896285366818481658
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
bool Parser::IsCurBlockInLoop() const { for (StmtNest *stmt = this->m_pstmtCur; stmt != nullptr; stmt = stmt->pstmtOuter) { OpCode nop = stmt->GetNop(); if (ParseNode::Grfnop(nop) & fnopContinue) { return true; } if (nop == knopFncDecl) { return false; } } return false; }
CWE-119
null
517,505
29454927713701830336486231491384374181
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ParseNodePtr Parser::ParseDestructuredObjectLiteral(tokens declarationType, bool isDecl, bool topLevel/* = true*/) { Assert(m_token.tk == tkLCurly); charcount_t ichMin = m_pscan->IchMinTok(); m_pscan->Scan(); if (!isDecl) { declarationType = tkLCurly; } ParseNodePtr pnodeMemberList = ParseMemberList<buildAST>(nullptr/*pNameHint*/, nullptr/*pHintLength*/, declarationType); Assert(m_token.tk == tkRCurly); ParseNodePtr objectPatternNode = nullptr; if (buildAST) { charcount_t ichLim = m_pscan->IchLimTok(); objectPatternNode = CreateUniNode(knopObjectPattern, pnodeMemberList, ichMin, ichLim); } return objectPatternNode; }
CWE-119
null
517,506
278047476201003260739256164847813032511
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
void Parser::AppendFunctionToScopeList(bool fDeclaration, ParseNodePtr pnodeFnc) { if (!fDeclaration && m_ppnodeExprScope) { // We're tracking function expressions separately from declarations in this scope // (e.g., inside a catch scope in standards mode). Assert(*m_ppnodeExprScope == nullptr); *m_ppnodeExprScope = pnodeFnc; m_ppnodeExprScope = &pnodeFnc->sxFnc.pnodeNext; } else { Assert(*m_ppnodeScope == nullptr); *m_ppnodeScope = pnodeFnc; m_ppnodeScope = &pnodeFnc->sxFnc.pnodeNext; } }
CWE-119
null
517,507
104317296939678619462583193666097197727
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ModuleImportOrExportEntry* Parser::AddModuleImportOrExportEntry(ModuleImportOrExportEntryList* importOrExportEntryList, ModuleImportOrExportEntry* importOrExportEntry) { if (importOrExportEntry->exportName != nullptr) { CheckForDuplicateExportEntry(importOrExportEntryList, importOrExportEntry->exportName); } importOrExportEntryList->Prepend(*importOrExportEntry); return importOrExportEntry; }
CWE-119
null
517,508
223051026406324536107048847521075035110
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
void PrintPnodeListWIndent(ParseNode *pnode,int indentAmt) { if (pnode!=NULL) { while(pnode->nop==knopList) { PrintPnodeWIndent(pnode->sxBin.pnode1,indentAmt); pnode = pnode->sxBin.pnode2; } PrintPnodeWIndent(pnode,indentAmt); } }
CWE-119
null
517,509
277582299512264400740490561076739303060
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
void Parser::RestorePidRefForSym(Symbol *sym) { IdentPtr pid = m_pscan->m_phtbl->PidHashNameLen(sym->GetName().GetBuffer(), sym->GetName().GetLength()); Assert(pid); sym->SetPid(pid); PidRefStack *ref = this->PushPidRef(pid); ref->SetSym(sym); }
CWE-119
null
517,510
190702657464596063966573813954736926091
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
void Parser::RestoreScopeInfo(Js::ParseableFunctionInfo* functionBody) { if (!functionBody) { return; } Js::ScopeInfo* scopeInfo = functionBody->GetScopeInfo(); if (!scopeInfo) { return; } if (this->IsBackgroundParser()) { PROBE_STACK_NO_DISPOSE(m_scriptContext, Js::Constants::MinStackByteCodeVisitor); } else { PROBE_STACK(m_scriptContext, Js::Constants::MinStackByteCodeVisitor); } RestoreScopeInfo(scopeInfo->GetParent()); // Recursively restore outer func scope info Js::ScopeInfo* funcExprScopeInfo = scopeInfo->GetFuncExprScopeInfo(); if (funcExprScopeInfo) { funcExprScopeInfo->SetScopeId(m_nextBlockId); ParseNodePtr pnodeFncExprScope = StartParseBlockWithCapacity<true>(PnodeBlockType::Function, ScopeType_FuncExpr, funcExprScopeInfo->GetSymbolCount()); Scope *scope = pnodeFncExprScope->sxBlock.scope; funcExprScopeInfo->GetScopeInfo(this, nullptr, nullptr, scope); } Js::ScopeInfo* paramScopeInfo = scopeInfo->GetParamScopeInfo(); if (paramScopeInfo) { paramScopeInfo->SetScopeId(m_nextBlockId); ParseNodePtr pnodeFncExprScope = StartParseBlockWithCapacity<true>(PnodeBlockType::Parameter, ScopeType_Parameter, paramScopeInfo->GetSymbolCount()); Scope *scope = pnodeFncExprScope->sxBlock.scope; paramScopeInfo->GetScopeInfo(this, nullptr, nullptr, scope); } scopeInfo->SetScopeId(m_nextBlockId); ParseNodePtr pnodeFncScope = nullptr; if (scopeInfo->IsGlobalEval()) { pnodeFncScope = StartParseBlockWithCapacity<true>(PnodeBlockType::Regular, ScopeType_GlobalEvalBlock, scopeInfo->GetSymbolCount()); } else { pnodeFncScope = StartParseBlockWithCapacity<true>(PnodeBlockType::Function, ScopeType_FunctionBody, scopeInfo->GetSymbolCount()); } Scope *scope = pnodeFncScope->sxBlock.scope; scopeInfo->GetScopeInfo(this, nullptr, nullptr, scope); }
CWE-119
null
517,511
268762905823484721949312340953799223051
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
HRESULT Parser::ParseSourceInternal( __out ParseNodePtr* parseTree, LPCUTF8 pszSrc, size_t offsetInBytes, size_t encodedCharCount, charcount_t offsetInChars, bool fromExternal, ULONG grfscr, CompileScriptException *pse, Js::LocalFunctionId * nextFunctionId, ULONG lineNumber, SourceContextInfo * sourceContextInfo) { AssertMem(parseTree); AssertPsz(pszSrc); AssertMemN(pse); if (this->IsBackgroundParser()) { PROBE_STACK_NO_DISPOSE(m_scriptContext, Js::Constants::MinStackDefault); } else { PROBE_STACK(m_scriptContext, Js::Constants::MinStackDefault); } #ifdef PROFILE_EXEC m_scriptContext->ProfileBegin(Js::ParsePhase); #endif JS_ETW_INTERNAL(EventWriteJSCRIPT_PARSE_START(m_scriptContext,0)); *parseTree = NULL; m_sourceLim = 0; m_grfscr = grfscr; m_sourceContextInfo = sourceContextInfo; ParseNodePtr pnodeBase = NULL; HRESULT hr; SmartFPUControl smartFpuControl; DebugOnly( m_err.fInited = TRUE; ) try { this->PrepareScanner(fromExternal); if ((grfscr & fscrEvalCode) != 0) { this->m_parsingSuperRestrictionState = Parser::ParsingSuperRestrictionState_SuperPropertyAllowed; } if ((grfscr & fscrIsModuleCode) != 0) { // Module source flag should not be enabled unless module is enabled Assert(m_scriptContext->GetConfig()->IsES6ModuleEnabled()); // Module code is always strict mode code. this->m_fUseStrictMode = TRUE; } // parse the source pnodeBase = Parse(pszSrc, offsetInBytes, encodedCharCount, offsetInChars, grfscr, lineNumber, nextFunctionId, pse); AssertNodeMem(pnodeBase); // Record the actual number of words parsed. m_sourceLim = pnodeBase->ichLim - offsetInChars; // TODO: The assert can be false positive in some scenarios and chuckj to fix it later // Assert(utf8::ByteIndexIntoCharacterIndex(pszSrc + offsetInBytes, encodedCharCount, fromExternal ? utf8::doDefault : utf8::doAllowThreeByteSurrogates) == m_sourceLim); #if DBG_DUMP if (Js::Configuration::Global.flags.Trace.IsEnabled(Js::ParsePhase)) { PrintPnodeWIndent(pnodeBase,4); fflush(stdout); } #endif *parseTree = pnodeBase; hr = NOERROR; } catch(ParseExceptionObject& e) { m_err.m_hr = e.GetError(); hr = pse->ProcessError( m_pscan, m_err.m_hr, pnodeBase); } if (this->m_hasParallelJob) { #if ENABLE_BACKGROUND_PARSING ///// Wait here for remaining jobs to finish. Then look for errors, do final const bindings. // pleath TODO: If there are remaining jobs, let the main thread help finish them. BackgroundParser *bgp = m_scriptContext->GetBackgroundParser(); Assert(bgp); CompileScriptException se; this->WaitForBackgroundJobs(bgp, &se); BackgroundParseItem *failedItem = bgp->GetFailedBackgroundParseItem(); if (failedItem) { CompileScriptException *bgPse = failedItem->GetPSE(); Assert(bgPse); *pse = *bgPse; hr = failedItem->GetHR(); bgp->SetFailedBackgroundParseItem(nullptr); } if (this->fastScannedRegExpNodes != nullptr) { this->FinishBackgroundRegExpNodes(); } for (BackgroundParseItem *item = this->backgroundParseItems; item; item = item->GetNext()) { Parser *parser = item->GetParser(); parser->FinishBackgroundPidRefs(item, this != parser); } #endif } // done with the scanner RELEASEPTR(m_pscan); #ifdef PROFILE_EXEC m_scriptContext->ProfileEnd(Js::ParsePhase); #endif JS_ETW_INTERNAL(EventWriteJSCRIPT_PARSE_STOP(m_scriptContext, 0)); return hr; }
CWE-119
null
517,512
160084190074378654367805440653328259633
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ParseNodePtr Parser::CreateNodeT(charcount_t ichMin,charcount_t ichLim) { Assert(!this->m_deferringAST); ParseNodePtr pnode = StaticCreateNodeT<nop>(&m_nodeAllocator, ichMin, ichLim); Assert(m_pCurrentAstSize != NULL); *m_pCurrentAstSize += GetNodeSize<nop>(); return pnode; }
CWE-119
null
517,513
163425013351372252164798857499493163264
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ModuleImportOrExportEntryList* Parser::EnsureModuleLocalExportEntryList() { if (m_currentNodeProg->sxModule.localExportEntries == nullptr) { m_currentNodeProg->sxModule.localExportEntries = Anew(&m_nodeAllocator, ModuleImportOrExportEntryList, &m_nodeAllocator); } return m_currentNodeProg->sxModule.localExportEntries; }
CWE-119
null
517,514
54000766599219842669149298819336869125
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
void Parser::AddModuleSpecifier(IdentPtr moduleRequest) { IdentPtrList* requestedModulesList = EnsureRequestedModulesList(); if (!requestedModulesList->Has(moduleRequest)) { requestedModulesList->Prepend(moduleRequest); } }
CWE-119
null
517,515
204270082900389308474462044736650809070
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ParseNodePtr Parser::ConvertArrayToArrayPattern(ParseNodePtr pnode) { Assert(pnode->nop == knopArray); pnode->nop = knopArrayPattern; ForEachItemRefInList(&pnode->sxArrLit.pnode1, [&](ParseNodePtr *itemRef) { ParseNodePtr item = *itemRef; if (item->nop == knopEllipsis) { itemRef = &item->sxUni.pnode1; item = *itemRef; if (!(item->nop == knopName || item->nop == knopDot || item->nop == knopIndex || item->nop == knopArray || item->nop == knopObject)) { Error(ERRInvalidAssignmentTarget); } } else if (item->nop == knopAsg) { itemRef = &item->sxBin.pnode1; item = *itemRef; } if (item->nop == knopArray) { ConvertArrayToArrayPattern(item); } else if (item->nop == knopObject) { *itemRef = ConvertObjectToObjectPattern(item); } else if (item->nop == knopName) { TrackAssignment<true>(item, nullptr); } }); return pnode; }
CWE-119
null
517,516
326086856928238421583950342954006049928
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
void PrintPnodeWIndent(ParseNode *pnode,int indentAmt) { if (pnode==NULL) return; Output::Print(_u("[%4d, %4d): "), pnode->ichMin, pnode->ichLim); switch (pnode->nop) { //PTNODE(knopName , "name" ,None ,Pid ,fnopLeaf) case knopName: Indent(indentAmt); if (pnode->sxPid.pid!=NULL) { Output::Print(_u("id: %s\n"),pnode->sxPid.pid->Psz()); } else { Output::Print(_u("name node\n")); } break; //PTNODE(knopInt , "int const" ,None ,Int ,fnopLeaf|fnopConst) case knopInt: Indent(indentAmt); Output::Print(_u("%d\n"),pnode->sxInt.lw); break; //PTNODE(knopFlt , "flt const" ,None ,Flt ,fnopLeaf|fnopConst) case knopFlt: Indent(indentAmt); Output::Print(_u("%lf\n"),pnode->sxFlt.dbl); break; //PTNODE(knopStr , "str const" ,None ,Pid ,fnopLeaf|fnopConst) case knopStr: Indent(indentAmt); Output::Print(_u("\"%s\"\n"),pnode->sxPid.pid->Psz()); break; //PTNODE(knopRegExp , "reg expr" ,None ,Pid ,fnopLeaf|fnopConst) case knopRegExp: Indent(indentAmt); Output::Print(_u("/%x/\n"),pnode->sxPid.regexPattern); break; //PTNODE(knopThis , "this" ,None ,None ,fnopLeaf) case knopThis: Indent(indentAmt); Output::Print(_u("this\n")); break; //PTNODE(knopSuper , "super" ,None ,None ,fnopLeaf) case knopSuper: Indent(indentAmt); Output::Print(_u("super\n")); break; //PTNODE(knopNewTarget , "new.target" ,None ,None ,fnopLeaf) case knopNewTarget: Indent(indentAmt); Output::Print(_u("new.target\n")); break; //PTNODE(knopNull , "null" ,Null ,None ,fnopLeaf) case knopNull: Indent(indentAmt); Output::Print(_u("null\n")); break; //PTNODE(knopFalse , "false" ,False ,None ,fnopLeaf) case knopFalse: Indent(indentAmt); Output::Print(_u("false\n")); break; //PTNODE(knopTrue , "true" ,True ,None ,fnopLeaf) case knopTrue: Indent(indentAmt); Output::Print(_u("true\n")); break; //PTNODE(knopEmpty , "empty" ,Empty ,None ,fnopLeaf) case knopEmpty: Indent(indentAmt); Output::Print(_u("empty\n")); break; // Unary operators. //PTNODE(knopNot , "~" ,BitNot ,Uni ,fnopUni) case knopNot: Indent(indentAmt); Output::Print(_u("~\n")); PrintPnodeWIndent(pnode->sxUni.pnode1,indentAmt+INDENT_SIZE); break; //PTNODE(knopNeg , "unary -" ,Neg ,Uni ,fnopUni) case knopNeg: Indent(indentAmt); Output::Print(_u("U-\n")); PrintPnodeWIndent(pnode->sxUni.pnode1,indentAmt+INDENT_SIZE); break; //PTNODE(knopPos , "unary +" ,Pos ,Uni ,fnopUni) case knopPos: Indent(indentAmt); Output::Print(_u("U+\n")); PrintPnodeWIndent(pnode->sxUni.pnode1,indentAmt+INDENT_SIZE); break; //PTNODE(knopLogNot , "!" ,LogNot ,Uni ,fnopUni) case knopLogNot: Indent(indentAmt); Output::Print(_u("!\n")); PrintPnodeWIndent(pnode->sxUni.pnode1,indentAmt+INDENT_SIZE); break; //PTNODE(knopEllipsis , "..." ,Spread ,Uni , fnopUni) case knopEllipsis: Indent(indentAmt); Output::Print(_u("...<expr>\n")); PrintPnodeWIndent(pnode->sxUni.pnode1,indentAmt+INDENT_SIZE); break; //PTNODE(knopIncPost , "++ post" ,Inc ,Uni ,fnopUni|fnopAsg) case knopIncPost: Indent(indentAmt); Output::Print(_u("<expr>++\n")); PrintPnodeWIndent(pnode->sxUni.pnode1,indentAmt+INDENT_SIZE); break; //PTNODE(knopDecPost , "-- post" ,Dec ,Uni ,fnopUni|fnopAsg) case knopDecPost: Indent(indentAmt); Output::Print(_u("<expr>--\n")); PrintPnodeWIndent(pnode->sxUni.pnode1,indentAmt+INDENT_SIZE); break; //PTNODE(knopIncPre , "++ pre" ,Inc ,Uni ,fnopUni|fnopAsg) case knopIncPre: Indent(indentAmt); Output::Print(_u("++<expr>\n")); PrintPnodeWIndent(pnode->sxUni.pnode1,indentAmt+INDENT_SIZE); break; //PTNODE(knopDecPre , "-- pre" ,Dec ,Uni ,fnopUni|fnopAsg) case knopDecPre: Indent(indentAmt); Output::Print(_u("--<expr>\n")); PrintPnodeWIndent(pnode->sxUni.pnode1,indentAmt+INDENT_SIZE); break; //PTNODE(knopTypeof , "typeof" ,None ,Uni ,fnopUni) case knopTypeof: Indent(indentAmt); Output::Print(_u("typeof\n")); PrintPnodeWIndent(pnode->sxUni.pnode1,indentAmt+INDENT_SIZE); break; //PTNODE(knopVoid , "void" ,Void ,Uni ,fnopUni) case knopVoid: Indent(indentAmt); Output::Print(_u("void\n")); PrintPnodeWIndent(pnode->sxUni.pnode1,indentAmt+INDENT_SIZE); break; //PTNODE(knopDelete , "delete" ,None ,Uni ,fnopUni) case knopDelete: Indent(indentAmt); Output::Print(_u("delete\n")); PrintPnodeWIndent(pnode->sxUni.pnode1,indentAmt+INDENT_SIZE); break; //PTNODE(knopArray , "arr cnst" ,None ,Uni ,fnopUni) case knopArrayPattern: Indent(indentAmt); Output::Print(_u("Array Pattern\n")); PrintPnodeListWIndent(pnode->sxUni.pnode1, indentAmt + INDENT_SIZE); break; case knopObjectPattern: Indent(indentAmt); Output::Print(_u("Object Pattern\n")); PrintPnodeListWIndent(pnode->sxUni.pnode1, indentAmt + INDENT_SIZE); break; case knopArray: Indent(indentAmt); Output::Print(_u("Array Literal\n")); PrintPnodeListWIndent(pnode->sxUni.pnode1,indentAmt+INDENT_SIZE); break; //PTNODE(knopObject , "obj cnst" ,None ,Uni ,fnopUni) case knopObject: Indent(indentAmt); Output::Print(_u("Object Literal\n")); PrintPnodeListWIndent(pnode->sxUni.pnode1,indentAmt+INDENT_SIZE); break; // Binary and Ternary Operators //PTNODE(knopAdd , "+" ,Add ,Bin ,fnopBin) case knopAdd: Indent(indentAmt); Output::Print(_u("+\n")); PrintPnodeWIndent(pnode->sxBin.pnode1,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxBin.pnode2,indentAmt+INDENT_SIZE); break; //PTNODE(knopSub , "-" ,Sub ,Bin ,fnopBin) case knopSub: Indent(indentAmt); Output::Print(_u("-\n")); PrintPnodeWIndent(pnode->sxBin.pnode1,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxBin.pnode2,indentAmt+INDENT_SIZE); break; //PTNODE(knopMul , "*" ,Mul ,Bin ,fnopBin) case knopMul: Indent(indentAmt); Output::Print(_u("*\n")); PrintPnodeWIndent(pnode->sxBin.pnode1,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxBin.pnode2,indentAmt+INDENT_SIZE); break; //PTNODE(knopDiv , "/" ,Div ,Bin ,fnopBin) case knopExpo: Indent(indentAmt); Output::Print(_u("**\n")); PrintPnodeWIndent(pnode->sxBin.pnode1, indentAmt + INDENT_SIZE); PrintPnodeWIndent(pnode->sxBin.pnode2, indentAmt + INDENT_SIZE); break; //PTNODE(knopExpo , "**" ,Expo ,Bin ,fnopBin) case knopDiv: Indent(indentAmt); Output::Print(_u("/\n")); PrintPnodeWIndent(pnode->sxBin.pnode1,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxBin.pnode2,indentAmt+INDENT_SIZE); break; //PTNODE(knopMod , "%" ,Mod ,Bin ,fnopBin) case knopMod: Indent(indentAmt); Output::Print(_u("%\n")); PrintPnodeWIndent(pnode->sxBin.pnode1,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxBin.pnode2,indentAmt+INDENT_SIZE); break; //PTNODE(knopOr , "|" ,BitOr ,Bin ,fnopBin) case knopOr: Indent(indentAmt); Output::Print(_u("|\n")); PrintPnodeWIndent(pnode->sxBin.pnode1,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxBin.pnode2,indentAmt+INDENT_SIZE); break; //PTNODE(knopXor , "^" ,BitXor ,Bin ,fnopBin) case knopXor: Indent(indentAmt); Output::Print(_u("^\n")); PrintPnodeWIndent(pnode->sxBin.pnode1,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxBin.pnode2,indentAmt+INDENT_SIZE); break; //PTNODE(knopAnd , "&" ,BitAnd ,Bin ,fnopBin) case knopAnd: Indent(indentAmt); Output::Print(_u("&\n")); PrintPnodeWIndent(pnode->sxBin.pnode1,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxBin.pnode2,indentAmt+INDENT_SIZE); break; //PTNODE(knopEq , "==" ,EQ ,Bin ,fnopBin|fnopRel) case knopEq: Indent(indentAmt); Output::Print(_u("==\n")); PrintPnodeWIndent(pnode->sxBin.pnode1,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxBin.pnode2,indentAmt+INDENT_SIZE); break; //PTNODE(knopNe , "!=" ,NE ,Bin ,fnopBin|fnopRel) case knopNe: Indent(indentAmt); Output::Print(_u("!=\n")); PrintPnodeWIndent(pnode->sxBin.pnode1,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxBin.pnode2,indentAmt+INDENT_SIZE); break; //PTNODE(knopLt , "<" ,LT ,Bin ,fnopBin|fnopRel) case knopLt: Indent(indentAmt); Output::Print(_u("<\n")); PrintPnodeWIndent(pnode->sxBin.pnode1,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxBin.pnode2,indentAmt+INDENT_SIZE); break; //PTNODE(knopLe , "<=" ,LE ,Bin ,fnopBin|fnopRel) case knopLe: Indent(indentAmt); Output::Print(_u("<=\n")); PrintPnodeWIndent(pnode->sxBin.pnode1,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxBin.pnode2,indentAmt+INDENT_SIZE); break; //PTNODE(knopGe , ">=" ,GE ,Bin ,fnopBin|fnopRel) case knopGe: Indent(indentAmt); Output::Print(_u(">=\n")); PrintPnodeWIndent(pnode->sxBin.pnode1,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxBin.pnode2,indentAmt+INDENT_SIZE); break; //PTNODE(knopGt , ">" ,GT ,Bin ,fnopBin|fnopRel) case knopGt: Indent(indentAmt); Output::Print(_u(">\n")); PrintPnodeWIndent(pnode->sxBin.pnode1,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxBin.pnode2,indentAmt+INDENT_SIZE); break; //PTNODE(knopCall , "()" ,None ,Bin ,fnopBin) case knopCall: Indent(indentAmt); Output::Print(_u("Call\n")); PrintPnodeWIndent(pnode->sxBin.pnode1,indentAmt+INDENT_SIZE); PrintPnodeListWIndent(pnode->sxBin.pnode2,indentAmt+INDENT_SIZE); break; //PTNODE(knopDot , "." ,None ,Bin ,fnopBin) case knopDot: Indent(indentAmt); Output::Print(_u(".\n")); PrintPnodeWIndent(pnode->sxBin.pnode1,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxBin.pnode2,indentAmt+INDENT_SIZE); break; //PTNODE(knopAsg , "=" ,None ,Bin ,fnopBin|fnopAsg) case knopAsg: Indent(indentAmt); Output::Print(_u("=\n")); PrintPnodeWIndent(pnode->sxBin.pnode1,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxBin.pnode2,indentAmt+INDENT_SIZE); break; //PTNODE(knopInstOf , "instanceof",InstOf ,Bin ,fnopBin|fnopRel) case knopInstOf: Indent(indentAmt); Output::Print(_u("instanceof\n")); PrintPnodeWIndent(pnode->sxBin.pnode1,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxBin.pnode2,indentAmt+INDENT_SIZE); break; //PTNODE(knopIn , "in" ,In ,Bin ,fnopBin|fnopRel) case knopIn: Indent(indentAmt); Output::Print(_u("in\n")); PrintPnodeWIndent(pnode->sxBin.pnode1,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxBin.pnode2,indentAmt+INDENT_SIZE); break; //PTNODE(knopEqv , "===" ,Eqv ,Bin ,fnopBin|fnopRel) case knopEqv: Indent(indentAmt); Output::Print(_u("===\n")); PrintPnodeWIndent(pnode->sxBin.pnode1,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxBin.pnode2,indentAmt+INDENT_SIZE); break; //PTNODE(knopNEqv , "!==" ,NEqv ,Bin ,fnopBin|fnopRel) case knopNEqv: Indent(indentAmt); Output::Print(_u("!==\n")); PrintPnodeWIndent(pnode->sxBin.pnode1,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxBin.pnode2,indentAmt+INDENT_SIZE); break; //PTNODE(knopComma , "," ,None ,Bin ,fnopBin) case knopComma: Indent(indentAmt); Output::Print(_u(",\n")); PrintPnodeWIndent(pnode->sxBin.pnode1,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxBin.pnode2,indentAmt+INDENT_SIZE); break; //PTNODE(knopLogOr , "||" ,None ,Bin ,fnopBin) case knopLogOr: Indent(indentAmt); Output::Print(_u("||\n")); PrintPnodeWIndent(pnode->sxBin.pnode1,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxBin.pnode2,indentAmt+INDENT_SIZE); break; //PTNODE(knopLogAnd , "&&" ,None ,Bin ,fnopBin) case knopLogAnd: Indent(indentAmt); Output::Print(_u("&&\n")); PrintPnodeWIndent(pnode->sxBin.pnode1,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxBin.pnode2,indentAmt+INDENT_SIZE); break; //PTNODE(knopLsh , "<<" ,Lsh ,Bin ,fnopBin) case knopLsh: Indent(indentAmt); Output::Print(_u("<<\n")); PrintPnodeWIndent(pnode->sxBin.pnode1,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxBin.pnode2,indentAmt+INDENT_SIZE); break; //PTNODE(knopRsh , ">>" ,Rsh ,Bin ,fnopBin) case knopRsh: Indent(indentAmt); Output::Print(_u(">>\n")); PrintPnodeWIndent(pnode->sxBin.pnode1,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxBin.pnode2,indentAmt+INDENT_SIZE); break; //PTNODE(knopRs2 , ">>>" ,Rs2 ,Bin ,fnopBin) case knopRs2: Indent(indentAmt); Output::Print(_u(">>>\n")); PrintPnodeWIndent(pnode->sxBin.pnode1,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxBin.pnode2,indentAmt+INDENT_SIZE); break; //PTNODE(knopNew , "new" ,None ,Bin ,fnopBin) case knopNew: Indent(indentAmt); Output::Print(_u("new\n")); PrintPnodeWIndent(pnode->sxBin.pnode1,indentAmt+INDENT_SIZE); PrintPnodeListWIndent(pnode->sxBin.pnode2,indentAmt+INDENT_SIZE); break; //PTNODE(knopIndex , "[]" ,None ,Bin ,fnopBin) case knopIndex: Indent(indentAmt); Output::Print(_u("[]\n")); PrintPnodeWIndent(pnode->sxBin.pnode1,indentAmt+INDENT_SIZE); PrintPnodeListWIndent(pnode->sxBin.pnode2,indentAmt+INDENT_SIZE); break; //PTNODE(knopQmark , "?" ,None ,Tri ,fnopBin) case knopQmark: Indent(indentAmt); Output::Print(_u("?:\n")); PrintPnodeWIndent(pnode->sxTri.pnode1,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxTri.pnode2,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxTri.pnode3,indentAmt+INDENT_SIZE); break; //PTNODE(knopAsgAdd , "+=" ,Add ,Bin ,fnopBin|fnopAsg) case knopAsgAdd: Indent(indentAmt); Output::Print(_u("+=\n")); PrintPnodeWIndent(pnode->sxBin.pnode1,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxBin.pnode2,indentAmt+INDENT_SIZE); break; //PTNODE(knopAsgSub , "-=" ,Sub ,Bin ,fnopBin|fnopAsg) case knopAsgSub: Indent(indentAmt); Output::Print(_u("-=\n")); PrintPnodeWIndent(pnode->sxBin.pnode1,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxBin.pnode2,indentAmt+INDENT_SIZE); break; //PTNODE(knopAsgMul , "*=" ,Mul ,Bin ,fnopBin|fnopAsg) case knopAsgMul: Indent(indentAmt); Output::Print(_u("*=\n")); PrintPnodeWIndent(pnode->sxBin.pnode1,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxBin.pnode2,indentAmt+INDENT_SIZE); break; //PTNODE(knopAsgDiv , "/=" ,Div ,Bin ,fnopBin|fnopAsg) case knopAsgExpo: Indent(indentAmt); Output::Print(_u("**=\n")); PrintPnodeWIndent(pnode->sxBin.pnode1, indentAmt + INDENT_SIZE); PrintPnodeWIndent(pnode->sxBin.pnode2, indentAmt + INDENT_SIZE); break; //PTNODE(knopAsgExpo , "**=" ,Expo ,Bin ,fnopBin|fnopAsg) case knopAsgDiv: Indent(indentAmt); Output::Print(_u("/=\n")); PrintPnodeWIndent(pnode->sxBin.pnode1,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxBin.pnode2,indentAmt+INDENT_SIZE); break; //PTNODE(knopAsgMod , "%=" ,Mod ,Bin ,fnopBin|fnopAsg) case knopAsgMod: Indent(indentAmt); Output::Print(_u("%=\n")); PrintPnodeWIndent(pnode->sxBin.pnode1,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxBin.pnode2,indentAmt+INDENT_SIZE); break; //PTNODE(knopAsgAnd , "&=" ,BitAnd ,Bin ,fnopBin|fnopAsg) case knopAsgAnd: Indent(indentAmt); Output::Print(_u("&=\n")); PrintPnodeWIndent(pnode->sxBin.pnode1,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxBin.pnode2,indentAmt+INDENT_SIZE); break; //PTNODE(knopAsgXor , "^=" ,BitXor ,Bin ,fnopBin|fnopAsg) case knopAsgXor: Indent(indentAmt); Output::Print(_u("^=\n")); PrintPnodeWIndent(pnode->sxBin.pnode1,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxBin.pnode2,indentAmt+INDENT_SIZE); break; //PTNODE(knopAsgOr , "|=" ,BitOr ,Bin ,fnopBin|fnopAsg) case knopAsgOr: Indent(indentAmt); Output::Print(_u("|=\n")); PrintPnodeWIndent(pnode->sxBin.pnode1,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxBin.pnode2,indentAmt+INDENT_SIZE); break; //PTNODE(knopAsgLsh , "<<=" ,Lsh ,Bin ,fnopBin|fnopAsg) case knopAsgLsh: Indent(indentAmt); Output::Print(_u("<<=\n")); PrintPnodeWIndent(pnode->sxBin.pnode1,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxBin.pnode2,indentAmt+INDENT_SIZE); break; //PTNODE(knopAsgRsh , ">>=" ,Rsh ,Bin ,fnopBin|fnopAsg) case knopAsgRsh: Indent(indentAmt); Output::Print(_u(">>=\n")); PrintPnodeWIndent(pnode->sxBin.pnode1,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxBin.pnode2,indentAmt+INDENT_SIZE); break; //PTNODE(knopAsgRs2 , ">>>=" ,Rs2 ,Bin ,fnopBin|fnopAsg) case knopAsgRs2: Indent(indentAmt); Output::Print(_u(">>>=\n")); PrintPnodeWIndent(pnode->sxBin.pnode1,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxBin.pnode2,indentAmt+INDENT_SIZE); break; case knopComputedName: Indent(indentAmt); Output::Print(_u("ComputedProperty\n")); PrintPnodeWIndent(pnode->sxUni.pnode1, indentAmt + INDENT_SIZE); break; //PTNODE(knopMember , ":" ,None ,Bin ,fnopBin) case knopMember: case knopMemberShort: case knopObjectPatternMember: Indent(indentAmt); Output::Print(_u(":\n")); PrintPnodeWIndent(pnode->sxBin.pnode1,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxBin.pnode2,indentAmt+INDENT_SIZE); break; // General nodes. //PTNODE(knopList , "<list>" ,None ,Bin ,fnopNone) case knopList: Indent(indentAmt); Output::Print(_u("List\n")); PrintPnodeListWIndent(pnode,indentAmt+INDENT_SIZE); break; //PTNODE(knopVarDecl , "varDcl" ,None ,Var ,fnopNone) case knopVarDecl: Indent(indentAmt); Output::Print(_u("var %s\n"),pnode->sxVar.pid->Psz()); if (pnode->sxVar.pnodeInit!=NULL) PrintPnodeWIndent(pnode->sxVar.pnodeInit,indentAmt+INDENT_SIZE); break; case knopConstDecl: Indent(indentAmt); Output::Print(_u("const %s\n"),pnode->sxVar.pid->Psz()); if (pnode->sxVar.pnodeInit!=NULL) PrintPnodeWIndent(pnode->sxVar.pnodeInit,indentAmt+INDENT_SIZE); break; case knopLetDecl: Indent(indentAmt); Output::Print(_u("let %s\n"),pnode->sxVar.pid->Psz()); if (pnode->sxVar.pnodeInit!=NULL) PrintPnodeWIndent(pnode->sxVar.pnodeInit,indentAmt+INDENT_SIZE); break; //PTNODE(knopFncDecl , "fncDcl" ,None ,Fnc ,fnopLeaf) case knopFncDecl: Indent(indentAmt); if (pnode->sxFnc.pid!=NULL) { Output::Print(_u("fn decl %d nested %d name %s (%d-%d)\n"),pnode->sxFnc.IsDeclaration(),pnode->sxFnc.IsNested(), pnode->sxFnc.pid->Psz(), pnode->ichMin, pnode->ichLim); } else { Output::Print(_u("fn decl %d nested %d anonymous (%d-%d)\n"),pnode->sxFnc.IsDeclaration(),pnode->sxFnc.IsNested(),pnode->ichMin,pnode->ichLim); } PrintScopesWIndent(pnode, indentAmt+INDENT_SIZE); PrintFormalsWIndent(pnode->sxFnc.pnodeParams, indentAmt + INDENT_SIZE); PrintPnodeWIndent(pnode->sxFnc.pnodeRest, indentAmt + INDENT_SIZE); PrintPnodeWIndent(pnode->sxFnc.pnodeBody, indentAmt + INDENT_SIZE); if (pnode->sxFnc.pnodeBody == nullptr) { Output::Print(_u("[%4d, %4d): "), pnode->ichMin, pnode->ichLim); Indent(indentAmt + INDENT_SIZE); Output::Print(_u("<parse deferred body>\n")); } break; //PTNODE(knopProg , "program" ,None ,Fnc ,fnopNone) case knopProg: Indent(indentAmt); Output::Print(_u("program\n")); PrintScopesWIndent(pnode, indentAmt+INDENT_SIZE); PrintPnodeListWIndent(pnode->sxFnc.pnodeBody,indentAmt+INDENT_SIZE); break; //PTNODE(knopEndCode , "<endcode>" ,None ,None ,fnopNone) case knopEndCode: Indent(indentAmt); Output::Print(_u("<endcode>\n")); break; //PTNODE(knopDebugger , "debugger" ,None ,None ,fnopNone) case knopDebugger: Indent(indentAmt); Output::Print(_u("<debugger>\n")); break; //PTNODE(knopFor , "for" ,None ,For ,fnopBreak|fnopContinue) case knopFor: Indent(indentAmt); Output::Print(_u("for\n")); PrintScopesWIndent(pnode, indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxFor.pnodeInit,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxFor.pnodeCond,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxFor.pnodeIncr,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxFor.pnodeBody,indentAmt+INDENT_SIZE); break; //PTNODE(knopIf , "if" ,None ,If ,fnopNone) case knopIf: Indent(indentAmt); Output::Print(_u("if\n")); PrintPnodeWIndent(pnode->sxIf.pnodeCond,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxIf.pnodeTrue,indentAmt+INDENT_SIZE); if (pnode->sxIf.pnodeFalse!=NULL) PrintPnodeWIndent(pnode->sxIf.pnodeFalse,indentAmt+INDENT_SIZE); break; //PTNODE(knopWhile , "while" ,None ,While,fnopBreak|fnopContinue) case knopWhile: Indent(indentAmt); Output::Print(_u("while\n")); PrintPnodeWIndent(pnode->sxWhile.pnodeCond,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxWhile.pnodeBody,indentAmt+INDENT_SIZE); break; //PTNODE(knopDoWhile , "do-while" ,None ,While,fnopBreak|fnopContinue) case knopDoWhile: Indent(indentAmt); Output::Print(_u("do\n")); PrintPnodeWIndent(pnode->sxWhile.pnodeCond,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxWhile.pnodeBody,indentAmt+INDENT_SIZE); break; //PTNODE(knopForIn , "for in" ,None ,ForIn,fnopBreak|fnopContinue|fnopCleanup) case knopForIn: Indent(indentAmt); Output::Print(_u("forIn\n")); PrintScopesWIndent(pnode, indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxForInOrForOf.pnodeLval,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxForInOrForOf.pnodeObj,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxForInOrForOf.pnodeBody,indentAmt+INDENT_SIZE); break; case knopForOf: Indent(indentAmt); Output::Print(_u("forOf\n")); PrintScopesWIndent(pnode, indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxForInOrForOf.pnodeLval,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxForInOrForOf.pnodeObj,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxForInOrForOf.pnodeBody,indentAmt+INDENT_SIZE); break; //PTNODE(knopReturn , "return" ,None ,Uni ,fnopNone) case knopReturn: Indent(indentAmt); Output::Print(_u("return\n")); if (pnode->sxReturn.pnodeExpr!=NULL) PrintPnodeWIndent(pnode->sxReturn.pnodeExpr,indentAmt+INDENT_SIZE); break; //PTNODE(knopBlock , "{}" ,None ,Block,fnopNone) case knopBlock: Indent(indentAmt); Output::Print(_u("block ")); if (pnode->grfpn & fpnSyntheticNode) Output::Print(_u("synthetic ")); PrintBlockType(pnode->sxBlock.blockType); Output::Print(_u("(%d-%d)\n"),pnode->ichMin,pnode->ichLim); PrintScopesWIndent(pnode, indentAmt+INDENT_SIZE); if (pnode->sxBlock.pnodeStmt!=NULL) PrintPnodeWIndent(pnode->sxBlock.pnodeStmt,indentAmt+INDENT_SIZE); break; //PTNODE(knopWith , "with" ,None ,With ,fnopCleanup) case knopWith: Indent(indentAmt); Output::Print(_u("with (%d-%d)\n"), pnode->ichMin,pnode->ichLim); PrintScopesWIndent(pnode, indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxWith.pnodeObj,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxWith.pnodeBody,indentAmt+INDENT_SIZE); break; //PTNODE(knopBreak , "break" ,None ,Jump ,fnopNone) case knopBreak: Indent(indentAmt); Output::Print(_u("break\n")); // TODO: some representation of target break; //PTNODE(knopContinue , "continue" ,None ,Jump ,fnopNone) case knopContinue: Indent(indentAmt); Output::Print(_u("continue\n")); // TODO: some representation of target break; //PTNODE(knopLabel , "label" ,None ,Label,fnopNone) case knopLabel: Indent(indentAmt); Output::Print(_u("label %s"),pnode->sxLabel.pid->Psz()); // TODO: print labeled statement break; //PTNODE(knopSwitch , "switch" ,None ,Switch,fnopBreak) case knopSwitch: Indent(indentAmt); Output::Print(_u("switch\n")); PrintScopesWIndent(pnode, indentAmt+INDENT_SIZE); for (ParseNode *pnodeT = pnode->sxSwitch.pnodeCases; NULL != pnodeT;pnodeT = pnodeT->sxCase.pnodeNext) { PrintPnodeWIndent(pnodeT,indentAmt+2); } break; //PTNODE(knopCase , "case" ,None ,Case ,fnopNone) case knopCase: Indent(indentAmt); Output::Print(_u("case\n")); PrintPnodeWIndent(pnode->sxCase.pnodeExpr,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxCase.pnodeBody,indentAmt+INDENT_SIZE); break; //PTNODE(knopTryFinally,"try-finally",None,TryFinally,fnopCleanup) case knopTryFinally: PrintPnodeWIndent(pnode->sxTryFinally.pnodeTry,indentAmt); PrintPnodeWIndent(pnode->sxTryFinally.pnodeFinally,indentAmt); break; case knopFinally: Indent(indentAmt); Output::Print(_u("finally\n")); PrintPnodeWIndent(pnode->sxFinally.pnodeBody,indentAmt+INDENT_SIZE); break; //PTNODE(knopCatch , "catch" ,None ,Catch,fnopNone) case knopCatch: Indent(indentAmt); Output::Print(_u("catch (%d-%d)\n"), pnode->ichMin,pnode->ichLim); PrintScopesWIndent(pnode, indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxCatch.pnodeParam,indentAmt+INDENT_SIZE); // if (pnode->sxCatch.pnodeGuard!=NULL) // PrintPnodeWIndent(pnode->sxCatch.pnodeGuard,indentAmt+INDENT_SIZE); PrintPnodeWIndent(pnode->sxCatch.pnodeBody,indentAmt+INDENT_SIZE); break; //PTNODE(knopTryCatch , "try-catch" ,None ,TryCatch ,fnopCleanup) case knopTryCatch: PrintPnodeWIndent(pnode->sxTryCatch.pnodeTry,indentAmt); PrintPnodeWIndent(pnode->sxTryCatch.pnodeCatch,indentAmt); break; //PTNODE(knopTry , "try" ,None ,Try ,fnopCleanup) case knopTry: Indent(indentAmt); Output::Print(_u("try\n")); PrintPnodeWIndent(pnode->sxTry.pnodeBody,indentAmt+INDENT_SIZE); break; //PTNODE(knopThrow , "throw" ,None ,Uni ,fnopNone) case knopThrow: Indent(indentAmt); Output::Print(_u("throw\n")); PrintPnodeWIndent(pnode->sxUni.pnode1,indentAmt+INDENT_SIZE); break; //PTNODE(knopClassDecl, "classDecl", None , Class, fnopLeaf) case knopClassDecl: Indent(indentAmt); Output::Print(_u("class %s"), pnode->sxClass.pnodeName->sxVar.pid->Psz()); if (pnode->sxClass.pnodeExtends != nullptr) { Output::Print(_u(" extends ")); PrintPnodeWIndent(pnode->sxClass.pnodeExtends, 0); } else { Output::Print(_u("\n")); } PrintPnodeWIndent(pnode->sxClass.pnodeConstructor, indentAmt + INDENT_SIZE); PrintPnodeWIndent(pnode->sxClass.pnodeMembers, indentAmt + INDENT_SIZE); PrintPnodeWIndent(pnode->sxClass.pnodeStaticMembers, indentAmt + INDENT_SIZE); break; case knopStrTemplate: Indent(indentAmt); Output::Print(_u("string template\n")); PrintPnodeListWIndent(pnode->sxStrTemplate.pnodeSubstitutionExpressions, indentAmt + INDENT_SIZE); break; case knopYieldStar: Indent(indentAmt); Output::Print(_u("yield*\n")); PrintPnodeListWIndent(pnode->sxUni.pnode1, indentAmt + INDENT_SIZE); break; case knopYield: case knopYieldLeaf: Indent(indentAmt); Output::Print(_u("yield\n")); PrintPnodeListWIndent(pnode->sxUni.pnode1, indentAmt + INDENT_SIZE); break; case knopAwait: Indent(indentAmt); Output::Print(_u("await\n")); PrintPnodeListWIndent(pnode->sxUni.pnode1, indentAmt + INDENT_SIZE); break; case knopExportDefault: Indent(indentAmt); Output::Print(_u("export default\n")); PrintPnodeListWIndent(pnode->sxExportDefault.pnodeExpr, indentAmt + INDENT_SIZE); break; default: Output::Print(_u("unhandled pnode op %d\n"),pnode->nop); break; } }
CWE-119
null
517,517
1240979234497265879669577418921135081
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
void Parser::AddFastScannedRegExpNode(ParseNodePtr const pnode) { Assert(!IsBackgroundParser()); Assert(m_doingFastScan); if (fastScannedRegExpNodes == nullptr) { fastScannedRegExpNodes = Anew(&m_nodeAllocator, NodeDList, &m_nodeAllocator); } fastScannedRegExpNodes->Append(pnode); }
CWE-119
null
517,518
303061525772293750262214131948744761903
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
LPCOLESTR Parser::FormatPropertyString(LPCOLESTR propertyString, ParseNodePtr pNode, uint32 *fullNameHintLength, uint32 *pShortNameOffset) { // propertyString could be null, such as 'this.foo' = // propertyString could be empty, found in pattern as in (-1)[""][(x = z)] OpCode op = pNode->nop; LPCOLESTR rightNode = nullptr; if (propertyString == nullptr) { propertyString = _u(""); } if (op != knopInt && op != knopFlt && op != knopName && op != knopStr) { rightNode = _u(""); } else if (op == knopStr) { return AppendNameHints(propertyString, pNode->sxPid.pid, fullNameHintLength, pShortNameOffset, false, true/*add brackets*/); } else if(op == knopFlt) { rightNode = m_pscan->StringFromDbl(pNode->sxFlt.dbl); } else { rightNode = op == knopInt ? m_pscan->StringFromLong(pNode->sxInt.lw) : pNode->sxPid.pid->Psz(); } return AppendNameHints(propertyString, rightNode, fullNameHintLength, pShortNameOffset, false, true/*add brackets*/); }
CWE-119
null
517,519
188854259239950493295646768367972004912
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ParseNodePtr Parser::ParseArgList( bool *pCallOfConstants, uint16 *pSpreadArgCount, uint16 * pCount) { ParseNodePtr pnodeArg; ParseNodePtr pnodeList = nullptr; ParseNodePtr *lastNodeRef = nullptr; // Check for an empty list Assert(m_token.tk == tkLParen); if (m_pscan->Scan() == tkRParen) { return nullptr; } *pCallOfConstants = true; *pSpreadArgCount = 0; int count=0; while (true) { // the count of arguments has to fit in an unsigned short if (count > 0xffffU) Error(ERRnoMemory); // Allow spread in argument lists. IdentToken token; pnodeArg = ParseExpr<buildAST>(koplCma, nullptr, TRUE, /* fAllowEllipsis */TRUE, NULL, nullptr, nullptr, &token); ++count; this->MarkEscapingRef(pnodeArg, &token); if (buildAST) { this->CheckArguments(pnodeArg); if (*pCallOfConstants && !IsConstantInFunctionCall(pnodeArg)) { *pCallOfConstants = false; } if (pnodeArg->nop == knopEllipsis) { (*pSpreadArgCount)++; } AddToNodeListEscapedUse(&pnodeList, &lastNodeRef, pnodeArg); } if (m_token.tk != tkComma) { break; } m_pscan->Scan(); if (m_token.tk == tkRParen && m_scriptContext->GetConfig()->IsES7TrailingCommaEnabled()) { break; } } if (pSpreadArgCount!=nullptr && (*pSpreadArgCount) > 0){ CHAKRATEL_LANGSTATS_INC_LANGFEATURECOUNT(SpreadFeature, m_scriptContext); } *pCount = static_cast<uint16>(count); if (buildAST) { AssertMem(lastNodeRef); AssertNodeMem(*lastNodeRef); pnodeList->ichLim = (*lastNodeRef)->ichLim; } return pnodeList; }
CWE-119
null
517,520
99766065967938912266458580629742778623
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
void Parser::FinishBackgroundPidRefs(BackgroundParseItem *item, bool isOtherParser) { for (BlockInfoStack *blockInfo = item->GetParseContext()->currentBlockInfo; blockInfo; blockInfo = blockInfo->pBlockInfoOuter) { if (isOtherParser) { this->BindPidRefs<true>(blockInfo, item->GetMaxBlockId()); } else { this->BindPidRefs<false>(blockInfo, item->GetMaxBlockId()); } } }
CWE-119
null
517,521
308100530354429601605711081911350783246
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
void VerifyNodeSize(OpCode nop, int size) { Assert(nop >= 0 && nop < knopLim); __analysis_assume(nop < knopLim); Assert(g_mpnopcbNode[nop] == size); }
CWE-119
null
517,522
24418252398740050331780298323064090087
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
uint Parser::CalculateFunctionColumnNumber() { uint columnNumber; if (m_pscan->IchMinTok() >= m_pscan->IchMinLine()) { // In scenarios involving defer parse IchMinLine() can be incorrect for the first line after defer parse columnNumber = m_pscan->IchMinTok() - m_pscan->IchMinLine(); if (m_functionBody != nullptr && m_functionBody->GetRelativeLineNumber() == m_pscan->LineCur()) { // Adjust the column if it falls on the first line, where the re-parse is happening. columnNumber += m_functionBody->GetRelativeColumnNumber(); } } else if (m_currentNodeFunc) { // For the first line after defer parse, compute the column relative to the column number // of the lexically parent function. ULONG offsetFromCurrentFunction = m_pscan->IchMinTok() - m_currentNodeFunc->ichMin; columnNumber = m_currentNodeFunc->sxFnc.columnNumber + offsetFromCurrentFunction ; } else { // if there is no current function, lets give a default of 0. columnNumber = 0; } return columnNumber; }
CWE-119
null
517,523
132254433701515041862720918196095815990
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ParseNodePtr Parser::CreateTriNode(OpCode nop, ParseNodePtr pnode1, ParseNodePtr pnode2, ParseNodePtr pnode3) { charcount_t ichMin; charcount_t ichLim; if (nullptr == pnode1) { // no ops Assert(nullptr == pnode2); Assert(nullptr == pnode3); ichMin = m_pscan->IchMinTok(); ichLim = m_pscan->IchLimTok(); } else if (nullptr == pnode2) { // 1 op Assert(nullptr == pnode3); ichMin = pnode1->ichMin; ichLim = pnode1->ichLim; } else if (nullptr == pnode3) { // 2 op ichMin = pnode1->ichMin; ichLim = pnode2->ichLim; } else { // 3 ops ichMin = pnode1->ichMin; ichLim = pnode3->ichLim; } return CreateTriNode(nop, pnode1, pnode2, pnode3, ichMin, ichLim); }
CWE-119
null
517,524
275098325725849867879738889414727578134
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ModuleImportOrExportEntryList* Parser::EnsureModuleIndirectExportEntryList() { if (m_currentNodeProg->sxModule.indirectExportEntries == nullptr) { m_currentNodeProg->sxModule.indirectExportEntries = Anew(&m_nodeAllocator, ModuleImportOrExportEntryList, &m_nodeAllocator); } return m_currentNodeProg->sxModule.indirectExportEntries; }
CWE-119
null
517,525
265470551243389450387401661502180556631
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
int Parser::GetCurrentDynamicBlockId() const { return m_currentDynamicBlock ? m_currentDynamicBlock->id : -1; }
CWE-119
null
517,526
293628805874611112076847769847218510106
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
void Parser::AddModuleLocalExportEntry(ParseNodePtr varDeclNode) { Assert(varDeclNode->nop == knopVarDecl || varDeclNode->nop == knopLetDecl || varDeclNode->nop == knopConstDecl); IdentPtr localName = varDeclNode->sxVar.pid; varDeclNode->sxVar.sym->SetIsModuleExportStorage(true); AddModuleImportOrExportEntry(EnsureModuleLocalExportEntryList(), nullptr, localName, localName, nullptr); }
CWE-119
null
517,527
52496058103214660718653654677646683548
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ModuleImportOrExportEntryList* Parser::EnsureModuleImportEntryList() { if (m_currentNodeProg->sxModule.importEntries == nullptr) { m_currentNodeProg->sxModule.importEntries = Anew(&m_nodeAllocator, ModuleImportOrExportEntryList, &m_nodeAllocator); } return m_currentNodeProg->sxModule.importEntries; }
CWE-119
null
517,528
141432643268520768729040223944799644093
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ParseNodePtr Parser::CreateBlockNode(charcount_t ichMin,charcount_t ichLim, PnodeBlockType blockType) { return StaticCreateBlockNode(&m_nodeAllocator, ichMin, ichLim, this->m_nextBlockId++, blockType); }
CWE-119
null
517,529
18151498282633016921982303548591681983
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
BOOL Parser::ExpectingExternalSource() { return m_fExpectExternalSource; }
CWE-119
null
517,530
230070106761707517992412896056996666481
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
void PrintPnode(ParseNode *pnode) { PrintPnodeWIndent(pnode,0); }
CWE-119
null
517,531
338962300966819207108821356277277784174
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ModuleImportOrExportEntry* Parser::AddModuleImportOrExportEntry(ModuleImportOrExportEntryList* importOrExportEntryList, IdentPtr importName, IdentPtr localName, IdentPtr exportName, IdentPtr moduleRequest) { ModuleImportOrExportEntry* importOrExportEntry = Anew(&m_nodeAllocator, ModuleImportOrExportEntry); importOrExportEntry->importName = importName; importOrExportEntry->localName = localName; importOrExportEntry->exportName = exportName; importOrExportEntry->moduleRequest = moduleRequest; return AddModuleImportOrExportEntry(importOrExportEntryList, importOrExportEntry); }
CWE-119
null
517,532
208934016675730322713197397193998885138
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
BOOL Parser::IsConstantInFunctionCall(ParseNodePtr pnode) { if (pnode->nop == knopInt && !Js::TaggedInt::IsOverflow(pnode->sxInt.lw)) { return TRUE; } if (pnode->nop == knopFlt) { return TRUE; } return FALSE; }
CWE-119
null
517,533
282139040316383003300656123345888246415
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ModuleImportOrExportEntryList* Parser::GetModuleLocalExportEntryList() { return m_currentNodeProg->sxModule.localExportEntries; }
CWE-119
null
517,534
164855651420157320368113669426625505799
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ParseNodePtr Parser::StaticCreateBinNode(OpCode nop, ParseNodePtr pnode1, ParseNodePtr pnode2,ArenaAllocator* alloc) { DebugOnly(VerifyNodeSize(nop, kcbPnBin)); ParseNodePtr pnode = (ParseNodePtr)alloc->Alloc(kcbPnBin); InitNode(nop, pnode); pnode->sxBin.pnodeNext = nullptr; pnode->sxBin.pnode1 = pnode1; pnode->sxBin.pnode2 = pnode2; // Statically detect if the add is a concat if (!PHASE_OFF1(Js::ByteCodeConcatExprOptPhase)) { // We can't flatten the concat expression if the LHS is not a flatten concat already // e.g. a + (<str> + b) // Side effect of ToStr(b) need to happen first before ToStr(a) // If we flatten the concat expression, we will do ToStr(a) before ToStr(b) if ((nop == knopAdd) && (pnode1->CanFlattenConcatExpr() || pnode2->nop == knopStr)) { pnode->grfpn |= fpnCanFlattenConcatExpr; } } return pnode; }
CWE-119
null
517,535
148228782261726853424438897518381704651
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
PidRefStack* Parser::PushPidRef(IdentPtr pid) { if (PHASE_ON1(Js::ParallelParsePhase)) { // NOTE: the phase check is here to protect perf. See OSG 1020424. // In some LS AST-rewrite cases we lose a lot of perf searching the PID ref stack rather // than just pushing on the top. This hasn't shown up as a perf issue in non-LS benchmarks. return pid->FindOrAddPidRef(&m_nodeAllocator, GetCurrentBlock()->sxBlock.blockId, GetCurrentFunctionNode()->sxFnc.functionId); } Assert(GetCurrentBlock() != nullptr); AssertMsg(pid != nullptr, "PID should be created"); PidRefStack *ref = pid->GetTopRef(); int blockId = GetCurrentBlock()->sxBlock.blockId; int funcId = GetCurrentFunctionNode()->sxFnc.functionId; if (!ref || (ref->GetScopeId() < blockId)) { ref = Anew(&m_nodeAllocator, PidRefStack); if (ref == nullptr) { Error(ERRnoMemory); } pid->PushPidRef(blockId, funcId, ref); } else if (m_reparsingLambdaParams) { // If we're reparsing params, then we may have pid refs left behind from the first pass. Make sure we're // working with the right ref at this point. ref = this->FindOrAddPidRef(pid, blockId, funcId); // Fix up the function ID if we're reparsing lambda parameters. ref->funcId = funcId; } return ref; }
CWE-119
null
517,536
28393598933216688506776065365014461450
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
void Parser::AddArgumentsNodeToVars(ParseNodePtr pnodeFnc) { if((pnodeFnc->grfpn & PNodeFlags::fpnArguments_overriddenByDecl) || pnodeFnc->sxFnc.IsLambda()) { // In any of the following cases, there is no way to reference the built-in 'arguments' variable (in the order of checks // above): // - A function parameter is named 'arguments' // - There is a nested function declaration (or named function expression in compat modes) named 'arguments' // - In compat modes, the function is named arguments, does not have a var declaration named 'arguments', and does // not call 'eval' pnodeFnc->sxFnc.SetHasReferenceableBuiltInArguments(false); } else { ParseNodePtr argNode = nullptr; if(m_ppnodeVar == &pnodeFnc->sxFnc.pnodeVars) { // There were no var declarations in the function argNode = CreateVarDeclNode(wellKnownPropertyPids.arguments, STVariable, true, pnodeFnc); } else { // There were var declarations in the function, so insert an 'arguments' local at the beginning of the var list. // This is done because the built-in 'arguments' variable overrides an 'arguments' var declaration until the // 'arguments' variable is assigned. By putting our built-in var declaration at the beginning, an 'arguments' // identifier will resolve to this symbol, which has the fpnArguments flag set, and will be the built-in arguments // object until it is replaced with something else. ParseNodePtr *const ppnodeVarSave = m_ppnodeVar; m_ppnodeVar = &pnodeFnc->sxFnc.pnodeVars; argNode = CreateVarDeclNode(wellKnownPropertyPids.arguments, STVariable, true, pnodeFnc); m_ppnodeVar = ppnodeVarSave; } Assert(argNode); argNode->grfpn |= PNodeFlags::fpnArguments; // When a function definition with the name arguments occurs in the body the declaration of the arguments symbol will // be set to that function declaration. We should change it to arguments declaration from the param scope as it may be // used in the param scope and we have to load the arguments. argNode->sxVar.sym->SetDecl(argNode); pnodeFnc->sxFnc.SetHasReferenceableBuiltInArguments(true); } }
CWE-119
null
517,537
253302624506394453029978944850380058547
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
void Parser::PopBlockInfo() { Assert(m_currentBlockInfo); PopDynamicBlock(); m_currentBlockInfo = m_currentBlockInfo->pBlockInfoOuter; }
CWE-119
null
517,538
86075663046680288479521949011780323170
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ParseNodePtr Parser::ParseCase(ParseNodePtr *ppnodeBody) { ParseNodePtr pnodeT = nullptr; charcount_t ichMinT = m_pscan->IchMinTok(); m_pscan->Scan(); ParseNodePtr pnodeExpr = ParseExpr<buildAST>(); charcount_t ichLim = m_pscan->IchLimTok(); ChkCurTok(tkColon, ERRnoColon); if (buildAST) { pnodeT = CreateNodeWithScanner<knopCase>(ichMinT); pnodeT->sxCase.pnodeExpr = pnodeExpr; pnodeT->ichLim = ichLim; } ParseStmtList<buildAST>(ppnodeBody); return pnodeT; }
CWE-119
null
517,539
270536604779347112243290052645678105864
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ParseNodePtr Parser::ParseFncDecl(ushort flags, LPCOLESTR pNameHint, const bool needsPIDOnRCurlyScan, bool resetParsingSuperRestrictionState, bool fUnaryOrParen) { AutoParsingSuperRestrictionStateRestorer restorer(this); if (resetParsingSuperRestrictionState) { // ParseFncDecl will always reset m_parsingSuperRestrictionState to super disallowed unless explicitly disabled this->m_parsingSuperRestrictionState = ParsingSuperRestrictionState_SuperDisallowed; } ParseNodePtr pnodeFnc = nullptr; ParseNodePtr *ppnodeVarSave = nullptr; ParseNodePtr pnodeFncBlockScope = nullptr; ParseNodePtr *ppnodeScopeSave = nullptr; ParseNodePtr *ppnodeExprScopeSave = nullptr; bool funcHasName = false; bool fDeclaration = flags & fFncDeclaration; bool fModule = (flags & fFncModule) != 0; bool fLambda = (flags & fFncLambda) != 0; charcount_t ichMin = this->m_pscan->IchMinTok(); bool wasInDeferredNestedFunc = false; uint tryCatchOrFinallyDepthSave = this->m_tryCatchOrFinallyDepth; this->m_tryCatchOrFinallyDepth = 0; if (this->m_arrayDepth) { this->m_funcInArrayDepth++; // Count function depth within array literal } // Update the count of functions nested in the current parent. Assert(m_pnestedCount || !buildAST); uint *pnestedCountSave = m_pnestedCount; if (buildAST || m_pnestedCount) { (*m_pnestedCount)++; } uint scopeCountNoAstSave = m_scopeCountNoAst; m_scopeCountNoAst = 0; bool noStmtContext = false; if (fDeclaration) { noStmtContext = m_pstmtCur->GetNop() != knopBlock; if (noStmtContext) { // We have a function declaration like "if (a) function f() {}". We didn't see // a block scope on the way in, so we need to pretend we did. Note that this is a syntax error // in strict mode. if (!this->FncDeclAllowedWithoutContext(flags)) { Error(ERRsyntax); } pnodeFncBlockScope = StartParseBlock<buildAST>(PnodeBlockType::Regular, ScopeType_Block); if (buildAST) { PushFuncBlockScope(pnodeFncBlockScope, &ppnodeScopeSave, &ppnodeExprScopeSave); } } } // Create the node. pnodeFnc = CreateNode(knopFncDecl); pnodeFnc->sxFnc.ClearFlags(); pnodeFnc->sxFnc.SetDeclaration(fDeclaration); pnodeFnc->sxFnc.astSize = 0; pnodeFnc->sxFnc.pnodeName = nullptr; pnodeFnc->sxFnc.pnodeScopes = nullptr; pnodeFnc->sxFnc.pnodeRest = nullptr; pnodeFnc->sxFnc.pid = nullptr; pnodeFnc->sxFnc.hint = nullptr; pnodeFnc->sxFnc.hintOffset = 0; pnodeFnc->sxFnc.hintLength = 0; pnodeFnc->sxFnc.isNameIdentifierRef = true; pnodeFnc->sxFnc.nestedFuncEscapes = false; pnodeFnc->sxFnc.pnodeNext = nullptr; pnodeFnc->sxFnc.pnodeParams = nullptr; pnodeFnc->sxFnc.pnodeVars = nullptr; pnodeFnc->sxFnc.funcInfo = nullptr; pnodeFnc->sxFnc.deferredStub = nullptr; pnodeFnc->sxFnc.nestedCount = 0; pnodeFnc->sxFnc.cbMin = m_pscan->IecpMinTok(); pnodeFnc->sxFnc.functionId = (*m_nextFunctionId)++; // Push new parser state with this new function node AppendFunctionToScopeList(fDeclaration, pnodeFnc); // Start the argument list. ppnodeVarSave = m_ppnodeVar; if (buildAST) { pnodeFnc->sxFnc.lineNumber = m_pscan->LineCur(); pnodeFnc->sxFnc.columnNumber = CalculateFunctionColumnNumber(); pnodeFnc->sxFnc.SetNested(m_currentNodeFunc != nullptr); // If there is a current function, then we're a nested function. pnodeFnc->sxFnc.SetStrictMode(IsStrictMode()); // Inherit current strict mode -- may be overridden by the function itself if it contains a strict mode directive. pnodeFnc->sxFnc.firstDefaultArg = 0; m_pCurrentAstSize = &pnodeFnc->sxFnc.astSize; } else // if !buildAST { wasInDeferredNestedFunc = m_inDeferredNestedFunc; m_inDeferredNestedFunc = true; } m_pnestedCount = &pnodeFnc->sxFnc.nestedCount; AnalysisAssert(pnodeFnc); pnodeFnc->sxFnc.SetIsAsync((flags & fFncAsync) != 0); pnodeFnc->sxFnc.SetIsLambda(fLambda); pnodeFnc->sxFnc.SetIsMethod((flags & fFncMethod) != 0); pnodeFnc->sxFnc.SetIsClassMember((flags & fFncClassMember) != 0); pnodeFnc->sxFnc.SetIsModule(fModule); bool needScanRCurly = true; bool result = ParseFncDeclHelper<buildAST>(pnodeFnc, pNameHint, flags, &funcHasName, fUnaryOrParen, noStmtContext, &needScanRCurly, fModule); if (!result) { Assert(!pnodeFncBlockScope); return pnodeFnc; } AnalysisAssert(pnodeFnc); *m_ppnodeVar = nullptr; m_ppnodeVar = ppnodeVarSave; if (m_currentNodeFunc && (pnodeFnc->sxFnc.CallsEval() || pnodeFnc->sxFnc.ChildCallsEval())) { GetCurrentFunctionNode()->sxFnc.SetChildCallsEval(true); } ParseNodePtr pnodeFncParent = buildAST ? m_currentNodeFunc : m_currentNodeDeferredFunc; // Lambdas do not have "arguments" and instead capture their parent's // binding of "arguments. To ensure the arguments object of the enclosing // non-lambda function is loaded propagate the UsesArguments flag up to // the parent function if ((flags & fFncLambda) != 0 && pnodeFnc->sxFnc.UsesArguments()) { if (pnodeFncParent != nullptr) { pnodeFncParent->sxFnc.SetUsesArguments(); } else { m_UsesArgumentsAtGlobal = true; } } if (needScanRCurly && !fModule) { // Consume the next token now that we're back in the enclosing function (whose strictness may be // different from the function we just finished). #if DBG bool expectedTokenValid = m_token.tk == tkRCurly; AssertMsg(expectedTokenValid, "Invalid token expected for RCurly match"); #endif // The next token may need to have a PID created in !buildAST mode, as we may be parsing a method with a string name. if (needsPIDOnRCurlyScan) { m_pscan->ScanForcingPid(); } else { m_pscan->Scan(); } } m_pnestedCount = pnestedCountSave; Assert(!buildAST || !wasInDeferredNestedFunc); m_inDeferredNestedFunc = wasInDeferredNestedFunc; if (this->m_arrayDepth) { this->m_funcInArrayDepth--; if (this->m_funcInArrayDepth == 0) { // We disable deferred parsing if array literals dominate. // But don't do this if the array literal is dominated by function bodies. if (flags & (fFncMethod | fFncClassMember) && m_token.tk != tkSColon) { // Class member methods have optional separators. We need to check whether we are // getting the IchLim of the correct token. Assert(m_pscan->m_tkPrevious == tkRCurly && needScanRCurly); this->m_funcInArray += m_pscan->IchMinTok() - /*tkRCurly*/ 1 - ichMin; } else { this->m_funcInArray += m_pscan->IchLimTok() - ichMin; } } } m_scopeCountNoAst = scopeCountNoAstSave; if (buildAST && fDeclaration && !IsStrictMode()) { if (pnodeFnc->sxFnc.pnodeName != nullptr && pnodeFnc->sxFnc.pnodeName->nop == knopVarDecl && GetCurrentBlock()->sxBlock.blockType == PnodeBlockType::Regular) { // Add a function-scoped VarDecl with the same name as the function for // back compat with pre-ES6 code that declares functions in blocks. The // idea is that the last executed declaration wins at the function scope // level and we accomplish this by having each block scoped function // declaration assign to both the block scoped "let" binding, as well // as the function scoped "var" binding. bool isRedecl = false; ParseNodePtr vardecl = CreateVarDeclNode(pnodeFnc->sxFnc.pnodeName->sxVar.pid, STVariable, false, nullptr, false, &isRedecl); vardecl->sxVar.isBlockScopeFncDeclVar = true; if (isRedecl) { vardecl->sxVar.sym->SetHasBlockFncVarRedecl(); } } } if (pnodeFncBlockScope) { Assert(pnodeFncBlockScope->sxBlock.pnodeStmt == nullptr); pnodeFncBlockScope->sxBlock.pnodeStmt = pnodeFnc; if (buildAST) { PopFuncBlockScope(ppnodeScopeSave, ppnodeExprScopeSave); } FinishParseBlock(pnodeFncBlockScope); return pnodeFncBlockScope; } this->m_tryCatchOrFinallyDepth = tryCatchOrFinallyDepthSave; return pnodeFnc; }
CWE-119
null
517,540
320647489395040366221259928725986908358
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
void Parser::AppendToList(ParseNodePtr *node, ParseNodePtr nodeToAppend) { Assert(nodeToAppend); ParseNodePtr* lastPtr = node; while ((*lastPtr) && (*lastPtr)->nop == knopList) { lastPtr = &(*lastPtr)->sxBin.pnode2; } auto last = (*lastPtr); if (last) { *lastPtr = CreateBinNode(knopList, last, nodeToAppend, last->ichMin, nodeToAppend->ichLim); } else { *lastPtr = nodeToAppend; } }
CWE-119
null
517,541
289773564953686294257066294545998293529
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ParseNodePtr Parser::ParseExportDeclaration() { Assert(m_scriptContext->GetConfig()->IsES6ModuleEnabled()); Assert(m_token.tk == tkEXPORT); if (!IsImportOrExportStatementValidHere()) { Error(ERRInvalidModuleImportOrExport); } ParseNodePtr pnode = nullptr; IdentPtr moduleIdentifier = nullptr; tokens declarationType; // We just parsed an export token. Next valid tokens are *, {, var, let, const, async, function, class, default. m_pscan->Scan(); switch (m_token.tk) { case tkStar: m_pscan->Scan(); // A star token in an export declaration must be followed by a from clause which begins with a token 'from'. moduleIdentifier = ParseImportOrExportFromClause<buildAST>(true); if (buildAST) { Assert(moduleIdentifier != nullptr); AddModuleSpecifier(moduleIdentifier); IdentPtr importName = wellKnownPropertyPids._star; AddModuleImportOrExportEntry(EnsureModuleStarExportEntryList(), importName, nullptr, nullptr, moduleIdentifier); } break; case tkLCurly: { ModuleImportOrExportEntryList exportEntryList(&m_nodeAllocator); ParseNamedImportOrExportClause<buildAST>(&exportEntryList, true); m_pscan->Scan(); // Export clause may be followed by a from clause. moduleIdentifier = ParseImportOrExportFromClause<buildAST>(false); if (buildAST) { if (moduleIdentifier != nullptr) { AddModuleSpecifier(moduleIdentifier); } exportEntryList.Map([this, moduleIdentifier](ModuleImportOrExportEntry& exportEntry) { if (moduleIdentifier != nullptr) { exportEntry.moduleRequest = moduleIdentifier; // We need to swap localname and importname when this is a re-export. exportEntry.importName = exportEntry.localName; exportEntry.localName = nullptr; AddModuleImportOrExportEntry(EnsureModuleIndirectExportEntryList(), &exportEntry); } else { AddModuleImportOrExportEntry(EnsureModuleLocalExportEntryList(), &exportEntry); } }); exportEntryList.Clear(); } } break; case tkID: { IdentPtr pid = m_token.GetIdentifier(m_phtbl); if (wellKnownPropertyPids.let == pid) { declarationType = tkLET; goto ParseVarDecl; } if (wellKnownPropertyPids.async == pid && m_scriptContext->GetConfig()->IsES7AsyncAndAwaitEnabled()) { // In module export statements, async token is only valid if it's followed by function. // We need to check here because ParseStatement would think 'async = 20' is a var decl. RestorePoint parsedAsync; m_pscan->Capture(&parsedAsync); m_pscan->Scan(); if (m_token.tk == tkFUNCTION) { // Token after async is function, rewind to the async token and let ParseStatement handle it. m_pscan->SeekTo(parsedAsync); goto ParseFunctionDecl; } // Token after async is not function, it's a syntax error. } goto ErrorToken; } case tkVAR: case tkLET: case tkCONST: { declarationType = m_token.tk; ParseVarDecl: m_pscan->Scan(); pnode = ParseVariableDeclaration<buildAST>(declarationType, m_pscan->IchMinTok()); if (buildAST) { ParseNodePtr temp = pnode; while (temp->nop == knopList) { ParseNodePtr varDeclNode = temp->sxBin.pnode1; temp = temp->sxBin.pnode2; AddModuleLocalExportEntry(varDeclNode); } AddModuleLocalExportEntry(temp); } } break; case tkFUNCTION: case tkCLASS: { ParseFunctionDecl: pnode = ParseStatement<buildAST>(); if (buildAST) { IdentPtr localName; if (pnode->nop == knopClassDecl) { pnode->sxClass.pnodeName->sxVar.sym->SetIsModuleExportStorage(true); pnode->sxClass.pnodeDeclName->sxVar.sym->SetIsModuleExportStorage(true); localName = pnode->sxClass.pnodeName->sxVar.pid; } else { Assert(pnode->nop == knopFncDecl); pnode->sxFnc.GetFuncSymbol()->SetIsModuleExportStorage(true); localName = pnode->sxFnc.pid; } Assert(localName != nullptr); AddModuleImportOrExportEntry(EnsureModuleLocalExportEntryList(), nullptr, localName, localName, nullptr); } } break; case tkDEFAULT: { pnode = ParseDefaultExportClause<buildAST>(); } break; default: { ErrorToken: Error(ERRsyntax); } } return pnode; }
CWE-119
null
517,542
161036491597529722078007338768591689237
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ParseNode* Parser::CopyPnode(ParseNode *pnode) { if (pnode==NULL) return NULL; switch (pnode->nop) { //PTNODE(knopName , "name" ,None ,Pid ,fnopLeaf) case knopName: { ParseNode* nameNode=CreateNameNode(pnode->sxPid.pid,pnode->ichMin,pnode->ichLim); nameNode->sxPid.sym=pnode->sxPid.sym; return nameNode; } //PTNODE(knopInt , "int const" ,None ,Int ,fnopLeaf|fnopConst) case knopInt: return pnode; //PTNODE(knopFlt , "flt const" ,None ,Flt ,fnopLeaf|fnopConst) case knopFlt: return pnode; //PTNODE(knopStr , "str const" ,None ,Pid ,fnopLeaf|fnopConst) case knopStr: return pnode; //PTNODE(knopRegExp , "reg expr" ,None ,Pid ,fnopLeaf|fnopConst) case knopRegExp: return pnode; break; //PTNODE(knopThis , "this" ,None ,None ,fnopLeaf) case knopThis: return CreateNodeT<knopThis>(pnode->ichMin,pnode->ichLim); //PTNODE(knopNull , "null" ,Null ,None ,fnopLeaf) case knopNull: return pnode; //PTNODE(knopFalse , "false" ,False ,None ,fnopLeaf) case knopFalse: { ParseNode* ret = CreateNodeT<knopFalse>(pnode->ichMin, pnode->ichLim); ret->location = pnode->location; return ret; } //PTNODE(knopTrue , "true" ,True ,None ,fnopLeaf) case knopTrue: { ParseNode* ret = CreateNodeT<knopTrue>(pnode->ichMin, pnode->ichLim); ret->location = pnode->location; return ret; } //PTNODE(knopEmpty , "empty" ,Empty ,None ,fnopLeaf) case knopEmpty: return CreateNodeT<knopEmpty>(pnode->ichMin,pnode->ichLim); // Unary operators. //PTNODE(knopNot , "~" ,BitNot ,Uni ,fnopUni) //PTNODE(knopNeg , "unary -" ,Neg ,Uni ,fnopUni) //PTNODE(knopPos , "unary +" ,Pos ,Uni ,fnopUni) //PTNODE(knopLogNot , "!" ,LogNot ,Uni ,fnopUni) //PTNODE(knopEllipsis , "..." ,Spread ,Uni , fnopUni) //PTNODE(knopDecPost , "-- post" ,Dec ,Uni ,fnopUni|fnopAsg) //PTNODE(knopIncPre , "++ pre" ,Inc ,Uni ,fnopUni|fnopAsg) //PTNODE(knopDecPre , "-- pre" ,Dec ,Uni ,fnopUni|fnopAsg) //PTNODE(knopTypeof , "typeof" ,None ,Uni ,fnopUni) //PTNODE(knopVoid , "void" ,Void ,Uni ,fnopUni) //PTNODE(knopDelete , "delete" ,None ,Uni ,fnopUni) case knopNot: case knopNeg: case knopPos: case knopLogNot: case knopEllipsis: case knopIncPost: case knopDecPost: case knopIncPre: case knopDecPre: case knopTypeof: case knopVoid: case knopDelete: return CreateUniNode(pnode->nop,CopyPnode(pnode->sxUni.pnode1),pnode->ichMin,pnode->ichLim); //PTNODE(knopArray , "arr cnst" ,None ,Uni ,fnopUni) //PTNODE(knopObject , "obj cnst" ,None ,Uni ,fnopUni) case knopArray: case knopObject: // TODO: need to copy arr Assert(false); break; // Binary operators //PTNODE(knopAdd , "+" ,Add ,Bin ,fnopBin) //PTNODE(knopSub , "-" ,Sub ,Bin ,fnopBin) //PTNODE(knopMul , "*" ,Mul ,Bin ,fnopBin) //PTNODE(knopExpo , "**" ,Expo ,Bin ,fnopBin) //PTNODE(knopDiv , "/" ,Div ,Bin ,fnopBin) //PTNODE(knopMod , "%" ,Mod ,Bin ,fnopBin) //PTNODE(knopOr , "|" ,BitOr ,Bin ,fnopBin) //PTNODE(knopXor , "^" ,BitXor ,Bin ,fnopBin) //PTNODE(knopAnd , "&" ,BitAnd ,Bin ,fnopBin) //PTNODE(knopEq , "==" ,EQ ,Bin ,fnopBin|fnopRel) //PTNODE(knopNe , "!=" ,NE ,Bin ,fnopBin|fnopRel) //PTNODE(knopLt , "<" ,LT ,Bin ,fnopBin|fnopRel) //PTNODE(knopLe , "<=" ,LE ,Bin ,fnopBin|fnopRel) //PTNODE(knopGe , ">=" ,GE ,Bin ,fnopBin|fnopRel) //PTNODE(knopGt , ">" ,GT ,Bin ,fnopBin|fnopRel) //PTNODE(knopEqv , "===" ,Eqv ,Bin ,fnopBin|fnopRel) //PTNODE(knopIn , "in" ,In ,Bin ,fnopBin|fnopRel) //PTNODE(knopInstOf , "instanceof",InstOf ,Bin ,fnopBin|fnopRel) //PTNODE(knopNEqv , "!==" ,NEqv ,Bin ,fnopBin|fnopRel) //PTNODE(knopComma , "," ,None ,Bin ,fnopBin) //PTNODE(knopLogOr , "||" ,None ,Bin ,fnopBin) //PTNODE(knopLogAnd , "&&" ,None ,Bin ,fnopBin) //PTNODE(knopLsh , "<<" ,Lsh ,Bin ,fnopBin) //PTNODE(knopRsh , ">>" ,Rsh ,Bin ,fnopBin) //PTNODE(knopRs2 , ">>>" ,Rs2 ,Bin ,fnopBin) case knopAdd: case knopSub: case knopMul: case knopExpo: case knopDiv: case knopMod: case knopOr: case knopXor: case knopAnd: case knopEq: case knopNe: case knopLt: case knopLe: case knopGe: case knopGt: case knopEqv: case knopIn: case knopInstOf: case knopNEqv: case knopComma: case knopLogOr: case knopLogAnd: case knopLsh: case knopRsh: case knopRs2: //PTNODE(knopAsg , "=" ,None ,Bin ,fnopBin|fnopAsg) case knopAsg: //PTNODE(knopDot , "." ,None ,Bin ,fnopBin) case knopDot: //PTNODE(knopAsgAdd , "+=" ,Add ,Bin ,fnopBin|fnopAsg) case knopAsgAdd: //PTNODE(knopAsgSub , "-=" ,Sub ,Bin ,fnopBin|fnopAsg) case knopAsgSub: //PTNODE(knopAsgMul , "*=" ,Mul ,Bin ,fnopBin|fnopAsg) case knopAsgMul: //PTNODE(knopAsgDiv , "/=" ,Div ,Bin ,fnopBin|fnopAsg) case knopAsgExpo: //PTNODE(knopAsgExpo , "**=" ,Expo ,Bin ,fnopBin|fnopAsg) case knopAsgDiv: //PTNODE(knopAsgMod , "%=" ,Mod ,Bin ,fnopBin|fnopAsg) case knopAsgMod: //PTNODE(knopAsgAnd , "&=" ,BitAnd ,Bin ,fnopBin|fnopAsg) case knopAsgAnd: //PTNODE(knopAsgXor , "^=" ,BitXor ,Bin ,fnopBin|fnopAsg) case knopAsgXor: //PTNODE(knopAsgOr , "|=" ,BitOr ,Bin ,fnopBin|fnopAsg) case knopAsgOr: //PTNODE(knopAsgLsh , "<<=" ,Lsh ,Bin ,fnopBin|fnopAsg) case knopAsgLsh: //PTNODE(knopAsgRsh , ">>=" ,Rsh ,Bin ,fnopBin|fnopAsg) case knopAsgRsh: //PTNODE(knopAsgRs2 , ">>>=" ,Rs2 ,Bin ,fnopBin|fnopAsg) case knopAsgRs2: //PTNODE(knopMember , ":" ,None ,Bin ,fnopBin) case knopMember: case knopMemberShort: //PTNODE(knopIndex , "[]" ,None ,Bin ,fnopBin) //PTNODE(knopList , "<list>" ,None ,Bin ,fnopNone) case knopIndex: case knopList: return CreateBinNode(pnode->nop,CopyPnode(pnode->sxBin.pnode1), CopyPnode(pnode->sxBin.pnode2),pnode->ichMin,pnode->ichLim); //PTNODE(knopCall , "()" ,None ,Bin ,fnopBin) //PTNODE(knopNew , "new" ,None ,Bin ,fnopBin) case knopNew: case knopCall: return CreateCallNode(pnode->nop,CopyPnode(pnode->sxCall.pnodeTarget), CopyPnode(pnode->sxCall.pnodeArgs),pnode->ichMin,pnode->ichLim); //PTNODE(knopQmark , "?" ,None ,Tri ,fnopBin) case knopQmark: return CreateTriNode(pnode->nop,CopyPnode(pnode->sxTri.pnode1), CopyPnode(pnode->sxTri.pnode2),CopyPnode(pnode->sxTri.pnode3), pnode->ichMin,pnode->ichLim); // General nodes. //PTNODE(knopVarDecl , "varDcl" ,None ,Var ,fnopNone) case knopVarDecl: { ParseNode* copyNode=CreateNodeT<knopVarDecl>(pnode->ichMin,pnode->ichLim); copyNode->sxVar.pnodeInit=CopyPnode(pnode->sxVar.pnodeInit); copyNode->sxVar.sym=pnode->sxVar.sym; // TODO: mult-decl Assert(pnode->sxVar.pnodeNext==NULL); copyNode->sxVar.pnodeNext=NULL; return copyNode; } //PTNODE(knopFncDecl , "fncDcl" ,None ,Fnc ,fnopLeaf) //PTNODE(knopProg , "program" ,None ,Fnc ,fnopNone) case knopFncDecl: case knopProg: Assert(false); break; //PTNODE(knopEndCode , "<endcode>" ,None ,None ,fnopNone) case knopEndCode: break; //PTNODE(knopDebugger , "debugger" ,None ,None ,fnopNone) case knopDebugger: break; //PTNODE(knopFor , "for" ,None ,For ,fnopBreak|fnopContinue) case knopFor: { ParseNode* copyNode=CreateNodeT<knopFor>(pnode->ichMin,pnode->ichLim); copyNode->sxFor.pnodeInverted=NULL; copyNode->sxFor.pnodeInit=CopyPnode(pnode->sxFor.pnodeInit); copyNode->sxFor.pnodeCond=CopyPnode(pnode->sxFor.pnodeCond); copyNode->sxFor.pnodeIncr=CopyPnode(pnode->sxFor.pnodeIncr); copyNode->sxFor.pnodeBody=CopyPnode(pnode->sxFor.pnodeBody); return copyNode; } //PTNODE(knopIf , "if" ,None ,If ,fnopNone) case knopIf: Assert(false); break; //PTNODE(knopWhile , "while" ,None ,While,fnopBreak|fnopContinue) case knopWhile: Assert(false); break; //PTNODE(knopDoWhile , "do-while" ,None ,While,fnopBreak|fnopContinue) case knopDoWhile: Assert(false); break; //PTNODE(knopForIn , "for in" ,None ,ForIn,fnopBreak|fnopContinue|fnopCleanup) case knopForIn: Assert(false); break; case knopForOf: Assert(false); break; //PTNODE(knopReturn , "return" ,None ,Uni ,fnopNone) case knopReturn: { ParseNode* copyNode=CreateNodeT<knopReturn>(pnode->ichMin,pnode->ichLim); copyNode->sxReturn.pnodeExpr=CopyPnode(pnode->sxReturn.pnodeExpr); return copyNode; } //PTNODE(knopBlock , "{}" ,None ,Block,fnopNone) case knopBlock: { ParseNode* copyNode=CreateBlockNode(pnode->ichMin,pnode->ichLim,pnode->sxBlock.blockType); if (pnode->grfpn & PNodeFlags::fpnSyntheticNode) { // fpnSyntheticNode is sometimes set on PnodeBlockType::Regular blocks which // CreateBlockNode() will not automatically set for us, so set it here if it's // specified on the source node. copyNode->grfpn |= PNodeFlags::fpnSyntheticNode; } copyNode->sxBlock.pnodeStmt=CopyPnode(pnode->sxBlock.pnodeStmt); return copyNode; } //PTNODE(knopWith , "with" ,None ,With ,fnopCleanup) case knopWith: Assert(false); break; //PTNODE(knopBreak , "break" ,None ,Jump ,fnopNone) case knopBreak: Assert(false); break; //PTNODE(knopContinue , "continue" ,None ,Jump ,fnopNone) case knopContinue: Assert(false); break; //PTNODE(knopLabel , "label" ,None ,Label,fnopNone) case knopLabel: Assert(false); break; //PTNODE(knopSwitch , "switch" ,None ,Switch,fnopBreak) case knopSwitch: Assert(false); break; //PTNODE(knopCase , "case" ,None ,Case ,fnopNone) case knopCase: Assert(false); break; //PTNODE(knopTryFinally,"try-finally",None,TryFinally,fnopCleanup) case knopTryFinally: Assert(false); break; case knopFinally: Assert(false); break; //PTNODE(knopCatch , "catch" ,None ,Catch,fnopNone) case knopCatch: Assert(false); break; //PTNODE(knopTryCatch , "try-catch" ,None ,TryCatch ,fnopCleanup) case knopTryCatch: Assert(false); break; //PTNODE(knopTry , "try" ,None ,Try ,fnopCleanup) case knopTry: Assert(false); break; //PTNODE(knopThrow , "throw" ,None ,Uni ,fnopNone) case knopThrow: Assert(false); break; default: Assert(false); break; } return NULL; }
CWE-119
null
517,543
259312429319136021317445612456745978748
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
IdentPtrList* Parser::GetRequestedModulesList() { return m_currentNodeProg->sxModule.requestedModules; }
CWE-119
null
517,544
153652111263868730093554623972502394060
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ParseNodePtr Parser::CreateNode(OpCode nop, charcount_t ichMin) { bool nodeAllowed = IsNodeAllowedInCurrentDeferralState(nop); Assert(nodeAllowed); Assert(nop >= 0 && nop < knopLim); ParseNodePtr pnode; int cb = (nop >= knopNone && nop < knopLim) ? g_mpnopcbNode[nop] : g_mpnopcbNode[knopEmpty]; pnode = (ParseNodePtr)m_nodeAllocator.Alloc(cb); Assert(pnode != nullptr); if (!m_deferringAST) { Assert(m_pCurrentAstSize != nullptr); *m_pCurrentAstSize += cb; } InitNode(nop,pnode); // default - may be changed pnode->ichMin = ichMin; if (m_pscan!= nullptr) { pnode->ichLim = m_pscan->IchLimTok(); } else pnode->ichLim=0; return pnode; }
CWE-119
null
517,545
266690134804382771318155769173561187109
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ParseNodePtr Parser::Parse(LPCUTF8 pszSrc, size_t offset, size_t length, charcount_t charOffset, ULONG grfscr, ULONG lineNumber, Js::LocalFunctionId * nextFunctionId, CompileScriptException *pse) { ParseNodePtr pnodeProg; ParseNodePtr *lastNodeRef = nullptr; m_nextBlockId = 0; // Scanner should run in Running mode and not syntax coloring mode grfscr &= ~fscrSyntaxColor; if (this->m_scriptContext->IsScriptContextInDebugMode() #ifdef ENABLE_PREJIT || Js::Configuration::Global.flags.Prejit #endif || ((grfscr & fscrNoDeferParse) != 0) ) { // Don't do deferred parsing if debugger is attached or feature is disabled // by command-line switch. grfscr &= ~fscrDeferFncParse; } else if (!(grfscr & fscrGlobalCode) && ( PHASE_OFF1(Js::Phase::DeferEventHandlersPhase) || this->m_scriptContext->IsScriptContextInSourceRundownOrDebugMode() ) ) { // Don't defer event handlers in debug/rundown mode, because we need to register the document, // so we need to create a full FunctionBody for the script body. grfscr &= ~fscrDeferFncParse; } bool isDeferred = (grfscr & fscrDeferredFnc) != 0; bool isModuleSource = (grfscr & fscrIsModuleCode) != 0; m_grfscr = grfscr; m_length = length; m_originalLength = length; m_nextFunctionId = nextFunctionId; if(m_parseType != ParseType_Deferred) { JS_ETW(EventWriteJSCRIPT_PARSE_METHOD_START(m_sourceContextInfo->dwHostSourceContext, GetScriptContext(), *m_nextFunctionId, 0, m_parseType, Js::Constants::GlobalFunction)); OUTPUT_TRACE(Js::DeferParsePhase, _u("Parsing function (%s) : %s (%d)\n"), GetParseType(), Js::Constants::GlobalFunction, *m_nextFunctionId); } // Give the scanner the source and get the first token m_pscan->SetText(pszSrc, offset, length, charOffset, grfscr, lineNumber); m_pscan->Scan(); // Make the main 'knopProg' node int32 initSize = 0; m_pCurrentAstSize = &initSize; pnodeProg = CreateProgNodeWithScanner(isModuleSource); pnodeProg->grfpn = PNodeFlags::fpnNone; pnodeProg->sxFnc.pid = nullptr; pnodeProg->sxFnc.pnodeName = nullptr; pnodeProg->sxFnc.pnodeRest = nullptr; pnodeProg->sxFnc.ClearFlags(); pnodeProg->sxFnc.SetNested(FALSE); pnodeProg->sxFnc.astSize = 0; pnodeProg->sxFnc.cbMin = m_pscan->IecpMinTok(); pnodeProg->sxFnc.lineNumber = lineNumber; pnodeProg->sxFnc.columnNumber = 0; if (!isDeferred || (isDeferred && grfscr & fscrGlobalCode)) { // In the deferred case, if the global function is deferred parse (which is in no-refresh case), // we will re-use the same function body, so start with the correct functionId. pnodeProg->sxFnc.functionId = (*m_nextFunctionId)++; } else { pnodeProg->sxFnc.functionId = Js::Constants::NoFunctionId; } if (isModuleSource) { Assert(m_scriptContext->GetConfig()->IsES6ModuleEnabled()); pnodeProg->sxModule.localExportEntries = nullptr; pnodeProg->sxModule.indirectExportEntries = nullptr; pnodeProg->sxModule.starExportEntries = nullptr; pnodeProg->sxModule.importEntries = nullptr; pnodeProg->sxModule.requestedModules = nullptr; } m_pCurrentAstSize = & (pnodeProg->sxFnc.astSize); pnodeProg->sxFnc.hint = nullptr; pnodeProg->sxFnc.hintLength = 0; pnodeProg->sxFnc.hintOffset = 0; pnodeProg->sxFnc.isNameIdentifierRef = true; pnodeProg->sxFnc.nestedFuncEscapes = false; // initialize parsing variables pnodeProg->sxFnc.pnodeNext = nullptr; m_currentNodeFunc = nullptr; m_currentNodeDeferredFunc = nullptr; m_currentNodeProg = pnodeProg; m_cactIdentToNodeLookup = 1; pnodeProg->sxFnc.nestedCount = 0; m_pnestedCount = &pnodeProg->sxFnc.nestedCount; m_inDeferredNestedFunc = false; pnodeProg->sxFnc.pnodeParams = nullptr; pnodeProg->sxFnc.pnodeVars = nullptr; pnodeProg->sxFnc.pnodeRest = nullptr; m_ppnodeVar = &pnodeProg->sxFnc.pnodeVars; SetCurrentStatement(nullptr); AssertMsg(m_pstmtCur == nullptr, "Statement stack should be empty when we start parse global code"); // Create block for const's and let's ParseNodePtr pnodeGlobalBlock = StartParseBlock<true>(PnodeBlockType::Global, ScopeType_Global); pnodeProg->sxProg.scope = pnodeGlobalBlock->sxBlock.scope; ParseNodePtr pnodeGlobalEvalBlock = nullptr; // Don't track function expressions separately from declarations at global scope. m_ppnodeExprScope = nullptr; // This synthetic block scope will contain all the nested scopes. pnodeProg->sxFnc.pnodeBodyScope = nullptr; pnodeProg->sxFnc.pnodeScopes = pnodeGlobalBlock; m_ppnodeScope = &pnodeGlobalBlock->sxBlock.pnodeScopes; if ((this->m_grfscr & fscrEvalCode) && !(this->m_functionBody && this->m_functionBody->GetScopeInfo())) { pnodeGlobalEvalBlock = StartParseBlock<true>(PnodeBlockType::Regular, ScopeType_GlobalEvalBlock); pnodeProg->sxFnc.pnodeScopes = pnodeGlobalEvalBlock; m_ppnodeScope = &pnodeGlobalEvalBlock->sxBlock.pnodeScopes; } Js::ScopeInfo *scopeInfo = nullptr; if (m_parseType == ParseType_Deferred && m_functionBody) { // this->m_functionBody can be cleared during parsing, but we need access to the scope info later. scopeInfo = m_functionBody->GetScopeInfo(); if (scopeInfo) { // Create an enclosing function context. m_currentNodeFunc = CreateNode(knopFncDecl); m_currentNodeFunc->sxFnc.pnodeName = nullptr; m_currentNodeFunc->sxFnc.functionId = m_functionBody->GetLocalFunctionId(); m_currentNodeFunc->sxFnc.nestedCount = m_functionBody->GetNestedCount(); m_currentNodeFunc->sxFnc.SetStrictMode(!!this->m_fUseStrictMode); this->RestoreScopeInfo(scopeInfo->GetParent()); } } // It's possible for the module global to be defer-parsed in debug scenarios. if (isModuleSource && (!isDeferred || (isDeferred && grfscr & fscrGlobalCode))) { ParseNodePtr moduleFunction = GenerateModuleFunctionWrapper<true>(); pnodeProg->sxFnc.pnodeBody = nullptr; AddToNodeList(&pnodeProg->sxFnc.pnodeBody, &lastNodeRef, moduleFunction); } else { // Process a sequence of statements/declarations ParseStmtList<true>( &pnodeProg->sxFnc.pnodeBody, &lastNodeRef, SM_OnGlobalCode, !(m_grfscr & fscrDeferredFncExpression) /* isSourceElementList */); } if (m_parseType == ParseType_Deferred) { if (scopeInfo) { this->FinishScopeInfo(scopeInfo->GetParent()); } } pnodeProg->sxProg.m_UsesArgumentsAtGlobal = m_UsesArgumentsAtGlobal; if (IsStrictMode()) { pnodeProg->sxFnc.SetStrictMode(); } #if DEBUG if(m_grfscr & fscrEnforceJSON && !IsJSONValid(pnodeProg->sxFnc.pnodeBody)) { Error(ERRsyntax); } #endif if (tkEOF != m_token.tk) Error(ERRsyntax); // Append an EndCode node. AddToNodeList(&pnodeProg->sxFnc.pnodeBody, &lastNodeRef, CreateNodeWithScanner<knopEndCode>()); AssertMem(lastNodeRef); AssertNodeMem(*lastNodeRef); Assert((*lastNodeRef)->nop == knopEndCode); (*lastNodeRef)->ichMin = 0; (*lastNodeRef)->ichLim = 0; // Get the extent of the code. pnodeProg->ichLim = m_pscan->IchLimTok(); pnodeProg->sxFnc.cbLim = m_pscan->IecpLimTok(); // Terminate the local list *m_ppnodeVar = nullptr; Assert(nullptr == *m_ppnodeScope); Assert(nullptr == pnodeProg->sxFnc.pnodeNext); #ifdef ENABLE_DEBUG_CONFIG_OPTIONS if (Js::Configuration::Global.flags.IsEnabled(Js::ForceUndoDeferFlag)) { m_stoppedDeferredParse = true; } #endif if (m_stoppedDeferredParse) { if (this->m_hasParallelJob) { #if ENABLE_BACKGROUND_PARSING BackgroundParser *bgp = static_cast<BackgroundParser*>(m_scriptContext->GetBackgroundParser()); Assert(bgp); this->WaitForBackgroundJobs(bgp, pse); #endif } // Finally, see if there are any function bodies we now want to generate because we // decided to stop deferring. FinishDeferredFunction(pnodeProg->sxFnc.pnodeScopes); } if (pnodeGlobalEvalBlock) { FinishParseBlock(pnodeGlobalEvalBlock); } // Append block as body of pnodeProg FinishParseBlock(pnodeGlobalBlock); m_scriptContext->AddSourceSize(m_length); if (m_parseType != ParseType_Deferred) { JS_ETW(EventWriteJSCRIPT_PARSE_METHOD_STOP(m_sourceContextInfo->dwHostSourceContext, GetScriptContext(), pnodeProg->sxFnc.functionId, *m_pCurrentAstSize, false, Js::Constants::GlobalFunction)); } return pnodeProg; }
CWE-119
null
517,546
205402930110296904064989386537802865572
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
void PnFnc::SetFuncSymbol(Symbol *sym) { Assert(pnodeName && pnodeName->nop == knopVarDecl); pnodeName->sxVar.sym = sym; }
CWE-119
null
517,547
191710909765985989515691408768728969912
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
HRESULT Parser::ValidateSyntax(LPCUTF8 pszSrc, size_t encodedCharCount, bool isGenerator, bool isAsync, CompileScriptException *pse, void (Parser::*validateFunction)()) { AssertPsz(pszSrc); AssertMemN(pse); if (this->IsBackgroundParser()) { PROBE_STACK_NO_DISPOSE(m_scriptContext, Js::Constants::MinStackDefault); } else { PROBE_STACK(m_scriptContext, Js::Constants::MinStackDefault); } HRESULT hr; SmartFPUControl smartFpuControl; DebugOnly( m_err.fInited = TRUE; ) BOOL fDeferSave = m_deferringAST; try { hr = NOERROR; this->PrepareScanner(false); m_length = encodedCharCount; m_originalLength = encodedCharCount; // make sure deferred parsing is turned off ULONG grfscr = fscrNil; // Give the scanner the source and get the first token m_pscan->SetText(pszSrc, 0, encodedCharCount, 0, grfscr); m_pscan->SetYieldIsKeyword(isGenerator); m_pscan->SetAwaitIsKeyword(isAsync); m_pscan->Scan(); uint nestedCount = 0; m_pnestedCount = &nestedCount; ParseNodePtr pnodeScope = nullptr; m_ppnodeScope = &pnodeScope; m_ppnodeExprScope = nullptr; uint nextFunctionId = 0; m_nextFunctionId = &nextFunctionId; m_inDeferredNestedFunc = false; m_deferringAST = true; m_nextBlockId = 0; ParseNode *pnodeFnc = CreateNode(knopFncDecl); pnodeFnc->sxFnc.ClearFlags(); pnodeFnc->sxFnc.SetDeclaration(false); pnodeFnc->sxFnc.functionId = 0; pnodeFnc->sxFnc.astSize = 0; pnodeFnc->sxFnc.pnodeVars = nullptr; pnodeFnc->sxFnc.pnodeParams = nullptr; pnodeFnc->sxFnc.pnodeBody = nullptr; pnodeFnc->sxFnc.pnodeName = nullptr; pnodeFnc->sxFnc.pnodeRest = nullptr; pnodeFnc->sxFnc.deferredStub = nullptr; pnodeFnc->sxFnc.SetIsGenerator(isGenerator); pnodeFnc->sxFnc.SetIsAsync(isAsync); m_ppnodeVar = &pnodeFnc->sxFnc.pnodeVars; m_currentNodeFunc = pnodeFnc; m_currentNodeDeferredFunc = NULL; m_sourceContextInfo = nullptr; AssertMsg(m_pstmtCur == NULL, "Statement stack should be empty when we start parse function body"); ParseNodePtr block = StartParseBlock<false>(PnodeBlockType::Function, ScopeType_FunctionBody); (this->*validateFunction)(); FinishParseBlock(block); pnodeFnc->ichLim = m_pscan->IchLimTok(); pnodeFnc->sxFnc.cbLim = m_pscan->IecpLimTok(); pnodeFnc->sxFnc.pnodeVars = nullptr; // there should be nothing after successful parsing for a given construct if (m_token.tk != tkEOF) Error(ERRsyntax); RELEASEPTR(m_pscan); m_deferringAST = fDeferSave; } catch(ParseExceptionObject& e) { m_deferringAST = fDeferSave; m_err.m_hr = e.GetError(); hr = pse->ProcessError( m_pscan, m_err.m_hr, /* pnodeBase */ NULL); } return hr; }
CWE-119
null
517,548
156040082252544081771038748862045881448
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ParseNodePtr Parser::CreateDeclNode(OpCode nop, IdentPtr pid, SymbolType symbolType, bool errorOnRedecl, bool *isRedecl) { ParseNodePtr pnode = CreateNode(nop); pnode->sxVar.InitDeclNode(pid, NULL); if (symbolType != STUnknown) { pnode->sxVar.sym = AddDeclForPid(pnode, pid, symbolType, errorOnRedecl, isRedecl); } return pnode; }
CWE-119
null
517,549
261863512406968468758478473951701470578
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
IdentPtr Parser::PidFromNode(ParseNodePtr pnode) { for (;;) { switch (pnode->nop) { case knopName: return pnode->sxPid.pid; case knopVarDecl: return pnode->sxVar.pid; case knopDot: Assert(pnode->sxBin.pnode2->nop == knopName); return pnode->sxBin.pnode2->sxPid.pid; case knopComma: // Advance to the RHS and iterate. pnode = pnode->sxBin.pnode2; break; default: return nullptr; } } }
CWE-119
null
517,550
223819199823574116698112750318294223586
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
void Parser::RegisterRegexPattern(UnifiedRegex::RegexPattern *const regexPattern) { Assert(regexPattern); // ensure a no-throw add behavior here, to catch out of memory exceptions, using the guest arena allocator if (!m_registeredRegexPatterns.PrependNoThrow(m_scriptContext->GetGuestArena(), regexPattern)) { Parser::Error(ERRnoMemory); } }
CWE-119
null
517,551
103831033746341689131166920598085439100
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
void Parser::FinishFncDecl(ParseNodePtr pnodeFnc, LPCOLESTR pNameHint, ParseNodePtr *lastNodeRef, bool skipCurlyBraces) { LPCOLESTR name = NULL; JS_ETW(int32 startAstSize = *m_pCurrentAstSize); if (IS_JS_ETW(EventEnabledJSCRIPT_PARSE_METHOD_START()) || PHASE_TRACE1(Js::DeferParsePhase)) { name = GetFunctionName(pnodeFnc, pNameHint); m_functionBody = NULL; // for nested functions we do not want to get the name of the top deferred function return name; JS_ETW(EventWriteJSCRIPT_PARSE_METHOD_START(m_sourceContextInfo->dwHostSourceContext, GetScriptContext(), pnodeFnc->sxFnc.functionId, 0, m_parseType, name)); OUTPUT_TRACE(Js::DeferParsePhase, _u("Parsing function (%s) : %s (%d)\n"), GetParseType(), name, pnodeFnc->sxFnc.functionId); } JS_ETW_INTERNAL(EventWriteJSCRIPT_PARSE_FUNC(GetScriptContext(), pnodeFnc->sxFnc.functionId, /*Undefer*/FALSE)); // Do the work of creating an AST for a function body. // This is common to the un-deferred case and the case in which we un-defer late in the game. Assert(pnodeFnc->nop == knopFncDecl); if (!skipCurlyBraces) { ChkCurTok(tkLCurly, ERRnoLcurly); } ParseStmtList<true>(&pnodeFnc->sxFnc.pnodeBody, &lastNodeRef, SM_OnFunctionCode, true /* isSourceElementList */); // Append an EndCode node. AddToNodeList(&pnodeFnc->sxFnc.pnodeBody, &lastNodeRef, CreateNodeWithScanner<knopEndCode>()); if (!skipCurlyBraces) { ChkCurTokNoScan(tkRCurly, ERRnoRcurly); } pnodeFnc->ichLim = m_pscan->IchLimTok(); pnodeFnc->sxFnc.cbLim = m_pscan->IecpLimTok(); #ifdef ENABLE_JS_ETW int32 astSize = *m_pCurrentAstSize - startAstSize; EventWriteJSCRIPT_PARSE_METHOD_STOP(m_sourceContextInfo->dwHostSourceContext, GetScriptContext(), pnodeFnc->sxFnc.functionId, astSize, m_parseType, name); #endif }
CWE-119
null
517,552
308874453543306247124584563549439417162
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
void Parser::PushDynamicBlock() { Assert(GetCurrentBlock()); int blockId = GetCurrentBlock()->sxBlock.blockId; if (m_currentDynamicBlock && m_currentDynamicBlock->id == blockId) { return; } BlockIdsStack *info = (BlockIdsStack *)m_nodeAllocator.Alloc(sizeof(BlockIdsStack)); if (nullptr == info) { Error(ERRnoMemory); } info->id = blockId; info->prev = m_currentDynamicBlock; m_currentDynamicBlock = info; }
CWE-119
null
517,553
291989238242805168380696696804048990885
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ParseNodePtr Parser::ParseArrayList(bool *pArrayOfTaggedInts, bool *pArrayOfInts, bool *pArrayOfNumbers, bool *pHasMissingValues, uint *count, uint *spreadCount) { ParseNodePtr pnodeArg = nullptr; ParseNodePtr pnodeList = nullptr; ParseNodePtr *lastNodeRef = nullptr; *count = 0; // Check for an empty list if (tkRBrack == m_token.tk) { return nullptr; } this->m_arrayDepth++; bool arrayOfTaggedInts = buildAST; bool arrayOfInts = buildAST; bool arrayOfNumbers = buildAST; bool arrayOfVarInts = false; bool hasMissingValues = false; for (;;) { (*count)++; if (tkComma == m_token.tk || tkRBrack == m_token.tk) { hasMissingValues = true; arrayOfTaggedInts = false; arrayOfInts = false; arrayOfNumbers = false; if (buildAST) { pnodeArg = CreateNodeWithScanner<knopEmpty>(); } } else { // Allow Spread in array literals. pnodeArg = ParseExpr<buildAST>(koplCma, nullptr, TRUE, /* fAllowEllipsis */ TRUE); if (buildAST) { if (pnodeArg->nop == knopEllipsis) { (*spreadCount)++; } this->CheckArguments(pnodeArg); } } #if DEBUG if(m_grfscr & fscrEnforceJSON && !IsJSONValid(pnodeArg)) { Error(ERRsyntax); } #endif if (buildAST) { if (arrayOfNumbers) { if (pnodeArg->nop != knopInt) { arrayOfTaggedInts = false; if (pnodeArg->nop != knopFlt) { // Not an array of constants. arrayOfInts = false; arrayOfNumbers = false; } else if (arrayOfInts && Js::JavascriptNumber::IsInt32OrUInt32(pnodeArg->sxFlt.dbl) && (!Js::JavascriptNumber::IsInt32(pnodeArg->sxFlt.dbl) || pnodeArg->sxFlt.dbl == -2147483648.0)) { // We've seen nothing but ints, and this is a uint32 but not an int32. // Unless we see an actual float at some point, we want an array of vars // so we can work with tagged ints. arrayOfVarInts = true; } else { // Not an int array, but it may still be a float array. arrayOfInts = false; } } else { if (Js::SparseArraySegment<int32>::IsMissingItem((int32*)&pnodeArg->sxInt.lw)) { arrayOfInts = false; } if (Js::TaggedInt::IsOverflow(pnodeArg->sxInt.lw)) { arrayOfTaggedInts = false; } } } AddToNodeListEscapedUse(&pnodeList, &lastNodeRef, pnodeArg); } if (tkComma != m_token.tk) { break; } m_pscan->Scan(); if (tkRBrack == m_token.tk) { break; } } if (spreadCount != nullptr && *spreadCount > 0){ CHAKRATEL_LANGSTATS_INC_LANGFEATURECOUNT(SpreadFeature, m_scriptContext); } if (buildAST) { AssertMem(lastNodeRef); AssertNodeMem(*lastNodeRef); pnodeList->ichLim = (*lastNodeRef)->ichLim; if (arrayOfVarInts && arrayOfInts) { arrayOfInts = false; arrayOfNumbers = false; } *pArrayOfTaggedInts = arrayOfTaggedInts; *pArrayOfInts = arrayOfInts; *pArrayOfNumbers = arrayOfNumbers; *pHasMissingValues = hasMissingValues; } this->m_arrayDepth--; return pnodeList; }
CWE-119
null
517,554
138722604765140271290053419337735544610
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
Parser::TokIsForInOrForOf() { return m_token.tk == tkIN || (m_token.tk == tkID && m_token.GetIdentifier(m_phtbl) == wellKnownPropertyPids.of); }
CWE-119
null
517,555
44002185870355480238921710297365722713
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ParseNodePtr Parser::CreateIntNodeWithScanner(int32 lw) { Assert(!this->m_deferringAST); ParseNodePtr pnode = CreateNodeWithScanner<knopInt>(); pnode->sxInt.lw = lw; return pnode; }
CWE-119
null
517,556
60704299472945426194940184319535176377
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
Parser::Parser(Js::ScriptContext* scriptContext, BOOL strictMode, PageAllocator *alloc, bool isBackground) #endif : m_nodeAllocator(_u("Parser"), alloc ? alloc : scriptContext->GetThreadContext()->GetPageAllocator(), Parser::OutOfMemory), // use the GuestArena directly for keeping the RegexPattern* alive during byte code generation m_registeredRegexPatterns(scriptContext->GetGuestArena()) { AssertMsg(size == sizeof(Parser), "verify conditionals affecting the size of Parser agree"); Assert(scriptContext != nullptr); m_isInBackground = isBackground; m_phtbl = nullptr; m_pscan = nullptr; m_deferringAST = FALSE; m_stoppedDeferredParse = FALSE; m_hasParallelJob = false; m_doingFastScan = false; m_scriptContext = scriptContext; m_pCurrentAstSize = nullptr; m_arrayDepth = 0; m_funcInArrayDepth = 0; m_parenDepth = 0; m_funcInArray = 0; m_tryCatchOrFinallyDepth = 0; m_UsesArgumentsAtGlobal = false; m_currentNodeFunc = nullptr; m_currentNodeDeferredFunc = nullptr; m_currentNodeNonLambdaFunc = nullptr; m_currentNodeNonLambdaDeferredFunc = nullptr; m_currentNodeProg = nullptr; m_currDeferredStub = nullptr; m_prevSiblingDeferredStub = nullptr; m_pstmtCur = nullptr; m_currentBlockInfo = nullptr; m_currentScope = nullptr; m_currentDynamicBlock = nullptr; m_grfscr = fscrNil; m_length = 0; m_originalLength = 0; m_nextFunctionId = nullptr; m_errorCallback = nullptr; m_uncertainStructure = FALSE; m_reparsingLambdaParams = false; m_inFIB = false; currBackgroundParseItem = nullptr; backgroundParseItems = nullptr; fastScannedRegExpNodes = nullptr; m_fUseStrictMode = strictMode; m_InAsmMode = false; m_deferAsmJs = true; m_scopeCountNoAst = 0; m_fExpectExternalSource = 0; m_parseType = ParseType_Upfront; m_deferEllipsisError = false; m_hasDeferredShorthandInitError = false; m_parsingSuperRestrictionState = ParsingSuperRestrictionState_SuperDisallowed; }
CWE-119
null
517,557
150898738471668583022352010863349347201
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
void Parser::PushFuncBlockScope(ParseNodePtr pnodeBlock, ParseNodePtr **ppnodeScopeSave, ParseNodePtr **ppnodeExprScopeSave) { // Maintain the scope tree. pnodeBlock->sxBlock.pnodeScopes = nullptr; pnodeBlock->sxBlock.pnodeNext = nullptr; // Insert this block into the active list of scopes (m_ppnodeExprScope or m_ppnodeScope). // Save the current block's "next" pointer as the new endpoint of that list. if (m_ppnodeExprScope) { *ppnodeScopeSave = m_ppnodeScope; Assert(*m_ppnodeExprScope == nullptr); *m_ppnodeExprScope = pnodeBlock; *ppnodeExprScopeSave = &pnodeBlock->sxBlock.pnodeNext; } else { Assert(m_ppnodeScope); Assert(*m_ppnodeScope == nullptr); *m_ppnodeScope = pnodeBlock; *ppnodeScopeSave = &pnodeBlock->sxBlock.pnodeNext; *ppnodeExprScopeSave = m_ppnodeExprScope; } // Advance the global scope list pointer to the new block's child list. m_ppnodeScope = &pnodeBlock->sxBlock.pnodeScopes; // Set m_ppnodeExprScope to NULL to make that list inactive. m_ppnodeExprScope = nullptr; }
CWE-119
null
517,558
89631530133722114040549370636912798890
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ParseNode *Parser::GetCurrentFunctionNode() { if (m_currentNodeDeferredFunc != nullptr) { return m_currentNodeDeferredFunc; } else if (m_currentNodeFunc != nullptr) { return m_currentNodeFunc; } else { AssertMsg(GetFunctionBlock()->sxBlock.blockType == PnodeBlockType::Global, "Most likely we are trying to find a syntax error, related to 'let' or 'const' in deferred parsing mode with disabled support of 'let' and 'const'"); return m_currentNodeProg; } }
CWE-119
null
517,559
335775864751909127194417997894647932129
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
void printNop(int nop) { printf("%s\n",nopNames[nop]); }
CWE-119
null
517,560
9481705645825740726521516887639497845
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
BOOL Parser::NodeEqualsName(ParseNodePtr pnode, LPCOLESTR sz, uint32 cch) { return pnode->nop == knopName && pnode->sxPid.pid->Cch() == cch && !wmemcmp(pnode->sxPid.pid->Psz(), sz, cch); }
CWE-119
null
517,561
84710972541395185089831660217135419576
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
void Parser::ParseFncFormals(ParseNodePtr pnodeFnc, ParseNodePtr pnodeParentFnc, ushort flags) { bool fLambda = (flags & fFncLambda) != 0; bool fMethod = (flags & fFncMethod) != 0; bool fNoArg = (flags & fFncNoArg) != 0; bool fOneArg = (flags & fFncOneArg) != 0; bool fAsync = (flags & fFncAsync) != 0; bool fPreviousYieldIsKeyword = false; bool fPreviousAwaitIsKeyword = false; if (fLambda) { fPreviousYieldIsKeyword = m_pscan->SetYieldIsKeyword(pnodeParentFnc != nullptr && pnodeParentFnc->sxFnc.IsGenerator()); fPreviousAwaitIsKeyword = m_pscan->SetAwaitIsKeyword(fAsync || (pnodeParentFnc != nullptr && pnodeParentFnc->sxFnc.IsAsync())); } Assert(!fNoArg || !fOneArg); // fNoArg and fOneArg can never be true at the same time. // strictFormals corresponds to the StrictFormalParameters grammar production // in the ES spec which just means duplicate names are not allowed bool fStrictFormals = IsStrictMode() || fLambda || fMethod; // When detecting duplicated formals pids are needed so force PID creation (unless the function should take 0 or 1 arg). bool forcePid = fStrictFormals && !fNoArg && !fOneArg; AutoTempForcePid autoForcePid(m_pscan, forcePid); // Lambda's allow single formal specified by a single binding identifier without parentheses, special case it. if (fLambda && m_token.tk == tkID) { IdentPtr pid = m_token.GetIdentifier(m_phtbl); CreateVarDeclNode(pid, STFormal, false, nullptr, false); CheckPidIsValid(pid); m_pscan->Scan(); if (m_token.tk != tkDArrow) { Error(ERRsyntax, m_pscan->IchMinTok(), m_pscan->IchLimTok()); } if (fLambda) { m_pscan->SetYieldIsKeyword(fPreviousYieldIsKeyword); m_pscan->SetAwaitIsKeyword(fPreviousAwaitIsKeyword); } return; } else if (fLambda && m_token.tk == tkAWAIT) { // async await => {} IdentifierExpectedError(m_token); } // Otherwise, must have a parameter list within parens. ChkCurTok(tkLParen, ERRnoLparen); // Now parse the list of arguments, if present if (m_token.tk == tkRParen) { if (fOneArg) { Error(ERRSetterMustHaveOneParameter); } } else { if (fNoArg) { Error(ERRGetterMustHaveNoParameters); } SList<IdentPtr> formals(&m_nodeAllocator); ParseNodePtr pnodeT = nullptr; bool seenRestParameter = false; bool isNonSimpleParameterList = false; for (Js::ArgSlot argPos = 0; ; ++argPos) { bool isBindingPattern = false; if (m_scriptContext->GetConfig()->IsES6RestEnabled() && m_token.tk == tkEllipsis) { // Possible rest parameter m_pscan->Scan(); seenRestParameter = true; } if (m_token.tk != tkID) { if (IsES6DestructuringEnabled() && IsPossiblePatternStart()) { // Mark that the function has a non simple parameter list before parsing the pattern since the pattern can have function definitions. this->GetCurrentFunctionNode()->sxFnc.SetHasNonSimpleParameterList(); ParseNodePtr *const ppnodeVarSave = m_ppnodeVar; m_ppnodeVar = &pnodeFnc->sxFnc.pnodeVars; ParseNodePtr * ppNodeLex = m_currentBlockInfo->m_ppnodeLex; Assert(ppNodeLex != nullptr); ParseNodePtr paramPattern = nullptr; ParseNodePtr pnodePattern = ParseDestructuredLiteral<buildAST>(tkLET, true /*isDecl*/, false /*topLevel*/); // Instead of passing the STFormal all the way on many methods, it seems it is better to change the symbol type afterward. for (ParseNodePtr lexNode = *ppNodeLex; lexNode != nullptr; lexNode = lexNode->sxVar.pnodeNext) { Assert(lexNode->IsVarLetOrConst()); UpdateOrCheckForDuplicateInFormals(lexNode->sxVar.pid, &formals); lexNode->sxVar.sym->SetSymbolType(STFormal); if (m_currentNodeFunc != nullptr && lexNode->sxVar.pid == wellKnownPropertyPids.arguments) { m_currentNodeFunc->grfpn |= PNodeFlags::fpnArguments_overriddenByDecl; } } m_ppnodeVar = ppnodeVarSave; if (buildAST) { paramPattern = CreateParamPatternNode(pnodePattern); // Linking the current formal parameter (which is pattern parameter) with other formals. *m_ppnodeVar = paramPattern; paramPattern->sxParamPattern.pnodeNext = nullptr; m_ppnodeVar = &paramPattern->sxParamPattern.pnodeNext; } isBindingPattern = true; isNonSimpleParameterList = true; } else { IdentifierExpectedError(m_token); } } if (!isBindingPattern) { IdentPtr pid = m_token.GetIdentifier(m_phtbl); LPCOLESTR pNameHint = pid->Psz(); uint32 nameHintLength = pid->Cch(); uint32 nameHintOffset = 0; if (seenRestParameter) { this->GetCurrentFunctionNode()->sxFnc.SetHasNonSimpleParameterList(); if (flags & fFncOneArg) { // The parameter of a setter cannot be a rest parameter. Error(ERRUnexpectedEllipsis); } pnodeT = CreateDeclNode(knopVarDecl, pid, STFormal, false); pnodeT->sxVar.sym->SetIsNonSimpleParameter(true); if (buildAST) { // When only validating formals, we won't have a function node. pnodeFnc->sxFnc.pnodeRest = pnodeT; if (!isNonSimpleParameterList) { // This is the first non-simple parameter we've seen. We need to go back // and set the Symbols of all previous parameters. MapFormalsWithoutRest(m_currentNodeFunc, [&](ParseNodePtr pnodeArg) { pnodeArg->sxVar.sym->SetIsNonSimpleParameter(true); }); } } isNonSimpleParameterList = true; } else { pnodeT = CreateVarDeclNode(pid, STFormal, false, nullptr, false); if (isNonSimpleParameterList) { pnodeT->sxVar.sym->SetIsNonSimpleParameter(true); } } if (buildAST && pid == wellKnownPropertyPids.arguments) { // This formal parameter overrides the built-in 'arguments' object m_currentNodeFunc->grfpn |= PNodeFlags::fpnArguments_overriddenByDecl; } if (fStrictFormals) { UpdateOrCheckForDuplicateInFormals(pid, &formals); } m_pscan->Scan(); if (seenRestParameter && m_token.tk != tkRParen && m_token.tk != tkAsg) { Error(ERRRestLastArg); } if (m_token.tk == tkAsg && m_scriptContext->GetConfig()->IsES6DefaultArgsEnabled()) { if (seenRestParameter && m_scriptContext->GetConfig()->IsES6RestEnabled()) { Error(ERRRestWithDefault); } // In defer parse mode we have to flag the function node to indicate that it has default arguments // so that it will be considered for any syntax error scenario. // Also mark it before parsing the expression as it may contain functions. ParseNode* currentFncNode = GetCurrentFunctionNode(); if (!currentFncNode->sxFnc.HasDefaultArguments()) { currentFncNode->sxFnc.SetHasDefaultArguments(); currentFncNode->sxFnc.SetHasNonSimpleParameterList(); currentFncNode->sxFnc.firstDefaultArg = argPos; } m_pscan->Scan(); ParseNodePtr pnodeInit = ParseExpr<buildAST>(koplCma, nullptr, TRUE, FALSE, pNameHint, &nameHintLength, &nameHintOffset); if (buildAST && pnodeInit->nop == knopFncDecl) { Assert(nameHintLength >= nameHintOffset); pnodeInit->sxFnc.hint = pNameHint; pnodeInit->sxFnc.hintLength = nameHintLength; pnodeInit->sxFnc.hintOffset = nameHintOffset; } AnalysisAssert(pnodeT); pnodeT->sxVar.sym->SetIsNonSimpleParameter(true); if (!isNonSimpleParameterList) { if (buildAST) { // This is the first non-simple parameter we've seen. We need to go back // and set the Symbols of all previous parameters. MapFormalsWithoutRest(m_currentNodeFunc, [&](ParseNodePtr pnodeArg) { pnodeArg->sxVar.sym->SetIsNonSimpleParameter(true); }); } // There may be previous parameters that need to be checked for duplicates. isNonSimpleParameterList = true; } if (buildAST) { if (!m_currentNodeFunc->sxFnc.HasDefaultArguments()) { CHAKRATEL_LANGSTATS_INC_LANGFEATURECOUNT(DefaultArgFunction, m_scriptContext); } pnodeT->sxVar.pnodeInit = pnodeInit; pnodeT->ichLim = m_pscan->IchLimTok(); } } } if (isNonSimpleParameterList && m_currentScope->GetHasDuplicateFormals()) { Error(ERRFormalSame); } if (flags & fFncOneArg) { if (m_token.tk != tkRParen) { Error(ERRSetterMustHaveOneParameter); } break; //enforce only one arg } if (m_token.tk != tkComma) { break; } m_pscan->Scan(); if (m_token.tk == tkRParen && m_scriptContext->GetConfig()->IsES7TrailingCommaEnabled()) { break; } } if (seenRestParameter) { CHAKRATEL_LANGSTATS_INC_LANGFEATURECOUNT(Rest, m_scriptContext); } if (m_token.tk != tkRParen) { Error(ERRnoRparen); } if (this->GetCurrentFunctionNode()->sxFnc.CallsEval() || this->GetCurrentFunctionNode()->sxFnc.ChildCallsEval()) { if (!m_scriptContext->GetConfig()->IsES6DefaultArgsSplitScopeEnabled()) { Error(ERREvalNotSupportedInParamScope); } else { Assert(pnodeFnc->sxFnc.HasNonSimpleParameterList()); pnodeFnc->sxFnc.pnodeScopes->sxBlock.scope->SetCannotMergeWithBodyScope(); } } } Assert(m_token.tk == tkRParen); if (fLambda) { m_pscan->SetYieldIsKeyword(fPreviousYieldIsKeyword); m_pscan->SetAwaitIsKeyword(fPreviousAwaitIsKeyword); } }
CWE-119
null
517,562
55485120894369536181183193493859474867
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ParseNodePtr Parser::ParseCatch() { ParseNodePtr rootNode = nullptr; ParseNodePtr* ppnode = &rootNode; ParseNodePtr *ppnodeExprScopeSave = nullptr; ParseNodePtr pnode = nullptr; ParseNodePtr pnodeCatchScope = nullptr; StmtNest stmt; IdentPtr pidCatch = nullptr; //while (tkCATCH == m_token.tk) if (tkCATCH == m_token.tk) { charcount_t ichMin; if (buildAST) { ichMin = m_pscan->IchMinTok(); } m_pscan->Scan(); //catch ChkCurTok(tkLParen, ERRnoLparen); //catch( bool isPattern = false; if (tkID != m_token.tk) { isPattern = IsES6DestructuringEnabled() && IsPossiblePatternStart(); if (!isPattern) { IdentifierExpectedError(m_token); } } if (buildAST) { pnode = CreateNodeWithScanner<knopCatch>(ichMin); PushStmt<buildAST>(&stmt, pnode, knopCatch, nullptr, nullptr); *ppnode = pnode; ppnode = &pnode->sxCatch.pnodeNext; *ppnode = nullptr; } pnodeCatchScope = StartParseBlock<buildAST>(PnodeBlockType::Regular, isPattern ? ScopeType_CatchParamPattern : ScopeType_Catch); if (buildAST) { // Add this catch to the current scope list. if (m_ppnodeExprScope) { Assert(*m_ppnodeExprScope == nullptr); *m_ppnodeExprScope = pnode; m_ppnodeExprScope = &pnode->sxCatch.pnodeNext; } else { Assert(m_ppnodeScope); Assert(*m_ppnodeScope == nullptr); *m_ppnodeScope = pnode; m_ppnodeScope = &pnode->sxCatch.pnodeNext; } // Keep a list of function expressions (not declarations) at this scope. ppnodeExprScopeSave = m_ppnodeExprScope; m_ppnodeExprScope = &pnode->sxCatch.pnodeScopes; pnode->sxCatch.pnodeScopes = nullptr; } if (isPattern) { ParseNodePtr pnodePattern = ParseDestructuredLiteral<buildAST>(tkLET, true /*isDecl*/, true /*topLevel*/, DIC_ForceErrorOnInitializer); if (buildAST) { pnode->sxCatch.pnodeParam = CreateParamPatternNode(pnodePattern); Scope *scope = pnodeCatchScope->sxBlock.scope; pnode->sxCatch.scope = scope; } } else { if (IsStrictMode()) { IdentPtr pid = m_token.GetIdentifier(m_phtbl); if (pid == wellKnownPropertyPids.eval) { Error(ERREvalUsage); } else if (pid == wellKnownPropertyPids.arguments) { Error(ERRArgsUsage); } } pidCatch = m_token.GetIdentifier(m_phtbl); PidRefStack *ref = this->PushPidRef(pidCatch); ParseNodePtr pnodeParam = CreateNameNode(pidCatch); pnodeParam->sxPid.symRef = ref->GetSymRef(); const char16 *name = reinterpret_cast<const char16*>(pidCatch->Psz()); int nameLength = pidCatch->Cch(); SymbolName const symName(name, nameLength); Symbol *sym = Anew(&m_nodeAllocator, Symbol, symName, pnodeParam, STVariable); sym->SetPid(pidCatch); if (sym == nullptr) { Error(ERRnoMemory); } Assert(ref->GetSym() == nullptr); ref->SetSym(sym); Scope *scope = pnodeCatchScope->sxBlock.scope; scope->AddNewSymbol(sym); if (buildAST) { pnode->sxCatch.pnodeParam = pnodeParam; pnode->sxCatch.scope = scope; } m_pscan->Scan(); } charcount_t ichLim; if (buildAST) { ichLim = m_pscan->IchLimTok(); } ChkCurTok(tkRParen, ERRnoRparen); //catch(id[:expr]) if (tkLCurly != m_token.tk) { Error(ERRnoLcurly); } ParseNodePtr pnodeBody = ParseStatement<buildAST>(); //catch(id[:expr]) {block} if (buildAST) { pnode->sxCatch.pnodeBody = pnodeBody; pnode->ichLim = ichLim; } if (pnodeCatchScope != nullptr) { FinishParseBlock(pnodeCatchScope); } if (buildAST) { PopStmt(&stmt); // Restore the lists of function expression scopes. AssertMem(m_ppnodeExprScope); Assert(*m_ppnodeExprScope == nullptr); m_ppnodeExprScope = ppnodeExprScopeSave; } } return rootNode; }
CWE-119
null
517,563
152655273237210564067122935745085405868
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ParseNodePtr Parser::ParseStatement() { ParseNodePtr *ppnodeT; ParseNodePtr pnodeT; ParseNodePtr pnode = nullptr; LabelId* pLabelIdList = nullptr; charcount_t ichMin = 0; size_t iecpMin = 0; StmtNest stmt; StmtNest *pstmt; BOOL fForInOrOfOkay; BOOL fCanAssign; IdentPtr pid; uint fnop; ParseNodePtr pnodeLabel = nullptr; bool expressionStmt = false; bool isAsyncMethod = false; tokens tok; #if EXCEPTION_RECOVERY ParseNodePtr pParentTryCatch = nullptr; ParseNodePtr pTryBlock = nullptr; ParseNodePtr pTry = nullptr; ParseNodePtr pParentTryCatchBlock = nullptr; StmtNest stmtTryCatchBlock; StmtNest stmtTryCatch; StmtNest stmtTry; StmtNest stmtTryBlock; #endif if (buildAST) { #if EXCEPTION_RECOVERY if(Js::Configuration::Global.flags.SwallowExceptions) { // If we're swallowing exceptions, surround this statement with a try/catch block: // // Before: x.y = 3; // After: try { x.y = 3; } catch(__ehobj) { } // // This is done to force the runtime to recover from exceptions at the most granular // possible point. Recovering from EH dramatically improves coverage of testing via // fault injection. // create and push the try-catch node pParentTryCatchBlock = CreateBlockNode(); PushStmt<buildAST>(&stmtTryCatchBlock, pParentTryCatchBlock, knopBlock, nullptr, nullptr); pParentTryCatch = CreateNodeWithScanner<knopTryCatch>(); PushStmt<buildAST>(&stmtTryCatch, pParentTryCatch, knopTryCatch, nullptr, nullptr); // create and push a try node pTry = CreateNodeWithScanner<knopTry>(); PushStmt<buildAST>(&stmtTry, pTry, knopTry, nullptr, nullptr); pTryBlock = CreateBlockNode(); PushStmt<buildAST>(&stmtTryBlock, pTryBlock, knopBlock, nullptr, nullptr); // these nodes will be closed after the statement is parsed. } #endif // EXCEPTION_RECOVERY } EnsureStackAvailable(); LRestart: tok = m_token.tk; switch (tok) { case tkEOF: if (buildAST) { pnode = nullptr; } break; case tkFUNCTION: { LFunctionStatement: if (m_grfscr & fscrDeferredFncExpression) { // The top-level deferred function body was defined by a function expression whose parsing was deferred. We are now // parsing it, so unset the flag so that any nested functions are parsed normally. This flag is only applicable the // first time we see it. m_grfscr &= ~fscrDeferredFncExpression; pnode = ParseFncDecl<buildAST>(isAsyncMethod ? fFncAsync : fFncNoFlgs, nullptr); } else { pnode = ParseFncDecl<buildAST>(fFncDeclaration | (isAsyncMethod ? fFncAsync : fFncNoFlgs), nullptr); } if (isAsyncMethod) { pnode->sxFnc.cbMin = iecpMin; pnode->ichMin = ichMin; } break; } case tkCLASS: if (m_scriptContext->GetConfig()->IsES6ClassAndExtendsEnabled()) { pnode = ParseClassDecl<buildAST>(TRUE, nullptr, nullptr, nullptr); } else { goto LDefaultToken; } break; case tkID: if (m_token.GetIdentifier(m_phtbl) == wellKnownPropertyPids.let) { // We see "let" at the start of a statement. This could either be a declaration or an identifier // reference. The next token determines which. RestorePoint parsedLet; m_pscan->Capture(&parsedLet); ichMin = m_pscan->IchMinTok(); m_pscan->Scan(); if (this->NextTokenConfirmsLetDecl()) { pnode = ParseVariableDeclaration<buildAST>(tkLET, ichMin); goto LNeedTerminator; } m_pscan->SeekTo(parsedLet); } else if (m_token.GetIdentifier(m_phtbl) == wellKnownPropertyPids.async && m_scriptContext->GetConfig()->IsES7AsyncAndAwaitEnabled()) { RestorePoint parsedAsync; m_pscan->Capture(&parsedAsync); ichMin = m_pscan->IchMinTok(); iecpMin = m_pscan->IecpMinTok(); m_pscan->Scan(); if (m_token.tk == tkFUNCTION && !m_pscan->FHadNewLine()) { isAsyncMethod = true; goto LFunctionStatement; } m_pscan->SeekTo(parsedAsync); } goto LDefaultToken; case tkCONST: case tkLET: ichMin = m_pscan->IchMinTok(); m_pscan->Scan(); pnode = ParseVariableDeclaration<buildAST>(tok, ichMin); goto LNeedTerminator; case tkVAR: ichMin = m_pscan->IchMinTok(); m_pscan->Scan(); pnode = ParseVariableDeclaration<buildAST>(tok, ichMin); goto LNeedTerminator; case tkFOR: { ParseNodePtr pnodeBlock = nullptr; ParseNodePtr *ppnodeScopeSave = nullptr; ParseNodePtr *ppnodeExprScopeSave = nullptr; ichMin = m_pscan->IchMinTok(); ChkNxtTok(tkLParen, ERRnoLparen); pnodeBlock = StartParseBlock<buildAST>(PnodeBlockType::Regular, ScopeType_Block); if (buildAST) { PushFuncBlockScope(pnodeBlock, &ppnodeScopeSave, &ppnodeExprScopeSave); } RestorePoint startExprOrIdentifier; fForInOrOfOkay = TRUE; fCanAssign = TRUE; tok = m_token.tk; BOOL nativeForOkay = TRUE; switch (tok) { case tkID: if (m_token.GetIdentifier(m_phtbl) == wellKnownPropertyPids.let) { // We see "let" in the init part of a for loop. This could either be a declaration or an identifier // reference. The next token determines which. RestorePoint parsedLet; m_pscan->Capture(&parsedLet); auto ichMinInner = m_pscan->IchMinTok(); m_pscan->Scan(); if (IsPossiblePatternStart()) { m_pscan->Capture(&startExprOrIdentifier); } if (this->NextTokenConfirmsLetDecl() && m_token.tk != tkIN) { pnodeT = ParseVariableDeclaration<buildAST>(tkLET, ichMinInner , /*fAllowIn = */FALSE , /*pfForInOk = */&fForInOrOfOkay , /*singleDefOnly*/FALSE , /*allowInit*/TRUE , /*isTopVarParse*/TRUE , /*isFor*/TRUE , &nativeForOkay); break; } m_pscan->SeekTo(parsedLet); } goto LDefaultTokenFor; case tkLET: case tkCONST: case tkVAR: { auto ichMinInner = m_pscan->IchMinTok(); m_pscan->Scan(); if (IsPossiblePatternStart()) { m_pscan->Capture(&startExprOrIdentifier); } pnodeT = ParseVariableDeclaration<buildAST>(tok, ichMinInner , /*fAllowIn = */FALSE , /*pfForInOk = */&fForInOrOfOkay , /*singleDefOnly*/FALSE , /*allowInit*/TRUE , /*isTopVarParse*/TRUE , /*isFor*/TRUE , &nativeForOkay); } break; case tkSColon: pnodeT = nullptr; fForInOrOfOkay = FALSE; break; default: { LDefaultTokenFor: RestorePoint exprStart; tokens beforeToken = tok; m_pscan->Capture(&exprStart); if (IsPossiblePatternStart()) { m_pscan->Capture(&startExprOrIdentifier); } bool fLikelyPattern = false; if (IsES6DestructuringEnabled() && (beforeToken == tkLBrack || beforeToken == tkLCurly)) { pnodeT = ParseExpr<buildAST>(koplNo, &fCanAssign, /*fAllowIn = */FALSE, /*fAllowEllipsis*/FALSE, /*pHint*/nullptr, /*pHintLength*/nullptr, /*pShortNameOffset*/nullptr, /*pToken*/nullptr, /**fUnaryOrParen*/false, &fLikelyPattern); } else { pnodeT = ParseExpr<buildAST>(koplNo, &fCanAssign, /*fAllowIn = */FALSE); } // We would veryfiy the grammar as destructuring grammar only when for..in/of case. As in the native for loop case the above ParseExpr call // has already converted them appropriately. if (fLikelyPattern && TokIsForInOrForOf()) { m_pscan->SeekTo(exprStart); ParseDestructuredLiteralWithScopeSave(tkNone, false/*isDecl*/, false /*topLevel*/, DIC_None, false /*allowIn*/); if (buildAST) { pnodeT = ConvertToPattern(pnodeT); } } if (buildAST) { Assert(pnodeT); pnodeT->isUsed = false; } } break; } if (TokIsForInOrForOf()) { bool isForOf = (m_token.tk != tkIN); Assert(!isForOf || (m_token.tk == tkID && m_token.GetIdentifier(m_phtbl) == wellKnownPropertyPids.of)); if ((buildAST && nullptr == pnodeT) || !fForInOrOfOkay) { if (isForOf) { Error(ERRForOfNoInitAllowed); } else { Error(ERRForInNoInitAllowed); } } if (!fCanAssign && PHASE_ON1(Js::EarlyReferenceErrorsPhase)) { Error(JSERR_CantAssignTo); } m_pscan->Scan(); ParseNodePtr pnodeObj = ParseExpr<buildAST>(isForOf ? koplCma : koplNo); charcount_t ichLim = m_pscan->IchLimTok(); ChkCurTok(tkRParen, ERRnoRparen); if (buildAST) { if (isForOf) { pnode = CreateNodeWithScanner<knopForOf>(ichMin); } else { pnode = CreateNodeWithScanner<knopForIn>(ichMin); } pnode->sxForInOrForOf.pnodeBlock = pnodeBlock; pnode->sxForInOrForOf.pnodeLval = pnodeT; pnode->sxForInOrForOf.pnodeObj = pnodeObj; pnode->ichLim = ichLim; TrackAssignment<true>(pnodeT, nullptr); } PushStmt<buildAST>(&stmt, pnode, isForOf ? knopForOf : knopForIn, pnodeLabel, pLabelIdList); ParseNodePtr pnodeBody = ParseStatement<buildAST>(); if (buildAST) { pnode->sxForInOrForOf.pnodeBody = pnodeBody; } PopStmt(&stmt); } else { if (!nativeForOkay) { Error(ERRDestructInit); } ChkCurTok(tkSColon, ERRnoSemic); ParseNodePtr pnodeCond = nullptr; if (m_token.tk != tkSColon) { pnodeCond = ParseExpr<buildAST>(); if (m_token.tk != tkSColon) { Error(ERRnoSemic); } } tokens tk; tk = m_pscan->Scan(); ParseNodePtr pnodeIncr = nullptr; if (tk != tkRParen) { pnodeIncr = ParseExpr<buildAST>(); if(pnodeIncr) { pnodeIncr->isUsed = false; } } charcount_t ichLim = m_pscan->IchLimTok(); ChkCurTok(tkRParen, ERRnoRparen); if (buildAST) { pnode = CreateNodeWithScanner<knopFor>(ichMin); pnode->sxFor.pnodeBlock = pnodeBlock; pnode->sxFor.pnodeInverted= nullptr; pnode->sxFor.pnodeInit = pnodeT; pnode->sxFor.pnodeCond = pnodeCond; pnode->sxFor.pnodeIncr = pnodeIncr; pnode->ichLim = ichLim; } PushStmt<buildAST>(&stmt, pnode, knopFor, pnodeLabel, pLabelIdList); ParseNodePtr pnodeBody = ParseStatement<buildAST>(); if (buildAST) { pnode->sxFor.pnodeBody = pnodeBody; } PopStmt(&stmt); } if (buildAST) { PopFuncBlockScope(ppnodeScopeSave, ppnodeExprScopeSave); } FinishParseBlock(pnodeBlock); break; } case tkSWITCH: { BOOL fSeenDefault = FALSE; ParseNodePtr pnodeBlock = nullptr; ParseNodePtr *ppnodeScopeSave = nullptr; ParseNodePtr *ppnodeExprScopeSave = nullptr; ichMin = m_pscan->IchMinTok(); ChkNxtTok(tkLParen, ERRnoLparen); ParseNodePtr pnodeVal = ParseExpr<buildAST>(); charcount_t ichLim = m_pscan->IchLimTok(); ChkCurTok(tkRParen, ERRnoRparen); ChkCurTok(tkLCurly, ERRnoLcurly); if (buildAST) { pnode = CreateNodeWithScanner<knopSwitch>(ichMin); } PushStmt<buildAST>(&stmt, pnode, knopSwitch, pnodeLabel, pLabelIdList); pnodeBlock = StartParseBlock<buildAST>(PnodeBlockType::Regular, ScopeType_Block, nullptr, pLabelIdList); if (buildAST) { pnode->sxSwitch.pnodeVal = pnodeVal; pnode->sxSwitch.pnodeBlock = pnodeBlock; pnode->ichLim = ichLim; PushFuncBlockScope(pnode->sxSwitch.pnodeBlock, &ppnodeScopeSave, &ppnodeExprScopeSave); pnode->sxSwitch.pnodeDefault = nullptr; ppnodeT = &pnode->sxSwitch.pnodeCases; } for (;;) { ParseNodePtr pnodeBody = nullptr; switch (m_token.tk) { default: goto LEndSwitch; case tkCASE: { pnodeT = this->ParseCase<buildAST>(&pnodeBody); break; } case tkDEFAULT: if (fSeenDefault) { Error(ERRdupDefault); // No recovery necessary since this is a semantic, not structural, error } fSeenDefault = TRUE; charcount_t ichMinT = m_pscan->IchMinTok(); m_pscan->Scan(); charcount_t ichMinInner = m_pscan->IchLimTok(); ChkCurTok(tkColon, ERRnoColon); if (buildAST) { pnodeT = CreateNodeWithScanner<knopCase>(ichMinT); pnode->sxSwitch.pnodeDefault = pnodeT; pnodeT->ichLim = ichMinInner; pnodeT->sxCase.pnodeExpr = nullptr; } ParseStmtList<buildAST>(&pnodeBody); break; } if (buildAST) { if (pnodeBody) { // Create a block node to contain the statement list for this case. // This helps us insert byte code to return the right value from // global/eval code. pnodeT->sxCase.pnodeBody = CreateBlockNode(pnodeT->ichMin, pnodeT->ichLim); pnodeT->sxCase.pnodeBody->grfpn |= PNodeFlags::fpnSyntheticNode; // block is not a user specifier block pnodeT->sxCase.pnodeBody->sxBlock.pnodeStmt = pnodeBody; } else { pnodeT->sxCase.pnodeBody = nullptr; } *ppnodeT = pnodeT; ppnodeT = &pnodeT->sxCase.pnodeNext; } } LEndSwitch: ChkCurTok(tkRCurly, ERRnoRcurly); if (buildAST) { *ppnodeT = nullptr; PopFuncBlockScope(ppnodeScopeSave, ppnodeExprScopeSave); FinishParseBlock(pnode->sxSwitch.pnodeBlock); } else { FinishParseBlock(pnodeBlock); } PopStmt(&stmt); break; } case tkWHILE: { ichMin = m_pscan->IchMinTok(); ChkNxtTok(tkLParen, ERRnoLparen); ParseNodePtr pnodeCond = ParseExpr<buildAST>(); charcount_t ichLim = m_pscan->IchLimTok(); ChkCurTok(tkRParen, ERRnoRparen); if (buildAST) { pnode = CreateNodeWithScanner<knopWhile>(ichMin); pnode->sxWhile.pnodeCond = pnodeCond; pnode->ichLim = ichLim; } PushStmt<buildAST>(&stmt, pnode, knopWhile, pnodeLabel, pLabelIdList); ParseNodePtr pnodeBody = ParseStatement<buildAST>(); PopStmt(&stmt); if (buildAST) { pnode->sxWhile.pnodeBody = pnodeBody; } break; } case tkDO: { if (buildAST) { pnode = CreateNodeWithScanner<knopDoWhile>(); } PushStmt<buildAST>(&stmt, pnode, knopDoWhile, pnodeLabel, pLabelIdList); m_pscan->Scan(); ParseNodePtr pnodeBody = ParseStatement<buildAST>(); PopStmt(&stmt); charcount_t ichMinT = m_pscan->IchMinTok(); ChkCurTok(tkWHILE, ERRnoWhile); ChkCurTok(tkLParen, ERRnoLparen); ParseNodePtr pnodeCond = ParseExpr<buildAST>(); charcount_t ichLim = m_pscan->IchLimTok(); ChkCurTok(tkRParen, ERRnoRparen); if (buildAST) { pnode->sxWhile.pnodeBody = pnodeBody; pnode->sxWhile.pnodeCond = pnodeCond; pnode->ichLim = ichLim; pnode->ichMin = ichMinT; } // REVIEW: Allow do...while statements to be embedded in other compound statements like if..else, or do..while? // goto LNeedTerminator; // For now just eat the trailing semicolon if present. if (m_token.tk == tkSColon) { if (pnode) { pnode->grfpn |= PNodeFlags::fpnExplicitSemicolon; } m_pscan->Scan(); } else if (pnode) { pnode->grfpn |= PNodeFlags::fpnAutomaticSemicolon; } break; } case tkIF: { ichMin = m_pscan->IchMinTok(); ChkNxtTok(tkLParen, ERRnoLparen); ParseNodePtr pnodeCond = ParseExpr<buildAST>(); if (buildAST) { pnode = CreateNodeWithScanner<knopIf>(ichMin); pnode->ichLim = m_pscan->IchLimTok(); pnode->sxIf.pnodeCond = pnodeCond; } ChkCurTok(tkRParen, ERRnoRparen); PushStmt<buildAST>(&stmt, pnode, knopIf, pnodeLabel, pLabelIdList); ParseNodePtr pnodeTrue = ParseStatement<buildAST>(); ParseNodePtr pnodeFalse = nullptr; if (m_token.tk == tkELSE) { m_pscan->Scan(); pnodeFalse = ParseStatement<buildAST>(); } if (buildAST) { pnode->sxIf.pnodeTrue = pnodeTrue; pnode->sxIf.pnodeFalse = pnodeFalse; } PopStmt(&stmt); break; } case tkTRY: { if (buildAST) { pnode = CreateBlockNode(); pnode->grfpn |= PNodeFlags::fpnSyntheticNode; // block is not a user specifier block } PushStmt<buildAST>(&stmt, pnode, knopBlock, pnodeLabel, pLabelIdList); ParseNodePtr pnodeStmt = ParseTryCatchFinally<buildAST>(); if (buildAST) { pnode->sxBlock.pnodeStmt = pnodeStmt; } PopStmt(&stmt); break; } case tkWITH: { if ( IsStrictMode() ) { Error(ERRES5NoWith); } if (m_currentNodeFunc) { GetCurrentFunctionNode()->sxFnc.SetHasWithStmt(); // Used by DeferNested } ichMin = m_pscan->IchMinTok(); ChkNxtTok(tkLParen, ERRnoLparen); ParseNodePtr pnodeObj = ParseExpr<buildAST>(); if (!buildAST) { m_scopeCountNoAst++; } charcount_t ichLim = m_pscan->IchLimTok(); ChkCurTok(tkRParen, ERRnoRparen); if (buildAST) { pnode = CreateNodeWithScanner<knopWith>(ichMin); } PushStmt<buildAST>(&stmt, pnode, knopWith, pnodeLabel, pLabelIdList); ParseNodePtr *ppnodeExprScopeSave = nullptr; if (buildAST) { pnode->sxWith.pnodeObj = pnodeObj; this->CheckArguments(pnode->sxWith.pnodeObj); if (m_ppnodeExprScope) { Assert(*m_ppnodeExprScope == nullptr); *m_ppnodeExprScope = pnode; m_ppnodeExprScope = &pnode->sxWith.pnodeNext; } else { Assert(m_ppnodeScope); Assert(*m_ppnodeScope == nullptr); *m_ppnodeScope = pnode; m_ppnodeScope = &pnode->sxWith.pnodeNext; } pnode->sxWith.pnodeNext = nullptr; pnode->sxWith.scope = nullptr; ppnodeExprScopeSave = m_ppnodeExprScope; m_ppnodeExprScope = &pnode->sxWith.pnodeScopes; pnode->sxWith.pnodeScopes = nullptr; pnode->ichLim = ichLim; } PushBlockInfo(CreateBlockNode()); PushDynamicBlock(); ParseNodePtr pnodeBody = ParseStatement<buildAST>(); if (buildAST) { pnode->sxWith.pnodeBody = pnodeBody; m_ppnodeExprScope = ppnodeExprScopeSave; } else { m_scopeCountNoAst--; } // The dynamic block is not stored in the actual parse tree and so will not // be visited by the byte code generator. Grab the callsEval flag off it and // pass on to outer block in case of: // with (...) eval(...); // i.e. blockless form of with bool callsEval = GetCurrentBlock()->sxBlock.GetCallsEval(); PopBlockInfo(); if (callsEval) { // be careful not to overwrite an existing true with false GetCurrentBlock()->sxBlock.SetCallsEval(true); } PopStmt(&stmt); break; } case tkLCurly: pnode = ParseBlock<buildAST>(pnodeLabel, pLabelIdList); break; case tkSColon: pnode = nullptr; m_pscan->Scan(); break; case tkBREAK: if (buildAST) { pnode = CreateNodeWithScanner<knopBreak>(); } fnop = fnopBreak; goto LGetJumpStatement; case tkCONTINUE: if (buildAST) { pnode = CreateNode(knopContinue); } fnop = fnopContinue; LGetJumpStatement: m_pscan->ScanForcingPid(); if (tkID == m_token.tk && !m_pscan->FHadNewLine()) { // Labeled break or continue. pid = m_token.GetIdentifier(m_phtbl); AssertMem(pid); if (buildAST) { pnode->sxJump.hasExplicitTarget=true; pnode->ichLim = m_pscan->IchLimTok(); m_pscan->Scan(); PushStmt<buildAST>(&stmt, pnode, pnode->nop, pnodeLabel, nullptr); Assert(pnode->sxStmt.grfnop == 0); for (pstmt = m_pstmtCur; nullptr != pstmt; pstmt = pstmt->pstmtOuter) { AssertNodeMem(pstmt->pnodeStmt); AssertNodeMemN(pstmt->pnodeLab); for (pnodeT = pstmt->pnodeLab; nullptr != pnodeT; pnodeT = pnodeT->sxLabel.pnodeNext) { Assert(knopLabel == pnodeT->nop); if (pid == pnodeT->sxLabel.pid) { // Found the label. Make sure we can use it. We can // break out of any statement, but we can only // continue loops. if (fnop == fnopContinue && !(pstmt->pnodeStmt->Grfnop() & fnop)) { Error(ERRbadContinue); } else { pstmt->pnodeStmt->sxStmt.grfnop |= fnop; pnode->sxJump.pnodeTarget = pstmt->pnodeStmt; } PopStmt(&stmt); goto LNeedTerminator; } } pnode->sxStmt.grfnop |= (pstmt->pnodeStmt->Grfnop() & fnopCleanup); } } else { m_pscan->Scan(); for (pstmt = m_pstmtCur; pstmt; pstmt = pstmt->pstmtOuter) { LabelId* pLabelId; for (pLabelId = pstmt->pLabelId; pLabelId; pLabelId = pLabelId->next) { if (pid == pLabelId->pid) { // Found the label. Make sure we can use it. We can // break out of any statement, but we can only // continue loops. if (fnop == fnopContinue && !(ParseNode::Grfnop(pstmt->op) & fnop)) { Error(ERRbadContinue); } goto LNeedTerminator; } } } } Error(ERRnoLabel); } else { // If we're doing a fast scan, we're not tracking labels, so we can't accurately do this analysis. // Let the thread that's doing the full parse detect the error, if there is one. if (!this->m_doingFastScan) { // Unlabeled break or continue. if (buildAST) { pnode->sxJump.hasExplicitTarget=false; PushStmt<buildAST>(&stmt, pnode, pnode->nop, pnodeLabel, nullptr); Assert(pnode->sxStmt.grfnop == 0); } for (pstmt = m_pstmtCur; nullptr != pstmt; pstmt = pstmt->pstmtOuter) { if (buildAST) { AnalysisAssert(pstmt->pnodeStmt); if (pstmt->pnodeStmt->Grfnop() & fnop) { pstmt->pnodeStmt->sxStmt.grfnop |= fnop; pnode->sxJump.pnodeTarget = pstmt->pnodeStmt; PopStmt(&stmt); goto LNeedTerminator; } pnode->sxStmt.grfnop |= (pstmt->pnodeStmt->Grfnop() & fnopCleanup); } else { if (ParseNode::Grfnop(pstmt->GetNop()) & fnop) { if (!pstmt->isDeferred) { AnalysisAssert(pstmt->pnodeStmt); pstmt->pnodeStmt->sxStmt.grfnop |= fnop; } goto LNeedTerminator; } } } Error(fnop == fnopBreak ? ERRbadBreak : ERRbadContinue); } goto LNeedTerminator; } case tkRETURN: { if (buildAST) { if (nullptr == m_currentNodeFunc) { Error(ERRbadReturn); } pnode = CreateNodeWithScanner<knopReturn>(); } m_pscan->Scan(); ParseNodePtr pnodeExpr = nullptr; ParseOptionalExpr<buildAST>(&pnodeExpr, true); if (buildAST) { pnode->sxReturn.pnodeExpr = pnodeExpr; if (pnodeExpr) { this->CheckArguments(pnode->sxReturn.pnodeExpr); pnode->ichLim = pnode->sxReturn.pnodeExpr->ichLim; } // See if return should call finally PushStmt<buildAST>(&stmt, pnode, knopReturn, pnodeLabel, nullptr); Assert(pnode->sxStmt.grfnop == 0); for (pstmt = m_pstmtCur; nullptr != pstmt; pstmt = pstmt->pstmtOuter) { AssertNodeMem(pstmt->pnodeStmt); AssertNodeMemN(pstmt->pnodeLab); if (pstmt->pnodeStmt->Grfnop() & fnopCleanup) { pnode->sxStmt.grfnop |= fnopCleanup; break; } } PopStmt(&stmt); } goto LNeedTerminator; } case tkTHROW: { if (buildAST) { pnode = CreateUniNode(knopThrow, nullptr); } m_pscan->Scan(); ParseNodePtr pnode1 = nullptr; if (m_token.tk != tkSColon && m_token.tk != tkRCurly && !m_pscan->FHadNewLine()) { pnode1 = ParseExpr<buildAST>(); } else { Error(ERRdanglingThrow); } if (buildAST) { pnode->sxUni.pnode1 = pnode1; if (pnode1) { this->CheckArguments(pnode->sxUni.pnode1); pnode->ichLim = pnode->sxUni.pnode1->ichLim; } } goto LNeedTerminator; } case tkDEBUGGER: if (buildAST) { pnode = CreateNodeWithScanner<knopDebugger>(); } m_pscan->Scan(); goto LNeedTerminator; case tkIMPORT: if (!(m_grfscr & fscrIsModuleCode)) { goto LDefaultToken; } pnode = ParseImportDeclaration<buildAST>(); goto LNeedTerminator; case tkEXPORT: if (!(m_grfscr & fscrIsModuleCode)) { goto LDefaultToken; } pnode = ParseExportDeclaration<buildAST>(); goto LNeedTerminator; LDefaultToken: default: { // First check for a label via lookahead. If not found, // rewind and reparse as expression statement. if (m_token.tk == tkLParen || m_token.tk == tkID) { RestorePoint idStart; m_pscan->Capture(&idStart); // Support legacy behavior of allowing parentheses around label identifiers. // Require balanced parentheses for correcting parsing. Note unbalanced cases // take care of themselves correctly by resulting in rewind and parsing as // an expression statement. // REVIEW[ianhall]: Can this legacy functionality be removed? Chrome does not support this parsing behavior. uint parenCount = 0; while (m_token.tk == tkLParen) { parenCount += 1; m_pscan->Scan(); } if (m_token.tk == tkID) { IdentToken tokInner; tokInner.tk = tkID; tokInner.ichMin = m_pscan->IchMinTok(); tokInner.ichLim = m_pscan->IchLimTok(); tokInner.pid = m_token.GetIdentifier(m_phtbl); m_pscan->Scan(); while (parenCount > 0 && m_token.tk == tkRParen) { parenCount -= 1; m_pscan->Scan(); } if (parenCount == 0 && m_token.tk == tkColon) { // We have a label. // TODO[ianhall]: Refactor to eliminate separate code paths for buildAST and !buildAST if (buildAST) { // See if the label is already defined. if (nullptr != PnodeLabel(tokInner.pid, pnodeLabel)) { Error(ERRbadLabel); } pnodeT = CreateNodeWithScanner<knopLabel>(); pnodeT->sxLabel.pid = tokInner.pid; pnodeT->sxLabel.pnodeNext = pnodeLabel; pnodeLabel = pnodeT; } else { // See if the label is already defined. if (PnodeLabelNoAST(&tokInner, pLabelIdList)) { Error(ERRbadLabel); } LabelId* pLabelId = CreateLabelId(&tokInner); pLabelId->next = pLabelIdList; pLabelIdList = pLabelId; } m_pscan->Scan(); goto LRestart; } } // No label, rewind back to the tkID and parse an expression m_pscan->SeekTo(idStart); } // Must be an expression statement. pnode = ParseExpr<buildAST>(); if (m_hasDeferredShorthandInitError) { Error(ERRnoColon); } if (buildAST) { expressionStmt = true; AnalysisAssert(pnode); pnode->isUsed = false; } } LNeedTerminator: // Need a semicolon, new-line, } or end-of-file. // We digest a semicolon if it's there. switch (m_token.tk) { case tkSColon: m_pscan->Scan(); if (pnode!= nullptr) pnode->grfpn |= PNodeFlags::fpnExplicitSemicolon; break; case tkEOF: case tkRCurly: if (pnode!= nullptr) pnode->grfpn |= PNodeFlags::fpnAutomaticSemicolon; break; default: if (!m_pscan->FHadNewLine()) { Error(ERRnoSemic); } else { if (pnode!= nullptr) pnode->grfpn |= PNodeFlags::fpnAutomaticSemicolon; } break; } break; } if (m_hasDeferredShorthandInitError) { Error(ERRnoColon); } if (buildAST) { // All non expression statements excluded from the "this.x" optimization // Another check while parsing expressions if (!expressionStmt) { if (m_currentNodeFunc) { m_currentNodeFunc->sxFnc.SetHasNonThisStmt(); } else if (m_currentNodeProg) { m_currentNodeProg->sxFnc.SetHasNonThisStmt(); } } #if EXCEPTION_RECOVERY // close the try/catch block if(Js::Configuration::Global.flags.SwallowExceptions) { // pop the try block and fill in the body PopStmt(&stmtTryBlock); pTryBlock->sxBlock.pnodeStmt = pnode; PopStmt(&stmtTry); if(pnode != nullptr) { pTry->ichLim = pnode->ichLim; } pTry->sxTry.pnodeBody = pTryBlock; // create a catch block with an empty body StmtNest stmtCatch; ParseNodePtr pCatch; pCatch = CreateNodeWithScanner<knopCatch>(); PushStmt<buildAST>(&stmtCatch, pCatch, knopCatch, nullptr, nullptr); pCatch->sxCatch.pnodeBody = nullptr; if(pnode != nullptr) { pCatch->ichLim = pnode->ichLim; } pCatch->sxCatch.grfnop = 0; pCatch->sxCatch.pnodeNext = nullptr; // create a fake name for the catch var. const WCHAR *uniqueNameStr = _u("__ehobj"); IdentPtr uniqueName = m_phtbl->PidHashNameLen(uniqueNameStr, static_cast<int32>(wcslen(uniqueNameStr))); pCatch->sxCatch.pnodeParam = CreateNameNode(uniqueName); // Add this catch to the current list. We don't bother adjusting the catch and function expression // lists here because the catch is just an empty statement. if (m_ppnodeExprScope) { Assert(*m_ppnodeExprScope == nullptr); *m_ppnodeExprScope = pCatch; m_ppnodeExprScope = &pCatch->sxCatch.pnodeNext; } else { Assert(m_ppnodeScope); Assert(*m_ppnodeScope == nullptr); *m_ppnodeScope = pCatch; m_ppnodeScope = &pCatch->sxCatch.pnodeNext; } pCatch->sxCatch.pnodeScopes = nullptr; PopStmt(&stmtCatch); // fill in and pop the try-catch pParentTryCatch->sxTryCatch.pnodeTry = pTry; pParentTryCatch->sxTryCatch.pnodeCatch = pCatch; PopStmt(&stmtTryCatch); PopStmt(&stmtTryCatchBlock); // replace the node that's being returned pParentTryCatchBlock->sxBlock.pnodeStmt = pParentTryCatch; pnode = pParentTryCatchBlock; } #endif // EXCEPTION_RECOVERY } return pnode; }
CWE-119
null
517,564
287053947639629828195738445927569127115
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ULONG Parser::GetDeferralThreshold(bool isProfileLoaded) { #ifdef ENABLE_DEBUG_CONFIG_OPTIONS if (CONFIG_FLAG(ForceDeferParse) || PHASE_FORCE1(Js::DeferParsePhase) || Js::Configuration::Global.flags.IsEnabled(Js::ForceUndoDeferFlag)) { return 0; } else if (Js::Configuration::Global.flags.IsEnabled(Js::DeferParseFlag)) { return Js::Configuration::Global.flags.DeferParse; } else #endif { if (isProfileLoaded) { return DEFAULT_CONFIG_ProfileBasedDeferParseThreshold; } return DEFAULT_CONFIG_DeferParseThreshold; } }
CWE-119
null
517,565
218433767636337920434913043745362024024
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ParseNodePtr Parser::ParseDefaultExportClause() { Assert(m_token.tk == tkDEFAULT); m_pscan->Scan(); ParseNodePtr pnode = nullptr; ushort flags = fFncNoFlgs; switch (m_token.tk) { case tkCLASS: { if (!m_scriptContext->GetConfig()->IsES6ClassAndExtendsEnabled()) { goto LDefault; } // Before we parse the class itself we need to know if the class has an identifier name. // If it does, we'll treat this class as an ordinary class declaration which will bind // it to that name. Otherwise the class should parse as a nameless class expression and // bind only to the export binding. BOOL classHasName = false; RestorePoint parsedClass; m_pscan->Capture(&parsedClass); m_pscan->Scan(); if (m_token.tk == tkID) { classHasName = true; } m_pscan->SeekTo(parsedClass); pnode = ParseClassDecl<buildAST>(classHasName, nullptr, nullptr, nullptr); if (buildAST) { AnalysisAssert(pnode != nullptr); Assert(pnode->nop == knopClassDecl); pnode->sxClass.SetIsDefaultModuleExport(true); } break; } case tkID: // If we parsed an async token, it could either modify the next token (if it is a // function token) or it could be an identifier (let async = 0; export default async;). // To handle both cases, when we parse an async token we need to keep the parser state // and rewind if the next token is not function. if (wellKnownPropertyPids.async == m_token.GetIdentifier(m_phtbl)) { RestorePoint parsedAsync; m_pscan->Capture(&parsedAsync); m_pscan->Scan(); if (m_token.tk == tkFUNCTION) { // Token after async is function, consume the async token and continue to parse the // function as an async function. flags |= fFncAsync; goto LFunction; } // Token after async is not function, no idea what the async token is supposed to mean // so rewind and let the default case handle it. m_pscan->SeekTo(parsedAsync); } goto LDefault; break; case tkFUNCTION: { LFunction: // We just parsed a function token but we need to figure out if the function // has an identifier name or not before we call the helper. RestorePoint parsedFunction; m_pscan->Capture(&parsedFunction); m_pscan->Scan(); if (m_token.tk == tkStar) { // If we saw 'function*' that indicates we are going to parse a generator, // but doesn't tell us if the generator has an identifier or not. // Skip the '*' token for now as it doesn't matter yet. m_pscan->Scan(); } // We say that if the function has an identifier name, it is a 'normal' declaration // and should create a binding to that identifier as well as one for our default export. if (m_token.tk == tkID) { flags |= fFncDeclaration; } else { flags |= fFncNoName; } // Rewind back to the function token and let the helper handle the parsing. m_pscan->SeekTo(parsedFunction); pnode = ParseFncDecl<buildAST>(flags); if (buildAST) { AnalysisAssert(pnode != nullptr); Assert(pnode->nop == knopFncDecl); pnode->sxFnc.SetIsDefaultModuleExport(true); } break; } default: LDefault: { ParseNodePtr pnodeExpression = ParseExpr<buildAST>(); // Consider: Can we detect this syntax error earlier? if (pnodeExpression && pnodeExpression->nop == knopComma) { Error(ERRsyntax); } if (buildAST) { AnalysisAssert(pnodeExpression != nullptr); // Mark this node as the default module export. We need to make sure it is put into the correct // module export slot when we emit the node. pnode = CreateNode(knopExportDefault); pnode->sxExportDefault.pnodeExpr = pnodeExpression; } break; } } IdentPtr exportName = wellKnownPropertyPids._default; IdentPtr localName = wellKnownPropertyPids._starDefaultStar; AddModuleImportOrExportEntry(EnsureModuleLocalExportEntryList(), nullptr, localName, exportName, nullptr); return pnode; }
CWE-119
null
517,566
328924244500509882734295272794785997848
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ModuleImportOrExportEntryList* Parser::GetModuleImportEntryList() { return m_currentNodeProg->sxModule.importEntries; }
CWE-119
null
517,567
10550554868262862729205975769618117436
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ParseNodePtr Parser::CreateNode(OpCode nop, charcount_t ichMin, charcount_t ichLim) { Assert(!this->m_deferringAST); Assert(nop >= 0 && nop < knopLim); ParseNodePtr pnode; __analysis_assume(nop < knopLim); int cb = nop >= 0 && nop < knopLim ? g_mpnopcbNode[nop] : kcbPnNone; pnode = (ParseNodePtr)m_nodeAllocator.Alloc(cb); Assert(pnode); Assert(m_pCurrentAstSize != NULL); *m_pCurrentAstSize += cb; InitNode(nop,pnode); pnode->ichMin = ichMin; pnode->ichLim = ichLim; return pnode; }
CWE-119
null
517,568
168410523792426168779485790111162059289
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ParseNodePtr Parser::ParseMetaProperty(tokens metaParentKeyword, charcount_t ichMin, _Out_opt_ BOOL* pfCanAssign) { AssertMsg(metaParentKeyword == tkNEW, "Only supported for tkNEW parent keywords"); AssertMsg(this->m_token.tk == tkDot, "We must be currently sitting on the dot after the parent keyword"); m_pscan->Scan(); if (this->m_token.tk == tkID && this->m_token.GetIdentifier(m_phtbl) == this->GetTargetPid()) { ThrowNewTargetSyntaxErrForGlobalScope(); if (pfCanAssign) { *pfCanAssign = FALSE; } if (buildAST) { return CreateNodeWithScanner<knopNewTarget>(ichMin); } } else { Error(ERRsyntax); } return nullptr; }
CWE-119
null
517,569
33054465153958126295169878446388989215
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
LPCOLESTR Parser::AppendNameHints(IdentPtr left, IdentPtr right, uint32 *pNameLength, uint32 *pShortNameOffset, bool ignoreAddDotWithSpace, bool wrapInBrackets) { if (pShortNameOffset != nullptr) { *pShortNameOffset = 0; } if (left == nullptr && !wrapInBrackets) { if (right) { *pNameLength = right->Cch(); return right->Psz(); } return nullptr; } uint32 leftLen = 0; LPCOLESTR leftStr = _u(""); if (left != nullptr) // if wrapInBrackets is true { leftStr = left->Psz(); leftLen = left->Cch(); } if (right == nullptr) { *pNameLength = leftLen; return left->Psz(); } uint32 rightLen = right->Cch(); return AppendNameHints(leftStr, leftLen, right->Psz(), rightLen, pNameLength, pShortNameOffset, ignoreAddDotWithSpace, wrapInBrackets); }
CWE-119
null
517,570
164782584619402582847950514702908557666
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
void Parser::FinishBackgroundRegExpNodes() { // We have a list of RegExp nodes that we saw on the UI thread in functions we're parallel parsing, // and for each background job we have a list of RegExp nodes for which we couldn't allocate patterns. // We need to copy the pattern pointers from the UI thread nodes to the corresponding nodes on the // background nodes. // There may be UI thread nodes for which there are no background thread equivalents, because the UI thread // has to assume that the background thread won't defer anything. // Note that because these lists (and the list of background jobs) are SList's built by prepending, they are // all in reverse lexical order. Assert(!this->IsBackgroundParser()); Assert(this->fastScannedRegExpNodes); Assert(this->backgroundParseItems != nullptr); BackgroundParseItem *currBackgroundItem; #if DBG for (currBackgroundItem = this->backgroundParseItems; currBackgroundItem; currBackgroundItem = currBackgroundItem->GetNext()) { if (currBackgroundItem->RegExpNodeList()) { FOREACH_DLIST_ENTRY(ParseNodePtr, ArenaAllocator, pnode, currBackgroundItem->RegExpNodeList()) { Assert(pnode->sxPid.regexPattern == nullptr); } NEXT_DLIST_ENTRY; } } #endif // Hook up the patterns allocated on the main thread to the nodes created on the background thread. // Walk the list of foreground nodes, advancing through the work items and looking up each item. // Note that the background thread may have chosen to defer a given RegEx literal, so not every foreground // node will have a matching background node. Doesn't matter for correctness. // (It's inefficient, of course, to have to restart the inner loop from the beginning of the work item's // list, but it should be unusual to have many RegExes in a single work item's chunk of code. Figure out how // to start the inner loop from a known internal node within the list if that turns out to be important.) currBackgroundItem = this->backgroundParseItems; FOREACH_DLIST_ENTRY(ParseNodePtr, ArenaAllocator, pnodeFgnd, this->fastScannedRegExpNodes) { Assert(pnodeFgnd->nop == knopRegExp); Assert(pnodeFgnd->sxPid.regexPattern != nullptr); bool quit = false; while (!quit) { // Find the next work item with a RegEx in it. while (currBackgroundItem && currBackgroundItem->RegExpNodeList() == nullptr) { currBackgroundItem = currBackgroundItem->GetNext(); } if (!currBackgroundItem) { break; } // Walk the RegExps in the work item. FOREACH_DLIST_ENTRY(ParseNodePtr, ArenaAllocator, pnodeBgnd, currBackgroundItem->RegExpNodeList()) { Assert(pnodeBgnd->nop == knopRegExp); if (pnodeFgnd->ichMin <= pnodeBgnd->ichMin) { // Either we found a match, or the next background node is past the foreground node. // In any case, we can stop searching. if (pnodeFgnd->ichMin == pnodeBgnd->ichMin) { Assert(pnodeFgnd->ichLim == pnodeBgnd->ichLim); pnodeBgnd->sxPid.regexPattern = pnodeFgnd->sxPid.regexPattern; } quit = true; break; } } NEXT_DLIST_ENTRY; if (!quit) { // Need to advance to the next work item. currBackgroundItem = currBackgroundItem->GetNext(); } } } NEXT_DLIST_ENTRY; #if DBG for (currBackgroundItem = this->backgroundParseItems; currBackgroundItem; currBackgroundItem = currBackgroundItem->GetNext()) { if (currBackgroundItem->RegExpNodeList()) { FOREACH_DLIST_ENTRY(ParseNodePtr, ArenaAllocator, pnode, currBackgroundItem->RegExpNodeList()) { Assert(pnode->sxPid.regexPattern != nullptr); } NEXT_DLIST_ENTRY; } } #endif }
CWE-119
null
517,571
271585886619452142905835980659169360687
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ParseNodePtr Parser::CreateStrNode(IdentPtr pid) { Assert(!this->m_deferringAST); ParseNodePtr pnode = CreateNode(knopStr); pnode->sxPid.pid=pid; pnode->grfpn |= PNodeFlags::fpnCanFlattenConcatExpr; return pnode; }
CWE-119
null
517,572
269232649614519841752415403057699413065
null
null
other
ChakraCore
402f3d967c0a905ec5b9ca9c240783d3f2c15724
0
ParseNodePtr Parser::StartParseBlockHelper(PnodeBlockType blockType, Scope *scope, ParseNodePtr pnodeLabel, LabelId* pLabelId) { ParseNodePtr pnodeBlock = CreateBlockNode(blockType); pnodeBlock->sxBlock.scope = scope; BlockInfoStack *newBlockInfo = PushBlockInfo(pnodeBlock); PushStmt<buildAST>(&newBlockInfo->pstmt, pnodeBlock, knopBlock, pnodeLabel, pLabelId); return pnodeBlock; }
CWE-119
null
517,573
279252692183049033093443484149551830843
null
null
other