Compiler-Inlining.js 88 KB

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