Compiler-Semantic.deploy.js 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207
  1. smalltalk.addPackage('Compiler-Semantic', {});
  2. smalltalk.addClass('LexicalScope', smalltalk.Object, ['node', 'instruction', 'temps', 'args', 'outerScope'], 'Compiler-Semantic');
  3. smalltalk.addMethod(
  4. "_addArg_",
  5. smalltalk.method({
  6. selector: "addArg:",
  7. fn: function (aString) {
  8. var self = this;
  9. smalltalk.send(smalltalk.send(self, "_args", []), "_at_put_", [aString, smalltalk.send(smalltalk.ArgVar || ArgVar, "_on_", [aString])]);
  10. smalltalk.send(smalltalk.send(smalltalk.send(self, "_args", []), "_at_", [aString]), "_scope_", [self]);
  11. return self;
  12. }
  13. }),
  14. smalltalk.LexicalScope);
  15. smalltalk.addMethod(
  16. "_addTemp_",
  17. smalltalk.method({
  18. selector: "addTemp:",
  19. fn: function (aString) {
  20. var self = this;
  21. smalltalk.send(smalltalk.send(self, "_temps", []), "_at_put_", [aString, smalltalk.send(smalltalk.TempVar || TempVar, "_on_", [aString])]);
  22. smalltalk.send(smalltalk.send(smalltalk.send(self, "_temps", []), "_at_", [aString]), "_scope_", [self]);
  23. return self;
  24. }
  25. }),
  26. smalltalk.LexicalScope);
  27. smalltalk.addMethod(
  28. "_allVariableNames",
  29. smalltalk.method({
  30. selector: "allVariableNames",
  31. fn: function () {
  32. var self = this;
  33. var $1;
  34. $1 = smalltalk.send(smalltalk.send(smalltalk.send(self, "_args", []), "_keys", []), "__comma", [smalltalk.send(smalltalk.send(self, "_temps", []), "_keys", [])]);
  35. return $1;
  36. }
  37. }),
  38. smalltalk.LexicalScope);
  39. smalltalk.addMethod(
  40. "_args",
  41. smalltalk.method({
  42. selector: "args",
  43. fn: function () {
  44. var self = this;
  45. var $1;
  46. if (($receiver = self['@args']) == nil || $receiver == undefined) {
  47. self['@args'] = smalltalk.send(smalltalk.Dictionary || Dictionary, "_new", []);
  48. $1 = self['@args'];
  49. } else {
  50. $1 = self['@args'];
  51. }
  52. return $1;
  53. }
  54. }),
  55. smalltalk.LexicalScope);
  56. smalltalk.addMethod(
  57. "_bindingFor_",
  58. smalltalk.method({
  59. selector: "bindingFor:",
  60. fn: function (aStringOrNode) {
  61. var self = this;
  62. var $1;
  63. $1 = smalltalk.send(smalltalk.send(self, "_pseudoVars", []), "_at_ifAbsent_", [smalltalk.send(aStringOrNode, "_value", []), function () {return smalltalk.send(smalltalk.send(self, "_args", []), "_at_ifAbsent_", [smalltalk.send(aStringOrNode, "_value", []), function () {return smalltalk.send(smalltalk.send(self, "_temps", []), "_at_ifAbsent_", [smalltalk.send(aStringOrNode, "_value", []), function () {return nil;}]);}]);}]);
  64. return $1;
  65. }
  66. }),
  67. smalltalk.LexicalScope);
  68. smalltalk.addMethod(
  69. "_canInlineNonLocalReturns",
  70. smalltalk.method({
  71. selector: "canInlineNonLocalReturns",
  72. fn: function () {
  73. var self = this;
  74. var $1;
  75. $1 = smalltalk.send(smalltalk.send(self, "_isInlined", []), "_and_", [function () {return smalltalk.send(smalltalk.send(self, "_outerScope", []), "_canInlineNonLocalReturns", []);}]);
  76. return $1;
  77. }
  78. }),
  79. smalltalk.LexicalScope);
  80. smalltalk.addMethod(
  81. "_instruction",
  82. smalltalk.method({
  83. selector: "instruction",
  84. fn: function () {
  85. var self = this;
  86. return self['@instruction'];
  87. }
  88. }),
  89. smalltalk.LexicalScope);
  90. smalltalk.addMethod(
  91. "_instruction_",
  92. smalltalk.method({
  93. selector: "instruction:",
  94. fn: function (anIRInstruction) {
  95. var self = this;
  96. self['@instruction'] = anIRInstruction;
  97. return self;
  98. }
  99. }),
  100. smalltalk.LexicalScope);
  101. smalltalk.addMethod(
  102. "_isBlockScope",
  103. smalltalk.method({
  104. selector: "isBlockScope",
  105. fn: function () {
  106. var self = this;
  107. var $1;
  108. $1 = smalltalk.send(smalltalk.send(self, "_isMethodScope", []), "_not", []);
  109. return $1;
  110. }
  111. }),
  112. smalltalk.LexicalScope);
  113. smalltalk.addMethod(
  114. "_isInlined",
  115. smalltalk.method({
  116. selector: "isInlined",
  117. fn: function () {
  118. var self = this;
  119. var $1;
  120. $1 = smalltalk.send(smalltalk.send(self, "_instruction", []), "_isInlined", []);
  121. return $1;
  122. }
  123. }),
  124. smalltalk.LexicalScope);
  125. smalltalk.addMethod(
  126. "_isMethodScope",
  127. smalltalk.method({
  128. selector: "isMethodScope",
  129. fn: function () {
  130. var self = this;
  131. return false;
  132. }
  133. }),
  134. smalltalk.LexicalScope);
  135. smalltalk.addMethod(
  136. "_lookupVariable_",
  137. smalltalk.method({
  138. selector: "lookupVariable:",
  139. fn: function (aNode) {
  140. var self = this;
  141. var $1;
  142. var lookup;
  143. lookup = smalltalk.send(self, "_bindingFor_", [aNode]);
  144. if (($receiver = lookup) == nil || $receiver == undefined) {
  145. $1 = smalltalk.send(self, "_outerScope", []);
  146. if (($receiver = $1) == nil || $receiver == undefined) {
  147. lookup = $1;
  148. } else {
  149. lookup = smalltalk.send(smalltalk.send(self, "_outerScope", []), "_lookupVariable_", [aNode]);
  150. }
  151. } else {
  152. }
  153. return lookup;
  154. }
  155. }),
  156. smalltalk.LexicalScope);
  157. smalltalk.addMethod(
  158. "_methodScope",
  159. smalltalk.method({
  160. selector: "methodScope",
  161. fn: function () {
  162. var self = this;
  163. var $2, $1;
  164. $2 = smalltalk.send(self, "_outerScope", []);
  165. if (($receiver = $2) == nil || $receiver == undefined) {
  166. $1 = $2;
  167. } else {
  168. $1 = smalltalk.send(smalltalk.send(self, "_outerScope", []), "_methodScope", []);
  169. }
  170. return $1;
  171. }
  172. }),
  173. smalltalk.LexicalScope);
  174. smalltalk.addMethod(
  175. "_node",
  176. smalltalk.method({
  177. selector: "node",
  178. fn: function () {
  179. var self = this;
  180. return self['@node'];
  181. }
  182. }),
  183. smalltalk.LexicalScope);
  184. smalltalk.addMethod(
  185. "_node_",
  186. smalltalk.method({
  187. selector: "node:",
  188. fn: function (aNode) {
  189. var self = this;
  190. self['@node'] = aNode;
  191. return self;
  192. }
  193. }),
  194. smalltalk.LexicalScope);
  195. smalltalk.addMethod(
  196. "_outerScope",
  197. smalltalk.method({
  198. selector: "outerScope",
  199. fn: function () {
  200. var self = this;
  201. return self['@outerScope'];
  202. }
  203. }),
  204. smalltalk.LexicalScope);
  205. smalltalk.addMethod(
  206. "_outerScope_",
  207. smalltalk.method({
  208. selector: "outerScope:",
  209. fn: function (aLexicalScope) {
  210. var self = this;
  211. self['@outerScope'] = aLexicalScope;
  212. return self;
  213. }
  214. }),
  215. smalltalk.LexicalScope);
  216. smalltalk.addMethod(
  217. "_pseudoVars",
  218. smalltalk.method({
  219. selector: "pseudoVars",
  220. fn: function () {
  221. var self = this;
  222. var $1;
  223. $1 = smalltalk.send(smalltalk.send(self, "_methodScope", []), "_pseudoVars", []);
  224. return $1;
  225. }
  226. }),
  227. smalltalk.LexicalScope);
  228. smalltalk.addMethod(
  229. "_scopeLevel",
  230. smalltalk.method({
  231. selector: "scopeLevel",
  232. fn: function () {
  233. var self = this;
  234. var $3, $2, $1;
  235. $3 = smalltalk.send(self, "_outerScope", []);
  236. if (($receiver = $3) == nil || $receiver == undefined) {
  237. $2 = 0;
  238. } else {
  239. $2 = smalltalk.send(smalltalk.send(self, "_outerScope", []), "_scopeLevel", []);
  240. }
  241. $1 = smalltalk.send($2, "__plus", [1]);
  242. return $1;
  243. }
  244. }),
  245. smalltalk.LexicalScope);
  246. smalltalk.addMethod(
  247. "_temps",
  248. smalltalk.method({
  249. selector: "temps",
  250. fn: function () {
  251. var self = this;
  252. var $1;
  253. if (($receiver = self['@temps']) == nil || $receiver == undefined) {
  254. self['@temps'] = smalltalk.send(smalltalk.Dictionary || Dictionary, "_new", []);
  255. $1 = self['@temps'];
  256. } else {
  257. $1 = self['@temps'];
  258. }
  259. return $1;
  260. }
  261. }),
  262. smalltalk.LexicalScope);
  263. smalltalk.addClass('MethodLexicalScope', smalltalk.LexicalScope, ['iVars', 'pseudoVars', 'unknownVariables', 'localReturn', 'nonLocalReturns'], 'Compiler-Semantic');
  264. smalltalk.addMethod(
  265. "_addIVar_",
  266. smalltalk.method({
  267. selector: "addIVar:",
  268. fn: function (aString) {
  269. var self = this;
  270. smalltalk.send(smalltalk.send(self, "_iVars", []), "_at_put_", [aString, smalltalk.send(smalltalk.InstanceVar || InstanceVar, "_on_", [aString])]);
  271. smalltalk.send(smalltalk.send(smalltalk.send(self, "_iVars", []), "_at_", [aString]), "_scope_", [self]);
  272. return self;
  273. }
  274. }),
  275. smalltalk.MethodLexicalScope);
  276. smalltalk.addMethod(
  277. "_addNonLocalReturn_",
  278. smalltalk.method({
  279. selector: "addNonLocalReturn:",
  280. fn: function (aScope) {
  281. var self = this;
  282. smalltalk.send(smalltalk.send(self, "_nonLocalReturns", []), "_add_", [aScope]);
  283. return self;
  284. }
  285. }),
  286. smalltalk.MethodLexicalScope);
  287. smalltalk.addMethod(
  288. "_allVariableNames",
  289. smalltalk.method({
  290. selector: "allVariableNames",
  291. fn: function () {
  292. var self = this;
  293. var $1;
  294. $1 = smalltalk.send(smalltalk.send(self, "_allVariableNames", [], smalltalk.LexicalScope), "__comma", [smalltalk.send(smalltalk.send(self, "_iVars", []), "_keys", [])]);
  295. return $1;
  296. }
  297. }),
  298. smalltalk.MethodLexicalScope);
  299. smalltalk.addMethod(
  300. "_bindingFor_",
  301. smalltalk.method({
  302. selector: "bindingFor:",
  303. fn: function (aNode) {
  304. var self = this;
  305. var $2, $1;
  306. $2 = smalltalk.send(self, "_bindingFor_", [aNode], smalltalk.LexicalScope);
  307. if (($receiver = $2) == nil || $receiver == undefined) {
  308. $1 = smalltalk.send(smalltalk.send(self, "_iVars", []), "_at_ifAbsent_", [smalltalk.send(aNode, "_value", []), function () {return nil;}]);
  309. } else {
  310. $1 = $2;
  311. }
  312. return $1;
  313. }
  314. }),
  315. smalltalk.MethodLexicalScope);
  316. smalltalk.addMethod(
  317. "_canInlineNonLocalReturns",
  318. smalltalk.method({
  319. selector: "canInlineNonLocalReturns",
  320. fn: function () {
  321. var self = this;
  322. return true;
  323. }
  324. }),
  325. smalltalk.MethodLexicalScope);
  326. smalltalk.addMethod(
  327. "_hasLocalReturn",
  328. smalltalk.method({
  329. selector: "hasLocalReturn",
  330. fn: function () {
  331. var self = this;
  332. var $1;
  333. $1 = smalltalk.send(self, "_localReturn", []);
  334. return $1;
  335. }
  336. }),
  337. smalltalk.MethodLexicalScope);
  338. smalltalk.addMethod(
  339. "_hasNonLocalReturn",
  340. smalltalk.method({
  341. selector: "hasNonLocalReturn",
  342. fn: function () {
  343. var self = this;
  344. var $1;
  345. $1 = smalltalk.send(smalltalk.send(self, "_nonLocalReturns", []), "_notEmpty", []);
  346. return $1;
  347. }
  348. }),
  349. smalltalk.MethodLexicalScope);
  350. smalltalk.addMethod(
  351. "_iVars",
  352. smalltalk.method({
  353. selector: "iVars",
  354. fn: function () {
  355. var self = this;
  356. var $1;
  357. if (($receiver = self['@iVars']) == nil || $receiver == undefined) {
  358. self['@iVars'] = smalltalk.send(smalltalk.Dictionary || Dictionary, "_new", []);
  359. $1 = self['@iVars'];
  360. } else {
  361. $1 = self['@iVars'];
  362. }
  363. return $1;
  364. }
  365. }),
  366. smalltalk.MethodLexicalScope);
  367. smalltalk.addMethod(
  368. "_isMethodScope",
  369. smalltalk.method({
  370. selector: "isMethodScope",
  371. fn: function () {
  372. var self = this;
  373. return true;
  374. }
  375. }),
  376. smalltalk.MethodLexicalScope);
  377. smalltalk.addMethod(
  378. "_localReturn",
  379. smalltalk.method({
  380. selector: "localReturn",
  381. fn: function () {
  382. var self = this;
  383. var $1;
  384. if (($receiver = self['@localReturn']) == nil || $receiver == undefined) {
  385. $1 = false;
  386. } else {
  387. $1 = self['@localReturn'];
  388. }
  389. return $1;
  390. }
  391. }),
  392. smalltalk.MethodLexicalScope);
  393. smalltalk.addMethod(
  394. "_localReturn_",
  395. smalltalk.method({
  396. selector: "localReturn:",
  397. fn: function (aBoolean) {
  398. var self = this;
  399. self['@localReturn'] = aBoolean;
  400. return self;
  401. }
  402. }),
  403. smalltalk.MethodLexicalScope);
  404. smalltalk.addMethod(
  405. "_methodScope",
  406. smalltalk.method({
  407. selector: "methodScope",
  408. fn: function () {
  409. var self = this;
  410. return self;
  411. }
  412. }),
  413. smalltalk.MethodLexicalScope);
  414. smalltalk.addMethod(
  415. "_nonLocalReturns",
  416. smalltalk.method({
  417. selector: "nonLocalReturns",
  418. fn: function () {
  419. var self = this;
  420. var $1;
  421. if (($receiver = self['@nonLocalReturns']) == nil ||
  422. $receiver == undefined) {
  423. self['@nonLocalReturns'] = smalltalk.send(smalltalk.OrderedCollection || OrderedCollection, "_new", []);
  424. $1 = self['@nonLocalReturns'];
  425. } else {
  426. $1 = self['@nonLocalReturns'];
  427. }
  428. return $1;
  429. }
  430. }),
  431. smalltalk.MethodLexicalScope);
  432. smalltalk.addMethod(
  433. "_pseudoVars",
  434. smalltalk.method({
  435. selector: "pseudoVars",
  436. fn: function () {
  437. var self = this;
  438. var $1, $2;
  439. if (($receiver = self['@pseudoVars']) == nil || $receiver == undefined) {
  440. self['@pseudoVars'] = smalltalk.send(smalltalk.Dictionary || Dictionary, "_new", []);
  441. self['@pseudoVars'];
  442. smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.Smalltalk || Smalltalk, "_current", []), "_pseudoVariableNames", []), "_do_", [function (each) {$1 = smalltalk.send(smalltalk.PseudoVar || PseudoVar, "_on_", [each]);smalltalk.send($1, "_scope_", [smalltalk.send(self, "_methodScope", [])]);$2 = smalltalk.send($1, "_yourself", []);return smalltalk.send(self['@pseudoVars'], "_at_put_", [each, $2]);}]);
  443. } else {
  444. self['@pseudoVars'];
  445. }
  446. return self['@pseudoVars'];
  447. }
  448. }),
  449. smalltalk.MethodLexicalScope);
  450. smalltalk.addMethod(
  451. "_removeNonLocalReturn_",
  452. smalltalk.method({
  453. selector: "removeNonLocalReturn:",
  454. fn: function (aScope) {
  455. var self = this;
  456. smalltalk.send(smalltalk.send(self, "_nonLocalReturns", []), "_remove_ifAbsent_", [aScope, function () {}]);
  457. return self;
  458. }
  459. }),
  460. smalltalk.MethodLexicalScope);
  461. smalltalk.addMethod(
  462. "_unknownVariables",
  463. smalltalk.method({
  464. selector: "unknownVariables",
  465. fn: function () {
  466. var self = this;
  467. var $1;
  468. if (($receiver = self['@unknownVariables']) == nil ||
  469. $receiver == undefined) {
  470. self['@unknownVariables'] = smalltalk.send(smalltalk.OrderedCollection || OrderedCollection, "_new", []);
  471. $1 = self['@unknownVariables'];
  472. } else {
  473. $1 = self['@unknownVariables'];
  474. }
  475. return $1;
  476. }
  477. }),
  478. smalltalk.MethodLexicalScope);
  479. smalltalk.addClass('ScopeVar', smalltalk.Object, ['scope', 'name'], 'Compiler-Semantic');
  480. smalltalk.addMethod(
  481. "_alias",
  482. smalltalk.method({
  483. selector: "alias",
  484. fn: function () {
  485. var self = this;
  486. var $1;
  487. $1 = smalltalk.send(smalltalk.send(self, "_name", []), "_asVariableName", []);
  488. return $1;
  489. }
  490. }),
  491. smalltalk.ScopeVar);
  492. smalltalk.addMethod(
  493. "_isArgVar",
  494. smalltalk.method({
  495. selector: "isArgVar",
  496. fn: function () {
  497. var self = this;
  498. return false;
  499. }
  500. }),
  501. smalltalk.ScopeVar);
  502. smalltalk.addMethod(
  503. "_isClassRefVar",
  504. smalltalk.method({
  505. selector: "isClassRefVar",
  506. fn: function () {
  507. var self = this;
  508. return false;
  509. }
  510. }),
  511. smalltalk.ScopeVar);
  512. smalltalk.addMethod(
  513. "_isInstanceVar",
  514. smalltalk.method({
  515. selector: "isInstanceVar",
  516. fn: function () {
  517. var self = this;
  518. return false;
  519. }
  520. }),
  521. smalltalk.ScopeVar);
  522. smalltalk.addMethod(
  523. "_isPseudoVar",
  524. smalltalk.method({
  525. selector: "isPseudoVar",
  526. fn: function () {
  527. var self = this;
  528. return false;
  529. }
  530. }),
  531. smalltalk.ScopeVar);
  532. smalltalk.addMethod(
  533. "_isTempVar",
  534. smalltalk.method({
  535. selector: "isTempVar",
  536. fn: function () {
  537. var self = this;
  538. return false;
  539. }
  540. }),
  541. smalltalk.ScopeVar);
  542. smalltalk.addMethod(
  543. "_isUnknownVar",
  544. smalltalk.method({
  545. selector: "isUnknownVar",
  546. fn: function () {
  547. var self = this;
  548. return false;
  549. }
  550. }),
  551. smalltalk.ScopeVar);
  552. smalltalk.addMethod(
  553. "_name",
  554. smalltalk.method({
  555. selector: "name",
  556. fn: function () {
  557. var self = this;
  558. return self['@name'];
  559. }
  560. }),
  561. smalltalk.ScopeVar);
  562. smalltalk.addMethod(
  563. "_name_",
  564. smalltalk.method({
  565. selector: "name:",
  566. fn: function (aString) {
  567. var self = this;
  568. self['@name'] = aString;
  569. return self;
  570. }
  571. }),
  572. smalltalk.ScopeVar);
  573. smalltalk.addMethod(
  574. "_scope",
  575. smalltalk.method({
  576. selector: "scope",
  577. fn: function () {
  578. var self = this;
  579. return self['@scope'];
  580. }
  581. }),
  582. smalltalk.ScopeVar);
  583. smalltalk.addMethod(
  584. "_scope_",
  585. smalltalk.method({
  586. selector: "scope:",
  587. fn: function (aScope) {
  588. var self = this;
  589. self['@scope'] = aScope;
  590. return self;
  591. }
  592. }),
  593. smalltalk.ScopeVar);
  594. smalltalk.addMethod(
  595. "_validateAssignment",
  596. smalltalk.method({
  597. selector: "validateAssignment",
  598. fn: function () {
  599. var self = this;
  600. var $1, $2, $3;
  601. $1 = smalltalk.send(smalltalk.send(self, "_isArgVar", []), "_or_", [function () {return smalltalk.send(self, "_isPseudoVar", []);}]);
  602. if (smalltalk.assert($1)) {
  603. $2 = smalltalk.send(smalltalk.InvalidAssignmentError || InvalidAssignmentError, "_new", []);
  604. smalltalk.send($2, "_variableName_", [smalltalk.send(self, "_name", [])]);
  605. $3 = smalltalk.send($2, "_signal", []);
  606. }
  607. return self;
  608. }
  609. }),
  610. smalltalk.ScopeVar);
  611. smalltalk.addMethod(
  612. "_on_",
  613. smalltalk.method({
  614. selector: "on:",
  615. fn: function (aString) {
  616. var self = this;
  617. var $2, $3, $1;
  618. $2 = smalltalk.send(self, "_new", []);
  619. smalltalk.send($2, "_name_", [aString]);
  620. $3 = smalltalk.send($2, "_yourself", []);
  621. $1 = $3;
  622. return $1;
  623. }
  624. }),
  625. smalltalk.ScopeVar.klass);
  626. smalltalk.addClass('AliasVar', smalltalk.ScopeVar, ['node'], 'Compiler-Semantic');
  627. smalltalk.addMethod(
  628. "_node",
  629. smalltalk.method({
  630. selector: "node",
  631. fn: function () {
  632. var self = this;
  633. return self['@node'];
  634. }
  635. }),
  636. smalltalk.AliasVar);
  637. smalltalk.addMethod(
  638. "_node_",
  639. smalltalk.method({
  640. selector: "node:",
  641. fn: function (aNode) {
  642. var self = this;
  643. self['@node'] = aNode;
  644. return self;
  645. }
  646. }),
  647. smalltalk.AliasVar);
  648. smalltalk.addClass('ArgVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');
  649. smalltalk.addMethod(
  650. "_isArgVar",
  651. smalltalk.method({
  652. selector: "isArgVar",
  653. fn: function () {
  654. var self = this;
  655. return true;
  656. }
  657. }),
  658. smalltalk.ArgVar);
  659. smalltalk.addClass('ClassRefVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');
  660. smalltalk.addMethod(
  661. "_alias",
  662. smalltalk.method({
  663. selector: "alias",
  664. fn: function () {
  665. var self = this;
  666. var $1;
  667. $1 = smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send("(smalltalk.", "__comma", [smalltalk.send(self, "_name", [])]), "__comma", [" || "]), "__comma", [smalltalk.send(self, "_name", [])]), "__comma", [")"]);
  668. return $1;
  669. }
  670. }),
  671. smalltalk.ClassRefVar);
  672. smalltalk.addMethod(
  673. "_isClassRefVar",
  674. smalltalk.method({
  675. selector: "isClassRefVar",
  676. fn: function () {
  677. var self = this;
  678. return true;
  679. }
  680. }),
  681. smalltalk.ClassRefVar);
  682. smalltalk.addClass('InstanceVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');
  683. smalltalk.addMethod(
  684. "_alias",
  685. smalltalk.method({
  686. selector: "alias",
  687. fn: function () {
  688. var self = this;
  689. var $1;
  690. $1 = smalltalk.send(smalltalk.send("self[\"@", "__comma", [smalltalk.send(self, "_name", [])]), "__comma", ["\"]"]);
  691. return $1;
  692. }
  693. }),
  694. smalltalk.InstanceVar);
  695. smalltalk.addMethod(
  696. "_isInstanceVar",
  697. smalltalk.method({
  698. selector: "isInstanceVar",
  699. fn: function () {
  700. var self = this;
  701. return true;
  702. }
  703. }),
  704. smalltalk.InstanceVar);
  705. smalltalk.addClass('PseudoVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');
  706. smalltalk.addMethod(
  707. "_alias",
  708. smalltalk.method({
  709. selector: "alias",
  710. fn: function () {
  711. var self = this;
  712. var $1;
  713. $1 = smalltalk.send(self, "_name", []);
  714. return $1;
  715. }
  716. }),
  717. smalltalk.PseudoVar);
  718. smalltalk.addMethod(
  719. "_isPseudoVar",
  720. smalltalk.method({
  721. selector: "isPseudoVar",
  722. fn: function () {
  723. var self = this;
  724. return true;
  725. }
  726. }),
  727. smalltalk.PseudoVar);
  728. smalltalk.addClass('TempVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');
  729. smalltalk.addMethod(
  730. "_isTempVar",
  731. smalltalk.method({
  732. selector: "isTempVar",
  733. fn: function () {
  734. var self = this;
  735. return true;
  736. }
  737. }),
  738. smalltalk.TempVar);
  739. smalltalk.addClass('UnknownVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');
  740. smalltalk.addMethod(
  741. "_isUnknownVar",
  742. smalltalk.method({
  743. selector: "isUnknownVar",
  744. fn: function () {
  745. var self = this;
  746. return true;
  747. }
  748. }),
  749. smalltalk.UnknownVar);
  750. smalltalk.addClass('SemanticAnalyzer', smalltalk.NodeVisitor, ['currentScope', 'theClass', 'classReferences', 'messageSends'], 'Compiler-Semantic');
  751. smalltalk.addMethod(
  752. "_classReferences",
  753. smalltalk.method({
  754. selector: "classReferences",
  755. fn: function () {
  756. var self = this;
  757. var $1;
  758. if (($receiver = self['@classReferences']) == nil ||
  759. $receiver == undefined) {
  760. self['@classReferences'] = smalltalk.send(smalltalk.Set || Set, "_new", []);
  761. $1 = self['@classReferences'];
  762. } else {
  763. $1 = self['@classReferences'];
  764. }
  765. return $1;
  766. }
  767. }),
  768. smalltalk.SemanticAnalyzer);
  769. smalltalk.addMethod(
  770. "_errorShadowingVariable_",
  771. smalltalk.method({
  772. selector: "errorShadowingVariable:",
  773. fn: function (aString) {
  774. var self = this;
  775. var $1, $2;
  776. $1 = smalltalk.send(smalltalk.ShadowingVariableError || ShadowingVariableError, "_new", []);
  777. smalltalk.send($1, "_variableName_", [aString]);
  778. $2 = smalltalk.send($1, "_signal", []);
  779. return self;
  780. }
  781. }),
  782. smalltalk.SemanticAnalyzer);
  783. smalltalk.addMethod(
  784. "_errorUnknownVariable_",
  785. smalltalk.method({
  786. selector: "errorUnknownVariable:",
  787. fn: function (aNode) {
  788. var self = this;
  789. var $1, $2;
  790. var notDefined;
  791. notDefined = eval("typeof " + aNode._value() + " == \"undefined\"");
  792. if (smalltalk.assert(notDefined)) {
  793. $1 = smalltalk.send(smalltalk.UnknownVariableError || UnknownVariableError, "_new", []);
  794. smalltalk.send($1, "_variableName_", [smalltalk.send(aNode, "_value", [])]);
  795. $2 = smalltalk.send($1, "_signal", []);
  796. } else {
  797. smalltalk.send(smalltalk.send(smalltalk.send(self['@currentScope'], "_methodScope", []), "_unknownVariables", []), "_add_", [smalltalk.send(aNode, "_value", [])]);
  798. }
  799. return self;
  800. }
  801. }),
  802. smalltalk.SemanticAnalyzer);
  803. smalltalk.addMethod(
  804. "_messageSends",
  805. smalltalk.method({
  806. selector: "messageSends",
  807. fn: function () {
  808. var self = this;
  809. var $1;
  810. if (($receiver = self['@messageSends']) == nil ||
  811. $receiver == undefined) {
  812. self['@messageSends'] = smalltalk.send(smalltalk.Dictionary || Dictionary, "_new", []);
  813. $1 = self['@messageSends'];
  814. } else {
  815. $1 = self['@messageSends'];
  816. }
  817. return $1;
  818. }
  819. }),
  820. smalltalk.SemanticAnalyzer);
  821. smalltalk.addMethod(
  822. "_newBlockScope",
  823. smalltalk.method({
  824. selector: "newBlockScope",
  825. fn: function () {
  826. var self = this;
  827. var $1;
  828. $1 = smalltalk.send(self, "_newScopeOfClass_", [smalltalk.LexicalScope || LexicalScope]);
  829. return $1;
  830. }
  831. }),
  832. smalltalk.SemanticAnalyzer);
  833. smalltalk.addMethod(
  834. "_newMethodScope",
  835. smalltalk.method({
  836. selector: "newMethodScope",
  837. fn: function () {
  838. var self = this;
  839. var $1;
  840. $1 = smalltalk.send(self, "_newScopeOfClass_", [smalltalk.MethodLexicalScope || MethodLexicalScope]);
  841. return $1;
  842. }
  843. }),
  844. smalltalk.SemanticAnalyzer);
  845. smalltalk.addMethod(
  846. "_newScopeOfClass_",
  847. smalltalk.method({
  848. selector: "newScopeOfClass:",
  849. fn: function (aLexicalScopeClass) {
  850. var self = this;
  851. var $2, $3, $1;
  852. $2 = smalltalk.send(aLexicalScopeClass, "_new", []);
  853. smalltalk.send($2, "_outerScope_", [self['@currentScope']]);
  854. $3 = smalltalk.send($2, "_yourself", []);
  855. $1 = $3;
  856. return $1;
  857. }
  858. }),
  859. smalltalk.SemanticAnalyzer);
  860. smalltalk.addMethod(
  861. "_popScope",
  862. smalltalk.method({
  863. selector: "popScope",
  864. fn: function () {
  865. var self = this;
  866. if (($receiver = self['@currentScope']) == nil ||
  867. $receiver == undefined) {
  868. self['@currentScope'];
  869. } else {
  870. self['@currentScope'] = smalltalk.send(self['@currentScope'], "_outerScope", []);
  871. self['@currentScope'];
  872. }
  873. return self;
  874. }
  875. }),
  876. smalltalk.SemanticAnalyzer);
  877. smalltalk.addMethod(
  878. "_pushScope_",
  879. smalltalk.method({
  880. selector: "pushScope:",
  881. fn: function (aScope) {
  882. var self = this;
  883. smalltalk.send(aScope, "_outerScope_", [self['@currentScope']]);
  884. self['@currentScope'] = aScope;
  885. return self;
  886. }
  887. }),
  888. smalltalk.SemanticAnalyzer);
  889. smalltalk.addMethod(
  890. "_theClass",
  891. smalltalk.method({
  892. selector: "theClass",
  893. fn: function () {
  894. var self = this;
  895. return self['@theClass'];
  896. }
  897. }),
  898. smalltalk.SemanticAnalyzer);
  899. smalltalk.addMethod(
  900. "_theClass_",
  901. smalltalk.method({
  902. selector: "theClass:",
  903. fn: function (aClass) {
  904. var self = this;
  905. self['@theClass'] = aClass;
  906. return self;
  907. }
  908. }),
  909. smalltalk.SemanticAnalyzer);
  910. smalltalk.addMethod(
  911. "_validateVariableScope_",
  912. smalltalk.method({
  913. selector: "validateVariableScope:",
  914. fn: function (aString) {
  915. var self = this;
  916. var $1;
  917. $1 = smalltalk.send(self['@currentScope'], "_lookupVariable_", [aString]);
  918. if (($receiver = $1) == nil || $receiver == undefined) {
  919. } else {
  920. smalltalk.send(self, "_errorShadowingVariable_", [aString]);
  921. }
  922. return self;
  923. }
  924. }),
  925. smalltalk.SemanticAnalyzer);
  926. smalltalk.addMethod(
  927. "_visitAssignmentNode_",
  928. smalltalk.method({
  929. selector: "visitAssignmentNode:",
  930. fn: function (aNode) {
  931. var self = this;
  932. smalltalk.send(self, "_visitAssignmentNode_", [aNode], smalltalk.NodeVisitor);
  933. smalltalk.send(smalltalk.send(aNode, "_left", []), "_beAssigned", []);
  934. return self;
  935. }
  936. }),
  937. smalltalk.SemanticAnalyzer);
  938. smalltalk.addMethod(
  939. "_visitBlockNode_",
  940. smalltalk.method({
  941. selector: "visitBlockNode:",
  942. fn: function (aNode) {
  943. var self = this;
  944. smalltalk.send(self, "_pushScope_", [smalltalk.send(self, "_newBlockScope", [])]);
  945. smalltalk.send(aNode, "_scope_", [self['@currentScope']]);
  946. smalltalk.send(self['@currentScope'], "_node_", [aNode]);
  947. smalltalk.send(smalltalk.send(aNode, "_parameters", []), "_do_", [function (each) {smalltalk.send(self, "_validateVariableScope_", [each]);return smalltalk.send(self['@currentScope'], "_addArg_", [each]);}]);
  948. smalltalk.send(self, "_visitBlockNode_", [aNode], smalltalk.NodeVisitor);
  949. smalltalk.send(self, "_popScope", []);
  950. return self;
  951. }
  952. }),
  953. smalltalk.SemanticAnalyzer);
  954. smalltalk.addMethod(
  955. "_visitCascadeNode_",
  956. smalltalk.method({
  957. selector: "visitCascadeNode:",
  958. fn: function (aNode) {
  959. var self = this;
  960. var $1;
  961. smalltalk.send(smalltalk.send(aNode, "_nodes", []), "_do_", [function (each) {return smalltalk.send(each, "_receiver_", [smalltalk.send(aNode, "_receiver", [])]);}]);
  962. smalltalk.send(self, "_visitCascadeNode_", [aNode], smalltalk.NodeVisitor);
  963. $1 = smalltalk.send(smalltalk.send(smalltalk.send(aNode, "_nodes", []), "_first", []), "_superSend", []);
  964. if (smalltalk.assert($1)) {
  965. smalltalk.send(smalltalk.send(aNode, "_nodes", []), "_do_", [function (each) {return smalltalk.send(each, "_superSend_", [true]);}]);
  966. }
  967. return self;
  968. }
  969. }),
  970. smalltalk.SemanticAnalyzer);
  971. smalltalk.addMethod(
  972. "_visitClassReferenceNode_",
  973. smalltalk.method({
  974. selector: "visitClassReferenceNode:",
  975. fn: function (aNode) {
  976. var self = this;
  977. var $1, $2;
  978. smalltalk.send(smalltalk.send(self, "_classReferences", []), "_add_", [smalltalk.send(aNode, "_value", [])]);
  979. $1 = smalltalk.send(smalltalk.ClassRefVar || ClassRefVar, "_new", []);
  980. smalltalk.send($1, "_name_", [smalltalk.send(aNode, "_value", [])]);
  981. $2 = smalltalk.send($1, "_yourself", []);
  982. smalltalk.send(aNode, "_binding_", [$2]);
  983. return self;
  984. }
  985. }),
  986. smalltalk.SemanticAnalyzer);
  987. smalltalk.addMethod(
  988. "_visitMethodNode_",
  989. smalltalk.method({
  990. selector: "visitMethodNode:",
  991. fn: function (aNode) {
  992. var self = this;
  993. var $1;
  994. smalltalk.send(self, "_pushScope_", [smalltalk.send(self, "_newMethodScope", [])]);
  995. smalltalk.send(aNode, "_scope_", [self['@currentScope']]);
  996. smalltalk.send(self['@currentScope'], "_node_", [aNode]);
  997. smalltalk.send(smalltalk.send(smalltalk.send(self, "_theClass", []), "_allInstanceVariableNames", []), "_do_", [function (each) {return smalltalk.send(self['@currentScope'], "_addIVar_", [each]);}]);
  998. smalltalk.send(smalltalk.send(aNode, "_arguments", []), "_do_", [function (each) {smalltalk.send(self, "_validateVariableScope_", [each]);return smalltalk.send(self['@currentScope'], "_addArg_", [each]);}]);
  999. smalltalk.send(self, "_visitMethodNode_", [aNode], smalltalk.NodeVisitor);
  1000. smalltalk.send(aNode, "_classReferences_", [smalltalk.send(self, "_classReferences", [])]);
  1001. $1 = smalltalk.send(aNode, "_messageSends_", [smalltalk.send(smalltalk.send(self, "_messageSends", []), "_keys", [])]);
  1002. smalltalk.send(self, "_popScope", []);
  1003. return self;
  1004. }
  1005. }),
  1006. smalltalk.SemanticAnalyzer);
  1007. smalltalk.addMethod(
  1008. "_visitReturnNode_",
  1009. smalltalk.method({
  1010. selector: "visitReturnNode:",
  1011. fn: function (aNode) {
  1012. var self = this;
  1013. var $1;
  1014. smalltalk.send(aNode, "_scope_", [self['@currentScope']]);
  1015. $1 = smalltalk.send(self['@currentScope'], "_isMethodScope", []);
  1016. if (smalltalk.assert($1)) {
  1017. smalltalk.send(self['@currentScope'], "_localReturn_", [true]);
  1018. } else {
  1019. smalltalk.send(smalltalk.send(self['@currentScope'], "_methodScope", []), "_addNonLocalReturn_", [self['@currentScope']]);
  1020. }
  1021. smalltalk.send(self, "_visitReturnNode_", [aNode], smalltalk.NodeVisitor);
  1022. return self;
  1023. }
  1024. }),
  1025. smalltalk.SemanticAnalyzer);
  1026. smalltalk.addMethod(
  1027. "_visitSendNode_",
  1028. smalltalk.method({
  1029. selector: "visitSendNode:",
  1030. fn: function (aNode) {
  1031. var self = this;
  1032. var $1, $2, $3;
  1033. $1 = smalltalk.send(smalltalk.send(smalltalk.send(aNode, "_receiver", []), "_value", []), "__eq", ["super"]);
  1034. if (smalltalk.assert($1)) {
  1035. smalltalk.send(aNode, "_superSend_", [true]);
  1036. smalltalk.send(smalltalk.send(aNode, "_receiver", []), "_value_", ["self"]);
  1037. } else {
  1038. $2 = smalltalk.send(smalltalk.send(smalltalk.IRSendInliner || IRSendInliner, "_inlinedSelectors", []), "_includes_", [smalltalk.send(aNode, "_selector", [])]);
  1039. if (smalltalk.assert($2)) {
  1040. smalltalk.send(aNode, "_shouldBeInlined_", [true]);
  1041. $3 = smalltalk.send(smalltalk.send(aNode, "_receiver", []), "_isValueNode", []);
  1042. if (!smalltalk.assert($3)) {
  1043. smalltalk.send(smalltalk.send(aNode, "_receiver", []), "_shouldBeAliased_", [true]);
  1044. }
  1045. }
  1046. }
  1047. smalltalk.send(smalltalk.send(self, "_messageSends", []), "_at_ifAbsentPut_", [smalltalk.send(aNode, "_selector", []), function () {return smalltalk.send(smalltalk.Set || Set, "_new", []);}]);
  1048. smalltalk.send(smalltalk.send(smalltalk.send(self, "_messageSends", []), "_at_", [smalltalk.send(aNode, "_selector", [])]), "_add_", [aNode]);
  1049. smalltalk.send(aNode, "_index_", [smalltalk.send(smalltalk.send(smalltalk.send(self, "_messageSends", []), "_at_", [smalltalk.send(aNode, "_selector", [])]), "_size", [])]);
  1050. smalltalk.send(self, "_visitSendNode_", [aNode], smalltalk.NodeVisitor);
  1051. return self;
  1052. }
  1053. }),
  1054. smalltalk.SemanticAnalyzer);
  1055. smalltalk.addMethod(
  1056. "_visitSequenceNode_",
  1057. smalltalk.method({
  1058. selector: "visitSequenceNode:",
  1059. fn: function (aNode) {
  1060. var self = this;
  1061. smalltalk.send(smalltalk.send(aNode, "_temps", []), "_do_", [function (each) {smalltalk.send(self, "_validateVariableScope_", [each]);return smalltalk.send(self['@currentScope'], "_addTemp_", [each]);}]);
  1062. smalltalk.send(self, "_visitSequenceNode_", [aNode], smalltalk.NodeVisitor);
  1063. return self;
  1064. }
  1065. }),
  1066. smalltalk.SemanticAnalyzer);
  1067. smalltalk.addMethod(
  1068. "_visitVariableNode_",
  1069. smalltalk.method({
  1070. selector: "visitVariableNode:",
  1071. fn: function (aNode) {
  1072. var self = this;
  1073. var $2, $3, $4, $1;
  1074. $2 = smalltalk.send(self['@currentScope'], "_lookupVariable_", [aNode]);
  1075. if (($receiver = $2) == nil || $receiver == undefined) {
  1076. smalltalk.send(self, "_errorUnknownVariable_", [aNode]);
  1077. $3 = smalltalk.send(smalltalk.UnknownVar || UnknownVar, "_new", []);
  1078. smalltalk.send($3, "_name_", [smalltalk.send(aNode, "_value", [])]);
  1079. $4 = smalltalk.send($3, "_yourself", []);
  1080. $1 = $4;
  1081. } else {
  1082. $1 = $2;
  1083. }
  1084. smalltalk.send(aNode, "_binding_", [$1]);
  1085. return self;
  1086. }
  1087. }),
  1088. smalltalk.SemanticAnalyzer);
  1089. smalltalk.addMethod(
  1090. "_on_",
  1091. smalltalk.method({
  1092. selector: "on:",
  1093. fn: function (aClass) {
  1094. var self = this;
  1095. var $2, $3, $1;
  1096. $2 = smalltalk.send(self, "_new", []);
  1097. smalltalk.send($2, "_theClass_", [aClass]);
  1098. $3 = smalltalk.send($2, "_yourself", []);
  1099. $1 = $3;
  1100. return $1;
  1101. }
  1102. }),
  1103. smalltalk.SemanticAnalyzer.klass);