Compiler-Semantic.deploy.js 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205
  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;
  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. smalltalk.send(smalltalk.send(aNode,"_receiver",[]),"_shouldBeAliased_",[true]);
  1042. };
  1043. };
  1044. smalltalk.send(smalltalk.send(self,"_messageSends",[]),"_at_ifAbsentPut_",[smalltalk.send(aNode,"_selector",[]),(function(){
  1045. return smalltalk.send((smalltalk.Set || Set),"_new",[]);
  1046. })]);
  1047. smalltalk.send(smalltalk.send(smalltalk.send(self,"_messageSends",[]),"_at_",[smalltalk.send(aNode,"_selector",[])]),"_add_",[aNode]);
  1048. smalltalk.send(aNode,"_index_",[smalltalk.send(smalltalk.send(smalltalk.send(self,"_messageSends",[]),"_at_",[smalltalk.send(aNode,"_selector",[])]),"_size",[])]);
  1049. smalltalk.send(self,"_visitSendNode_",[aNode],smalltalk.NodeVisitor);
  1050. return self}
  1051. }),
  1052. smalltalk.SemanticAnalyzer);
  1053. smalltalk.addMethod(
  1054. "_visitSequenceNode_",
  1055. smalltalk.method({
  1056. selector: "visitSequenceNode:",
  1057. fn: function (aNode) {
  1058. var self = this;
  1059. smalltalk.send(smalltalk.send(aNode, "_temps", []), "_do_", [function (each) {smalltalk.send(self, "_validateVariableScope_", [each]);return smalltalk.send(self['@currentScope'], "_addTemp_", [each]);}]);
  1060. smalltalk.send(self, "_visitSequenceNode_", [aNode], smalltalk.NodeVisitor);
  1061. return self;
  1062. }
  1063. }),
  1064. smalltalk.SemanticAnalyzer);
  1065. smalltalk.addMethod(
  1066. "_visitVariableNode_",
  1067. smalltalk.method({
  1068. selector: "visitVariableNode:",
  1069. fn: function (aNode) {
  1070. var self = this;
  1071. var $2, $3, $4, $1;
  1072. $2 = smalltalk.send(self['@currentScope'], "_lookupVariable_", [aNode]);
  1073. if (($receiver = $2) == nil || $receiver == undefined) {
  1074. smalltalk.send(self, "_errorUnknownVariable_", [aNode]);
  1075. $3 = smalltalk.send(smalltalk.UnknownVar || UnknownVar, "_new", []);
  1076. smalltalk.send($3, "_name_", [smalltalk.send(aNode, "_value", [])]);
  1077. $4 = smalltalk.send($3, "_yourself", []);
  1078. $1 = $4;
  1079. } else {
  1080. $1 = $2;
  1081. }
  1082. smalltalk.send(aNode, "_binding_", [$1]);
  1083. return self;
  1084. }
  1085. }),
  1086. smalltalk.SemanticAnalyzer);
  1087. smalltalk.addMethod(
  1088. "_on_",
  1089. smalltalk.method({
  1090. selector: "on:",
  1091. fn: function (aClass) {
  1092. var self = this;
  1093. var $2, $3, $1;
  1094. $2 = smalltalk.send(self, "_new", []);
  1095. smalltalk.send($2, "_theClass_", [aClass]);
  1096. $3 = smalltalk.send($2, "_yourself", []);
  1097. $1 = $3;
  1098. return $1;
  1099. }
  1100. }),
  1101. smalltalk.SemanticAnalyzer.klass);