Compiler-Inlining.js 88 KB

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