Compiler-Inlining.js 98 KB

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