1
0

Compiler-Inlining.js 87 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327
  1. define(["amber/boot", "amber_core/Compiler-AST", "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('ASTPreInliner', $globals.NodeVisitor, [], 'Compiler-Inlining');
  9. $core.addMethod(
  10. $core.method({
  11. selector: "visitSendNode:",
  12. protocol: 'visiting',
  13. fn: function (aNode){
  14. var self=this;
  15. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  16. return $core.withContext(function($ctx1) {
  17. //>>excludeEnd("ctx");
  18. var $1,$2,$3,$4,$receiver;
  19. $1=$recv(aNode)._superSend();
  20. if(!$core.assert($1)){
  21. $2=$recv($recv($globals.IRSendInliner)._inlinedSelectors())._includes_($recv(aNode)._selector());
  22. if($core.assert($2)){
  23. $recv(aNode)._shouldBeInlined_(true);
  24. $3=$recv(aNode)._receiver();
  25. if(($receiver = $3) == null || $receiver.isNil){
  26. $3;
  27. } else {
  28. var receiver;
  29. receiver=$receiver;
  30. $recv(receiver)._shouldBeAliased_(true);
  31. }
  32. }
  33. }
  34. $4=(
  35. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  36. $ctx1.supercall = true,
  37. //>>excludeEnd("ctx");
  38. ($globals.ASTPreInliner.superclass||$boot.nilAsClass).fn.prototype._visitSendNode_.apply($recv(self), [aNode]));
  39. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  40. $ctx1.supercall = false;
  41. //>>excludeEnd("ctx");;
  42. return $4;
  43. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  44. }, function($ctx1) {$ctx1.fill(self,"visitSendNode:",{aNode:aNode},$globals.ASTPreInliner)});
  45. //>>excludeEnd("ctx");
  46. },
  47. //>>excludeStart("ide", pragmas.excludeIdeData);
  48. args: ["aNode"],
  49. 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\x09^ super visitSendNode: aNode",
  50. referencedClasses: ["IRSendInliner"],
  51. //>>excludeEnd("ide");
  52. messageSends: ["ifFalse:", "superSend", "ifTrue:", "includes:", "inlinedSelectors", "selector", "shouldBeInlined:", "ifNotNil:", "receiver", "shouldBeAliased:", "visitSendNode:"]
  53. }),
  54. $globals.ASTPreInliner);
  55. $core.addClass('IRInlinedClosure', $globals.IRClosure, [], 'Compiler-Inlining');
  56. //>>excludeStart("ide", pragmas.excludeIdeData);
  57. $globals.IRInlinedClosure.comment="I represent an inlined closure instruction.";
  58. //>>excludeEnd("ide");
  59. $core.addMethod(
  60. $core.method({
  61. selector: "acceptDagVisitor:",
  62. protocol: 'visiting',
  63. fn: function (aVisitor){
  64. var self=this;
  65. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  66. return $core.withContext(function($ctx1) {
  67. //>>excludeEnd("ctx");
  68. $recv(aVisitor)._visitIRInlinedClosure_(self);
  69. return self;
  70. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  71. }, function($ctx1) {$ctx1.fill(self,"acceptDagVisitor:",{aVisitor:aVisitor},$globals.IRInlinedClosure)});
  72. //>>excludeEnd("ctx");
  73. },
  74. //>>excludeStart("ide", pragmas.excludeIdeData);
  75. args: ["aVisitor"],
  76. source: "acceptDagVisitor: aVisitor\x0a\x09aVisitor visitIRInlinedClosure: self",
  77. referencedClasses: [],
  78. //>>excludeEnd("ide");
  79. messageSends: ["visitIRInlinedClosure:"]
  80. }),
  81. $globals.IRInlinedClosure);
  82. $core.addMethod(
  83. $core.method({
  84. selector: "isInlined",
  85. protocol: 'testing',
  86. fn: function (){
  87. var self=this;
  88. return true;
  89. },
  90. //>>excludeStart("ide", pragmas.excludeIdeData);
  91. args: [],
  92. source: "isInlined\x0a\x09^ true",
  93. referencedClasses: [],
  94. //>>excludeEnd("ide");
  95. messageSends: []
  96. }),
  97. $globals.IRInlinedClosure);
  98. $core.addClass('IRInlinedSend', $globals.IRSend, [], 'Compiler-Inlining');
  99. //>>excludeStart("ide", pragmas.excludeIdeData);
  100. $globals.IRInlinedSend.comment="I am the abstract super class of inlined message send instructions.";
  101. //>>excludeEnd("ide");
  102. $core.addMethod(
  103. $core.method({
  104. selector: "acceptDagVisitor:",
  105. protocol: 'visiting',
  106. fn: function (aVisitor){
  107. var self=this;
  108. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  109. return $core.withContext(function($ctx1) {
  110. //>>excludeEnd("ctx");
  111. $recv(aVisitor)._visitInlinedSend_(self);
  112. return self;
  113. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  114. }, function($ctx1) {$ctx1.fill(self,"acceptDagVisitor:",{aVisitor:aVisitor},$globals.IRInlinedSend)});
  115. //>>excludeEnd("ctx");
  116. },
  117. //>>excludeStart("ide", pragmas.excludeIdeData);
  118. args: ["aVisitor"],
  119. source: "acceptDagVisitor: aVisitor\x0a\x09aVisitor visitInlinedSend: self",
  120. referencedClasses: [],
  121. //>>excludeEnd("ide");
  122. messageSends: ["visitInlinedSend:"]
  123. }),
  124. $globals.IRInlinedSend);
  125. $core.addMethod(
  126. $core.method({
  127. selector: "internalVariables",
  128. protocol: 'accessing',
  129. fn: function (){
  130. var self=this;
  131. return [];
  132. },
  133. //>>excludeStart("ide", pragmas.excludeIdeData);
  134. args: [],
  135. source: "internalVariables\x0a\x09\x22Answer a collection of internal variables required \x0a\x09to perform the inlining\x22\x0a\x09\x0a\x09^ #()",
  136. referencedClasses: [],
  137. //>>excludeEnd("ide");
  138. messageSends: []
  139. }),
  140. $globals.IRInlinedSend);
  141. $core.addMethod(
  142. $core.method({
  143. selector: "isInlined",
  144. protocol: 'testing',
  145. fn: function (){
  146. var self=this;
  147. return true;
  148. },
  149. //>>excludeStart("ide", pragmas.excludeIdeData);
  150. args: [],
  151. source: "isInlined\x0a\x09^ true",
  152. referencedClasses: [],
  153. //>>excludeEnd("ide");
  154. messageSends: []
  155. }),
  156. $globals.IRInlinedSend);
  157. $core.addClass('IRInlinedIfFalse', $globals.IRInlinedSend, [], 'Compiler-Inlining');
  158. //>>excludeStart("ide", pragmas.excludeIdeData);
  159. $globals.IRInlinedIfFalse.comment="I represent an inlined `#ifFalse:` message send instruction.";
  160. //>>excludeEnd("ide");
  161. $core.addMethod(
  162. $core.method({
  163. selector: "acceptDagVisitor:",
  164. protocol: 'visiting',
  165. fn: function (aVisitor){
  166. var self=this;
  167. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  168. return $core.withContext(function($ctx1) {
  169. //>>excludeEnd("ctx");
  170. $recv(aVisitor)._visitIRInlinedIfFalse_(self);
  171. return self;
  172. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  173. }, function($ctx1) {$ctx1.fill(self,"acceptDagVisitor:",{aVisitor:aVisitor},$globals.IRInlinedIfFalse)});
  174. //>>excludeEnd("ctx");
  175. },
  176. //>>excludeStart("ide", pragmas.excludeIdeData);
  177. args: ["aVisitor"],
  178. source: "acceptDagVisitor: aVisitor\x0a\x09aVisitor visitIRInlinedIfFalse: self",
  179. referencedClasses: [],
  180. //>>excludeEnd("ide");
  181. messageSends: ["visitIRInlinedIfFalse:"]
  182. }),
  183. $globals.IRInlinedIfFalse);
  184. $core.addClass('IRInlinedIfNilIfNotNil', $globals.IRInlinedSend, [], 'Compiler-Inlining');
  185. //>>excludeStart("ide", pragmas.excludeIdeData);
  186. $globals.IRInlinedIfNilIfNotNil.comment="I represent an inlined `#ifNil:ifNotNil:` message send instruction.";
  187. //>>excludeEnd("ide");
  188. $core.addMethod(
  189. $core.method({
  190. selector: "acceptDagVisitor:",
  191. protocol: 'visiting',
  192. fn: function (aVisitor){
  193. var self=this;
  194. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  195. return $core.withContext(function($ctx1) {
  196. //>>excludeEnd("ctx");
  197. $recv(aVisitor)._visitIRInlinedIfNilIfNotNil_(self);
  198. return self;
  199. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  200. }, function($ctx1) {$ctx1.fill(self,"acceptDagVisitor:",{aVisitor:aVisitor},$globals.IRInlinedIfNilIfNotNil)});
  201. //>>excludeEnd("ctx");
  202. },
  203. //>>excludeStart("ide", pragmas.excludeIdeData);
  204. args: ["aVisitor"],
  205. source: "acceptDagVisitor: aVisitor\x0a\x09aVisitor visitIRInlinedIfNilIfNotNil: self",
  206. referencedClasses: [],
  207. //>>excludeEnd("ide");
  208. messageSends: ["visitIRInlinedIfNilIfNotNil:"]
  209. }),
  210. $globals.IRInlinedIfNilIfNotNil);
  211. $core.addMethod(
  212. $core.method({
  213. selector: "internalVariables",
  214. protocol: 'accessing',
  215. fn: function (){
  216. var self=this;
  217. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  218. return $core.withContext(function($ctx1) {
  219. //>>excludeEnd("ctx");
  220. return $recv($globals.Array)._with_(self._receiverInternalVariable());
  221. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  222. }, function($ctx1) {$ctx1.fill(self,"internalVariables",{},$globals.IRInlinedIfNilIfNotNil)});
  223. //>>excludeEnd("ctx");
  224. },
  225. //>>excludeStart("ide", pragmas.excludeIdeData);
  226. args: [],
  227. source: "internalVariables\x0a\x09^ Array with: self receiverInternalVariable",
  228. referencedClasses: ["Array"],
  229. //>>excludeEnd("ide");
  230. messageSends: ["with:", "receiverInternalVariable"]
  231. }),
  232. $globals.IRInlinedIfNilIfNotNil);
  233. $core.addMethod(
  234. $core.method({
  235. selector: "receiverInternalVariable",
  236. protocol: 'accessing',
  237. fn: function (){
  238. var self=this;
  239. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  240. return $core.withContext(function($ctx1) {
  241. //>>excludeEnd("ctx");
  242. var $1;
  243. $1=$recv($globals.IRVariable)._new();
  244. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  245. $ctx1.sendIdx["new"]=1;
  246. //>>excludeEnd("ctx");
  247. $recv($1)._variable_($recv($recv($globals.AliasVar)._new())._name_(self._receiverInternalVariableName()));
  248. return $recv($1)._yourself();
  249. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  250. }, function($ctx1) {$ctx1.fill(self,"receiverInternalVariable",{},$globals.IRInlinedIfNilIfNotNil)});
  251. //>>excludeEnd("ctx");
  252. },
  253. //>>excludeStart("ide", pragmas.excludeIdeData);
  254. args: [],
  255. source: "receiverInternalVariable\x0a\x09^ IRVariable new\x0a\x09\x09variable: (AliasVar new name: self receiverInternalVariableName);\x0a\x09\x09yourself.",
  256. referencedClasses: ["IRVariable", "AliasVar"],
  257. //>>excludeEnd("ide");
  258. messageSends: ["variable:", "new", "name:", "receiverInternalVariableName", "yourself"]
  259. }),
  260. $globals.IRInlinedIfNilIfNotNil);
  261. $core.addMethod(
  262. $core.method({
  263. selector: "receiverInternalVariableName",
  264. protocol: 'accessing',
  265. fn: function (){
  266. var self=this;
  267. return "$receiver";
  268. },
  269. //>>excludeStart("ide", pragmas.excludeIdeData);
  270. args: [],
  271. source: "receiverInternalVariableName\x0a\x09^ '$receiver'",
  272. referencedClasses: [],
  273. //>>excludeEnd("ide");
  274. messageSends: []
  275. }),
  276. $globals.IRInlinedIfNilIfNotNil);
  277. $core.addClass('IRInlinedIfTrue', $globals.IRInlinedSend, [], 'Compiler-Inlining');
  278. //>>excludeStart("ide", pragmas.excludeIdeData);
  279. $globals.IRInlinedIfTrue.comment="I represent an inlined `#ifTrue:` message send instruction.";
  280. //>>excludeEnd("ide");
  281. $core.addMethod(
  282. $core.method({
  283. selector: "acceptDagVisitor:",
  284. protocol: 'visiting',
  285. fn: function (aVisitor){
  286. var self=this;
  287. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  288. return $core.withContext(function($ctx1) {
  289. //>>excludeEnd("ctx");
  290. $recv(aVisitor)._visitIRInlinedIfTrue_(self);
  291. return self;
  292. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  293. }, function($ctx1) {$ctx1.fill(self,"acceptDagVisitor:",{aVisitor:aVisitor},$globals.IRInlinedIfTrue)});
  294. //>>excludeEnd("ctx");
  295. },
  296. //>>excludeStart("ide", pragmas.excludeIdeData);
  297. args: ["aVisitor"],
  298. source: "acceptDagVisitor: aVisitor\x0a\x09aVisitor visitIRInlinedIfTrue: self",
  299. referencedClasses: [],
  300. //>>excludeEnd("ide");
  301. messageSends: ["visitIRInlinedIfTrue:"]
  302. }),
  303. $globals.IRInlinedIfTrue);
  304. $core.addClass('IRInlinedIfTrueIfFalse', $globals.IRInlinedSend, [], 'Compiler-Inlining');
  305. //>>excludeStart("ide", pragmas.excludeIdeData);
  306. $globals.IRInlinedIfTrueIfFalse.comment="I represent an inlined `#ifTrue:ifFalse:` message send instruction.";
  307. //>>excludeEnd("ide");
  308. $core.addMethod(
  309. $core.method({
  310. selector: "acceptDagVisitor:",
  311. protocol: 'visiting',
  312. fn: function (aVisitor){
  313. var self=this;
  314. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  315. return $core.withContext(function($ctx1) {
  316. //>>excludeEnd("ctx");
  317. $recv(aVisitor)._visitIRInlinedIfTrueIfFalse_(self);
  318. return self;
  319. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  320. }, function($ctx1) {$ctx1.fill(self,"acceptDagVisitor:",{aVisitor:aVisitor},$globals.IRInlinedIfTrueIfFalse)});
  321. //>>excludeEnd("ctx");
  322. },
  323. //>>excludeStart("ide", pragmas.excludeIdeData);
  324. args: ["aVisitor"],
  325. source: "acceptDagVisitor: aVisitor\x0a\x09aVisitor visitIRInlinedIfTrueIfFalse: self",
  326. referencedClasses: [],
  327. //>>excludeEnd("ide");
  328. messageSends: ["visitIRInlinedIfTrueIfFalse:"]
  329. }),
  330. $globals.IRInlinedIfTrueIfFalse);
  331. $core.addClass('IRInlinedSequence', $globals.IRBlockSequence, [], 'Compiler-Inlining');
  332. //>>excludeStart("ide", pragmas.excludeIdeData);
  333. $globals.IRInlinedSequence.comment="I represent a (block) sequence inside an inlined closure instruction (instance of `IRInlinedClosure`).";
  334. //>>excludeEnd("ide");
  335. $core.addMethod(
  336. $core.method({
  337. selector: "acceptDagVisitor:",
  338. protocol: 'visiting',
  339. fn: function (aVisitor){
  340. var self=this;
  341. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  342. return $core.withContext(function($ctx1) {
  343. //>>excludeEnd("ctx");
  344. $recv(aVisitor)._visitIRInlinedSequence_(self);
  345. return self;
  346. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  347. }, function($ctx1) {$ctx1.fill(self,"acceptDagVisitor:",{aVisitor:aVisitor},$globals.IRInlinedSequence)});
  348. //>>excludeEnd("ctx");
  349. },
  350. //>>excludeStart("ide", pragmas.excludeIdeData);
  351. args: ["aVisitor"],
  352. source: "acceptDagVisitor: aVisitor\x0a\x09aVisitor visitIRInlinedSequence: self",
  353. referencedClasses: [],
  354. //>>excludeEnd("ide");
  355. messageSends: ["visitIRInlinedSequence:"]
  356. }),
  357. $globals.IRInlinedSequence);
  358. $core.addMethod(
  359. $core.method({
  360. selector: "isInlined",
  361. protocol: 'testing',
  362. fn: function (){
  363. var self=this;
  364. return true;
  365. },
  366. //>>excludeStart("ide", pragmas.excludeIdeData);
  367. args: [],
  368. source: "isInlined\x0a\x09^ true",
  369. referencedClasses: [],
  370. //>>excludeEnd("ide");
  371. messageSends: []
  372. }),
  373. $globals.IRInlinedSequence);
  374. $core.addClass('IRInliner', $globals.IRVisitor, [], 'Compiler-Inlining');
  375. //>>excludeStart("ide", pragmas.excludeIdeData);
  376. $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`";
  377. //>>excludeEnd("ide");
  378. $core.addMethod(
  379. $core.method({
  380. selector: "assignmentInliner",
  381. protocol: 'factory',
  382. fn: function (){
  383. var self=this;
  384. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  385. return $core.withContext(function($ctx1) {
  386. //>>excludeEnd("ctx");
  387. var $1;
  388. $1=$recv($globals.IRAssignmentInliner)._new();
  389. $recv($1)._translator_(self);
  390. return $recv($1)._yourself();
  391. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  392. }, function($ctx1) {$ctx1.fill(self,"assignmentInliner",{},$globals.IRInliner)});
  393. //>>excludeEnd("ctx");
  394. },
  395. //>>excludeStart("ide", pragmas.excludeIdeData);
  396. args: [],
  397. source: "assignmentInliner\x0a\x09^ IRAssignmentInliner new\x0a\x09\x09translator: self;\x0a\x09\x09yourself",
  398. referencedClasses: ["IRAssignmentInliner"],
  399. //>>excludeEnd("ide");
  400. messageSends: ["translator:", "new", "yourself"]
  401. }),
  402. $globals.IRInliner);
  403. $core.addMethod(
  404. $core.method({
  405. selector: "returnInliner",
  406. protocol: 'factory',
  407. fn: function (){
  408. var self=this;
  409. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  410. return $core.withContext(function($ctx1) {
  411. //>>excludeEnd("ctx");
  412. var $1;
  413. $1=$recv($globals.IRReturnInliner)._new();
  414. $recv($1)._translator_(self);
  415. return $recv($1)._yourself();
  416. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  417. }, function($ctx1) {$ctx1.fill(self,"returnInliner",{},$globals.IRInliner)});
  418. //>>excludeEnd("ctx");
  419. },
  420. //>>excludeStart("ide", pragmas.excludeIdeData);
  421. args: [],
  422. source: "returnInliner\x0a\x09^ IRReturnInliner new\x0a\x09\x09translator: self;\x0a\x09\x09yourself",
  423. referencedClasses: ["IRReturnInliner"],
  424. //>>excludeEnd("ide");
  425. messageSends: ["translator:", "new", "yourself"]
  426. }),
  427. $globals.IRInliner);
  428. $core.addMethod(
  429. $core.method({
  430. selector: "sendInliner",
  431. protocol: 'factory',
  432. fn: function (){
  433. var self=this;
  434. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  435. return $core.withContext(function($ctx1) {
  436. //>>excludeEnd("ctx");
  437. var $1;
  438. $1=$recv($globals.IRSendInliner)._new();
  439. $recv($1)._translator_(self);
  440. return $recv($1)._yourself();
  441. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  442. }, function($ctx1) {$ctx1.fill(self,"sendInliner",{},$globals.IRInliner)});
  443. //>>excludeEnd("ctx");
  444. },
  445. //>>excludeStart("ide", pragmas.excludeIdeData);
  446. args: [],
  447. source: "sendInliner\x0a\x09^ IRSendInliner new\x0a\x09\x09translator: self;\x0a\x09\x09yourself",
  448. referencedClasses: ["IRSendInliner"],
  449. //>>excludeEnd("ide");
  450. messageSends: ["translator:", "new", "yourself"]
  451. }),
  452. $globals.IRInliner);
  453. $core.addMethod(
  454. $core.method({
  455. selector: "shouldInlineAssignment:",
  456. protocol: 'testing',
  457. fn: function (anIRAssignment){
  458. var self=this;
  459. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  460. return $core.withContext(function($ctx1) {
  461. //>>excludeEnd("ctx");
  462. var $3,$2,$1;
  463. $1=$recv($recv($recv(anIRAssignment)._isInlined())._not())._and_((function(){
  464. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  465. return $core.withContext(function($ctx2) {
  466. //>>excludeEnd("ctx");
  467. $3=$recv(anIRAssignment)._right();
  468. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  469. $ctx2.sendIdx["right"]=1;
  470. //>>excludeEnd("ctx");
  471. $2=$recv($3)._isSend();
  472. return $recv($2)._and_((function(){
  473. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  474. return $core.withContext(function($ctx3) {
  475. //>>excludeEnd("ctx");
  476. return self._shouldInlineSend_($recv(anIRAssignment)._right());
  477. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  478. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)});
  479. //>>excludeEnd("ctx");
  480. }));
  481. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  482. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  483. //>>excludeEnd("ctx");
  484. }));
  485. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  486. $ctx1.sendIdx["and:"]=1;
  487. //>>excludeEnd("ctx");
  488. return $1;
  489. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  490. }, function($ctx1) {$ctx1.fill(self,"shouldInlineAssignment:",{anIRAssignment:anIRAssignment},$globals.IRInliner)});
  491. //>>excludeEnd("ctx");
  492. },
  493. //>>excludeStart("ide", pragmas.excludeIdeData);
  494. args: ["anIRAssignment"],
  495. source: "shouldInlineAssignment: anIRAssignment\x0a\x09^ anIRAssignment isInlined not and: [\x0a\x09\x09anIRAssignment right isSend and: [\x0a\x09\x09\x09self shouldInlineSend: anIRAssignment right ]]",
  496. referencedClasses: [],
  497. //>>excludeEnd("ide");
  498. messageSends: ["and:", "not", "isInlined", "isSend", "right", "shouldInlineSend:"]
  499. }),
  500. $globals.IRInliner);
  501. $core.addMethod(
  502. $core.method({
  503. selector: "shouldInlineReturn:",
  504. protocol: 'testing',
  505. fn: function (anIRReturn){
  506. var self=this;
  507. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  508. return $core.withContext(function($ctx1) {
  509. //>>excludeEnd("ctx");
  510. var $3,$2,$1;
  511. $1=$recv($recv($recv(anIRReturn)._isInlined())._not())._and_((function(){
  512. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  513. return $core.withContext(function($ctx2) {
  514. //>>excludeEnd("ctx");
  515. $3=$recv(anIRReturn)._expression();
  516. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  517. $ctx2.sendIdx["expression"]=1;
  518. //>>excludeEnd("ctx");
  519. $2=$recv($3)._isSend();
  520. return $recv($2)._and_((function(){
  521. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  522. return $core.withContext(function($ctx3) {
  523. //>>excludeEnd("ctx");
  524. return self._shouldInlineSend_($recv(anIRReturn)._expression());
  525. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  526. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)});
  527. //>>excludeEnd("ctx");
  528. }));
  529. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  530. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  531. //>>excludeEnd("ctx");
  532. }));
  533. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  534. $ctx1.sendIdx["and:"]=1;
  535. //>>excludeEnd("ctx");
  536. return $1;
  537. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  538. }, function($ctx1) {$ctx1.fill(self,"shouldInlineReturn:",{anIRReturn:anIRReturn},$globals.IRInliner)});
  539. //>>excludeEnd("ctx");
  540. },
  541. //>>excludeStart("ide", pragmas.excludeIdeData);
  542. args: ["anIRReturn"],
  543. source: "shouldInlineReturn: anIRReturn\x0a\x09^ anIRReturn isInlined not and: [\x0a\x09\x09anIRReturn expression isSend and: [\x0a\x09\x09\x09self shouldInlineSend: anIRReturn expression ]]",
  544. referencedClasses: [],
  545. //>>excludeEnd("ide");
  546. messageSends: ["and:", "not", "isInlined", "isSend", "expression", "shouldInlineSend:"]
  547. }),
  548. $globals.IRInliner);
  549. $core.addMethod(
  550. $core.method({
  551. selector: "shouldInlineSend:",
  552. protocol: 'testing',
  553. fn: function (anIRSend){
  554. var self=this;
  555. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  556. return $core.withContext(function($ctx1) {
  557. //>>excludeEnd("ctx");
  558. return $recv($recv($recv(anIRSend)._isInlined())._not())._and_((function(){
  559. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  560. return $core.withContext(function($ctx2) {
  561. //>>excludeEnd("ctx");
  562. return $recv($globals.IRSendInliner)._shouldInline_(anIRSend);
  563. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  564. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  565. //>>excludeEnd("ctx");
  566. }));
  567. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  568. }, function($ctx1) {$ctx1.fill(self,"shouldInlineSend:",{anIRSend:anIRSend},$globals.IRInliner)});
  569. //>>excludeEnd("ctx");
  570. },
  571. //>>excludeStart("ide", pragmas.excludeIdeData);
  572. args: ["anIRSend"],
  573. source: "shouldInlineSend: anIRSend\x0a\x09^ anIRSend isInlined not and: [\x0a\x09\x09IRSendInliner shouldInline: anIRSend ]",
  574. referencedClasses: ["IRSendInliner"],
  575. //>>excludeEnd("ide");
  576. messageSends: ["and:", "not", "isInlined", "shouldInline:"]
  577. }),
  578. $globals.IRInliner);
  579. $core.addMethod(
  580. $core.method({
  581. selector: "visitIRAssignment:",
  582. protocol: 'visiting',
  583. fn: function (anIRAssignment){
  584. var self=this;
  585. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  586. return $core.withContext(function($ctx1) {
  587. //>>excludeEnd("ctx");
  588. var $1;
  589. $1=self._shouldInlineAssignment_(anIRAssignment);
  590. if($core.assert($1)){
  591. return $recv(self._assignmentInliner())._inlineAssignment_(anIRAssignment);
  592. } else {
  593. return (
  594. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  595. $ctx1.supercall = true,
  596. //>>excludeEnd("ctx");
  597. ($globals.IRInliner.superclass||$boot.nilAsClass).fn.prototype._visitIRAssignment_.apply($recv(self), [anIRAssignment]));
  598. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  599. $ctx1.supercall = false;
  600. //>>excludeEnd("ctx");;
  601. }
  602. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  603. }, function($ctx1) {$ctx1.fill(self,"visitIRAssignment:",{anIRAssignment:anIRAssignment},$globals.IRInliner)});
  604. //>>excludeEnd("ctx");
  605. },
  606. //>>excludeStart("ide", pragmas.excludeIdeData);
  607. args: ["anIRAssignment"],
  608. source: "visitIRAssignment: anIRAssignment\x0a\x09^ (self shouldInlineAssignment: anIRAssignment)\x0a\x09\x09ifTrue: [ self assignmentInliner inlineAssignment: anIRAssignment ]\x0a\x09\x09ifFalse: [ super visitIRAssignment: anIRAssignment ]",
  609. referencedClasses: [],
  610. //>>excludeEnd("ide");
  611. messageSends: ["ifTrue:ifFalse:", "shouldInlineAssignment:", "inlineAssignment:", "assignmentInliner", "visitIRAssignment:"]
  612. }),
  613. $globals.IRInliner);
  614. $core.addMethod(
  615. $core.method({
  616. selector: "visitIRNonLocalReturn:",
  617. protocol: 'visiting',
  618. fn: function (anIRNonLocalReturn){
  619. var self=this;
  620. var localReturn;
  621. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  622. return $core.withContext(function($ctx1) {
  623. //>>excludeEnd("ctx");
  624. var $2,$1,$4,$3,$5,$6,$7;
  625. $2=$recv(anIRNonLocalReturn)._scope();
  626. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  627. $ctx1.sendIdx["scope"]=1;
  628. //>>excludeEnd("ctx");
  629. $1=$recv($2)._canInlineNonLocalReturns();
  630. if($core.assert($1)){
  631. $4=$recv(anIRNonLocalReturn)._scope();
  632. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  633. $ctx1.sendIdx["scope"]=2;
  634. //>>excludeEnd("ctx");
  635. $3=$recv($4)._methodScope();
  636. $5=$recv(anIRNonLocalReturn)._scope();
  637. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  638. $ctx1.sendIdx["scope"]=3;
  639. //>>excludeEnd("ctx");
  640. $recv($3)._removeNonLocalReturn_($5);
  641. $6=$recv($globals.IRReturn)._new();
  642. $recv($6)._scope_($recv(anIRNonLocalReturn)._scope());
  643. localReturn=$recv($6)._yourself();
  644. localReturn;
  645. $recv($recv(anIRNonLocalReturn)._dagChildren())._do_((function(each){
  646. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  647. return $core.withContext(function($ctx2) {
  648. //>>excludeEnd("ctx");
  649. return $recv(localReturn)._add_(each);
  650. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  651. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)});
  652. //>>excludeEnd("ctx");
  653. }));
  654. $recv(anIRNonLocalReturn)._replaceWith_(localReturn);
  655. return self._visitIRReturn_(localReturn);
  656. }
  657. $7=(
  658. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  659. $ctx1.supercall = true,
  660. //>>excludeEnd("ctx");
  661. ($globals.IRInliner.superclass||$boot.nilAsClass).fn.prototype._visitIRNonLocalReturn_.apply($recv(self), [anIRNonLocalReturn]));
  662. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  663. $ctx1.supercall = false;
  664. //>>excludeEnd("ctx");;
  665. return $7;
  666. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  667. }, function($ctx1) {$ctx1.fill(self,"visitIRNonLocalReturn:",{anIRNonLocalReturn:anIRNonLocalReturn,localReturn:localReturn},$globals.IRInliner)});
  668. //>>excludeEnd("ctx");
  669. },
  670. //>>excludeStart("ide", pragmas.excludeIdeData);
  671. args: ["anIRNonLocalReturn"],
  672. 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 dagChildren do: [ :each |\x0a\x09\x09\x09localReturn add: each ].\x0a\x09\x09anIRNonLocalReturn replaceWith: localReturn.\x0a\x09\x09^ self visitIRReturn: localReturn ].\x0a\x09^ super visitIRNonLocalReturn: anIRNonLocalReturn",
  673. referencedClasses: ["IRReturn"],
  674. //>>excludeEnd("ide");
  675. messageSends: ["ifTrue:", "canInlineNonLocalReturns", "scope", "removeNonLocalReturn:", "methodScope", "scope:", "new", "yourself", "do:", "dagChildren", "add:", "replaceWith:", "visitIRReturn:", "visitIRNonLocalReturn:"]
  676. }),
  677. $globals.IRInliner);
  678. $core.addMethod(
  679. $core.method({
  680. selector: "visitIRReturn:",
  681. protocol: 'visiting',
  682. fn: function (anIRReturn){
  683. var self=this;
  684. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  685. return $core.withContext(function($ctx1) {
  686. //>>excludeEnd("ctx");
  687. var $1;
  688. $1=self._shouldInlineReturn_(anIRReturn);
  689. if($core.assert($1)){
  690. return $recv(self._returnInliner())._inlineReturn_(anIRReturn);
  691. } else {
  692. return (
  693. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  694. $ctx1.supercall = true,
  695. //>>excludeEnd("ctx");
  696. ($globals.IRInliner.superclass||$boot.nilAsClass).fn.prototype._visitIRReturn_.apply($recv(self), [anIRReturn]));
  697. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  698. $ctx1.supercall = false;
  699. //>>excludeEnd("ctx");;
  700. }
  701. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  702. }, function($ctx1) {$ctx1.fill(self,"visitIRReturn:",{anIRReturn:anIRReturn},$globals.IRInliner)});
  703. //>>excludeEnd("ctx");
  704. },
  705. //>>excludeStart("ide", pragmas.excludeIdeData);
  706. args: ["anIRReturn"],
  707. source: "visitIRReturn: anIRReturn\x0a\x09^ (self shouldInlineReturn: anIRReturn)\x0a\x09\x09ifTrue: [ self returnInliner inlineReturn: anIRReturn ]\x0a\x09\x09ifFalse: [ super visitIRReturn: anIRReturn ]",
  708. referencedClasses: [],
  709. //>>excludeEnd("ide");
  710. messageSends: ["ifTrue:ifFalse:", "shouldInlineReturn:", "inlineReturn:", "returnInliner", "visitIRReturn:"]
  711. }),
  712. $globals.IRInliner);
  713. $core.addMethod(
  714. $core.method({
  715. selector: "visitIRSend:",
  716. protocol: 'visiting',
  717. fn: function (anIRSend){
  718. var self=this;
  719. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  720. return $core.withContext(function($ctx1) {
  721. //>>excludeEnd("ctx");
  722. var $1;
  723. $1=self._shouldInlineSend_(anIRSend);
  724. if($core.assert($1)){
  725. return $recv(self._sendInliner())._inlineSend_(anIRSend);
  726. } else {
  727. return (
  728. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  729. $ctx1.supercall = true,
  730. //>>excludeEnd("ctx");
  731. ($globals.IRInliner.superclass||$boot.nilAsClass).fn.prototype._visitIRSend_.apply($recv(self), [anIRSend]));
  732. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  733. $ctx1.supercall = false;
  734. //>>excludeEnd("ctx");;
  735. }
  736. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  737. }, function($ctx1) {$ctx1.fill(self,"visitIRSend:",{anIRSend:anIRSend},$globals.IRInliner)});
  738. //>>excludeEnd("ctx");
  739. },
  740. //>>excludeStart("ide", pragmas.excludeIdeData);
  741. args: ["anIRSend"],
  742. source: "visitIRSend: anIRSend\x0a\x09^ (self shouldInlineSend: anIRSend)\x0a\x09\x09ifTrue: [ self sendInliner inlineSend: anIRSend ]\x0a\x09\x09ifFalse: [ super visitIRSend: anIRSend ]",
  743. referencedClasses: [],
  744. //>>excludeEnd("ide");
  745. messageSends: ["ifTrue:ifFalse:", "shouldInlineSend:", "inlineSend:", "sendInliner", "visitIRSend:"]
  746. }),
  747. $globals.IRInliner);
  748. $core.addClass('IRInliningJSTranslator', $globals.IRJSTranslator, [], 'Compiler-Inlining');
  749. //>>excludeStart("ide", pragmas.excludeIdeData);
  750. $globals.IRInliningJSTranslator.comment="I am a specialized JavaScript translator able to write inlined IR instructions to JavaScript stream (`JSStream` instance).";
  751. //>>excludeEnd("ide");
  752. $core.addMethod(
  753. $core.method({
  754. selector: "visitIRInlinedClosure:",
  755. protocol: 'visiting',
  756. fn: function (anIRInlinedClosure){
  757. var self=this;
  758. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  759. return $core.withContext(function($ctx1) {
  760. //>>excludeEnd("ctx");
  761. $recv(self._stream())._nextPutVars_($recv($recv(anIRInlinedClosure)._tempDeclarations())._collect_((function(each){
  762. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  763. return $core.withContext(function($ctx2) {
  764. //>>excludeEnd("ctx");
  765. return $recv($recv(each)._name())._asVariableName();
  766. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  767. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  768. //>>excludeEnd("ctx");
  769. })));
  770. self._visitAll_($recv(anIRInlinedClosure)._dagChildren());
  771. return self;
  772. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  773. }, function($ctx1) {$ctx1.fill(self,"visitIRInlinedClosure:",{anIRInlinedClosure:anIRInlinedClosure},$globals.IRInliningJSTranslator)});
  774. //>>excludeEnd("ctx");
  775. },
  776. //>>excludeStart("ide", pragmas.excludeIdeData);
  777. args: ["anIRInlinedClosure"],
  778. source: "visitIRInlinedClosure: anIRInlinedClosure\x0a\x09self stream nextPutVars: (anIRInlinedClosure tempDeclarations collect: [ :each |\x0a\x09\x09each name asVariableName ]).\x0a\x09self visitAll: anIRInlinedClosure dagChildren",
  779. referencedClasses: [],
  780. //>>excludeEnd("ide");
  781. messageSends: ["nextPutVars:", "stream", "collect:", "tempDeclarations", "asVariableName", "name", "visitAll:", "dagChildren"]
  782. }),
  783. $globals.IRInliningJSTranslator);
  784. $core.addMethod(
  785. $core.method({
  786. selector: "visitIRInlinedIfFalse:",
  787. protocol: 'visiting',
  788. fn: function (anIRInlinedIfFalse){
  789. var self=this;
  790. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  791. return $core.withContext(function($ctx1) {
  792. //>>excludeEnd("ctx");
  793. var $1,$2,$4,$3;
  794. $1=self._stream();
  795. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  796. $ctx1.sendIdx["stream"]=1;
  797. //>>excludeEnd("ctx");
  798. $recv($1)._nextPutIf_then_((function(){
  799. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  800. return $core.withContext(function($ctx2) {
  801. //>>excludeEnd("ctx");
  802. $2=self._stream();
  803. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  804. $ctx2.sendIdx["stream"]=2;
  805. //>>excludeEnd("ctx");
  806. $recv($2)._nextPutAll_("!$core.assert(");
  807. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  808. $ctx2.sendIdx["nextPutAll:"]=1;
  809. //>>excludeEnd("ctx");
  810. $4=$recv(anIRInlinedIfFalse)._dagChildren();
  811. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  812. $ctx2.sendIdx["dagChildren"]=1;
  813. //>>excludeEnd("ctx");
  814. $3=$recv($4)._first();
  815. self._visit_($3);
  816. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  817. $ctx2.sendIdx["visit:"]=1;
  818. //>>excludeEnd("ctx");
  819. return $recv(self._stream())._nextPutAll_(")");
  820. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  821. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  822. //>>excludeEnd("ctx");
  823. }),(function(){
  824. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  825. return $core.withContext(function($ctx2) {
  826. //>>excludeEnd("ctx");
  827. return self._visit_($recv($recv(anIRInlinedIfFalse)._dagChildren())._last());
  828. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  829. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  830. //>>excludeEnd("ctx");
  831. }));
  832. return self;
  833. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  834. }, function($ctx1) {$ctx1.fill(self,"visitIRInlinedIfFalse:",{anIRInlinedIfFalse:anIRInlinedIfFalse},$globals.IRInliningJSTranslator)});
  835. //>>excludeEnd("ctx");
  836. },
  837. //>>excludeStart("ide", pragmas.excludeIdeData);
  838. args: ["anIRInlinedIfFalse"],
  839. source: "visitIRInlinedIfFalse: anIRInlinedIfFalse\x0a\x09self stream nextPutIf: [\x0a\x09\x09self stream nextPutAll: '!$core.assert('.\x0a\x09\x09self visit: anIRInlinedIfFalse dagChildren first.\x0a\x09\x09self stream nextPutAll: ')' ]\x0a\x09\x09then: [ self visit: anIRInlinedIfFalse dagChildren last ]",
  840. referencedClasses: [],
  841. //>>excludeEnd("ide");
  842. messageSends: ["nextPutIf:then:", "stream", "nextPutAll:", "visit:", "first", "dagChildren", "last"]
  843. }),
  844. $globals.IRInliningJSTranslator);
  845. $core.addMethod(
  846. $core.method({
  847. selector: "visitIRInlinedIfNilIfNotNil:",
  848. protocol: 'visiting',
  849. fn: function (anIRInlinedIfNilIfNotNil){
  850. var self=this;
  851. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  852. return $core.withContext(function($ctx1) {
  853. //>>excludeEnd("ctx");
  854. var $1,$2,$4,$3,$6,$5,$7,$8,$10,$9;
  855. $1=self._stream();
  856. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  857. $ctx1.sendIdx["stream"]=1;
  858. //>>excludeEnd("ctx");
  859. $recv($1)._nextPutIf_then_else_((function(){
  860. var recvVarName;
  861. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  862. return $core.withContext(function($ctx2) {
  863. //>>excludeEnd("ctx");
  864. recvVarName=$recv(anIRInlinedIfNilIfNotNil)._receiverInternalVariableName();
  865. recvVarName;
  866. $2=self._stream();
  867. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  868. $ctx2.sendIdx["stream"]=2;
  869. //>>excludeEnd("ctx");
  870. $4="(".__comma(recvVarName);
  871. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  872. $ctx2.sendIdx[","]=2;
  873. //>>excludeEnd("ctx");
  874. $3=$recv($4).__comma(" = ");
  875. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  876. $ctx2.sendIdx[","]=1;
  877. //>>excludeEnd("ctx");
  878. $recv($2)._nextPutAll_($3);
  879. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  880. $ctx2.sendIdx["nextPutAll:"]=1;
  881. //>>excludeEnd("ctx");
  882. $6=$recv(anIRInlinedIfNilIfNotNil)._dagChildren();
  883. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  884. $ctx2.sendIdx["dagChildren"]=1;
  885. //>>excludeEnd("ctx");
  886. $5=$recv($6)._first();
  887. self._visit_($5);
  888. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  889. $ctx2.sendIdx["visit:"]=1;
  890. //>>excludeEnd("ctx");
  891. $7=self._stream();
  892. $8=$recv(") == null || ".__comma(recvVarName)).__comma(".isNil");
  893. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  894. $ctx2.sendIdx[","]=3;
  895. //>>excludeEnd("ctx");
  896. return $recv($7)._nextPutAll_($8);
  897. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  898. }, function($ctx2) {$ctx2.fillBlock({recvVarName:recvVarName},$ctx1,1)});
  899. //>>excludeEnd("ctx");
  900. }),(function(){
  901. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  902. return $core.withContext(function($ctx2) {
  903. //>>excludeEnd("ctx");
  904. $10=$recv(anIRInlinedIfNilIfNotNil)._dagChildren();
  905. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  906. $ctx2.sendIdx["dagChildren"]=2;
  907. //>>excludeEnd("ctx");
  908. $9=$recv($10)._second();
  909. return self._visit_($9);
  910. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  911. $ctx2.sendIdx["visit:"]=2;
  912. //>>excludeEnd("ctx");
  913. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  914. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  915. //>>excludeEnd("ctx");
  916. }),(function(){
  917. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  918. return $core.withContext(function($ctx2) {
  919. //>>excludeEnd("ctx");
  920. return self._visit_($recv($recv(anIRInlinedIfNilIfNotNil)._dagChildren())._third());
  921. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  922. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)});
  923. //>>excludeEnd("ctx");
  924. }));
  925. return self;
  926. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  927. }, function($ctx1) {$ctx1.fill(self,"visitIRInlinedIfNilIfNotNil:",{anIRInlinedIfNilIfNotNil:anIRInlinedIfNilIfNotNil},$globals.IRInliningJSTranslator)});
  928. //>>excludeEnd("ctx");
  929. },
  930. //>>excludeStart("ide", pragmas.excludeIdeData);
  931. args: ["anIRInlinedIfNilIfNotNil"],
  932. 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 dagChildren first.\x0a\x09\x09\x09self stream nextPutAll: ') == null || ', recvVarName, '.isNil' ]\x0a\x09\x09then: [ self visit: anIRInlinedIfNilIfNotNil dagChildren second ]\x0a\x09\x09else: [ self visit: anIRInlinedIfNilIfNotNil dagChildren third ]",
  933. referencedClasses: [],
  934. //>>excludeEnd("ide");
  935. messageSends: ["nextPutIf:then:else:", "stream", "receiverInternalVariableName", "nextPutAll:", ",", "visit:", "first", "dagChildren", "second", "third"]
  936. }),
  937. $globals.IRInliningJSTranslator);
  938. $core.addMethod(
  939. $core.method({
  940. selector: "visitIRInlinedIfTrue:",
  941. protocol: 'visiting',
  942. fn: function (anIRInlinedIfTrue){
  943. var self=this;
  944. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  945. return $core.withContext(function($ctx1) {
  946. //>>excludeEnd("ctx");
  947. var $1,$2,$4,$3;
  948. $1=self._stream();
  949. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  950. $ctx1.sendIdx["stream"]=1;
  951. //>>excludeEnd("ctx");
  952. $recv($1)._nextPutIf_then_((function(){
  953. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  954. return $core.withContext(function($ctx2) {
  955. //>>excludeEnd("ctx");
  956. $2=self._stream();
  957. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  958. $ctx2.sendIdx["stream"]=2;
  959. //>>excludeEnd("ctx");
  960. $recv($2)._nextPutAll_("$core.assert(");
  961. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  962. $ctx2.sendIdx["nextPutAll:"]=1;
  963. //>>excludeEnd("ctx");
  964. $4=$recv(anIRInlinedIfTrue)._dagChildren();
  965. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  966. $ctx2.sendIdx["dagChildren"]=1;
  967. //>>excludeEnd("ctx");
  968. $3=$recv($4)._first();
  969. self._visit_($3);
  970. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  971. $ctx2.sendIdx["visit:"]=1;
  972. //>>excludeEnd("ctx");
  973. return $recv(self._stream())._nextPutAll_(")");
  974. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  975. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  976. //>>excludeEnd("ctx");
  977. }),(function(){
  978. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  979. return $core.withContext(function($ctx2) {
  980. //>>excludeEnd("ctx");
  981. return self._visit_($recv($recv(anIRInlinedIfTrue)._dagChildren())._last());
  982. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  983. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  984. //>>excludeEnd("ctx");
  985. }));
  986. return self;
  987. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  988. }, function($ctx1) {$ctx1.fill(self,"visitIRInlinedIfTrue:",{anIRInlinedIfTrue:anIRInlinedIfTrue},$globals.IRInliningJSTranslator)});
  989. //>>excludeEnd("ctx");
  990. },
  991. //>>excludeStart("ide", pragmas.excludeIdeData);
  992. args: ["anIRInlinedIfTrue"],
  993. source: "visitIRInlinedIfTrue: anIRInlinedIfTrue\x0a\x09self stream nextPutIf: [\x0a\x09\x09self stream nextPutAll: '$core.assert('.\x0a\x09\x09self visit: anIRInlinedIfTrue dagChildren first.\x0a\x09\x09self stream nextPutAll: ')' ]\x0a\x09\x09then: [ self visit: anIRInlinedIfTrue dagChildren last ]",
  994. referencedClasses: [],
  995. //>>excludeEnd("ide");
  996. messageSends: ["nextPutIf:then:", "stream", "nextPutAll:", "visit:", "first", "dagChildren", "last"]
  997. }),
  998. $globals.IRInliningJSTranslator);
  999. $core.addMethod(
  1000. $core.method({
  1001. selector: "visitIRInlinedIfTrueIfFalse:",
  1002. protocol: 'visiting',
  1003. fn: function (anIRInlinedIfTrueIfFalse){
  1004. var self=this;
  1005. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1006. return $core.withContext(function($ctx1) {
  1007. //>>excludeEnd("ctx");
  1008. var $1,$2,$4,$3,$6,$5;
  1009. $1=self._stream();
  1010. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1011. $ctx1.sendIdx["stream"]=1;
  1012. //>>excludeEnd("ctx");
  1013. $recv($1)._nextPutIf_then_else_((function(){
  1014. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1015. return $core.withContext(function($ctx2) {
  1016. //>>excludeEnd("ctx");
  1017. $2=self._stream();
  1018. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1019. $ctx2.sendIdx["stream"]=2;
  1020. //>>excludeEnd("ctx");
  1021. $recv($2)._nextPutAll_("$core.assert(");
  1022. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1023. $ctx2.sendIdx["nextPutAll:"]=1;
  1024. //>>excludeEnd("ctx");
  1025. $4=$recv(anIRInlinedIfTrueIfFalse)._dagChildren();
  1026. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1027. $ctx2.sendIdx["dagChildren"]=1;
  1028. //>>excludeEnd("ctx");
  1029. $3=$recv($4)._first();
  1030. self._visit_($3);
  1031. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1032. $ctx2.sendIdx["visit:"]=1;
  1033. //>>excludeEnd("ctx");
  1034. return $recv(self._stream())._nextPutAll_(")");
  1035. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1036. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  1037. //>>excludeEnd("ctx");
  1038. }),(function(){
  1039. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1040. return $core.withContext(function($ctx2) {
  1041. //>>excludeEnd("ctx");
  1042. $6=$recv(anIRInlinedIfTrueIfFalse)._dagChildren();
  1043. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1044. $ctx2.sendIdx["dagChildren"]=2;
  1045. //>>excludeEnd("ctx");
  1046. $5=$recv($6)._second();
  1047. return self._visit_($5);
  1048. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1049. $ctx2.sendIdx["visit:"]=2;
  1050. //>>excludeEnd("ctx");
  1051. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1052. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  1053. //>>excludeEnd("ctx");
  1054. }),(function(){
  1055. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1056. return $core.withContext(function($ctx2) {
  1057. //>>excludeEnd("ctx");
  1058. return self._visit_($recv($recv(anIRInlinedIfTrueIfFalse)._dagChildren())._third());
  1059. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1060. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)});
  1061. //>>excludeEnd("ctx");
  1062. }));
  1063. return self;
  1064. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1065. }, function($ctx1) {$ctx1.fill(self,"visitIRInlinedIfTrueIfFalse:",{anIRInlinedIfTrueIfFalse:anIRInlinedIfTrueIfFalse},$globals.IRInliningJSTranslator)});
  1066. //>>excludeEnd("ctx");
  1067. },
  1068. //>>excludeStart("ide", pragmas.excludeIdeData);
  1069. args: ["anIRInlinedIfTrueIfFalse"],
  1070. source: "visitIRInlinedIfTrueIfFalse: anIRInlinedIfTrueIfFalse\x0a\x09self stream\x0a\x09\x09nextPutIf: [\x0a\x09\x09\x09self stream nextPutAll: '$core.assert('.\x0a\x09\x09\x09self visit: anIRInlinedIfTrueIfFalse dagChildren first.\x0a\x09\x09\x09self stream nextPutAll: ')' ]\x0a\x09\x09then: [ self visit: anIRInlinedIfTrueIfFalse dagChildren second ]\x0a\x09\x09else: [ self visit: anIRInlinedIfTrueIfFalse dagChildren third ]",
  1071. referencedClasses: [],
  1072. //>>excludeEnd("ide");
  1073. messageSends: ["nextPutIf:then:else:", "stream", "nextPutAll:", "visit:", "first", "dagChildren", "second", "third"]
  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())._dagChildren();
  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 dagChildren.\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:", "dagChildren", "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)._dagChildren();
  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 dagChildren.\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", "dagChildren", "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)._dagChildren();
  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 dagChildren.\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", "dagChildren", "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: "inliner",
  2030. protocol: 'compiling',
  2031. fn: function (){
  2032. var self=this;
  2033. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2034. return $core.withContext(function($ctx1) {
  2035. //>>excludeEnd("ctx");
  2036. return $recv($globals.IRInliner)._new();
  2037. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2038. }, function($ctx1) {$ctx1.fill(self,"inliner",{},$globals.InliningCodeGenerator)});
  2039. //>>excludeEnd("ctx");
  2040. },
  2041. //>>excludeStart("ide", pragmas.excludeIdeData);
  2042. args: [],
  2043. source: "inliner\x0a\x09^ IRInliner new",
  2044. referencedClasses: ["IRInliner"],
  2045. //>>excludeEnd("ide");
  2046. messageSends: ["new"]
  2047. }),
  2048. $globals.InliningCodeGenerator);
  2049. $core.addMethod(
  2050. $core.method({
  2051. selector: "irTranslatorClass",
  2052. protocol: 'compiling',
  2053. fn: function (){
  2054. var self=this;
  2055. return $globals.IRInliningJSTranslator;
  2056. },
  2057. //>>excludeStart("ide", pragmas.excludeIdeData);
  2058. args: [],
  2059. source: "irTranslatorClass\x0a\x09^ IRInliningJSTranslator",
  2060. referencedClasses: ["IRInliningJSTranslator"],
  2061. //>>excludeEnd("ide");
  2062. messageSends: []
  2063. }),
  2064. $globals.InliningCodeGenerator);
  2065. $core.addMethod(
  2066. $core.method({
  2067. selector: "preInliner",
  2068. protocol: 'compiling',
  2069. fn: function (){
  2070. var self=this;
  2071. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2072. return $core.withContext(function($ctx1) {
  2073. //>>excludeEnd("ctx");
  2074. return $recv($globals.ASTPreInliner)._new();
  2075. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2076. }, function($ctx1) {$ctx1.fill(self,"preInliner",{},$globals.InliningCodeGenerator)});
  2077. //>>excludeEnd("ctx");
  2078. },
  2079. //>>excludeStart("ide", pragmas.excludeIdeData);
  2080. args: [],
  2081. source: "preInliner\x0a\x09^ ASTPreInliner new",
  2082. referencedClasses: ["ASTPreInliner"],
  2083. //>>excludeEnd("ide");
  2084. messageSends: ["new"]
  2085. }),
  2086. $globals.InliningCodeGenerator);
  2087. $core.addMethod(
  2088. $core.method({
  2089. selector: "transformersDictionary",
  2090. protocol: 'compiling',
  2091. fn: function (){
  2092. var self=this;
  2093. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2094. return $core.withContext(function($ctx1) {
  2095. //>>excludeEnd("ctx");
  2096. var $1;
  2097. $1=(
  2098. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2099. $ctx1.supercall = true,
  2100. //>>excludeEnd("ctx");
  2101. ($globals.InliningCodeGenerator.superclass||$boot.nilAsClass).fn.prototype._transformersDictionary.apply($recv(self), []));
  2102. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2103. $ctx1.supercall = false;
  2104. //>>excludeEnd("ctx");;
  2105. $recv($1)._at_put_("3000-inlinerTagging",self._preInliner());
  2106. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2107. $ctx1.sendIdx["at:put:"]=1;
  2108. //>>excludeEnd("ctx");
  2109. $recv($1)._at_put_("6000-inliner",self._inliner());
  2110. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2111. $ctx1.sendIdx["at:put:"]=2;
  2112. //>>excludeEnd("ctx");
  2113. $recv($1)._at_put_("8000-irToJs",self._irTranslator());
  2114. return $recv($1)._yourself();
  2115. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2116. }, function($ctx1) {$ctx1.fill(self,"transformersDictionary",{},$globals.InliningCodeGenerator)});
  2117. //>>excludeEnd("ctx");
  2118. },
  2119. //>>excludeStart("ide", pragmas.excludeIdeData);
  2120. args: [],
  2121. source: "transformersDictionary\x0a\x09^ super transformersDictionary\x0a\x09\x09at: '3000-inlinerTagging' put: self preInliner;\x0a\x09\x09at: '6000-inliner' put: self inliner;\x0a\x09\x09at: '8000-irToJs' put: self irTranslator;\x0a\x09\x09yourself",
  2122. referencedClasses: [],
  2123. //>>excludeEnd("ide");
  2124. messageSends: ["at:put:", "transformersDictionary", "preInliner", "inliner", "irTranslator", "yourself"]
  2125. }),
  2126. $globals.InliningCodeGenerator);
  2127. $core.addClass('InliningError', $globals.SemanticError, [], 'Compiler-Inlining');
  2128. //>>excludeStart("ide", pragmas.excludeIdeData);
  2129. $globals.InliningError.comment="Instances of InliningError are signaled when using an `InliningCodeGenerator`in a `Compiler`.";
  2130. //>>excludeEnd("ide");
  2131. $core.addClass('InliningSemanticAnalyzer', $globals.SemanticAnalyzer, [], 'Compiler-Inlining');
  2132. $core.addMethod(
  2133. $core.method({
  2134. selector: "visitSendNode:",
  2135. protocol: 'visiting',
  2136. fn: function (aNode){
  2137. var self=this;
  2138. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2139. return $core.withContext(function($ctx1) {
  2140. //>>excludeEnd("ctx");
  2141. var $1,$2,$3,$receiver;
  2142. $1=$recv(aNode)._superSend();
  2143. if(!$core.assert($1)){
  2144. $2=$recv($recv($globals.IRSendInliner)._inlinedSelectors())._includes_($recv(aNode)._selector());
  2145. if($core.assert($2)){
  2146. $recv(aNode)._shouldBeInlined_(true);
  2147. $3=$recv(aNode)._receiver();
  2148. if(($receiver = $3) == null || $receiver.isNil){
  2149. $3;
  2150. } else {
  2151. var receiver;
  2152. receiver=$receiver;
  2153. $recv(receiver)._shouldBeAliased_(true);
  2154. }
  2155. }
  2156. }
  2157. (
  2158. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2159. $ctx1.supercall = true,
  2160. //>>excludeEnd("ctx");
  2161. ($globals.InliningSemanticAnalyzer.superclass||$boot.nilAsClass).fn.prototype._visitSendNode_.apply($recv(self), [aNode]));
  2162. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2163. $ctx1.supercall = false;
  2164. //>>excludeEnd("ctx");;
  2165. return self;
  2166. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2167. }, function($ctx1) {$ctx1.fill(self,"visitSendNode:",{aNode:aNode},$globals.InliningSemanticAnalyzer)});
  2168. //>>excludeEnd("ctx");
  2169. },
  2170. //>>excludeStart("ide", pragmas.excludeIdeData);
  2171. args: ["aNode"],
  2172. 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",
  2173. referencedClasses: ["IRSendInliner"],
  2174. //>>excludeEnd("ide");
  2175. messageSends: ["ifFalse:", "superSend", "ifTrue:", "includes:", "inlinedSelectors", "selector", "shouldBeInlined:", "ifNotNil:", "receiver", "shouldBeAliased:", "visitSendNode:"]
  2176. }),
  2177. $globals.InliningSemanticAnalyzer);
  2178. $core.addMethod(
  2179. $core.method({
  2180. selector: "asInlinedBlockResult",
  2181. protocol: '*Compiler-Inlining',
  2182. fn: function (){
  2183. var self=this;
  2184. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2185. return $core.withContext(function($ctx1) {
  2186. //>>excludeEnd("ctx");
  2187. return self._expression();
  2188. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2189. }, function($ctx1) {$ctx1.fill(self,"asInlinedBlockResult",{},$globals.IRBlockReturn)});
  2190. //>>excludeEnd("ctx");
  2191. },
  2192. //>>excludeStart("ide", pragmas.excludeIdeData);
  2193. args: [],
  2194. source: "asInlinedBlockResult\x0a\x09^ self expression",
  2195. referencedClasses: [],
  2196. //>>excludeEnd("ide");
  2197. messageSends: ["expression"]
  2198. }),
  2199. $globals.IRBlockReturn);
  2200. $core.addMethod(
  2201. $core.method({
  2202. selector: "asInlinedBlockResult",
  2203. protocol: '*Compiler-Inlining',
  2204. fn: function (){
  2205. var self=this;
  2206. return self;
  2207. },
  2208. //>>excludeStart("ide", pragmas.excludeIdeData);
  2209. args: [],
  2210. source: "asInlinedBlockResult\x0a\x09^ self",
  2211. referencedClasses: [],
  2212. //>>excludeEnd("ide");
  2213. messageSends: []
  2214. }),
  2215. $globals.IRInstruction);
  2216. });