1
0

Compiler-AST.js 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416
  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', 'source', '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: "source",
  581. protocol: 'accessing',
  582. fn: function (){
  583. var self=this;
  584. return smalltalk.withContext(function($ctx1) {
  585. var $2,$1;
  586. $2=self["@source"];
  587. if(($receiver = $2) == nil || $receiver == null){
  588. $1="";
  589. } else {
  590. $1=$2;
  591. };
  592. return $1;
  593. }, function($ctx1) {$ctx1.fill(self,"source",{},globals.Node)})},
  594. args: [],
  595. source: "source\x0a\x09^ source ifNil: [ '' ]",
  596. messageSends: ["ifNil:"],
  597. referencedClasses: []
  598. }),
  599. globals.Node);
  600. smalltalk.addMethod(
  601. smalltalk.method({
  602. selector: "source:",
  603. protocol: 'accessing',
  604. fn: function (aString){
  605. var self=this;
  606. self["@source"]=aString;
  607. return self},
  608. args: ["aString"],
  609. source: "source: aString\x0a\x09source := aString",
  610. messageSends: [],
  611. referencedClasses: []
  612. }),
  613. globals.Node);
  614. smalltalk.addMethod(
  615. smalltalk.method({
  616. selector: "stopOnStepping",
  617. protocol: 'testing',
  618. fn: function (){
  619. var self=this;
  620. return false;
  621. },
  622. args: [],
  623. source: "stopOnStepping\x0a\x09^ false",
  624. messageSends: [],
  625. referencedClasses: []
  626. }),
  627. globals.Node);
  628. smalltalk.addMethod(
  629. smalltalk.method({
  630. selector: "subtreeNeedsAliasing",
  631. protocol: 'testing',
  632. fn: function (){
  633. var self=this;
  634. return smalltalk.withContext(function($ctx1) {
  635. var $1;
  636. $1=_st(_st(self._shouldBeAliased())._or_((function(){
  637. return smalltalk.withContext(function($ctx2) {
  638. return self._shouldBeInlined();
  639. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})})))._or_((function(){
  640. return smalltalk.withContext(function($ctx2) {
  641. return _st(self._nodes())._anySatisfy_((function(each){
  642. return smalltalk.withContext(function($ctx3) {
  643. return _st(each)._subtreeNeedsAliasing();
  644. }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx2,3)})}));
  645. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  646. $ctx1.sendIdx["or:"]=1;
  647. return $1;
  648. }, function($ctx1) {$ctx1.fill(self,"subtreeNeedsAliasing",{},globals.Node)})},
  649. args: [],
  650. source: "subtreeNeedsAliasing\x0a\x09^ (self shouldBeAliased or: [ self shouldBeInlined ]) or: [\x0a\x09\x09self nodes anySatisfy: [ :each | each subtreeNeedsAliasing ] ]",
  651. messageSends: ["or:", "shouldBeAliased", "shouldBeInlined", "anySatisfy:", "nodes", "subtreeNeedsAliasing"],
  652. referencedClasses: []
  653. }),
  654. globals.Node);
  655. smalltalk.addClass('AssignmentNode', globals.Node, ['left', 'right'], 'Compiler-AST');
  656. globals.AssignmentNode.comment="I represent an assignment node.";
  657. smalltalk.addMethod(
  658. smalltalk.method({
  659. selector: "accept:",
  660. protocol: 'visiting',
  661. fn: function (aVisitor){
  662. var self=this;
  663. return smalltalk.withContext(function($ctx1) {
  664. var $1;
  665. $1=_st(aVisitor)._visitAssignmentNode_(self);
  666. return $1;
  667. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.AssignmentNode)})},
  668. args: ["aVisitor"],
  669. source: "accept: aVisitor\x0a\x09^ aVisitor visitAssignmentNode: self",
  670. messageSends: ["visitAssignmentNode:"],
  671. referencedClasses: []
  672. }),
  673. globals.AssignmentNode);
  674. smalltalk.addMethod(
  675. smalltalk.method({
  676. selector: "isAssignmentNode",
  677. protocol: 'testing',
  678. fn: function (){
  679. var self=this;
  680. return true;
  681. },
  682. args: [],
  683. source: "isAssignmentNode\x0a\x09^ true",
  684. messageSends: [],
  685. referencedClasses: []
  686. }),
  687. globals.AssignmentNode);
  688. smalltalk.addMethod(
  689. smalltalk.method({
  690. selector: "left",
  691. protocol: 'accessing',
  692. fn: function (){
  693. var self=this;
  694. var $1;
  695. $1=self["@left"];
  696. return $1;
  697. },
  698. args: [],
  699. source: "left\x0a\x09^ left",
  700. messageSends: [],
  701. referencedClasses: []
  702. }),
  703. globals.AssignmentNode);
  704. smalltalk.addMethod(
  705. smalltalk.method({
  706. selector: "left:",
  707. protocol: 'accessing',
  708. fn: function (aNode){
  709. var self=this;
  710. return smalltalk.withContext(function($ctx1) {
  711. self["@left"]=aNode;
  712. _st(aNode)._parent_(self);
  713. return self}, function($ctx1) {$ctx1.fill(self,"left:",{aNode:aNode},globals.AssignmentNode)})},
  714. args: ["aNode"],
  715. source: "left: aNode\x0a\x09left := aNode.\x0a\x09aNode parent: self",
  716. messageSends: ["parent:"],
  717. referencedClasses: []
  718. }),
  719. globals.AssignmentNode);
  720. smalltalk.addMethod(
  721. smalltalk.method({
  722. selector: "nodes",
  723. protocol: 'accessing',
  724. fn: function (){
  725. var self=this;
  726. function $Array(){return globals.Array||(typeof Array=="undefined"?nil:Array)}
  727. return smalltalk.withContext(function($ctx1) {
  728. var $1;
  729. $1=_st($Array())._with_with_(self._left(),self._right());
  730. return $1;
  731. }, function($ctx1) {$ctx1.fill(self,"nodes",{},globals.AssignmentNode)})},
  732. args: [],
  733. source: "nodes\x0a\x09^ Array with: self left with: self right",
  734. messageSends: ["with:with:", "left", "right"],
  735. referencedClasses: ["Array"]
  736. }),
  737. globals.AssignmentNode);
  738. smalltalk.addMethod(
  739. smalltalk.method({
  740. selector: "right",
  741. protocol: 'accessing',
  742. fn: function (){
  743. var self=this;
  744. var $1;
  745. $1=self["@right"];
  746. return $1;
  747. },
  748. args: [],
  749. source: "right\x0a\x09^ right",
  750. messageSends: [],
  751. referencedClasses: []
  752. }),
  753. globals.AssignmentNode);
  754. smalltalk.addMethod(
  755. smalltalk.method({
  756. selector: "right:",
  757. protocol: 'accessing',
  758. fn: function (aNode){
  759. var self=this;
  760. return smalltalk.withContext(function($ctx1) {
  761. self["@right"]=aNode;
  762. _st(aNode)._parent_(self);
  763. return self}, function($ctx1) {$ctx1.fill(self,"right:",{aNode:aNode},globals.AssignmentNode)})},
  764. args: ["aNode"],
  765. source: "right: aNode\x0a\x09right := aNode.\x0a\x09aNode parent: self",
  766. messageSends: ["parent:"],
  767. referencedClasses: []
  768. }),
  769. globals.AssignmentNode);
  770. smalltalk.addMethod(
  771. smalltalk.method({
  772. selector: "shouldBeAliased",
  773. protocol: 'testing',
  774. fn: function (){
  775. var self=this;
  776. return smalltalk.withContext(function($ctx1) {
  777. var $1;
  778. $1=_st(globals.AssignmentNode.superclass.fn.prototype._shouldBeAliased.apply(_st(self), []))._or_((function(){
  779. return smalltalk.withContext(function($ctx2) {
  780. return self._isReferenced();
  781. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  782. return $1;
  783. }, function($ctx1) {$ctx1.fill(self,"shouldBeAliased",{},globals.AssignmentNode)})},
  784. args: [],
  785. source: "shouldBeAliased\x0a\x09^ super shouldBeAliased or: [ self isReferenced ]",
  786. messageSends: ["or:", "shouldBeAliased", "isReferenced"],
  787. referencedClasses: []
  788. }),
  789. globals.AssignmentNode);
  790. smalltalk.addClass('BlockNode', globals.Node, ['parameters', 'scope'], 'Compiler-AST');
  791. globals.BlockNode.comment="I represent an block closure node.";
  792. smalltalk.addMethod(
  793. smalltalk.method({
  794. selector: "accept:",
  795. protocol: 'visiting',
  796. fn: function (aVisitor){
  797. var self=this;
  798. return smalltalk.withContext(function($ctx1) {
  799. var $1;
  800. $1=_st(aVisitor)._visitBlockNode_(self);
  801. return $1;
  802. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.BlockNode)})},
  803. args: ["aVisitor"],
  804. source: "accept: aVisitor\x0a\x09^ aVisitor visitBlockNode: self",
  805. messageSends: ["visitBlockNode:"],
  806. referencedClasses: []
  807. }),
  808. globals.BlockNode);
  809. smalltalk.addMethod(
  810. smalltalk.method({
  811. selector: "isBlockNode",
  812. protocol: 'testing',
  813. fn: function (){
  814. var self=this;
  815. return true;
  816. },
  817. args: [],
  818. source: "isBlockNode\x0a\x09^ true",
  819. messageSends: [],
  820. referencedClasses: []
  821. }),
  822. globals.BlockNode);
  823. smalltalk.addMethod(
  824. smalltalk.method({
  825. selector: "nextChild",
  826. protocol: 'accessing',
  827. fn: function (){
  828. var self=this;
  829. return self;
  830. },
  831. args: [],
  832. source: "nextChild\x0a\x09\x22Answer the receiver as we want to avoid eager evaluation\x22\x0a\x09\x0a\x09^ self",
  833. messageSends: [],
  834. referencedClasses: []
  835. }),
  836. globals.BlockNode);
  837. smalltalk.addMethod(
  838. smalltalk.method({
  839. selector: "nextNode:",
  840. protocol: 'accessing',
  841. fn: function (aNode){
  842. var self=this;
  843. return self;
  844. },
  845. args: ["aNode"],
  846. source: "nextNode: aNode\x0a\x09\x22Answer the receiver as we want to avoid eager evaluation\x22\x0a\x09\x0a\x09^ self",
  847. messageSends: [],
  848. referencedClasses: []
  849. }),
  850. globals.BlockNode);
  851. smalltalk.addMethod(
  852. smalltalk.method({
  853. selector: "parameters",
  854. protocol: 'accessing',
  855. fn: function (){
  856. var self=this;
  857. function $Array(){return globals.Array||(typeof Array=="undefined"?nil:Array)}
  858. return smalltalk.withContext(function($ctx1) {
  859. var $2,$1;
  860. $2=self["@parameters"];
  861. if(($receiver = $2) == nil || $receiver == null){
  862. self["@parameters"]=_st($Array())._new();
  863. $1=self["@parameters"];
  864. } else {
  865. $1=$2;
  866. };
  867. return $1;
  868. }, function($ctx1) {$ctx1.fill(self,"parameters",{},globals.BlockNode)})},
  869. args: [],
  870. source: "parameters\x0a\x09^ parameters ifNil: [ parameters := Array new ]",
  871. messageSends: ["ifNil:", "new"],
  872. referencedClasses: ["Array"]
  873. }),
  874. globals.BlockNode);
  875. smalltalk.addMethod(
  876. smalltalk.method({
  877. selector: "parameters:",
  878. protocol: 'accessing',
  879. fn: function (aCollection){
  880. var self=this;
  881. self["@parameters"]=aCollection;
  882. return self},
  883. args: ["aCollection"],
  884. source: "parameters: aCollection\x0a\x09parameters := aCollection",
  885. messageSends: [],
  886. referencedClasses: []
  887. }),
  888. globals.BlockNode);
  889. smalltalk.addMethod(
  890. smalltalk.method({
  891. selector: "scope",
  892. protocol: 'accessing',
  893. fn: function (){
  894. var self=this;
  895. var $1;
  896. $1=self["@scope"];
  897. return $1;
  898. },
  899. args: [],
  900. source: "scope\x0a\x09^ scope",
  901. messageSends: [],
  902. referencedClasses: []
  903. }),
  904. globals.BlockNode);
  905. smalltalk.addMethod(
  906. smalltalk.method({
  907. selector: "scope:",
  908. protocol: 'accessing',
  909. fn: function (aLexicalScope){
  910. var self=this;
  911. self["@scope"]=aLexicalScope;
  912. return self},
  913. args: ["aLexicalScope"],
  914. source: "scope: aLexicalScope\x0a\x09scope := aLexicalScope",
  915. messageSends: [],
  916. referencedClasses: []
  917. }),
  918. globals.BlockNode);
  919. smalltalk.addMethod(
  920. smalltalk.method({
  921. selector: "subtreeNeedsAliasing",
  922. protocol: 'testing',
  923. fn: function (){
  924. var self=this;
  925. return smalltalk.withContext(function($ctx1) {
  926. var $1;
  927. $1=_st(self._shouldBeAliased())._or_((function(){
  928. return smalltalk.withContext(function($ctx2) {
  929. return self._shouldBeInlined();
  930. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  931. return $1;
  932. }, function($ctx1) {$ctx1.fill(self,"subtreeNeedsAliasing",{},globals.BlockNode)})},
  933. args: [],
  934. source: "subtreeNeedsAliasing\x0a\x09^ self shouldBeAliased or: [ self shouldBeInlined ]",
  935. messageSends: ["or:", "shouldBeAliased", "shouldBeInlined"],
  936. referencedClasses: []
  937. }),
  938. globals.BlockNode);
  939. smalltalk.addClass('CascadeNode', globals.Node, ['receiver'], 'Compiler-AST');
  940. globals.CascadeNode.comment="I represent an cascade node.";
  941. smalltalk.addMethod(
  942. smalltalk.method({
  943. selector: "accept:",
  944. protocol: 'visiting',
  945. fn: function (aVisitor){
  946. var self=this;
  947. return smalltalk.withContext(function($ctx1) {
  948. var $1;
  949. $1=_st(aVisitor)._visitCascadeNode_(self);
  950. return $1;
  951. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.CascadeNode)})},
  952. args: ["aVisitor"],
  953. source: "accept: aVisitor\x0a\x09^ aVisitor visitCascadeNode: self",
  954. messageSends: ["visitCascadeNode:"],
  955. referencedClasses: []
  956. }),
  957. globals.CascadeNode);
  958. smalltalk.addMethod(
  959. smalltalk.method({
  960. selector: "isCascadeNode",
  961. protocol: 'testing',
  962. fn: function (){
  963. var self=this;
  964. return true;
  965. },
  966. args: [],
  967. source: "isCascadeNode\x0a\x09^ true",
  968. messageSends: [],
  969. referencedClasses: []
  970. }),
  971. globals.CascadeNode);
  972. smalltalk.addMethod(
  973. smalltalk.method({
  974. selector: "receiver",
  975. protocol: 'accessing',
  976. fn: function (){
  977. var self=this;
  978. var $1;
  979. $1=self["@receiver"];
  980. return $1;
  981. },
  982. args: [],
  983. source: "receiver\x0a\x09^ receiver",
  984. messageSends: [],
  985. referencedClasses: []
  986. }),
  987. globals.CascadeNode);
  988. smalltalk.addMethod(
  989. smalltalk.method({
  990. selector: "receiver:",
  991. protocol: 'accessing',
  992. fn: function (aNode){
  993. var self=this;
  994. self["@receiver"]=aNode;
  995. return self},
  996. args: ["aNode"],
  997. source: "receiver: aNode\x0a\x09receiver := aNode",
  998. messageSends: [],
  999. referencedClasses: []
  1000. }),
  1001. globals.CascadeNode);
  1002. smalltalk.addClass('DynamicArrayNode', globals.Node, [], 'Compiler-AST');
  1003. globals.DynamicArrayNode.comment="I represent an dynamic array node.";
  1004. smalltalk.addMethod(
  1005. smalltalk.method({
  1006. selector: "accept:",
  1007. protocol: 'visiting',
  1008. fn: function (aVisitor){
  1009. var self=this;
  1010. return smalltalk.withContext(function($ctx1) {
  1011. var $1;
  1012. $1=_st(aVisitor)._visitDynamicArrayNode_(self);
  1013. return $1;
  1014. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.DynamicArrayNode)})},
  1015. args: ["aVisitor"],
  1016. source: "accept: aVisitor\x0a\x09^ aVisitor visitDynamicArrayNode: self",
  1017. messageSends: ["visitDynamicArrayNode:"],
  1018. referencedClasses: []
  1019. }),
  1020. globals.DynamicArrayNode);
  1021. smalltalk.addClass('DynamicDictionaryNode', globals.Node, [], 'Compiler-AST');
  1022. globals.DynamicDictionaryNode.comment="I represent an dynamic dictionary node.";
  1023. smalltalk.addMethod(
  1024. smalltalk.method({
  1025. selector: "accept:",
  1026. protocol: 'visiting',
  1027. fn: function (aVisitor){
  1028. var self=this;
  1029. return smalltalk.withContext(function($ctx1) {
  1030. var $1;
  1031. $1=_st(aVisitor)._visitDynamicDictionaryNode_(self);
  1032. return $1;
  1033. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.DynamicDictionaryNode)})},
  1034. args: ["aVisitor"],
  1035. source: "accept: aVisitor\x0a\x09^ aVisitor visitDynamicDictionaryNode: self",
  1036. messageSends: ["visitDynamicDictionaryNode:"],
  1037. referencedClasses: []
  1038. }),
  1039. globals.DynamicDictionaryNode);
  1040. smalltalk.addClass('JSStatementNode', globals.Node, [], 'Compiler-AST');
  1041. globals.JSStatementNode.comment="I represent an JavaScript statement node.";
  1042. smalltalk.addMethod(
  1043. smalltalk.method({
  1044. selector: "accept:",
  1045. protocol: 'visiting',
  1046. fn: function (aVisitor){
  1047. var self=this;
  1048. return smalltalk.withContext(function($ctx1) {
  1049. var $1;
  1050. $1=_st(aVisitor)._visitJSStatementNode_(self);
  1051. return $1;
  1052. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.JSStatementNode)})},
  1053. args: ["aVisitor"],
  1054. source: "accept: aVisitor\x0a\x09^ aVisitor visitJSStatementNode: self",
  1055. messageSends: ["visitJSStatementNode:"],
  1056. referencedClasses: []
  1057. }),
  1058. globals.JSStatementNode);
  1059. smalltalk.addMethod(
  1060. smalltalk.method({
  1061. selector: "isJSStatementNode",
  1062. protocol: 'testing',
  1063. fn: function (){
  1064. var self=this;
  1065. return true;
  1066. },
  1067. args: [],
  1068. source: "isJSStatementNode\x0a\x09^ true",
  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. _st($2)._source_(self._source());
  1798. $3=$2;
  1799. $5=self._receiver();
  1800. $ctx1.sendIdx["receiver"]=1;
  1801. if(($receiver = $5) == nil || $receiver == null){
  1802. $4=anObject;
  1803. } else {
  1804. $4=_st(self._receiver())._valueForReceiver_(anObject);
  1805. };
  1806. _st($3)._receiver_($4);
  1807. _st($2)._selector_(self._selector());
  1808. _st($2)._arguments_(self._arguments());
  1809. $6=_st($2)._yourself();
  1810. $1=$6;
  1811. return $1;
  1812. }, function($ctx1) {$ctx1.fill(self,"valueForReceiver:",{anObject:anObject},globals.SendNode)})},
  1813. args: ["anObject"],
  1814. source: "valueForReceiver: anObject\x0a\x09^ SendNode new\x0a\x09\x09position: self position;\x0a\x09\x09source: self source;\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",
  1815. messageSends: ["position:", "new", "position", "source:", "source", "receiver:", "ifNil:ifNotNil:", "receiver", "valueForReceiver:", "selector:", "selector", "arguments:", "arguments", "yourself"],
  1816. referencedClasses: ["SendNode"]
  1817. }),
  1818. globals.SendNode);
  1819. smalltalk.addClass('SequenceNode', globals.Node, ['temps', 'scope'], 'Compiler-AST');
  1820. 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).";
  1821. smalltalk.addMethod(
  1822. smalltalk.method({
  1823. selector: "accept:",
  1824. protocol: 'visiting',
  1825. fn: function (aVisitor){
  1826. var self=this;
  1827. return smalltalk.withContext(function($ctx1) {
  1828. var $1;
  1829. $1=_st(aVisitor)._visitSequenceNode_(self);
  1830. return $1;
  1831. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.SequenceNode)})},
  1832. args: ["aVisitor"],
  1833. source: "accept: aVisitor\x0a\x09^ aVisitor visitSequenceNode: self",
  1834. messageSends: ["visitSequenceNode:"],
  1835. referencedClasses: []
  1836. }),
  1837. globals.SequenceNode);
  1838. smalltalk.addMethod(
  1839. smalltalk.method({
  1840. selector: "asBlockSequenceNode",
  1841. protocol: 'converting',
  1842. fn: function (){
  1843. var self=this;
  1844. function $BlockSequenceNode(){return globals.BlockSequenceNode||(typeof BlockSequenceNode=="undefined"?nil:BlockSequenceNode)}
  1845. return smalltalk.withContext(function($ctx1) {
  1846. var $2,$3,$1;
  1847. $2=_st($BlockSequenceNode())._new();
  1848. _st($2)._position_(self._position());
  1849. _st($2)._source_(self._source());
  1850. _st($2)._nodes_(self._nodes());
  1851. _st($2)._temps_(self._temps());
  1852. $3=_st($2)._yourself();
  1853. $1=$3;
  1854. return $1;
  1855. }, function($ctx1) {$ctx1.fill(self,"asBlockSequenceNode",{},globals.SequenceNode)})},
  1856. args: [],
  1857. source: "asBlockSequenceNode\x0a\x09^ BlockSequenceNode new\x0a\x09\x09position: self position;\x0a\x09\x09source: self source;\x0a\x09\x09nodes: self nodes;\x0a\x09\x09temps: self temps;\x0a\x09\x09yourself",
  1858. messageSends: ["position:", "new", "position", "source:", "source", "nodes:", "nodes", "temps:", "temps", "yourself"],
  1859. referencedClasses: ["BlockSequenceNode"]
  1860. }),
  1861. globals.SequenceNode);
  1862. smalltalk.addMethod(
  1863. smalltalk.method({
  1864. selector: "isSequenceNode",
  1865. protocol: 'testing',
  1866. fn: function (){
  1867. var self=this;
  1868. return true;
  1869. },
  1870. args: [],
  1871. source: "isSequenceNode\x0a\x09^ true",
  1872. messageSends: [],
  1873. referencedClasses: []
  1874. }),
  1875. globals.SequenceNode);
  1876. smalltalk.addMethod(
  1877. smalltalk.method({
  1878. selector: "scope",
  1879. protocol: 'accessing',
  1880. fn: function (){
  1881. var self=this;
  1882. var $1;
  1883. $1=self["@scope"];
  1884. return $1;
  1885. },
  1886. args: [],
  1887. source: "scope\x0a\x09^ scope",
  1888. messageSends: [],
  1889. referencedClasses: []
  1890. }),
  1891. globals.SequenceNode);
  1892. smalltalk.addMethod(
  1893. smalltalk.method({
  1894. selector: "scope:",
  1895. protocol: 'accessing',
  1896. fn: function (aLexicalScope){
  1897. var self=this;
  1898. self["@scope"]=aLexicalScope;
  1899. return self},
  1900. args: ["aLexicalScope"],
  1901. source: "scope: aLexicalScope\x0a\x09scope := aLexicalScope",
  1902. messageSends: [],
  1903. referencedClasses: []
  1904. }),
  1905. globals.SequenceNode);
  1906. smalltalk.addMethod(
  1907. smalltalk.method({
  1908. selector: "temps",
  1909. protocol: 'accessing',
  1910. fn: function (){
  1911. var self=this;
  1912. return smalltalk.withContext(function($ctx1) {
  1913. var $2,$1;
  1914. $2=self["@temps"];
  1915. if(($receiver = $2) == nil || $receiver == null){
  1916. $1=[];
  1917. } else {
  1918. $1=$2;
  1919. };
  1920. return $1;
  1921. }, function($ctx1) {$ctx1.fill(self,"temps",{},globals.SequenceNode)})},
  1922. args: [],
  1923. source: "temps\x0a\x09^ temps ifNil: [ #() ]",
  1924. messageSends: ["ifNil:"],
  1925. referencedClasses: []
  1926. }),
  1927. globals.SequenceNode);
  1928. smalltalk.addMethod(
  1929. smalltalk.method({
  1930. selector: "temps:",
  1931. protocol: 'accessing',
  1932. fn: function (aCollection){
  1933. var self=this;
  1934. self["@temps"]=aCollection;
  1935. return self},
  1936. args: ["aCollection"],
  1937. source: "temps: aCollection\x0a\x09temps := aCollection",
  1938. messageSends: [],
  1939. referencedClasses: []
  1940. }),
  1941. globals.SequenceNode);
  1942. smalltalk.addClass('BlockSequenceNode', globals.SequenceNode, [], 'Compiler-AST');
  1943. globals.BlockSequenceNode.comment="I represent an special sequence node for block scopes.";
  1944. smalltalk.addMethod(
  1945. smalltalk.method({
  1946. selector: "accept:",
  1947. protocol: 'visiting',
  1948. fn: function (aVisitor){
  1949. var self=this;
  1950. return smalltalk.withContext(function($ctx1) {
  1951. var $1;
  1952. $1=_st(aVisitor)._visitBlockSequenceNode_(self);
  1953. return $1;
  1954. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.BlockSequenceNode)})},
  1955. args: ["aVisitor"],
  1956. source: "accept: aVisitor\x0a\x09^ aVisitor visitBlockSequenceNode: self",
  1957. messageSends: ["visitBlockSequenceNode:"],
  1958. referencedClasses: []
  1959. }),
  1960. globals.BlockSequenceNode);
  1961. smalltalk.addMethod(
  1962. smalltalk.method({
  1963. selector: "isBlockSequenceNode",
  1964. protocol: 'testing',
  1965. fn: function (){
  1966. var self=this;
  1967. return true;
  1968. },
  1969. args: [],
  1970. source: "isBlockSequenceNode\x0a\x09^ true",
  1971. messageSends: [],
  1972. referencedClasses: []
  1973. }),
  1974. globals.BlockSequenceNode);
  1975. smalltalk.addClass('ValueNode', globals.Node, ['value'], 'Compiler-AST');
  1976. globals.ValueNode.comment="I represent a value node.";
  1977. smalltalk.addMethod(
  1978. smalltalk.method({
  1979. selector: "accept:",
  1980. protocol: 'visiting',
  1981. fn: function (aVisitor){
  1982. var self=this;
  1983. return smalltalk.withContext(function($ctx1) {
  1984. var $1;
  1985. $1=_st(aVisitor)._visitValueNode_(self);
  1986. return $1;
  1987. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.ValueNode)})},
  1988. args: ["aVisitor"],
  1989. source: "accept: aVisitor\x0a\x09^ aVisitor visitValueNode: self",
  1990. messageSends: ["visitValueNode:"],
  1991. referencedClasses: []
  1992. }),
  1993. globals.ValueNode);
  1994. smalltalk.addMethod(
  1995. smalltalk.method({
  1996. selector: "isImmutable",
  1997. protocol: 'testing',
  1998. fn: function (){
  1999. var self=this;
  2000. return smalltalk.withContext(function($ctx1) {
  2001. var $1;
  2002. $1=_st(self._value())._isImmutable();
  2003. return $1;
  2004. }, function($ctx1) {$ctx1.fill(self,"isImmutable",{},globals.ValueNode)})},
  2005. args: [],
  2006. source: "isImmutable\x0a\x09^ self value isImmutable",
  2007. messageSends: ["isImmutable", "value"],
  2008. referencedClasses: []
  2009. }),
  2010. globals.ValueNode);
  2011. smalltalk.addMethod(
  2012. smalltalk.method({
  2013. selector: "isValueNode",
  2014. protocol: 'testing',
  2015. fn: function (){
  2016. var self=this;
  2017. return true;
  2018. },
  2019. args: [],
  2020. source: "isValueNode\x0a\x09^ true",
  2021. messageSends: [],
  2022. referencedClasses: []
  2023. }),
  2024. globals.ValueNode);
  2025. smalltalk.addMethod(
  2026. smalltalk.method({
  2027. selector: "value",
  2028. protocol: 'accessing',
  2029. fn: function (){
  2030. var self=this;
  2031. var $1;
  2032. $1=self["@value"];
  2033. return $1;
  2034. },
  2035. args: [],
  2036. source: "value\x0a\x09^ value",
  2037. messageSends: [],
  2038. referencedClasses: []
  2039. }),
  2040. globals.ValueNode);
  2041. smalltalk.addMethod(
  2042. smalltalk.method({
  2043. selector: "value:",
  2044. protocol: 'accessing',
  2045. fn: function (anObject){
  2046. var self=this;
  2047. self["@value"]=anObject;
  2048. return self},
  2049. args: ["anObject"],
  2050. source: "value: anObject\x0a\x09value := anObject",
  2051. messageSends: [],
  2052. referencedClasses: []
  2053. }),
  2054. globals.ValueNode);
  2055. smalltalk.addClass('VariableNode', globals.ValueNode, ['assigned', 'binding'], 'Compiler-AST');
  2056. globals.VariableNode.comment="I represent an variable node.";
  2057. smalltalk.addMethod(
  2058. smalltalk.method({
  2059. selector: "accept:",
  2060. protocol: 'visiting',
  2061. fn: function (aVisitor){
  2062. var self=this;
  2063. return smalltalk.withContext(function($ctx1) {
  2064. var $1;
  2065. $1=_st(aVisitor)._visitVariableNode_(self);
  2066. return $1;
  2067. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.VariableNode)})},
  2068. args: ["aVisitor"],
  2069. source: "accept: aVisitor\x0a\x09^ aVisitor visitVariableNode: self",
  2070. messageSends: ["visitVariableNode:"],
  2071. referencedClasses: []
  2072. }),
  2073. globals.VariableNode);
  2074. smalltalk.addMethod(
  2075. smalltalk.method({
  2076. selector: "alias",
  2077. protocol: 'accessing',
  2078. fn: function (){
  2079. var self=this;
  2080. return smalltalk.withContext(function($ctx1) {
  2081. var $1;
  2082. $1=_st(self._binding())._alias();
  2083. return $1;
  2084. }, function($ctx1) {$ctx1.fill(self,"alias",{},globals.VariableNode)})},
  2085. args: [],
  2086. source: "alias\x0a\x09^ self binding alias",
  2087. messageSends: ["alias", "binding"],
  2088. referencedClasses: []
  2089. }),
  2090. globals.VariableNode);
  2091. smalltalk.addMethod(
  2092. smalltalk.method({
  2093. selector: "assigned",
  2094. protocol: 'accessing',
  2095. fn: function (){
  2096. var self=this;
  2097. return smalltalk.withContext(function($ctx1) {
  2098. var $2,$1;
  2099. $2=self["@assigned"];
  2100. if(($receiver = $2) == nil || $receiver == null){
  2101. $1=false;
  2102. } else {
  2103. $1=$2;
  2104. };
  2105. return $1;
  2106. }, function($ctx1) {$ctx1.fill(self,"assigned",{},globals.VariableNode)})},
  2107. args: [],
  2108. source: "assigned\x0a\x09^ assigned ifNil: [ false ]",
  2109. messageSends: ["ifNil:"],
  2110. referencedClasses: []
  2111. }),
  2112. globals.VariableNode);
  2113. smalltalk.addMethod(
  2114. smalltalk.method({
  2115. selector: "assigned:",
  2116. protocol: 'accessing',
  2117. fn: function (aBoolean){
  2118. var self=this;
  2119. self["@assigned"]=aBoolean;
  2120. return self},
  2121. args: ["aBoolean"],
  2122. source: "assigned: aBoolean\x0a\x09assigned := aBoolean",
  2123. messageSends: [],
  2124. referencedClasses: []
  2125. }),
  2126. globals.VariableNode);
  2127. smalltalk.addMethod(
  2128. smalltalk.method({
  2129. selector: "beAssigned",
  2130. protocol: 'accessing',
  2131. fn: function (){
  2132. var self=this;
  2133. return smalltalk.withContext(function($ctx1) {
  2134. _st(self._binding())._validateAssignment();
  2135. self["@assigned"]=true;
  2136. return self}, function($ctx1) {$ctx1.fill(self,"beAssigned",{},globals.VariableNode)})},
  2137. args: [],
  2138. source: "beAssigned\x0a\x09self binding validateAssignment.\x0a\x09assigned := true",
  2139. messageSends: ["validateAssignment", "binding"],
  2140. referencedClasses: []
  2141. }),
  2142. globals.VariableNode);
  2143. smalltalk.addMethod(
  2144. smalltalk.method({
  2145. selector: "binding",
  2146. protocol: 'accessing',
  2147. fn: function (){
  2148. var self=this;
  2149. var $1;
  2150. $1=self["@binding"];
  2151. return $1;
  2152. },
  2153. args: [],
  2154. source: "binding\x0a\x09^ binding",
  2155. messageSends: [],
  2156. referencedClasses: []
  2157. }),
  2158. globals.VariableNode);
  2159. smalltalk.addMethod(
  2160. smalltalk.method({
  2161. selector: "binding:",
  2162. protocol: 'accessing',
  2163. fn: function (aScopeVar){
  2164. var self=this;
  2165. self["@binding"]=aScopeVar;
  2166. return self},
  2167. args: ["aScopeVar"],
  2168. source: "binding: aScopeVar\x0a\x09binding := aScopeVar",
  2169. messageSends: [],
  2170. referencedClasses: []
  2171. }),
  2172. globals.VariableNode);
  2173. smalltalk.addMethod(
  2174. smalltalk.method({
  2175. selector: "isArgument",
  2176. protocol: 'testing',
  2177. fn: function (){
  2178. var self=this;
  2179. return smalltalk.withContext(function($ctx1) {
  2180. var $1;
  2181. $1=_st(self._binding())._isArgVar();
  2182. return $1;
  2183. }, function($ctx1) {$ctx1.fill(self,"isArgument",{},globals.VariableNode)})},
  2184. args: [],
  2185. source: "isArgument\x0a\x09^ self binding isArgVar",
  2186. messageSends: ["isArgVar", "binding"],
  2187. referencedClasses: []
  2188. }),
  2189. globals.VariableNode);
  2190. smalltalk.addMethod(
  2191. smalltalk.method({
  2192. selector: "isImmutable",
  2193. protocol: 'testing',
  2194. fn: function (){
  2195. var self=this;
  2196. return smalltalk.withContext(function($ctx1) {
  2197. var $1;
  2198. $1=_st(self._binding())._isImmutable();
  2199. return $1;
  2200. }, function($ctx1) {$ctx1.fill(self,"isImmutable",{},globals.VariableNode)})},
  2201. args: [],
  2202. source: "isImmutable\x0a\x09^ self binding isImmutable",
  2203. messageSends: ["isImmutable", "binding"],
  2204. referencedClasses: []
  2205. }),
  2206. globals.VariableNode);
  2207. smalltalk.addMethod(
  2208. smalltalk.method({
  2209. selector: "isVariableNode",
  2210. protocol: 'testing',
  2211. fn: function (){
  2212. var self=this;
  2213. return true;
  2214. },
  2215. args: [],
  2216. source: "isVariableNode\x0a\x09^ true",
  2217. messageSends: [],
  2218. referencedClasses: []
  2219. }),
  2220. globals.VariableNode);
  2221. smalltalk.addMethod(
  2222. smalltalk.method({
  2223. selector: "isNode",
  2224. protocol: '*Compiler-AST',
  2225. fn: function (){
  2226. var self=this;
  2227. return false;
  2228. },
  2229. args: [],
  2230. source: "isNode\x0a\x09^ false",
  2231. messageSends: [],
  2232. referencedClasses: []
  2233. }),
  2234. globals.Object);
  2235. smalltalk.addMethod(
  2236. smalltalk.method({
  2237. selector: "ast",
  2238. protocol: '*Compiler-AST',
  2239. fn: function (){
  2240. var self=this;
  2241. function $Smalltalk(){return globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  2242. return smalltalk.withContext(function($ctx1) {
  2243. var $1,$2;
  2244. $1=self._source();
  2245. $ctx1.sendIdx["source"]=1;
  2246. _st($1)._ifEmpty_((function(){
  2247. return smalltalk.withContext(function($ctx2) {
  2248. return self._error_("Method source is empty");
  2249. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  2250. $2=_st($Smalltalk())._parse_(self._source());
  2251. return $2;
  2252. }, function($ctx1) {$ctx1.fill(self,"ast",{},globals.CompiledMethod)})},
  2253. args: [],
  2254. source: "ast\x0a\x09self source ifEmpty: [ self error: 'Method source is empty' ].\x0a\x09\x0a\x09^ Smalltalk parse: self source",
  2255. messageSends: ["ifEmpty:", "source", "error:", "parse:"],
  2256. referencedClasses: ["Smalltalk"]
  2257. }),
  2258. globals.CompiledMethod);
  2259. });