Compiler-Inlining.js 91 KB

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