Compiler-AST.js 60 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414
  1. define("amber_core/Compiler-AST", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_vm/globals", "amber_core/Kernel-Objects", "amber_core/Kernel-Methods"], function(smalltalk,nil,_st, globals){
  2. smalltalk.addPackage('Compiler-AST');
  3. smalltalk.packages["Compiler-AST"].transport = {"type":"amd","amdNamespace":"amber_core"};
  4. smalltalk.addClass('Node', globals.Object, ['parent', 'position', 'nodes', 'shouldBeInlined', 'shouldBeAliased'], 'Compiler-AST');
  5. globals.Node.comment="I am the abstract root class of the abstract syntax tree.\x0a\x0aConcrete classes should implement `#accept:` to allow visiting.\x0a\x0a`position` holds a point containing line and column number of the symbol location in the original source file.";
  6. smalltalk.addMethod(
  7. smalltalk.method({
  8. selector: "accept:",
  9. protocol: 'visiting',
  10. fn: function (aVisitor){
  11. var self=this;
  12. return smalltalk.withContext(function($ctx1) {
  13. var $1;
  14. $1=_st(aVisitor)._visitNode_(self);
  15. return $1;
  16. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.Node)})},
  17. args: ["aVisitor"],
  18. source: "accept: aVisitor\x0a\x09^ aVisitor visitNode: self",
  19. messageSends: ["visitNode:"],
  20. referencedClasses: []
  21. }),
  22. globals.Node);
  23. smalltalk.addMethod(
  24. smalltalk.method({
  25. selector: "addNode:",
  26. protocol: 'accessing',
  27. fn: function (aNode){
  28. var self=this;
  29. return smalltalk.withContext(function($ctx1) {
  30. _st(self._nodes())._add_(aNode);
  31. _st(aNode)._parent_(self);
  32. return self}, function($ctx1) {$ctx1.fill(self,"addNode:",{aNode:aNode},globals.Node)})},
  33. args: ["aNode"],
  34. source: "addNode: aNode\x0a\x09self nodes add: aNode.\x0a\x09aNode parent: self",
  35. messageSends: ["add:", "nodes", "parent:"],
  36. referencedClasses: []
  37. }),
  38. globals.Node);
  39. smalltalk.addMethod(
  40. smalltalk.method({
  41. selector: "isAssignmentNode",
  42. protocol: 'testing',
  43. fn: function (){
  44. var self=this;
  45. return false;
  46. },
  47. args: [],
  48. source: "isAssignmentNode\x0a\x09^ false",
  49. messageSends: [],
  50. referencedClasses: []
  51. }),
  52. globals.Node);
  53. smalltalk.addMethod(
  54. smalltalk.method({
  55. selector: "isBlockNode",
  56. protocol: 'testing',
  57. fn: function (){
  58. var self=this;
  59. return false;
  60. },
  61. args: [],
  62. source: "isBlockNode\x0a\x09^ false",
  63. messageSends: [],
  64. referencedClasses: []
  65. }),
  66. globals.Node);
  67. smalltalk.addMethod(
  68. smalltalk.method({
  69. selector: "isBlockSequenceNode",
  70. protocol: 'testing',
  71. fn: function (){
  72. var self=this;
  73. return false;
  74. },
  75. args: [],
  76. source: "isBlockSequenceNode\x0a\x09^ false",
  77. messageSends: [],
  78. referencedClasses: []
  79. }),
  80. globals.Node);
  81. smalltalk.addMethod(
  82. smalltalk.method({
  83. selector: "isCascadeNode",
  84. protocol: 'testing',
  85. fn: function (){
  86. var self=this;
  87. return false;
  88. },
  89. args: [],
  90. source: "isCascadeNode\x0a\x09^ false",
  91. messageSends: [],
  92. referencedClasses: []
  93. }),
  94. globals.Node);
  95. smalltalk.addMethod(
  96. smalltalk.method({
  97. selector: "isImmutable",
  98. protocol: 'testing',
  99. fn: function (){
  100. var self=this;
  101. return false;
  102. },
  103. args: [],
  104. source: "isImmutable\x0a\x09^ false",
  105. messageSends: [],
  106. referencedClasses: []
  107. }),
  108. globals.Node);
  109. smalltalk.addMethod(
  110. smalltalk.method({
  111. selector: "isJSStatementNode",
  112. protocol: 'testing',
  113. fn: function (){
  114. var self=this;
  115. return false;
  116. },
  117. args: [],
  118. source: "isJSStatementNode\x0a\x09^ false",
  119. messageSends: [],
  120. referencedClasses: []
  121. }),
  122. globals.Node);
  123. smalltalk.addMethod(
  124. smalltalk.method({
  125. selector: "isLastChild",
  126. protocol: 'testing',
  127. fn: function (){
  128. var self=this;
  129. return smalltalk.withContext(function($ctx1) {
  130. var $1;
  131. $1=_st(_st(_st(self._parent())._nodes())._last()).__eq(self);
  132. return $1;
  133. }, function($ctx1) {$ctx1.fill(self,"isLastChild",{},globals.Node)})},
  134. args: [],
  135. source: "isLastChild\x0a\x09^ self parent nodes last = self",
  136. messageSends: ["=", "last", "nodes", "parent"],
  137. referencedClasses: []
  138. }),
  139. globals.Node);
  140. smalltalk.addMethod(
  141. smalltalk.method({
  142. selector: "isNode",
  143. protocol: 'testing',
  144. fn: function (){
  145. var self=this;
  146. return true;
  147. },
  148. args: [],
  149. source: "isNode\x0a\x09^ true",
  150. messageSends: [],
  151. referencedClasses: []
  152. }),
  153. globals.Node);
  154. smalltalk.addMethod(
  155. smalltalk.method({
  156. selector: "isReferenced",
  157. protocol: 'testing',
  158. fn: function (){
  159. var self=this;
  160. return smalltalk.withContext(function($ctx1) {
  161. var $4,$3,$2,$1;
  162. $4=self._parent();
  163. $ctx1.sendIdx["parent"]=1;
  164. $3=_st($4)._isSequenceNode();
  165. $2=_st($3)._or_((function(){
  166. return smalltalk.withContext(function($ctx2) {
  167. return _st(self._parent())._isAssignmentNode();
  168. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  169. $1=_st($2)._not();
  170. return $1;
  171. }, function($ctx1) {$ctx1.fill(self,"isReferenced",{},globals.Node)})},
  172. args: [],
  173. source: "isReferenced\x0a\x09\x22Answer true if the receiver is referenced by other nodes.\x0a\x09Do not take sequences or assignments into account\x22\x0a\x09\x0a\x09^ (self parent isSequenceNode or: [\x0a\x09\x09self parent isAssignmentNode ]) not",
  174. messageSends: ["not", "or:", "isSequenceNode", "parent", "isAssignmentNode"],
  175. referencedClasses: []
  176. }),
  177. globals.Node);
  178. smalltalk.addMethod(
  179. smalltalk.method({
  180. selector: "isReturnNode",
  181. protocol: 'testing',
  182. fn: function (){
  183. var self=this;
  184. return false;
  185. },
  186. args: [],
  187. source: "isReturnNode\x0a\x09^ false",
  188. messageSends: [],
  189. referencedClasses: []
  190. }),
  191. globals.Node);
  192. smalltalk.addMethod(
  193. smalltalk.method({
  194. selector: "isSendNode",
  195. protocol: 'testing',
  196. fn: function (){
  197. var self=this;
  198. return false;
  199. },
  200. args: [],
  201. source: "isSendNode\x0a\x09^ false",
  202. messageSends: [],
  203. referencedClasses: []
  204. }),
  205. globals.Node);
  206. smalltalk.addMethod(
  207. smalltalk.method({
  208. selector: "isSequenceNode",
  209. protocol: 'testing',
  210. fn: function (){
  211. var self=this;
  212. return false;
  213. },
  214. args: [],
  215. source: "isSequenceNode\x0a\x09^ false",
  216. messageSends: [],
  217. referencedClasses: []
  218. }),
  219. globals.Node);
  220. smalltalk.addMethod(
  221. smalltalk.method({
  222. selector: "isValueNode",
  223. protocol: 'testing',
  224. fn: function (){
  225. var self=this;
  226. return false;
  227. },
  228. args: [],
  229. source: "isValueNode\x0a\x09^ false",
  230. messageSends: [],
  231. referencedClasses: []
  232. }),
  233. globals.Node);
  234. smalltalk.addMethod(
  235. smalltalk.method({
  236. selector: "isVariableNode",
  237. protocol: 'testing',
  238. fn: function (){
  239. var self=this;
  240. return false;
  241. },
  242. args: [],
  243. source: "isVariableNode\x0a\x09^ false",
  244. messageSends: [],
  245. referencedClasses: []
  246. }),
  247. globals.Node);
  248. smalltalk.addMethod(
  249. smalltalk.method({
  250. selector: "method",
  251. protocol: 'accessing',
  252. fn: function (){
  253. var self=this;
  254. return smalltalk.withContext(function($ctx1) {
  255. var $2,$1;
  256. $2=self._parent();
  257. if(($receiver = $2) == nil || $receiver == null){
  258. $1=$2;
  259. } else {
  260. var node;
  261. node=$receiver;
  262. $1=_st(node)._method();
  263. };
  264. return $1;
  265. }, function($ctx1) {$ctx1.fill(self,"method",{},globals.Node)})},
  266. args: [],
  267. source: "method\x0a\x09^ self parent ifNotNil: [ :node | node method ]",
  268. messageSends: ["ifNotNil:", "parent", "method"],
  269. referencedClasses: []
  270. }),
  271. globals.Node);
  272. smalltalk.addMethod(
  273. smalltalk.method({
  274. selector: "nextChild",
  275. protocol: 'accessing',
  276. fn: function (){
  277. var self=this;
  278. return smalltalk.withContext(function($ctx1) {
  279. var $3,$2,$1;
  280. $3=self._nodes();
  281. $ctx1.sendIdx["nodes"]=1;
  282. $2=_st($3)._isEmpty();
  283. if(smalltalk.assert($2)){
  284. $1=self;
  285. } else {
  286. $1=_st(_st(self._nodes())._first())._nextChild();
  287. };
  288. return $1;
  289. }, function($ctx1) {$ctx1.fill(self,"nextChild",{},globals.Node)})},
  290. args: [],
  291. source: "nextChild\x0a\x09\x22Answer the next node after aNode.\x0a\x09Recurse into the possible children of the receiver to answer the next node to be evaluated\x22\x0a\x09\x0a\x09^ self nodes isEmpty\x0a\x09\x09ifTrue: [ self ]\x0a\x09\x09ifFalse: [ self nodes first nextChild ]",
  292. messageSends: ["ifTrue:ifFalse:", "isEmpty", "nodes", "nextChild", "first"],
  293. referencedClasses: []
  294. }),
  295. globals.Node);
  296. smalltalk.addMethod(
  297. smalltalk.method({
  298. selector: "nextNode",
  299. protocol: 'accessing',
  300. fn: function (){
  301. var self=this;
  302. return smalltalk.withContext(function($ctx1) {
  303. var $2,$1;
  304. $2=self._parent();
  305. if(($receiver = $2) == nil || $receiver == null){
  306. $1=$2;
  307. } else {
  308. var node;
  309. node=$receiver;
  310. $1=_st(node)._nextNode_(self);
  311. };
  312. return $1;
  313. }, function($ctx1) {$ctx1.fill(self,"nextNode",{},globals.Node)})},
  314. args: [],
  315. source: "nextNode\x0a\x09^ self parent ifNotNil: [ :node |\x0a\x09\x09node nextNode: self ]",
  316. messageSends: ["ifNotNil:", "parent", "nextNode:"],
  317. referencedClasses: []
  318. }),
  319. globals.Node);
  320. smalltalk.addMethod(
  321. smalltalk.method({
  322. selector: "nextNode:",
  323. protocol: 'accessing',
  324. fn: function (aNode){
  325. var self=this;
  326. var next;
  327. return smalltalk.withContext(function($ctx1) {
  328. var $1,$2;
  329. var $early={};
  330. try {
  331. $1=self._nodes();
  332. $ctx1.sendIdx["nodes"]=1;
  333. next=_st($1)._at_ifAbsent_(_st(_st(self._nodes())._indexOf_(aNode)).__plus((1)),(function(){
  334. return smalltalk.withContext(function($ctx2) {
  335. throw $early=[self];
  336. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  337. $2=_st(next)._nextChild();
  338. return $2;
  339. }
  340. catch(e) {if(e===$early)return e[0]; throw e}
  341. }, function($ctx1) {$ctx1.fill(self,"nextNode:",{aNode:aNode,next:next},globals.Node)})},
  342. args: ["aNode"],
  343. source: "nextNode: aNode\x0a\x09\x22Answer the next node after aNode.\x0a\x09Recurse into the possible children of the next node to answer the next node to be evaluated\x22\x0a\x09\x0a\x09| next |\x0a\x09\x0a\x09next := self nodes \x0a\x09\x09at: (self nodes indexOf: aNode) + 1\x0a\x09\x09ifAbsent: [ ^ self ].\x0a\x09\x0a\x09^ next nextChild",
  344. messageSends: ["at:ifAbsent:", "nodes", "+", "indexOf:", "nextChild"],
  345. referencedClasses: []
  346. }),
  347. globals.Node);
  348. smalltalk.addMethod(
  349. smalltalk.method({
  350. selector: "nodes",
  351. protocol: 'accessing',
  352. fn: function (){
  353. var self=this;
  354. function $Array(){return globals.Array||(typeof Array=="undefined"?nil:Array)}
  355. return smalltalk.withContext(function($ctx1) {
  356. var $2,$1;
  357. $2=self["@nodes"];
  358. if(($receiver = $2) == nil || $receiver == null){
  359. self["@nodes"]=_st($Array())._new();
  360. $1=self["@nodes"];
  361. } else {
  362. $1=$2;
  363. };
  364. return $1;
  365. }, function($ctx1) {$ctx1.fill(self,"nodes",{},globals.Node)})},
  366. args: [],
  367. source: "nodes\x0a\x09^ nodes ifNil: [ nodes := Array new ]",
  368. messageSends: ["ifNil:", "new"],
  369. referencedClasses: ["Array"]
  370. }),
  371. globals.Node);
  372. smalltalk.addMethod(
  373. smalltalk.method({
  374. selector: "nodes:",
  375. protocol: 'building',
  376. fn: function (aCollection){
  377. var self=this;
  378. return smalltalk.withContext(function($ctx1) {
  379. self["@nodes"]=aCollection;
  380. _st(aCollection)._do_((function(each){
  381. return smalltalk.withContext(function($ctx2) {
  382. return _st(each)._parent_(self);
  383. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  384. return self}, function($ctx1) {$ctx1.fill(self,"nodes:",{aCollection:aCollection},globals.Node)})},
  385. args: ["aCollection"],
  386. source: "nodes: aCollection\x0a\x09nodes := aCollection.\x0a\x09aCollection do: [ :each | each parent: self ]",
  387. messageSends: ["do:", "parent:"],
  388. referencedClasses: []
  389. }),
  390. globals.Node);
  391. smalltalk.addMethod(
  392. smalltalk.method({
  393. selector: "parent",
  394. protocol: 'accessing',
  395. fn: function (){
  396. var self=this;
  397. var $1;
  398. $1=self["@parent"];
  399. return $1;
  400. },
  401. args: [],
  402. source: "parent\x0a\x09^ parent",
  403. messageSends: [],
  404. referencedClasses: []
  405. }),
  406. globals.Node);
  407. smalltalk.addMethod(
  408. smalltalk.method({
  409. selector: "parent:",
  410. protocol: 'accessing',
  411. fn: function (aNode){
  412. var self=this;
  413. self["@parent"]=aNode;
  414. return self},
  415. args: ["aNode"],
  416. source: "parent: aNode\x0a\x09parent := aNode",
  417. messageSends: [],
  418. referencedClasses: []
  419. }),
  420. globals.Node);
  421. smalltalk.addMethod(
  422. smalltalk.method({
  423. selector: "position",
  424. protocol: 'accessing',
  425. fn: function (){
  426. var self=this;
  427. return smalltalk.withContext(function($ctx1) {
  428. var $2,$3,$1;
  429. $2=self["@position"];
  430. if(($receiver = $2) == nil || $receiver == null){
  431. $3=self._parent();
  432. if(($receiver = $3) == nil || $receiver == null){
  433. $1=$3;
  434. } else {
  435. var node;
  436. node=$receiver;
  437. $1=_st(node)._position();
  438. };
  439. } else {
  440. $1=$2;
  441. };
  442. return $1;
  443. }, function($ctx1) {$ctx1.fill(self,"position",{},globals.Node)})},
  444. args: [],
  445. source: "position\x0a\x09\x22answer the line and column of the receiver in the source code\x22\x0a\x09\x0a\x09^ position ifNil: [ \x0a\x09\x09self parent ifNotNil: [ :node | node position ] ]",
  446. messageSends: ["ifNil:", "ifNotNil:", "parent", "position"],
  447. referencedClasses: []
  448. }),
  449. globals.Node);
  450. smalltalk.addMethod(
  451. smalltalk.method({
  452. selector: "position:",
  453. protocol: 'building',
  454. fn: function (aPosition){
  455. var self=this;
  456. self["@position"]=aPosition;
  457. return self},
  458. args: ["aPosition"],
  459. source: "position: aPosition\x0a\x09position := aPosition",
  460. messageSends: [],
  461. referencedClasses: []
  462. }),
  463. globals.Node);
  464. smalltalk.addMethod(
  465. smalltalk.method({
  466. selector: "postCopy",
  467. protocol: 'copying',
  468. fn: function (){
  469. var self=this;
  470. return smalltalk.withContext(function($ctx1) {
  471. globals.Node.superclass.fn.prototype._postCopy.apply(_st(self), []);
  472. _st(self._nodes())._do_((function(each){
  473. return smalltalk.withContext(function($ctx2) {
  474. return _st(each)._parent_(self);
  475. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  476. return self}, function($ctx1) {$ctx1.fill(self,"postCopy",{},globals.Node)})},
  477. args: [],
  478. source: "postCopy\x0a\x09super postCopy.\x0a\x09self nodes do: [ :each | each parent: self ]",
  479. messageSends: ["postCopy", "do:", "nodes", "parent:"],
  480. referencedClasses: []
  481. }),
  482. globals.Node);
  483. smalltalk.addMethod(
  484. smalltalk.method({
  485. selector: "requiresSmalltalkContext",
  486. protocol: 'testing',
  487. fn: function (){
  488. var self=this;
  489. return smalltalk.withContext(function($ctx1) {
  490. var $1;
  491. $1=_st(_st(self._nodes())._detect_ifNone_((function(each){
  492. return smalltalk.withContext(function($ctx2) {
  493. return _st(each)._requiresSmalltalkContext();
  494. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}),(function(){
  495. return smalltalk.withContext(function($ctx2) {
  496. return nil;
  497. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})})))._notNil();
  498. return $1;
  499. }, function($ctx1) {$ctx1.fill(self,"requiresSmalltalkContext",{},globals.Node)})},
  500. args: [],
  501. source: "requiresSmalltalkContext\x0a\x09\x22Answer true if the receiver requires a smalltalk context.\x0a\x09Only send nodes require a context.\x0a\x09\x0a\x09If no node requires a context, the method will be compiled without one.\x0a\x09See `IRJSTranslator` and `JSStream` for context creation\x22\x0a\x09\x0a\x09^ (self nodes \x0a\x09\x09detect: [ :each | each requiresSmalltalkContext ]\x0a\x09\x09ifNone: [ nil ]) notNil",
  502. messageSends: ["notNil", "detect:ifNone:", "nodes", "requiresSmalltalkContext"],
  503. referencedClasses: []
  504. }),
  505. globals.Node);
  506. smalltalk.addMethod(
  507. smalltalk.method({
  508. selector: "shouldBeAliased",
  509. protocol: 'accessing',
  510. fn: function (){
  511. var self=this;
  512. return smalltalk.withContext(function($ctx1) {
  513. var $2,$1;
  514. $2=self["@shouldBeAliased"];
  515. if(($receiver = $2) == nil || $receiver == null){
  516. $1=false;
  517. } else {
  518. $1=$2;
  519. };
  520. return $1;
  521. }, function($ctx1) {$ctx1.fill(self,"shouldBeAliased",{},globals.Node)})},
  522. args: [],
  523. source: "shouldBeAliased\x0a\x09^ shouldBeAliased ifNil: [ false ]",
  524. messageSends: ["ifNil:"],
  525. referencedClasses: []
  526. }),
  527. globals.Node);
  528. smalltalk.addMethod(
  529. smalltalk.method({
  530. selector: "shouldBeAliased:",
  531. protocol: 'accessing',
  532. fn: function (aBoolean){
  533. var self=this;
  534. self["@shouldBeAliased"]=aBoolean;
  535. return self},
  536. args: ["aBoolean"],
  537. source: "shouldBeAliased: aBoolean\x0a\x09shouldBeAliased := aBoolean",
  538. messageSends: [],
  539. referencedClasses: []
  540. }),
  541. globals.Node);
  542. smalltalk.addMethod(
  543. smalltalk.method({
  544. selector: "shouldBeInlined",
  545. protocol: 'accessing',
  546. fn: function (){
  547. var self=this;
  548. return smalltalk.withContext(function($ctx1) {
  549. var $2,$1;
  550. $2=self["@shouldBeInlined"];
  551. if(($receiver = $2) == nil || $receiver == null){
  552. $1=false;
  553. } else {
  554. $1=$2;
  555. };
  556. return $1;
  557. }, function($ctx1) {$ctx1.fill(self,"shouldBeInlined",{},globals.Node)})},
  558. args: [],
  559. source: "shouldBeInlined\x0a\x09^ shouldBeInlined ifNil: [ false ]",
  560. messageSends: ["ifNil:"],
  561. referencedClasses: []
  562. }),
  563. globals.Node);
  564. smalltalk.addMethod(
  565. smalltalk.method({
  566. selector: "shouldBeInlined:",
  567. protocol: 'accessing',
  568. fn: function (aBoolean){
  569. var self=this;
  570. self["@shouldBeInlined"]=aBoolean;
  571. return self},
  572. args: ["aBoolean"],
  573. source: "shouldBeInlined: aBoolean\x0a\x09shouldBeInlined := aBoolean",
  574. messageSends: [],
  575. referencedClasses: []
  576. }),
  577. globals.Node);
  578. smalltalk.addMethod(
  579. smalltalk.method({
  580. selector: "stopOnStepping",
  581. protocol: 'testing',
  582. fn: function (){
  583. var self=this;
  584. return false;
  585. },
  586. args: [],
  587. source: "stopOnStepping\x0a\x09^ false",
  588. messageSends: [],
  589. referencedClasses: []
  590. }),
  591. globals.Node);
  592. smalltalk.addMethod(
  593. smalltalk.method({
  594. selector: "subtreeNeedsAliasing",
  595. protocol: 'testing',
  596. fn: function (){
  597. var self=this;
  598. return smalltalk.withContext(function($ctx1) {
  599. var $1;
  600. $1=_st(_st(self._shouldBeAliased())._or_((function(){
  601. return smalltalk.withContext(function($ctx2) {
  602. return self._shouldBeInlined();
  603. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})})))._or_((function(){
  604. return smalltalk.withContext(function($ctx2) {
  605. return _st(self._nodes())._anySatisfy_((function(each){
  606. return smalltalk.withContext(function($ctx3) {
  607. return _st(each)._subtreeNeedsAliasing();
  608. }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx2,3)})}));
  609. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  610. $ctx1.sendIdx["or:"]=1;
  611. return $1;
  612. }, function($ctx1) {$ctx1.fill(self,"subtreeNeedsAliasing",{},globals.Node)})},
  613. args: [],
  614. source: "subtreeNeedsAliasing\x0a\x09^ (self shouldBeAliased or: [ self shouldBeInlined ]) or: [\x0a\x09\x09self nodes anySatisfy: [ :each | each subtreeNeedsAliasing ] ]",
  615. messageSends: ["or:", "shouldBeAliased", "shouldBeInlined", "anySatisfy:", "nodes", "subtreeNeedsAliasing"],
  616. referencedClasses: []
  617. }),
  618. globals.Node);
  619. smalltalk.addClass('AssignmentNode', globals.Node, ['left', 'right'], 'Compiler-AST');
  620. globals.AssignmentNode.comment="I represent an assignment node.";
  621. smalltalk.addMethod(
  622. smalltalk.method({
  623. selector: "accept:",
  624. protocol: 'visiting',
  625. fn: function (aVisitor){
  626. var self=this;
  627. return smalltalk.withContext(function($ctx1) {
  628. var $1;
  629. $1=_st(aVisitor)._visitAssignmentNode_(self);
  630. return $1;
  631. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.AssignmentNode)})},
  632. args: ["aVisitor"],
  633. source: "accept: aVisitor\x0a\x09^ aVisitor visitAssignmentNode: self",
  634. messageSends: ["visitAssignmentNode:"],
  635. referencedClasses: []
  636. }),
  637. globals.AssignmentNode);
  638. smalltalk.addMethod(
  639. smalltalk.method({
  640. selector: "isAssignmentNode",
  641. protocol: 'testing',
  642. fn: function (){
  643. var self=this;
  644. return true;
  645. },
  646. args: [],
  647. source: "isAssignmentNode\x0a\x09^ true",
  648. messageSends: [],
  649. referencedClasses: []
  650. }),
  651. globals.AssignmentNode);
  652. smalltalk.addMethod(
  653. smalltalk.method({
  654. selector: "left",
  655. protocol: 'accessing',
  656. fn: function (){
  657. var self=this;
  658. var $1;
  659. $1=self["@left"];
  660. return $1;
  661. },
  662. args: [],
  663. source: "left\x0a\x09^ left",
  664. messageSends: [],
  665. referencedClasses: []
  666. }),
  667. globals.AssignmentNode);
  668. smalltalk.addMethod(
  669. smalltalk.method({
  670. selector: "left:",
  671. protocol: 'accessing',
  672. fn: function (aNode){
  673. var self=this;
  674. return smalltalk.withContext(function($ctx1) {
  675. self["@left"]=aNode;
  676. _st(aNode)._parent_(self);
  677. return self}, function($ctx1) {$ctx1.fill(self,"left:",{aNode:aNode},globals.AssignmentNode)})},
  678. args: ["aNode"],
  679. source: "left: aNode\x0a\x09left := aNode.\x0a\x09aNode parent: self",
  680. messageSends: ["parent:"],
  681. referencedClasses: []
  682. }),
  683. globals.AssignmentNode);
  684. smalltalk.addMethod(
  685. smalltalk.method({
  686. selector: "nodes",
  687. protocol: 'accessing',
  688. fn: function (){
  689. var self=this;
  690. function $Array(){return globals.Array||(typeof Array=="undefined"?nil:Array)}
  691. return smalltalk.withContext(function($ctx1) {
  692. var $1;
  693. $1=_st($Array())._with_with_(self._left(),self._right());
  694. return $1;
  695. }, function($ctx1) {$ctx1.fill(self,"nodes",{},globals.AssignmentNode)})},
  696. args: [],
  697. source: "nodes\x0a\x09^ Array with: self left with: self right",
  698. messageSends: ["with:with:", "left", "right"],
  699. referencedClasses: ["Array"]
  700. }),
  701. globals.AssignmentNode);
  702. smalltalk.addMethod(
  703. smalltalk.method({
  704. selector: "right",
  705. protocol: 'accessing',
  706. fn: function (){
  707. var self=this;
  708. var $1;
  709. $1=self["@right"];
  710. return $1;
  711. },
  712. args: [],
  713. source: "right\x0a\x09^ right",
  714. messageSends: [],
  715. referencedClasses: []
  716. }),
  717. globals.AssignmentNode);
  718. smalltalk.addMethod(
  719. smalltalk.method({
  720. selector: "right:",
  721. protocol: 'accessing',
  722. fn: function (aNode){
  723. var self=this;
  724. return smalltalk.withContext(function($ctx1) {
  725. self["@right"]=aNode;
  726. _st(aNode)._parent_(self);
  727. return self}, function($ctx1) {$ctx1.fill(self,"right:",{aNode:aNode},globals.AssignmentNode)})},
  728. args: ["aNode"],
  729. source: "right: aNode\x0a\x09right := aNode.\x0a\x09aNode parent: self",
  730. messageSends: ["parent:"],
  731. referencedClasses: []
  732. }),
  733. globals.AssignmentNode);
  734. smalltalk.addMethod(
  735. smalltalk.method({
  736. selector: "shouldBeAliased",
  737. protocol: 'testing',
  738. fn: function (){
  739. var self=this;
  740. return smalltalk.withContext(function($ctx1) {
  741. var $1;
  742. $1=_st(globals.AssignmentNode.superclass.fn.prototype._shouldBeAliased.apply(_st(self), []))._or_((function(){
  743. return smalltalk.withContext(function($ctx2) {
  744. return self._isReferenced();
  745. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  746. return $1;
  747. }, function($ctx1) {$ctx1.fill(self,"shouldBeAliased",{},globals.AssignmentNode)})},
  748. args: [],
  749. source: "shouldBeAliased\x0a\x09^ super shouldBeAliased or: [ self isReferenced ]",
  750. messageSends: ["or:", "shouldBeAliased", "isReferenced"],
  751. referencedClasses: []
  752. }),
  753. globals.AssignmentNode);
  754. smalltalk.addClass('BlockNode', globals.Node, ['parameters', 'scope'], 'Compiler-AST');
  755. globals.BlockNode.comment="I represent an block closure node.";
  756. smalltalk.addMethod(
  757. smalltalk.method({
  758. selector: "accept:",
  759. protocol: 'visiting',
  760. fn: function (aVisitor){
  761. var self=this;
  762. return smalltalk.withContext(function($ctx1) {
  763. var $1;
  764. $1=_st(aVisitor)._visitBlockNode_(self);
  765. return $1;
  766. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.BlockNode)})},
  767. args: ["aVisitor"],
  768. source: "accept: aVisitor\x0a\x09^ aVisitor visitBlockNode: self",
  769. messageSends: ["visitBlockNode:"],
  770. referencedClasses: []
  771. }),
  772. globals.BlockNode);
  773. smalltalk.addMethod(
  774. smalltalk.method({
  775. selector: "isBlockNode",
  776. protocol: 'testing',
  777. fn: function (){
  778. var self=this;
  779. return true;
  780. },
  781. args: [],
  782. source: "isBlockNode\x0a\x09^ true",
  783. messageSends: [],
  784. referencedClasses: []
  785. }),
  786. globals.BlockNode);
  787. smalltalk.addMethod(
  788. smalltalk.method({
  789. selector: "nextChild",
  790. protocol: 'accessing',
  791. fn: function (){
  792. var self=this;
  793. return self;
  794. },
  795. args: [],
  796. source: "nextChild\x0a\x09\x22Answer the receiver as we want to avoid eager evaluation\x22\x0a\x09\x0a\x09^ self",
  797. messageSends: [],
  798. referencedClasses: []
  799. }),
  800. globals.BlockNode);
  801. smalltalk.addMethod(
  802. smalltalk.method({
  803. selector: "nextNode:",
  804. protocol: 'accessing',
  805. fn: function (aNode){
  806. var self=this;
  807. return self;
  808. },
  809. args: ["aNode"],
  810. source: "nextNode: aNode\x0a\x09\x22Answer the receiver as we want to avoid eager evaluation\x22\x0a\x09\x0a\x09^ self",
  811. messageSends: [],
  812. referencedClasses: []
  813. }),
  814. globals.BlockNode);
  815. smalltalk.addMethod(
  816. smalltalk.method({
  817. selector: "parameters",
  818. protocol: 'accessing',
  819. fn: function (){
  820. var self=this;
  821. function $Array(){return globals.Array||(typeof Array=="undefined"?nil:Array)}
  822. return smalltalk.withContext(function($ctx1) {
  823. var $2,$1;
  824. $2=self["@parameters"];
  825. if(($receiver = $2) == nil || $receiver == null){
  826. self["@parameters"]=_st($Array())._new();
  827. $1=self["@parameters"];
  828. } else {
  829. $1=$2;
  830. };
  831. return $1;
  832. }, function($ctx1) {$ctx1.fill(self,"parameters",{},globals.BlockNode)})},
  833. args: [],
  834. source: "parameters\x0a\x09^ parameters ifNil: [ parameters := Array new ]",
  835. messageSends: ["ifNil:", "new"],
  836. referencedClasses: ["Array"]
  837. }),
  838. globals.BlockNode);
  839. smalltalk.addMethod(
  840. smalltalk.method({
  841. selector: "parameters:",
  842. protocol: 'accessing',
  843. fn: function (aCollection){
  844. var self=this;
  845. self["@parameters"]=aCollection;
  846. return self},
  847. args: ["aCollection"],
  848. source: "parameters: aCollection\x0a\x09parameters := aCollection",
  849. messageSends: [],
  850. referencedClasses: []
  851. }),
  852. globals.BlockNode);
  853. smalltalk.addMethod(
  854. smalltalk.method({
  855. selector: "scope",
  856. protocol: 'accessing',
  857. fn: function (){
  858. var self=this;
  859. var $1;
  860. $1=self["@scope"];
  861. return $1;
  862. },
  863. args: [],
  864. source: "scope\x0a\x09^ scope",
  865. messageSends: [],
  866. referencedClasses: []
  867. }),
  868. globals.BlockNode);
  869. smalltalk.addMethod(
  870. smalltalk.method({
  871. selector: "scope:",
  872. protocol: 'accessing',
  873. fn: function (aLexicalScope){
  874. var self=this;
  875. self["@scope"]=aLexicalScope;
  876. return self},
  877. args: ["aLexicalScope"],
  878. source: "scope: aLexicalScope\x0a\x09scope := aLexicalScope",
  879. messageSends: [],
  880. referencedClasses: []
  881. }),
  882. globals.BlockNode);
  883. smalltalk.addMethod(
  884. smalltalk.method({
  885. selector: "subtreeNeedsAliasing",
  886. protocol: 'testing',
  887. fn: function (){
  888. var self=this;
  889. return smalltalk.withContext(function($ctx1) {
  890. var $1;
  891. $1=_st(self._shouldBeAliased())._or_((function(){
  892. return smalltalk.withContext(function($ctx2) {
  893. return self._shouldBeInlined();
  894. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  895. return $1;
  896. }, function($ctx1) {$ctx1.fill(self,"subtreeNeedsAliasing",{},globals.BlockNode)})},
  897. args: [],
  898. source: "subtreeNeedsAliasing\x0a\x09^ self shouldBeAliased or: [ self shouldBeInlined ]",
  899. messageSends: ["or:", "shouldBeAliased", "shouldBeInlined"],
  900. referencedClasses: []
  901. }),
  902. globals.BlockNode);
  903. smalltalk.addClass('CascadeNode', globals.Node, ['receiver'], 'Compiler-AST');
  904. globals.CascadeNode.comment="I represent an cascade node.";
  905. smalltalk.addMethod(
  906. smalltalk.method({
  907. selector: "accept:",
  908. protocol: 'visiting',
  909. fn: function (aVisitor){
  910. var self=this;
  911. return smalltalk.withContext(function($ctx1) {
  912. var $1;
  913. $1=_st(aVisitor)._visitCascadeNode_(self);
  914. return $1;
  915. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.CascadeNode)})},
  916. args: ["aVisitor"],
  917. source: "accept: aVisitor\x0a\x09^ aVisitor visitCascadeNode: self",
  918. messageSends: ["visitCascadeNode:"],
  919. referencedClasses: []
  920. }),
  921. globals.CascadeNode);
  922. smalltalk.addMethod(
  923. smalltalk.method({
  924. selector: "isCascadeNode",
  925. protocol: 'testing',
  926. fn: function (){
  927. var self=this;
  928. return true;
  929. },
  930. args: [],
  931. source: "isCascadeNode\x0a\x09^ true",
  932. messageSends: [],
  933. referencedClasses: []
  934. }),
  935. globals.CascadeNode);
  936. smalltalk.addMethod(
  937. smalltalk.method({
  938. selector: "receiver",
  939. protocol: 'accessing',
  940. fn: function (){
  941. var self=this;
  942. var $1;
  943. $1=self["@receiver"];
  944. return $1;
  945. },
  946. args: [],
  947. source: "receiver\x0a\x09^ receiver",
  948. messageSends: [],
  949. referencedClasses: []
  950. }),
  951. globals.CascadeNode);
  952. smalltalk.addMethod(
  953. smalltalk.method({
  954. selector: "receiver:",
  955. protocol: 'accessing',
  956. fn: function (aNode){
  957. var self=this;
  958. self["@receiver"]=aNode;
  959. return self},
  960. args: ["aNode"],
  961. source: "receiver: aNode\x0a\x09receiver := aNode",
  962. messageSends: [],
  963. referencedClasses: []
  964. }),
  965. globals.CascadeNode);
  966. smalltalk.addClass('DynamicArrayNode', globals.Node, [], 'Compiler-AST');
  967. globals.DynamicArrayNode.comment="I represent an dynamic array node.";
  968. smalltalk.addMethod(
  969. smalltalk.method({
  970. selector: "accept:",
  971. protocol: 'visiting',
  972. fn: function (aVisitor){
  973. var self=this;
  974. return smalltalk.withContext(function($ctx1) {
  975. var $1;
  976. $1=_st(aVisitor)._visitDynamicArrayNode_(self);
  977. return $1;
  978. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.DynamicArrayNode)})},
  979. args: ["aVisitor"],
  980. source: "accept: aVisitor\x0a\x09^ aVisitor visitDynamicArrayNode: self",
  981. messageSends: ["visitDynamicArrayNode:"],
  982. referencedClasses: []
  983. }),
  984. globals.DynamicArrayNode);
  985. smalltalk.addClass('DynamicDictionaryNode', globals.Node, [], 'Compiler-AST');
  986. globals.DynamicDictionaryNode.comment="I represent an dynamic dictionary node.";
  987. smalltalk.addMethod(
  988. smalltalk.method({
  989. selector: "accept:",
  990. protocol: 'visiting',
  991. fn: function (aVisitor){
  992. var self=this;
  993. return smalltalk.withContext(function($ctx1) {
  994. var $1;
  995. $1=_st(aVisitor)._visitDynamicDictionaryNode_(self);
  996. return $1;
  997. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.DynamicDictionaryNode)})},
  998. args: ["aVisitor"],
  999. source: "accept: aVisitor\x0a\x09^ aVisitor visitDynamicDictionaryNode: self",
  1000. messageSends: ["visitDynamicDictionaryNode:"],
  1001. referencedClasses: []
  1002. }),
  1003. globals.DynamicDictionaryNode);
  1004. smalltalk.addClass('JSStatementNode', globals.Node, ['source'], 'Compiler-AST');
  1005. globals.JSStatementNode.comment="I represent an JavaScript statement node.";
  1006. smalltalk.addMethod(
  1007. smalltalk.method({
  1008. selector: "accept:",
  1009. protocol: 'visiting',
  1010. fn: function (aVisitor){
  1011. var self=this;
  1012. return smalltalk.withContext(function($ctx1) {
  1013. var $1;
  1014. $1=_st(aVisitor)._visitJSStatementNode_(self);
  1015. return $1;
  1016. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.JSStatementNode)})},
  1017. args: ["aVisitor"],
  1018. source: "accept: aVisitor\x0a\x09^ aVisitor visitJSStatementNode: self",
  1019. messageSends: ["visitJSStatementNode:"],
  1020. referencedClasses: []
  1021. }),
  1022. globals.JSStatementNode);
  1023. smalltalk.addMethod(
  1024. smalltalk.method({
  1025. selector: "isJSStatementNode",
  1026. protocol: 'testing',
  1027. fn: function (){
  1028. var self=this;
  1029. return true;
  1030. },
  1031. args: [],
  1032. source: "isJSStatementNode\x0a\x09^ true",
  1033. messageSends: [],
  1034. referencedClasses: []
  1035. }),
  1036. globals.JSStatementNode);
  1037. smalltalk.addMethod(
  1038. smalltalk.method({
  1039. selector: "source",
  1040. protocol: 'accessing',
  1041. fn: function (){
  1042. var self=this;
  1043. return smalltalk.withContext(function($ctx1) {
  1044. var $2,$1;
  1045. $2=self["@source"];
  1046. if(($receiver = $2) == nil || $receiver == null){
  1047. $1="";
  1048. } else {
  1049. $1=$2;
  1050. };
  1051. return $1;
  1052. }, function($ctx1) {$ctx1.fill(self,"source",{},globals.JSStatementNode)})},
  1053. args: [],
  1054. source: "source\x0a\x09^ source ifNil: [ '' ]",
  1055. messageSends: ["ifNil:"],
  1056. referencedClasses: []
  1057. }),
  1058. globals.JSStatementNode);
  1059. smalltalk.addMethod(
  1060. smalltalk.method({
  1061. selector: "source:",
  1062. protocol: 'accessing',
  1063. fn: function (aString){
  1064. var self=this;
  1065. self["@source"]=aString;
  1066. return self},
  1067. args: ["aString"],
  1068. source: "source: aString\x0a\x09source := aString",
  1069. messageSends: [],
  1070. referencedClasses: []
  1071. }),
  1072. globals.JSStatementNode);
  1073. smalltalk.addClass('MethodNode', globals.Node, ['selector', 'arguments', 'source', 'scope', 'classReferences', 'sendIndexes', 'superSends'], 'Compiler-AST');
  1074. globals.MethodNode.comment="I represent an method node.\x0a\x0aA method node must be the root and only method node of a valid AST.";
  1075. smalltalk.addMethod(
  1076. smalltalk.method({
  1077. selector: "accept:",
  1078. protocol: 'visiting',
  1079. fn: function (aVisitor){
  1080. var self=this;
  1081. return smalltalk.withContext(function($ctx1) {
  1082. var $1;
  1083. $1=_st(aVisitor)._visitMethodNode_(self);
  1084. return $1;
  1085. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.MethodNode)})},
  1086. args: ["aVisitor"],
  1087. source: "accept: aVisitor\x0a\x09^ aVisitor visitMethodNode: self",
  1088. messageSends: ["visitMethodNode:"],
  1089. referencedClasses: []
  1090. }),
  1091. globals.MethodNode);
  1092. smalltalk.addMethod(
  1093. smalltalk.method({
  1094. selector: "arguments",
  1095. protocol: 'accessing',
  1096. fn: function (){
  1097. var self=this;
  1098. return smalltalk.withContext(function($ctx1) {
  1099. var $2,$1;
  1100. $2=self["@arguments"];
  1101. if(($receiver = $2) == nil || $receiver == null){
  1102. $1=[];
  1103. } else {
  1104. $1=$2;
  1105. };
  1106. return $1;
  1107. }, function($ctx1) {$ctx1.fill(self,"arguments",{},globals.MethodNode)})},
  1108. args: [],
  1109. source: "arguments\x0a\x09^ arguments ifNil: [ #() ]",
  1110. messageSends: ["ifNil:"],
  1111. referencedClasses: []
  1112. }),
  1113. globals.MethodNode);
  1114. smalltalk.addMethod(
  1115. smalltalk.method({
  1116. selector: "arguments:",
  1117. protocol: 'accessing',
  1118. fn: function (aCollection){
  1119. var self=this;
  1120. self["@arguments"]=aCollection;
  1121. return self},
  1122. args: ["aCollection"],
  1123. source: "arguments: aCollection\x0a\x09arguments := aCollection",
  1124. messageSends: [],
  1125. referencedClasses: []
  1126. }),
  1127. globals.MethodNode);
  1128. smalltalk.addMethod(
  1129. smalltalk.method({
  1130. selector: "classReferences",
  1131. protocol: 'accessing',
  1132. fn: function (){
  1133. var self=this;
  1134. var $1;
  1135. $1=self["@classReferences"];
  1136. return $1;
  1137. },
  1138. args: [],
  1139. source: "classReferences\x0a\x09^ classReferences",
  1140. messageSends: [],
  1141. referencedClasses: []
  1142. }),
  1143. globals.MethodNode);
  1144. smalltalk.addMethod(
  1145. smalltalk.method({
  1146. selector: "classReferences:",
  1147. protocol: 'accessing',
  1148. fn: function (aCollection){
  1149. var self=this;
  1150. self["@classReferences"]=aCollection;
  1151. return self},
  1152. args: ["aCollection"],
  1153. source: "classReferences: aCollection\x0a\x09classReferences := aCollection",
  1154. messageSends: [],
  1155. referencedClasses: []
  1156. }),
  1157. globals.MethodNode);
  1158. smalltalk.addMethod(
  1159. smalltalk.method({
  1160. selector: "extent",
  1161. protocol: 'accessing',
  1162. fn: function (){
  1163. var self=this;
  1164. return smalltalk.withContext(function($ctx1) {
  1165. var $4,$3,$2,$1;
  1166. $4=self._source();
  1167. $ctx1.sendIdx["source"]=1;
  1168. $3=_st($4)._lines();
  1169. $ctx1.sendIdx["lines"]=1;
  1170. $2=_st($3)._size();
  1171. $ctx1.sendIdx["size"]=1;
  1172. $1=_st($2).__at(_st(_st(_st(_st(self._source())._lines())._last())._size()).__plus((1)));
  1173. return $1;
  1174. }, function($ctx1) {$ctx1.fill(self,"extent",{},globals.MethodNode)})},
  1175. args: [],
  1176. source: "extent\x0a\x09^ self source lines size @ (self source lines last size + 1)",
  1177. messageSends: ["@", "size", "lines", "source", "+", "last"],
  1178. referencedClasses: []
  1179. }),
  1180. globals.MethodNode);
  1181. smalltalk.addMethod(
  1182. smalltalk.method({
  1183. selector: "messageSends",
  1184. protocol: 'accessing',
  1185. fn: function (){
  1186. var self=this;
  1187. return smalltalk.withContext(function($ctx1) {
  1188. var $1;
  1189. $1=_st(self._sendIndexes())._keys();
  1190. return $1;
  1191. }, function($ctx1) {$ctx1.fill(self,"messageSends",{},globals.MethodNode)})},
  1192. args: [],
  1193. source: "messageSends\x0a\x09^ self sendIndexes keys",
  1194. messageSends: ["keys", "sendIndexes"],
  1195. referencedClasses: []
  1196. }),
  1197. globals.MethodNode);
  1198. smalltalk.addMethod(
  1199. smalltalk.method({
  1200. selector: "method",
  1201. protocol: 'accessing',
  1202. fn: function (){
  1203. var self=this;
  1204. return self;
  1205. },
  1206. args: [],
  1207. source: "method\x0a\x09^ self",
  1208. messageSends: [],
  1209. referencedClasses: []
  1210. }),
  1211. globals.MethodNode);
  1212. smalltalk.addMethod(
  1213. smalltalk.method({
  1214. selector: "scope",
  1215. protocol: 'accessing',
  1216. fn: function (){
  1217. var self=this;
  1218. var $1;
  1219. $1=self["@scope"];
  1220. return $1;
  1221. },
  1222. args: [],
  1223. source: "scope\x0a\x09^ scope",
  1224. messageSends: [],
  1225. referencedClasses: []
  1226. }),
  1227. globals.MethodNode);
  1228. smalltalk.addMethod(
  1229. smalltalk.method({
  1230. selector: "scope:",
  1231. protocol: 'accessing',
  1232. fn: function (aMethodScope){
  1233. var self=this;
  1234. self["@scope"]=aMethodScope;
  1235. return self},
  1236. args: ["aMethodScope"],
  1237. source: "scope: aMethodScope\x0a\x09scope := aMethodScope",
  1238. messageSends: [],
  1239. referencedClasses: []
  1240. }),
  1241. globals.MethodNode);
  1242. smalltalk.addMethod(
  1243. smalltalk.method({
  1244. selector: "selector",
  1245. protocol: 'accessing',
  1246. fn: function (){
  1247. var self=this;
  1248. var $1;
  1249. $1=self["@selector"];
  1250. return $1;
  1251. },
  1252. args: [],
  1253. source: "selector\x0a\x09^ selector",
  1254. messageSends: [],
  1255. referencedClasses: []
  1256. }),
  1257. globals.MethodNode);
  1258. smalltalk.addMethod(
  1259. smalltalk.method({
  1260. selector: "selector:",
  1261. protocol: 'accessing',
  1262. fn: function (aString){
  1263. var self=this;
  1264. self["@selector"]=aString;
  1265. return self},
  1266. args: ["aString"],
  1267. source: "selector: aString\x0a\x09selector := aString",
  1268. messageSends: [],
  1269. referencedClasses: []
  1270. }),
  1271. globals.MethodNode);
  1272. smalltalk.addMethod(
  1273. smalltalk.method({
  1274. selector: "sendIndexes",
  1275. protocol: 'accessing',
  1276. fn: function (){
  1277. var self=this;
  1278. var $1;
  1279. $1=self["@sendIndexes"];
  1280. return $1;
  1281. },
  1282. args: [],
  1283. source: "sendIndexes\x0a\x09^ sendIndexes",
  1284. messageSends: [],
  1285. referencedClasses: []
  1286. }),
  1287. globals.MethodNode);
  1288. smalltalk.addMethod(
  1289. smalltalk.method({
  1290. selector: "sendIndexes:",
  1291. protocol: 'accessing',
  1292. fn: function (aDictionary){
  1293. var self=this;
  1294. self["@sendIndexes"]=aDictionary;
  1295. return self},
  1296. args: ["aDictionary"],
  1297. source: "sendIndexes: aDictionary\x0a\x09sendIndexes := aDictionary",
  1298. messageSends: [],
  1299. referencedClasses: []
  1300. }),
  1301. globals.MethodNode);
  1302. smalltalk.addMethod(
  1303. smalltalk.method({
  1304. selector: "source",
  1305. protocol: 'accessing',
  1306. fn: function (){
  1307. var self=this;
  1308. var $1;
  1309. $1=self["@source"];
  1310. return $1;
  1311. },
  1312. args: [],
  1313. source: "source\x0a\x09^ source",
  1314. messageSends: [],
  1315. referencedClasses: []
  1316. }),
  1317. globals.MethodNode);
  1318. smalltalk.addMethod(
  1319. smalltalk.method({
  1320. selector: "source:",
  1321. protocol: 'accessing',
  1322. fn: function (aString){
  1323. var self=this;
  1324. self["@source"]=aString;
  1325. return self},
  1326. args: ["aString"],
  1327. source: "source: aString\x0a\x09source := aString",
  1328. messageSends: [],
  1329. referencedClasses: []
  1330. }),
  1331. globals.MethodNode);
  1332. smalltalk.addMethod(
  1333. smalltalk.method({
  1334. selector: "superSends",
  1335. protocol: 'accessing',
  1336. fn: function (){
  1337. var self=this;
  1338. var $1;
  1339. $1=self["@superSends"];
  1340. return $1;
  1341. },
  1342. args: [],
  1343. source: "superSends\x0a\x09^ superSends",
  1344. messageSends: [],
  1345. referencedClasses: []
  1346. }),
  1347. globals.MethodNode);
  1348. smalltalk.addMethod(
  1349. smalltalk.method({
  1350. selector: "superSends:",
  1351. protocol: 'accessing',
  1352. fn: function (aCollection){
  1353. var self=this;
  1354. self["@superSends"]=aCollection;
  1355. return self},
  1356. args: ["aCollection"],
  1357. source: "superSends: aCollection\x0a\x09superSends := aCollection",
  1358. messageSends: [],
  1359. referencedClasses: []
  1360. }),
  1361. globals.MethodNode);
  1362. smalltalk.addClass('ReturnNode', globals.Node, ['scope'], 'Compiler-AST');
  1363. globals.ReturnNode.comment="I represent an return node. At the AST level, there is not difference between a local return or non-local return.";
  1364. smalltalk.addMethod(
  1365. smalltalk.method({
  1366. selector: "accept:",
  1367. protocol: 'visiting',
  1368. fn: function (aVisitor){
  1369. var self=this;
  1370. return smalltalk.withContext(function($ctx1) {
  1371. var $1;
  1372. $1=_st(aVisitor)._visitReturnNode_(self);
  1373. return $1;
  1374. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.ReturnNode)})},
  1375. args: ["aVisitor"],
  1376. source: "accept: aVisitor\x0a\x09^ aVisitor visitReturnNode: self",
  1377. messageSends: ["visitReturnNode:"],
  1378. referencedClasses: []
  1379. }),
  1380. globals.ReturnNode);
  1381. smalltalk.addMethod(
  1382. smalltalk.method({
  1383. selector: "isReturnNode",
  1384. protocol: 'testing',
  1385. fn: function (){
  1386. var self=this;
  1387. return true;
  1388. },
  1389. args: [],
  1390. source: "isReturnNode\x0a\x09^ true",
  1391. messageSends: [],
  1392. referencedClasses: []
  1393. }),
  1394. globals.ReturnNode);
  1395. smalltalk.addMethod(
  1396. smalltalk.method({
  1397. selector: "nonLocalReturn",
  1398. protocol: 'testing',
  1399. fn: function (){
  1400. var self=this;
  1401. return smalltalk.withContext(function($ctx1) {
  1402. var $1;
  1403. $1=_st(_st(self._scope())._isMethodScope())._not();
  1404. return $1;
  1405. }, function($ctx1) {$ctx1.fill(self,"nonLocalReturn",{},globals.ReturnNode)})},
  1406. args: [],
  1407. source: "nonLocalReturn\x0a\x09^ self scope isMethodScope not",
  1408. messageSends: ["not", "isMethodScope", "scope"],
  1409. referencedClasses: []
  1410. }),
  1411. globals.ReturnNode);
  1412. smalltalk.addMethod(
  1413. smalltalk.method({
  1414. selector: "scope",
  1415. protocol: 'accessing',
  1416. fn: function (){
  1417. var self=this;
  1418. var $1;
  1419. $1=self["@scope"];
  1420. return $1;
  1421. },
  1422. args: [],
  1423. source: "scope\x0a\x09^ scope",
  1424. messageSends: [],
  1425. referencedClasses: []
  1426. }),
  1427. globals.ReturnNode);
  1428. smalltalk.addMethod(
  1429. smalltalk.method({
  1430. selector: "scope:",
  1431. protocol: 'accessing',
  1432. fn: function (aLexicalScope){
  1433. var self=this;
  1434. self["@scope"]=aLexicalScope;
  1435. return self},
  1436. args: ["aLexicalScope"],
  1437. source: "scope: aLexicalScope\x0a\x09scope := aLexicalScope",
  1438. messageSends: [],
  1439. referencedClasses: []
  1440. }),
  1441. globals.ReturnNode);
  1442. smalltalk.addClass('SendNode', globals.Node, ['selector', 'arguments', 'receiver', 'superSend', 'index'], 'Compiler-AST');
  1443. globals.SendNode.comment="I represent an message send node.";
  1444. smalltalk.addMethod(
  1445. smalltalk.method({
  1446. selector: "accept:",
  1447. protocol: 'visiting',
  1448. fn: function (aVisitor){
  1449. var self=this;
  1450. return smalltalk.withContext(function($ctx1) {
  1451. var $1;
  1452. $1=_st(aVisitor)._visitSendNode_(self);
  1453. return $1;
  1454. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.SendNode)})},
  1455. args: ["aVisitor"],
  1456. source: "accept: aVisitor\x0a\x09^ aVisitor visitSendNode: self",
  1457. messageSends: ["visitSendNode:"],
  1458. referencedClasses: []
  1459. }),
  1460. globals.SendNode);
  1461. smalltalk.addMethod(
  1462. smalltalk.method({
  1463. selector: "arguments",
  1464. protocol: 'accessing',
  1465. fn: function (){
  1466. var self=this;
  1467. return smalltalk.withContext(function($ctx1) {
  1468. var $2,$1;
  1469. $2=self["@arguments"];
  1470. if(($receiver = $2) == nil || $receiver == null){
  1471. self["@arguments"]=[];
  1472. $1=self["@arguments"];
  1473. } else {
  1474. $1=$2;
  1475. };
  1476. return $1;
  1477. }, function($ctx1) {$ctx1.fill(self,"arguments",{},globals.SendNode)})},
  1478. args: [],
  1479. source: "arguments\x0a\x09^ arguments ifNil: [ arguments := #() ]",
  1480. messageSends: ["ifNil:"],
  1481. referencedClasses: []
  1482. }),
  1483. globals.SendNode);
  1484. smalltalk.addMethod(
  1485. smalltalk.method({
  1486. selector: "arguments:",
  1487. protocol: 'accessing',
  1488. fn: function (aCollection){
  1489. var self=this;
  1490. return smalltalk.withContext(function($ctx1) {
  1491. self["@arguments"]=aCollection;
  1492. _st(aCollection)._do_((function(each){
  1493. return smalltalk.withContext(function($ctx2) {
  1494. return _st(each)._parent_(self);
  1495. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  1496. return self}, function($ctx1) {$ctx1.fill(self,"arguments:",{aCollection:aCollection},globals.SendNode)})},
  1497. args: ["aCollection"],
  1498. source: "arguments: aCollection\x0a\x09arguments := aCollection.\x0a\x09aCollection do: [ :each | each parent: self ]",
  1499. messageSends: ["do:", "parent:"],
  1500. referencedClasses: []
  1501. }),
  1502. globals.SendNode);
  1503. smalltalk.addMethod(
  1504. smalltalk.method({
  1505. selector: "cascadeNodeWithMessages:",
  1506. protocol: 'accessing',
  1507. fn: function (aCollection){
  1508. var self=this;
  1509. var first;
  1510. function $SendNode(){return globals.SendNode||(typeof SendNode=="undefined"?nil:SendNode)}
  1511. function $CascadeNode(){return globals.CascadeNode||(typeof CascadeNode=="undefined"?nil:CascadeNode)}
  1512. function $Array(){return globals.Array||(typeof Array=="undefined"?nil:Array)}
  1513. return smalltalk.withContext(function($ctx1) {
  1514. var $1,$2,$4,$5,$3;
  1515. $1=_st($SendNode())._new();
  1516. $ctx1.sendIdx["new"]=1;
  1517. _st($1)._selector_(self._selector());
  1518. _st($1)._arguments_(self._arguments());
  1519. $2=_st($1)._yourself();
  1520. $ctx1.sendIdx["yourself"]=1;
  1521. first=$2;
  1522. $4=_st($CascadeNode())._new();
  1523. _st($4)._receiver_(self._receiver());
  1524. _st($4)._nodes_(_st(_st($Array())._with_(first)).__comma(aCollection));
  1525. $5=_st($4)._yourself();
  1526. $3=$5;
  1527. return $3;
  1528. }, function($ctx1) {$ctx1.fill(self,"cascadeNodeWithMessages:",{aCollection:aCollection,first:first},globals.SendNode)})},
  1529. args: ["aCollection"],
  1530. source: "cascadeNodeWithMessages: aCollection\x0a\x09| first |\x0a\x09first := SendNode new\x0a\x09\x09selector: self selector;\x0a\x09\x09arguments: self arguments;\x0a\x09\x09yourself.\x0a\x09^ CascadeNode new\x0a\x09\x09receiver: self receiver;\x0a\x09\x09nodes: (Array with: first), aCollection;\x0a\x09\x09yourself",
  1531. messageSends: ["selector:", "new", "selector", "arguments:", "arguments", "yourself", "receiver:", "receiver", "nodes:", ",", "with:"],
  1532. referencedClasses: ["SendNode", "CascadeNode", "Array"]
  1533. }),
  1534. globals.SendNode);
  1535. smalltalk.addMethod(
  1536. smalltalk.method({
  1537. selector: "index",
  1538. protocol: 'accessing',
  1539. fn: function (){
  1540. var self=this;
  1541. var $1;
  1542. $1=self["@index"];
  1543. return $1;
  1544. },
  1545. args: [],
  1546. source: "index\x0a\x09^ index",
  1547. messageSends: [],
  1548. referencedClasses: []
  1549. }),
  1550. globals.SendNode);
  1551. smalltalk.addMethod(
  1552. smalltalk.method({
  1553. selector: "index:",
  1554. protocol: 'accessing',
  1555. fn: function (anInteger){
  1556. var self=this;
  1557. self["@index"]=anInteger;
  1558. return self},
  1559. args: ["anInteger"],
  1560. source: "index: anInteger\x0a\x09index := anInteger",
  1561. messageSends: [],
  1562. referencedClasses: []
  1563. }),
  1564. globals.SendNode);
  1565. smalltalk.addMethod(
  1566. smalltalk.method({
  1567. selector: "isCascadeSendNode",
  1568. protocol: 'testing',
  1569. fn: function (){
  1570. var self=this;
  1571. return smalltalk.withContext(function($ctx1) {
  1572. var $1;
  1573. $1=_st(self._parent())._isCascadeNode();
  1574. return $1;
  1575. }, function($ctx1) {$ctx1.fill(self,"isCascadeSendNode",{},globals.SendNode)})},
  1576. args: [],
  1577. source: "isCascadeSendNode\x0a\x09^ self parent isCascadeNode",
  1578. messageSends: ["isCascadeNode", "parent"],
  1579. referencedClasses: []
  1580. }),
  1581. globals.SendNode);
  1582. smalltalk.addMethod(
  1583. smalltalk.method({
  1584. selector: "isSendNode",
  1585. protocol: 'testing',
  1586. fn: function (){
  1587. var self=this;
  1588. return true;
  1589. },
  1590. args: [],
  1591. source: "isSendNode\x0a\x09^ true",
  1592. messageSends: [],
  1593. referencedClasses: []
  1594. }),
  1595. globals.SendNode);
  1596. smalltalk.addMethod(
  1597. smalltalk.method({
  1598. selector: "nodes",
  1599. protocol: 'accessing',
  1600. fn: function (){
  1601. var self=this;
  1602. function $Array(){return globals.Array||(typeof Array=="undefined"?nil:Array)}
  1603. return smalltalk.withContext(function($ctx1) {
  1604. var $1,$3,$2,$5,$6,$4;
  1605. $1=self._receiver();
  1606. $ctx1.sendIdx["receiver"]=1;
  1607. if(($receiver = $1) == nil || $receiver == null){
  1608. $3=self._arguments();
  1609. $ctx1.sendIdx["arguments"]=1;
  1610. $2=_st($3)._copy();
  1611. return $2;
  1612. } else {
  1613. $1;
  1614. };
  1615. $5=_st($Array())._with_(self._receiver());
  1616. _st($5)._addAll_(self._arguments());
  1617. $6=_st($5)._yourself();
  1618. $4=$6;
  1619. return $4;
  1620. }, function($ctx1) {$ctx1.fill(self,"nodes",{},globals.SendNode)})},
  1621. args: [],
  1622. source: "nodes\x0a\x09self receiver ifNil: [ ^ self arguments copy ].\x0a\x09\x0a\x09^ (Array with: self receiver)\x0a\x09\x09addAll: self arguments;\x0a\x09\x09yourself",
  1623. messageSends: ["ifNil:", "receiver", "copy", "arguments", "addAll:", "with:", "yourself"],
  1624. referencedClasses: ["Array"]
  1625. }),
  1626. globals.SendNode);
  1627. smalltalk.addMethod(
  1628. smalltalk.method({
  1629. selector: "receiver",
  1630. protocol: 'accessing',
  1631. fn: function (){
  1632. var self=this;
  1633. var $1;
  1634. $1=self["@receiver"];
  1635. return $1;
  1636. },
  1637. args: [],
  1638. source: "receiver\x0a\x09^ receiver",
  1639. messageSends: [],
  1640. referencedClasses: []
  1641. }),
  1642. globals.SendNode);
  1643. smalltalk.addMethod(
  1644. smalltalk.method({
  1645. selector: "receiver:",
  1646. protocol: 'accessing',
  1647. fn: function (aNode){
  1648. var self=this;
  1649. return smalltalk.withContext(function($ctx1) {
  1650. var $1;
  1651. self["@receiver"]=aNode;
  1652. $1=_st(aNode)._isNode();
  1653. if(smalltalk.assert($1)){
  1654. _st(aNode)._parent_(self);
  1655. };
  1656. return self}, function($ctx1) {$ctx1.fill(self,"receiver:",{aNode:aNode},globals.SendNode)})},
  1657. args: ["aNode"],
  1658. source: "receiver: aNode\x0a\x09receiver := aNode.\x0a\x09aNode isNode ifTrue: [\x0a\x09\x09aNode parent: self ]",
  1659. messageSends: ["ifTrue:", "isNode", "parent:"],
  1660. referencedClasses: []
  1661. }),
  1662. globals.SendNode);
  1663. smalltalk.addMethod(
  1664. smalltalk.method({
  1665. selector: "requiresSmalltalkContext",
  1666. protocol: 'testing',
  1667. fn: function (){
  1668. var self=this;
  1669. return true;
  1670. },
  1671. args: [],
  1672. source: "requiresSmalltalkContext\x0a\x09^ true",
  1673. messageSends: [],
  1674. referencedClasses: []
  1675. }),
  1676. globals.SendNode);
  1677. smalltalk.addMethod(
  1678. smalltalk.method({
  1679. selector: "selector",
  1680. protocol: 'accessing',
  1681. fn: function (){
  1682. var self=this;
  1683. var $1;
  1684. $1=self["@selector"];
  1685. return $1;
  1686. },
  1687. args: [],
  1688. source: "selector\x0a\x09^ selector",
  1689. messageSends: [],
  1690. referencedClasses: []
  1691. }),
  1692. globals.SendNode);
  1693. smalltalk.addMethod(
  1694. smalltalk.method({
  1695. selector: "selector:",
  1696. protocol: 'accessing',
  1697. fn: function (aString){
  1698. var self=this;
  1699. self["@selector"]=aString;
  1700. return self},
  1701. args: ["aString"],
  1702. source: "selector: aString\x0a\x09selector := aString",
  1703. messageSends: [],
  1704. referencedClasses: []
  1705. }),
  1706. globals.SendNode);
  1707. smalltalk.addMethod(
  1708. smalltalk.method({
  1709. selector: "shouldBeAliased",
  1710. protocol: 'testing',
  1711. fn: function (){
  1712. var self=this;
  1713. var sends;
  1714. return smalltalk.withContext(function($ctx1) {
  1715. var $1;
  1716. sends=_st(_st(_st(self._method())._sendIndexes())._at_(self._selector()))._size();
  1717. $1=_st(globals.SendNode.superclass.fn.prototype._shouldBeAliased.apply(_st(self), []))._or_((function(){
  1718. return smalltalk.withContext(function($ctx2) {
  1719. return _st(_st(_st(sends).__gt((1)))._and_((function(){
  1720. return smalltalk.withContext(function($ctx3) {
  1721. return _st(self._index()).__lt(sends);
  1722. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)})})))._and_((function(){
  1723. return smalltalk.withContext(function($ctx3) {
  1724. return self._isReferenced();
  1725. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,3)})}));
  1726. $ctx2.sendIdx["and:"]=1;
  1727. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  1728. return $1;
  1729. }, function($ctx1) {$ctx1.fill(self,"shouldBeAliased",{sends:sends},globals.SendNode)})},
  1730. args: [],
  1731. source: "shouldBeAliased\x0a\x09\x22Because we keep track of send indexes, some send nodes need additional care for aliasing. \x0a\x09See IRJSVisitor >> visitIRSend:\x22\x0a\x09\x0a\x09| sends |\x0a\x09\x0a\x09sends := (self method sendIndexes at: self selector) size.\x0a\x09\x0a\x09^ super shouldBeAliased or: [\x0a\x09\x09(sends > 1 and: [ self index < sends ]) and: [ self isReferenced ] ]",
  1732. messageSends: ["size", "at:", "sendIndexes", "method", "selector", "or:", "shouldBeAliased", "and:", ">", "<", "index", "isReferenced"],
  1733. referencedClasses: []
  1734. }),
  1735. globals.SendNode);
  1736. smalltalk.addMethod(
  1737. smalltalk.method({
  1738. selector: "stopOnStepping",
  1739. protocol: 'testing',
  1740. fn: function (){
  1741. var self=this;
  1742. return true;
  1743. },
  1744. args: [],
  1745. source: "stopOnStepping\x0a\x09^ true",
  1746. messageSends: [],
  1747. referencedClasses: []
  1748. }),
  1749. globals.SendNode);
  1750. smalltalk.addMethod(
  1751. smalltalk.method({
  1752. selector: "superSend",
  1753. protocol: 'accessing',
  1754. fn: function (){
  1755. var self=this;
  1756. return smalltalk.withContext(function($ctx1) {
  1757. var $2,$1;
  1758. $2=self["@superSend"];
  1759. if(($receiver = $2) == nil || $receiver == null){
  1760. $1=false;
  1761. } else {
  1762. $1=$2;
  1763. };
  1764. return $1;
  1765. }, function($ctx1) {$ctx1.fill(self,"superSend",{},globals.SendNode)})},
  1766. args: [],
  1767. source: "superSend\x0a\x09^ superSend ifNil: [ false ]",
  1768. messageSends: ["ifNil:"],
  1769. referencedClasses: []
  1770. }),
  1771. globals.SendNode);
  1772. smalltalk.addMethod(
  1773. smalltalk.method({
  1774. selector: "superSend:",
  1775. protocol: 'accessing',
  1776. fn: function (aBoolean){
  1777. var self=this;
  1778. self["@superSend"]=aBoolean;
  1779. return self},
  1780. args: ["aBoolean"],
  1781. source: "superSend: aBoolean\x0a\x09superSend := aBoolean",
  1782. messageSends: [],
  1783. referencedClasses: []
  1784. }),
  1785. globals.SendNode);
  1786. smalltalk.addMethod(
  1787. smalltalk.method({
  1788. selector: "valueForReceiver:",
  1789. protocol: 'accessing',
  1790. fn: function (anObject){
  1791. var self=this;
  1792. function $SendNode(){return globals.SendNode||(typeof SendNode=="undefined"?nil:SendNode)}
  1793. return smalltalk.withContext(function($ctx1) {
  1794. var $2,$3,$5,$4,$6,$1;
  1795. $2=_st($SendNode())._new();
  1796. _st($2)._position_(self._position());
  1797. $3=$2;
  1798. $5=self._receiver();
  1799. $ctx1.sendIdx["receiver"]=1;
  1800. if(($receiver = $5) == nil || $receiver == null){
  1801. $4=anObject;
  1802. } else {
  1803. $4=_st(self._receiver())._valueForReceiver_(anObject);
  1804. };
  1805. _st($3)._receiver_($4);
  1806. _st($2)._selector_(self._selector());
  1807. _st($2)._arguments_(self._arguments());
  1808. $6=_st($2)._yourself();
  1809. $1=$6;
  1810. return $1;
  1811. }, function($ctx1) {$ctx1.fill(self,"valueForReceiver:",{anObject:anObject},globals.SendNode)})},
  1812. args: ["anObject"],
  1813. source: "valueForReceiver: anObject\x0a\x09^ SendNode new\x0a\x09\x09position: self position;\x0a\x09\x09receiver: (self receiver\x0a\x09\x09ifNil: [ anObject ] \x0a\x09\x09ifNotNil: [ self receiver valueForReceiver: anObject ]);\x0a\x09\x09selector: self selector;\x0a\x09\x09arguments: self arguments;\x0a\x09\x09yourself",
  1814. messageSends: ["position:", "new", "position", "receiver:", "ifNil:ifNotNil:", "receiver", "valueForReceiver:", "selector:", "selector", "arguments:", "arguments", "yourself"],
  1815. referencedClasses: ["SendNode"]
  1816. }),
  1817. globals.SendNode);
  1818. smalltalk.addClass('SequenceNode', globals.Node, ['temps', 'scope'], 'Compiler-AST');
  1819. globals.SequenceNode.comment="I represent an sequence node. A sequence represent a set of instructions inside the same scope (the method scope or a block scope).";
  1820. smalltalk.addMethod(
  1821. smalltalk.method({
  1822. selector: "accept:",
  1823. protocol: 'visiting',
  1824. fn: function (aVisitor){
  1825. var self=this;
  1826. return smalltalk.withContext(function($ctx1) {
  1827. var $1;
  1828. $1=_st(aVisitor)._visitSequenceNode_(self);
  1829. return $1;
  1830. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.SequenceNode)})},
  1831. args: ["aVisitor"],
  1832. source: "accept: aVisitor\x0a\x09^ aVisitor visitSequenceNode: self",
  1833. messageSends: ["visitSequenceNode:"],
  1834. referencedClasses: []
  1835. }),
  1836. globals.SequenceNode);
  1837. smalltalk.addMethod(
  1838. smalltalk.method({
  1839. selector: "asBlockSequenceNode",
  1840. protocol: 'converting',
  1841. fn: function (){
  1842. var self=this;
  1843. function $BlockSequenceNode(){return globals.BlockSequenceNode||(typeof BlockSequenceNode=="undefined"?nil:BlockSequenceNode)}
  1844. return smalltalk.withContext(function($ctx1) {
  1845. var $2,$3,$1;
  1846. $2=_st($BlockSequenceNode())._new();
  1847. _st($2)._position_(self._position());
  1848. _st($2)._nodes_(self._nodes());
  1849. _st($2)._temps_(self._temps());
  1850. $3=_st($2)._yourself();
  1851. $1=$3;
  1852. return $1;
  1853. }, function($ctx1) {$ctx1.fill(self,"asBlockSequenceNode",{},globals.SequenceNode)})},
  1854. args: [],
  1855. source: "asBlockSequenceNode\x0a\x09^ BlockSequenceNode new\x0a\x09\x09position: self position;\x0a\x09\x09nodes: self nodes;\x0a\x09\x09temps: self temps;\x0a\x09\x09yourself",
  1856. messageSends: ["position:", "new", "position", "nodes:", "nodes", "temps:", "temps", "yourself"],
  1857. referencedClasses: ["BlockSequenceNode"]
  1858. }),
  1859. globals.SequenceNode);
  1860. smalltalk.addMethod(
  1861. smalltalk.method({
  1862. selector: "isSequenceNode",
  1863. protocol: 'testing',
  1864. fn: function (){
  1865. var self=this;
  1866. return true;
  1867. },
  1868. args: [],
  1869. source: "isSequenceNode\x0a\x09^ true",
  1870. messageSends: [],
  1871. referencedClasses: []
  1872. }),
  1873. globals.SequenceNode);
  1874. smalltalk.addMethod(
  1875. smalltalk.method({
  1876. selector: "scope",
  1877. protocol: 'accessing',
  1878. fn: function (){
  1879. var self=this;
  1880. var $1;
  1881. $1=self["@scope"];
  1882. return $1;
  1883. },
  1884. args: [],
  1885. source: "scope\x0a\x09^ scope",
  1886. messageSends: [],
  1887. referencedClasses: []
  1888. }),
  1889. globals.SequenceNode);
  1890. smalltalk.addMethod(
  1891. smalltalk.method({
  1892. selector: "scope:",
  1893. protocol: 'accessing',
  1894. fn: function (aLexicalScope){
  1895. var self=this;
  1896. self["@scope"]=aLexicalScope;
  1897. return self},
  1898. args: ["aLexicalScope"],
  1899. source: "scope: aLexicalScope\x0a\x09scope := aLexicalScope",
  1900. messageSends: [],
  1901. referencedClasses: []
  1902. }),
  1903. globals.SequenceNode);
  1904. smalltalk.addMethod(
  1905. smalltalk.method({
  1906. selector: "temps",
  1907. protocol: 'accessing',
  1908. fn: function (){
  1909. var self=this;
  1910. return smalltalk.withContext(function($ctx1) {
  1911. var $2,$1;
  1912. $2=self["@temps"];
  1913. if(($receiver = $2) == nil || $receiver == null){
  1914. $1=[];
  1915. } else {
  1916. $1=$2;
  1917. };
  1918. return $1;
  1919. }, function($ctx1) {$ctx1.fill(self,"temps",{},globals.SequenceNode)})},
  1920. args: [],
  1921. source: "temps\x0a\x09^ temps ifNil: [ #() ]",
  1922. messageSends: ["ifNil:"],
  1923. referencedClasses: []
  1924. }),
  1925. globals.SequenceNode);
  1926. smalltalk.addMethod(
  1927. smalltalk.method({
  1928. selector: "temps:",
  1929. protocol: 'accessing',
  1930. fn: function (aCollection){
  1931. var self=this;
  1932. self["@temps"]=aCollection;
  1933. return self},
  1934. args: ["aCollection"],
  1935. source: "temps: aCollection\x0a\x09temps := aCollection",
  1936. messageSends: [],
  1937. referencedClasses: []
  1938. }),
  1939. globals.SequenceNode);
  1940. smalltalk.addClass('BlockSequenceNode', globals.SequenceNode, [], 'Compiler-AST');
  1941. globals.BlockSequenceNode.comment="I represent an special sequence node for block scopes.";
  1942. smalltalk.addMethod(
  1943. smalltalk.method({
  1944. selector: "accept:",
  1945. protocol: 'visiting',
  1946. fn: function (aVisitor){
  1947. var self=this;
  1948. return smalltalk.withContext(function($ctx1) {
  1949. var $1;
  1950. $1=_st(aVisitor)._visitBlockSequenceNode_(self);
  1951. return $1;
  1952. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.BlockSequenceNode)})},
  1953. args: ["aVisitor"],
  1954. source: "accept: aVisitor\x0a\x09^ aVisitor visitBlockSequenceNode: self",
  1955. messageSends: ["visitBlockSequenceNode:"],
  1956. referencedClasses: []
  1957. }),
  1958. globals.BlockSequenceNode);
  1959. smalltalk.addMethod(
  1960. smalltalk.method({
  1961. selector: "isBlockSequenceNode",
  1962. protocol: 'testing',
  1963. fn: function (){
  1964. var self=this;
  1965. return true;
  1966. },
  1967. args: [],
  1968. source: "isBlockSequenceNode\x0a\x09^ true",
  1969. messageSends: [],
  1970. referencedClasses: []
  1971. }),
  1972. globals.BlockSequenceNode);
  1973. smalltalk.addClass('ValueNode', globals.Node, ['value'], 'Compiler-AST');
  1974. globals.ValueNode.comment="I represent a value node.";
  1975. smalltalk.addMethod(
  1976. smalltalk.method({
  1977. selector: "accept:",
  1978. protocol: 'visiting',
  1979. fn: function (aVisitor){
  1980. var self=this;
  1981. return smalltalk.withContext(function($ctx1) {
  1982. var $1;
  1983. $1=_st(aVisitor)._visitValueNode_(self);
  1984. return $1;
  1985. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.ValueNode)})},
  1986. args: ["aVisitor"],
  1987. source: "accept: aVisitor\x0a\x09^ aVisitor visitValueNode: self",
  1988. messageSends: ["visitValueNode:"],
  1989. referencedClasses: []
  1990. }),
  1991. globals.ValueNode);
  1992. smalltalk.addMethod(
  1993. smalltalk.method({
  1994. selector: "isImmutable",
  1995. protocol: 'testing',
  1996. fn: function (){
  1997. var self=this;
  1998. return smalltalk.withContext(function($ctx1) {
  1999. var $1;
  2000. $1=_st(self._value())._isImmutable();
  2001. return $1;
  2002. }, function($ctx1) {$ctx1.fill(self,"isImmutable",{},globals.ValueNode)})},
  2003. args: [],
  2004. source: "isImmutable\x0a\x09^ self value isImmutable",
  2005. messageSends: ["isImmutable", "value"],
  2006. referencedClasses: []
  2007. }),
  2008. globals.ValueNode);
  2009. smalltalk.addMethod(
  2010. smalltalk.method({
  2011. selector: "isValueNode",
  2012. protocol: 'testing',
  2013. fn: function (){
  2014. var self=this;
  2015. return true;
  2016. },
  2017. args: [],
  2018. source: "isValueNode\x0a\x09^ true",
  2019. messageSends: [],
  2020. referencedClasses: []
  2021. }),
  2022. globals.ValueNode);
  2023. smalltalk.addMethod(
  2024. smalltalk.method({
  2025. selector: "value",
  2026. protocol: 'accessing',
  2027. fn: function (){
  2028. var self=this;
  2029. var $1;
  2030. $1=self["@value"];
  2031. return $1;
  2032. },
  2033. args: [],
  2034. source: "value\x0a\x09^ value",
  2035. messageSends: [],
  2036. referencedClasses: []
  2037. }),
  2038. globals.ValueNode);
  2039. smalltalk.addMethod(
  2040. smalltalk.method({
  2041. selector: "value:",
  2042. protocol: 'accessing',
  2043. fn: function (anObject){
  2044. var self=this;
  2045. self["@value"]=anObject;
  2046. return self},
  2047. args: ["anObject"],
  2048. source: "value: anObject\x0a\x09value := anObject",
  2049. messageSends: [],
  2050. referencedClasses: []
  2051. }),
  2052. globals.ValueNode);
  2053. smalltalk.addClass('VariableNode', globals.ValueNode, ['assigned', 'binding'], 'Compiler-AST');
  2054. globals.VariableNode.comment="I represent an variable node.";
  2055. smalltalk.addMethod(
  2056. smalltalk.method({
  2057. selector: "accept:",
  2058. protocol: 'visiting',
  2059. fn: function (aVisitor){
  2060. var self=this;
  2061. return smalltalk.withContext(function($ctx1) {
  2062. var $1;
  2063. $1=_st(aVisitor)._visitVariableNode_(self);
  2064. return $1;
  2065. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.VariableNode)})},
  2066. args: ["aVisitor"],
  2067. source: "accept: aVisitor\x0a\x09^ aVisitor visitVariableNode: self",
  2068. messageSends: ["visitVariableNode:"],
  2069. referencedClasses: []
  2070. }),
  2071. globals.VariableNode);
  2072. smalltalk.addMethod(
  2073. smalltalk.method({
  2074. selector: "alias",
  2075. protocol: 'accessing',
  2076. fn: function (){
  2077. var self=this;
  2078. return smalltalk.withContext(function($ctx1) {
  2079. var $1;
  2080. $1=_st(self._binding())._alias();
  2081. return $1;
  2082. }, function($ctx1) {$ctx1.fill(self,"alias",{},globals.VariableNode)})},
  2083. args: [],
  2084. source: "alias\x0a\x09^ self binding alias",
  2085. messageSends: ["alias", "binding"],
  2086. referencedClasses: []
  2087. }),
  2088. globals.VariableNode);
  2089. smalltalk.addMethod(
  2090. smalltalk.method({
  2091. selector: "assigned",
  2092. protocol: 'accessing',
  2093. fn: function (){
  2094. var self=this;
  2095. return smalltalk.withContext(function($ctx1) {
  2096. var $2,$1;
  2097. $2=self["@assigned"];
  2098. if(($receiver = $2) == nil || $receiver == null){
  2099. $1=false;
  2100. } else {
  2101. $1=$2;
  2102. };
  2103. return $1;
  2104. }, function($ctx1) {$ctx1.fill(self,"assigned",{},globals.VariableNode)})},
  2105. args: [],
  2106. source: "assigned\x0a\x09^ assigned ifNil: [ false ]",
  2107. messageSends: ["ifNil:"],
  2108. referencedClasses: []
  2109. }),
  2110. globals.VariableNode);
  2111. smalltalk.addMethod(
  2112. smalltalk.method({
  2113. selector: "assigned:",
  2114. protocol: 'accessing',
  2115. fn: function (aBoolean){
  2116. var self=this;
  2117. self["@assigned"]=aBoolean;
  2118. return self},
  2119. args: ["aBoolean"],
  2120. source: "assigned: aBoolean\x0a\x09assigned := aBoolean",
  2121. messageSends: [],
  2122. referencedClasses: []
  2123. }),
  2124. globals.VariableNode);
  2125. smalltalk.addMethod(
  2126. smalltalk.method({
  2127. selector: "beAssigned",
  2128. protocol: 'accessing',
  2129. fn: function (){
  2130. var self=this;
  2131. return smalltalk.withContext(function($ctx1) {
  2132. _st(self._binding())._validateAssignment();
  2133. self["@assigned"]=true;
  2134. return self}, function($ctx1) {$ctx1.fill(self,"beAssigned",{},globals.VariableNode)})},
  2135. args: [],
  2136. source: "beAssigned\x0a\x09self binding validateAssignment.\x0a\x09assigned := true",
  2137. messageSends: ["validateAssignment", "binding"],
  2138. referencedClasses: []
  2139. }),
  2140. globals.VariableNode);
  2141. smalltalk.addMethod(
  2142. smalltalk.method({
  2143. selector: "binding",
  2144. protocol: 'accessing',
  2145. fn: function (){
  2146. var self=this;
  2147. var $1;
  2148. $1=self["@binding"];
  2149. return $1;
  2150. },
  2151. args: [],
  2152. source: "binding\x0a\x09^ binding",
  2153. messageSends: [],
  2154. referencedClasses: []
  2155. }),
  2156. globals.VariableNode);
  2157. smalltalk.addMethod(
  2158. smalltalk.method({
  2159. selector: "binding:",
  2160. protocol: 'accessing',
  2161. fn: function (aScopeVar){
  2162. var self=this;
  2163. self["@binding"]=aScopeVar;
  2164. return self},
  2165. args: ["aScopeVar"],
  2166. source: "binding: aScopeVar\x0a\x09binding := aScopeVar",
  2167. messageSends: [],
  2168. referencedClasses: []
  2169. }),
  2170. globals.VariableNode);
  2171. smalltalk.addMethod(
  2172. smalltalk.method({
  2173. selector: "isArgument",
  2174. protocol: 'testing',
  2175. fn: function (){
  2176. var self=this;
  2177. return smalltalk.withContext(function($ctx1) {
  2178. var $1;
  2179. $1=_st(self._binding())._isArgVar();
  2180. return $1;
  2181. }, function($ctx1) {$ctx1.fill(self,"isArgument",{},globals.VariableNode)})},
  2182. args: [],
  2183. source: "isArgument\x0a\x09^ self binding isArgVar",
  2184. messageSends: ["isArgVar", "binding"],
  2185. referencedClasses: []
  2186. }),
  2187. globals.VariableNode);
  2188. smalltalk.addMethod(
  2189. smalltalk.method({
  2190. selector: "isImmutable",
  2191. protocol: 'testing',
  2192. fn: function (){
  2193. var self=this;
  2194. return smalltalk.withContext(function($ctx1) {
  2195. var $1;
  2196. $1=_st(self._binding())._isImmutable();
  2197. return $1;
  2198. }, function($ctx1) {$ctx1.fill(self,"isImmutable",{},globals.VariableNode)})},
  2199. args: [],
  2200. source: "isImmutable\x0a\x09^ self binding isImmutable",
  2201. messageSends: ["isImmutable", "binding"],
  2202. referencedClasses: []
  2203. }),
  2204. globals.VariableNode);
  2205. smalltalk.addMethod(
  2206. smalltalk.method({
  2207. selector: "isVariableNode",
  2208. protocol: 'testing',
  2209. fn: function (){
  2210. var self=this;
  2211. return true;
  2212. },
  2213. args: [],
  2214. source: "isVariableNode\x0a\x09^ true",
  2215. messageSends: [],
  2216. referencedClasses: []
  2217. }),
  2218. globals.VariableNode);
  2219. smalltalk.addMethod(
  2220. smalltalk.method({
  2221. selector: "isNode",
  2222. protocol: '*Compiler-AST',
  2223. fn: function (){
  2224. var self=this;
  2225. return false;
  2226. },
  2227. args: [],
  2228. source: "isNode\x0a\x09^ false",
  2229. messageSends: [],
  2230. referencedClasses: []
  2231. }),
  2232. globals.Object);
  2233. smalltalk.addMethod(
  2234. smalltalk.method({
  2235. selector: "ast",
  2236. protocol: '*Compiler-AST',
  2237. fn: function (){
  2238. var self=this;
  2239. function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  2240. return smalltalk.withContext(function($ctx1) {
  2241. var $1,$2;
  2242. $1=self._source();
  2243. $ctx1.sendIdx["source"]=1;
  2244. _st($1)._ifEmpty_((function(){
  2245. return smalltalk.withContext(function($ctx2) {
  2246. return self._error_("Method source is empty");
  2247. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  2248. $2=_st($Smalltalk())._parse_(self._source());
  2249. return $2;
  2250. }, function($ctx1) {$ctx1.fill(self,"ast",{},globals.CompiledMethod)})},
  2251. args: [],
  2252. source: "ast\x0a\x09self source ifEmpty: [ self error: 'Method source is empty' ].\x0a\x09\x0a\x09^ Smalltalk parse: self source",
  2253. messageSends: ["ifEmpty:", "source", "error:", "parse:"],
  2254. referencedClasses: ["Smalltalk"]
  2255. }),
  2256. globals.CompiledMethod);
  2257. });