Compiler-Inlining.js 88 KB

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