1
0

Compiler-Inlining.js 88 KB

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