Compiler-Inlining.js 86 KB

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