ptree.cpp 18 KB

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