Compiler-Semantic.deploy.js 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218
  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. "_pseudoVariables",
  879. smalltalk.method({
  880. selector: "pseudoVariables",
  881. fn: function () {
  882. var self = this;
  883. return ["self", "super", "true", "false", "nil", "thisContext"];
  884. }
  885. }),
  886. smalltalk.SemanticAnalyzer);
  887. smalltalk.addMethod(
  888. "_pushScope_",
  889. smalltalk.method({
  890. selector: "pushScope:",
  891. fn: function (aScope) {
  892. var self = this;
  893. smalltalk.send(aScope, "_outerScope_", [self['@currentScope']]);
  894. self['@currentScope'] = aScope;
  895. return self;
  896. }
  897. }),
  898. smalltalk.SemanticAnalyzer);
  899. smalltalk.addMethod(
  900. "_theClass",
  901. smalltalk.method({
  902. selector: "theClass",
  903. fn: function () {
  904. var self = this;
  905. return self['@theClass'];
  906. }
  907. }),
  908. smalltalk.SemanticAnalyzer);
  909. smalltalk.addMethod(
  910. "_theClass_",
  911. smalltalk.method({
  912. selector: "theClass:",
  913. fn: function (aClass) {
  914. var self = this;
  915. self['@theClass'] = aClass;
  916. return self;
  917. }
  918. }),
  919. smalltalk.SemanticAnalyzer);
  920. smalltalk.addMethod(
  921. "_validateVariableScope_",
  922. smalltalk.method({
  923. selector: "validateVariableScope:",
  924. fn: function (aString) {
  925. var self = this;
  926. var $1;
  927. $1 = smalltalk.send(self['@currentScope'], "_lookupVariable_", [aString]);
  928. if (($receiver = $1) == nil || $receiver == undefined) {
  929. } else {
  930. smalltalk.send(self, "_errorShadowingVariable_", [aString]);
  931. }
  932. return self;
  933. }
  934. }),
  935. smalltalk.SemanticAnalyzer);
  936. smalltalk.addMethod(
  937. "_visitAssignmentNode_",
  938. smalltalk.method({
  939. selector: "visitAssignmentNode:",
  940. fn: function (aNode) {
  941. var self = this;
  942. smalltalk.send(self, "_visitAssignmentNode_", [aNode], smalltalk.NodeVisitor);
  943. smalltalk.send(smalltalk.send(aNode, "_left", []), "_beAssigned", []);
  944. return self;
  945. }
  946. }),
  947. smalltalk.SemanticAnalyzer);
  948. smalltalk.addMethod(
  949. "_visitBlockNode_",
  950. smalltalk.method({
  951. selector: "visitBlockNode:",
  952. fn: function (aNode) {
  953. var self = this;
  954. smalltalk.send(self, "_pushScope_", [smalltalk.send(self, "_newBlockScope", [])]);
  955. smalltalk.send(aNode, "_scope_", [self['@currentScope']]);
  956. smalltalk.send(self['@currentScope'], "_node_", [aNode]);
  957. smalltalk.send(smalltalk.send(aNode, "_parameters", []), "_do_", [function (each) {smalltalk.send(self, "_validateVariableScope_", [each]);return smalltalk.send(self['@currentScope'], "_addArg_", [each]);}]);
  958. smalltalk.send(self, "_visitBlockNode_", [aNode], smalltalk.NodeVisitor);
  959. smalltalk.send(self, "_popScope", []);
  960. return self;
  961. }
  962. }),
  963. smalltalk.SemanticAnalyzer);
  964. smalltalk.addMethod(
  965. "_visitCascadeNode_",
  966. smalltalk.method({
  967. selector: "visitCascadeNode:",
  968. fn: function (aNode) {
  969. var self = this;
  970. var $1;
  971. smalltalk.send(smalltalk.send(aNode, "_nodes", []), "_do_", [function (each) {return smalltalk.send(each, "_receiver_", [smalltalk.send(aNode, "_receiver", [])]);}]);
  972. smalltalk.send(self, "_visitCascadeNode_", [aNode], smalltalk.NodeVisitor);
  973. $1 = smalltalk.send(smalltalk.send(smalltalk.send(aNode, "_nodes", []), "_first", []), "_superSend", []);
  974. if (smalltalk.assert($1)) {
  975. smalltalk.send(smalltalk.send(aNode, "_nodes", []), "_do_", [function (each) {return smalltalk.send(each, "_superSend_", [true]);}]);
  976. }
  977. return self;
  978. }
  979. }),
  980. smalltalk.SemanticAnalyzer);
  981. smalltalk.addMethod(
  982. "_visitClassReferenceNode_",
  983. smalltalk.method({
  984. selector: "visitClassReferenceNode:",
  985. fn: function (aNode) {
  986. var self = this;
  987. var $1, $2;
  988. smalltalk.send(smalltalk.send(self, "_classReferences", []), "_add_", [smalltalk.send(aNode, "_value", [])]);
  989. $1 = smalltalk.send(smalltalk.ClassRefVar || ClassRefVar, "_new", []);
  990. smalltalk.send($1, "_name_", [smalltalk.send(aNode, "_value", [])]);
  991. $2 = smalltalk.send($1, "_yourself", []);
  992. smalltalk.send(aNode, "_binding_", [$2]);
  993. return self;
  994. }
  995. }),
  996. smalltalk.SemanticAnalyzer);
  997. smalltalk.addMethod(
  998. "_visitMethodNode_",
  999. smalltalk.method({
  1000. selector: "visitMethodNode:",
  1001. fn: function (aNode) {
  1002. var self = this;
  1003. var $1;
  1004. smalltalk.send(self, "_pushScope_", [smalltalk.send(self, "_newMethodScope", [])]);
  1005. smalltalk.send(aNode, "_scope_", [self['@currentScope']]);
  1006. smalltalk.send(self['@currentScope'], "_node_", [aNode]);
  1007. smalltalk.send(smalltalk.send(smalltalk.send(self, "_theClass", []), "_allInstanceVariableNames", []), "_do_", [function (each) {return smalltalk.send(self['@currentScope'], "_addIVar_", [each]);}]);
  1008. smalltalk.send(smalltalk.send(aNode, "_arguments", []), "_do_", [function (each) {smalltalk.send(self, "_validateVariableScope_", [each]);return smalltalk.send(self['@currentScope'], "_addArg_", [each]);}]);
  1009. smalltalk.send(self, "_visitMethodNode_", [aNode], smalltalk.NodeVisitor);
  1010. smalltalk.send(aNode, "_classReferences_", [smalltalk.send(self, "_classReferences", [])]);
  1011. $1 = smalltalk.send(aNode, "_messageSends_", [smalltalk.send(smalltalk.send(self, "_messageSends", []), "_keys", [])]);
  1012. smalltalk.send(self, "_popScope", []);
  1013. return self;
  1014. }
  1015. }),
  1016. smalltalk.SemanticAnalyzer);
  1017. smalltalk.addMethod(
  1018. "_visitReturnNode_",
  1019. smalltalk.method({
  1020. selector: "visitReturnNode:",
  1021. fn: function (aNode) {
  1022. var self = this;
  1023. var $1;
  1024. smalltalk.send(aNode, "_scope_", [self['@currentScope']]);
  1025. $1 = smalltalk.send(self['@currentScope'], "_isMethodScope", []);
  1026. if (smalltalk.assert($1)) {
  1027. smalltalk.send(self['@currentScope'], "_localReturn_", [true]);
  1028. } else {
  1029. smalltalk.send(smalltalk.send(self['@currentScope'], "_methodScope", []), "_addNonLocalReturn_", [self['@currentScope']]);
  1030. }
  1031. smalltalk.send(self, "_visitReturnNode_", [aNode], smalltalk.NodeVisitor);
  1032. return self;
  1033. }
  1034. }),
  1035. smalltalk.SemanticAnalyzer);
  1036. smalltalk.addMethod(
  1037. "_visitSendNode_",
  1038. smalltalk.method({
  1039. selector: "visitSendNode:",
  1040. fn: function (aNode) {
  1041. var self = this;
  1042. var $1, $2, $3;
  1043. $1 = smalltalk.send(smalltalk.send(smalltalk.send(aNode, "_receiver", []), "_value", []), "__eq", ["super"]);
  1044. if (smalltalk.assert($1)) {
  1045. smalltalk.send(aNode, "_superSend_", [true]);
  1046. smalltalk.send(smalltalk.send(aNode, "_receiver", []), "_value_", ["self"]);
  1047. } else {
  1048. $2 = smalltalk.send(smalltalk.send(smalltalk.IRSendInliner || IRSendInliner, "_inlinedSelectors", []), "_includes_", [smalltalk.send(aNode, "_selector", [])]);
  1049. if (smalltalk.assert($2)) {
  1050. smalltalk.send(aNode, "_shouldBeInlined_", [true]);
  1051. $3 = smalltalk.send(smalltalk.send(aNode, "_receiver", []), "_isValueNode", []);
  1052. if (!smalltalk.assert($3)) {
  1053. smalltalk.send(smalltalk.send(aNode, "_receiver", []), "_shouldBeAliased_", [true]);
  1054. }
  1055. }
  1056. }
  1057. smalltalk.send(smalltalk.send(self, "_messageSends", []), "_at_ifAbsentPut_", [smalltalk.send(aNode, "_selector", []), function () {return smalltalk.send(smalltalk.Set || Set, "_new", []);}]);
  1058. smalltalk.send(smalltalk.send(smalltalk.send(self, "_messageSends", []), "_at_", [smalltalk.send(aNode, "_selector", [])]), "_add_", [aNode]);
  1059. smalltalk.send(aNode, "_index_", [smalltalk.send(smalltalk.send(smalltalk.send(self, "_messageSends", []), "_at_", [smalltalk.send(aNode, "_selector", [])]), "_size", [])]);
  1060. smalltalk.send(self, "_visitSendNode_", [aNode], smalltalk.NodeVisitor);
  1061. return self;
  1062. }
  1063. }),
  1064. smalltalk.SemanticAnalyzer);
  1065. smalltalk.addMethod(
  1066. "_visitSequenceNode_",
  1067. smalltalk.method({
  1068. selector: "visitSequenceNode:",
  1069. fn: function (aNode) {
  1070. var self = this;
  1071. smalltalk.send(smalltalk.send(aNode, "_temps", []), "_do_", [function (each) {smalltalk.send(self, "_validateVariableScope_", [each]);return smalltalk.send(self['@currentScope'], "_addTemp_", [each]);}]);
  1072. smalltalk.send(self, "_visitSequenceNode_", [aNode], smalltalk.NodeVisitor);
  1073. return self;
  1074. }
  1075. }),
  1076. smalltalk.SemanticAnalyzer);
  1077. smalltalk.addMethod(
  1078. "_visitVariableNode_",
  1079. smalltalk.method({
  1080. selector: "visitVariableNode:",
  1081. fn: function (aNode) {
  1082. var self = this;
  1083. var $2, $3, $4, $1;
  1084. $2 = smalltalk.send(self['@currentScope'], "_lookupVariable_", [aNode]);
  1085. if (($receiver = $2) == nil || $receiver == undefined) {
  1086. smalltalk.send(self, "_errorUnknownVariable_", [aNode]);
  1087. $3 = smalltalk.send(smalltalk.UnknownVar || UnknownVar, "_new", []);
  1088. smalltalk.send($3, "_name_", [smalltalk.send(aNode, "_value", [])]);
  1089. $4 = smalltalk.send($3, "_yourself", []);
  1090. $1 = $4;
  1091. } else {
  1092. $1 = $2;
  1093. }
  1094. smalltalk.send(aNode, "_binding_", [$1]);
  1095. return self;
  1096. }
  1097. }),
  1098. smalltalk.SemanticAnalyzer);
  1099. smalltalk.addMethod(
  1100. "_on_",
  1101. smalltalk.method({
  1102. selector: "on:",
  1103. fn: function (aClass) {
  1104. var self = this;
  1105. var $2, $3, $1;
  1106. $2 = smalltalk.send(self, "_new", []);
  1107. smalltalk.send($2, "_theClass_", [aClass]);
  1108. $3 = smalltalk.send($2, "_yourself", []);
  1109. $1 = $3;
  1110. return $1;
  1111. }
  1112. }),
  1113. smalltalk.SemanticAnalyzer.klass);