Compiler-Inlining.js 87 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324
  1. define(["amber/boot", "amber_core/Compiler-Core", "amber_core/Compiler-IR", "amber_core/Compiler-Semantic", "amber_core/Kernel-Objects"], function($boot){"use strict";
  2. if(!$boot.nilAsReceiver)$boot.nilAsReceiver=$boot.nil;
  3. var $core=$boot.api,nil=$boot.nilAsReceiver,$recv=$boot.asReceiver,$globals=$boot.globals;
  4. if(!$boot.nilAsClass)$boot.nilAsClass=$boot.dnu;
  5. $core.addPackage('Compiler-Inlining');
  6. $core.packages["Compiler-Inlining"].innerEval = function (expr) { return eval(expr); };
  7. $core.packages["Compiler-Inlining"].transport = {"type":"amd","amdNamespace":"amber_core"};
  8. $core.addClass('IRInlinedClosure', $globals.IRClosure, [], 'Compiler-Inlining');
  9. //>>excludeStart("ide", pragmas.excludeIdeData);
  10. $globals.IRInlinedClosure.comment="I represent an inlined closure instruction.";
  11. //>>excludeEnd("ide");
  12. $core.addMethod(
  13. $core.method({
  14. selector: "accept:",
  15. protocol: 'visiting',
  16. fn: function (aVisitor){
  17. var self=this;
  18. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  19. return $core.withContext(function($ctx1) {
  20. //>>excludeEnd("ctx");
  21. $recv(aVisitor)._visitIRInlinedClosure_(self);
  22. return self;
  23. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  24. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},$globals.IRInlinedClosure)});
  25. //>>excludeEnd("ctx");
  26. },
  27. //>>excludeStart("ide", pragmas.excludeIdeData);
  28. args: ["aVisitor"],
  29. source: "accept: aVisitor\x0a\x09aVisitor visitIRInlinedClosure: self",
  30. referencedClasses: [],
  31. //>>excludeEnd("ide");
  32. messageSends: ["visitIRInlinedClosure:"]
  33. }),
  34. $globals.IRInlinedClosure);
  35. $core.addMethod(
  36. $core.method({
  37. selector: "isInlined",
  38. protocol: 'testing',
  39. fn: function (){
  40. var self=this;
  41. return true;
  42. },
  43. //>>excludeStart("ide", pragmas.excludeIdeData);
  44. args: [],
  45. source: "isInlined\x0a\x09^ true",
  46. referencedClasses: [],
  47. //>>excludeEnd("ide");
  48. messageSends: []
  49. }),
  50. $globals.IRInlinedClosure);
  51. $core.addClass('IRInlinedSend', $globals.IRSend, [], 'Compiler-Inlining');
  52. //>>excludeStart("ide", pragmas.excludeIdeData);
  53. $globals.IRInlinedSend.comment="I am the abstract super class of inlined message send instructions.";
  54. //>>excludeEnd("ide");
  55. $core.addMethod(
  56. $core.method({
  57. selector: "accept:",
  58. protocol: 'visiting',
  59. fn: function (aVisitor){
  60. var self=this;
  61. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  62. return $core.withContext(function($ctx1) {
  63. //>>excludeEnd("ctx");
  64. $recv(aVisitor)._visitInlinedSend_(self);
  65. return self;
  66. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  67. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},$globals.IRInlinedSend)});
  68. //>>excludeEnd("ctx");
  69. },
  70. //>>excludeStart("ide", pragmas.excludeIdeData);
  71. args: ["aVisitor"],
  72. source: "accept: aVisitor\x0a\x09aVisitor visitInlinedSend: self",
  73. referencedClasses: [],
  74. //>>excludeEnd("ide");
  75. messageSends: ["visitInlinedSend:"]
  76. }),
  77. $globals.IRInlinedSend);
  78. $core.addMethod(
  79. $core.method({
  80. selector: "internalVariables",
  81. protocol: 'accessing',
  82. fn: function (){
  83. var self=this;
  84. return [];
  85. },
  86. //>>excludeStart("ide", pragmas.excludeIdeData);
  87. args: [],
  88. source: "internalVariables\x0a\x09\x22Answer a collection of internal variables required \x0a\x09to perform the inlining\x22\x0a\x09\x0a\x09^ #()",
  89. referencedClasses: [],
  90. //>>excludeEnd("ide");
  91. messageSends: []
  92. }),
  93. $globals.IRInlinedSend);
  94. $core.addMethod(
  95. $core.method({
  96. selector: "isInlined",
  97. protocol: 'testing',
  98. fn: function (){
  99. var self=this;
  100. return true;
  101. },
  102. //>>excludeStart("ide", pragmas.excludeIdeData);
  103. args: [],
  104. source: "isInlined\x0a\x09^ true",
  105. referencedClasses: [],
  106. //>>excludeEnd("ide");
  107. messageSends: []
  108. }),
  109. $globals.IRInlinedSend);
  110. $core.addClass('IRInlinedIfFalse', $globals.IRInlinedSend, [], 'Compiler-Inlining');
  111. //>>excludeStart("ide", pragmas.excludeIdeData);
  112. $globals.IRInlinedIfFalse.comment="I represent an inlined `#ifFalse:` message send instruction.";
  113. //>>excludeEnd("ide");
  114. $core.addMethod(
  115. $core.method({
  116. selector: "accept:",
  117. protocol: 'visiting',
  118. fn: function (aVisitor){
  119. var self=this;
  120. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  121. return $core.withContext(function($ctx1) {
  122. //>>excludeEnd("ctx");
  123. $recv(aVisitor)._visitIRInlinedIfFalse_(self);
  124. return self;
  125. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  126. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},$globals.IRInlinedIfFalse)});
  127. //>>excludeEnd("ctx");
  128. },
  129. //>>excludeStart("ide", pragmas.excludeIdeData);
  130. args: ["aVisitor"],
  131. source: "accept: aVisitor\x0a\x09aVisitor visitIRInlinedIfFalse: self",
  132. referencedClasses: [],
  133. //>>excludeEnd("ide");
  134. messageSends: ["visitIRInlinedIfFalse:"]
  135. }),
  136. $globals.IRInlinedIfFalse);
  137. $core.addClass('IRInlinedIfNilIfNotNil', $globals.IRInlinedSend, [], 'Compiler-Inlining');
  138. //>>excludeStart("ide", pragmas.excludeIdeData);
  139. $globals.IRInlinedIfNilIfNotNil.comment="I represent an inlined `#ifNil:ifNotNil:` message send instruction.";
  140. //>>excludeEnd("ide");
  141. $core.addMethod(
  142. $core.method({
  143. selector: "accept:",
  144. protocol: 'visiting',
  145. fn: function (aVisitor){
  146. var self=this;
  147. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  148. return $core.withContext(function($ctx1) {
  149. //>>excludeEnd("ctx");
  150. $recv(aVisitor)._visitIRInlinedIfNilIfNotNil_(self);
  151. return self;
  152. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  153. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},$globals.IRInlinedIfNilIfNotNil)});
  154. //>>excludeEnd("ctx");
  155. },
  156. //>>excludeStart("ide", pragmas.excludeIdeData);
  157. args: ["aVisitor"],
  158. source: "accept: aVisitor\x0a\x09aVisitor visitIRInlinedIfNilIfNotNil: self",
  159. referencedClasses: [],
  160. //>>excludeEnd("ide");
  161. messageSends: ["visitIRInlinedIfNilIfNotNil:"]
  162. }),
  163. $globals.IRInlinedIfNilIfNotNil);
  164. $core.addMethod(
  165. $core.method({
  166. selector: "internalVariables",
  167. protocol: 'accessing',
  168. fn: function (){
  169. var self=this;
  170. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  171. return $core.withContext(function($ctx1) {
  172. //>>excludeEnd("ctx");
  173. return $recv($globals.Array)._with_(self._receiverInternalVariable());
  174. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  175. }, function($ctx1) {$ctx1.fill(self,"internalVariables",{},$globals.IRInlinedIfNilIfNotNil)});
  176. //>>excludeEnd("ctx");
  177. },
  178. //>>excludeStart("ide", pragmas.excludeIdeData);
  179. args: [],
  180. source: "internalVariables\x0a\x09^ Array with: self receiverInternalVariable",
  181. referencedClasses: ["Array"],
  182. //>>excludeEnd("ide");
  183. messageSends: ["with:", "receiverInternalVariable"]
  184. }),
  185. $globals.IRInlinedIfNilIfNotNil);
  186. $core.addMethod(
  187. $core.method({
  188. selector: "receiverInternalVariable",
  189. protocol: 'accessing',
  190. fn: function (){
  191. var self=this;
  192. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  193. return $core.withContext(function($ctx1) {
  194. //>>excludeEnd("ctx");
  195. var $1;
  196. $1=$recv($globals.IRVariable)._new();
  197. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  198. $ctx1.sendIdx["new"]=1;
  199. //>>excludeEnd("ctx");
  200. $recv($1)._variable_($recv($recv($globals.AliasVar)._new())._name_(self._receiverInternalVariableName()));
  201. return $recv($1)._yourself();
  202. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  203. }, function($ctx1) {$ctx1.fill(self,"receiverInternalVariable",{},$globals.IRInlinedIfNilIfNotNil)});
  204. //>>excludeEnd("ctx");
  205. },
  206. //>>excludeStart("ide", pragmas.excludeIdeData);
  207. args: [],
  208. source: "receiverInternalVariable\x0a\x09^ IRVariable new\x0a\x09\x09variable: (AliasVar new name: self receiverInternalVariableName);\x0a\x09\x09yourself.",
  209. referencedClasses: ["IRVariable", "AliasVar"],
  210. //>>excludeEnd("ide");
  211. messageSends: ["variable:", "new", "name:", "receiverInternalVariableName", "yourself"]
  212. }),
  213. $globals.IRInlinedIfNilIfNotNil);
  214. $core.addMethod(
  215. $core.method({
  216. selector: "receiverInternalVariableName",
  217. protocol: 'accessing',
  218. fn: function (){
  219. var self=this;
  220. return "$receiver";
  221. },
  222. //>>excludeStart("ide", pragmas.excludeIdeData);
  223. args: [],
  224. source: "receiverInternalVariableName\x0a\x09^ '$receiver'",
  225. referencedClasses: [],
  226. //>>excludeEnd("ide");
  227. messageSends: []
  228. }),
  229. $globals.IRInlinedIfNilIfNotNil);
  230. $core.addClass('IRInlinedIfTrue', $globals.IRInlinedSend, [], 'Compiler-Inlining');
  231. //>>excludeStart("ide", pragmas.excludeIdeData);
  232. $globals.IRInlinedIfTrue.comment="I represent an inlined `#ifTrue:` message send instruction.";
  233. //>>excludeEnd("ide");
  234. $core.addMethod(
  235. $core.method({
  236. selector: "accept:",
  237. protocol: 'visiting',
  238. fn: function (aVisitor){
  239. var self=this;
  240. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  241. return $core.withContext(function($ctx1) {
  242. //>>excludeEnd("ctx");
  243. $recv(aVisitor)._visitIRInlinedIfTrue_(self);
  244. return self;
  245. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  246. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},$globals.IRInlinedIfTrue)});
  247. //>>excludeEnd("ctx");
  248. },
  249. //>>excludeStart("ide", pragmas.excludeIdeData);
  250. args: ["aVisitor"],
  251. source: "accept: aVisitor\x0a\x09aVisitor visitIRInlinedIfTrue: self",
  252. referencedClasses: [],
  253. //>>excludeEnd("ide");
  254. messageSends: ["visitIRInlinedIfTrue:"]
  255. }),
  256. $globals.IRInlinedIfTrue);
  257. $core.addClass('IRInlinedIfTrueIfFalse', $globals.IRInlinedSend, [], 'Compiler-Inlining');
  258. //>>excludeStart("ide", pragmas.excludeIdeData);
  259. $globals.IRInlinedIfTrueIfFalse.comment="I represent an inlined `#ifTrue:ifFalse:` message send instruction.";
  260. //>>excludeEnd("ide");
  261. $core.addMethod(
  262. $core.method({
  263. selector: "accept:",
  264. protocol: 'visiting',
  265. fn: function (aVisitor){
  266. var self=this;
  267. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  268. return $core.withContext(function($ctx1) {
  269. //>>excludeEnd("ctx");
  270. $recv(aVisitor)._visitIRInlinedIfTrueIfFalse_(self);
  271. return self;
  272. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  273. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},$globals.IRInlinedIfTrueIfFalse)});
  274. //>>excludeEnd("ctx");
  275. },
  276. //>>excludeStart("ide", pragmas.excludeIdeData);
  277. args: ["aVisitor"],
  278. source: "accept: aVisitor\x0a\x09aVisitor visitIRInlinedIfTrueIfFalse: self",
  279. referencedClasses: [],
  280. //>>excludeEnd("ide");
  281. messageSends: ["visitIRInlinedIfTrueIfFalse:"]
  282. }),
  283. $globals.IRInlinedIfTrueIfFalse);
  284. $core.addClass('IRInlinedSequence', $globals.IRBlockSequence, [], 'Compiler-Inlining');
  285. //>>excludeStart("ide", pragmas.excludeIdeData);
  286. $globals.IRInlinedSequence.comment="I represent a (block) sequence inside an inlined closure instruction (instance of `IRInlinedClosure`).";
  287. //>>excludeEnd("ide");
  288. $core.addMethod(
  289. $core.method({
  290. selector: "accept:",
  291. protocol: 'visiting',
  292. fn: function (aVisitor){
  293. var self=this;
  294. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  295. return $core.withContext(function($ctx1) {
  296. //>>excludeEnd("ctx");
  297. $recv(aVisitor)._visitIRInlinedSequence_(self);
  298. return self;
  299. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  300. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},$globals.IRInlinedSequence)});
  301. //>>excludeEnd("ctx");
  302. },
  303. //>>excludeStart("ide", pragmas.excludeIdeData);
  304. args: ["aVisitor"],
  305. source: "accept: aVisitor\x0a\x09aVisitor visitIRInlinedSequence: self",
  306. referencedClasses: [],
  307. //>>excludeEnd("ide");
  308. messageSends: ["visitIRInlinedSequence:"]
  309. }),
  310. $globals.IRInlinedSequence);
  311. $core.addMethod(
  312. $core.method({
  313. selector: "isInlined",
  314. protocol: 'testing',
  315. fn: function (){
  316. var self=this;
  317. return true;
  318. },
  319. //>>excludeStart("ide", pragmas.excludeIdeData);
  320. args: [],
  321. source: "isInlined\x0a\x09^ true",
  322. referencedClasses: [],
  323. //>>excludeEnd("ide");
  324. messageSends: []
  325. }),
  326. $globals.IRInlinedSequence);
  327. $core.addClass('IRInliner', $globals.IRVisitor, [], 'Compiler-Inlining');
  328. //>>excludeStart("ide", pragmas.excludeIdeData);
  329. $globals.IRInliner.comment="I visit an IR tree, inlining message sends and block closures.\x0a\x0aMessage selectors that can be inlined are answered by `IRSendInliner >> #inlinedSelectors`";
  330. //>>excludeEnd("ide");
  331. $core.addMethod(
  332. $core.method({
  333. selector: "assignmentInliner",
  334. protocol: 'factory',
  335. fn: function (){
  336. var self=this;
  337. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  338. return $core.withContext(function($ctx1) {
  339. //>>excludeEnd("ctx");
  340. var $1;
  341. $1=$recv($globals.IRAssignmentInliner)._new();
  342. $recv($1)._translator_(self);
  343. return $recv($1)._yourself();
  344. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  345. }, function($ctx1) {$ctx1.fill(self,"assignmentInliner",{},$globals.IRInliner)});
  346. //>>excludeEnd("ctx");
  347. },
  348. //>>excludeStart("ide", pragmas.excludeIdeData);
  349. args: [],
  350. source: "assignmentInliner\x0a\x09^ IRAssignmentInliner new\x0a\x09\x09translator: self;\x0a\x09\x09yourself",
  351. referencedClasses: ["IRAssignmentInliner"],
  352. //>>excludeEnd("ide");
  353. messageSends: ["translator:", "new", "yourself"]
  354. }),
  355. $globals.IRInliner);
  356. $core.addMethod(
  357. $core.method({
  358. selector: "returnInliner",
  359. protocol: 'factory',
  360. fn: function (){
  361. var self=this;
  362. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  363. return $core.withContext(function($ctx1) {
  364. //>>excludeEnd("ctx");
  365. var $1;
  366. $1=$recv($globals.IRReturnInliner)._new();
  367. $recv($1)._translator_(self);
  368. return $recv($1)._yourself();
  369. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  370. }, function($ctx1) {$ctx1.fill(self,"returnInliner",{},$globals.IRInliner)});
  371. //>>excludeEnd("ctx");
  372. },
  373. //>>excludeStart("ide", pragmas.excludeIdeData);
  374. args: [],
  375. source: "returnInliner\x0a\x09^ IRReturnInliner new\x0a\x09\x09translator: self;\x0a\x09\x09yourself",
  376. referencedClasses: ["IRReturnInliner"],
  377. //>>excludeEnd("ide");
  378. messageSends: ["translator:", "new", "yourself"]
  379. }),
  380. $globals.IRInliner);
  381. $core.addMethod(
  382. $core.method({
  383. selector: "sendInliner",
  384. protocol: 'factory',
  385. fn: function (){
  386. var self=this;
  387. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  388. return $core.withContext(function($ctx1) {
  389. //>>excludeEnd("ctx");
  390. var $1;
  391. $1=$recv($globals.IRSendInliner)._new();
  392. $recv($1)._translator_(self);
  393. return $recv($1)._yourself();
  394. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  395. }, function($ctx1) {$ctx1.fill(self,"sendInliner",{},$globals.IRInliner)});
  396. //>>excludeEnd("ctx");
  397. },
  398. //>>excludeStart("ide", pragmas.excludeIdeData);
  399. args: [],
  400. source: "sendInliner\x0a\x09^ IRSendInliner new\x0a\x09\x09translator: self;\x0a\x09\x09yourself",
  401. referencedClasses: ["IRSendInliner"],
  402. //>>excludeEnd("ide");
  403. messageSends: ["translator:", "new", "yourself"]
  404. }),
  405. $globals.IRInliner);
  406. $core.addMethod(
  407. $core.method({
  408. selector: "shouldInlineAssignment:",
  409. protocol: 'testing',
  410. fn: function (anIRAssignment){
  411. var self=this;
  412. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  413. return $core.withContext(function($ctx1) {
  414. //>>excludeEnd("ctx");
  415. var $3,$2,$1;
  416. $1=$recv($recv($recv(anIRAssignment)._isInlined())._not())._and_((function(){
  417. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  418. return $core.withContext(function($ctx2) {
  419. //>>excludeEnd("ctx");
  420. $3=$recv(anIRAssignment)._right();
  421. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  422. $ctx2.sendIdx["right"]=1;
  423. //>>excludeEnd("ctx");
  424. $2=$recv($3)._isSend();
  425. return $recv($2)._and_((function(){
  426. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  427. return $core.withContext(function($ctx3) {
  428. //>>excludeEnd("ctx");
  429. return self._shouldInlineSend_($recv(anIRAssignment)._right());
  430. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  431. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)});
  432. //>>excludeEnd("ctx");
  433. }));
  434. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  435. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  436. //>>excludeEnd("ctx");
  437. }));
  438. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  439. $ctx1.sendIdx["and:"]=1;
  440. //>>excludeEnd("ctx");
  441. return $1;
  442. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  443. }, function($ctx1) {$ctx1.fill(self,"shouldInlineAssignment:",{anIRAssignment:anIRAssignment},$globals.IRInliner)});
  444. //>>excludeEnd("ctx");
  445. },
  446. //>>excludeStart("ide", pragmas.excludeIdeData);
  447. args: ["anIRAssignment"],
  448. source: "shouldInlineAssignment: anIRAssignment\x0a\x09^ anIRAssignment isInlined not and: [\x0a\x09\x09anIRAssignment right isSend and: [\x0a\x09\x09\x09self shouldInlineSend: anIRAssignment right ]]",
  449. referencedClasses: [],
  450. //>>excludeEnd("ide");
  451. messageSends: ["and:", "not", "isInlined", "isSend", "right", "shouldInlineSend:"]
  452. }),
  453. $globals.IRInliner);
  454. $core.addMethod(
  455. $core.method({
  456. selector: "shouldInlineReturn:",
  457. protocol: 'testing',
  458. fn: function (anIRReturn){
  459. var self=this;
  460. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  461. return $core.withContext(function($ctx1) {
  462. //>>excludeEnd("ctx");
  463. var $3,$2,$1;
  464. $1=$recv($recv($recv(anIRReturn)._isInlined())._not())._and_((function(){
  465. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  466. return $core.withContext(function($ctx2) {
  467. //>>excludeEnd("ctx");
  468. $3=$recv(anIRReturn)._expression();
  469. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  470. $ctx2.sendIdx["expression"]=1;
  471. //>>excludeEnd("ctx");
  472. $2=$recv($3)._isSend();
  473. return $recv($2)._and_((function(){
  474. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  475. return $core.withContext(function($ctx3) {
  476. //>>excludeEnd("ctx");
  477. return self._shouldInlineSend_($recv(anIRReturn)._expression());
  478. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  479. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)});
  480. //>>excludeEnd("ctx");
  481. }));
  482. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  483. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  484. //>>excludeEnd("ctx");
  485. }));
  486. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  487. $ctx1.sendIdx["and:"]=1;
  488. //>>excludeEnd("ctx");
  489. return $1;
  490. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  491. }, function($ctx1) {$ctx1.fill(self,"shouldInlineReturn:",{anIRReturn:anIRReturn},$globals.IRInliner)});
  492. //>>excludeEnd("ctx");
  493. },
  494. //>>excludeStart("ide", pragmas.excludeIdeData);
  495. args: ["anIRReturn"],
  496. source: "shouldInlineReturn: anIRReturn\x0a\x09^ anIRReturn isInlined not and: [\x0a\x09\x09anIRReturn expression isSend and: [\x0a\x09\x09\x09self shouldInlineSend: anIRReturn expression ]]",
  497. referencedClasses: [],
  498. //>>excludeEnd("ide");
  499. messageSends: ["and:", "not", "isInlined", "isSend", "expression", "shouldInlineSend:"]
  500. }),
  501. $globals.IRInliner);
  502. $core.addMethod(
  503. $core.method({
  504. selector: "shouldInlineSend:",
  505. protocol: 'testing',
  506. fn: function (anIRSend){
  507. var self=this;
  508. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  509. return $core.withContext(function($ctx1) {
  510. //>>excludeEnd("ctx");
  511. return $recv($recv($recv(anIRSend)._isInlined())._not())._and_((function(){
  512. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  513. return $core.withContext(function($ctx2) {
  514. //>>excludeEnd("ctx");
  515. return $recv($globals.IRSendInliner)._shouldInline_(anIRSend);
  516. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  517. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  518. //>>excludeEnd("ctx");
  519. }));
  520. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  521. }, function($ctx1) {$ctx1.fill(self,"shouldInlineSend:",{anIRSend:anIRSend},$globals.IRInliner)});
  522. //>>excludeEnd("ctx");
  523. },
  524. //>>excludeStart("ide", pragmas.excludeIdeData);
  525. args: ["anIRSend"],
  526. source: "shouldInlineSend: anIRSend\x0a\x09^ anIRSend isInlined not and: [\x0a\x09\x09IRSendInliner shouldInline: anIRSend ]",
  527. referencedClasses: ["IRSendInliner"],
  528. //>>excludeEnd("ide");
  529. messageSends: ["and:", "not", "isInlined", "shouldInline:"]
  530. }),
  531. $globals.IRInliner);
  532. $core.addMethod(
  533. $core.method({
  534. selector: "visitIRAssignment:",
  535. protocol: 'visiting',
  536. fn: function (anIRAssignment){
  537. var self=this;
  538. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  539. return $core.withContext(function($ctx1) {
  540. //>>excludeEnd("ctx");
  541. var $1;
  542. $1=self._shouldInlineAssignment_(anIRAssignment);
  543. if($core.assert($1)){
  544. return $recv(self._assignmentInliner())._inlineAssignment_(anIRAssignment);
  545. } else {
  546. return (
  547. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  548. $ctx1.supercall = true,
  549. //>>excludeEnd("ctx");
  550. ($globals.IRInliner.superclass||$boot.nilAsClass).fn.prototype._visitIRAssignment_.apply($recv(self), [anIRAssignment]));
  551. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  552. $ctx1.supercall = false;
  553. //>>excludeEnd("ctx");;
  554. };
  555. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  556. }, function($ctx1) {$ctx1.fill(self,"visitIRAssignment:",{anIRAssignment:anIRAssignment},$globals.IRInliner)});
  557. //>>excludeEnd("ctx");
  558. },
  559. //>>excludeStart("ide", pragmas.excludeIdeData);
  560. args: ["anIRAssignment"],
  561. source: "visitIRAssignment: anIRAssignment\x0a\x09^ (self shouldInlineAssignment: anIRAssignment)\x0a\x09\x09ifTrue: [ self assignmentInliner inlineAssignment: anIRAssignment ]\x0a\x09\x09ifFalse: [ super visitIRAssignment: anIRAssignment ]",
  562. referencedClasses: [],
  563. //>>excludeEnd("ide");
  564. messageSends: ["ifTrue:ifFalse:", "shouldInlineAssignment:", "inlineAssignment:", "assignmentInliner", "visitIRAssignment:"]
  565. }),
  566. $globals.IRInliner);
  567. $core.addMethod(
  568. $core.method({
  569. selector: "visitIRNonLocalReturn:",
  570. protocol: 'visiting',
  571. fn: function (anIRNonLocalReturn){
  572. var self=this;
  573. var localReturn;
  574. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  575. return $core.withContext(function($ctx1) {
  576. //>>excludeEnd("ctx");
  577. var $2,$1,$4,$3,$5,$6,$7;
  578. $2=$recv(anIRNonLocalReturn)._scope();
  579. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  580. $ctx1.sendIdx["scope"]=1;
  581. //>>excludeEnd("ctx");
  582. $1=$recv($2)._canInlineNonLocalReturns();
  583. if($core.assert($1)){
  584. $4=$recv(anIRNonLocalReturn)._scope();
  585. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  586. $ctx1.sendIdx["scope"]=2;
  587. //>>excludeEnd("ctx");
  588. $3=$recv($4)._methodScope();
  589. $5=$recv(anIRNonLocalReturn)._scope();
  590. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  591. $ctx1.sendIdx["scope"]=3;
  592. //>>excludeEnd("ctx");
  593. $recv($3)._removeNonLocalReturn_($5);
  594. $6=$recv($globals.IRReturn)._new();
  595. $recv($6)._scope_($recv(anIRNonLocalReturn)._scope());
  596. localReturn=$recv($6)._yourself();
  597. localReturn;
  598. $recv($recv(anIRNonLocalReturn)._instructions())._do_((function(each){
  599. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  600. return $core.withContext(function($ctx2) {
  601. //>>excludeEnd("ctx");
  602. return $recv(localReturn)._add_(each);
  603. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  604. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)});
  605. //>>excludeEnd("ctx");
  606. }));
  607. $recv(anIRNonLocalReturn)._replaceWith_(localReturn);
  608. return self._visitIRReturn_(localReturn);
  609. };
  610. $7=(
  611. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  612. $ctx1.supercall = true,
  613. //>>excludeEnd("ctx");
  614. ($globals.IRInliner.superclass||$boot.nilAsClass).fn.prototype._visitIRNonLocalReturn_.apply($recv(self), [anIRNonLocalReturn]));
  615. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  616. $ctx1.supercall = false;
  617. //>>excludeEnd("ctx");;
  618. return $7;
  619. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  620. }, function($ctx1) {$ctx1.fill(self,"visitIRNonLocalReturn:",{anIRNonLocalReturn:anIRNonLocalReturn,localReturn:localReturn},$globals.IRInliner)});
  621. //>>excludeEnd("ctx");
  622. },
  623. //>>excludeStart("ide", pragmas.excludeIdeData);
  624. args: ["anIRNonLocalReturn"],
  625. source: "visitIRNonLocalReturn: anIRNonLocalReturn\x0a\x09| localReturn |\x0a\x09anIRNonLocalReturn scope canInlineNonLocalReturns ifTrue: [\x0a\x09\x09anIRNonLocalReturn scope methodScope removeNonLocalReturn: anIRNonLocalReturn scope.\x0a\x09\x09localReturn := IRReturn new\x0a\x09\x09\x09scope: anIRNonLocalReturn scope;\x0a\x09\x09\x09yourself.\x0a\x09\x09anIRNonLocalReturn instructions do: [ :each |\x0a\x09\x09\x09localReturn add: each ].\x0a\x09\x09anIRNonLocalReturn replaceWith: localReturn.\x0a\x09\x09^ self visitIRReturn: localReturn ].\x0a\x09^ super visitIRNonLocalReturn: anIRNonLocalReturn",
  626. referencedClasses: ["IRReturn"],
  627. //>>excludeEnd("ide");
  628. messageSends: ["ifTrue:", "canInlineNonLocalReturns", "scope", "removeNonLocalReturn:", "methodScope", "scope:", "new", "yourself", "do:", "instructions", "add:", "replaceWith:", "visitIRReturn:", "visitIRNonLocalReturn:"]
  629. }),
  630. $globals.IRInliner);
  631. $core.addMethod(
  632. $core.method({
  633. selector: "visitIRReturn:",
  634. protocol: 'visiting',
  635. fn: function (anIRReturn){
  636. var self=this;
  637. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  638. return $core.withContext(function($ctx1) {
  639. //>>excludeEnd("ctx");
  640. var $1;
  641. $1=self._shouldInlineReturn_(anIRReturn);
  642. if($core.assert($1)){
  643. return $recv(self._returnInliner())._inlineReturn_(anIRReturn);
  644. } else {
  645. return (
  646. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  647. $ctx1.supercall = true,
  648. //>>excludeEnd("ctx");
  649. ($globals.IRInliner.superclass||$boot.nilAsClass).fn.prototype._visitIRReturn_.apply($recv(self), [anIRReturn]));
  650. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  651. $ctx1.supercall = false;
  652. //>>excludeEnd("ctx");;
  653. };
  654. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  655. }, function($ctx1) {$ctx1.fill(self,"visitIRReturn:",{anIRReturn:anIRReturn},$globals.IRInliner)});
  656. //>>excludeEnd("ctx");
  657. },
  658. //>>excludeStart("ide", pragmas.excludeIdeData);
  659. args: ["anIRReturn"],
  660. source: "visitIRReturn: anIRReturn\x0a\x09^ (self shouldInlineReturn: anIRReturn)\x0a\x09\x09ifTrue: [ self returnInliner inlineReturn: anIRReturn ]\x0a\x09\x09ifFalse: [ super visitIRReturn: anIRReturn ]",
  661. referencedClasses: [],
  662. //>>excludeEnd("ide");
  663. messageSends: ["ifTrue:ifFalse:", "shouldInlineReturn:", "inlineReturn:", "returnInliner", "visitIRReturn:"]
  664. }),
  665. $globals.IRInliner);
  666. $core.addMethod(
  667. $core.method({
  668. selector: "visitIRSend:",
  669. protocol: 'visiting',
  670. fn: function (anIRSend){
  671. var self=this;
  672. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  673. return $core.withContext(function($ctx1) {
  674. //>>excludeEnd("ctx");
  675. var $1;
  676. $1=self._shouldInlineSend_(anIRSend);
  677. if($core.assert($1)){
  678. return $recv(self._sendInliner())._inlineSend_(anIRSend);
  679. } else {
  680. return (
  681. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  682. $ctx1.supercall = true,
  683. //>>excludeEnd("ctx");
  684. ($globals.IRInliner.superclass||$boot.nilAsClass).fn.prototype._visitIRSend_.apply($recv(self), [anIRSend]));
  685. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  686. $ctx1.supercall = false;
  687. //>>excludeEnd("ctx");;
  688. };
  689. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  690. }, function($ctx1) {$ctx1.fill(self,"visitIRSend:",{anIRSend:anIRSend},$globals.IRInliner)});
  691. //>>excludeEnd("ctx");
  692. },
  693. //>>excludeStart("ide", pragmas.excludeIdeData);
  694. args: ["anIRSend"],
  695. source: "visitIRSend: anIRSend\x0a\x09^ (self shouldInlineSend: anIRSend)\x0a\x09\x09ifTrue: [ self sendInliner inlineSend: anIRSend ]\x0a\x09\x09ifFalse: [ super visitIRSend: anIRSend ]",
  696. referencedClasses: [],
  697. //>>excludeEnd("ide");
  698. messageSends: ["ifTrue:ifFalse:", "shouldInlineSend:", "inlineSend:", "sendInliner", "visitIRSend:"]
  699. }),
  700. $globals.IRInliner);
  701. $core.addClass('IRInliningJSTranslator', $globals.IRJSTranslator, [], 'Compiler-Inlining');
  702. //>>excludeStart("ide", pragmas.excludeIdeData);
  703. $globals.IRInliningJSTranslator.comment="I am a specialized JavaScript translator able to write inlined IR instructions to JavaScript stream (`JSStream` instance).";
  704. //>>excludeEnd("ide");
  705. $core.addMethod(
  706. $core.method({
  707. selector: "visitIRInlinedClosure:",
  708. protocol: 'visiting',
  709. fn: function (anIRInlinedClosure){
  710. var self=this;
  711. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  712. return $core.withContext(function($ctx1) {
  713. //>>excludeEnd("ctx");
  714. $recv(self._stream())._nextPutVars_($recv($recv(anIRInlinedClosure)._tempDeclarations())._collect_((function(each){
  715. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  716. return $core.withContext(function($ctx2) {
  717. //>>excludeEnd("ctx");
  718. return $recv($recv(each)._name())._asVariableName();
  719. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  720. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  721. //>>excludeEnd("ctx");
  722. })));
  723. $recv($recv(anIRInlinedClosure)._instructions())._do_((function(each){
  724. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  725. return $core.withContext(function($ctx2) {
  726. //>>excludeEnd("ctx");
  727. return self._visit_(each);
  728. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  729. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)});
  730. //>>excludeEnd("ctx");
  731. }));
  732. return self;
  733. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  734. }, function($ctx1) {$ctx1.fill(self,"visitIRInlinedClosure:",{anIRInlinedClosure:anIRInlinedClosure},$globals.IRInliningJSTranslator)});
  735. //>>excludeEnd("ctx");
  736. },
  737. //>>excludeStart("ide", pragmas.excludeIdeData);
  738. args: ["anIRInlinedClosure"],
  739. source: "visitIRInlinedClosure: anIRInlinedClosure\x0a\x09self stream nextPutVars: (anIRInlinedClosure tempDeclarations collect: [ :each |\x0a\x09\x09each name asVariableName ]).\x0a\x09anIRInlinedClosure instructions do: [ :each |\x0a\x09\x09self visit: each ]",
  740. referencedClasses: [],
  741. //>>excludeEnd("ide");
  742. messageSends: ["nextPutVars:", "stream", "collect:", "tempDeclarations", "asVariableName", "name", "do:", "instructions", "visit:"]
  743. }),
  744. $globals.IRInliningJSTranslator);
  745. $core.addMethod(
  746. $core.method({
  747. selector: "visitIRInlinedIfFalse:",
  748. protocol: 'visiting',
  749. fn: function (anIRInlinedIfFalse){
  750. var self=this;
  751. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  752. return $core.withContext(function($ctx1) {
  753. //>>excludeEnd("ctx");
  754. var $1,$2,$4,$3;
  755. $1=self._stream();
  756. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  757. $ctx1.sendIdx["stream"]=1;
  758. //>>excludeEnd("ctx");
  759. $recv($1)._nextPutIf_then_((function(){
  760. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  761. return $core.withContext(function($ctx2) {
  762. //>>excludeEnd("ctx");
  763. $2=self._stream();
  764. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  765. $ctx2.sendIdx["stream"]=2;
  766. //>>excludeEnd("ctx");
  767. $recv($2)._nextPutAll_("!$core.assert(");
  768. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  769. $ctx2.sendIdx["nextPutAll:"]=1;
  770. //>>excludeEnd("ctx");
  771. $4=$recv(anIRInlinedIfFalse)._instructions();
  772. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  773. $ctx2.sendIdx["instructions"]=1;
  774. //>>excludeEnd("ctx");
  775. $3=$recv($4)._first();
  776. self._visit_($3);
  777. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  778. $ctx2.sendIdx["visit:"]=1;
  779. //>>excludeEnd("ctx");
  780. return $recv(self._stream())._nextPutAll_(")");
  781. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  782. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  783. //>>excludeEnd("ctx");
  784. }),(function(){
  785. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  786. return $core.withContext(function($ctx2) {
  787. //>>excludeEnd("ctx");
  788. return self._visit_($recv($recv(anIRInlinedIfFalse)._instructions())._last());
  789. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  790. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  791. //>>excludeEnd("ctx");
  792. }));
  793. return self;
  794. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  795. }, function($ctx1) {$ctx1.fill(self,"visitIRInlinedIfFalse:",{anIRInlinedIfFalse:anIRInlinedIfFalse},$globals.IRInliningJSTranslator)});
  796. //>>excludeEnd("ctx");
  797. },
  798. //>>excludeStart("ide", pragmas.excludeIdeData);
  799. args: ["anIRInlinedIfFalse"],
  800. source: "visitIRInlinedIfFalse: anIRInlinedIfFalse\x0a\x09self stream nextPutIf: [\x0a\x09\x09self stream nextPutAll: '!$core.assert('.\x0a\x09\x09self visit: anIRInlinedIfFalse instructions first.\x0a\x09\x09self stream nextPutAll: ')' ]\x0a\x09\x09then: [ self visit: anIRInlinedIfFalse instructions last ]",
  801. referencedClasses: [],
  802. //>>excludeEnd("ide");
  803. messageSends: ["nextPutIf:then:", "stream", "nextPutAll:", "visit:", "first", "instructions", "last"]
  804. }),
  805. $globals.IRInliningJSTranslator);
  806. $core.addMethod(
  807. $core.method({
  808. selector: "visitIRInlinedIfNilIfNotNil:",
  809. protocol: 'visiting',
  810. fn: function (anIRInlinedIfNilIfNotNil){
  811. var self=this;
  812. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  813. return $core.withContext(function($ctx1) {
  814. //>>excludeEnd("ctx");
  815. var $1,$2,$4,$3,$6,$5,$7,$8,$10,$9;
  816. $1=self._stream();
  817. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  818. $ctx1.sendIdx["stream"]=1;
  819. //>>excludeEnd("ctx");
  820. $recv($1)._nextPutIf_then_else_((function(){
  821. var recvVarName;
  822. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  823. return $core.withContext(function($ctx2) {
  824. //>>excludeEnd("ctx");
  825. recvVarName=$recv(anIRInlinedIfNilIfNotNil)._receiverInternalVariableName();
  826. recvVarName;
  827. $2=self._stream();
  828. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  829. $ctx2.sendIdx["stream"]=2;
  830. //>>excludeEnd("ctx");
  831. $4="(".__comma(recvVarName);
  832. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  833. $ctx2.sendIdx[","]=2;
  834. //>>excludeEnd("ctx");
  835. $3=$recv($4).__comma(" = ");
  836. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  837. $ctx2.sendIdx[","]=1;
  838. //>>excludeEnd("ctx");
  839. $recv($2)._nextPutAll_($3);
  840. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  841. $ctx2.sendIdx["nextPutAll:"]=1;
  842. //>>excludeEnd("ctx");
  843. $6=$recv(anIRInlinedIfNilIfNotNil)._instructions();
  844. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  845. $ctx2.sendIdx["instructions"]=1;
  846. //>>excludeEnd("ctx");
  847. $5=$recv($6)._first();
  848. self._visit_($5);
  849. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  850. $ctx2.sendIdx["visit:"]=1;
  851. //>>excludeEnd("ctx");
  852. $7=self._stream();
  853. $8=$recv(") == null || ".__comma(recvVarName)).__comma(".isNil");
  854. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  855. $ctx2.sendIdx[","]=3;
  856. //>>excludeEnd("ctx");
  857. return $recv($7)._nextPutAll_($8);
  858. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  859. }, function($ctx2) {$ctx2.fillBlock({recvVarName:recvVarName},$ctx1,1)});
  860. //>>excludeEnd("ctx");
  861. }),(function(){
  862. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  863. return $core.withContext(function($ctx2) {
  864. //>>excludeEnd("ctx");
  865. $10=$recv(anIRInlinedIfNilIfNotNil)._instructions();
  866. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  867. $ctx2.sendIdx["instructions"]=2;
  868. //>>excludeEnd("ctx");
  869. $9=$recv($10)._second();
  870. return self._visit_($9);
  871. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  872. $ctx2.sendIdx["visit:"]=2;
  873. //>>excludeEnd("ctx");
  874. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  875. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  876. //>>excludeEnd("ctx");
  877. }),(function(){
  878. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  879. return $core.withContext(function($ctx2) {
  880. //>>excludeEnd("ctx");
  881. return self._visit_($recv($recv(anIRInlinedIfNilIfNotNil)._instructions())._third());
  882. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  883. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)});
  884. //>>excludeEnd("ctx");
  885. }));
  886. return self;
  887. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  888. }, function($ctx1) {$ctx1.fill(self,"visitIRInlinedIfNilIfNotNil:",{anIRInlinedIfNilIfNotNil:anIRInlinedIfNilIfNotNil},$globals.IRInliningJSTranslator)});
  889. //>>excludeEnd("ctx");
  890. },
  891. //>>excludeStart("ide", pragmas.excludeIdeData);
  892. args: ["anIRInlinedIfNilIfNotNil"],
  893. source: "visitIRInlinedIfNilIfNotNil: anIRInlinedIfNilIfNotNil\x0a\x09self stream\x0a\x09\x09nextPutIf: [\x0a\x09\x09\x09| recvVarName |\x0a\x09\x09\x09recvVarName := anIRInlinedIfNilIfNotNil receiverInternalVariableName.\x0a\x09\x09\x09self stream nextPutAll: '(', recvVarName, ' = '.\x0a\x09\x09\x09self visit: anIRInlinedIfNilIfNotNil instructions first.\x0a\x09\x09\x09self stream nextPutAll: ') == null || ', recvVarName, '.isNil' ]\x0a\x09\x09then: [ self visit: anIRInlinedIfNilIfNotNil instructions second ]\x0a\x09\x09else: [ self visit: anIRInlinedIfNilIfNotNil instructions third ]",
  894. referencedClasses: [],
  895. //>>excludeEnd("ide");
  896. messageSends: ["nextPutIf:then:else:", "stream", "receiverInternalVariableName", "nextPutAll:", ",", "visit:", "first", "instructions", "second", "third"]
  897. }),
  898. $globals.IRInliningJSTranslator);
  899. $core.addMethod(
  900. $core.method({
  901. selector: "visitIRInlinedIfTrue:",
  902. protocol: 'visiting',
  903. fn: function (anIRInlinedIfTrue){
  904. var self=this;
  905. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  906. return $core.withContext(function($ctx1) {
  907. //>>excludeEnd("ctx");
  908. var $1,$2,$4,$3;
  909. $1=self._stream();
  910. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  911. $ctx1.sendIdx["stream"]=1;
  912. //>>excludeEnd("ctx");
  913. $recv($1)._nextPutIf_then_((function(){
  914. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  915. return $core.withContext(function($ctx2) {
  916. //>>excludeEnd("ctx");
  917. $2=self._stream();
  918. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  919. $ctx2.sendIdx["stream"]=2;
  920. //>>excludeEnd("ctx");
  921. $recv($2)._nextPutAll_("$core.assert(");
  922. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  923. $ctx2.sendIdx["nextPutAll:"]=1;
  924. //>>excludeEnd("ctx");
  925. $4=$recv(anIRInlinedIfTrue)._instructions();
  926. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  927. $ctx2.sendIdx["instructions"]=1;
  928. //>>excludeEnd("ctx");
  929. $3=$recv($4)._first();
  930. self._visit_($3);
  931. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  932. $ctx2.sendIdx["visit:"]=1;
  933. //>>excludeEnd("ctx");
  934. return $recv(self._stream())._nextPutAll_(")");
  935. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  936. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  937. //>>excludeEnd("ctx");
  938. }),(function(){
  939. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  940. return $core.withContext(function($ctx2) {
  941. //>>excludeEnd("ctx");
  942. return self._visit_($recv($recv(anIRInlinedIfTrue)._instructions())._last());
  943. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  944. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  945. //>>excludeEnd("ctx");
  946. }));
  947. return self;
  948. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  949. }, function($ctx1) {$ctx1.fill(self,"visitIRInlinedIfTrue:",{anIRInlinedIfTrue:anIRInlinedIfTrue},$globals.IRInliningJSTranslator)});
  950. //>>excludeEnd("ctx");
  951. },
  952. //>>excludeStart("ide", pragmas.excludeIdeData);
  953. args: ["anIRInlinedIfTrue"],
  954. source: "visitIRInlinedIfTrue: anIRInlinedIfTrue\x0a\x09self stream nextPutIf: [\x0a\x09\x09self stream nextPutAll: '$core.assert('.\x0a\x09\x09self visit: anIRInlinedIfTrue instructions first.\x0a\x09\x09self stream nextPutAll: ')' ]\x0a\x09\x09then: [ self visit: anIRInlinedIfTrue instructions last ]",
  955. referencedClasses: [],
  956. //>>excludeEnd("ide");
  957. messageSends: ["nextPutIf:then:", "stream", "nextPutAll:", "visit:", "first", "instructions", "last"]
  958. }),
  959. $globals.IRInliningJSTranslator);
  960. $core.addMethod(
  961. $core.method({
  962. selector: "visitIRInlinedIfTrueIfFalse:",
  963. protocol: 'visiting',
  964. fn: function (anIRInlinedIfTrueIfFalse){
  965. var self=this;
  966. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  967. return $core.withContext(function($ctx1) {
  968. //>>excludeEnd("ctx");
  969. var $1,$2,$4,$3,$6,$5;
  970. $1=self._stream();
  971. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  972. $ctx1.sendIdx["stream"]=1;
  973. //>>excludeEnd("ctx");
  974. $recv($1)._nextPutIf_then_else_((function(){
  975. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  976. return $core.withContext(function($ctx2) {
  977. //>>excludeEnd("ctx");
  978. $2=self._stream();
  979. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  980. $ctx2.sendIdx["stream"]=2;
  981. //>>excludeEnd("ctx");
  982. $recv($2)._nextPutAll_("$core.assert(");
  983. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  984. $ctx2.sendIdx["nextPutAll:"]=1;
  985. //>>excludeEnd("ctx");
  986. $4=$recv(anIRInlinedIfTrueIfFalse)._instructions();
  987. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  988. $ctx2.sendIdx["instructions"]=1;
  989. //>>excludeEnd("ctx");
  990. $3=$recv($4)._first();
  991. self._visit_($3);
  992. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  993. $ctx2.sendIdx["visit:"]=1;
  994. //>>excludeEnd("ctx");
  995. return $recv(self._stream())._nextPutAll_(")");
  996. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  997. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  998. //>>excludeEnd("ctx");
  999. }),(function(){
  1000. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1001. return $core.withContext(function($ctx2) {
  1002. //>>excludeEnd("ctx");
  1003. $6=$recv(anIRInlinedIfTrueIfFalse)._instructions();
  1004. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1005. $ctx2.sendIdx["instructions"]=2;
  1006. //>>excludeEnd("ctx");
  1007. $5=$recv($6)._second();
  1008. return self._visit_($5);
  1009. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1010. $ctx2.sendIdx["visit:"]=2;
  1011. //>>excludeEnd("ctx");
  1012. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1013. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  1014. //>>excludeEnd("ctx");
  1015. }),(function(){
  1016. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1017. return $core.withContext(function($ctx2) {
  1018. //>>excludeEnd("ctx");
  1019. return self._visit_($recv($recv(anIRInlinedIfTrueIfFalse)._instructions())._third());
  1020. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1021. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)});
  1022. //>>excludeEnd("ctx");
  1023. }));
  1024. return self;
  1025. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1026. }, function($ctx1) {$ctx1.fill(self,"visitIRInlinedIfTrueIfFalse:",{anIRInlinedIfTrueIfFalse:anIRInlinedIfTrueIfFalse},$globals.IRInliningJSTranslator)});
  1027. //>>excludeEnd("ctx");
  1028. },
  1029. //>>excludeStart("ide", pragmas.excludeIdeData);
  1030. args: ["anIRInlinedIfTrueIfFalse"],
  1031. source: "visitIRInlinedIfTrueIfFalse: anIRInlinedIfTrueIfFalse\x0a\x09self stream\x0a\x09\x09nextPutIf: [\x0a\x09\x09\x09self stream nextPutAll: '$core.assert('.\x0a\x09\x09\x09self visit: anIRInlinedIfTrueIfFalse instructions first.\x0a\x09\x09\x09self stream nextPutAll: ')' ]\x0a\x09\x09then: [ self visit: anIRInlinedIfTrueIfFalse instructions second ]\x0a\x09\x09else: [ self visit: anIRInlinedIfTrueIfFalse instructions third ]",
  1032. referencedClasses: [],
  1033. //>>excludeEnd("ide");
  1034. messageSends: ["nextPutIf:then:else:", "stream", "nextPutAll:", "visit:", "first", "instructions", "second", "third"]
  1035. }),
  1036. $globals.IRInliningJSTranslator);
  1037. $core.addMethod(
  1038. $core.method({
  1039. selector: "visitIRInlinedSequence:",
  1040. protocol: 'visiting',
  1041. fn: function (anIRInlinedSequence){
  1042. var self=this;
  1043. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1044. return $core.withContext(function($ctx1) {
  1045. //>>excludeEnd("ctx");
  1046. $recv($recv(anIRInlinedSequence)._instructions())._do_((function(each){
  1047. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1048. return $core.withContext(function($ctx2) {
  1049. //>>excludeEnd("ctx");
  1050. return $recv(self._stream())._nextPutStatementWith_((function(){
  1051. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1052. return $core.withContext(function($ctx3) {
  1053. //>>excludeEnd("ctx");
  1054. return self._visit_(each);
  1055. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1056. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)});
  1057. //>>excludeEnd("ctx");
  1058. }));
  1059. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1060. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  1061. //>>excludeEnd("ctx");
  1062. }));
  1063. return self;
  1064. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1065. }, function($ctx1) {$ctx1.fill(self,"visitIRInlinedSequence:",{anIRInlinedSequence:anIRInlinedSequence},$globals.IRInliningJSTranslator)});
  1066. //>>excludeEnd("ctx");
  1067. },
  1068. //>>excludeStart("ide", pragmas.excludeIdeData);
  1069. args: ["anIRInlinedSequence"],
  1070. source: "visitIRInlinedSequence: anIRInlinedSequence\x0a\x09anIRInlinedSequence instructions do: [ :each |\x0a\x09\x09self stream nextPutStatementWith: [ self visit: each ]]",
  1071. referencedClasses: [],
  1072. //>>excludeEnd("ide");
  1073. messageSends: ["do:", "instructions", "nextPutStatementWith:", "stream", "visit:"]
  1074. }),
  1075. $globals.IRInliningJSTranslator);
  1076. $core.addClass('IRSendInliner', $globals.Object, ['send', 'translator'], 'Compiler-Inlining');
  1077. //>>excludeStart("ide", pragmas.excludeIdeData);
  1078. $globals.IRSendInliner.comment="I inline some message sends and block closure arguments. I heavily rely on #perform: to dispatch inlining methods.";
  1079. //>>excludeEnd("ide");
  1080. $core.addMethod(
  1081. $core.method({
  1082. selector: "ifFalse:",
  1083. protocol: 'inlining',
  1084. fn: function (anIRInstruction){
  1085. var self=this;
  1086. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1087. return $core.withContext(function($ctx1) {
  1088. //>>excludeEnd("ctx");
  1089. return self._inlinedSend_withBlock_($recv($globals.IRInlinedIfFalse)._new(),anIRInstruction);
  1090. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1091. }, function($ctx1) {$ctx1.fill(self,"ifFalse:",{anIRInstruction:anIRInstruction},$globals.IRSendInliner)});
  1092. //>>excludeEnd("ctx");
  1093. },
  1094. //>>excludeStart("ide", pragmas.excludeIdeData);
  1095. args: ["anIRInstruction"],
  1096. source: "ifFalse: anIRInstruction\x0a\x09^ self inlinedSend: IRInlinedIfFalse new withBlock: anIRInstruction",
  1097. referencedClasses: ["IRInlinedIfFalse"],
  1098. //>>excludeEnd("ide");
  1099. messageSends: ["inlinedSend:withBlock:", "new"]
  1100. }),
  1101. $globals.IRSendInliner);
  1102. $core.addMethod(
  1103. $core.method({
  1104. selector: "ifFalse:ifTrue:",
  1105. protocol: 'inlining',
  1106. fn: function (anIRInstruction,anotherIRInstruction){
  1107. var self=this;
  1108. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1109. return $core.withContext(function($ctx1) {
  1110. //>>excludeEnd("ctx");
  1111. return self._perform_withArguments_("ifTrue:ifFalse:",[anotherIRInstruction,anIRInstruction]);
  1112. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1113. }, function($ctx1) {$ctx1.fill(self,"ifFalse:ifTrue:",{anIRInstruction:anIRInstruction,anotherIRInstruction:anotherIRInstruction},$globals.IRSendInliner)});
  1114. //>>excludeEnd("ctx");
  1115. },
  1116. //>>excludeStart("ide", pragmas.excludeIdeData);
  1117. args: ["anIRInstruction", "anotherIRInstruction"],
  1118. source: "ifFalse: anIRInstruction ifTrue: anotherIRInstruction\x0a\x09^ self perform: #ifTrue:ifFalse: withArguments: { anotherIRInstruction. anIRInstruction }",
  1119. referencedClasses: [],
  1120. //>>excludeEnd("ide");
  1121. messageSends: ["perform:withArguments:"]
  1122. }),
  1123. $globals.IRSendInliner);
  1124. $core.addMethod(
  1125. $core.method({
  1126. selector: "ifNil:",
  1127. protocol: 'inlining',
  1128. fn: function (anIRInstruction){
  1129. var self=this;
  1130. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1131. return $core.withContext(function($ctx1) {
  1132. //>>excludeEnd("ctx");
  1133. var $1,$3,$5,$6,$4,$2;
  1134. $1=$recv($globals.IRInlinedIfNilIfNotNil)._new();
  1135. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1136. $ctx1.sendIdx["new"]=1;
  1137. //>>excludeEnd("ctx");
  1138. $3=$recv($globals.IRClosure)._new();
  1139. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1140. $ctx1.sendIdx["new"]=2;
  1141. //>>excludeEnd("ctx");
  1142. $recv($3)._scope_($recv($recv(anIRInstruction)._scope())._copy());
  1143. $5=$recv($globals.IRBlockSequence)._new();
  1144. $recv($5)._add_($recv(self._send())._receiver());
  1145. $6=$recv($5)._yourself();
  1146. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1147. $ctx1.sendIdx["yourself"]=1;
  1148. //>>excludeEnd("ctx");
  1149. $4=$6;
  1150. $recv($3)._add_($4);
  1151. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1152. $ctx1.sendIdx["add:"]=1;
  1153. //>>excludeEnd("ctx");
  1154. $2=$recv($3)._yourself();
  1155. return self._inlinedSend_withBlock_withBlock_($1,anIRInstruction,$2);
  1156. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1157. }, function($ctx1) {$ctx1.fill(self,"ifNil:",{anIRInstruction:anIRInstruction},$globals.IRSendInliner)});
  1158. //>>excludeEnd("ctx");
  1159. },
  1160. //>>excludeStart("ide", pragmas.excludeIdeData);
  1161. args: ["anIRInstruction"],
  1162. source: "ifNil: anIRInstruction\x0a\x09^ self\x0a\x09\x09inlinedSend: IRInlinedIfNilIfNotNil new\x0a\x09\x09withBlock: anIRInstruction\x0a\x09\x09withBlock: (IRClosure new\x0a\x09\x09\x09scope: anIRInstruction scope copy;\x0a\x09\x09\x09add: (IRBlockSequence new\x0a\x09\x09\x09\x09add: self send receiver;\x0a\x09\x09\x09\x09yourself);\x0a\x09\x09\x09yourself)",
  1163. referencedClasses: ["IRInlinedIfNilIfNotNil", "IRClosure", "IRBlockSequence"],
  1164. //>>excludeEnd("ide");
  1165. messageSends: ["inlinedSend:withBlock:withBlock:", "new", "scope:", "copy", "scope", "add:", "receiver", "send", "yourself"]
  1166. }),
  1167. $globals.IRSendInliner);
  1168. $core.addMethod(
  1169. $core.method({
  1170. selector: "ifNil:ifNotNil:",
  1171. protocol: 'inlining',
  1172. fn: function (anIRInstruction,anotherIRInstruction){
  1173. var self=this;
  1174. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1175. return $core.withContext(function($ctx1) {
  1176. //>>excludeEnd("ctx");
  1177. return self._inlinedSend_withBlock_withBlock_($recv($globals.IRInlinedIfNilIfNotNil)._new(),anIRInstruction,anotherIRInstruction);
  1178. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1179. }, function($ctx1) {$ctx1.fill(self,"ifNil:ifNotNil:",{anIRInstruction:anIRInstruction,anotherIRInstruction:anotherIRInstruction},$globals.IRSendInliner)});
  1180. //>>excludeEnd("ctx");
  1181. },
  1182. //>>excludeStart("ide", pragmas.excludeIdeData);
  1183. args: ["anIRInstruction", "anotherIRInstruction"],
  1184. source: "ifNil: anIRInstruction ifNotNil: anotherIRInstruction\x0a\x09^ self inlinedSend: IRInlinedIfNilIfNotNil new withBlock: anIRInstruction withBlock: anotherIRInstruction",
  1185. referencedClasses: ["IRInlinedIfNilIfNotNil"],
  1186. //>>excludeEnd("ide");
  1187. messageSends: ["inlinedSend:withBlock:withBlock:", "new"]
  1188. }),
  1189. $globals.IRSendInliner);
  1190. $core.addMethod(
  1191. $core.method({
  1192. selector: "ifNotNil:",
  1193. protocol: 'inlining',
  1194. fn: function (anIRInstruction){
  1195. var self=this;
  1196. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1197. return $core.withContext(function($ctx1) {
  1198. //>>excludeEnd("ctx");
  1199. var $1,$3,$5,$6,$4,$2;
  1200. $1=$recv($globals.IRInlinedIfNilIfNotNil)._new();
  1201. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1202. $ctx1.sendIdx["new"]=1;
  1203. //>>excludeEnd("ctx");
  1204. $3=$recv($globals.IRClosure)._new();
  1205. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1206. $ctx1.sendIdx["new"]=2;
  1207. //>>excludeEnd("ctx");
  1208. $recv($3)._scope_($recv($recv(anIRInstruction)._scope())._copy());
  1209. $5=$recv($globals.IRBlockSequence)._new();
  1210. $recv($5)._add_($recv(self._send())._receiver());
  1211. $6=$recv($5)._yourself();
  1212. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1213. $ctx1.sendIdx["yourself"]=1;
  1214. //>>excludeEnd("ctx");
  1215. $4=$6;
  1216. $recv($3)._add_($4);
  1217. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1218. $ctx1.sendIdx["add:"]=1;
  1219. //>>excludeEnd("ctx");
  1220. $2=$recv($3)._yourself();
  1221. return self._inlinedSend_withBlock_withBlock_($1,$2,anIRInstruction);
  1222. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1223. }, function($ctx1) {$ctx1.fill(self,"ifNotNil:",{anIRInstruction:anIRInstruction},$globals.IRSendInliner)});
  1224. //>>excludeEnd("ctx");
  1225. },
  1226. //>>excludeStart("ide", pragmas.excludeIdeData);
  1227. args: ["anIRInstruction"],
  1228. source: "ifNotNil: anIRInstruction\x0a\x09^ self\x0a\x09\x09inlinedSend: IRInlinedIfNilIfNotNil new\x0a\x09\x09withBlock: (IRClosure new\x0a\x09\x09\x09scope: anIRInstruction scope copy;\x0a\x09\x09\x09add: (IRBlockSequence new\x0a\x09\x09\x09\x09add: self send receiver;\x0a\x09\x09\x09\x09yourself);\x0a\x09\x09\x09yourself)\x0a\x09\x09withBlock: anIRInstruction",
  1229. referencedClasses: ["IRInlinedIfNilIfNotNil", "IRClosure", "IRBlockSequence"],
  1230. //>>excludeEnd("ide");
  1231. messageSends: ["inlinedSend:withBlock:withBlock:", "new", "scope:", "copy", "scope", "add:", "receiver", "send", "yourself"]
  1232. }),
  1233. $globals.IRSendInliner);
  1234. $core.addMethod(
  1235. $core.method({
  1236. selector: "ifNotNil:ifNil:",
  1237. protocol: 'inlining',
  1238. fn: function (anIRInstruction,anotherIRInstruction){
  1239. var self=this;
  1240. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1241. return $core.withContext(function($ctx1) {
  1242. //>>excludeEnd("ctx");
  1243. return self._inlinedSend_withBlock_withBlock_($recv($globals.IRInlinedIfNilIfNotNil)._new(),anotherIRInstruction,anIRInstruction);
  1244. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1245. }, function($ctx1) {$ctx1.fill(self,"ifNotNil:ifNil:",{anIRInstruction:anIRInstruction,anotherIRInstruction:anotherIRInstruction},$globals.IRSendInliner)});
  1246. //>>excludeEnd("ctx");
  1247. },
  1248. //>>excludeStart("ide", pragmas.excludeIdeData);
  1249. args: ["anIRInstruction", "anotherIRInstruction"],
  1250. source: "ifNotNil: anIRInstruction ifNil: anotherIRInstruction\x0a\x09^ self inlinedSend: IRInlinedIfNilIfNotNil new withBlock: anotherIRInstruction withBlock: anIRInstruction",
  1251. referencedClasses: ["IRInlinedIfNilIfNotNil"],
  1252. //>>excludeEnd("ide");
  1253. messageSends: ["inlinedSend:withBlock:withBlock:", "new"]
  1254. }),
  1255. $globals.IRSendInliner);
  1256. $core.addMethod(
  1257. $core.method({
  1258. selector: "ifTrue:",
  1259. protocol: 'inlining',
  1260. fn: function (anIRInstruction){
  1261. var self=this;
  1262. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1263. return $core.withContext(function($ctx1) {
  1264. //>>excludeEnd("ctx");
  1265. return self._inlinedSend_withBlock_($recv($globals.IRInlinedIfTrue)._new(),anIRInstruction);
  1266. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1267. }, function($ctx1) {$ctx1.fill(self,"ifTrue:",{anIRInstruction:anIRInstruction},$globals.IRSendInliner)});
  1268. //>>excludeEnd("ctx");
  1269. },
  1270. //>>excludeStart("ide", pragmas.excludeIdeData);
  1271. args: ["anIRInstruction"],
  1272. source: "ifTrue: anIRInstruction\x0a\x09^ self inlinedSend: IRInlinedIfTrue new withBlock: anIRInstruction",
  1273. referencedClasses: ["IRInlinedIfTrue"],
  1274. //>>excludeEnd("ide");
  1275. messageSends: ["inlinedSend:withBlock:", "new"]
  1276. }),
  1277. $globals.IRSendInliner);
  1278. $core.addMethod(
  1279. $core.method({
  1280. selector: "ifTrue:ifFalse:",
  1281. protocol: 'inlining',
  1282. fn: function (anIRInstruction,anotherIRInstruction){
  1283. var self=this;
  1284. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1285. return $core.withContext(function($ctx1) {
  1286. //>>excludeEnd("ctx");
  1287. return self._inlinedSend_withBlock_withBlock_($recv($globals.IRInlinedIfTrueIfFalse)._new(),anIRInstruction,anotherIRInstruction);
  1288. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1289. }, function($ctx1) {$ctx1.fill(self,"ifTrue:ifFalse:",{anIRInstruction:anIRInstruction,anotherIRInstruction:anotherIRInstruction},$globals.IRSendInliner)});
  1290. //>>excludeEnd("ctx");
  1291. },
  1292. //>>excludeStart("ide", pragmas.excludeIdeData);
  1293. args: ["anIRInstruction", "anotherIRInstruction"],
  1294. source: "ifTrue: anIRInstruction ifFalse: anotherIRInstruction\x0a\x09^ self inlinedSend: IRInlinedIfTrueIfFalse new withBlock: anIRInstruction withBlock: anotherIRInstruction",
  1295. referencedClasses: ["IRInlinedIfTrueIfFalse"],
  1296. //>>excludeEnd("ide");
  1297. messageSends: ["inlinedSend:withBlock:withBlock:", "new"]
  1298. }),
  1299. $globals.IRSendInliner);
  1300. $core.addMethod(
  1301. $core.method({
  1302. selector: "inlineClosure:",
  1303. protocol: 'inlining',
  1304. fn: function (anIRClosure){
  1305. var self=this;
  1306. var inlinedClosure,sequence,statements;
  1307. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1308. return $core.withContext(function($ctx1) {
  1309. //>>excludeEnd("ctx");
  1310. var $1,$2,$3,$5,$6,$4,$7,$9,$11,$13,$14,$15,$12,$10,$17,$19,$20,$18,$16,$8;
  1311. inlinedClosure=self._inlinedClosure();
  1312. $1=inlinedClosure;
  1313. $2=$recv(anIRClosure)._scope();
  1314. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1315. $ctx1.sendIdx["scope"]=1;
  1316. //>>excludeEnd("ctx");
  1317. $recv($1)._scope_($2);
  1318. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1319. $ctx1.sendIdx["scope:"]=1;
  1320. //>>excludeEnd("ctx");
  1321. $recv($1)._parent_($recv(anIRClosure)._parent());
  1322. $recv($recv(anIRClosure)._tempDeclarations())._do_((function(each){
  1323. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1324. return $core.withContext(function($ctx2) {
  1325. //>>excludeEnd("ctx");
  1326. return $recv(inlinedClosure)._add_(each);
  1327. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1328. $ctx2.sendIdx["add:"]=1;
  1329. //>>excludeEnd("ctx");
  1330. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1331. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  1332. //>>excludeEnd("ctx");
  1333. }));
  1334. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1335. $ctx1.sendIdx["do:"]=1;
  1336. //>>excludeEnd("ctx");
  1337. sequence=self._inlinedSequence();
  1338. $recv($recv(anIRClosure)._arguments())._do_((function(each){
  1339. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1340. return $core.withContext(function($ctx2) {
  1341. //>>excludeEnd("ctx");
  1342. $3=inlinedClosure;
  1343. $5=$recv($globals.IRTempDeclaration)._new();
  1344. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1345. $ctx2.sendIdx["new"]=1;
  1346. //>>excludeEnd("ctx");
  1347. $recv($5)._name_(each);
  1348. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1349. $ctx2.sendIdx["name:"]=1;
  1350. //>>excludeEnd("ctx");
  1351. $6=$recv($5)._yourself();
  1352. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1353. $ctx2.sendIdx["yourself"]=1;
  1354. //>>excludeEnd("ctx");
  1355. $4=$6;
  1356. $recv($3)._add_($4);
  1357. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1358. $ctx2.sendIdx["add:"]=2;
  1359. //>>excludeEnd("ctx");
  1360. $7=sequence;
  1361. $9=$recv($globals.IRAssignment)._new();
  1362. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1363. $ctx2.sendIdx["new"]=2;
  1364. //>>excludeEnd("ctx");
  1365. $11=$recv($globals.IRVariable)._new();
  1366. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1367. $ctx2.sendIdx["new"]=3;
  1368. //>>excludeEnd("ctx");
  1369. $13=$recv($globals.AliasVar)._new();
  1370. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1371. $ctx2.sendIdx["new"]=4;
  1372. //>>excludeEnd("ctx");
  1373. $14=$recv(inlinedClosure)._scope();
  1374. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1375. $ctx2.sendIdx["scope"]=2;
  1376. //>>excludeEnd("ctx");
  1377. $recv($13)._scope_($14);
  1378. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1379. $ctx2.sendIdx["scope:"]=2;
  1380. //>>excludeEnd("ctx");
  1381. $recv($13)._name_(each);
  1382. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1383. $ctx2.sendIdx["name:"]=2;
  1384. //>>excludeEnd("ctx");
  1385. $15=$recv($13)._yourself();
  1386. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1387. $ctx2.sendIdx["yourself"]=2;
  1388. //>>excludeEnd("ctx");
  1389. $12=$15;
  1390. $10=$recv($11)._variable_($12);
  1391. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1392. $ctx2.sendIdx["variable:"]=1;
  1393. //>>excludeEnd("ctx");
  1394. $recv($9)._add_($10);
  1395. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1396. $ctx2.sendIdx["add:"]=4;
  1397. //>>excludeEnd("ctx");
  1398. $17=$recv($globals.IRVariable)._new();
  1399. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1400. $ctx2.sendIdx["new"]=5;
  1401. //>>excludeEnd("ctx");
  1402. $19=$recv($globals.AliasVar)._new();
  1403. $recv($19)._scope_($recv(inlinedClosure)._scope());
  1404. $recv($19)._name_("$receiver");
  1405. $20=$recv($19)._yourself();
  1406. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1407. $ctx2.sendIdx["yourself"]=3;
  1408. //>>excludeEnd("ctx");
  1409. $18=$20;
  1410. $16=$recv($17)._variable_($18);
  1411. $recv($9)._add_($16);
  1412. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1413. $ctx2.sendIdx["add:"]=5;
  1414. //>>excludeEnd("ctx");
  1415. $8=$recv($9)._yourself();
  1416. return $recv($7)._add_($8);
  1417. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1418. $ctx2.sendIdx["add:"]=3;
  1419. //>>excludeEnd("ctx");
  1420. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1421. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)});
  1422. //>>excludeEnd("ctx");
  1423. }));
  1424. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1425. $ctx1.sendIdx["do:"]=2;
  1426. //>>excludeEnd("ctx");
  1427. $recv(inlinedClosure)._add_(sequence);
  1428. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1429. $ctx1.sendIdx["add:"]=6;
  1430. //>>excludeEnd("ctx");
  1431. statements=$recv($recv(anIRClosure)._sequence())._instructions();
  1432. $recv(statements)._ifNotEmpty_((function(){
  1433. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1434. return $core.withContext(function($ctx2) {
  1435. //>>excludeEnd("ctx");
  1436. $recv($recv(statements)._allButLast())._do_((function(each){
  1437. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1438. return $core.withContext(function($ctx3) {
  1439. //>>excludeEnd("ctx");
  1440. return $recv(sequence)._add_(each);
  1441. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1442. $ctx3.sendIdx["add:"]=7;
  1443. //>>excludeEnd("ctx");
  1444. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1445. }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx2,4)});
  1446. //>>excludeEnd("ctx");
  1447. }));
  1448. return $recv(sequence)._add_($recv($recv(statements)._last())._asInlinedBlockResult());
  1449. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1450. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)});
  1451. //>>excludeEnd("ctx");
  1452. }));
  1453. return inlinedClosure;
  1454. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1455. }, function($ctx1) {$ctx1.fill(self,"inlineClosure:",{anIRClosure:anIRClosure,inlinedClosure:inlinedClosure,sequence:sequence,statements:statements},$globals.IRSendInliner)});
  1456. //>>excludeEnd("ctx");
  1457. },
  1458. //>>excludeStart("ide", pragmas.excludeIdeData);
  1459. args: ["anIRClosure"],
  1460. source: "inlineClosure: anIRClosure\x0a\x09| inlinedClosure sequence statements |\x0a\x0a\x09inlinedClosure := self inlinedClosure.\x0a\x09inlinedClosure \x0a\x09\x09scope: anIRClosure scope;\x0a\x09\x09parent: anIRClosure parent.\x0a\x0a\x09\x22Add the possible temp declarations\x22\x0a\x09anIRClosure tempDeclarations do: [ :each |\x0a\x09\x09\x09inlinedClosure add: each ].\x0a\x0a\x09\x22Add a block sequence\x22\x0a\x09sequence := self inlinedSequence.\x0a\x0a\x09\x22Map the closure arguments to the receiver of the message send\x22\x0a\x09anIRClosure arguments do: [ :each |\x0a\x09\x09inlinedClosure add: (IRTempDeclaration new name: each; yourself).\x0a\x09\x09sequence add: (IRAssignment new\x0a\x09\x09\x09add: (IRVariable new variable: (AliasVar new scope: inlinedClosure scope; name: each; yourself));\x0a\x09\x09\x09add: (IRVariable new variable: (AliasVar new scope: inlinedClosure scope; name: '$receiver'; yourself));\x0a\x09\x09\x09yourself) ].\x0a\x09\x09\x09\x0a\x09\x22To ensure the correct order of the closure instructions: first the temps then the sequence\x22\x0a\x09inlinedClosure add: sequence.\x0a\x0a\x09\x22Get all the statements\x22\x0a\x09statements := anIRClosure sequence instructions.\x0a\x09\x0a\x09statements ifNotEmpty: [\x0a\x09\x09statements allButLast do: [ :each | sequence add: each ].\x0a\x0a\x09\x09\x22Inlined closures change local returns into result value itself\x22\x0a\x09\x09sequence add: statements last asInlinedBlockResult ].\x0a\x0a\x09^ inlinedClosure",
  1461. referencedClasses: ["IRTempDeclaration", "IRAssignment", "IRVariable", "AliasVar"],
  1462. //>>excludeEnd("ide");
  1463. messageSends: ["inlinedClosure", "scope:", "scope", "parent:", "parent", "do:", "tempDeclarations", "add:", "inlinedSequence", "arguments", "name:", "new", "yourself", "variable:", "instructions", "sequence", "ifNotEmpty:", "allButLast", "asInlinedBlockResult", "last"]
  1464. }),
  1465. $globals.IRSendInliner);
  1466. $core.addMethod(
  1467. $core.method({
  1468. selector: "inlineSend:",
  1469. protocol: 'inlining',
  1470. fn: function (anIRSend){
  1471. var self=this;
  1472. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1473. return $core.withContext(function($ctx1) {
  1474. //>>excludeEnd("ctx");
  1475. var $2,$1;
  1476. self._send_(anIRSend);
  1477. $2=self._send();
  1478. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1479. $ctx1.sendIdx["send"]=1;
  1480. //>>excludeEnd("ctx");
  1481. $1=$recv($2)._selector();
  1482. return self._perform_withArguments_($1,$recv(self._send())._arguments());
  1483. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1484. }, function($ctx1) {$ctx1.fill(self,"inlineSend:",{anIRSend:anIRSend},$globals.IRSendInliner)});
  1485. //>>excludeEnd("ctx");
  1486. },
  1487. //>>excludeStart("ide", pragmas.excludeIdeData);
  1488. args: ["anIRSend"],
  1489. source: "inlineSend: anIRSend\x0a\x09self send: anIRSend.\x0a\x09^ self\x0a\x09\x09perform: self send selector\x0a\x09\x09withArguments: self send arguments",
  1490. referencedClasses: [],
  1491. //>>excludeEnd("ide");
  1492. messageSends: ["send:", "perform:withArguments:", "selector", "send", "arguments"]
  1493. }),
  1494. $globals.IRSendInliner);
  1495. $core.addMethod(
  1496. $core.method({
  1497. selector: "inlineSend:andReplace:",
  1498. protocol: 'private',
  1499. fn: function (anIRSend,anIRInstruction){
  1500. var self=this;
  1501. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1502. return $core.withContext(function($ctx1) {
  1503. //>>excludeEnd("ctx");
  1504. $recv(anIRInstruction)._replaceWith_(anIRSend);
  1505. return self._inlineSend_(anIRSend);
  1506. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1507. }, function($ctx1) {$ctx1.fill(self,"inlineSend:andReplace:",{anIRSend:anIRSend,anIRInstruction:anIRInstruction},$globals.IRSendInliner)});
  1508. //>>excludeEnd("ctx");
  1509. },
  1510. //>>excludeStart("ide", pragmas.excludeIdeData);
  1511. args: ["anIRSend", "anIRInstruction"],
  1512. source: "inlineSend: anIRSend andReplace: anIRInstruction\x0a\x09anIRInstruction replaceWith: anIRSend.\x0a\x09^ self inlineSend: anIRSend",
  1513. referencedClasses: [],
  1514. //>>excludeEnd("ide");
  1515. messageSends: ["replaceWith:", "inlineSend:"]
  1516. }),
  1517. $globals.IRSendInliner);
  1518. $core.addMethod(
  1519. $core.method({
  1520. selector: "inlinedClosure",
  1521. protocol: 'factory',
  1522. fn: function (){
  1523. var self=this;
  1524. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1525. return $core.withContext(function($ctx1) {
  1526. //>>excludeEnd("ctx");
  1527. return $recv($globals.IRInlinedClosure)._new();
  1528. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1529. }, function($ctx1) {$ctx1.fill(self,"inlinedClosure",{},$globals.IRSendInliner)});
  1530. //>>excludeEnd("ctx");
  1531. },
  1532. //>>excludeStart("ide", pragmas.excludeIdeData);
  1533. args: [],
  1534. source: "inlinedClosure\x0a\x09^ IRInlinedClosure new",
  1535. referencedClasses: ["IRInlinedClosure"],
  1536. //>>excludeEnd("ide");
  1537. messageSends: ["new"]
  1538. }),
  1539. $globals.IRSendInliner);
  1540. $core.addMethod(
  1541. $core.method({
  1542. selector: "inlinedSend:withBlock:",
  1543. protocol: 'private',
  1544. fn: function (inlinedSend,anIRInstruction){
  1545. var self=this;
  1546. var inlinedClosure;
  1547. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1548. return $core.withContext(function($ctx1) {
  1549. //>>excludeEnd("ctx");
  1550. var $1,$2,$4,$3,$5;
  1551. $1=$recv(anIRInstruction)._isClosure();
  1552. if(!$core.assert($1)){
  1553. self._inliningError_("Message argument should be a block");
  1554. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1555. $ctx1.sendIdx["inliningError:"]=1;
  1556. //>>excludeEnd("ctx");
  1557. };
  1558. $2=$recv($recv($recv(anIRInstruction)._arguments())._size()).__eq((0));
  1559. if(!$core.assert($2)){
  1560. self._inliningError_("Inlined block should have zero argument");
  1561. };
  1562. inlinedClosure=$recv(self._translator())._visit_(self._inlineClosure_(anIRInstruction));
  1563. $4=self._send();
  1564. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1565. $ctx1.sendIdx["send"]=1;
  1566. //>>excludeEnd("ctx");
  1567. $3=$recv($4)._receiver();
  1568. $recv(inlinedSend)._add_($3);
  1569. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1570. $ctx1.sendIdx["add:"]=1;
  1571. //>>excludeEnd("ctx");
  1572. $recv(inlinedSend)._add_(inlinedClosure);
  1573. $recv(self._send())._replaceWith_(inlinedSend);
  1574. $5=$recv($recv(inlinedSend)._method())._internalVariables();
  1575. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1576. $ctx1.sendIdx["internalVariables"]=1;
  1577. //>>excludeEnd("ctx");
  1578. $recv($5)._addAll_($recv(inlinedSend)._internalVariables());
  1579. return inlinedSend;
  1580. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1581. }, function($ctx1) {$ctx1.fill(self,"inlinedSend:withBlock:",{inlinedSend:inlinedSend,anIRInstruction:anIRInstruction,inlinedClosure:inlinedClosure},$globals.IRSendInliner)});
  1582. //>>excludeEnd("ctx");
  1583. },
  1584. //>>excludeStart("ide", pragmas.excludeIdeData);
  1585. args: ["inlinedSend", "anIRInstruction"],
  1586. source: "inlinedSend: inlinedSend withBlock: anIRInstruction\x0a\x09| inlinedClosure |\x0a\x0a\x09anIRInstruction isClosure ifFalse: [ self inliningError: 'Message argument should be a block' ].\x0a\x09anIRInstruction arguments size = 0 ifFalse: [ self inliningError: 'Inlined block should have zero argument' ].\x0a\x0a\x09inlinedClosure := self translator visit: (self inlineClosure: anIRInstruction).\x0a\x0a\x09inlinedSend\x0a\x09\x09add: self send receiver;\x0a\x09\x09add: inlinedClosure.\x0a\x0a\x09self send replaceWith: inlinedSend.\x0a\x09inlinedSend method internalVariables \x0a\x09\x09addAll: inlinedSend internalVariables.\x0a\x0a\x09^ inlinedSend",
  1587. referencedClasses: [],
  1588. //>>excludeEnd("ide");
  1589. messageSends: ["ifFalse:", "isClosure", "inliningError:", "=", "size", "arguments", "visit:", "translator", "inlineClosure:", "add:", "receiver", "send", "replaceWith:", "addAll:", "internalVariables", "method"]
  1590. }),
  1591. $globals.IRSendInliner);
  1592. $core.addMethod(
  1593. $core.method({
  1594. selector: "inlinedSend:withBlock:withBlock:",
  1595. protocol: 'private',
  1596. fn: function (inlinedSend,anIRInstruction,anotherIRInstruction){
  1597. var self=this;
  1598. var inlinedClosure1,inlinedClosure2;
  1599. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1600. return $core.withContext(function($ctx1) {
  1601. //>>excludeEnd("ctx");
  1602. var $1,$2,$3,$4,$6,$5,$7;
  1603. $1=$recv(anIRInstruction)._isClosure();
  1604. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1605. $ctx1.sendIdx["isClosure"]=1;
  1606. //>>excludeEnd("ctx");
  1607. if(!$core.assert($1)){
  1608. self._inliningError_("Message argument should be a block");
  1609. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1610. $ctx1.sendIdx["inliningError:"]=1;
  1611. //>>excludeEnd("ctx");
  1612. };
  1613. $2=$recv(anotherIRInstruction)._isClosure();
  1614. if(!$core.assert($2)){
  1615. self._inliningError_("Message argument should be a block");
  1616. };
  1617. $3=self._translator();
  1618. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1619. $ctx1.sendIdx["translator"]=1;
  1620. //>>excludeEnd("ctx");
  1621. $4=self._inlineClosure_(anIRInstruction);
  1622. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1623. $ctx1.sendIdx["inlineClosure:"]=1;
  1624. //>>excludeEnd("ctx");
  1625. inlinedClosure1=$recv($3)._visit_($4);
  1626. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1627. $ctx1.sendIdx["visit:"]=1;
  1628. //>>excludeEnd("ctx");
  1629. inlinedClosure2=$recv(self._translator())._visit_(self._inlineClosure_(anotherIRInstruction));
  1630. $6=self._send();
  1631. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1632. $ctx1.sendIdx["send"]=1;
  1633. //>>excludeEnd("ctx");
  1634. $5=$recv($6)._receiver();
  1635. $recv(inlinedSend)._add_($5);
  1636. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1637. $ctx1.sendIdx["add:"]=1;
  1638. //>>excludeEnd("ctx");
  1639. $recv(inlinedSend)._add_(inlinedClosure1);
  1640. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1641. $ctx1.sendIdx["add:"]=2;
  1642. //>>excludeEnd("ctx");
  1643. $recv(inlinedSend)._add_(inlinedClosure2);
  1644. $recv(self._send())._replaceWith_(inlinedSend);
  1645. $7=$recv($recv(inlinedSend)._method())._internalVariables();
  1646. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1647. $ctx1.sendIdx["internalVariables"]=1;
  1648. //>>excludeEnd("ctx");
  1649. $recv($7)._addAll_($recv(inlinedSend)._internalVariables());
  1650. return inlinedSend;
  1651. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1652. }, function($ctx1) {$ctx1.fill(self,"inlinedSend:withBlock:withBlock:",{inlinedSend:inlinedSend,anIRInstruction:anIRInstruction,anotherIRInstruction:anotherIRInstruction,inlinedClosure1:inlinedClosure1,inlinedClosure2:inlinedClosure2},$globals.IRSendInliner)});
  1653. //>>excludeEnd("ctx");
  1654. },
  1655. //>>excludeStart("ide", pragmas.excludeIdeData);
  1656. args: ["inlinedSend", "anIRInstruction", "anotherIRInstruction"],
  1657. source: "inlinedSend: inlinedSend withBlock: anIRInstruction withBlock: anotherIRInstruction\x0a\x09| inlinedClosure1 inlinedClosure2 |\x0a\x0a\x09anIRInstruction isClosure ifFalse: [ self inliningError: 'Message argument should be a block' ].\x0a\x09anotherIRInstruction isClosure ifFalse: [ self inliningError: 'Message argument should be a block' ].\x0a\x0a\x09inlinedClosure1 := self translator visit: (self inlineClosure: anIRInstruction).\x0a\x09inlinedClosure2 := self translator visit: (self inlineClosure: anotherIRInstruction).\x0a\x0a\x09inlinedSend\x0a\x09\x09add: self send receiver;\x0a\x09\x09add: inlinedClosure1;\x0a\x09\x09add: inlinedClosure2.\x0a\x0a\x09self send replaceWith: inlinedSend.\x0a\x09inlinedSend method internalVariables \x0a\x09\x09addAll: inlinedSend internalVariables.\x0a\x09\x09\x0a\x09^ inlinedSend",
  1658. referencedClasses: [],
  1659. //>>excludeEnd("ide");
  1660. messageSends: ["ifFalse:", "isClosure", "inliningError:", "visit:", "translator", "inlineClosure:", "add:", "receiver", "send", "replaceWith:", "addAll:", "internalVariables", "method"]
  1661. }),
  1662. $globals.IRSendInliner);
  1663. $core.addMethod(
  1664. $core.method({
  1665. selector: "inlinedSequence",
  1666. protocol: 'factory',
  1667. fn: function (){
  1668. var self=this;
  1669. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1670. return $core.withContext(function($ctx1) {
  1671. //>>excludeEnd("ctx");
  1672. return $recv($globals.IRInlinedSequence)._new();
  1673. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1674. }, function($ctx1) {$ctx1.fill(self,"inlinedSequence",{},$globals.IRSendInliner)});
  1675. //>>excludeEnd("ctx");
  1676. },
  1677. //>>excludeStart("ide", pragmas.excludeIdeData);
  1678. args: [],
  1679. source: "inlinedSequence\x0a\x09^ IRInlinedSequence new",
  1680. referencedClasses: ["IRInlinedSequence"],
  1681. //>>excludeEnd("ide");
  1682. messageSends: ["new"]
  1683. }),
  1684. $globals.IRSendInliner);
  1685. $core.addMethod(
  1686. $core.method({
  1687. selector: "inliningError:",
  1688. protocol: 'error handling',
  1689. fn: function (aString){
  1690. var self=this;
  1691. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1692. return $core.withContext(function($ctx1) {
  1693. //>>excludeEnd("ctx");
  1694. $recv($globals.InliningError)._signal_(aString);
  1695. return self;
  1696. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1697. }, function($ctx1) {$ctx1.fill(self,"inliningError:",{aString:aString},$globals.IRSendInliner)});
  1698. //>>excludeEnd("ctx");
  1699. },
  1700. //>>excludeStart("ide", pragmas.excludeIdeData);
  1701. args: ["aString"],
  1702. source: "inliningError: aString\x0a\x09InliningError signal: aString",
  1703. referencedClasses: ["InliningError"],
  1704. //>>excludeEnd("ide");
  1705. messageSends: ["signal:"]
  1706. }),
  1707. $globals.IRSendInliner);
  1708. $core.addMethod(
  1709. $core.method({
  1710. selector: "send",
  1711. protocol: 'accessing',
  1712. fn: function (){
  1713. var self=this;
  1714. return self["@send"];
  1715. },
  1716. //>>excludeStart("ide", pragmas.excludeIdeData);
  1717. args: [],
  1718. source: "send\x0a\x09^ send",
  1719. referencedClasses: [],
  1720. //>>excludeEnd("ide");
  1721. messageSends: []
  1722. }),
  1723. $globals.IRSendInliner);
  1724. $core.addMethod(
  1725. $core.method({
  1726. selector: "send:",
  1727. protocol: 'accessing',
  1728. fn: function (anIRSend){
  1729. var self=this;
  1730. self["@send"]=anIRSend;
  1731. return self;
  1732. },
  1733. //>>excludeStart("ide", pragmas.excludeIdeData);
  1734. args: ["anIRSend"],
  1735. source: "send: anIRSend\x0a\x09send := anIRSend",
  1736. referencedClasses: [],
  1737. //>>excludeEnd("ide");
  1738. messageSends: []
  1739. }),
  1740. $globals.IRSendInliner);
  1741. $core.addMethod(
  1742. $core.method({
  1743. selector: "translator",
  1744. protocol: 'accessing',
  1745. fn: function (){
  1746. var self=this;
  1747. return self["@translator"];
  1748. },
  1749. //>>excludeStart("ide", pragmas.excludeIdeData);
  1750. args: [],
  1751. source: "translator\x0a\x09^ translator",
  1752. referencedClasses: [],
  1753. //>>excludeEnd("ide");
  1754. messageSends: []
  1755. }),
  1756. $globals.IRSendInliner);
  1757. $core.addMethod(
  1758. $core.method({
  1759. selector: "translator:",
  1760. protocol: 'accessing',
  1761. fn: function (anASTTranslator){
  1762. var self=this;
  1763. self["@translator"]=anASTTranslator;
  1764. return self;
  1765. },
  1766. //>>excludeStart("ide", pragmas.excludeIdeData);
  1767. args: ["anASTTranslator"],
  1768. source: "translator: anASTTranslator\x0a\x09translator := anASTTranslator",
  1769. referencedClasses: [],
  1770. //>>excludeEnd("ide");
  1771. messageSends: []
  1772. }),
  1773. $globals.IRSendInliner);
  1774. $core.addMethod(
  1775. $core.method({
  1776. selector: "inlinedSelectors",
  1777. protocol: 'accessing',
  1778. fn: function (){
  1779. var self=this;
  1780. return ["ifTrue:", "ifFalse:", "ifTrue:ifFalse:", "ifFalse:ifTrue:", "ifNil:", "ifNotNil:", "ifNil:ifNotNil:", "ifNotNil:ifNil:"];
  1781. },
  1782. //>>excludeStart("ide", pragmas.excludeIdeData);
  1783. args: [],
  1784. source: "inlinedSelectors\x0a\x09^ #('ifTrue:' 'ifFalse:' 'ifTrue:ifFalse:' 'ifFalse:ifTrue:' 'ifNil:' 'ifNotNil:' 'ifNil:ifNotNil:' 'ifNotNil:ifNil:')",
  1785. referencedClasses: [],
  1786. //>>excludeEnd("ide");
  1787. messageSends: []
  1788. }),
  1789. $globals.IRSendInliner.klass);
  1790. $core.addMethod(
  1791. $core.method({
  1792. selector: "shouldInline:",
  1793. protocol: 'accessing',
  1794. fn: function (anIRSend){
  1795. var self=this;
  1796. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1797. return $core.withContext(function($ctx1) {
  1798. //>>excludeEnd("ctx");
  1799. var $1;
  1800. $1=$recv(self._inlinedSelectors())._includes_($recv(anIRSend)._selector());
  1801. if(!$core.assert($1)){
  1802. return false;
  1803. };
  1804. return $recv($recv(anIRSend)._arguments())._allSatisfy_((function(each){
  1805. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1806. return $core.withContext(function($ctx2) {
  1807. //>>excludeEnd("ctx");
  1808. return $recv(each)._isClosure();
  1809. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1810. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)});
  1811. //>>excludeEnd("ctx");
  1812. }));
  1813. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1814. }, function($ctx1) {$ctx1.fill(self,"shouldInline:",{anIRSend:anIRSend},$globals.IRSendInliner.klass)});
  1815. //>>excludeEnd("ctx");
  1816. },
  1817. //>>excludeStart("ide", pragmas.excludeIdeData);
  1818. args: ["anIRSend"],
  1819. source: "shouldInline: anIRSend\x0a\x09(self inlinedSelectors includes: anIRSend selector) ifFalse: [ ^ false ].\x0a\x09^ anIRSend arguments allSatisfy: [ :each | each isClosure ]",
  1820. referencedClasses: [],
  1821. //>>excludeEnd("ide");
  1822. messageSends: ["ifFalse:", "includes:", "inlinedSelectors", "selector", "allSatisfy:", "arguments", "isClosure"]
  1823. }),
  1824. $globals.IRSendInliner.klass);
  1825. $core.addClass('IRAssignmentInliner', $globals.IRSendInliner, ['target'], 'Compiler-Inlining');
  1826. //>>excludeStart("ide", pragmas.excludeIdeData);
  1827. $globals.IRAssignmentInliner.comment="I inline message sends together with assignments by moving them around into the inline closure instructions.\x0a\x0a##Example\x0a\x0a\x09foo\x0a\x09\x09| a |\x0a\x09\x09a := true ifTrue: [ 1 ]\x0a\x0aWill produce:\x0a\x0a\x09if($core.assert(true) {\x0a\x09\x09a = 1;\x0a\x09};";
  1828. //>>excludeEnd("ide");
  1829. $core.addMethod(
  1830. $core.method({
  1831. selector: "inlineAssignment:",
  1832. protocol: 'inlining',
  1833. fn: function (anIRAssignment){
  1834. var self=this;
  1835. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1836. return $core.withContext(function($ctx1) {
  1837. //>>excludeEnd("ctx");
  1838. self._target_($recv(anIRAssignment)._left());
  1839. return self._inlineSend_andReplace_($recv(anIRAssignment)._right(),anIRAssignment);
  1840. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1841. }, function($ctx1) {$ctx1.fill(self,"inlineAssignment:",{anIRAssignment:anIRAssignment},$globals.IRAssignmentInliner)});
  1842. //>>excludeEnd("ctx");
  1843. },
  1844. //>>excludeStart("ide", pragmas.excludeIdeData);
  1845. args: ["anIRAssignment"],
  1846. source: "inlineAssignment: anIRAssignment\x0a\x09self target: anIRAssignment left.\x0a\x09^ self inlineSend: anIRAssignment right andReplace: anIRAssignment",
  1847. referencedClasses: [],
  1848. //>>excludeEnd("ide");
  1849. messageSends: ["target:", "left", "inlineSend:andReplace:", "right"]
  1850. }),
  1851. $globals.IRAssignmentInliner);
  1852. $core.addMethod(
  1853. $core.method({
  1854. selector: "inlineClosure:",
  1855. protocol: 'inlining',
  1856. fn: function (anIRClosure){
  1857. var self=this;
  1858. var closure,sequence,statements;
  1859. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1860. return $core.withContext(function($ctx1) {
  1861. //>>excludeEnd("ctx");
  1862. var $1,$2,$3,$5,$4;
  1863. closure=(
  1864. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1865. $ctx1.supercall = true,
  1866. //>>excludeEnd("ctx");
  1867. ($globals.IRAssignmentInliner.superclass||$boot.nilAsClass).fn.prototype._inlineClosure_.apply($recv(self), [anIRClosure]));
  1868. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1869. $ctx1.supercall = false;
  1870. //>>excludeEnd("ctx");;
  1871. sequence=$recv(closure)._sequence();
  1872. statements=$recv(sequence)._instructions();
  1873. $recv(statements)._ifNotEmpty_((function(){
  1874. var final;
  1875. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1876. return $core.withContext(function($ctx2) {
  1877. //>>excludeEnd("ctx");
  1878. final=$recv(statements)._last();
  1879. final;
  1880. $1=$recv(final)._yieldsValue();
  1881. if($core.assert($1)){
  1882. $2=sequence;
  1883. $3=final;
  1884. $5=$recv($globals.IRAssignment)._new();
  1885. $recv($5)._add_(self._target());
  1886. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1887. $ctx2.sendIdx["add:"]=1;
  1888. //>>excludeEnd("ctx");
  1889. $recv($5)._add_($recv(final)._copy());
  1890. $4=$recv($5)._yourself();
  1891. return $recv($2)._replace_with_($3,$4);
  1892. };
  1893. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1894. }, function($ctx2) {$ctx2.fillBlock({final:final},$ctx1,1)});
  1895. //>>excludeEnd("ctx");
  1896. }));
  1897. return closure;
  1898. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1899. }, function($ctx1) {$ctx1.fill(self,"inlineClosure:",{anIRClosure:anIRClosure,closure:closure,sequence:sequence,statements:statements},$globals.IRAssignmentInliner)});
  1900. //>>excludeEnd("ctx");
  1901. },
  1902. //>>excludeStart("ide", pragmas.excludeIdeData);
  1903. args: ["anIRClosure"],
  1904. source: "inlineClosure: anIRClosure\x0a\x09| closure sequence statements |\x0a\x0a\x09closure := super inlineClosure: anIRClosure.\x0a\x09sequence := closure sequence.\x0a\x09statements := sequence instructions.\x0a\x09\x0a\x09statements ifNotEmpty: [\x0a\x09\x09| final |\x0a\x09\x09final := statements last.\x0a\x09\x09final yieldsValue ifTrue: [\x0a\x09\x09\x09sequence replace: final with: (IRAssignment new\x0a\x09\x09\x09\x09add: self target;\x0a\x09\x09\x09\x09add: final copy;\x0a\x09\x09\x09\x09yourself) ] ].\x0a\x0a\x09^ closure",
  1905. referencedClasses: ["IRAssignment"],
  1906. //>>excludeEnd("ide");
  1907. messageSends: ["inlineClosure:", "sequence", "instructions", "ifNotEmpty:", "last", "ifTrue:", "yieldsValue", "replace:with:", "add:", "new", "target", "copy", "yourself"]
  1908. }),
  1909. $globals.IRAssignmentInliner);
  1910. $core.addMethod(
  1911. $core.method({
  1912. selector: "target",
  1913. protocol: 'accessing',
  1914. fn: function (){
  1915. var self=this;
  1916. return self["@target"];
  1917. },
  1918. //>>excludeStart("ide", pragmas.excludeIdeData);
  1919. args: [],
  1920. source: "target\x0a\x09^ target",
  1921. referencedClasses: [],
  1922. //>>excludeEnd("ide");
  1923. messageSends: []
  1924. }),
  1925. $globals.IRAssignmentInliner);
  1926. $core.addMethod(
  1927. $core.method({
  1928. selector: "target:",
  1929. protocol: 'accessing',
  1930. fn: function (anObject){
  1931. var self=this;
  1932. self["@target"]=anObject;
  1933. return self;
  1934. },
  1935. //>>excludeStart("ide", pragmas.excludeIdeData);
  1936. args: ["anObject"],
  1937. source: "target: anObject\x0a\x09target := anObject",
  1938. referencedClasses: [],
  1939. //>>excludeEnd("ide");
  1940. messageSends: []
  1941. }),
  1942. $globals.IRAssignmentInliner);
  1943. $core.addClass('IRReturnInliner', $globals.IRSendInliner, [], 'Compiler-Inlining');
  1944. //>>excludeStart("ide", pragmas.excludeIdeData);
  1945. $globals.IRReturnInliner.comment="I inline message sends with inlined closure together with a return instruction.";
  1946. //>>excludeEnd("ide");
  1947. $core.addMethod(
  1948. $core.method({
  1949. selector: "inlineClosure:",
  1950. protocol: 'inlining',
  1951. fn: function (anIRClosure){
  1952. var self=this;
  1953. var closure,sequence,statements;
  1954. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1955. return $core.withContext(function($ctx1) {
  1956. //>>excludeEnd("ctx");
  1957. var $1,$2,$3,$5,$4;
  1958. closure=(
  1959. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1960. $ctx1.supercall = true,
  1961. //>>excludeEnd("ctx");
  1962. ($globals.IRReturnInliner.superclass||$boot.nilAsClass).fn.prototype._inlineClosure_.apply($recv(self), [anIRClosure]));
  1963. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1964. $ctx1.supercall = false;
  1965. //>>excludeEnd("ctx");;
  1966. sequence=$recv(closure)._sequence();
  1967. statements=$recv(sequence)._instructions();
  1968. $recv(statements)._ifNotEmpty_((function(){
  1969. var final;
  1970. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1971. return $core.withContext(function($ctx2) {
  1972. //>>excludeEnd("ctx");
  1973. final=$recv(statements)._last();
  1974. final;
  1975. $1=$recv(final)._yieldsValue();
  1976. if($core.assert($1)){
  1977. $2=sequence;
  1978. $3=final;
  1979. $5=$recv($globals.IRReturn)._new();
  1980. $recv($5)._add_($recv(final)._copy());
  1981. $4=$recv($5)._yourself();
  1982. return $recv($2)._replace_with_($3,$4);
  1983. };
  1984. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1985. }, function($ctx2) {$ctx2.fillBlock({final:final},$ctx1,1)});
  1986. //>>excludeEnd("ctx");
  1987. }));
  1988. return closure;
  1989. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1990. }, function($ctx1) {$ctx1.fill(self,"inlineClosure:",{anIRClosure:anIRClosure,closure:closure,sequence:sequence,statements:statements},$globals.IRReturnInliner)});
  1991. //>>excludeEnd("ctx");
  1992. },
  1993. //>>excludeStart("ide", pragmas.excludeIdeData);
  1994. args: ["anIRClosure"],
  1995. source: "inlineClosure: anIRClosure\x0a\x09| closure sequence statements |\x0a\x0a\x09closure := super inlineClosure: anIRClosure.\x0a\x09sequence := closure sequence.\x0a\x09statements := sequence instructions.\x0a\x09\x0a\x09statements ifNotEmpty: [\x0a\x09\x09| final |\x0a\x09\x09final := statements last.\x0a\x09\x09final yieldsValue ifTrue: [\x0a\x09\x09\x09sequence replace: final with: (IRReturn new\x0a\x09\x09\x09\x09add: final copy;\x0a\x09\x09\x09\x09yourself) ] ].\x0a\x0a\x09^ closure",
  1996. referencedClasses: ["IRReturn"],
  1997. //>>excludeEnd("ide");
  1998. messageSends: ["inlineClosure:", "sequence", "instructions", "ifNotEmpty:", "last", "ifTrue:", "yieldsValue", "replace:with:", "add:", "new", "copy", "yourself"]
  1999. }),
  2000. $globals.IRReturnInliner);
  2001. $core.addMethod(
  2002. $core.method({
  2003. selector: "inlineReturn:",
  2004. protocol: 'inlining',
  2005. fn: function (anIRReturn){
  2006. var self=this;
  2007. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2008. return $core.withContext(function($ctx1) {
  2009. //>>excludeEnd("ctx");
  2010. return self._inlineSend_andReplace_($recv(anIRReturn)._expression(),anIRReturn);
  2011. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2012. }, function($ctx1) {$ctx1.fill(self,"inlineReturn:",{anIRReturn:anIRReturn},$globals.IRReturnInliner)});
  2013. //>>excludeEnd("ctx");
  2014. },
  2015. //>>excludeStart("ide", pragmas.excludeIdeData);
  2016. args: ["anIRReturn"],
  2017. source: "inlineReturn: anIRReturn\x0a\x09^ self inlineSend: anIRReturn expression andReplace: anIRReturn",
  2018. referencedClasses: [],
  2019. //>>excludeEnd("ide");
  2020. messageSends: ["inlineSend:andReplace:", "expression"]
  2021. }),
  2022. $globals.IRReturnInliner);
  2023. $core.addClass('InliningCodeGenerator', $globals.CodeGenerator, [], 'Compiler-Inlining');
  2024. //>>excludeStart("ide", pragmas.excludeIdeData);
  2025. $globals.InliningCodeGenerator.comment="I am a specialized code generator that uses inlining to produce more optimized JavaScript output";
  2026. //>>excludeEnd("ide");
  2027. $core.addMethod(
  2028. $core.method({
  2029. selector: "compileNode:",
  2030. protocol: 'compiling',
  2031. fn: function (aNode){
  2032. var self=this;
  2033. var ir,stream;
  2034. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2035. return $core.withContext(function($ctx1) {
  2036. //>>excludeEnd("ctx");
  2037. var $1;
  2038. $recv(self._semanticAnalyzer())._visit_(aNode);
  2039. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2040. $ctx1.sendIdx["visit:"]=1;
  2041. //>>excludeEnd("ctx");
  2042. ir=$recv(self._translator())._visit_(aNode);
  2043. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2044. $ctx1.sendIdx["visit:"]=2;
  2045. //>>excludeEnd("ctx");
  2046. $recv(self._inliner())._visit_(ir);
  2047. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2048. $ctx1.sendIdx["visit:"]=3;
  2049. //>>excludeEnd("ctx");
  2050. $1=self._irTranslator();
  2051. $recv($1)._currentClass_(self._currentClass());
  2052. $recv($1)._visit_(ir);
  2053. return $recv($1)._contents();
  2054. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2055. }, function($ctx1) {$ctx1.fill(self,"compileNode:",{aNode:aNode,ir:ir,stream:stream},$globals.InliningCodeGenerator)});
  2056. //>>excludeEnd("ctx");
  2057. },
  2058. //>>excludeStart("ide", pragmas.excludeIdeData);
  2059. args: ["aNode"],
  2060. source: "compileNode: aNode\x0a\x09| ir stream |\x0a\x0a\x09self semanticAnalyzer visit: aNode.\x0a\x09ir := self translator visit: aNode.\x0a\x09self inliner visit: ir.\x0a\x0a\x09^ self irTranslator\x0a\x09\x09currentClass: self currentClass;\x0a\x09\x09visit: ir;\x0a\x09\x09contents",
  2061. referencedClasses: [],
  2062. //>>excludeEnd("ide");
  2063. messageSends: ["visit:", "semanticAnalyzer", "translator", "inliner", "currentClass:", "irTranslator", "currentClass", "contents"]
  2064. }),
  2065. $globals.InliningCodeGenerator);
  2066. $core.addMethod(
  2067. $core.method({
  2068. selector: "inliner",
  2069. protocol: 'compiling',
  2070. fn: function (){
  2071. var self=this;
  2072. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2073. return $core.withContext(function($ctx1) {
  2074. //>>excludeEnd("ctx");
  2075. return $recv($globals.IRInliner)._new();
  2076. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2077. }, function($ctx1) {$ctx1.fill(self,"inliner",{},$globals.InliningCodeGenerator)});
  2078. //>>excludeEnd("ctx");
  2079. },
  2080. //>>excludeStart("ide", pragmas.excludeIdeData);
  2081. args: [],
  2082. source: "inliner\x0a\x09^ IRInliner new",
  2083. referencedClasses: ["IRInliner"],
  2084. //>>excludeEnd("ide");
  2085. messageSends: ["new"]
  2086. }),
  2087. $globals.InliningCodeGenerator);
  2088. $core.addMethod(
  2089. $core.method({
  2090. selector: "irTranslator",
  2091. protocol: 'compiling',
  2092. fn: function (){
  2093. var self=this;
  2094. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2095. return $core.withContext(function($ctx1) {
  2096. //>>excludeEnd("ctx");
  2097. return $recv($globals.IRInliningJSTranslator)._new();
  2098. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2099. }, function($ctx1) {$ctx1.fill(self,"irTranslator",{},$globals.InliningCodeGenerator)});
  2100. //>>excludeEnd("ctx");
  2101. },
  2102. //>>excludeStart("ide", pragmas.excludeIdeData);
  2103. args: [],
  2104. source: "irTranslator\x0a\x09^ IRInliningJSTranslator new",
  2105. referencedClasses: ["IRInliningJSTranslator"],
  2106. //>>excludeEnd("ide");
  2107. messageSends: ["new"]
  2108. }),
  2109. $globals.InliningCodeGenerator);
  2110. $core.addMethod(
  2111. $core.method({
  2112. selector: "semanticAnalyzerClass",
  2113. protocol: 'compiling',
  2114. fn: function (){
  2115. var self=this;
  2116. return $globals.InliningSemanticAnalyzer;
  2117. },
  2118. //>>excludeStart("ide", pragmas.excludeIdeData);
  2119. args: [],
  2120. source: "semanticAnalyzerClass\x0a\x09^ InliningSemanticAnalyzer",
  2121. referencedClasses: ["InliningSemanticAnalyzer"],
  2122. //>>excludeEnd("ide");
  2123. messageSends: []
  2124. }),
  2125. $globals.InliningCodeGenerator);
  2126. $core.addClass('InliningError', $globals.SemanticError, [], 'Compiler-Inlining');
  2127. //>>excludeStart("ide", pragmas.excludeIdeData);
  2128. $globals.InliningError.comment="Instances of InliningError are signaled when using an `InliningCodeGenerator`in a `Compiler`.";
  2129. //>>excludeEnd("ide");
  2130. $core.addClass('InliningSemanticAnalyzer', $globals.SemanticAnalyzer, [], 'Compiler-Inlining');
  2131. $core.addMethod(
  2132. $core.method({
  2133. selector: "visitSendNode:",
  2134. protocol: 'visiting',
  2135. fn: function (aNode){
  2136. var self=this;
  2137. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2138. return $core.withContext(function($ctx1) {
  2139. //>>excludeEnd("ctx");
  2140. var $1,$2,$3,$receiver;
  2141. $1=$recv(aNode)._superSend();
  2142. if(!$core.assert($1)){
  2143. $2=$recv($recv($globals.IRSendInliner)._inlinedSelectors())._includes_($recv(aNode)._selector());
  2144. if($core.assert($2)){
  2145. $recv(aNode)._shouldBeInlined_(true);
  2146. $3=$recv(aNode)._receiver();
  2147. if(($receiver = $3) == null || $receiver.isNil){
  2148. $3;
  2149. } else {
  2150. var receiver;
  2151. receiver=$receiver;
  2152. $recv(receiver)._shouldBeAliased_(true);
  2153. };
  2154. };
  2155. };
  2156. (
  2157. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2158. $ctx1.supercall = true,
  2159. //>>excludeEnd("ctx");
  2160. ($globals.InliningSemanticAnalyzer.superclass||$boot.nilAsClass).fn.prototype._visitSendNode_.apply($recv(self), [aNode]));
  2161. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2162. $ctx1.supercall = false;
  2163. //>>excludeEnd("ctx");;
  2164. return self;
  2165. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2166. }, function($ctx1) {$ctx1.fill(self,"visitSendNode:",{aNode:aNode},$globals.InliningSemanticAnalyzer)});
  2167. //>>excludeEnd("ctx");
  2168. },
  2169. //>>excludeStart("ide", pragmas.excludeIdeData);
  2170. args: ["aNode"],
  2171. source: "visitSendNode: aNode\x0a\x0a\x09aNode superSend ifFalse: [ \x0a\x09\x09(IRSendInliner inlinedSelectors includes: aNode selector) ifTrue: [\x0a\x09\x09\x09aNode shouldBeInlined: true.\x0a\x09\x09\x09aNode receiver ifNotNil: [ :receiver |\x0a\x09\x09\x09\x09receiver shouldBeAliased: true ] ] ].\x0a\x0a\x09super visitSendNode: aNode",
  2172. referencedClasses: ["IRSendInliner"],
  2173. //>>excludeEnd("ide");
  2174. messageSends: ["ifFalse:", "superSend", "ifTrue:", "includes:", "inlinedSelectors", "selector", "shouldBeInlined:", "ifNotNil:", "receiver", "shouldBeAliased:", "visitSendNode:"]
  2175. }),
  2176. $globals.InliningSemanticAnalyzer);
  2177. $core.addMethod(
  2178. $core.method({
  2179. selector: "asInlinedBlockResult",
  2180. protocol: '*Compiler-Inlining',
  2181. fn: function (){
  2182. var self=this;
  2183. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2184. return $core.withContext(function($ctx1) {
  2185. //>>excludeEnd("ctx");
  2186. return self._expression();
  2187. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2188. }, function($ctx1) {$ctx1.fill(self,"asInlinedBlockResult",{},$globals.IRBlockReturn)});
  2189. //>>excludeEnd("ctx");
  2190. },
  2191. //>>excludeStart("ide", pragmas.excludeIdeData);
  2192. args: [],
  2193. source: "asInlinedBlockResult\x0a\x09^ self expression",
  2194. referencedClasses: [],
  2195. //>>excludeEnd("ide");
  2196. messageSends: ["expression"]
  2197. }),
  2198. $globals.IRBlockReturn);
  2199. $core.addMethod(
  2200. $core.method({
  2201. selector: "asInlinedBlockResult",
  2202. protocol: '*Compiler-Inlining',
  2203. fn: function (){
  2204. var self=this;
  2205. return self;
  2206. },
  2207. //>>excludeStart("ide", pragmas.excludeIdeData);
  2208. args: [],
  2209. source: "asInlinedBlockResult\x0a\x09^ self",
  2210. referencedClasses: [],
  2211. //>>excludeEnd("ide");
  2212. messageSends: []
  2213. }),
  2214. $globals.IRInstruction);
  2215. });