ptree.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. #include "ParserPch.h"
  6. ParseNode::ParseNode(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  7. {
  8. this->nop = nop;
  9. this->grfpn = PNodeFlags::fpnNone;
  10. this->location = Js::Constants::NoRegister;
  11. this->isUsed = true;
  12. this->notEscapedUse = false;
  13. this->isInList = false;
  14. this->isPatternDeclaration = false;
  15. this->isCallApplyTargetLoad = false;
  16. this->ichMin = ichMin;
  17. this->ichLim = ichLim;
  18. }
  19. ParseNodeUni * ParseNode::AsParseNodeUni()
  20. {
  21. Assert((this->Grfnop() & fnopUni) || this->nop == knopThrow);
  22. return reinterpret_cast<ParseNodeUni *>(this);
  23. }
  24. ParseNodeBin * ParseNode::AsParseNodeBin()
  25. {
  26. Assert((this->Grfnop() & fnopBin) || this->nop == knopList);
  27. return reinterpret_cast<ParseNodeBin *>(this);
  28. }
  29. ParseNodeTri * ParseNode::AsParseNodeTri()
  30. {
  31. Assert(this->nop == knopQmark);
  32. return reinterpret_cast<ParseNodeTri *>(this);
  33. }
  34. ParseNodeInt * ParseNode::AsParseNodeInt()
  35. {
  36. Assert(this->nop == knopInt);
  37. return reinterpret_cast<ParseNodeInt *>(this);
  38. }
  39. ParseNodeBigInt * ParseNode::AsParseNodeBigInt()
  40. {
  41. Assert(this->nop == knopBigInt);
  42. return reinterpret_cast<ParseNodeBigInt *>(this);
  43. }
  44. ParseNodeFloat * ParseNode::AsParseNodeFloat()
  45. {
  46. Assert(this->nop == knopFlt);
  47. return reinterpret_cast<ParseNodeFloat *>(this);
  48. }
  49. ParseNodeRegExp * ParseNode::AsParseNodeRegExp()
  50. {
  51. Assert(this->nop == knopRegExp);
  52. return reinterpret_cast<ParseNodeRegExp *>(this);
  53. }
  54. ParseNodeVar * ParseNode::AsParseNodeVar()
  55. {
  56. Assert(this->nop == knopVarDecl || this->nop == knopConstDecl || this->nop == knopLetDecl || this->nop == knopTemp);
  57. return reinterpret_cast<ParseNodeVar *>(this);
  58. }
  59. ParseNodeStr * ParseNode::AsParseNodeStr()
  60. {
  61. Assert(this->nop == knopStr);
  62. return reinterpret_cast<ParseNodeStr *>(this);
  63. }
  64. ParseNodeName * ParseNode::AsParseNodeName()
  65. {
  66. Assert(this->nop == knopName);
  67. return reinterpret_cast<ParseNodeName *>(this);
  68. }
  69. ParseNodeSpecialName * ParseNode::AsParseNodeSpecialName()
  70. {
  71. Assert(this->nop == knopName && this->AsParseNodeName()->IsSpecialName());
  72. return reinterpret_cast<ParseNodeSpecialName *>(this);
  73. }
  74. ParseNodeExportDefault * ParseNode::AsParseNodeExportDefault()
  75. {
  76. Assert(this->nop == knopExportDefault);
  77. return reinterpret_cast<ParseNodeExportDefault *>(this);
  78. }
  79. ParseNodeStrTemplate * ParseNode::AsParseNodeStrTemplate()
  80. {
  81. Assert(this->nop == knopStrTemplate);
  82. return reinterpret_cast<ParseNodeStrTemplate *>(this);
  83. }
  84. ParseNodeSuperReference * ParseNode::AsParseNodeSuperReference()
  85. {
  86. Assert(this->nop == knopDot || this->nop == knopIndex);
  87. Assert(this->AsParseNodeBin()->pnode1 && this->AsParseNodeBin()->pnode1->AsParseNodeSpecialName()->isSuper);
  88. return reinterpret_cast<ParseNodeSuperReference*>(this);
  89. }
  90. ParseNodeArrLit * ParseNode::AsParseNodeArrLit()
  91. {
  92. Assert(this->nop == knopArray || this->nop == knopArrayPattern);
  93. return reinterpret_cast<ParseNodeArrLit*>(this);
  94. }
  95. ParseNodeObjLit * ParseNode::AsParseNodeObjLit()
  96. {
  97. // Currently only Object Assignment Pattern needs extra field to count members
  98. Assert(this->nop == knopObjectPattern);
  99. return reinterpret_cast<ParseNodeObjLit*>(this);
  100. }
  101. ParseNodeCall * ParseNode::AsParseNodeCall()
  102. {
  103. Assert(this->nop == knopCall || this->nop == knopNew);
  104. return reinterpret_cast<ParseNodeCall*>(this);
  105. }
  106. ParseNodeSuperCall * ParseNode::AsParseNodeSuperCall()
  107. {
  108. Assert(this->nop == knopCall && this->AsParseNodeCall()->isSuperCall);
  109. return reinterpret_cast<ParseNodeSuperCall*>(this);
  110. }
  111. ParseNodeClass * ParseNode::AsParseNodeClass()
  112. {
  113. Assert(this->nop == knopClassDecl);
  114. return reinterpret_cast<ParseNodeClass*>(this);
  115. }
  116. ParseNodeParamPattern * ParseNode::AsParseNodeParamPattern()
  117. {
  118. Assert(this->nop == knopParamPattern);
  119. return reinterpret_cast<ParseNodeParamPattern*>(this);
  120. }
  121. ParseNodeStmt * ParseNode::AsParseNodeStmt()
  122. {
  123. Assert(this->nop == knopBlock || this->nop == knopBreak || this->nop == knopContinue || this->nop == knopWith || this->nop == knopIf || this->nop == knopSwitch || this->nop == knopCase || this->nop == knopReturn
  124. || this->nop == knopTryFinally || this->nop == knopTryCatch || this->nop == knopTry || this->nop == knopCatch || this->nop == knopFinally
  125. || this->nop == knopWhile || this->nop == knopDoWhile || this->nop == knopFor || this->nop == knopForIn || this->nop == knopForOf);
  126. return reinterpret_cast<ParseNodeStmt*>(this);
  127. }
  128. ParseNodeBlock * ParseNode::AsParseNodeBlock()
  129. {
  130. Assert(this->nop == knopBlock);
  131. return reinterpret_cast<ParseNodeBlock*>(this);
  132. }
  133. ParseNodeJump * ParseNode::AsParseNodeJump()
  134. {
  135. Assert(this->nop == knopBreak || this->nop == knopContinue);
  136. return reinterpret_cast<ParseNodeJump*>(this);
  137. }
  138. ParseNodeWith * ParseNode::AsParseNodeWith()
  139. {
  140. Assert(this->nop == knopWith);
  141. return reinterpret_cast<ParseNodeWith*>(this);
  142. }
  143. ParseNodeIf * ParseNode::AsParseNodeIf()
  144. {
  145. Assert(this->nop == knopIf);
  146. return reinterpret_cast<ParseNodeIf*>(this);
  147. }
  148. ParseNodeSwitch * ParseNode::AsParseNodeSwitch()
  149. {
  150. Assert(this->nop == knopSwitch);
  151. return reinterpret_cast<ParseNodeSwitch*>(this);
  152. }
  153. ParseNodeCase * ParseNode::AsParseNodeCase()
  154. {
  155. Assert(this->nop == knopCase);
  156. return reinterpret_cast<ParseNodeCase*>(this);
  157. }
  158. ParseNodeReturn * ParseNode::AsParseNodeReturn()
  159. {
  160. Assert(this->nop == knopReturn);
  161. return reinterpret_cast<ParseNodeReturn*>(this);
  162. }
  163. ParseNodeTryFinally * ParseNode::AsParseNodeTryFinally()
  164. {
  165. Assert(this->nop == knopTryFinally);
  166. return reinterpret_cast<ParseNodeTryFinally*>(this);
  167. }
  168. ParseNodeTryCatch * ParseNode::AsParseNodeTryCatch()
  169. {
  170. Assert(this->nop == knopTryCatch);
  171. return reinterpret_cast<ParseNodeTryCatch*>(this);
  172. }
  173. ParseNodeTry * ParseNode::AsParseNodeTry()
  174. {
  175. Assert(this->nop == knopTry);
  176. return reinterpret_cast<ParseNodeTry*>(this);
  177. }
  178. ParseNodeCatch * ParseNode::AsParseNodeCatch()
  179. {
  180. Assert(this->nop == knopCatch);
  181. return reinterpret_cast<ParseNodeCatch*>(this);
  182. }
  183. ParseNodeFinally * ParseNode::AsParseNodeFinally()
  184. {
  185. Assert(this->nop == knopFinally);
  186. return reinterpret_cast<ParseNodeFinally*>(this);
  187. }
  188. ParseNodeLoop * ParseNode::AsParseNodeLoop()
  189. {
  190. Assert(this->nop == knopWhile || this->nop == knopDoWhile || this->nop == knopFor || this->nop == knopForIn || this->nop == knopForOf);
  191. return reinterpret_cast<ParseNodeLoop*>(this);
  192. }
  193. ParseNodeWhile * ParseNode::AsParseNodeWhile()
  194. {
  195. Assert(this->nop == knopWhile || this->nop == knopDoWhile);
  196. return reinterpret_cast<ParseNodeWhile*>(this);
  197. }
  198. ParseNodeFor * ParseNode::AsParseNodeFor()
  199. {
  200. Assert(this->nop == knopFor);
  201. return reinterpret_cast<ParseNodeFor*>(this);
  202. }
  203. ParseNodeForInOrForOf * ParseNode::AsParseNodeForInOrForOf()
  204. {
  205. Assert(this->nop == knopForIn || this->nop == knopForOf);
  206. return reinterpret_cast<ParseNodeForInOrForOf*>(this);
  207. }
  208. ParseNodeFnc * ParseNode::AsParseNodeFnc()
  209. {
  210. Assert(this->nop == knopFncDecl || this->nop == knopProg || this->nop == knopModule);
  211. return reinterpret_cast<ParseNodeFnc*>(this);
  212. }
  213. ParseNodeProg * ParseNode::AsParseNodeProg()
  214. {
  215. Assert(this->nop == knopProg);
  216. return reinterpret_cast<ParseNodeProg*>(this);
  217. }
  218. ParseNodeModule * ParseNode::AsParseNodeModule()
  219. {
  220. // TODO: Currently there is not way to distingish a ParseNodeModule to ParseNodeProg node
  221. Assert(this->nop == knopProg);
  222. return reinterpret_cast<ParseNodeModule*>(this);
  223. }
  224. IdentPtr ParseNode::name()
  225. {
  226. if (this->nop == knopStr)
  227. {
  228. return this->AsParseNodeStr()->pid;
  229. }
  230. else if (this->nop == knopName)
  231. {
  232. return this->AsParseNodeName()->pid;
  233. }
  234. else if (this->nop == knopVarDecl || this->nop == knopConstDecl)
  235. {
  236. return this->AsParseNodeVar()->pid;
  237. }
  238. return nullptr;
  239. }
  240. ParseNodePtr ParseNode::GetFormalNext()
  241. {
  242. ParseNodePtr pnodeNext = nullptr;
  243. if (nop == knopParamPattern)
  244. {
  245. pnodeNext = this->AsParseNodeParamPattern()->pnodeNext;
  246. }
  247. else
  248. {
  249. Assert(IsVarLetOrConst());
  250. pnodeNext = this->AsParseNodeVar()->pnodeNext;
  251. }
  252. return pnodeNext;
  253. }
  254. bool ParseNode::IsUserIdentifier()
  255. {
  256. return this->nop == knopName && !this->AsParseNodeName()->IsSpecialName();
  257. }
  258. ParseNodeUni::ParseNodeUni(OpCode nop, charcount_t ichMin, charcount_t ichLim, ParseNode * pnode1)
  259. : ParseNode(nop, ichMin, ichLim)
  260. {
  261. this->pnode1 = pnode1;
  262. }
  263. ParseNodeBin::ParseNodeBin(OpCode nop, charcount_t ichMin, charcount_t ichLim, ParseNode * pnode1, ParseNode * pnode2)
  264. : ParseNode(nop, ichMin, ichLim)
  265. {
  266. // Member name is either a string or a computed name
  267. Assert((nop != knopMember && nop != knopMemberShort && nop != knopObjectPatternMember && nop != knopGetMember && nop != knopSetMember)
  268. || (pnode1->nop == knopStr || pnode1->nop == knopComputedName));
  269. // Dot's rhs has to be a name;
  270. Assert(nop != knopDot || pnode2->nop == knopName);
  271. this->pnode1 = pnode1;
  272. this->pnode2 = pnode2;
  273. // Statically detect if the add is a concat
  274. if (!PHASE_OFF1(Js::ByteCodeConcatExprOptPhase))
  275. {
  276. // We can't flatten the concat expression if the LHS is not a flatten concat already
  277. // e.g. a + (<str> + b)
  278. // Side effect of ToStr(b) need to happen first before ToStr(a)
  279. // If we flatten the concat expression, we will do ToStr(a) before ToStr(b)
  280. if ((nop == knopAdd) && (pnode1->CanFlattenConcatExpr() || pnode2->nop == knopStr))
  281. {
  282. this->grfpn |= fpnCanFlattenConcatExpr;
  283. }
  284. }
  285. }
  286. ParseNodeTri::ParseNodeTri(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  287. : ParseNode(nop, ichMin, ichLim)
  288. {
  289. }
  290. ParseNodeInt::ParseNodeInt(charcount_t ichMin, charcount_t ichLim, int32 lw)
  291. : ParseNode(knopInt, ichMin, ichLim)
  292. {
  293. this->lw = lw;
  294. }
  295. ParseNodeFloat::ParseNodeFloat(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  296. : ParseNode(nop, ichMin, ichLim)
  297. {
  298. }
  299. ParseNodeRegExp::ParseNodeRegExp(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  300. : ParseNode(nop, ichMin, ichLim)
  301. {
  302. this->regexPattern = nullptr;
  303. this->regexPatternIndex = 0;
  304. }
  305. ParseNodeStr::ParseNodeStr(charcount_t ichMin, charcount_t ichLim, IdentPtr name)
  306. : ParseNode(knopStr, ichMin, ichLim), pid(name)
  307. {
  308. }
  309. ParseNodeBigInt::ParseNodeBigInt(charcount_t ichMin, charcount_t ichLim, IdentPtr name)
  310. : ParseNode(knopBigInt, ichMin, ichLim), pid(name)
  311. {
  312. }
  313. ParseNodeName::ParseNodeName(charcount_t ichMin, charcount_t ichLim, IdentPtr name)
  314. : ParseNode(knopName, ichMin, ichLim), pid(name)
  315. {
  316. this->sym = nullptr;
  317. this->symRef = nullptr;
  318. this->isSpecialName = false;
  319. }
  320. void ParseNodeName::SetSymRef(PidRefStack * ref)
  321. {
  322. Assert(this->symRef == nullptr);
  323. this->symRef = ref->GetSymRef();
  324. }
  325. Js::PropertyId ParseNodeName::PropertyIdFromNameNode() const
  326. {
  327. Js::PropertyId propertyId;
  328. Symbol *sym = this->sym;
  329. if (sym)
  330. {
  331. propertyId = sym->GetPosition();
  332. }
  333. else
  334. {
  335. propertyId = this->pid->GetPropertyId();
  336. }
  337. return propertyId;
  338. }
  339. ParseNodeVar::ParseNodeVar(OpCode nop, charcount_t ichMin, charcount_t ichLim, IdentPtr name)
  340. : ParseNode(nop, ichMin, ichLim), pid(name)
  341. {
  342. Assert(nop == knopVarDecl || nop == knopConstDecl || nop == knopLetDecl || nop == knopTemp);
  343. this->pnodeInit = nullptr;
  344. this->pnodeNext = nullptr;
  345. this->sym = nullptr;
  346. this->symRef = nullptr;
  347. this->isSwitchStmtDecl = false;
  348. this->isBlockScopeFncDeclVar = false;
  349. }
  350. ParseNodeArrLit::ParseNodeArrLit(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  351. : ParseNodeUni(nop, ichMin, ichLim, nullptr)
  352. {
  353. }
  354. ParseNodeObjLit::ParseNodeObjLit(OpCode nop, charcount_t ichMin, charcount_t ichLim, uint staticCnt, uint computedCnt, bool rest)
  355. : ParseNodeUni(nop, ichMin, ichLim, nullptr), staticCount(staticCnt), computedCount(computedCnt), hasRest(rest)
  356. {
  357. }
  358. ParseNodeFnc::ParseNodeFnc(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  359. : ParseNode(nop, ichMin, ichLim)
  360. {
  361. this->ClearFlags(); // Initialize fncFlags, canBeDeferred and isBodyAndParamScopeMerged
  362. this->SetDeclaration(false);
  363. this->pnodeNext = nullptr;
  364. this->pnodeName = nullptr;
  365. this->pid = nullptr;
  366. this->hint = nullptr;
  367. this->hintOffset = 0;
  368. this->hintLength = 0;
  369. this->isNameIdentifierRef = true;
  370. this->nestedFuncEscapes = false;
  371. this->pnodeScopes = nullptr;
  372. this->pnodeBodyScope = nullptr;
  373. this->pnodeParams = nullptr;
  374. this->pnodeVars = nullptr;
  375. this->pnodeBody = nullptr;
  376. this->pnodeRest = nullptr;
  377. this->funcInfo = nullptr;
  378. this->scope = nullptr;
  379. this->nestedCount = 0;
  380. this->nestedIndex = (uint)-1;
  381. this->firstDefaultArg = 0;
  382. this->astSize = 0;
  383. this->cbMin = 0;
  384. this->cbStringMin = 0;
  385. this->cbLim = 0;
  386. this->lineNumber = 0;
  387. this->columnNumber = 0;
  388. this->functionId = 0;
  389. #if DBG
  390. this->deferredParseNextFunctionId = Js::Constants::NoFunctionId;
  391. #endif
  392. this->pRestorePoint = nullptr;
  393. this->deferredStub = nullptr;
  394. this->capturedNames = nullptr;
  395. this->superRestrictionState = SuperRestrictionState::Disallowed;
  396. }
  397. ParseNodeClass::ParseNodeClass(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  398. : ParseNode(nop, ichMin, ichLim)
  399. {
  400. }
  401. ParseNodeExportDefault::ParseNodeExportDefault(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  402. : ParseNode(nop, ichMin, ichLim)
  403. {
  404. }
  405. ParseNodeStrTemplate::ParseNodeStrTemplate(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  406. : ParseNode(nop, ichMin, ichLim)
  407. {
  408. }
  409. ParseNodeProg::ParseNodeProg(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  410. : ParseNodeFnc(nop, ichMin, ichLim)
  411. {
  412. this->pnodeLastValStmt = nullptr;
  413. this->m_UsesArgumentsAtGlobal = false;
  414. }
  415. ParseNodeModule::ParseNodeModule(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  416. : ParseNodeProg(nop, ichMin, ichLim)
  417. {
  418. }
  419. ParseNodeCall::ParseNodeCall(OpCode nop, charcount_t ichMin, charcount_t ichLim, ParseNodePtr pnodeTarget, ParseNodePtr pnodeArgs)
  420. : ParseNode(nop, ichMin, ichLim)
  421. {
  422. this->pnodeTarget = pnodeTarget;
  423. this->pnodeArgs = pnodeArgs;
  424. this->argCount = 0;
  425. this->spreadArgCount = 0;
  426. this->callOfConstants = false;
  427. this->isApplyCall = false;
  428. this->isEvalCall = false;
  429. this->isSuperCall = false;
  430. this->hasDestructuring = false;
  431. }
  432. ParseNodeStmt::ParseNodeStmt(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  433. : ParseNode(nop, ichMin, ichLim)
  434. {
  435. this->emitLabels = false;
  436. }
  437. ParseNodeBlock::ParseNodeBlock(charcount_t ichMin, charcount_t ichLim, int blockId, PnodeBlockType blockType)
  438. : ParseNodeStmt(knopBlock, ichMin, ichLim)
  439. {
  440. this->pnodeScopes = nullptr;
  441. this->pnodeNext = nullptr;
  442. this->scope = nullptr;
  443. this->enclosingBlock = nullptr;
  444. this->pnodeLexVars = nullptr;
  445. this->pnodeStmt = nullptr;
  446. this->pnodeLastValStmt = nullptr;
  447. this->callsEval = false;
  448. this->childCallsEval = false;
  449. this->blockType = blockType;
  450. this->blockId = blockId;
  451. if (blockType != PnodeBlockType::Regular)
  452. {
  453. this->grfpn |= PNodeFlags::fpnSyntheticNode;
  454. }
  455. }
  456. ParseNodeJump::ParseNodeJump(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  457. : ParseNodeStmt(nop, ichMin, ichLim)
  458. {
  459. }
  460. ParseNodeLoop::ParseNodeLoop(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  461. : ParseNodeStmt(nop, ichMin, ichLim)
  462. {
  463. }
  464. ParseNodeWhile::ParseNodeWhile(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  465. : ParseNodeLoop(nop, ichMin, ichLim)
  466. {
  467. }
  468. ParseNodeWith::ParseNodeWith(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  469. : ParseNodeStmt(nop, ichMin, ichLim)
  470. {
  471. }
  472. ParseNodeParamPattern::ParseNodeParamPattern(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  473. : ParseNodeUni(nop, ichMin, ichLim, nullptr)
  474. {
  475. }
  476. ParseNodeIf::ParseNodeIf(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  477. : ParseNodeStmt(nop, ichMin, ichLim)
  478. {
  479. }
  480. ParseNodeForInOrForOf::ParseNodeForInOrForOf(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  481. : ParseNodeLoop(nop, ichMin, ichLim)
  482. {
  483. }
  484. ParseNodeFor::ParseNodeFor(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  485. : ParseNodeLoop(nop, ichMin, ichLim)
  486. {
  487. }
  488. ParseNodeSwitch::ParseNodeSwitch(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  489. : ParseNodeStmt(nop, ichMin, ichLim)
  490. {
  491. }
  492. ParseNodeCase::ParseNodeCase(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  493. : ParseNodeStmt(nop, ichMin, ichLim)
  494. {
  495. }
  496. ParseNodeReturn::ParseNodeReturn(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  497. : ParseNodeStmt(nop, ichMin, ichLim)
  498. {
  499. }
  500. ParseNodeTryFinally::ParseNodeTryFinally(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  501. : ParseNodeStmt(nop, ichMin, ichLim)
  502. {
  503. }
  504. ParseNodeTryCatch::ParseNodeTryCatch(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  505. : ParseNodeStmt(nop, ichMin, ichLim)
  506. {
  507. }
  508. ParseNodeTry::ParseNodeTry(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  509. : ParseNodeStmt(nop, ichMin, ichLim)
  510. {
  511. }
  512. ParseNodeCatch::ParseNodeCatch(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  513. : ParseNodeStmt(nop, ichMin, ichLim)
  514. {
  515. }
  516. ParseNodeFinally::ParseNodeFinally(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  517. : ParseNodeStmt(nop, ichMin, ichLim)
  518. {
  519. }
  520. ParseNodeSpecialName::ParseNodeSpecialName(charcount_t ichMin, charcount_t ichLim, IdentPtr pid)
  521. : ParseNodeName(ichMin, ichLim, pid)
  522. {
  523. this->SetIsSpecialName();
  524. this->isThis = false;
  525. this->isSuper = false;
  526. }
  527. ParseNodeSuperReference::ParseNodeSuperReference(OpCode nop, charcount_t ichMin, charcount_t ichLim, ParseNode * pnode1, ParseNode * pnode2)
  528. : ParseNodeBin(nop, ichMin, ichLim, pnode1, pnode2)
  529. {
  530. this->pnodeThis = nullptr;
  531. }
  532. ParseNodeSuperCall::ParseNodeSuperCall(OpCode nop, charcount_t ichMin, charcount_t ichLim, ParseNode * pnodeTarget, ParseNode * pnodeArgs)
  533. : ParseNodeCall(nop, ichMin, ichLim, pnodeTarget, pnodeArgs)
  534. {
  535. this->isSuperCall = true;
  536. this->pnodeThis = nullptr;
  537. this->pnodeNewTarget = nullptr;
  538. }
  539. IdentPtrSet* ParseNodeFnc::EnsureCapturedNames(ArenaAllocator* alloc)
  540. {
  541. if (this->capturedNames == nullptr)
  542. {
  543. this->capturedNames = Anew(alloc, IdentPtrSet, alloc);
  544. }
  545. return this->capturedNames;
  546. }
  547. IdentPtrSet* ParseNodeFnc::GetCapturedNames()
  548. {
  549. return this->capturedNames;
  550. }
  551. bool ParseNodeFnc::HasAnyCapturedNames()
  552. {
  553. return this->capturedNames != nullptr && this->capturedNames->Count() != 0;
  554. }