Compiler-IR.js 68 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925
  1. smalltalk.addPackage('Compiler-IR', {});
  2. smalltalk.addClass('IRASTTranslator', smalltalk.NodeVisitor, ['builder', 'source'], 'Compiler-IR');
  3. smalltalk.IRASTTranslator.comment="I am the AST (abstract syntax tree) visitor responsible for building the intermediate representation graph.\x0aI rely on a builder object, instance of IRBuilder.\x0a\x0aI am myself unable to produce a valid IR as nodes are not resolved. \x0aSee concrete subclasses."
  4. smalltalk.addMethod(
  5. "_builder",
  6. smalltalk.method({
  7. selector: "builder",
  8. category: 'accessing',
  9. fn: function () {
  10. var self=this;
  11. return (($receiver = self['@builder']) == nil || $receiver == undefined) ? (function(){return (self['@builder']=smalltalk.send((smalltalk.IRBuilder || IRBuilder), "_new", []));})() : $receiver;
  12. return self;},
  13. args: [],
  14. source: "builder\x0a\x09^ builder ifNil: [ builder := IRBuilder new ]",
  15. messageSends: ["ifNil:", "new"],
  16. referencedClasses: ["IRBuilder"]
  17. }),
  18. smalltalk.IRASTTranslator);
  19. smalltalk.addMethod(
  20. "_builder_",
  21. smalltalk.method({
  22. selector: "builder:",
  23. category: 'accessing',
  24. fn: function (aBuilder) {
  25. var self=this;
  26. (self['@builder']=aBuilder);
  27. return self;},
  28. args: ["aBuilder"],
  29. source: "builder: aBuilder\x0a\x09builder := aBuilder",
  30. messageSends: [],
  31. referencedClasses: []
  32. }),
  33. smalltalk.IRASTTranslator);
  34. smalltalk.addMethod(
  35. "_source",
  36. smalltalk.method({
  37. selector: "source",
  38. category: 'accessing',
  39. fn: function () {
  40. var self=this;
  41. return self['@source'];
  42. return self;},
  43. args: [],
  44. source: "source\x0a\x09^ source",
  45. messageSends: [],
  46. referencedClasses: []
  47. }),
  48. smalltalk.IRASTTranslator);
  49. smalltalk.addMethod(
  50. "_source_",
  51. smalltalk.method({
  52. selector: "source:",
  53. category: 'accessing',
  54. fn: function (aString) {
  55. var self=this;
  56. (self['@source']=aString);
  57. return self;},
  58. args: ["aString"],
  59. source: "source: aString\x0a\x09source := aString",
  60. messageSends: [],
  61. referencedClasses: []
  62. }),
  63. smalltalk.IRASTTranslator);
  64. smalltalk.addMethod(
  65. "_visitAssignmentNode_",
  66. smalltalk.method({
  67. selector: "visitAssignmentNode:",
  68. category: 'visiting',
  69. fn: function (aNode) {
  70. var self=this;
  71. (function($rec){smalltalk.send($rec, "_with_", [(function(){return smalltalk.send(self, "_visit_", [smalltalk.send(aNode, "_left", [])]);})]);return smalltalk.send($rec, "_with_", [(function(){return smalltalk.send(self, "_visit_", [smalltalk.send(aNode, "_right", [])]);})]);})(smalltalk.send(smalltalk.send(self, "_builder", []), "_assignment", []));
  72. return self;},
  73. args: ["aNode"],
  74. source: "visitAssignmentNode: aNode\x0a\x09self builder assignment \x0a\x09\x09with: [ self visit: aNode left ];\x0a\x09\x09with: [ self visit: aNode right ]",
  75. messageSends: ["with:", "visit:", "left", "right", "assignment", "builder"],
  76. referencedClasses: []
  77. }),
  78. smalltalk.IRASTTranslator);
  79. smalltalk.addMethod(
  80. "_visitBlockNode_",
  81. smalltalk.method({
  82. selector: "visitBlockNode:",
  83. category: 'visiting',
  84. fn: function (aNode) {
  85. var self=this;
  86. (function($rec){smalltalk.send($rec, "_with_", [(function(){return smalltalk.send(self, "_visitBlockNode_", [aNode], smalltalk.IRASTTranslator.superclass || nil);})]);return smalltalk.send($rec, "_arguments_", [smalltalk.send(aNode, "_parameters", [])]);})(smalltalk.send(smalltalk.send(self, "_builder", []), "_closure", []));
  87. return self;},
  88. args: ["aNode"],
  89. source: "visitBlockNode: aNode\x0a\x09self builder closure \x0a\x09\x09with: [ super visitBlockNode: aNode ];\x0a\x09\x09arguments: aNode parameters",
  90. messageSends: ["with:", "visitBlockNode:", "arguments:", "parameters", "closure", "builder"],
  91. referencedClasses: []
  92. }),
  93. smalltalk.IRASTTranslator);
  94. smalltalk.addMethod(
  95. "_visitJSStatementNode_",
  96. smalltalk.method({
  97. selector: "visitJSStatementNode:",
  98. category: 'visiting',
  99. fn: function (aNode) {
  100. var self=this;
  101. smalltalk.send(smalltalk.send(self, "_builder", []), "_verbatim_", [smalltalk.send(aNode, "_source", [])]);
  102. return self;},
  103. args: ["aNode"],
  104. source: "visitJSStatementNode: aNode\x0a\x09self builder verbatim: aNode source",
  105. messageSends: ["verbatim:", "builder", "source"],
  106. referencedClasses: []
  107. }),
  108. smalltalk.IRASTTranslator);
  109. smalltalk.addMethod(
  110. "_visitMethodNode_",
  111. smalltalk.method({
  112. selector: "visitMethodNode:",
  113. category: 'visiting',
  114. fn: function (aNode) {
  115. var self=this;
  116. (function($rec){smalltalk.send($rec, "_source_", [smalltalk.send(self, "_source", [])]);smalltalk.send($rec, "_arguments_", [smalltalk.send(aNode, "_arguments", [])]);smalltalk.send($rec, "_selector_", [smalltalk.send(aNode, "_selector", [])]);smalltalk.send($rec, "_messageSends_", [smalltalk.send(aNode, "_messageSends", [])]);return smalltalk.send($rec, "_classReferences_", [smalltalk.send(aNode, "_classReferences", [])]);})(smalltalk.send(smalltalk.send(self, "_builder", []), "_method", []));
  117. smalltalk.send(smalltalk.send(smalltalk.send(aNode, "_scope", []), "_temps", []), "_do_", [(function(each){return smalltalk.send(smalltalk.send(smalltalk.send(self, "_builder", []), "_tempDeclaration", []), "_name_", [smalltalk.send(each, "_name", [])]);})]);
  118. ((($receiver = smalltalk.send(aNode, "_hasNonLocalReturn", [])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(smalltalk.send(smalltalk.send(self, "_builder", []), "_nonLocalReturnHandling", []), "_with_", [(function(){return smalltalk.send(self, "_visitMethodNode_", [aNode], smalltalk.IRASTTranslator.superclass || nil);})]);})() : (function(){return smalltalk.send(self, "_visitMethodNode_", [aNode], smalltalk.IRASTTranslator.superclass || nil);})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return smalltalk.send(smalltalk.send(smalltalk.send(self, "_builder", []), "_nonLocalReturnHandling", []), "_with_", [(function(){return smalltalk.send(self, "_visitMethodNode_", [aNode], smalltalk.IRASTTranslator.superclass || nil);})]);}), (function(){return smalltalk.send(self, "_visitMethodNode_", [aNode], smalltalk.IRASTTranslator.superclass || nil);})]));
  119. return self;},
  120. args: ["aNode"],
  121. source: "visitMethodNode: aNode\x0a\x09self builder method \x0a\x09\x09source: self source;\x0a\x09\x09arguments: aNode arguments;\x0a\x09\x09selector: aNode selector;\x0a\x09\x09messageSends: aNode messageSends;\x0a\x09\x09classReferences: aNode classReferences.\x0a\x0a\x09aNode scope temps do: [ :each |\x0a\x09\x09self builder tempDeclaration name: each name ].\x0a\x09aNode hasNonLocalReturn \x0a\x09\x09ifTrue: [ self builder nonLocalReturnHandling with: [\x0a\x09\x09\x09super visitMethodNode: aNode ]]\x0a\x09\x09ifFalse: [ super visitMethodNode: aNode ]",
  122. messageSends: ["source:", "source", "arguments:", "arguments", "selector:", "selector", "messageSends:", "messageSends", "classReferences:", "classReferences", "method", "builder", "do:", "temps", "scope", "name:", "tempDeclaration", "name", "ifTrue:ifFalse:", "hasNonLocalReturn", "with:", "nonLocalReturnHandling", "visitMethodNode:"],
  123. referencedClasses: []
  124. }),
  125. smalltalk.IRASTTranslator);
  126. smalltalk.addMethod(
  127. "_visitReturnNode_",
  128. smalltalk.method({
  129. selector: "visitReturnNode:",
  130. category: 'visiting',
  131. fn: function (aNode) {
  132. var self=this;
  133. smalltalk.send(((($receiver = smalltalk.send(aNode, "_nonLocalReturn", [])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(smalltalk.send(self, "_builder", []), "_nonLocalReturn", []);})() : (function(){return smalltalk.send(smalltalk.send(self, "_builder", []), "_return", []);})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return smalltalk.send(smalltalk.send(self, "_builder", []), "_nonLocalReturn", []);}), (function(){return smalltalk.send(smalltalk.send(self, "_builder", []), "_return", []);})])), "_with_", [(function(){return smalltalk.send(self, "_visitReturnNode_", [aNode], smalltalk.IRASTTranslator.superclass || nil);})]);
  134. return self;},
  135. args: ["aNode"],
  136. source: "visitReturnNode: aNode\x0a\x09(aNode nonLocalReturn \x0a\x09\x09ifTrue: [ self builder nonLocalReturn ]\x0a\x09\x09ifFalse: [ self builder return ]) with: [ super visitReturnNode: aNode ]",
  137. messageSends: ["with:", "ifTrue:ifFalse:", "nonLocalReturn", "builder", "return", "visitReturnNode:"],
  138. referencedClasses: []
  139. }),
  140. smalltalk.IRASTTranslator);
  141. smalltalk.addMethod(
  142. "_visitSendNode_",
  143. smalltalk.method({
  144. selector: "visitSendNode:",
  145. category: 'visiting',
  146. fn: function (aNode) {
  147. var self=this;
  148. (function($rec){smalltalk.send($rec, "_selector_", [smalltalk.send(aNode, "_selector", [])]);return smalltalk.send($rec, "_with_", [(function(){smalltalk.send(self, "_visit_", [smalltalk.send(aNode, "_receiver", [])]);return smalltalk.send(smalltalk.send(aNode, "_arguments", []), "_do_", [(function(each){return smalltalk.send(self, "_visit_", [each]);})]);})]);})(smalltalk.send(smalltalk.send(self, "_builder", []), "_send", []));
  149. return self;},
  150. args: ["aNode"],
  151. source: "visitSendNode: aNode\x0a\x09self builder send\x0a\x09\x09selector: aNode selector;\x0a\x09\x09with: [\x0a\x09\x09\x09self visit: aNode receiver.\x0a\x09\x09\x09(aNode arguments do: [ :each | self visit: each ]) ]",
  152. messageSends: ["selector:", "selector", "with:", "visit:", "receiver", "do:", "arguments", "send", "builder"],
  153. referencedClasses: []
  154. }),
  155. smalltalk.IRASTTranslator);
  156. smalltalk.addMethod(
  157. "_visitSequenceNode_",
  158. smalltalk.method({
  159. selector: "visitSequenceNode:",
  160. category: 'visiting',
  161. fn: function (aNode) {
  162. var self=this;
  163. smalltalk.send(smalltalk.send(smalltalk.send(self, "_builder", []), "_sequence", []), "_with_", [(function(){return smalltalk.send(self, "_visitSequenceNode_", [aNode], smalltalk.IRASTTranslator.superclass || nil);})]);
  164. return self;},
  165. args: ["aNode"],
  166. source: "visitSequenceNode: aNode\x0a\x09self builder sequence with: [\x0a\x09\x09super visitSequenceNode: aNode ]",
  167. messageSends: ["with:", "sequence", "builder", "visitSequenceNode:"],
  168. referencedClasses: []
  169. }),
  170. smalltalk.IRASTTranslator);
  171. smalltalk.addMethod(
  172. "_visitValueNode_",
  173. smalltalk.method({
  174. selector: "visitValueNode:",
  175. category: 'visiting',
  176. fn: function (aNode) {
  177. var self=this;
  178. smalltalk.send(smalltalk.send(self, "_builder", []), "_value_", [smalltalk.send(aNode, "_value", [])]);
  179. return self;},
  180. args: ["aNode"],
  181. source: "visitValueNode: aNode\x0a\x09self builder value: aNode value",
  182. messageSends: ["value:", "builder", "value"],
  183. referencedClasses: []
  184. }),
  185. smalltalk.IRASTTranslator);
  186. smalltalk.addMethod(
  187. "_visitVariableNode_",
  188. smalltalk.method({
  189. selector: "visitVariableNode:",
  190. category: 'visiting',
  191. fn: function (aNode) {
  192. var self=this;
  193. smalltalk.send(smalltalk.send(self, "_builder", []), "_variable_", [smalltalk.send(aNode, "_binding", [])]);
  194. return self;},
  195. args: ["aNode"],
  196. source: "visitVariableNode: aNode\x0a\x09self builder variable: aNode binding",
  197. messageSends: ["variable:", "builder", "binding"],
  198. referencedClasses: []
  199. }),
  200. smalltalk.IRASTTranslator);
  201. smalltalk.addClass('IRASTResolver', smalltalk.IRASTTranslator, ['nextAlias'], 'Compiler-IR');
  202. smalltalk.IRASTResolver.comment="I resolve nodes by creating an alias variable when appropriate, to flatten the AST.\x0aNodes referenced in other nodes are aliased, except for some specific nodes such as variable or value nodes."
  203. smalltalk.addMethod(
  204. "_nextAlias",
  205. smalltalk.method({
  206. selector: "nextAlias",
  207. category: 'accessing',
  208. fn: function () {
  209. var self=this;
  210. (($receiver = self['@nextAlias']) == nil || $receiver == undefined) ? (function(){return (self['@nextAlias']=(0));})() : $receiver;
  211. (self['@nextAlias']=((($receiver = self['@nextAlias']).klass === smalltalk.Number) ? $receiver +(1) : smalltalk.send($receiver, "__plus", [(1)])));
  212. return smalltalk.send("$", "__comma", [smalltalk.send(self['@nextAlias'], "_asString", [])]);
  213. return self;},
  214. args: [],
  215. source: "nextAlias\x0a\x09\x22Message sends are assigned, or 'aliased', to internal variables.\x0a\x09Internal variable names are unique, and attached to the annotated send node\x22\x0a\x0a\x09nextAlias ifNil: [ nextAlias := 0 ].\x0a\x09nextAlias := nextAlias + 1.\x0a\x09^ '$', nextAlias asString",
  216. messageSends: ["ifNil:", "+", ",", "asString"],
  217. referencedClasses: []
  218. }),
  219. smalltalk.IRASTResolver);
  220. smalltalk.addMethod(
  221. "_resolve_",
  222. smalltalk.method({
  223. selector: "resolve:",
  224. category: 'visiting',
  225. fn: function (aNode) {
  226. var self=this;
  227. ((($receiver = smalltalk.send(aNode, "_isBlockSequenceNode", [])).klass === smalltalk.Boolean) ? (! $receiver ? (function(){return smalltalk.send(smalltalk.send(aNode, "_nodes", []), "_do_", [(function(each){return smalltalk.send(self, "_resolve_", [each]);})]);})() : nil) : smalltalk.send($receiver, "_ifFalse_", [(function(){return smalltalk.send(smalltalk.send(aNode, "_nodes", []), "_do_", [(function(each){return smalltalk.send(self, "_resolve_", [each]);})]);})]));
  228. ((($receiver = smalltalk.send(aNode, "_shouldBeAliased", [])).klass === smalltalk.Boolean) ? ($receiver ? (function(){var alias=nil;
  229. (alias=smalltalk.send(self, "_nextAlias", []));smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(self, "_builder", []), "_method", []), "_internalVariables", []), "_add_", [alias]);(function($rec){smalltalk.send($rec, "_with_", [(function(){return smalltalk.send(smalltalk.send(self, "_builder", []), "_variable_", [smalltalk.send(smalltalk.send((smalltalk.AliasVar || AliasVar), "_new", []), "_name_", [alias])]);})]);return smalltalk.send($rec, "_with_", [(function(){return smalltalk.send(self, "_visit_resolving_", [aNode, false]);})]);})(smalltalk.send(smalltalk.send(self, "_builder", []), "_assignment", []));return smalltalk.send(aNode, "_alias_", [alias]);})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){var alias=nil;
  230. (alias=smalltalk.send(self, "_nextAlias", []));smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(self, "_builder", []), "_method", []), "_internalVariables", []), "_add_", [alias]);(function($rec){smalltalk.send($rec, "_with_", [(function(){return smalltalk.send(smalltalk.send(self, "_builder", []), "_variable_", [smalltalk.send(smalltalk.send((smalltalk.AliasVar || AliasVar), "_new", []), "_name_", [alias])]);})]);return smalltalk.send($rec, "_with_", [(function(){return smalltalk.send(self, "_visit_resolving_", [aNode, false]);})]);})(smalltalk.send(smalltalk.send(self, "_builder", []), "_assignment", []));return smalltalk.send(aNode, "_alias_", [alias]);})]));
  231. return self;},
  232. args: ["aNode"],
  233. source: "resolve: aNode\x0a\x09aNode isBlockSequenceNode ifFalse: [\x0a\x09\x09aNode nodes do: [ :each | self resolve: each ]].\x0a\x09aNode shouldBeAliased ifTrue: [\x0a\x09\x09| alias |\x0a\x09\x09alias := self nextAlias.\x0a\x09\x09self builder method internalVariables add: alias.\x0a\x09\x09self builder assignment\x0a\x09\x09\x09with: [ self builder variable: (AliasVar new name: alias) ];\x0a\x09\x09\x09with: [ self visit: aNode resolving: false ].\x0a\x09\x09\x09aNode alias: alias ]",
  234. messageSends: ["ifFalse:", "isBlockSequenceNode", "do:", "nodes", "resolve:", "ifTrue:", "shouldBeAliased", "nextAlias", "add:", "internalVariables", "method", "builder", "with:", "variable:", "name:", "new", "visit:resolving:", "assignment", "alias:"],
  235. referencedClasses: ["AliasVar"]
  236. }),
  237. smalltalk.IRASTResolver);
  238. smalltalk.addMethod(
  239. "_visit_",
  240. smalltalk.method({
  241. selector: "visit:",
  242. category: 'visiting',
  243. fn: function (aNode) {
  244. var self=this;
  245. smalltalk.send(self, "_visit_resolving_", [aNode, smalltalk.send(aNode, "_canAliasChildren", [])]);
  246. return self;},
  247. args: ["aNode"],
  248. source: "visit: aNode\x0a\x09self visit: aNode resolving: aNode canAliasChildren ",
  249. messageSends: ["visit:resolving:", "canAliasChildren"],
  250. referencedClasses: []
  251. }),
  252. smalltalk.IRASTResolver);
  253. smalltalk.addMethod(
  254. "_visit_resolving_",
  255. smalltalk.method({
  256. selector: "visit:resolving:",
  257. category: 'visiting',
  258. fn: function (aNode, aBoolean) {
  259. var self=this;
  260. ((($receiver = aBoolean).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(self, "_resolve_", [aNode]);})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return smalltalk.send(self, "_resolve_", [aNode]);})]));
  261. ((($receiver = smalltalk.send(aNode, "_isAliased", [])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(self, "_visitAliased_", [aNode]);})() : (function(){return smalltalk.send(self, "_visit_", [aNode], smalltalk.IRASTResolver.superclass || nil);})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return smalltalk.send(self, "_visitAliased_", [aNode]);}), (function(){return smalltalk.send(self, "_visit_", [aNode], smalltalk.IRASTResolver.superclass || nil);})]));
  262. return self;},
  263. args: ["aNode", "aBoolean"],
  264. source: "visit: aNode resolving: aBoolean\x0a\x09aBoolean ifTrue: [ self resolve: aNode ].\x0a\x09aNode isAliased \x0a\x09\x09ifTrue: [ self visitAliased: aNode ]\x0a\x09\x09ifFalse: [ super visit: aNode ]",
  265. messageSends: ["ifTrue:", "resolve:", "ifTrue:ifFalse:", "isAliased", "visitAliased:", "visit:"],
  266. referencedClasses: []
  267. }),
  268. smalltalk.IRASTResolver);
  269. smalltalk.addMethod(
  270. "_visitAliased_",
  271. smalltalk.method({
  272. selector: "visitAliased:",
  273. category: 'visiting',
  274. fn: function (aNode) {
  275. var self=this;
  276. return smalltalk.send(smalltalk.send(self, "_builder", []), "_variable_", [smalltalk.send(smalltalk.send((smalltalk.AliasVar || AliasVar), "_new", []), "_name_", [smalltalk.send(aNode, "_alias", [])])]);
  277. return self;},
  278. args: ["aNode"],
  279. source: "visitAliased: aNode\x0a\x09^ self builder variable: (AliasVar new name: aNode alias)",
  280. messageSends: ["variable:", "builder", "name:", "new", "alias"],
  281. referencedClasses: ["AliasVar"]
  282. }),
  283. smalltalk.IRASTResolver);
  284. smalltalk.addClass('IRBuilder', smalltalk.Object, ['method', 'root', 'nextPc'], 'Compiler-IR');
  285. smalltalk.IRBuilder.comment="I am responsible for building the IR (Intermatiate Representation) graph, composed of IRInstruction objects."
  286. smalltalk.addMethod(
  287. "_add_",
  288. smalltalk.method({
  289. selector: "add:",
  290. category: 'building',
  291. fn: function (aClass) {
  292. var self=this;
  293. return smalltalk.send(smalltalk.send(self, "_root", []), "_append_", [smalltalk.send(aClass, "_on_", [self])]);
  294. return self;},
  295. args: ["aClass"],
  296. source: "add: aClass\x0a\x09^ self root append: (aClass on: self)",
  297. messageSends: ["append:", "root", "on:"],
  298. referencedClasses: []
  299. }),
  300. smalltalk.IRBuilder);
  301. smalltalk.addMethod(
  302. "_append_",
  303. smalltalk.method({
  304. selector: "append:",
  305. category: 'building',
  306. fn: function (anObject) {
  307. var self=this;
  308. return smalltalk.send(self['@root'], "_append_", [anObject]);
  309. return self;},
  310. args: ["anObject"],
  311. source: "append: anObject\x0a\x09^root append: anObject",
  312. messageSends: ["append:"],
  313. referencedClasses: []
  314. }),
  315. smalltalk.IRBuilder);
  316. smalltalk.addMethod(
  317. "_assignment",
  318. smalltalk.method({
  319. selector: "assignment",
  320. category: 'building',
  321. fn: function () {
  322. var self=this;
  323. return smalltalk.send(self, "_add_", [(smalltalk.IRAssignment || IRAssignment)]);
  324. return self;},
  325. args: [],
  326. source: "assignment\x0a\x09^ self add: IRAssignment",
  327. messageSends: ["add:"],
  328. referencedClasses: ["IRAssignment"]
  329. }),
  330. smalltalk.IRBuilder);
  331. smalltalk.addMethod(
  332. "_closure",
  333. smalltalk.method({
  334. selector: "closure",
  335. category: 'building',
  336. fn: function () {
  337. var self=this;
  338. return smalltalk.send(self, "_add_", [(smalltalk.IRClosure || IRClosure)]);
  339. return self;},
  340. args: [],
  341. source: "closure\x0a\x09^ self add: IRClosure",
  342. messageSends: ["add:"],
  343. referencedClasses: ["IRClosure"]
  344. }),
  345. smalltalk.IRBuilder);
  346. smalltalk.addMethod(
  347. "_emitOn_",
  348. smalltalk.method({
  349. selector: "emitOn:",
  350. category: 'emiting',
  351. fn: function (aStream) {
  352. var self=this;
  353. smalltalk.send(self['@method'], "_emitOn_", [aStream]);
  354. return self;},
  355. args: ["aStream"],
  356. source: "emitOn: aStream\x0a\x09method emitOn: aStream",
  357. messageSends: ["emitOn:"],
  358. referencedClasses: []
  359. }),
  360. smalltalk.IRBuilder);
  361. smalltalk.addMethod(
  362. "_initialize",
  363. smalltalk.method({
  364. selector: "initialize",
  365. category: 'initialization',
  366. fn: function () {
  367. var self=this;
  368. smalltalk.send(self, "_initialize", [], smalltalk.IRBuilder.superclass || nil);
  369. (self['@root']=(self['@method']=smalltalk.send((smalltalk.IRMethod || IRMethod), "_on_", [self])));
  370. return self;},
  371. args: [],
  372. source: "initialize\x0a\x09super initialize.\x0a\x09root := method := IRMethod on: self",
  373. messageSends: ["initialize", "on:"],
  374. referencedClasses: ["IRMethod"]
  375. }),
  376. smalltalk.IRBuilder);
  377. smalltalk.addMethod(
  378. "_method",
  379. smalltalk.method({
  380. selector: "method",
  381. category: 'accessing',
  382. fn: function () {
  383. var self=this;
  384. return self['@method'];
  385. return self;},
  386. args: [],
  387. source: "method\x0a\x09^ method",
  388. messageSends: [],
  389. referencedClasses: []
  390. }),
  391. smalltalk.IRBuilder);
  392. smalltalk.addMethod(
  393. "_nextPc",
  394. smalltalk.method({
  395. selector: "nextPc",
  396. category: 'accessing',
  397. fn: function () {
  398. var self=this;
  399. (($receiver = self['@nextPc']) == nil || $receiver == undefined) ? (function(){return (self['@nextPc']=(0));})() : $receiver;
  400. (self['@nextPc']=((($receiver = self['@nextPc']).klass === smalltalk.Number) ? $receiver +(1) : smalltalk.send($receiver, "__plus", [(1)])));
  401. return self['@nextPc'];
  402. return self;},
  403. args: [],
  404. source: "nextPc\x0a\x09nextPc ifNil: [ nextPc := 0 ].\x0a\x09nextPc := nextPc + 1.\x0a\x09^ nextPc",
  405. messageSends: ["ifNil:", "+"],
  406. referencedClasses: []
  407. }),
  408. smalltalk.IRBuilder);
  409. smalltalk.addMethod(
  410. "_nonLocalReturn",
  411. smalltalk.method({
  412. selector: "nonLocalReturn",
  413. category: 'building',
  414. fn: function () {
  415. var self=this;
  416. return smalltalk.send(self, "_add_", [(smalltalk.IRNonLocalReturn || IRNonLocalReturn)]);
  417. return self;},
  418. args: [],
  419. source: "nonLocalReturn\x0a\x09^ self add: IRNonLocalReturn",
  420. messageSends: ["add:"],
  421. referencedClasses: ["IRNonLocalReturn"]
  422. }),
  423. smalltalk.IRBuilder);
  424. smalltalk.addMethod(
  425. "_nonLocalReturnHandling",
  426. smalltalk.method({
  427. selector: "nonLocalReturnHandling",
  428. category: 'building',
  429. fn: function () {
  430. var self=this;
  431. return smalltalk.send(self, "_add_", [(smalltalk.IRNonLocalReturnHandling || IRNonLocalReturnHandling)]);
  432. return self;},
  433. args: [],
  434. source: "nonLocalReturnHandling\x0a\x09^ self add: IRNonLocalReturnHandling",
  435. messageSends: ["add:"],
  436. referencedClasses: ["IRNonLocalReturnHandling"]
  437. }),
  438. smalltalk.IRBuilder);
  439. smalltalk.addMethod(
  440. "_return",
  441. smalltalk.method({
  442. selector: "return",
  443. category: 'building',
  444. fn: function () {
  445. var self=this;
  446. return smalltalk.send(self, "_add_", [(smalltalk.IRReturn || IRReturn)]);
  447. return self;},
  448. args: [],
  449. source: "return\x0a\x09^ self add: IRReturn",
  450. messageSends: ["add:"],
  451. referencedClasses: ["IRReturn"]
  452. }),
  453. smalltalk.IRBuilder);
  454. smalltalk.addMethod(
  455. "_root",
  456. smalltalk.method({
  457. selector: "root",
  458. category: 'accessing',
  459. fn: function () {
  460. var self=this;
  461. return self['@root'];
  462. return self;},
  463. args: [],
  464. source: "root\x0a\x09^ root",
  465. messageSends: [],
  466. referencedClasses: []
  467. }),
  468. smalltalk.IRBuilder);
  469. smalltalk.addMethod(
  470. "_root_",
  471. smalltalk.method({
  472. selector: "root:",
  473. category: 'accessing',
  474. fn: function (anIRInstruction) {
  475. var self=this;
  476. (self['@root']=anIRInstruction);
  477. return self;},
  478. args: ["anIRInstruction"],
  479. source: "root: anIRInstruction\x0a\x09root := anIRInstruction",
  480. messageSends: [],
  481. referencedClasses: []
  482. }),
  483. smalltalk.IRBuilder);
  484. smalltalk.addMethod(
  485. "_send",
  486. smalltalk.method({
  487. selector: "send",
  488. category: 'building',
  489. fn: function () {
  490. var self=this;
  491. return smalltalk.send(self, "_add_", [(smalltalk.IRSend || IRSend)]);
  492. return self;},
  493. args: [],
  494. source: "send\x0a\x09^ self add: IRSend",
  495. messageSends: ["add:"],
  496. referencedClasses: ["IRSend"]
  497. }),
  498. smalltalk.IRBuilder);
  499. smalltalk.addMethod(
  500. "_sequence",
  501. smalltalk.method({
  502. selector: "sequence",
  503. category: 'building',
  504. fn: function () {
  505. var self=this;
  506. return smalltalk.send(self, "_add_", [(smalltalk.IRSequence || IRSequence)]);
  507. return self;},
  508. args: [],
  509. source: "sequence\x0a\x09^ self add: IRSequence",
  510. messageSends: ["add:"],
  511. referencedClasses: ["IRSequence"]
  512. }),
  513. smalltalk.IRBuilder);
  514. smalltalk.addMethod(
  515. "_statement",
  516. smalltalk.method({
  517. selector: "statement",
  518. category: 'building',
  519. fn: function () {
  520. var self=this;
  521. return smalltalk.send(self, "_add_", [(smalltalk.IRStatement || IRStatement)]);
  522. return self;},
  523. args: [],
  524. source: "statement\x0a\x09^ self add: IRStatement",
  525. messageSends: ["add:"],
  526. referencedClasses: ["IRStatement"]
  527. }),
  528. smalltalk.IRBuilder);
  529. smalltalk.addMethod(
  530. "_tempDeclaration",
  531. smalltalk.method({
  532. selector: "tempDeclaration",
  533. category: 'building',
  534. fn: function () {
  535. var self=this;
  536. return smalltalk.send(self, "_add_", [(smalltalk.IRTempDeclaration || IRTempDeclaration)]);
  537. return self;},
  538. args: [],
  539. source: "tempDeclaration\x0a\x09^ self add: IRTempDeclaration",
  540. messageSends: ["add:"],
  541. referencedClasses: ["IRTempDeclaration"]
  542. }),
  543. smalltalk.IRBuilder);
  544. smalltalk.addMethod(
  545. "_value",
  546. smalltalk.method({
  547. selector: "value",
  548. category: 'building',
  549. fn: function () {
  550. var self=this;
  551. return smalltalk.send(self, "_add_", [(smalltalk.IRValue || IRValue)]);
  552. return self;},
  553. args: [],
  554. source: "value\x0a\x09^ self add: IRValue",
  555. messageSends: ["add:"],
  556. referencedClasses: ["IRValue"]
  557. }),
  558. smalltalk.IRBuilder);
  559. smalltalk.addMethod(
  560. "_value_",
  561. smalltalk.method({
  562. selector: "value:",
  563. category: 'building',
  564. fn: function (aString) {
  565. var self=this;
  566. return (function($rec){smalltalk.send($rec, "_value_", [aString]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send(self, "_value", []));
  567. return self;},
  568. args: ["aString"],
  569. source: "value: aString\x0a\x09^ self value\x0a\x09\x09value: aString;\x0a\x09\x09yourself",
  570. messageSends: ["value:", "yourself", "value"],
  571. referencedClasses: []
  572. }),
  573. smalltalk.IRBuilder);
  574. smalltalk.addMethod(
  575. "_variable",
  576. smalltalk.method({
  577. selector: "variable",
  578. category: 'building',
  579. fn: function () {
  580. var self=this;
  581. return smalltalk.send(self, "_add_", [(smalltalk.IRVariable || IRVariable)]);
  582. return self;},
  583. args: [],
  584. source: "variable\x0a\x09^ self add: IRVariable",
  585. messageSends: ["add:"],
  586. referencedClasses: ["IRVariable"]
  587. }),
  588. smalltalk.IRBuilder);
  589. smalltalk.addMethod(
  590. "_variable_",
  591. smalltalk.method({
  592. selector: "variable:",
  593. category: 'building',
  594. fn: function (aScopeVariable) {
  595. var self=this;
  596. return (function($rec){smalltalk.send($rec, "_variable_", [aScopeVariable]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send(self, "_variable", []));
  597. return self;},
  598. args: ["aScopeVariable"],
  599. source: "variable: aScopeVariable\x0a\x09^ self variable\x0a\x09\x09variable: aScopeVariable;\x0a\x09\x09yourself",
  600. messageSends: ["variable:", "yourself", "variable"],
  601. referencedClasses: []
  602. }),
  603. smalltalk.IRBuilder);
  604. smalltalk.addMethod(
  605. "_verbatim_",
  606. smalltalk.method({
  607. selector: "verbatim:",
  608. category: 'building',
  609. fn: function (aString) {
  610. var self=this;
  611. return (function($rec){smalltalk.send($rec, "_source_", [aString]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send(self, "_add_", [(smalltalk.IRVerbatim || IRVerbatim)]));
  612. return self;},
  613. args: ["aString"],
  614. source: "verbatim: aString\x0a\x09^(self add: IRVerbatim)\x0a\x09\x09source: aString;\x0a\x09\x09yourself",
  615. messageSends: ["source:", "yourself", "add:"],
  616. referencedClasses: ["IRVerbatim"]
  617. }),
  618. smalltalk.IRBuilder);
  619. smalltalk.addMethod(
  620. "_with_",
  621. smalltalk.method({
  622. selector: "with:",
  623. category: 'building',
  624. fn: function (anObject) {
  625. var self=this;
  626. smalltalk.send(smalltalk.send(self, "_root", []), "_with_", [anObject]);
  627. return self;},
  628. args: ["anObject"],
  629. source: "with: anObject\x0a\x09self root with: anObject",
  630. messageSends: ["with:", "root"],
  631. referencedClasses: []
  632. }),
  633. smalltalk.IRBuilder);
  634. smalltalk.addClass('IRInstruction', smalltalk.Object, ['builder', 'instructions'], 'Compiler-IR');
  635. smalltalk.IRInstruction.comment="I am the abstract root class of the IR (intermediate representation) instructions class hierarchy.\x0aThe IR graph is used to emit JavaScript code using a JSStream. "
  636. smalltalk.addMethod(
  637. "_append_",
  638. smalltalk.method({
  639. selector: "append:",
  640. category: 'building',
  641. fn: function (anObject) {
  642. var self=this;
  643. smalltalk.send(anObject, "_appendToInstruction_", [self]);
  644. return anObject;
  645. return self;},
  646. args: ["anObject"],
  647. source: "append: anObject\x0a\x09anObject appendToInstruction: self.\x0a\x09^ anObject",
  648. messageSends: ["appendToInstruction:"],
  649. referencedClasses: []
  650. }),
  651. smalltalk.IRInstruction);
  652. smalltalk.addMethod(
  653. "_appendBlock_",
  654. smalltalk.method({
  655. selector: "appendBlock:",
  656. category: 'building',
  657. fn: function (aBlock) {
  658. var self=this;
  659. var root=nil;
  660. (root=smalltalk.send(smalltalk.send(self, "_builder", []), "_root", []));
  661. smalltalk.send(smalltalk.send(self, "_builder", []), "_root_", [self]);
  662. smalltalk.send(aBlock, "_value", []);
  663. smalltalk.send(smalltalk.send(self, "_builder", []), "_root_", [root]);
  664. return self;},
  665. args: ["aBlock"],
  666. source: "appendBlock: aBlock\x0a\x09| root |\x0a\x09root := self builder root.\x0a\x09self builder root: self.\x0a\x09aBlock value.\x0a\x09self builder root: root",
  667. messageSends: ["root", "builder", "root:", "value"],
  668. referencedClasses: []
  669. }),
  670. smalltalk.IRInstruction);
  671. smalltalk.addMethod(
  672. "_appendInstruction_",
  673. smalltalk.method({
  674. selector: "appendInstruction:",
  675. category: 'building',
  676. fn: function (anIRInstruction) {
  677. var self=this;
  678. smalltalk.send(smalltalk.send(self, "_instructions", []), "_add_", [anIRInstruction]);
  679. return self;},
  680. args: ["anIRInstruction"],
  681. source: "appendInstruction: anIRInstruction\x0a\x09self instructions add: anIRInstruction",
  682. messageSends: ["add:", "instructions"],
  683. referencedClasses: []
  684. }),
  685. smalltalk.IRInstruction);
  686. smalltalk.addMethod(
  687. "_appendString_",
  688. smalltalk.method({
  689. selector: "appendString:",
  690. category: 'building',
  691. fn: function (aString) {
  692. var self=this;
  693. smalltalk.send(self, "_append_", [smalltalk.send(smalltalk.send(self, "_builder", []), "_value_", [aString])]);
  694. return self;},
  695. args: ["aString"],
  696. source: "appendString: aString\x0a\x09self append: (self builder value: aString)",
  697. messageSends: ["append:", "value:", "builder"],
  698. referencedClasses: []
  699. }),
  700. smalltalk.IRInstruction);
  701. smalltalk.addMethod(
  702. "_appendToInstruction_",
  703. smalltalk.method({
  704. selector: "appendToInstruction:",
  705. category: 'building',
  706. fn: function (anIRInstruction) {
  707. var self=this;
  708. smalltalk.send(anIRInstruction, "_appendInstruction_", [self]);
  709. return self;},
  710. args: ["anIRInstruction"],
  711. source: "appendToInstruction: anIRInstruction\x0a\x09anIRInstruction appendInstruction: self",
  712. messageSends: ["appendInstruction:"],
  713. referencedClasses: []
  714. }),
  715. smalltalk.IRInstruction);
  716. smalltalk.addMethod(
  717. "_builder",
  718. smalltalk.method({
  719. selector: "builder",
  720. category: 'accessing',
  721. fn: function () {
  722. var self=this;
  723. return self['@builder'];
  724. return self;},
  725. args: [],
  726. source: "builder\x0a\x09^ builder",
  727. messageSends: [],
  728. referencedClasses: []
  729. }),
  730. smalltalk.IRInstruction);
  731. smalltalk.addMethod(
  732. "_builder_",
  733. smalltalk.method({
  734. selector: "builder:",
  735. category: 'accessing',
  736. fn: function (aBuilder) {
  737. var self=this;
  738. (self['@builder']=aBuilder);
  739. return self;},
  740. args: ["aBuilder"],
  741. source: "builder: aBuilder\x0a\x09builder := aBuilder",
  742. messageSends: [],
  743. referencedClasses: []
  744. }),
  745. smalltalk.IRInstruction);
  746. smalltalk.addMethod(
  747. "_emitOn_",
  748. smalltalk.method({
  749. selector: "emitOn:",
  750. category: 'emiting',
  751. fn: function (aStream) {
  752. var self=this;
  753. smalltalk.send(smalltalk.send(self, "_instructions", []), "_do_", [(function(each){return smalltalk.send(each, "_emitOn_", [aStream]);})]);
  754. return self;},
  755. args: ["aStream"],
  756. source: "emitOn: aStream\x0a\x09\x22Just emit all sub instructions to aStream.\x0a\x09Subclasses should not forget to call `super emitOn:`\x22\x0a\x0a\x09self instructions do: [ :each |\x0a\x09\x09each emitOn: aStream ]",
  757. messageSends: ["do:", "instructions", "emitOn:"],
  758. referencedClasses: []
  759. }),
  760. smalltalk.IRInstruction);
  761. smalltalk.addMethod(
  762. "_instructions",
  763. smalltalk.method({
  764. selector: "instructions",
  765. category: 'accessing',
  766. fn: function () {
  767. var self=this;
  768. return (($receiver = self['@instructions']) == nil || $receiver == undefined) ? (function(){return (self['@instructions']=smalltalk.send((smalltalk.OrderedCollection || OrderedCollection), "_new", []));})() : $receiver;
  769. return self;},
  770. args: [],
  771. source: "instructions\x0a\x09^ instructions ifNil: [ instructions := OrderedCollection new ]",
  772. messageSends: ["ifNil:", "new"],
  773. referencedClasses: ["OrderedCollection"]
  774. }),
  775. smalltalk.IRInstruction);
  776. smalltalk.addMethod(
  777. "_with_",
  778. smalltalk.method({
  779. selector: "with:",
  780. category: 'building',
  781. fn: function (anObject) {
  782. var self=this;
  783. smalltalk.send(anObject, "_appendToInstruction_", [self]);
  784. return self;},
  785. args: ["anObject"],
  786. source: "with: anObject\x0a\x09anObject appendToInstruction: self",
  787. messageSends: ["appendToInstruction:"],
  788. referencedClasses: []
  789. }),
  790. smalltalk.IRInstruction);
  791. smalltalk.addMethod(
  792. "_on_",
  793. smalltalk.method({
  794. selector: "on:",
  795. category: 'instance creation',
  796. fn: function (aBuilder) {
  797. var self=this;
  798. return (function($rec){smalltalk.send($rec, "_builder_", [aBuilder]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send(self, "_new", []));
  799. return self;},
  800. args: ["aBuilder"],
  801. source: "on: aBuilder\x0a\x09^ self new\x0a\x09\x09builder: aBuilder;\x0a\x09\x09yourself",
  802. messageSends: ["builder:", "yourself", "new"],
  803. referencedClasses: []
  804. }),
  805. smalltalk.IRInstruction.klass);
  806. smalltalk.addClass('IRAssignment', smalltalk.IRInstruction, ['left', 'right'], 'Compiler-IR');
  807. smalltalk.addMethod(
  808. "_emitOn_",
  809. smalltalk.method({
  810. selector: "emitOn:",
  811. category: 'emiting',
  812. fn: function (aStream) {
  813. var self=this;
  814. smalltalk.send(aStream, "_nextPutAssignment_to_", [smalltalk.send(smalltalk.send(self, "_instructions", []), "_first", []), smalltalk.send(smalltalk.send(self, "_instructions", []), "_last", [])]);
  815. return self;},
  816. args: ["aStream"],
  817. source: "emitOn: aStream\x0a\x09aStream \x0a\x09\x09nextPutAssignment: self instructions first \x0a\x09\x09to: self instructions last",
  818. messageSends: ["nextPutAssignment:to:", "first", "instructions", "last"],
  819. referencedClasses: []
  820. }),
  821. smalltalk.IRAssignment);
  822. smalltalk.addClass('IRClosure', smalltalk.IRInstruction, ['arguments'], 'Compiler-IR');
  823. smalltalk.addMethod(
  824. "_arguments",
  825. smalltalk.method({
  826. selector: "arguments",
  827. category: 'accessing',
  828. fn: function () {
  829. var self=this;
  830. return self['@arguments'];
  831. return self;},
  832. args: [],
  833. source: "arguments\x0a\x09^ arguments",
  834. messageSends: [],
  835. referencedClasses: []
  836. }),
  837. smalltalk.IRClosure);
  838. smalltalk.addMethod(
  839. "_arguments_",
  840. smalltalk.method({
  841. selector: "arguments:",
  842. category: 'accessing',
  843. fn: function (aCollection) {
  844. var self=this;
  845. (self['@arguments']=aCollection);
  846. return self;},
  847. args: ["aCollection"],
  848. source: "arguments: aCollection\x0a\x09arguments := aCollection",
  849. messageSends: [],
  850. referencedClasses: []
  851. }),
  852. smalltalk.IRClosure);
  853. smalltalk.addMethod(
  854. "_emitOn_",
  855. smalltalk.method({
  856. selector: "emitOn:",
  857. category: 'emiting',
  858. fn: function (aStream) {
  859. var self=this;
  860. smalltalk.send(aStream, "_nextPutClosureWith_arguments_", [(function(){return smalltalk.send(self, "_emitOn_", [aStream], smalltalk.IRClosure.superclass || nil);}), smalltalk.send(self, "_arguments", [])]);
  861. return self;},
  862. args: ["aStream"],
  863. source: "emitOn: aStream\x0a\x09aStream \x0a\x09\x09nextPutClosureWith: [ super emitOn: aStream ] \x0a\x09\x09arguments: self arguments",
  864. messageSends: ["nextPutClosureWith:arguments:", "emitOn:", "arguments"],
  865. referencedClasses: []
  866. }),
  867. smalltalk.IRClosure);
  868. smalltalk.addClass('IRMethod', smalltalk.IRInstruction, ['source', 'selector', 'classReferences', 'messageSends', 'arguments', 'internalVariables', 'source'], 'Compiler-IR');
  869. smalltalk.IRMethod.comment="I am a method instruction"
  870. smalltalk.addMethod(
  871. "_arguments",
  872. smalltalk.method({
  873. selector: "arguments",
  874. category: 'accessing',
  875. fn: function () {
  876. var self=this;
  877. return self['@arguments'];
  878. return self;},
  879. args: [],
  880. source: "arguments\x0a\x09^ arguments",
  881. messageSends: [],
  882. referencedClasses: []
  883. }),
  884. smalltalk.IRMethod);
  885. smalltalk.addMethod(
  886. "_arguments_",
  887. smalltalk.method({
  888. selector: "arguments:",
  889. category: 'accessing',
  890. fn: function (aCollection) {
  891. var self=this;
  892. (self['@arguments']=aCollection);
  893. return self;},
  894. args: ["aCollection"],
  895. source: "arguments: aCollection\x0a\x09arguments := aCollection",
  896. messageSends: [],
  897. referencedClasses: []
  898. }),
  899. smalltalk.IRMethod);
  900. smalltalk.addMethod(
  901. "_classReferences",
  902. smalltalk.method({
  903. selector: "classReferences",
  904. category: 'accessing',
  905. fn: function () {
  906. var self=this;
  907. return self['@classReferences'];
  908. return self;},
  909. args: [],
  910. source: "classReferences\x0a\x09^ classReferences",
  911. messageSends: [],
  912. referencedClasses: []
  913. }),
  914. smalltalk.IRMethod);
  915. smalltalk.addMethod(
  916. "_classReferences_",
  917. smalltalk.method({
  918. selector: "classReferences:",
  919. category: 'accessing',
  920. fn: function (aCollection) {
  921. var self=this;
  922. (self['@classReferences']=aCollection);
  923. return self;},
  924. args: ["aCollection"],
  925. source: "classReferences: aCollection\x0a\x09classReferences := aCollection",
  926. messageSends: [],
  927. referencedClasses: []
  928. }),
  929. smalltalk.IRMethod);
  930. smalltalk.addMethod(
  931. "_emitOn_",
  932. smalltalk.method({
  933. selector: "emitOn:",
  934. category: 'emiting',
  935. fn: function (aStream) {
  936. var self=this;
  937. smalltalk.send(aStream, "_nextPutMethodDeclaration_with_", [self, (function(){return smalltalk.send(aStream, "_nextPutFunctionWith_arguments_", [(function(){((($receiver = smalltalk.send(smalltalk.send(self, "_internalVariables", []), "_notEmpty", [])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(aStream, "_nextPutVars_", [smalltalk.send(self, "_internalVariables", [])]);})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return smalltalk.send(aStream, "_nextPutVars_", [smalltalk.send(self, "_internalVariables", [])]);})]));return smalltalk.send(self, "_emitOn_", [aStream], smalltalk.IRMethod.superclass || nil);}), smalltalk.send(self, "_arguments", [])]);})]);
  938. return self;},
  939. args: ["aStream"],
  940. source: "emitOn: aStream\x0a\x09aStream\x0a\x09\x09nextPutMethodDeclaration: self \x0a\x09\x09with: [\x0a\x09\x09\x09aStream \x0a\x09\x09\x09\x09nextPutFunctionWith: [ \x0a\x09\x09\x09\x09\x09self internalVariables notEmpty ifTrue: [\x0a\x09\x09\x09\x09\x09\x09aStream nextPutVars: self internalVariables ].\x0a\x09\x09\x09\x09\x09super emitOn: aStream ]\x0a\x09\x09\x09arguments: self arguments ]",
  941. messageSends: ["nextPutMethodDeclaration:with:", "nextPutFunctionWith:arguments:", "ifTrue:", "notEmpty", "internalVariables", "nextPutVars:", "emitOn:", "arguments"],
  942. referencedClasses: []
  943. }),
  944. smalltalk.IRMethod);
  945. smalltalk.addMethod(
  946. "_internalVariables",
  947. smalltalk.method({
  948. selector: "internalVariables",
  949. category: 'accessing',
  950. fn: function () {
  951. var self=this;
  952. return (($receiver = self['@internalVariables']) == nil || $receiver == undefined) ? (function(){return (self['@internalVariables']=smalltalk.send((smalltalk.Set || Set), "_new", []));})() : $receiver;
  953. return self;},
  954. args: [],
  955. source: "internalVariables\x0a\x09^ internalVariables ifNil: [ internalVariables := Set new ]",
  956. messageSends: ["ifNil:", "new"],
  957. referencedClasses: ["Set"]
  958. }),
  959. smalltalk.IRMethod);
  960. smalltalk.addMethod(
  961. "_messageSends",
  962. smalltalk.method({
  963. selector: "messageSends",
  964. category: 'accessing',
  965. fn: function () {
  966. var self=this;
  967. return self['@messageSends'];
  968. return self;},
  969. args: [],
  970. source: "messageSends\x0a\x09^ messageSends",
  971. messageSends: [],
  972. referencedClasses: []
  973. }),
  974. smalltalk.IRMethod);
  975. smalltalk.addMethod(
  976. "_messageSends_",
  977. smalltalk.method({
  978. selector: "messageSends:",
  979. category: 'accessing',
  980. fn: function (aCollection) {
  981. var self=this;
  982. (self['@messageSends']=aCollection);
  983. return self;},
  984. args: ["aCollection"],
  985. source: "messageSends: aCollection\x0a\x09messageSends := aCollection",
  986. messageSends: [],
  987. referencedClasses: []
  988. }),
  989. smalltalk.IRMethod);
  990. smalltalk.addMethod(
  991. "_selector",
  992. smalltalk.method({
  993. selector: "selector",
  994. category: 'accessing',
  995. fn: function () {
  996. var self=this;
  997. return self['@selector'];
  998. return self;},
  999. args: [],
  1000. source: "selector\x0a\x09^ selector",
  1001. messageSends: [],
  1002. referencedClasses: []
  1003. }),
  1004. smalltalk.IRMethod);
  1005. smalltalk.addMethod(
  1006. "_selector_",
  1007. smalltalk.method({
  1008. selector: "selector:",
  1009. category: 'accessing',
  1010. fn: function (aString) {
  1011. var self=this;
  1012. (self['@selector']=aString);
  1013. return self;},
  1014. args: ["aString"],
  1015. source: "selector: aString\x0a\x09selector := aString",
  1016. messageSends: [],
  1017. referencedClasses: []
  1018. }),
  1019. smalltalk.IRMethod);
  1020. smalltalk.addMethod(
  1021. "_source",
  1022. smalltalk.method({
  1023. selector: "source",
  1024. category: 'accessing',
  1025. fn: function () {
  1026. var self=this;
  1027. return self['@source'];
  1028. return self;},
  1029. args: [],
  1030. source: "source\x0a\x09^ source",
  1031. messageSends: [],
  1032. referencedClasses: []
  1033. }),
  1034. smalltalk.IRMethod);
  1035. smalltalk.addMethod(
  1036. "_source_",
  1037. smalltalk.method({
  1038. selector: "source:",
  1039. category: 'accessing',
  1040. fn: function (aString) {
  1041. var self=this;
  1042. (self['@source']=aString);
  1043. return self;},
  1044. args: ["aString"],
  1045. source: "source: aString\x0a\x09source := aString",
  1046. messageSends: [],
  1047. referencedClasses: []
  1048. }),
  1049. smalltalk.IRMethod);
  1050. smalltalk.addClass('IRNonLocalReturn', smalltalk.IRInstruction, [], 'Compiler-IR');
  1051. smalltalk.IRNonLocalReturn.comment="I am a non local return instruction.\x0aNon local returns are handled using a try/catch JS statement.\x0a\x0aSee IRNonLocalReturnHandling class"
  1052. smalltalk.addMethod(
  1053. "_emitOn_",
  1054. smalltalk.method({
  1055. selector: "emitOn:",
  1056. category: 'emiting',
  1057. fn: function (aStream) {
  1058. var self=this;
  1059. smalltalk.send(aStream, "_nextPutNonLocalReturnWith_", [(function(){return smalltalk.send(self, "_emitOn_", [aStream], smalltalk.IRNonLocalReturn.superclass || nil);})]);
  1060. return self;},
  1061. args: ["aStream"],
  1062. source: "emitOn: aStream\x0a\x09aStream nextPutNonLocalReturnWith: [\x0a\x09\x09super emitOn: aStream ]",
  1063. messageSends: ["nextPutNonLocalReturnWith:", "emitOn:"],
  1064. referencedClasses: []
  1065. }),
  1066. smalltalk.IRNonLocalReturn);
  1067. smalltalk.addClass('IRNonLocalReturnHandling', smalltalk.IRInstruction, [], 'Compiler-IR');
  1068. smalltalk.IRNonLocalReturnHandling.comment="I represent a non local return handling instruction.\x0aNon local returns are handled with a try/catch statement"
  1069. smalltalk.addMethod(
  1070. "_emitOn_",
  1071. smalltalk.method({
  1072. selector: "emitOn:",
  1073. category: 'emiting',
  1074. fn: function (aStream) {
  1075. var self=this;
  1076. smalltalk.send(aStream, "_nextPutNonLocalReturnHandlingWith_", [(function(){return smalltalk.send(self, "_emitOn_", [aStream], smalltalk.IRNonLocalReturnHandling.superclass || nil);})]);
  1077. return self;},
  1078. args: ["aStream"],
  1079. source: "emitOn: aStream\x0a\x09aStream nextPutNonLocalReturnHandlingWith: [\x0a\x09\x09super emitOn: aStream ]",
  1080. messageSends: ["nextPutNonLocalReturnHandlingWith:", "emitOn:"],
  1081. referencedClasses: []
  1082. }),
  1083. smalltalk.IRNonLocalReturnHandling);
  1084. smalltalk.addClass('IRReturn', smalltalk.IRInstruction, [], 'Compiler-IR');
  1085. smalltalk.IRReturn.comment="I am a local return instruction."
  1086. smalltalk.addMethod(
  1087. "_emitOn_",
  1088. smalltalk.method({
  1089. selector: "emitOn:",
  1090. category: 'emiting',
  1091. fn: function (aStream) {
  1092. var self=this;
  1093. smalltalk.send(aStream, "_nextPutReturnWith_", [(function(){return smalltalk.send(self, "_emitOn_", [aStream], smalltalk.IRReturn.superclass || nil);})]);
  1094. return self;},
  1095. args: ["aStream"],
  1096. source: "emitOn: aStream\x0a\x09aStream nextPutReturnWith: [\x0a\x09\x09super emitOn: aStream ]",
  1097. messageSends: ["nextPutReturnWith:", "emitOn:"],
  1098. referencedClasses: []
  1099. }),
  1100. smalltalk.IRReturn);
  1101. smalltalk.addClass('IRSend', smalltalk.IRInstruction, ['selector', 'superSend'], 'Compiler-IR');
  1102. smalltalk.IRSend.comment="I am a message send instruction. "
  1103. smalltalk.addMethod(
  1104. "_emitOn_",
  1105. smalltalk.method({
  1106. selector: "emitOn:",
  1107. category: 'accessing',
  1108. fn: function (aStream) {
  1109. var self=this;
  1110. smalltalk.send(aStream, "_nextPutAll_", ["smalltalk.send("]);
  1111. smalltalk.send(smalltalk.send(smalltalk.send(self, "_instructions", []), "_first", []), "_emitOn_", [aStream]);
  1112. smalltalk.send(aStream, "_nextPutAll_", [smalltalk.send(smalltalk.send(",\x22", "__comma", [smalltalk.send(smalltalk.send(self, "_selector", []), "_asSelector", [])]), "__comma", ["\x22, ["])]);
  1113. smalltalk.send(smalltalk.send(smalltalk.send(self, "_instructions", []), "_allButFirst", []), "_do_separatedBy_", [(function(each){return smalltalk.send(each, "_emitOn_", [aStream]);}), (function(){return smalltalk.send(aStream, "_nextPutAll_", [","]);})]);
  1114. smalltalk.send(aStream, "_nextPutAll_", ["])"]);
  1115. return self;},
  1116. args: ["aStream"],
  1117. source: "emitOn: aStream\x0a\x0a\x09aStream nextPutAll: 'smalltalk.send('.\x0a\x09self instructions first emitOn: aStream.\x0a\x09aStream nextPutAll: ',\x22', self selector asSelector, '\x22, ['.\x0a\x09self instructions allButFirst\x0a\x09\x09do: [ :each | each emitOn: aStream ]\x0a\x09\x09separatedBy: [ aStream nextPutAll: ',' ].\x0a\x09aStream nextPutAll: '])'",
  1118. messageSends: ["nextPutAll:", "emitOn:", "first", "instructions", ",", "asSelector", "selector", "do:separatedBy:", "allButFirst"],
  1119. referencedClasses: []
  1120. }),
  1121. smalltalk.IRSend);
  1122. smalltalk.addMethod(
  1123. "_selector",
  1124. smalltalk.method({
  1125. selector: "selector",
  1126. category: 'accessing',
  1127. fn: function () {
  1128. var self=this;
  1129. return self['@selector'];
  1130. return self;},
  1131. args: [],
  1132. source: "selector\x0a\x09^ selector",
  1133. messageSends: [],
  1134. referencedClasses: []
  1135. }),
  1136. smalltalk.IRSend);
  1137. smalltalk.addMethod(
  1138. "_selector_",
  1139. smalltalk.method({
  1140. selector: "selector:",
  1141. category: 'accessing',
  1142. fn: function (aString) {
  1143. var self=this;
  1144. (self['@selector']=aString);
  1145. return self;},
  1146. args: ["aString"],
  1147. source: "selector: aString\x0a\x09selector := aString",
  1148. messageSends: [],
  1149. referencedClasses: []
  1150. }),
  1151. smalltalk.IRSend);
  1152. smalltalk.addMethod(
  1153. "_superSend",
  1154. smalltalk.method({
  1155. selector: "superSend",
  1156. category: 'accessing',
  1157. fn: function () {
  1158. var self=this;
  1159. return (($receiver = self['@superSend']) == nil || $receiver == undefined) ? (function(){return false;})() : $receiver;
  1160. return self;},
  1161. args: [],
  1162. source: "superSend\x0a\x09^ superSend ifNil: [ false ]",
  1163. messageSends: ["ifNil:"],
  1164. referencedClasses: []
  1165. }),
  1166. smalltalk.IRSend);
  1167. smalltalk.addMethod(
  1168. "_superSend_",
  1169. smalltalk.method({
  1170. selector: "superSend:",
  1171. category: 'accessing',
  1172. fn: function (aBoolean) {
  1173. var self=this;
  1174. (self['@superSend']=aBoolean);
  1175. return self;},
  1176. args: ["aBoolean"],
  1177. source: "superSend: aBoolean\x0a\x09superSend := aBoolean",
  1178. messageSends: [],
  1179. referencedClasses: []
  1180. }),
  1181. smalltalk.IRSend);
  1182. smalltalk.addClass('IRSequence', smalltalk.IRInstruction, [], 'Compiler-IR');
  1183. smalltalk.addMethod(
  1184. "_appendInstruction_",
  1185. smalltalk.method({
  1186. selector: "appendInstruction:",
  1187. category: 'emiting',
  1188. fn: function (anIRInstruction) {
  1189. var self=this;
  1190. smalltalk.send(smalltalk.send(self, "_instructions", []), "_add_", [smalltalk.send(smalltalk.send((smalltalk.IRStatement || IRStatement), "_on_", [smalltalk.send(self, "_builder", [])]), "_with_", [anIRInstruction])]);
  1191. return self;},
  1192. args: ["anIRInstruction"],
  1193. source: "appendInstruction: anIRInstruction\x0a\x09self instructions add: ((IRStatement on: self builder) with: anIRInstruction)",
  1194. messageSends: ["add:", "instructions", "with:", "on:", "builder"],
  1195. referencedClasses: ["IRStatement"]
  1196. }),
  1197. smalltalk.IRSequence);
  1198. smalltalk.addMethod(
  1199. "_emitOn_",
  1200. smalltalk.method({
  1201. selector: "emitOn:",
  1202. category: 'emiting',
  1203. fn: function (aStream) {
  1204. var self=this;
  1205. smalltalk.send(aStream, "_nextPutSequenceWith_", [(function(){return smalltalk.send(self, "_emitOn_", [aStream], smalltalk.IRSequence.superclass || nil);})]);
  1206. return self;},
  1207. args: ["aStream"],
  1208. source: "emitOn: aStream\x0a\x09aStream nextPutSequenceWith: [\x0a\x09\x09\x22self instructions do: [ :each |\x0a\x09\x09\x09((IRStatement on: self builder)\x0a\x09\x09\x09\x09pc: self builder nextPc;\x0a\x09\x09\x09\x09with: each;\x0a\x09\x09\x09\x09yourself) emitOn: aStream ]\x22\x0a\x09\x09super emitOn: aStream ]",
  1209. messageSends: ["nextPutSequenceWith:", "emitOn:"],
  1210. referencedClasses: []
  1211. }),
  1212. smalltalk.IRSequence);
  1213. smalltalk.addClass('IRStatement', smalltalk.IRInstruction, ['pc'], 'Compiler-IR');
  1214. smalltalk.IRStatement.comment="I am a statement instruction. \x0aStatements can be used to control the PC count, among other things."
  1215. smalltalk.addMethod(
  1216. "_emitOn_",
  1217. smalltalk.method({
  1218. selector: "emitOn:",
  1219. category: 'emiting',
  1220. fn: function (aStream) {
  1221. var self=this;
  1222. smalltalk.send(aStream, "_nextPutStatement_with_", [smalltalk.send(self, "_pc", []), (function(){return smalltalk.send(self, "_emitOn_", [aStream], smalltalk.IRStatement.superclass || nil);})]);
  1223. return self;},
  1224. args: ["aStream"],
  1225. source: "emitOn: aStream\x0a\x09aStream nextPutStatement: self pc with: [\x0a\x09\x09super emitOn: aStream ]",
  1226. messageSends: ["nextPutStatement:with:", "pc", "emitOn:"],
  1227. referencedClasses: []
  1228. }),
  1229. smalltalk.IRStatement);
  1230. smalltalk.addMethod(
  1231. "_pc",
  1232. smalltalk.method({
  1233. selector: "pc",
  1234. category: 'accessing',
  1235. fn: function () {
  1236. var self=this;
  1237. return (($receiver = self['@pc']) == nil || $receiver == undefined) ? (function(){return (self['@pc']=smalltalk.send(smalltalk.send(self, "_builder", []), "_nextPc", []));})() : $receiver;
  1238. return self;},
  1239. args: [],
  1240. source: "pc\x0a\x09^ pc ifNil: [pc := self builder nextPc]",
  1241. messageSends: ["ifNil:", "nextPc", "builder"],
  1242. referencedClasses: []
  1243. }),
  1244. smalltalk.IRStatement);
  1245. smalltalk.addClass('IRTempDeclaration', smalltalk.IRInstruction, ['name'], 'Compiler-IR');
  1246. smalltalk.IRTempDeclaration.comment="I am a temporary variable declaration instruction"
  1247. smalltalk.addMethod(
  1248. "_emitOn_",
  1249. smalltalk.method({
  1250. selector: "emitOn:",
  1251. category: 'emiting',
  1252. fn: function (aStream) {
  1253. var self=this;
  1254. smalltalk.send(aStream, "_nextPutVar_", [smalltalk.send(smalltalk.send(self, "_name", []), "_asVariableName", [])]);
  1255. return self;},
  1256. args: ["aStream"],
  1257. source: "emitOn: aStream\x0a\x09aStream nextPutVar: self name asVariableName",
  1258. messageSends: ["nextPutVar:", "asVariableName", "name"],
  1259. referencedClasses: []
  1260. }),
  1261. smalltalk.IRTempDeclaration);
  1262. smalltalk.addMethod(
  1263. "_name",
  1264. smalltalk.method({
  1265. selector: "name",
  1266. category: 'accessing',
  1267. fn: function () {
  1268. var self=this;
  1269. return self['@name'];
  1270. return self;},
  1271. args: [],
  1272. source: "name\x0a\x09^ name",
  1273. messageSends: [],
  1274. referencedClasses: []
  1275. }),
  1276. smalltalk.IRTempDeclaration);
  1277. smalltalk.addMethod(
  1278. "_name_",
  1279. smalltalk.method({
  1280. selector: "name:",
  1281. category: 'accessing',
  1282. fn: function (aString) {
  1283. var self=this;
  1284. (self['@name']=aString);
  1285. return self;},
  1286. args: ["aString"],
  1287. source: "name: aString\x0a\x09name := aString",
  1288. messageSends: [],
  1289. referencedClasses: []
  1290. }),
  1291. smalltalk.IRTempDeclaration);
  1292. smalltalk.addClass('IRValue', smalltalk.IRInstruction, ['value'], 'Compiler-IR');
  1293. smalltalk.IRValue.comment="I am the simplest possible instruction. I represent a value."
  1294. smalltalk.addMethod(
  1295. "_emitOn_",
  1296. smalltalk.method({
  1297. selector: "emitOn:",
  1298. category: 'emiting',
  1299. fn: function (aStream) {
  1300. var self=this;
  1301. smalltalk.send(aStream, "_nextPutAll_", [smalltalk.send(smalltalk.send(self, "_value", []), "_asJavascript", [])]);
  1302. return self;},
  1303. args: ["aStream"],
  1304. source: "emitOn: aStream\x0a\x09aStream nextPutAll: self value asJavascript",
  1305. messageSends: ["nextPutAll:", "asJavascript", "value"],
  1306. referencedClasses: []
  1307. }),
  1308. smalltalk.IRValue);
  1309. smalltalk.addMethod(
  1310. "_value",
  1311. smalltalk.method({
  1312. selector: "value",
  1313. category: 'accessing',
  1314. fn: function () {
  1315. var self=this;
  1316. return self['@value'];
  1317. return self;},
  1318. args: [],
  1319. source: "value\x0a\x09^value",
  1320. messageSends: [],
  1321. referencedClasses: []
  1322. }),
  1323. smalltalk.IRValue);
  1324. smalltalk.addMethod(
  1325. "_value_",
  1326. smalltalk.method({
  1327. selector: "value:",
  1328. category: 'accessing',
  1329. fn: function (aString) {
  1330. var self=this;
  1331. (self['@value']=aString);
  1332. return self;},
  1333. args: ["aString"],
  1334. source: "value: aString\x0a\x09value := aString",
  1335. messageSends: [],
  1336. referencedClasses: []
  1337. }),
  1338. smalltalk.IRValue);
  1339. smalltalk.addClass('IRVariable', smalltalk.IRInstruction, ['variable'], 'Compiler-IR');
  1340. smalltalk.IRVariable.comment="I am a variable instruction."
  1341. smalltalk.addMethod(
  1342. "_emitOn_",
  1343. smalltalk.method({
  1344. selector: "emitOn:",
  1345. category: 'emiting',
  1346. fn: function (aStream) {
  1347. var self=this;
  1348. smalltalk.send(aStream, "_nextPutAll_", [smalltalk.send(smalltalk.send(self, "_variable", []), "_alias", [])]);
  1349. return self;},
  1350. args: ["aStream"],
  1351. source: "emitOn: aStream\x0a\x09aStream nextPutAll: self variable alias",
  1352. messageSends: ["nextPutAll:", "alias", "variable"],
  1353. referencedClasses: []
  1354. }),
  1355. smalltalk.IRVariable);
  1356. smalltalk.addMethod(
  1357. "_variable",
  1358. smalltalk.method({
  1359. selector: "variable",
  1360. category: 'accessing',
  1361. fn: function () {
  1362. var self=this;
  1363. return self['@variable'];
  1364. return self;},
  1365. args: [],
  1366. source: "variable\x0a\x09^ variable",
  1367. messageSends: [],
  1368. referencedClasses: []
  1369. }),
  1370. smalltalk.IRVariable);
  1371. smalltalk.addMethod(
  1372. "_variable_",
  1373. smalltalk.method({
  1374. selector: "variable:",
  1375. category: 'accessing',
  1376. fn: function (aScopeVariable) {
  1377. var self=this;
  1378. (self['@variable']=aScopeVariable);
  1379. return self;},
  1380. args: ["aScopeVariable"],
  1381. source: "variable: aScopeVariable\x0a\x09variable := aScopeVariable",
  1382. messageSends: [],
  1383. referencedClasses: []
  1384. }),
  1385. smalltalk.IRVariable);
  1386. smalltalk.addClass('IRVerbatim', smalltalk.IRInstruction, ['source'], 'Compiler-IR');
  1387. smalltalk.addMethod(
  1388. "_emitOn_",
  1389. smalltalk.method({
  1390. selector: "emitOn:",
  1391. category: 'emiting',
  1392. fn: function (aStream) {
  1393. var self=this;
  1394. smalltalk.send(aStream, "_nextPutAll_", [smalltalk.send(smalltalk.send(self, "_source", []), "__comma", [";"])]);
  1395. return self;},
  1396. args: ["aStream"],
  1397. source: "emitOn: aStream\x0a\x09aStream nextPutAll: self source, ';'",
  1398. messageSends: ["nextPutAll:", ",", "source"],
  1399. referencedClasses: []
  1400. }),
  1401. smalltalk.IRVerbatim);
  1402. smalltalk.addMethod(
  1403. "_source",
  1404. smalltalk.method({
  1405. selector: "source",
  1406. category: 'accessing',
  1407. fn: function () {
  1408. var self=this;
  1409. return self['@source'];
  1410. return self;},
  1411. args: [],
  1412. source: "source\x0a\x09^ source",
  1413. messageSends: [],
  1414. referencedClasses: []
  1415. }),
  1416. smalltalk.IRVerbatim);
  1417. smalltalk.addMethod(
  1418. "_source_",
  1419. smalltalk.method({
  1420. selector: "source:",
  1421. category: 'accessing',
  1422. fn: function (aString) {
  1423. var self=this;
  1424. (self['@source']=aString);
  1425. return self;},
  1426. args: ["aString"],
  1427. source: "source: aString\x0a\x09source := aString",
  1428. messageSends: [],
  1429. referencedClasses: []
  1430. }),
  1431. smalltalk.IRVerbatim);
  1432. smalltalk.addClass('JSStream', smalltalk.Object, ['stream'], 'Compiler-IR');
  1433. smalltalk.addMethod(
  1434. "_contents",
  1435. smalltalk.method({
  1436. selector: "contents",
  1437. category: 'accessing',
  1438. fn: function () {
  1439. var self=this;
  1440. return smalltalk.send(self['@stream'], "_contents", []);
  1441. return self;},
  1442. args: [],
  1443. source: "contents\x0a\x09^ stream contents",
  1444. messageSends: ["contents"],
  1445. referencedClasses: []
  1446. }),
  1447. smalltalk.JSStream);
  1448. smalltalk.addMethod(
  1449. "_initialize",
  1450. smalltalk.method({
  1451. selector: "initialize",
  1452. category: 'initialization',
  1453. fn: function () {
  1454. var self=this;
  1455. smalltalk.send(self, "_initialize", [], smalltalk.JSStream.superclass || nil);
  1456. (self['@stream']=smalltalk.send("", "_writeStream", []));
  1457. return self;},
  1458. args: [],
  1459. source: "initialize\x0a\x09super initialize.\x0a\x09stream := '' writeStream.",
  1460. messageSends: ["initialize", "writeStream"],
  1461. referencedClasses: []
  1462. }),
  1463. smalltalk.JSStream);
  1464. smalltalk.addMethod(
  1465. "_lf",
  1466. smalltalk.method({
  1467. selector: "lf",
  1468. category: 'streaming',
  1469. fn: function () {
  1470. var self=this;
  1471. smalltalk.send(self['@stream'], "_lf", []);
  1472. return self;},
  1473. args: [],
  1474. source: "lf\x0a\x09stream lf",
  1475. messageSends: ["lf"],
  1476. referencedClasses: []
  1477. }),
  1478. smalltalk.JSStream);
  1479. smalltalk.addMethod(
  1480. "_nextPut_",
  1481. smalltalk.method({
  1482. selector: "nextPut:",
  1483. category: 'streaming',
  1484. fn: function (aString) {
  1485. var self=this;
  1486. smalltalk.send(self['@stream'], "_nextPut_", [aString]);
  1487. return self;},
  1488. args: ["aString"],
  1489. source: "nextPut: aString\x0a\x09stream nextPut: aString",
  1490. messageSends: ["nextPut:"],
  1491. referencedClasses: []
  1492. }),
  1493. smalltalk.JSStream);
  1494. smalltalk.addMethod(
  1495. "_nextPutAll_",
  1496. smalltalk.method({
  1497. selector: "nextPutAll:",
  1498. category: 'streaming',
  1499. fn: function (aString) {
  1500. var self=this;
  1501. smalltalk.send(self['@stream'], "_nextPutAll_", [aString]);
  1502. return self;},
  1503. args: ["aString"],
  1504. source: "nextPutAll: aString\x0a\x09stream nextPutAll: aString",
  1505. messageSends: ["nextPutAll:"],
  1506. referencedClasses: []
  1507. }),
  1508. smalltalk.JSStream);
  1509. smalltalk.addMethod(
  1510. "_nextPutAssignment_to_",
  1511. smalltalk.method({
  1512. selector: "nextPutAssignment:to:",
  1513. category: 'streaming',
  1514. fn: function (varInstruction, valueInstruction) {
  1515. var self=this;
  1516. smalltalk.send(varInstruction, "_emitOn_", [self]);
  1517. smalltalk.send(self['@stream'], "_nextPutAll_", ["="]);
  1518. smalltalk.send(valueInstruction, "_emitOn_", [self]);
  1519. return self;},
  1520. args: ["varInstruction", "valueInstruction"],
  1521. source: "nextPutAssignment: varInstruction to: valueInstruction\x0a\x09varInstruction emitOn: self.\x0a\x09stream nextPutAll: '='.\x0a\x09valueInstruction emitOn: self",
  1522. messageSends: ["emitOn:", "nextPutAll:"],
  1523. referencedClasses: []
  1524. }),
  1525. smalltalk.JSStream);
  1526. smalltalk.addMethod(
  1527. "_nextPutClosureWith_arguments_",
  1528. smalltalk.method({
  1529. selector: "nextPutClosureWith:arguments:",
  1530. category: 'streaming',
  1531. fn: function (aBlock, anArray) {
  1532. var self=this;
  1533. smalltalk.send(self['@stream'], "_nextPutAll_", ["(function("]);
  1534. smalltalk.send(anArray, "_do_separatedBy_", [(function(each){return smalltalk.send(self['@stream'], "_nextPutAll_", [smalltalk.send(each, "_asVariableName", [])]);}), (function(){return smalltalk.send(self['@stream'], "_nextPut_", [","]);})]);
  1535. (function($rec){smalltalk.send($rec, "_nextPutAll_", ["){"]);return smalltalk.send($rec, "_lf", []);})(self['@stream']);
  1536. smalltalk.send(aBlock, "_value", []);
  1537. smalltalk.send(self['@stream'], "_nextPutAll_", ["})"]);
  1538. return self;},
  1539. args: ["aBlock", "anArray"],
  1540. source: "nextPutClosureWith: aBlock arguments: anArray\x0a\x09stream nextPutAll: '(function('.\x0a\x09anArray \x0a\x09\x09do: [ :each | stream nextPutAll: each asVariableName ]\x0a\x09\x09separatedBy: [ stream nextPut: ',' ].\x0a\x09stream nextPutAll: '){'; lf.\x0a\x09aBlock value.\x0a\x09stream nextPutAll: '})'",
  1541. messageSends: ["nextPutAll:", "do:separatedBy:", "asVariableName", "nextPut:", "lf", "value"],
  1542. referencedClasses: []
  1543. }),
  1544. smalltalk.JSStream);
  1545. smalltalk.addMethod(
  1546. "_nextPutFunctionWith_arguments_",
  1547. smalltalk.method({
  1548. selector: "nextPutFunctionWith:arguments:",
  1549. category: 'streaming',
  1550. fn: function (aBlock, anArray) {
  1551. var self=this;
  1552. smalltalk.send(self['@stream'], "_nextPutAll_", ["fn: function("]);
  1553. smalltalk.send(anArray, "_do_separatedBy_", [(function(each){return smalltalk.send(self['@stream'], "_nextPutAll_", [smalltalk.send(each, "_asVariableName", [])]);}), (function(){return smalltalk.send(self['@stream'], "_nextPut_", [","]);})]);
  1554. (function($rec){smalltalk.send($rec, "_nextPutAll_", ["){"]);return smalltalk.send($rec, "_lf", []);})(self['@stream']);
  1555. smalltalk.send(self, "_nextPutVar_", ["$return"]);
  1556. (function($rec){smalltalk.send($rec, "_nextPutAll_", ["var self=this;"]);return smalltalk.send($rec, "_lf", []);})(self['@stream']);
  1557. smalltalk.send(aBlock, "_value", []);
  1558. smalltalk.send(self['@stream'], "_nextPutAll_", ["return $return || self;}"]);
  1559. return self;},
  1560. args: ["aBlock", "anArray"],
  1561. source: "nextPutFunctionWith: aBlock arguments: anArray\x0a\x09stream nextPutAll: 'fn: function('.\x0a\x09anArray \x0a\x09\x09do: [ :each | stream nextPutAll: each asVariableName ]\x0a\x09\x09separatedBy: [ stream nextPut: ',' ].\x0a\x09stream nextPutAll: '){'; lf.\x0a\x09self nextPutVar: '$return'.\x0a\x09stream nextPutAll: 'var self=this;'; lf.\x0a\x09aBlock value.\x0a\x09stream nextPutAll: 'return $return || self;}'",
  1562. messageSends: ["nextPutAll:", "do:separatedBy:", "asVariableName", "nextPut:", "lf", "nextPutVar:", "value"],
  1563. referencedClasses: []
  1564. }),
  1565. smalltalk.JSStream);
  1566. smalltalk.addMethod(
  1567. "_nextPutMethodDeclaration_with_",
  1568. smalltalk.method({
  1569. selector: "nextPutMethodDeclaration:with:",
  1570. category: 'streaming',
  1571. fn: function (aMethod, aBlock) {
  1572. var self=this;
  1573. (function($rec){smalltalk.send($rec, "_nextPutAll_", ["smalltalk.method({"]);smalltalk.send($rec, "_lf", []);smalltalk.send($rec, "_nextPutAll_", [smalltalk.send(smalltalk.send("selector: \x22", "__comma", [smalltalk.send(aMethod, "_selector", [])]), "__comma", ["\x22,"])]);smalltalk.send($rec, "_lf", []);smalltalk.send($rec, "_nextPutAll_", [smalltalk.send(smalltalk.send("source: ", "__comma", [smalltalk.send(smalltalk.send(aMethod, "_source", []), "_asJavascript", [])]), "__comma", [","])]);return smalltalk.send($rec, "_lf", []);})(self['@stream']);
  1574. smalltalk.send(aBlock, "_value", []);
  1575. (function($rec){smalltalk.send($rec, "_nextPutAll_", [smalltalk.send(smalltalk.send(",", "__comma", [smalltalk.send((smalltalk.String || String), "_lf", [])]), "__comma", ["messageSends: "])]);smalltalk.send($rec, "_nextPutAll_", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(aMethod, "_messageSends", []), "_asArray", []), "_asJavascript", []), "__comma", [","])]);smalltalk.send($rec, "_lf", []);smalltalk.send($rec, "_nextPutAll_", [smalltalk.send(smalltalk.send("args: ", "__comma", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(aMethod, "_arguments", []), "_collect_", [(function(each){return smalltalk.send(each, "_value", []);})]), "_asArray", []), "_asJavascript", [])]), "__comma", [","])]);smalltalk.send($rec, "_lf", []);return smalltalk.send($rec, "_nextPutAll_", ["referencedClasses: ["]);})(self['@stream']);
  1576. smalltalk.send(smalltalk.send(aMethod, "_classReferences", []), "_do_separatedBy_", [(function(each){return smalltalk.send(self['@stream'], "_nextPutAll_", [smalltalk.send(each, "_asJavascript", [])]);}), (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [","]);})]);
  1577. (function($rec){smalltalk.send($rec, "_nextPutAll_", ["]"]);return smalltalk.send($rec, "_nextPutAll_", ["})"]);})(self['@stream']);
  1578. return self;},
  1579. args: ["aMethod", "aBlock"],
  1580. source: "nextPutMethodDeclaration: aMethod with: aBlock\x0a\x09stream \x0a\x09\x09nextPutAll: 'smalltalk.method({'; lf;\x0a\x09\x09nextPutAll: 'selector: \x22', aMethod selector, '\x22,'; lf;\x0a\x09\x09nextPutAll: 'source: ', aMethod source asJavascript, ',';lf.\x0a\x09aBlock value.\x0a\x09stream \x0a\x09\x09nextPutAll: ',', String lf, 'messageSends: ';\x0a\x09\x09nextPutAll: aMethod messageSends asArray asJavascript, ','; lf;\x0a \x09nextPutAll: 'args: ', (aMethod arguments collect: [ :each | each value ]) asArray asJavascript, ','; lf;\x0a\x09\x09nextPutAll: 'referencedClasses: ['.\x0a\x09aMethod classReferences \x0a\x09\x09do: [:each | stream nextPutAll: each asJavascript]\x0a\x09\x09separatedBy: [stream nextPutAll: ','].\x0a\x09stream \x0a\x09\x09nextPutAll: ']';\x0a\x09\x09nextPutAll: '})'",
  1581. messageSends: ["nextPutAll:", "lf", ",", "selector", "asJavascript", "source", "value", "asArray", "messageSends", "collect:", "arguments", "do:separatedBy:", "classReferences"],
  1582. referencedClasses: ["String"]
  1583. }),
  1584. smalltalk.JSStream);
  1585. smalltalk.addMethod(
  1586. "_nextPutNonLocalReturnHandlingWith_",
  1587. smalltalk.method({
  1588. selector: "nextPutNonLocalReturnHandlingWith:",
  1589. category: 'streaming',
  1590. fn: function (aBlock) {
  1591. var self=this;
  1592. (function($rec){smalltalk.send($rec, "_nextPutAll_", ["var $early={};"]);smalltalk.send($rec, "_lf", []);smalltalk.send($rec, "_nextPutAll_", ["try {"]);return smalltalk.send($rec, "_lf", []);})(self['@stream']);
  1593. smalltalk.send(aBlock, "_value", []);
  1594. (function($rec){smalltalk.send($rec, "_nextPutAll_", ["}"]);smalltalk.send($rec, "_lf", []);smalltalk.send($rec, "_nextPutAll_", ["catch(e) {if(e===$early)return e[0]; throw e}"]);return smalltalk.send($rec, "_lf", []);})(self['@stream']);
  1595. return self;},
  1596. args: ["aBlock"],
  1597. source: "nextPutNonLocalReturnHandlingWith: aBlock\x0a\x09stream \x0a\x09\x09nextPutAll: 'var $early={};'; lf;\x0a\x09\x09nextPutAll: 'try {'; lf.\x0a\x09aBlock value.\x0a\x09stream \x0a\x09\x09nextPutAll: '}'; lf;\x0a\x09\x09nextPutAll: 'catch(e) {if(e===$early)return e[0]; throw e}'; lf",
  1598. messageSends: ["nextPutAll:", "lf", "value"],
  1599. referencedClasses: []
  1600. }),
  1601. smalltalk.JSStream);
  1602. smalltalk.addMethod(
  1603. "_nextPutNonLocalReturnWith_",
  1604. smalltalk.method({
  1605. selector: "nextPutNonLocalReturnWith:",
  1606. category: 'streaming',
  1607. fn: function (aBlock) {
  1608. var self=this;
  1609. smalltalk.send(self['@stream'], "_nextPutAll_", ["(function(){throw $early=["]);
  1610. smalltalk.send(aBlock, "_value", []);
  1611. smalltalk.send(self['@stream'], "_nextPutAll_", ["]})()"]);
  1612. return self;},
  1613. args: ["aBlock"],
  1614. source: "nextPutNonLocalReturnWith: aBlock\x0a\x09stream nextPutAll: '(function(){throw $early=['.\x0a\x09aBlock value.\x0a\x09stream nextPutAll: ']})()'",
  1615. messageSends: ["nextPutAll:", "value"],
  1616. referencedClasses: []
  1617. }),
  1618. smalltalk.JSStream);
  1619. smalltalk.addMethod(
  1620. "_nextPutReturnWith_",
  1621. smalltalk.method({
  1622. selector: "nextPutReturnWith:",
  1623. category: 'streaming',
  1624. fn: function (aBlock) {
  1625. var self=this;
  1626. smalltalk.send(self['@stream'], "_nextPutAll_", ["$return="]);
  1627. smalltalk.send(aBlock, "_value", []);
  1628. return self;},
  1629. args: ["aBlock"],
  1630. source: "nextPutReturnWith: aBlock\x0a\x09stream nextPutAll: '$return='.\x0a\x09aBlock value",
  1631. messageSends: ["nextPutAll:", "value"],
  1632. referencedClasses: []
  1633. }),
  1634. smalltalk.JSStream);
  1635. smalltalk.addMethod(
  1636. "_nextPutSendTo_selector_arguments_",
  1637. smalltalk.method({
  1638. selector: "nextPutSendTo:selector:arguments:",
  1639. category: 'streaming',
  1640. fn: function (receiver, selector, arguments) {
  1641. var self=this;
  1642. smalltalk.send(self['@stream'], "_nextPutAll_", ["smalltalk.send("]);
  1643. smalltalk.send(receiver, "_emitOn_", [self]);
  1644. smalltalk.send(self['@stream'], "_nextPutAll_", [smalltalk.send(smalltalk.send(",\x22", "__comma", [smalltalk.send(selector, "_asSelector", [])]), "__comma", ["\x22,["])]);
  1645. smalltalk.send(arguments, "_do_separatedBy_", [(function(each){return smalltalk.send(each, "_emitOn_", [self]);}), (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [","]);})]);
  1646. smalltalk.send(self['@stream'], "_nextPutAll_", ["])"]);
  1647. return self;},
  1648. args: ["receiver", "selector", "arguments"],
  1649. source: "nextPutSendTo: receiver selector: selector arguments: arguments\x0a\x09stream nextPutAll: 'smalltalk.send('.\x0a\x09receiver emitOn: self. \x0a\x09stream nextPutAll: ',\x22', selector asSelector, '\x22,['.\x0a\x09arguments \x0a\x09\x09do: [ :each | each emitOn: self ]\x0a\x09\x09separatedBy: [ stream nextPutAll: ',' ].\x0a\x09stream nextPutAll: '])'",
  1650. messageSends: ["nextPutAll:", "emitOn:", ",", "asSelector", "do:separatedBy:"],
  1651. referencedClasses: []
  1652. }),
  1653. smalltalk.JSStream);
  1654. smalltalk.addMethod(
  1655. "_nextPutSequenceWith_",
  1656. smalltalk.method({
  1657. selector: "nextPutSequenceWith:",
  1658. category: 'streaming',
  1659. fn: function (aBlock) {
  1660. var self=this;
  1661. smalltalk.send(aBlock, "_value", []);
  1662. return self;},
  1663. args: ["aBlock"],
  1664. source: "nextPutSequenceWith: aBlock\x0a\x09\x22stream \x0a\x09\x09nextPutAll: 'switch(smalltalk.thisContext.pc){'; lf.\x22\x0a\x09aBlock value.\x0a\x09\x22stream \x0a\x09\x09nextPutAll: '};'; lf\x22",
  1665. messageSends: ["value"],
  1666. referencedClasses: []
  1667. }),
  1668. smalltalk.JSStream);
  1669. smalltalk.addMethod(
  1670. "_nextPutStatement_with_",
  1671. smalltalk.method({
  1672. selector: "nextPutStatement:with:",
  1673. category: 'streaming',
  1674. fn: function (anInteger, aBlock) {
  1675. var self=this;
  1676. smalltalk.send(aBlock, "_value", []);
  1677. (function($rec){smalltalk.send($rec, "_nextPutAll_", [";"]);return smalltalk.send($rec, "_lf", []);})(self['@stream']);
  1678. return self;},
  1679. args: ["anInteger", "aBlock"],
  1680. source: "nextPutStatement: anInteger with: aBlock\x0a\x09\x22stream \x0a\x09\x09nextPutAll: 'case ', anInteger asString, ':'; lf.\x22\x0a\x09aBlock value.\x0a\x09stream \x0a\x09\x09nextPutAll: ';'; lf\x22;\x0a\x09\x09nextPutAll: 'smalltalk.thisContext.pc=', (anInteger + 1) asString, ';'; lf\x22",
  1681. messageSends: ["value", "nextPutAll:", "lf"],
  1682. referencedClasses: []
  1683. }),
  1684. smalltalk.JSStream);
  1685. smalltalk.addMethod(
  1686. "_nextPutVar_",
  1687. smalltalk.method({
  1688. selector: "nextPutVar:",
  1689. category: 'streaming',
  1690. fn: function (aString) {
  1691. var self=this;
  1692. (function($rec){smalltalk.send($rec, "_nextPutAll_", [smalltalk.send(smalltalk.send("var ", "__comma", [aString]), "__comma", [";"])]);return smalltalk.send($rec, "_lf", []);})(self['@stream']);
  1693. return self;},
  1694. args: ["aString"],
  1695. source: "nextPutVar: aString\x0a\x09stream nextPutAll: 'var ', aString, ';'; lf",
  1696. messageSends: ["nextPutAll:", ",", "lf"],
  1697. referencedClasses: []
  1698. }),
  1699. smalltalk.JSStream);
  1700. smalltalk.addMethod(
  1701. "_nextPutVars_",
  1702. smalltalk.method({
  1703. selector: "nextPutVars:",
  1704. category: 'streaming',
  1705. fn: function (aCollection) {
  1706. var self=this;
  1707. smalltalk.send(self['@stream'], "_nextPutAll_", ["var "]);
  1708. smalltalk.send(aCollection, "_do_separatedBy_", [(function(each){return smalltalk.send(self['@stream'], "_nextPutAll_", [each]);}), (function(){return smalltalk.send(self['@stream'], "_nextPutAll_", [","]);})]);
  1709. (function($rec){smalltalk.send($rec, "_nextPutAll_", [";"]);return smalltalk.send($rec, "_lf", []);})(self['@stream']);
  1710. return self;},
  1711. args: ["aCollection"],
  1712. source: "nextPutVars: aCollection\x0a\x09stream nextPutAll: 'var '.\x0a\x09aCollection \x0a\x09\x09do: [ :each | stream nextPutAll: each ]\x0a\x09\x09separatedBy: [ stream nextPutAll: ',' ].\x0a\x09stream nextPutAll: ';'; lf",
  1713. messageSends: ["nextPutAll:", "do:separatedBy:", "lf"],
  1714. referencedClasses: []
  1715. }),
  1716. smalltalk.JSStream);
  1717. smalltalk.addMethod(
  1718. "_appendToInstruction_",
  1719. smalltalk.method({
  1720. selector: "appendToInstruction:",
  1721. category: '*Compiler-IR',
  1722. fn: function (anIRInstruction) {
  1723. var self=this;
  1724. smalltalk.send(anIRInstruction, "_appendBlock_", [self]);
  1725. return self;},
  1726. args: ["anIRInstruction"],
  1727. source: "appendToInstruction: anIRInstruction\x0a anIRInstruction appendBlock: self",
  1728. messageSends: ["appendBlock:"],
  1729. referencedClasses: []
  1730. }),
  1731. smalltalk.BlockClosure);
  1732. smalltalk.addMethod(
  1733. "_appendToInstruction_",
  1734. smalltalk.method({
  1735. selector: "appendToInstruction:",
  1736. category: '*Compiler-IR',
  1737. fn: function (anInstruction) {
  1738. var self=this;
  1739. smalltalk.send(anInstruction, "_appendString_", [self]);
  1740. return self;},
  1741. args: ["anInstruction"],
  1742. source: "appendToInstruction: anInstruction\x0a\x09anInstruction appendString: self",
  1743. messageSends: ["appendString:"],
  1744. referencedClasses: []
  1745. }),
  1746. smalltalk.String);
  1747. smalltalk.addMethod(
  1748. "_asVariableName",
  1749. smalltalk.method({
  1750. selector: "asVariableName",
  1751. category: '*Compiler-IR',
  1752. fn: function () {
  1753. var self=this;
  1754. return ((($receiver = smalltalk.send(smalltalk.send(smalltalk.send((smalltalk.Smalltalk || Smalltalk), "_current", []), "_reservedWords", []), "_includes_", [self])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(self, "__comma", ["_"]);})() : (function(){return self;})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return smalltalk.send(self, "__comma", ["_"]);}), (function(){return self;})]));
  1755. return self;},
  1756. args: [],
  1757. source: "asVariableName\x0a\x09^ (Smalltalk current reservedWords includes: self)\x0a\x09\x09ifTrue: [ self, '_' ]\x0a\x09\x09ifFalse: [ self ]",
  1758. messageSends: ["ifTrue:ifFalse:", "includes:", "reservedWords", "current", ","],
  1759. referencedClasses: ["Smalltalk"]
  1760. }),
  1761. smalltalk.String);
  1762. smalltalk.addMethod(
  1763. "_emitOn_",
  1764. smalltalk.method({
  1765. selector: "emitOn:",
  1766. category: '*Compiler-IR',
  1767. fn: function (aStream) {
  1768. var self=this;
  1769. smalltalk.send(aStream, "_nextPutAll_", [self]);
  1770. return self;},
  1771. args: ["aStream"],
  1772. source: "emitOn: aStream\x0a\x09aStream nextPutAll: self",
  1773. messageSends: ["nextPutAll:"],
  1774. referencedClasses: []
  1775. }),
  1776. smalltalk.String);