Compiler-Inlining.js 99 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554
  1. define(["amber/boot", "require", "amber/core/Compiler-AST", "amber/core/Compiler-Core", "amber/core/Compiler-IR", "amber/core/Compiler-Semantic", "amber/core/Kernel-Objects"], function($boot,requirejs){"use strict";
  2. var $core=$boot.api,nil=$boot.nilAsValue,$nil=$boot.nilAsReceiver,$recv=$boot.asReceiver,$globals=$boot.globals;
  3. var $pkg = $core.addPackage("Compiler-Inlining");
  4. $pkg.innerEval = function (expr) { return eval(expr); };
  5. $pkg.transport = {"type":"amd","amdNamespace":"amber/core"};
  6. $core.addClass("ASTPreInliner", $globals.NodeVisitor, [], "Compiler-Inlining");
  7. $core.addMethod(
  8. $core.method({
  9. selector: "visitSendNode:",
  10. protocol: "visiting",
  11. //>>excludeStart("ide", pragmas.excludeIdeData);
  12. args: ["aNode"],
  13. 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",
  14. referencedClasses: ["IRSendInliner"],
  15. //>>excludeEnd("ide");
  16. pragmas: [],
  17. messageSends: ["ifFalse:", "superSend", "ifTrue:", "includes:", "inlinedSelectors", "selector", "shouldBeAliased:", "ifNotNil:", "receiver", "inlinedSelectorsNeedingIdempotentReceiver", "visitSendNode:"]
  18. }, function ($methodClass){ return function (aNode){
  19. var self=this,$self=this;
  20. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  21. return $core.withContext(function($ctx1) {
  22. //>>excludeEnd("ctx");
  23. var $1;
  24. if(!$core.assert($recv(aNode)._superSend())){
  25. if($core.assert([$recv($recv($globals.IRSendInliner)._inlinedSelectors())._includes_([$recv(aNode)._selector()
  26. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  27. ,$ctx1.sendIdx["selector"]=1
  28. //>>excludeEnd("ctx");
  29. ][0])
  30. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  31. ,$ctx1.sendIdx["includes:"]=1
  32. //>>excludeEnd("ctx");
  33. ][0])){
  34. [$recv(aNode)._shouldBeAliased_(true)
  35. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  36. ,$ctx1.sendIdx["shouldBeAliased:"]=1
  37. //>>excludeEnd("ctx");
  38. ][0];
  39. $1=$recv(aNode)._receiver();
  40. if($1 == null || $1.a$nil){
  41. $1;
  42. } else {
  43. var receiver;
  44. receiver=$1;
  45. if($core.assert($recv($recv($globals.IRSendInliner)._inlinedSelectorsNeedingIdempotentReceiver())._includes_($recv(aNode)._selector()))){
  46. $recv(receiver)._shouldBeAliased_(true);
  47. }
  48. }
  49. }
  50. }
  51. return [(
  52. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  53. $ctx1.supercall = true,
  54. //>>excludeEnd("ctx");
  55. ($methodClass.superclass||$boot.nilAsClass).fn.prototype._visitSendNode_.call($self,aNode))
  56. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  57. ,$ctx1.supercall = false
  58. //>>excludeEnd("ctx");
  59. ][0];
  60. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  61. }, function($ctx1) {$ctx1.fill(self,"visitSendNode:",{aNode:aNode})});
  62. //>>excludeEnd("ctx");
  63. }; }),
  64. $globals.ASTPreInliner);
  65. $core.addClass("IRInlinedClosure", $globals.IRClosure, [], "Compiler-Inlining");
  66. //>>excludeStart("ide", pragmas.excludeIdeData);
  67. $globals.IRInlinedClosure.comment="I represent an inlined closure instruction.";
  68. //>>excludeEnd("ide");
  69. $core.addMethod(
  70. $core.method({
  71. selector: "acceptDagVisitor:",
  72. protocol: "visiting",
  73. //>>excludeStart("ide", pragmas.excludeIdeData);
  74. args: ["aVisitor"],
  75. source: "acceptDagVisitor: aVisitor\x0a\x09aVisitor visitIRInlinedClosure: self",
  76. referencedClasses: [],
  77. //>>excludeEnd("ide");
  78. pragmas: [],
  79. messageSends: ["visitIRInlinedClosure:"]
  80. }, function ($methodClass){ return function (aVisitor){
  81. var self=this,$self=this;
  82. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  83. return $core.withContext(function($ctx1) {
  84. //>>excludeEnd("ctx");
  85. $recv(aVisitor)._visitIRInlinedClosure_(self);
  86. return self;
  87. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  88. }, function($ctx1) {$ctx1.fill(self,"acceptDagVisitor:",{aVisitor:aVisitor})});
  89. //>>excludeEnd("ctx");
  90. }; }),
  91. $globals.IRInlinedClosure);
  92. $core.addMethod(
  93. $core.method({
  94. selector: "isInlined",
  95. protocol: "testing",
  96. //>>excludeStart("ide", pragmas.excludeIdeData);
  97. args: [],
  98. source: "isInlined\x0a\x09^ true",
  99. referencedClasses: [],
  100. //>>excludeEnd("ide");
  101. pragmas: [],
  102. messageSends: []
  103. }, function ($methodClass){ return function (){
  104. var self=this,$self=this;
  105. return true;
  106. }; }),
  107. $globals.IRInlinedClosure);
  108. $core.addClass("IRInlinedSend", $globals.IRSend, [], "Compiler-Inlining");
  109. //>>excludeStart("ide", pragmas.excludeIdeData);
  110. $globals.IRInlinedSend.comment="I am the abstract super class of inlined message send instructions.";
  111. //>>excludeEnd("ide");
  112. $core.addMethod(
  113. $core.method({
  114. selector: "acceptDagVisitor:",
  115. protocol: "visiting",
  116. //>>excludeStart("ide", pragmas.excludeIdeData);
  117. args: ["aVisitor"],
  118. source: "acceptDagVisitor: aVisitor\x0a\x09aVisitor visitInlinedSend: self",
  119. referencedClasses: [],
  120. //>>excludeEnd("ide");
  121. pragmas: [],
  122. messageSends: ["visitInlinedSend:"]
  123. }, function ($methodClass){ return function (aVisitor){
  124. var self=this,$self=this;
  125. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  126. return $core.withContext(function($ctx1) {
  127. //>>excludeEnd("ctx");
  128. $recv(aVisitor)._visitInlinedSend_(self);
  129. return self;
  130. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  131. }, function($ctx1) {$ctx1.fill(self,"acceptDagVisitor:",{aVisitor:aVisitor})});
  132. //>>excludeEnd("ctx");
  133. }; }),
  134. $globals.IRInlinedSend);
  135. $core.addMethod(
  136. $core.method({
  137. selector: "internalVariables",
  138. protocol: "accessing",
  139. //>>excludeStart("ide", pragmas.excludeIdeData);
  140. args: [],
  141. source: "internalVariables\x0a\x09\x22Answer a collection of internal variables required \x0a\x09to perform the inlining\x22\x0a\x09\x0a\x09^ #()",
  142. referencedClasses: [],
  143. //>>excludeEnd("ide");
  144. pragmas: [],
  145. messageSends: []
  146. }, function ($methodClass){ return function (){
  147. var self=this,$self=this;
  148. return [];
  149. }; }),
  150. $globals.IRInlinedSend);
  151. $core.addMethod(
  152. $core.method({
  153. selector: "isInlined",
  154. protocol: "testing",
  155. //>>excludeStart("ide", pragmas.excludeIdeData);
  156. args: [],
  157. source: "isInlined\x0a\x09^ true",
  158. referencedClasses: [],
  159. //>>excludeEnd("ide");
  160. pragmas: [],
  161. messageSends: []
  162. }, function ($methodClass){ return function (){
  163. var self=this,$self=this;
  164. return true;
  165. }; }),
  166. $globals.IRInlinedSend);
  167. $core.addClass("IRInlinedIfFalse", $globals.IRInlinedSend, [], "Compiler-Inlining");
  168. //>>excludeStart("ide", pragmas.excludeIdeData);
  169. $globals.IRInlinedIfFalse.comment="I represent an inlined `#ifFalse:` message send instruction.";
  170. //>>excludeEnd("ide");
  171. $core.addMethod(
  172. $core.method({
  173. selector: "acceptDagVisitor:",
  174. protocol: "visiting",
  175. //>>excludeStart("ide", pragmas.excludeIdeData);
  176. args: ["aVisitor"],
  177. source: "acceptDagVisitor: aVisitor\x0a\x09aVisitor visitIRInlinedIfFalse: self",
  178. referencedClasses: [],
  179. //>>excludeEnd("ide");
  180. pragmas: [],
  181. messageSends: ["visitIRInlinedIfFalse:"]
  182. }, function ($methodClass){ return function (aVisitor){
  183. var self=this,$self=this;
  184. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  185. return $core.withContext(function($ctx1) {
  186. //>>excludeEnd("ctx");
  187. $recv(aVisitor)._visitIRInlinedIfFalse_(self);
  188. return self;
  189. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  190. }, function($ctx1) {$ctx1.fill(self,"acceptDagVisitor:",{aVisitor:aVisitor})});
  191. //>>excludeEnd("ctx");
  192. }; }),
  193. $globals.IRInlinedIfFalse);
  194. $core.addClass("IRInlinedIfNilIfNotNil", $globals.IRInlinedSend, [], "Compiler-Inlining");
  195. //>>excludeStart("ide", pragmas.excludeIdeData);
  196. $globals.IRInlinedIfNilIfNotNil.comment="I represent an inlined `#ifNil:ifNotNil:` message send instruction.";
  197. //>>excludeEnd("ide");
  198. $core.addMethod(
  199. $core.method({
  200. selector: "acceptDagVisitor:",
  201. protocol: "visiting",
  202. //>>excludeStart("ide", pragmas.excludeIdeData);
  203. args: ["aVisitor"],
  204. source: "acceptDagVisitor: aVisitor\x0a\x09aVisitor visitIRInlinedIfNilIfNotNil: self",
  205. referencedClasses: [],
  206. //>>excludeEnd("ide");
  207. pragmas: [],
  208. messageSends: ["visitIRInlinedIfNilIfNotNil:"]
  209. }, function ($methodClass){ return function (aVisitor){
  210. var self=this,$self=this;
  211. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  212. return $core.withContext(function($ctx1) {
  213. //>>excludeEnd("ctx");
  214. $recv(aVisitor)._visitIRInlinedIfNilIfNotNil_(self);
  215. return self;
  216. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  217. }, function($ctx1) {$ctx1.fill(self,"acceptDagVisitor:",{aVisitor:aVisitor})});
  218. //>>excludeEnd("ctx");
  219. }; }),
  220. $globals.IRInlinedIfNilIfNotNil);
  221. $core.addClass("IRInlinedIfTrue", $globals.IRInlinedSend, [], "Compiler-Inlining");
  222. //>>excludeStart("ide", pragmas.excludeIdeData);
  223. $globals.IRInlinedIfTrue.comment="I represent an inlined `#ifTrue:` message send instruction.";
  224. //>>excludeEnd("ide");
  225. $core.addMethod(
  226. $core.method({
  227. selector: "acceptDagVisitor:",
  228. protocol: "visiting",
  229. //>>excludeStart("ide", pragmas.excludeIdeData);
  230. args: ["aVisitor"],
  231. source: "acceptDagVisitor: aVisitor\x0a\x09aVisitor visitIRInlinedIfTrue: self",
  232. referencedClasses: [],
  233. //>>excludeEnd("ide");
  234. pragmas: [],
  235. messageSends: ["visitIRInlinedIfTrue:"]
  236. }, function ($methodClass){ return function (aVisitor){
  237. var self=this,$self=this;
  238. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  239. return $core.withContext(function($ctx1) {
  240. //>>excludeEnd("ctx");
  241. $recv(aVisitor)._visitIRInlinedIfTrue_(self);
  242. return self;
  243. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  244. }, function($ctx1) {$ctx1.fill(self,"acceptDagVisitor:",{aVisitor:aVisitor})});
  245. //>>excludeEnd("ctx");
  246. }; }),
  247. $globals.IRInlinedIfTrue);
  248. $core.addClass("IRInlinedIfTrueIfFalse", $globals.IRInlinedSend, [], "Compiler-Inlining");
  249. //>>excludeStart("ide", pragmas.excludeIdeData);
  250. $globals.IRInlinedIfTrueIfFalse.comment="I represent an inlined `#ifTrue:ifFalse:` message send instruction.";
  251. //>>excludeEnd("ide");
  252. $core.addMethod(
  253. $core.method({
  254. selector: "acceptDagVisitor:",
  255. protocol: "visiting",
  256. //>>excludeStart("ide", pragmas.excludeIdeData);
  257. args: ["aVisitor"],
  258. source: "acceptDagVisitor: aVisitor\x0a\x09aVisitor visitIRInlinedIfTrueIfFalse: self",
  259. referencedClasses: [],
  260. //>>excludeEnd("ide");
  261. pragmas: [],
  262. messageSends: ["visitIRInlinedIfTrueIfFalse:"]
  263. }, function ($methodClass){ return function (aVisitor){
  264. var self=this,$self=this;
  265. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  266. return $core.withContext(function($ctx1) {
  267. //>>excludeEnd("ctx");
  268. $recv(aVisitor)._visitIRInlinedIfTrueIfFalse_(self);
  269. return self;
  270. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  271. }, function($ctx1) {$ctx1.fill(self,"acceptDagVisitor:",{aVisitor:aVisitor})});
  272. //>>excludeEnd("ctx");
  273. }; }),
  274. $globals.IRInlinedIfTrueIfFalse);
  275. $core.addClass("IRInlinedSequence", $globals.IRBlockSequence, [], "Compiler-Inlining");
  276. //>>excludeStart("ide", pragmas.excludeIdeData);
  277. $globals.IRInlinedSequence.comment="I represent a (block) sequence inside an inlined closure instruction (instance of `IRInlinedClosure`).";
  278. //>>excludeEnd("ide");
  279. $core.addMethod(
  280. $core.method({
  281. selector: "acceptDagVisitor:",
  282. protocol: "visiting",
  283. //>>excludeStart("ide", pragmas.excludeIdeData);
  284. args: ["aVisitor"],
  285. source: "acceptDagVisitor: aVisitor\x0a\x09aVisitor visitIRInlinedSequence: self",
  286. referencedClasses: [],
  287. //>>excludeEnd("ide");
  288. pragmas: [],
  289. messageSends: ["visitIRInlinedSequence:"]
  290. }, function ($methodClass){ return function (aVisitor){
  291. var self=this,$self=this;
  292. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  293. return $core.withContext(function($ctx1) {
  294. //>>excludeEnd("ctx");
  295. $recv(aVisitor)._visitIRInlinedSequence_(self);
  296. return self;
  297. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  298. }, function($ctx1) {$ctx1.fill(self,"acceptDagVisitor:",{aVisitor:aVisitor})});
  299. //>>excludeEnd("ctx");
  300. }; }),
  301. $globals.IRInlinedSequence);
  302. $core.addMethod(
  303. $core.method({
  304. selector: "isInlined",
  305. protocol: "testing",
  306. //>>excludeStart("ide", pragmas.excludeIdeData);
  307. args: [],
  308. source: "isInlined\x0a\x09^ true",
  309. referencedClasses: [],
  310. //>>excludeEnd("ide");
  311. pragmas: [],
  312. messageSends: []
  313. }, function ($methodClass){ return function (){
  314. var self=this,$self=this;
  315. return true;
  316. }; }),
  317. $globals.IRInlinedSequence);
  318. $core.addClass("IRInliner", $globals.IRVisitor, [], "Compiler-Inlining");
  319. //>>excludeStart("ide", pragmas.excludeIdeData);
  320. $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`";
  321. //>>excludeEnd("ide");
  322. $core.addMethod(
  323. $core.method({
  324. selector: "assignmentInliner",
  325. protocol: "factory",
  326. //>>excludeStart("ide", pragmas.excludeIdeData);
  327. args: [],
  328. source: "assignmentInliner\x0a\x09^ IRAssignmentInliner new\x0a\x09\x09translator: self;\x0a\x09\x09yourself",
  329. referencedClasses: ["IRAssignmentInliner"],
  330. //>>excludeEnd("ide");
  331. pragmas: [],
  332. messageSends: ["translator:", "new", "yourself"]
  333. }, function ($methodClass){ return function (){
  334. var self=this,$self=this;
  335. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  336. return $core.withContext(function($ctx1) {
  337. //>>excludeEnd("ctx");
  338. var $1;
  339. $1=$recv($globals.IRAssignmentInliner)._new();
  340. $recv($1)._translator_(self);
  341. return $recv($1)._yourself();
  342. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  343. }, function($ctx1) {$ctx1.fill(self,"assignmentInliner",{})});
  344. //>>excludeEnd("ctx");
  345. }; }),
  346. $globals.IRInliner);
  347. $core.addMethod(
  348. $core.method({
  349. selector: "flattenedReturn:",
  350. protocol: "visiting",
  351. //>>excludeStart("ide", pragmas.excludeIdeData);
  352. args: ["anIRNonLocalReturn"],
  353. 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",
  354. referencedClasses: ["IRReturn"],
  355. //>>excludeEnd("ide");
  356. pragmas: [],
  357. messageSends: ["scope:", "new", "scope", "yourself", "do:", "dagChildren", "add:"]
  358. }, function ($methodClass){ return function (anIRNonLocalReturn){
  359. var self=this,$self=this;
  360. var localReturn;
  361. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  362. return $core.withContext(function($ctx1) {
  363. //>>excludeEnd("ctx");
  364. var $1;
  365. $1=$recv($globals.IRReturn)._new();
  366. $recv($1)._scope_($recv(anIRNonLocalReturn)._scope());
  367. localReturn=$recv($1)._yourself();
  368. $recv($recv(anIRNonLocalReturn)._dagChildren())._do_((function(each){
  369. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  370. return $core.withContext(function($ctx2) {
  371. //>>excludeEnd("ctx");
  372. return $recv(localReturn)._add_(each);
  373. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  374. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  375. //>>excludeEnd("ctx");
  376. }));
  377. return localReturn;
  378. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  379. }, function($ctx1) {$ctx1.fill(self,"flattenedReturn:",{anIRNonLocalReturn:anIRNonLocalReturn,localReturn:localReturn})});
  380. //>>excludeEnd("ctx");
  381. }; }),
  382. $globals.IRInliner);
  383. $core.addMethod(
  384. $core.method({
  385. selector: "nonLocalReturnInliner",
  386. protocol: "factory",
  387. //>>excludeStart("ide", pragmas.excludeIdeData);
  388. args: [],
  389. source: "nonLocalReturnInliner\x0a\x09^ IRNonLocalReturnInliner new\x0a\x09\x09translator: self;\x0a\x09\x09yourself",
  390. referencedClasses: ["IRNonLocalReturnInliner"],
  391. //>>excludeEnd("ide");
  392. pragmas: [],
  393. messageSends: ["translator:", "new", "yourself"]
  394. }, function ($methodClass){ return function (){
  395. var self=this,$self=this;
  396. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  397. return $core.withContext(function($ctx1) {
  398. //>>excludeEnd("ctx");
  399. var $1;
  400. $1=$recv($globals.IRNonLocalReturnInliner)._new();
  401. $recv($1)._translator_(self);
  402. return $recv($1)._yourself();
  403. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  404. }, function($ctx1) {$ctx1.fill(self,"nonLocalReturnInliner",{})});
  405. //>>excludeEnd("ctx");
  406. }; }),
  407. $globals.IRInliner);
  408. $core.addMethod(
  409. $core.method({
  410. selector: "returnInliner",
  411. protocol: "factory",
  412. //>>excludeStart("ide", pragmas.excludeIdeData);
  413. args: [],
  414. source: "returnInliner\x0a\x09^ IRReturnInliner new\x0a\x09\x09translator: self;\x0a\x09\x09yourself",
  415. referencedClasses: ["IRReturnInliner"],
  416. //>>excludeEnd("ide");
  417. pragmas: [],
  418. messageSends: ["translator:", "new", "yourself"]
  419. }, function ($methodClass){ return function (){
  420. var self=this,$self=this;
  421. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  422. return $core.withContext(function($ctx1) {
  423. //>>excludeEnd("ctx");
  424. var $1;
  425. $1=$recv($globals.IRReturnInliner)._new();
  426. $recv($1)._translator_(self);
  427. return $recv($1)._yourself();
  428. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  429. }, function($ctx1) {$ctx1.fill(self,"returnInliner",{})});
  430. //>>excludeEnd("ctx");
  431. }; }),
  432. $globals.IRInliner);
  433. $core.addMethod(
  434. $core.method({
  435. selector: "sendInliner",
  436. protocol: "factory",
  437. //>>excludeStart("ide", pragmas.excludeIdeData);
  438. args: [],
  439. source: "sendInliner\x0a\x09^ IRSendInliner new\x0a\x09\x09translator: self;\x0a\x09\x09yourself",
  440. referencedClasses: ["IRSendInliner"],
  441. //>>excludeEnd("ide");
  442. pragmas: [],
  443. messageSends: ["translator:", "new", "yourself"]
  444. }, function ($methodClass){ return function (){
  445. var self=this,$self=this;
  446. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  447. return $core.withContext(function($ctx1) {
  448. //>>excludeEnd("ctx");
  449. var $1;
  450. $1=$recv($globals.IRSendInliner)._new();
  451. $recv($1)._translator_(self);
  452. return $recv($1)._yourself();
  453. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  454. }, function($ctx1) {$ctx1.fill(self,"sendInliner",{})});
  455. //>>excludeEnd("ctx");
  456. }; }),
  457. $globals.IRInliner);
  458. $core.addMethod(
  459. $core.method({
  460. selector: "shouldInlineAssignment:",
  461. protocol: "testing",
  462. //>>excludeStart("ide", pragmas.excludeIdeData);
  463. args: ["anIRAssignment"],
  464. source: "shouldInlineAssignment: anIRAssignment\x0a\x09^ anIRAssignment isInlined not and: [\x0a\x09\x09anIRAssignment right isSend and: [\x0a\x09\x09\x09self shouldInlineSend: anIRAssignment right ]]",
  465. referencedClasses: [],
  466. //>>excludeEnd("ide");
  467. pragmas: [],
  468. messageSends: ["and:", "not", "isInlined", "isSend", "right", "shouldInlineSend:"]
  469. }, function ($methodClass){ return function (anIRAssignment){
  470. var self=this,$self=this;
  471. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  472. return $core.withContext(function($ctx1) {
  473. //>>excludeEnd("ctx");
  474. if($core.assert($recv($recv(anIRAssignment)._isInlined())._not())){
  475. if($core.assert($recv([$recv(anIRAssignment)._right()
  476. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  477. ,$ctx1.sendIdx["right"]=1
  478. //>>excludeEnd("ctx");
  479. ][0])._isSend())){
  480. return $self._shouldInlineSend_($recv(anIRAssignment)._right());
  481. } else {
  482. return false;
  483. }
  484. } else {
  485. return false;
  486. }
  487. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  488. }, function($ctx1) {$ctx1.fill(self,"shouldInlineAssignment:",{anIRAssignment:anIRAssignment})});
  489. //>>excludeEnd("ctx");
  490. }; }),
  491. $globals.IRInliner);
  492. $core.addMethod(
  493. $core.method({
  494. selector: "shouldInlineReturn:",
  495. protocol: "testing",
  496. //>>excludeStart("ide", pragmas.excludeIdeData);
  497. args: ["anIRReturn"],
  498. source: "shouldInlineReturn: anIRReturn\x0a\x09^ anIRReturn isInlined not and: [\x0a\x09\x09anIRReturn expression isSend and: [\x0a\x09\x09\x09self shouldInlineSend: anIRReturn expression ]]",
  499. referencedClasses: [],
  500. //>>excludeEnd("ide");
  501. pragmas: [],
  502. messageSends: ["and:", "not", "isInlined", "isSend", "expression", "shouldInlineSend:"]
  503. }, function ($methodClass){ return function (anIRReturn){
  504. var self=this,$self=this;
  505. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  506. return $core.withContext(function($ctx1) {
  507. //>>excludeEnd("ctx");
  508. if($core.assert($recv($recv(anIRReturn)._isInlined())._not())){
  509. if($core.assert($recv([$recv(anIRReturn)._expression()
  510. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  511. ,$ctx1.sendIdx["expression"]=1
  512. //>>excludeEnd("ctx");
  513. ][0])._isSend())){
  514. return $self._shouldInlineSend_($recv(anIRReturn)._expression());
  515. } else {
  516. return false;
  517. }
  518. } else {
  519. return false;
  520. }
  521. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  522. }, function($ctx1) {$ctx1.fill(self,"shouldInlineReturn:",{anIRReturn:anIRReturn})});
  523. //>>excludeEnd("ctx");
  524. }; }),
  525. $globals.IRInliner);
  526. $core.addMethod(
  527. $core.method({
  528. selector: "shouldInlineSend:",
  529. protocol: "testing",
  530. //>>excludeStart("ide", pragmas.excludeIdeData);
  531. args: ["anIRSend"],
  532. source: "shouldInlineSend: anIRSend\x0a\x09^ anIRSend isInlined not and: [\x0a\x09\x09IRSendInliner shouldInline: anIRSend ]",
  533. referencedClasses: ["IRSendInliner"],
  534. //>>excludeEnd("ide");
  535. pragmas: [],
  536. messageSends: ["and:", "not", "isInlined", "shouldInline:"]
  537. }, function ($methodClass){ return function (anIRSend){
  538. var self=this,$self=this;
  539. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  540. return $core.withContext(function($ctx1) {
  541. //>>excludeEnd("ctx");
  542. if($core.assert($recv($recv(anIRSend)._isInlined())._not())){
  543. return $recv($globals.IRSendInliner)._shouldInline_(anIRSend);
  544. } else {
  545. return false;
  546. }
  547. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  548. }, function($ctx1) {$ctx1.fill(self,"shouldInlineSend:",{anIRSend:anIRSend})});
  549. //>>excludeEnd("ctx");
  550. }; }),
  551. $globals.IRInliner);
  552. $core.addMethod(
  553. $core.method({
  554. selector: "visitIRAssignment:",
  555. protocol: "visiting",
  556. //>>excludeStart("ide", pragmas.excludeIdeData);
  557. args: ["anIRAssignment"],
  558. source: "visitIRAssignment: anIRAssignment\x0a\x09^ (self shouldInlineAssignment: anIRAssignment)\x0a\x09\x09ifTrue: [ self assignmentInliner inlineAssignment: anIRAssignment ]\x0a\x09\x09ifFalse: [ super visitIRAssignment: anIRAssignment ]",
  559. referencedClasses: [],
  560. //>>excludeEnd("ide");
  561. pragmas: [],
  562. messageSends: ["ifTrue:ifFalse:", "shouldInlineAssignment:", "inlineAssignment:", "assignmentInliner", "visitIRAssignment:"]
  563. }, function ($methodClass){ return function (anIRAssignment){
  564. var self=this,$self=this;
  565. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  566. return $core.withContext(function($ctx1) {
  567. //>>excludeEnd("ctx");
  568. if($core.assert($self._shouldInlineAssignment_(anIRAssignment))){
  569. return $recv($self._assignmentInliner())._inlineAssignment_(anIRAssignment);
  570. } else {
  571. return [(
  572. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  573. $ctx1.supercall = true,
  574. //>>excludeEnd("ctx");
  575. ($methodClass.superclass||$boot.nilAsClass).fn.prototype._visitIRAssignment_.call($self,anIRAssignment))
  576. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  577. ,$ctx1.supercall = false
  578. //>>excludeEnd("ctx");
  579. ][0];
  580. }
  581. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  582. }, function($ctx1) {$ctx1.fill(self,"visitIRAssignment:",{anIRAssignment:anIRAssignment})});
  583. //>>excludeEnd("ctx");
  584. }; }),
  585. $globals.IRInliner);
  586. $core.addMethod(
  587. $core.method({
  588. selector: "visitIRNonLocalReturn:",
  589. protocol: "visiting",
  590. //>>excludeStart("ide", pragmas.excludeIdeData);
  591. args: ["anIRNonLocalReturn"],
  592. 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 ]",
  593. referencedClasses: [],
  594. //>>excludeEnd("ide");
  595. pragmas: [],
  596. messageSends: ["ifTrue:", "canFlattenNonLocalReturns", "scope", "removeNonLocalReturn:", "methodScope", "flattenedReturn:", "replaceWith:", "visitIRReturn:", "ifTrue:ifFalse:", "shouldInlineReturn:", "inlineReturn:", "nonLocalReturnInliner", "visitIRNonLocalReturn:"]
  597. }, function ($methodClass){ return function (anIRNonLocalReturn){
  598. var self=this,$self=this;
  599. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  600. return $core.withContext(function($ctx1) {
  601. //>>excludeEnd("ctx");
  602. if($core.assert($recv([$recv(anIRNonLocalReturn)._scope()
  603. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  604. ,$ctx1.sendIdx["scope"]=1
  605. //>>excludeEnd("ctx");
  606. ][0])._canFlattenNonLocalReturns())){
  607. var localReturn;
  608. $recv($recv([$recv(anIRNonLocalReturn)._scope()
  609. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  610. ,$ctx1.sendIdx["scope"]=2
  611. //>>excludeEnd("ctx");
  612. ][0])._methodScope())._removeNonLocalReturn_($recv(anIRNonLocalReturn)._scope());
  613. localReturn=$self._flattenedReturn_(anIRNonLocalReturn);
  614. $recv(anIRNonLocalReturn)._replaceWith_(localReturn);
  615. return $self._visitIRReturn_(localReturn);
  616. }
  617. if($core.assert($self._shouldInlineReturn_(anIRNonLocalReturn))){
  618. return $recv($self._nonLocalReturnInliner())._inlineReturn_(anIRNonLocalReturn);
  619. } else {
  620. return [(
  621. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  622. $ctx1.supercall = true,
  623. //>>excludeEnd("ctx");
  624. ($methodClass.superclass||$boot.nilAsClass).fn.prototype._visitIRNonLocalReturn_.call($self,anIRNonLocalReturn))
  625. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  626. ,$ctx1.supercall = false
  627. //>>excludeEnd("ctx");
  628. ][0];
  629. }
  630. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  631. }, function($ctx1) {$ctx1.fill(self,"visitIRNonLocalReturn:",{anIRNonLocalReturn:anIRNonLocalReturn})});
  632. //>>excludeEnd("ctx");
  633. }; }),
  634. $globals.IRInliner);
  635. $core.addMethod(
  636. $core.method({
  637. selector: "visitIRReturn:",
  638. protocol: "visiting",
  639. //>>excludeStart("ide", pragmas.excludeIdeData);
  640. args: ["anIRReturn"],
  641. source: "visitIRReturn: anIRReturn\x0a\x09^ (self shouldInlineReturn: anIRReturn)\x0a\x09\x09ifTrue: [ self returnInliner inlineReturn: anIRReturn ]\x0a\x09\x09ifFalse: [ super visitIRReturn: anIRReturn ]",
  642. referencedClasses: [],
  643. //>>excludeEnd("ide");
  644. pragmas: [],
  645. messageSends: ["ifTrue:ifFalse:", "shouldInlineReturn:", "inlineReturn:", "returnInliner", "visitIRReturn:"]
  646. }, function ($methodClass){ return function (anIRReturn){
  647. var self=this,$self=this;
  648. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  649. return $core.withContext(function($ctx1) {
  650. //>>excludeEnd("ctx");
  651. if($core.assert($self._shouldInlineReturn_(anIRReturn))){
  652. return $recv($self._returnInliner())._inlineReturn_(anIRReturn);
  653. } else {
  654. return [(
  655. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  656. $ctx1.supercall = true,
  657. //>>excludeEnd("ctx");
  658. ($methodClass.superclass||$boot.nilAsClass).fn.prototype._visitIRReturn_.call($self,anIRReturn))
  659. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  660. ,$ctx1.supercall = false
  661. //>>excludeEnd("ctx");
  662. ][0];
  663. }
  664. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  665. }, function($ctx1) {$ctx1.fill(self,"visitIRReturn:",{anIRReturn:anIRReturn})});
  666. //>>excludeEnd("ctx");
  667. }; }),
  668. $globals.IRInliner);
  669. $core.addMethod(
  670. $core.method({
  671. selector: "visitIRSend:",
  672. protocol: "visiting",
  673. //>>excludeStart("ide", pragmas.excludeIdeData);
  674. args: ["anIRSend"],
  675. source: "visitIRSend: anIRSend\x0a\x09^ (self shouldInlineSend: anIRSend)\x0a\x09\x09ifTrue: [ self sendInliner inlineSend: anIRSend ]\x0a\x09\x09ifFalse: [ super visitIRSend: anIRSend ]",
  676. referencedClasses: [],
  677. //>>excludeEnd("ide");
  678. pragmas: [],
  679. messageSends: ["ifTrue:ifFalse:", "shouldInlineSend:", "inlineSend:", "sendInliner", "visitIRSend:"]
  680. }, function ($methodClass){ return function (anIRSend){
  681. var self=this,$self=this;
  682. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  683. return $core.withContext(function($ctx1) {
  684. //>>excludeEnd("ctx");
  685. if($core.assert($self._shouldInlineSend_(anIRSend))){
  686. return $recv($self._sendInliner())._inlineSend_(anIRSend);
  687. } else {
  688. return [(
  689. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  690. $ctx1.supercall = true,
  691. //>>excludeEnd("ctx");
  692. ($methodClass.superclass||$boot.nilAsClass).fn.prototype._visitIRSend_.call($self,anIRSend))
  693. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  694. ,$ctx1.supercall = false
  695. //>>excludeEnd("ctx");
  696. ][0];
  697. }
  698. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  699. }, function($ctx1) {$ctx1.fill(self,"visitIRSend:",{anIRSend:anIRSend})});
  700. //>>excludeEnd("ctx");
  701. }; }),
  702. $globals.IRInliner);
  703. $core.addClass("IRInliningJSTranslator", $globals.IRJSTranslator, [], "Compiler-Inlining");
  704. //>>excludeStart("ide", pragmas.excludeIdeData);
  705. $globals.IRInliningJSTranslator.comment="I am a specialized JavaScript translator able to write inlined IR instructions to JavaScript stream (`JSStream` instance).";
  706. //>>excludeEnd("ide");
  707. $core.addMethod(
  708. $core.method({
  709. selector: "visitIRInlinedClosure:",
  710. protocol: "visiting",
  711. //>>excludeStart("ide", pragmas.excludeIdeData);
  712. args: ["anIRInlinedClosure"],
  713. source: "visitIRInlinedClosure: anIRInlinedClosure\x0a\x09self stream nextPutVars: (anIRInlinedClosure tempDeclarations collect: [ :each |\x0a\x09\x09each name asVariableName ]).\x0a\x09self visitAllChildren: anIRInlinedClosure",
  714. referencedClasses: [],
  715. //>>excludeEnd("ide");
  716. pragmas: [],
  717. messageSends: ["nextPutVars:", "stream", "collect:", "tempDeclarations", "asVariableName", "name", "visitAllChildren:"]
  718. }, function ($methodClass){ return function (anIRInlinedClosure){
  719. var self=this,$self=this;
  720. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  721. return $core.withContext(function($ctx1) {
  722. //>>excludeEnd("ctx");
  723. $recv($self._stream())._nextPutVars_($recv($recv(anIRInlinedClosure)._tempDeclarations())._collect_((function(each){
  724. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  725. return $core.withContext(function($ctx2) {
  726. //>>excludeEnd("ctx");
  727. return $recv($recv(each)._name())._asVariableName();
  728. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  729. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  730. //>>excludeEnd("ctx");
  731. })));
  732. $self._visitAllChildren_(anIRInlinedClosure);
  733. return self;
  734. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  735. }, function($ctx1) {$ctx1.fill(self,"visitIRInlinedClosure:",{anIRInlinedClosure:anIRInlinedClosure})});
  736. //>>excludeEnd("ctx");
  737. }; }),
  738. $globals.IRInliningJSTranslator);
  739. $core.addMethod(
  740. $core.method({
  741. selector: "visitIRInlinedIfFalse:",
  742. protocol: "visiting",
  743. //>>excludeStart("ide", pragmas.excludeIdeData);
  744. args: ["anIRInlinedIfFalse"],
  745. 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 ]",
  746. referencedClasses: [],
  747. //>>excludeEnd("ide");
  748. pragmas: [],
  749. messageSends: ["nextPutIf:then:", "stream", "nextPutAll:", "visit:", "first", "dagChildren", "last"]
  750. }, function ($methodClass){ return function (anIRInlinedIfFalse){
  751. var self=this,$self=this;
  752. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  753. return $core.withContext(function($ctx1) {
  754. //>>excludeEnd("ctx");
  755. $recv([$self._stream()
  756. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  757. ,$ctx1.sendIdx["stream"]=1
  758. //>>excludeEnd("ctx");
  759. ][0])._nextPutIf_then_((function(){
  760. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  761. return $core.withContext(function($ctx2) {
  762. //>>excludeEnd("ctx");
  763. [$recv([$self._stream()
  764. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  765. ,$ctx2.sendIdx["stream"]=2
  766. //>>excludeEnd("ctx");
  767. ][0])._nextPutAll_("!$core.assert(")
  768. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  769. ,$ctx2.sendIdx["nextPutAll:"]=1
  770. //>>excludeEnd("ctx");
  771. ][0];
  772. [$self._visit_($recv([$recv(anIRInlinedIfFalse)._dagChildren()
  773. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  774. ,$ctx2.sendIdx["dagChildren"]=1
  775. //>>excludeEnd("ctx");
  776. ][0])._first())
  777. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  778. ,$ctx2.sendIdx["visit:"]=1
  779. //>>excludeEnd("ctx");
  780. ][0];
  781. return $recv($self._stream())._nextPutAll_(")");
  782. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  783. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  784. //>>excludeEnd("ctx");
  785. }),(function(){
  786. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  787. return $core.withContext(function($ctx2) {
  788. //>>excludeEnd("ctx");
  789. return $self._visit_($recv($recv(anIRInlinedIfFalse)._dagChildren())._last());
  790. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  791. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  792. //>>excludeEnd("ctx");
  793. }));
  794. return self;
  795. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  796. }, function($ctx1) {$ctx1.fill(self,"visitIRInlinedIfFalse:",{anIRInlinedIfFalse:anIRInlinedIfFalse})});
  797. //>>excludeEnd("ctx");
  798. }; }),
  799. $globals.IRInliningJSTranslator);
  800. $core.addMethod(
  801. $core.method({
  802. selector: "visitIRInlinedIfNilIfNotNil:",
  803. protocol: "visiting",
  804. //>>excludeStart("ide", pragmas.excludeIdeData);
  805. args: ["anIRInlinedIfNilIfNotNil"],
  806. 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 ]",
  807. referencedClasses: [],
  808. //>>excludeEnd("ide");
  809. pragmas: [],
  810. messageSends: ["nextPutIf:then:else:", "stream", "visit:", "first", "dagChildren", "nextPutAll:", "second", "third"]
  811. }, function ($methodClass){ return function (anIRInlinedIfNilIfNotNil){
  812. var self=this,$self=this;
  813. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  814. return $core.withContext(function($ctx1) {
  815. //>>excludeEnd("ctx");
  816. $recv([$self._stream()
  817. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  818. ,$ctx1.sendIdx["stream"]=1
  819. //>>excludeEnd("ctx");
  820. ][0])._nextPutIf_then_else_((function(){
  821. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  822. return $core.withContext(function($ctx2) {
  823. //>>excludeEnd("ctx");
  824. [$self._visit_([$recv([$recv(anIRInlinedIfNilIfNotNil)._dagChildren()
  825. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  826. ,$ctx2.sendIdx["dagChildren"]=1
  827. //>>excludeEnd("ctx");
  828. ][0])._first()
  829. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  830. ,$ctx2.sendIdx["first"]=1
  831. //>>excludeEnd("ctx");
  832. ][0])
  833. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  834. ,$ctx2.sendIdx["visit:"]=1
  835. //>>excludeEnd("ctx");
  836. ][0];
  837. [$recv([$self._stream()
  838. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  839. ,$ctx2.sendIdx["stream"]=2
  840. //>>excludeEnd("ctx");
  841. ][0])._nextPutAll_(" == null || ")
  842. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  843. ,$ctx2.sendIdx["nextPutAll:"]=1
  844. //>>excludeEnd("ctx");
  845. ][0];
  846. [$self._visit_($recv([$recv(anIRInlinedIfNilIfNotNil)._dagChildren()
  847. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  848. ,$ctx2.sendIdx["dagChildren"]=2
  849. //>>excludeEnd("ctx");
  850. ][0])._first())
  851. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  852. ,$ctx2.sendIdx["visit:"]=2
  853. //>>excludeEnd("ctx");
  854. ][0];
  855. return $recv($self._stream())._nextPutAll_(".a$nil");
  856. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  857. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  858. //>>excludeEnd("ctx");
  859. }),(function(){
  860. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  861. return $core.withContext(function($ctx2) {
  862. //>>excludeEnd("ctx");
  863. return [$self._visit_($recv([$recv(anIRInlinedIfNilIfNotNil)._dagChildren()
  864. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  865. ,$ctx2.sendIdx["dagChildren"]=3
  866. //>>excludeEnd("ctx");
  867. ][0])._second())
  868. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  869. ,$ctx2.sendIdx["visit:"]=3
  870. //>>excludeEnd("ctx");
  871. ][0];
  872. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  873. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  874. //>>excludeEnd("ctx");
  875. }),(function(){
  876. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  877. return $core.withContext(function($ctx2) {
  878. //>>excludeEnd("ctx");
  879. return $self._visit_($recv($recv(anIRInlinedIfNilIfNotNil)._dagChildren())._third());
  880. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  881. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)});
  882. //>>excludeEnd("ctx");
  883. }));
  884. return self;
  885. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  886. }, function($ctx1) {$ctx1.fill(self,"visitIRInlinedIfNilIfNotNil:",{anIRInlinedIfNilIfNotNil:anIRInlinedIfNilIfNotNil})});
  887. //>>excludeEnd("ctx");
  888. }; }),
  889. $globals.IRInliningJSTranslator);
  890. $core.addMethod(
  891. $core.method({
  892. selector: "visitIRInlinedIfTrue:",
  893. protocol: "visiting",
  894. //>>excludeStart("ide", pragmas.excludeIdeData);
  895. args: ["anIRInlinedIfTrue"],
  896. 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 ]",
  897. referencedClasses: [],
  898. //>>excludeEnd("ide");
  899. pragmas: [],
  900. messageSends: ["nextPutIf:then:", "stream", "nextPutAll:", "visit:", "first", "dagChildren", "last"]
  901. }, function ($methodClass){ return function (anIRInlinedIfTrue){
  902. var self=this,$self=this;
  903. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  904. return $core.withContext(function($ctx1) {
  905. //>>excludeEnd("ctx");
  906. $recv([$self._stream()
  907. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  908. ,$ctx1.sendIdx["stream"]=1
  909. //>>excludeEnd("ctx");
  910. ][0])._nextPutIf_then_((function(){
  911. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  912. return $core.withContext(function($ctx2) {
  913. //>>excludeEnd("ctx");
  914. [$recv([$self._stream()
  915. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  916. ,$ctx2.sendIdx["stream"]=2
  917. //>>excludeEnd("ctx");
  918. ][0])._nextPutAll_("$core.assert(")
  919. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  920. ,$ctx2.sendIdx["nextPutAll:"]=1
  921. //>>excludeEnd("ctx");
  922. ][0];
  923. [$self._visit_($recv([$recv(anIRInlinedIfTrue)._dagChildren()
  924. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  925. ,$ctx2.sendIdx["dagChildren"]=1
  926. //>>excludeEnd("ctx");
  927. ][0])._first())
  928. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  929. ,$ctx2.sendIdx["visit:"]=1
  930. //>>excludeEnd("ctx");
  931. ][0];
  932. return $recv($self._stream())._nextPutAll_(")");
  933. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  934. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  935. //>>excludeEnd("ctx");
  936. }),(function(){
  937. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  938. return $core.withContext(function($ctx2) {
  939. //>>excludeEnd("ctx");
  940. return $self._visit_($recv($recv(anIRInlinedIfTrue)._dagChildren())._last());
  941. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  942. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  943. //>>excludeEnd("ctx");
  944. }));
  945. return self;
  946. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  947. }, function($ctx1) {$ctx1.fill(self,"visitIRInlinedIfTrue:",{anIRInlinedIfTrue:anIRInlinedIfTrue})});
  948. //>>excludeEnd("ctx");
  949. }; }),
  950. $globals.IRInliningJSTranslator);
  951. $core.addMethod(
  952. $core.method({
  953. selector: "visitIRInlinedIfTrueIfFalse:",
  954. protocol: "visiting",
  955. //>>excludeStart("ide", pragmas.excludeIdeData);
  956. args: ["anIRInlinedIfTrueIfFalse"],
  957. 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 ]",
  958. referencedClasses: [],
  959. //>>excludeEnd("ide");
  960. pragmas: [],
  961. messageSends: ["nextPutIf:then:else:", "stream", "nextPutAll:", "visit:", "first", "dagChildren", "second", "third"]
  962. }, function ($methodClass){ return function (anIRInlinedIfTrueIfFalse){
  963. var self=this,$self=this;
  964. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  965. return $core.withContext(function($ctx1) {
  966. //>>excludeEnd("ctx");
  967. $recv([$self._stream()
  968. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  969. ,$ctx1.sendIdx["stream"]=1
  970. //>>excludeEnd("ctx");
  971. ][0])._nextPutIf_then_else_((function(){
  972. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  973. return $core.withContext(function($ctx2) {
  974. //>>excludeEnd("ctx");
  975. [$recv([$self._stream()
  976. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  977. ,$ctx2.sendIdx["stream"]=2
  978. //>>excludeEnd("ctx");
  979. ][0])._nextPutAll_("$core.assert(")
  980. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  981. ,$ctx2.sendIdx["nextPutAll:"]=1
  982. //>>excludeEnd("ctx");
  983. ][0];
  984. [$self._visit_($recv([$recv(anIRInlinedIfTrueIfFalse)._dagChildren()
  985. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  986. ,$ctx2.sendIdx["dagChildren"]=1
  987. //>>excludeEnd("ctx");
  988. ][0])._first())
  989. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  990. ,$ctx2.sendIdx["visit:"]=1
  991. //>>excludeEnd("ctx");
  992. ][0];
  993. return $recv($self._stream())._nextPutAll_(")");
  994. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  995. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  996. //>>excludeEnd("ctx");
  997. }),(function(){
  998. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  999. return $core.withContext(function($ctx2) {
  1000. //>>excludeEnd("ctx");
  1001. return [$self._visit_($recv([$recv(anIRInlinedIfTrueIfFalse)._dagChildren()
  1002. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1003. ,$ctx2.sendIdx["dagChildren"]=2
  1004. //>>excludeEnd("ctx");
  1005. ][0])._second())
  1006. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1007. ,$ctx2.sendIdx["visit:"]=2
  1008. //>>excludeEnd("ctx");
  1009. ][0];
  1010. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1011. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  1012. //>>excludeEnd("ctx");
  1013. }),(function(){
  1014. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1015. return $core.withContext(function($ctx2) {
  1016. //>>excludeEnd("ctx");
  1017. return $self._visit_($recv($recv(anIRInlinedIfTrueIfFalse)._dagChildren())._third());
  1018. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1019. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)});
  1020. //>>excludeEnd("ctx");
  1021. }));
  1022. return self;
  1023. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1024. }, function($ctx1) {$ctx1.fill(self,"visitIRInlinedIfTrueIfFalse:",{anIRInlinedIfTrueIfFalse:anIRInlinedIfTrueIfFalse})});
  1025. //>>excludeEnd("ctx");
  1026. }; }),
  1027. $globals.IRInliningJSTranslator);
  1028. $core.addClass("IRSendInliner", $globals.Object, ["send", "translator"], "Compiler-Inlining");
  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^ #('ifTrue:' 'ifFalse:' 'ifTrue:ifFalse:' 'ifFalse:ifTrue:' 'ifNil:' 'ifNotNil:' 'ifNil:ifNotNil:' 'ifNotNil:ifNil:' 'and:' 'or:')",
  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^ #('ifNil:' 'ifNotNil:' 'ifNil:ifNotNil:' 'ifNotNil:ifNil:')",
  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) ifFalse: [ ^ false ].\x0a\x09anIRSend receiver isSuper ifTrue: [ ^ false ].\x0a\x09^ anIRSend arguments allSatisfy: [ :each | each isClosure ]",
  1962. referencedClasses: [],
  1963. //>>excludeEnd("ide");
  1964. pragmas: [],
  1965. messageSends: ["ifFalse:", "includes:", "inlinedSelectors", "selector", "ifTrue:", "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. return false;
  1973. }
  1974. if($core.assert($recv($recv(anIRSend)._receiver())._isSuper())){
  1975. return false;
  1976. }
  1977. return $recv($recv(anIRSend)._arguments())._allSatisfy_((function(each){
  1978. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1979. return $core.withContext(function($ctx2) {
  1980. //>>excludeEnd("ctx");
  1981. return $recv(each)._isClosure();
  1982. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1983. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,3)});
  1984. //>>excludeEnd("ctx");
  1985. }));
  1986. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1987. }, function($ctx1) {$ctx1.fill(self,"shouldInline:",{anIRSend:anIRSend})});
  1988. //>>excludeEnd("ctx");
  1989. }; }),
  1990. $globals.IRSendInliner.a$cls);
  1991. $core.addClass("IRAssignmentInliner", $globals.IRSendInliner, ["target"], "Compiler-Inlining");
  1992. //>>excludeStart("ide", pragmas.excludeIdeData);
  1993. $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};";
  1994. //>>excludeEnd("ide");
  1995. $core.addMethod(
  1996. $core.method({
  1997. selector: "inlineAssignment:",
  1998. protocol: "inlining",
  1999. //>>excludeStart("ide", pragmas.excludeIdeData);
  2000. args: ["anIRAssignment"],
  2001. source: "inlineAssignment: anIRAssignment\x0a\x09self target: anIRAssignment left.\x0a\x09^ self inlineSend: anIRAssignment right andReplace: anIRAssignment",
  2002. referencedClasses: [],
  2003. //>>excludeEnd("ide");
  2004. pragmas: [],
  2005. messageSends: ["target:", "left", "inlineSend:andReplace:", "right"]
  2006. }, function ($methodClass){ return function (anIRAssignment){
  2007. var self=this,$self=this;
  2008. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2009. return $core.withContext(function($ctx1) {
  2010. //>>excludeEnd("ctx");
  2011. $self._target_($recv(anIRAssignment)._left());
  2012. return $self._inlineSend_andReplace_($recv(anIRAssignment)._right(),anIRAssignment);
  2013. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2014. }, function($ctx1) {$ctx1.fill(self,"inlineAssignment:",{anIRAssignment:anIRAssignment})});
  2015. //>>excludeEnd("ctx");
  2016. }; }),
  2017. $globals.IRAssignmentInliner);
  2018. $core.addMethod(
  2019. $core.method({
  2020. selector: "inlineClosure:",
  2021. protocol: "inlining",
  2022. //>>excludeStart("ide", pragmas.excludeIdeData);
  2023. args: ["anIRClosure"],
  2024. 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 ]",
  2025. referencedClasses: ["IRAssignment"],
  2026. //>>excludeEnd("ide");
  2027. pragmas: [],
  2028. messageSends: ["inlinedClosure:wrapFinalValueIn:", "inlineClosure:", "add:", "new", "target", "copy", "yourself"]
  2029. }, function ($methodClass){ return function (anIRClosure){
  2030. var self=this,$self=this;
  2031. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2032. return $core.withContext(function($ctx1) {
  2033. //>>excludeEnd("ctx");
  2034. var $1;
  2035. return $self._inlinedClosure_wrapFinalValueIn_([(
  2036. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2037. $ctx1.supercall = true,
  2038. //>>excludeEnd("ctx");
  2039. ($methodClass.superclass||$boot.nilAsClass).fn.prototype._inlineClosure_.call($self,anIRClosure))
  2040. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2041. ,$ctx1.supercall = false
  2042. //>>excludeEnd("ctx");
  2043. ][0],(function(final){
  2044. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2045. return $core.withContext(function($ctx2) {
  2046. //>>excludeEnd("ctx");
  2047. $1=$recv($globals.IRAssignment)._new();
  2048. [$recv($1)._add_($self._target())
  2049. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2050. ,$ctx2.sendIdx["add:"]=1
  2051. //>>excludeEnd("ctx");
  2052. ][0];
  2053. $recv($1)._add_($recv(final)._copy());
  2054. return $recv($1)._yourself();
  2055. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2056. }, function($ctx2) {$ctx2.fillBlock({final:final},$ctx1,1)});
  2057. //>>excludeEnd("ctx");
  2058. }));
  2059. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2060. }, function($ctx1) {$ctx1.fill(self,"inlineClosure:",{anIRClosure:anIRClosure})});
  2061. //>>excludeEnd("ctx");
  2062. }; }),
  2063. $globals.IRAssignmentInliner);
  2064. $core.addMethod(
  2065. $core.method({
  2066. selector: "target",
  2067. protocol: "accessing",
  2068. //>>excludeStart("ide", pragmas.excludeIdeData);
  2069. args: [],
  2070. source: "target\x0a\x09^ target",
  2071. referencedClasses: [],
  2072. //>>excludeEnd("ide");
  2073. pragmas: [],
  2074. messageSends: []
  2075. }, function ($methodClass){ return function (){
  2076. var self=this,$self=this;
  2077. return $self.target;
  2078. }; }),
  2079. $globals.IRAssignmentInliner);
  2080. $core.addMethod(
  2081. $core.method({
  2082. selector: "target:",
  2083. protocol: "accessing",
  2084. //>>excludeStart("ide", pragmas.excludeIdeData);
  2085. args: ["anObject"],
  2086. source: "target: anObject\x0a\x09target := anObject",
  2087. referencedClasses: [],
  2088. //>>excludeEnd("ide");
  2089. pragmas: [],
  2090. messageSends: []
  2091. }, function ($methodClass){ return function (anObject){
  2092. var self=this,$self=this;
  2093. $self.target=anObject;
  2094. return self;
  2095. }; }),
  2096. $globals.IRAssignmentInliner);
  2097. $core.addClass("IRNonLocalReturnInliner", $globals.IRSendInliner, [], "Compiler-Inlining");
  2098. //>>excludeStart("ide", pragmas.excludeIdeData);
  2099. $globals.IRNonLocalReturnInliner.comment="I inline message sends with inlined closure together with a return instruction.";
  2100. //>>excludeEnd("ide");
  2101. $core.addMethod(
  2102. $core.method({
  2103. selector: "inlineClosure:",
  2104. protocol: "inlining",
  2105. //>>excludeStart("ide", pragmas.excludeIdeData);
  2106. args: ["anIRClosure"],
  2107. 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 ]",
  2108. referencedClasses: ["IRNonLocalReturn"],
  2109. //>>excludeEnd("ide");
  2110. pragmas: [],
  2111. messageSends: ["inlinedClosure:wrapFinalValueIn:", "inlineClosure:", "add:", "new", "copy", "yourself"]
  2112. }, function ($methodClass){ return function (anIRClosure){
  2113. var self=this,$self=this;
  2114. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2115. return $core.withContext(function($ctx1) {
  2116. //>>excludeEnd("ctx");
  2117. var $1;
  2118. return $self._inlinedClosure_wrapFinalValueIn_([(
  2119. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2120. $ctx1.supercall = true,
  2121. //>>excludeEnd("ctx");
  2122. ($methodClass.superclass||$boot.nilAsClass).fn.prototype._inlineClosure_.call($self,anIRClosure))
  2123. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2124. ,$ctx1.supercall = false
  2125. //>>excludeEnd("ctx");
  2126. ][0],(function(final){
  2127. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2128. return $core.withContext(function($ctx2) {
  2129. //>>excludeEnd("ctx");
  2130. $1=$recv($globals.IRNonLocalReturn)._new();
  2131. $recv($1)._add_($recv(final)._copy());
  2132. return $recv($1)._yourself();
  2133. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2134. }, function($ctx2) {$ctx2.fillBlock({final:final},$ctx1,1)});
  2135. //>>excludeEnd("ctx");
  2136. }));
  2137. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2138. }, function($ctx1) {$ctx1.fill(self,"inlineClosure:",{anIRClosure:anIRClosure})});
  2139. //>>excludeEnd("ctx");
  2140. }; }),
  2141. $globals.IRNonLocalReturnInliner);
  2142. $core.addMethod(
  2143. $core.method({
  2144. selector: "inlineReturn:",
  2145. protocol: "inlining",
  2146. //>>excludeStart("ide", pragmas.excludeIdeData);
  2147. args: ["anIRReturn"],
  2148. source: "inlineReturn: anIRReturn\x0a\x09^ self inlineSend: anIRReturn expression andReplace: anIRReturn",
  2149. referencedClasses: [],
  2150. //>>excludeEnd("ide");
  2151. pragmas: [],
  2152. messageSends: ["inlineSend:andReplace:", "expression"]
  2153. }, function ($methodClass){ return function (anIRReturn){
  2154. var self=this,$self=this;
  2155. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2156. return $core.withContext(function($ctx1) {
  2157. //>>excludeEnd("ctx");
  2158. return $self._inlineSend_andReplace_($recv(anIRReturn)._expression(),anIRReturn);
  2159. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2160. }, function($ctx1) {$ctx1.fill(self,"inlineReturn:",{anIRReturn:anIRReturn})});
  2161. //>>excludeEnd("ctx");
  2162. }; }),
  2163. $globals.IRNonLocalReturnInliner);
  2164. $core.addClass("IRReturnInliner", $globals.IRSendInliner, [], "Compiler-Inlining");
  2165. //>>excludeStart("ide", pragmas.excludeIdeData);
  2166. $globals.IRReturnInliner.comment="I inline message sends with inlined closure together with a return instruction.";
  2167. //>>excludeEnd("ide");
  2168. $core.addMethod(
  2169. $core.method({
  2170. selector: "inlineClosure:",
  2171. protocol: "inlining",
  2172. //>>excludeStart("ide", pragmas.excludeIdeData);
  2173. args: ["anIRClosure"],
  2174. 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 ]",
  2175. referencedClasses: ["IRReturn"],
  2176. //>>excludeEnd("ide");
  2177. pragmas: [],
  2178. messageSends: ["inlinedClosure:wrapFinalValueIn:", "inlineClosure:", "add:", "new", "copy", "yourself"]
  2179. }, function ($methodClass){ return function (anIRClosure){
  2180. var self=this,$self=this;
  2181. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2182. return $core.withContext(function($ctx1) {
  2183. //>>excludeEnd("ctx");
  2184. var $1;
  2185. return $self._inlinedClosure_wrapFinalValueIn_([(
  2186. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2187. $ctx1.supercall = true,
  2188. //>>excludeEnd("ctx");
  2189. ($methodClass.superclass||$boot.nilAsClass).fn.prototype._inlineClosure_.call($self,anIRClosure))
  2190. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2191. ,$ctx1.supercall = false
  2192. //>>excludeEnd("ctx");
  2193. ][0],(function(final){
  2194. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2195. return $core.withContext(function($ctx2) {
  2196. //>>excludeEnd("ctx");
  2197. $1=$recv($globals.IRReturn)._new();
  2198. $recv($1)._add_($recv(final)._copy());
  2199. return $recv($1)._yourself();
  2200. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2201. }, function($ctx2) {$ctx2.fillBlock({final:final},$ctx1,1)});
  2202. //>>excludeEnd("ctx");
  2203. }));
  2204. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2205. }, function($ctx1) {$ctx1.fill(self,"inlineClosure:",{anIRClosure:anIRClosure})});
  2206. //>>excludeEnd("ctx");
  2207. }; }),
  2208. $globals.IRReturnInliner);
  2209. $core.addMethod(
  2210. $core.method({
  2211. selector: "inlineReturn:",
  2212. protocol: "inlining",
  2213. //>>excludeStart("ide", pragmas.excludeIdeData);
  2214. args: ["anIRReturn"],
  2215. source: "inlineReturn: anIRReturn\x0a\x09^ self inlineSend: anIRReturn expression andReplace: anIRReturn",
  2216. referencedClasses: [],
  2217. //>>excludeEnd("ide");
  2218. pragmas: [],
  2219. messageSends: ["inlineSend:andReplace:", "expression"]
  2220. }, function ($methodClass){ return function (anIRReturn){
  2221. var self=this,$self=this;
  2222. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2223. return $core.withContext(function($ctx1) {
  2224. //>>excludeEnd("ctx");
  2225. return $self._inlineSend_andReplace_($recv(anIRReturn)._expression(),anIRReturn);
  2226. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2227. }, function($ctx1) {$ctx1.fill(self,"inlineReturn:",{anIRReturn:anIRReturn})});
  2228. //>>excludeEnd("ctx");
  2229. }; }),
  2230. $globals.IRReturnInliner);
  2231. $core.addClass("InliningCodeGenerator", $globals.CodeGenerator, [], "Compiler-Inlining");
  2232. //>>excludeStart("ide", pragmas.excludeIdeData);
  2233. $globals.InliningCodeGenerator.comment="I am a specialized code generator that uses inlining to produce more optimized JavaScript output";
  2234. //>>excludeEnd("ide");
  2235. $core.addMethod(
  2236. $core.method({
  2237. selector: "inliner",
  2238. protocol: "compiling",
  2239. //>>excludeStart("ide", pragmas.excludeIdeData);
  2240. args: [],
  2241. source: "inliner\x0a\x09^ IRInliner new",
  2242. referencedClasses: ["IRInliner"],
  2243. //>>excludeEnd("ide");
  2244. pragmas: [],
  2245. messageSends: ["new"]
  2246. }, function ($methodClass){ return function (){
  2247. var self=this,$self=this;
  2248. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2249. return $core.withContext(function($ctx1) {
  2250. //>>excludeEnd("ctx");
  2251. return $recv($globals.IRInliner)._new();
  2252. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2253. }, function($ctx1) {$ctx1.fill(self,"inliner",{})});
  2254. //>>excludeEnd("ctx");
  2255. }; }),
  2256. $globals.InliningCodeGenerator);
  2257. $core.addMethod(
  2258. $core.method({
  2259. selector: "irTranslatorClass",
  2260. protocol: "compiling",
  2261. //>>excludeStart("ide", pragmas.excludeIdeData);
  2262. args: [],
  2263. source: "irTranslatorClass\x0a\x09^ IRInliningJSTranslator",
  2264. referencedClasses: ["IRInliningJSTranslator"],
  2265. //>>excludeEnd("ide");
  2266. pragmas: [],
  2267. messageSends: []
  2268. }, function ($methodClass){ return function (){
  2269. var self=this,$self=this;
  2270. return $globals.IRInliningJSTranslator;
  2271. }; }),
  2272. $globals.InliningCodeGenerator);
  2273. $core.addMethod(
  2274. $core.method({
  2275. selector: "preInliner",
  2276. protocol: "compiling",
  2277. //>>excludeStart("ide", pragmas.excludeIdeData);
  2278. args: [],
  2279. source: "preInliner\x0a\x09^ ASTPreInliner new",
  2280. referencedClasses: ["ASTPreInliner"],
  2281. //>>excludeEnd("ide");
  2282. pragmas: [],
  2283. messageSends: ["new"]
  2284. }, function ($methodClass){ return function (){
  2285. var self=this,$self=this;
  2286. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2287. return $core.withContext(function($ctx1) {
  2288. //>>excludeEnd("ctx");
  2289. return $recv($globals.ASTPreInliner)._new();
  2290. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2291. }, function($ctx1) {$ctx1.fill(self,"preInliner",{})});
  2292. //>>excludeEnd("ctx");
  2293. }; }),
  2294. $globals.InliningCodeGenerator);
  2295. $core.addMethod(
  2296. $core.method({
  2297. selector: "transformersDictionary",
  2298. protocol: "compiling",
  2299. //>>excludeStart("ide", pragmas.excludeIdeData);
  2300. args: [],
  2301. 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 ]",
  2302. referencedClasses: [],
  2303. //>>excludeEnd("ide");
  2304. pragmas: [],
  2305. messageSends: ["ifNil:", "at:put:", "transformersDictionary", "preInliner", "inliner", "irTranslator", "yourself"]
  2306. }, function ($methodClass){ return function (){
  2307. var self=this,$self=this;
  2308. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2309. return $core.withContext(function($ctx1) {
  2310. //>>excludeEnd("ctx");
  2311. var $1,$2;
  2312. $1=$self.transformersDictionary;
  2313. if($1 == null || $1.a$nil){
  2314. $2=[(
  2315. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2316. $ctx1.supercall = true,
  2317. //>>excludeEnd("ctx");
  2318. ($methodClass.superclass||$boot.nilAsClass).fn.prototype._transformersDictionary.call($self))
  2319. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2320. ,$ctx1.supercall = false
  2321. //>>excludeEnd("ctx");
  2322. ][0];
  2323. [$recv($2)._at_put_("3000-inlinerTagging",$self._preInliner())
  2324. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2325. ,$ctx1.sendIdx["at:put:"]=1
  2326. //>>excludeEnd("ctx");
  2327. ][0];
  2328. [$recv($2)._at_put_("6000-inliner",$self._inliner())
  2329. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2330. ,$ctx1.sendIdx["at:put:"]=2
  2331. //>>excludeEnd("ctx");
  2332. ][0];
  2333. $recv($2)._at_put_("8000-irToJs",$self._irTranslator());
  2334. $self.transformersDictionary=$recv($2)._yourself();
  2335. return $self.transformersDictionary;
  2336. } else {
  2337. return $1;
  2338. }
  2339. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2340. }, function($ctx1) {$ctx1.fill(self,"transformersDictionary",{})});
  2341. //>>excludeEnd("ctx");
  2342. }; }),
  2343. $globals.InliningCodeGenerator);
  2344. $core.addClass("InliningError", $globals.SemanticError, [], "Compiler-Inlining");
  2345. //>>excludeStart("ide", pragmas.excludeIdeData);
  2346. $globals.InliningError.comment="Instances of InliningError are signaled when using an `InliningCodeGenerator`in a `Compiler`.";
  2347. //>>excludeEnd("ide");
  2348. $core.addTrait("TIRInlinedVisitor", "Compiler-Inlining");
  2349. $core.addMethod(
  2350. $core.method({
  2351. selector: "visitIRInlinedClosure:",
  2352. protocol: "visiting",
  2353. //>>excludeStart("ide", pragmas.excludeIdeData);
  2354. args: ["anIRInlinedClosure"],
  2355. source: "visitIRInlinedClosure: anIRInlinedClosure\x0a\x09^ self visitIRClosure: anIRInlinedClosure",
  2356. referencedClasses: [],
  2357. //>>excludeEnd("ide");
  2358. pragmas: [],
  2359. messageSends: ["visitIRClosure:"]
  2360. }, function ($methodClass){ return function (anIRInlinedClosure){
  2361. var self=this,$self=this;
  2362. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2363. return $core.withContext(function($ctx1) {
  2364. //>>excludeEnd("ctx");
  2365. return $self._visitIRClosure_(anIRInlinedClosure);
  2366. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2367. }, function($ctx1) {$ctx1.fill(self,"visitIRInlinedClosure:",{anIRInlinedClosure:anIRInlinedClosure})});
  2368. //>>excludeEnd("ctx");
  2369. }; }),
  2370. $globals.TIRInlinedVisitor);
  2371. $core.addMethod(
  2372. $core.method({
  2373. selector: "visitIRInlinedSequence:",
  2374. protocol: "visiting",
  2375. //>>excludeStart("ide", pragmas.excludeIdeData);
  2376. args: ["anIRInlinedSequence"],
  2377. source: "visitIRInlinedSequence: anIRInlinedSequence\x0a\x09^ self visitIRSequence: anIRInlinedSequence",
  2378. referencedClasses: [],
  2379. //>>excludeEnd("ide");
  2380. pragmas: [],
  2381. messageSends: ["visitIRSequence:"]
  2382. }, function ($methodClass){ return function (anIRInlinedSequence){
  2383. var self=this,$self=this;
  2384. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2385. return $core.withContext(function($ctx1) {
  2386. //>>excludeEnd("ctx");
  2387. return $self._visitIRSequence_(anIRInlinedSequence);
  2388. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2389. }, function($ctx1) {$ctx1.fill(self,"visitIRInlinedSequence:",{anIRInlinedSequence:anIRInlinedSequence})});
  2390. //>>excludeEnd("ctx");
  2391. }; }),
  2392. $globals.TIRInlinedVisitor);
  2393. $core.setTraitComposition([{trait: $globals.TIRInlinedVisitor}], $globals.IRInliner);
  2394. $core.setTraitComposition([{trait: $globals.TIRInlinedVisitor}], $globals.IRInliningJSTranslator);
  2395. $core.addMethod(
  2396. $core.method({
  2397. selector: "asInlinedBlockResult",
  2398. protocol: "*Compiler-Inlining",
  2399. //>>excludeStart("ide", pragmas.excludeIdeData);
  2400. args: [],
  2401. source: "asInlinedBlockResult\x0a\x09^ self expression",
  2402. referencedClasses: [],
  2403. //>>excludeEnd("ide");
  2404. pragmas: [],
  2405. messageSends: ["expression"]
  2406. }, function ($methodClass){ return function (){
  2407. var self=this,$self=this;
  2408. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2409. return $core.withContext(function($ctx1) {
  2410. //>>excludeEnd("ctx");
  2411. return $self._expression();
  2412. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2413. }, function($ctx1) {$ctx1.fill(self,"asInlinedBlockResult",{})});
  2414. //>>excludeEnd("ctx");
  2415. }; }),
  2416. $globals.IRBlockReturn);
  2417. $core.addMethod(
  2418. $core.method({
  2419. selector: "asInlinedBlockResult",
  2420. protocol: "*Compiler-Inlining",
  2421. //>>excludeStart("ide", pragmas.excludeIdeData);
  2422. args: [],
  2423. source: "asInlinedBlockResult\x0a\x09^ self",
  2424. referencedClasses: [],
  2425. //>>excludeEnd("ide");
  2426. pragmas: [],
  2427. messageSends: []
  2428. }, function ($methodClass){ return function (){
  2429. var self=this,$self=this;
  2430. return self;
  2431. }; }),
  2432. $globals.IRInstruction);
  2433. });