Compiler-Inlining.js 99 KB

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