ptree.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  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 || this->nop == knopForAwaitOf);
  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. ParseNodeWhile * ParseNode::AsParseNodeWhile()
  189. {
  190. Assert(this->nop == knopWhile || this->nop == knopDoWhile);
  191. return reinterpret_cast<ParseNodeWhile*>(this);
  192. }
  193. ParseNodeFor * ParseNode::AsParseNodeFor()
  194. {
  195. Assert(this->nop == knopFor);
  196. return reinterpret_cast<ParseNodeFor*>(this);
  197. }
  198. ParseNodeForInOrForOf * ParseNode::AsParseNodeForInOrForOf()
  199. {
  200. Assert(this->nop == knopForIn || this->nop == knopForOf || this->nop == knopForAwaitOf);
  201. return reinterpret_cast<ParseNodeForInOrForOf*>(this);
  202. }
  203. ParseNodeFnc * ParseNode::AsParseNodeFnc()
  204. {
  205. Assert(this->nop == knopFncDecl || this->nop == knopProg || this->nop == knopModule);
  206. return reinterpret_cast<ParseNodeFnc*>(this);
  207. }
  208. ParseNodeProg * ParseNode::AsParseNodeProg()
  209. {
  210. Assert(this->nop == knopProg);
  211. return reinterpret_cast<ParseNodeProg*>(this);
  212. }
  213. ParseNodeModule * ParseNode::AsParseNodeModule()
  214. {
  215. // TODO: Currently there is not way to distingish a ParseNodeModule to ParseNodeProg node
  216. Assert(this->nop == knopProg);
  217. return reinterpret_cast<ParseNodeModule*>(this);
  218. }
  219. IdentPtr ParseNode::name()
  220. {
  221. if (this->nop == knopStr)
  222. {
  223. return this->AsParseNodeStr()->pid;
  224. }
  225. else if (this->nop == knopName)
  226. {
  227. return this->AsParseNodeName()->pid;
  228. }
  229. else if (this->nop == knopVarDecl || this->nop == knopConstDecl)
  230. {
  231. return this->AsParseNodeVar()->pid;
  232. }
  233. return nullptr;
  234. }
  235. ParseNodePtr ParseNode::GetFormalNext()
  236. {
  237. ParseNodePtr pnodeNext = nullptr;
  238. if (nop == knopParamPattern)
  239. {
  240. pnodeNext = this->AsParseNodeParamPattern()->pnodeNext;
  241. }
  242. else
  243. {
  244. Assert(IsVarLetOrConst());
  245. pnodeNext = this->AsParseNodeVar()->pnodeNext;
  246. }
  247. return pnodeNext;
  248. }
  249. bool ParseNode::IsUserIdentifier()
  250. {
  251. return this->nop == knopName && !this->AsParseNodeName()->IsSpecialName();
  252. }
  253. ParseNodeUni::ParseNodeUni(OpCode nop, charcount_t ichMin, charcount_t ichLim, ParseNode * pnode1)
  254. : ParseNode(nop, ichMin, ichLim)
  255. {
  256. this->pnode1 = pnode1;
  257. }
  258. ParseNodeBin::ParseNodeBin(OpCode nop, charcount_t ichMin, charcount_t ichLim, ParseNode * pnode1, ParseNode * pnode2)
  259. : ParseNode(nop, ichMin, ichLim)
  260. {
  261. // Member name is either a string or a computed name
  262. Assert((nop != knopMember && nop != knopMemberShort && nop != knopObjectPatternMember && nop != knopGetMember && nop != knopSetMember)
  263. || (pnode1->nop == knopStr || pnode1->nop == knopComputedName));
  264. // Dot's rhs has to be a name;
  265. Assert(nop != knopDot || pnode2->nop == knopName);
  266. this->pnode1 = pnode1;
  267. this->pnode2 = pnode2;
  268. // Statically detect if the add is a concat
  269. if (!PHASE_OFF1(Js::ByteCodeConcatExprOptPhase))
  270. {
  271. // We can't flatten the concat expression if the LHS is not a flatten concat already
  272. // e.g. a + (<str> + b)
  273. // Side effect of ToStr(b) need to happen first before ToStr(a)
  274. // If we flatten the concat expression, we will do ToStr(a) before ToStr(b)
  275. if ((nop == knopAdd) && (pnode1->CanFlattenConcatExpr() || pnode2->nop == knopStr))
  276. {
  277. this->grfpn |= fpnCanFlattenConcatExpr;
  278. }
  279. }
  280. }
  281. ParseNodeTri::ParseNodeTri(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  282. : ParseNode(nop, ichMin, ichLim)
  283. {
  284. }
  285. ParseNodeInt::ParseNodeInt(charcount_t ichMin, charcount_t ichLim, int32 lw)
  286. : ParseNode(knopInt, ichMin, ichLim)
  287. {
  288. this->lw = lw;
  289. }
  290. ParseNodeFloat::ParseNodeFloat(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  291. : ParseNode(nop, ichMin, ichLim)
  292. {
  293. }
  294. ParseNodeRegExp::ParseNodeRegExp(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  295. : ParseNode(nop, ichMin, ichLim)
  296. {
  297. this->regexPattern = nullptr;
  298. this->regexPatternIndex = 0;
  299. }
  300. ParseNodeStr::ParseNodeStr(charcount_t ichMin, charcount_t ichLim, IdentPtr name)
  301. : ParseNode(knopStr, ichMin, ichLim), pid(name)
  302. {
  303. }
  304. ParseNodeBigInt::ParseNodeBigInt(charcount_t ichMin, charcount_t ichLim, IdentPtr name)
  305. : ParseNode(knopBigInt, ichMin, ichLim), pid(name)
  306. {
  307. }
  308. ParseNodeName::ParseNodeName(charcount_t ichMin, charcount_t ichLim, IdentPtr name)
  309. : ParseNode(knopName, ichMin, ichLim), pid(name)
  310. {
  311. this->sym = nullptr;
  312. this->symRef = nullptr;
  313. this->isSpecialName = false;
  314. }
  315. void ParseNodeName::SetSymRef(PidRefStack * ref)
  316. {
  317. Assert(this->symRef == nullptr);
  318. this->symRef = ref->GetSymRef();
  319. }
  320. Js::PropertyId ParseNodeName::PropertyIdFromNameNode() const
  321. {
  322. Js::PropertyId propertyId;
  323. Symbol *sym = this->sym;
  324. if (sym)
  325. {
  326. propertyId = sym->GetPosition();
  327. }
  328. else
  329. {
  330. propertyId = this->pid->GetPropertyId();
  331. }
  332. return propertyId;
  333. }
  334. ParseNodeVar::ParseNodeVar(OpCode nop, charcount_t ichMin, charcount_t ichLim, IdentPtr name)
  335. : ParseNode(nop, ichMin, ichLim), pid(name)
  336. {
  337. Assert(nop == knopVarDecl || nop == knopConstDecl || nop == knopLetDecl || nop == knopTemp);
  338. this->pnodeInit = nullptr;
  339. this->pnodeNext = nullptr;
  340. this->sym = nullptr;
  341. this->symRef = nullptr;
  342. this->isSwitchStmtDecl = false;
  343. this->isBlockScopeFncDeclVar = false;
  344. }
  345. ParseNodeArrLit::ParseNodeArrLit(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  346. : ParseNodeUni(nop, ichMin, ichLim, nullptr)
  347. {
  348. }
  349. ParseNodeObjLit::ParseNodeObjLit(OpCode nop, charcount_t ichMin, charcount_t ichLim, uint staticCnt, uint computedCnt, bool rest)
  350. : ParseNodeUni(nop, ichMin, ichLim, nullptr), staticCount(staticCnt), computedCount(computedCnt), hasRest(rest)
  351. {
  352. }
  353. ParseNodeFnc::ParseNodeFnc(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  354. : ParseNode(nop, ichMin, ichLim)
  355. {
  356. this->ClearFlags(); // Initialize fncFlags, canBeDeferred and isBodyAndParamScopeMerged
  357. this->SetDeclaration(false);
  358. this->pnodeNext = nullptr;
  359. this->pnodeName = nullptr;
  360. this->pid = nullptr;
  361. this->hint = nullptr;
  362. this->hintOffset = 0;
  363. this->hintLength = 0;
  364. this->isNameIdentifierRef = true;
  365. this->nestedFuncEscapes = false;
  366. this->pnodeScopes = nullptr;
  367. this->pnodeBodyScope = nullptr;
  368. this->pnodeParams = nullptr;
  369. this->pnodeVars = nullptr;
  370. this->pnodeBody = nullptr;
  371. this->pnodeRest = nullptr;
  372. this->funcInfo = nullptr;
  373. this->scope = nullptr;
  374. this->nestedCount = 0;
  375. this->nestedIndex = (uint)-1;
  376. this->firstDefaultArg = 0;
  377. this->astSize = 0;
  378. this->cbMin = 0;
  379. this->cbStringMin = 0;
  380. this->cbLim = 0;
  381. this->lineNumber = 0;
  382. this->columnNumber = 0;
  383. this->functionId = 0;
  384. #if DBG
  385. this->deferredParseNextFunctionId = Js::Constants::NoFunctionId;
  386. #endif
  387. this->pRestorePoint = nullptr;
  388. this->deferredStub = nullptr;
  389. this->capturedNames = nullptr;
  390. this->superRestrictionState = SuperRestrictionState::Disallowed;
  391. }
  392. ParseNodeClass::ParseNodeClass(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  393. : ParseNode(nop, ichMin, ichLim)
  394. {
  395. }
  396. ParseNodeExportDefault::ParseNodeExportDefault(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  397. : ParseNode(nop, ichMin, ichLim)
  398. {
  399. }
  400. ParseNodeStrTemplate::ParseNodeStrTemplate(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  401. : ParseNode(nop, ichMin, ichLim)
  402. {
  403. }
  404. ParseNodeProg::ParseNodeProg(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  405. : ParseNodeFnc(nop, ichMin, ichLim)
  406. {
  407. this->pnodeLastValStmt = nullptr;
  408. this->m_UsesArgumentsAtGlobal = false;
  409. }
  410. ParseNodeModule::ParseNodeModule(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  411. : ParseNodeProg(nop, ichMin, ichLim)
  412. {
  413. }
  414. ParseNodeCall::ParseNodeCall(OpCode nop, charcount_t ichMin, charcount_t ichLim, ParseNodePtr pnodeTarget, ParseNodePtr pnodeArgs)
  415. : ParseNode(nop, ichMin, ichLim)
  416. {
  417. this->pnodeTarget = pnodeTarget;
  418. this->pnodeArgs = pnodeArgs;
  419. this->argCount = 0;
  420. this->spreadArgCount = 0;
  421. this->callOfConstants = false;
  422. this->isApplyCall = false;
  423. this->isEvalCall = false;
  424. this->isSuperCall = false;
  425. this->hasDestructuring = false;
  426. }
  427. ParseNodeStmt::ParseNodeStmt(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  428. : ParseNode(nop, ichMin, ichLim)
  429. {
  430. this->emitLabels = false;
  431. }
  432. ParseNodeBlock::ParseNodeBlock(charcount_t ichMin, charcount_t ichLim, int blockId, PnodeBlockType blockType)
  433. : ParseNodeStmt(knopBlock, ichMin, ichLim)
  434. {
  435. this->pnodeScopes = nullptr;
  436. this->pnodeNext = nullptr;
  437. this->scope = nullptr;
  438. this->enclosingBlock = nullptr;
  439. this->pnodeLexVars = nullptr;
  440. this->pnodeStmt = nullptr;
  441. this->pnodeLastValStmt = nullptr;
  442. this->callsEval = false;
  443. this->childCallsEval = false;
  444. this->blockType = blockType;
  445. this->blockId = blockId;
  446. if (blockType != PnodeBlockType::Regular)
  447. {
  448. this->grfpn |= PNodeFlags::fpnSyntheticNode;
  449. }
  450. }
  451. ParseNodeJump::ParseNodeJump(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  452. : ParseNodeStmt(nop, ichMin, ichLim)
  453. {
  454. }
  455. ParseNodeWhile::ParseNodeWhile(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  456. : ParseNodeStmt(nop, ichMin, ichLim)
  457. {
  458. }
  459. ParseNodeWith::ParseNodeWith(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  460. : ParseNodeStmt(nop, ichMin, ichLim)
  461. {
  462. }
  463. ParseNodeParamPattern::ParseNodeParamPattern(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  464. : ParseNodeUni(nop, ichMin, ichLim, nullptr)
  465. {
  466. }
  467. ParseNodeIf::ParseNodeIf(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  468. : ParseNodeStmt(nop, ichMin, ichLim)
  469. {
  470. }
  471. ParseNodeForInOrForOf::ParseNodeForInOrForOf(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  472. : ParseNodeStmt(nop, ichMin, ichLim)
  473. {
  474. }
  475. ParseNodeFor::ParseNodeFor(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  476. : ParseNodeStmt(nop, ichMin, ichLim)
  477. {
  478. }
  479. ParseNodeSwitch::ParseNodeSwitch(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  480. : ParseNodeStmt(nop, ichMin, ichLim)
  481. {
  482. }
  483. ParseNodeCase::ParseNodeCase(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  484. : ParseNodeStmt(nop, ichMin, ichLim)
  485. {
  486. }
  487. ParseNodeReturn::ParseNodeReturn(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  488. : ParseNodeStmt(nop, ichMin, ichLim)
  489. {
  490. }
  491. ParseNodeTryFinally::ParseNodeTryFinally(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  492. : ParseNodeStmt(nop, ichMin, ichLim)
  493. {
  494. }
  495. ParseNodeTryCatch::ParseNodeTryCatch(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  496. : ParseNodeStmt(nop, ichMin, ichLim)
  497. {
  498. }
  499. ParseNodeTry::ParseNodeTry(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  500. : ParseNodeStmt(nop, ichMin, ichLim)
  501. {
  502. }
  503. ParseNodeCatch::ParseNodeCatch(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  504. : ParseNodeStmt(nop, ichMin, ichLim), pnodeParam(nullptr)
  505. {
  506. }
  507. ParseNodeFinally::ParseNodeFinally(OpCode nop, charcount_t ichMin, charcount_t ichLim)
  508. : ParseNodeStmt(nop, ichMin, ichLim)
  509. {
  510. }
  511. ParseNodeSpecialName::ParseNodeSpecialName(charcount_t ichMin, charcount_t ichLim, IdentPtr pid)
  512. : ParseNodeName(ichMin, ichLim, pid)
  513. {
  514. this->SetIsSpecialName();
  515. this->isThis = false;
  516. this->isSuper = false;
  517. }
  518. ParseNodeSuperReference::ParseNodeSuperReference(OpCode nop, charcount_t ichMin, charcount_t ichLim, ParseNode * pnode1, ParseNode * pnode2)
  519. : ParseNodeBin(nop, ichMin, ichLim, pnode1, pnode2)
  520. {
  521. this->pnodeThis = nullptr;
  522. }
  523. ParseNodeSuperCall::ParseNodeSuperCall(OpCode nop, charcount_t ichMin, charcount_t ichLim, ParseNode * pnodeTarget, ParseNode * pnodeArgs)
  524. : ParseNodeCall(nop, ichMin, ichLim, pnodeTarget, pnodeArgs)
  525. {
  526. this->isSuperCall = true;
  527. this->pnodeThis = nullptr;
  528. this->pnodeNewTarget = nullptr;
  529. }
  530. IdentPtrSet* ParseNodeFnc::EnsureCapturedNames(ArenaAllocator* alloc)
  531. {
  532. if (this->capturedNames == nullptr)
  533. {
  534. this->capturedNames = Anew(alloc, IdentPtrSet, alloc);
  535. }
  536. return this->capturedNames;
  537. }
  538. IdentPtrSet* ParseNodeFnc::GetCapturedNames()
  539. {
  540. return this->capturedNames;
  541. }
  542. bool ParseNodeFnc::HasAnyCapturedNames()
  543. {
  544. return this->capturedNames != nullptr && this->capturedNames->Count() != 0;
  545. }