Compiler-Inlining.js 87 KB

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