Compiler-Semantic.deploy.js 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984
  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. smalltalk.LexicalScope);
  14. smalltalk.addMethod(
  15. "_addTemp_",
  16. smalltalk.method({
  17. selector: "addTemp:",
  18. fn: function (aString) {
  19. var self=this;
  20. smalltalk.send(smalltalk.send(self, "_temps", []), "_at_put_", [aString, smalltalk.send((smalltalk.TempVar || TempVar), "_on_", [aString])]);
  21. smalltalk.send(smalltalk.send(smalltalk.send(self, "_temps", []), "_at_", [aString]), "_scope_", [self]);
  22. return self;}
  23. }),
  24. smalltalk.LexicalScope);
  25. smalltalk.addMethod(
  26. "_allVariableNames",
  27. smalltalk.method({
  28. selector: "allVariableNames",
  29. fn: function () {
  30. var self=this;
  31. return smalltalk.send(smalltalk.send(smalltalk.send(self, "_args", []), "_keys", []), "__comma", [smalltalk.send(smalltalk.send(self, "_temps", []), "_keys", [])]);
  32. return self;}
  33. }),
  34. smalltalk.LexicalScope);
  35. smalltalk.addMethod(
  36. "_args",
  37. smalltalk.method({
  38. selector: "args",
  39. fn: function () {
  40. var self=this;
  41. return (($receiver = self['@args']) == nil || $receiver == undefined) ? (function(){return (self['@args']=smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));})() : $receiver;
  42. return self;}
  43. }),
  44. smalltalk.LexicalScope);
  45. smalltalk.addMethod(
  46. "_bindingFor_",
  47. smalltalk.method({
  48. selector: "bindingFor:",
  49. fn: function (aStringOrNode) {
  50. var self=this;
  51. return 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;})]);})]);})]);
  52. return self;}
  53. }),
  54. smalltalk.LexicalScope);
  55. smalltalk.addMethod(
  56. "_instruction",
  57. smalltalk.method({
  58. selector: "instruction",
  59. fn: function (){
  60. var self=this;
  61. return self['@instruction'];
  62. return self;}
  63. }),
  64. smalltalk.LexicalScope);
  65. smalltalk.addMethod(
  66. "_instruction_",
  67. smalltalk.method({
  68. selector: "instruction:",
  69. fn: function (anIRInstruction){
  70. var self=this;
  71. (self['@instruction']=anIRInstruction);
  72. return self;}
  73. }),
  74. smalltalk.LexicalScope);
  75. smalltalk.addMethod(
  76. "_isMethodScope",
  77. smalltalk.method({
  78. selector: "isMethodScope",
  79. fn: function () {
  80. var self=this;
  81. return false;
  82. return self;}
  83. }),
  84. smalltalk.LexicalScope);
  85. smalltalk.addMethod(
  86. "_lookupVariable_",
  87. smalltalk.method({
  88. selector: "lookupVariable:",
  89. fn: function (aNode) {
  90. var self=this;
  91. var lookup=nil;
  92. (lookup=smalltalk.send(self, "_bindingFor_", [aNode]));
  93. (($receiver = lookup) == nil || $receiver == undefined) ? (function(){return (lookup=(($receiver = smalltalk.send(self, "_outerScope", [])) != nil && $receiver != undefined) ? (function(){return smalltalk.send(smalltalk.send(self, "_outerScope", []), "_lookupVariable_", [aNode]);})() : nil);})() : $receiver;
  94. return lookup;
  95. return self;}
  96. }),
  97. smalltalk.LexicalScope);
  98. smalltalk.addMethod(
  99. "_methodScope",
  100. smalltalk.method({
  101. selector: "methodScope",
  102. fn: function () {
  103. var self=this;
  104. return (($receiver = smalltalk.send(self, "_outerScope", [])) != nil && $receiver != undefined) ? (function(){return smalltalk.send(smalltalk.send(self, "_outerScope", []), "_methodScope", []);})() : nil;
  105. return self;}
  106. }),
  107. smalltalk.LexicalScope);
  108. smalltalk.addMethod(
  109. "_node",
  110. smalltalk.method({
  111. selector: "node",
  112. fn: function () {
  113. var self=this;
  114. return self['@node'];
  115. return self;}
  116. }),
  117. smalltalk.LexicalScope);
  118. smalltalk.addMethod(
  119. "_node_",
  120. smalltalk.method({
  121. selector: "node:",
  122. fn: function (aNode) {
  123. var self=this;
  124. (self['@node']=aNode);
  125. return self;}
  126. }),
  127. smalltalk.LexicalScope);
  128. smalltalk.addMethod(
  129. "_outerScope",
  130. smalltalk.method({
  131. selector: "outerScope",
  132. fn: function () {
  133. var self=this;
  134. return self['@outerScope'];
  135. return self;}
  136. }),
  137. smalltalk.LexicalScope);
  138. smalltalk.addMethod(
  139. "_outerScope_",
  140. smalltalk.method({
  141. selector: "outerScope:",
  142. fn: function (aLexicalScope) {
  143. var self=this;
  144. (self['@outerScope']=aLexicalScope);
  145. return self;}
  146. }),
  147. smalltalk.LexicalScope);
  148. smalltalk.addMethod(
  149. "_pseudoVars",
  150. smalltalk.method({
  151. selector: "pseudoVars",
  152. fn: function () {
  153. var self=this;
  154. return smalltalk.send(smalltalk.send(self, "_methodScope", []), "_pseudoVars", []);
  155. return self;}
  156. }),
  157. smalltalk.LexicalScope);
  158. smalltalk.addMethod(
  159. "_scopeLevel",
  160. smalltalk.method({
  161. selector: "scopeLevel",
  162. fn: function () {
  163. var self=this;
  164. return ((($receiver = (($receiver = smalltalk.send(self, "_outerScope", [])) == nil || $receiver == undefined) ? (function(){return (0);})() : (function(){return smalltalk.send(smalltalk.send(self, "_outerScope", []), "_scopeLevel", []);})()).klass === smalltalk.Number) ? $receiver +(1) : smalltalk.send($receiver, "__plus", [(1)]));
  165. return self;}
  166. }),
  167. smalltalk.LexicalScope);
  168. smalltalk.addMethod(
  169. "_temps",
  170. smalltalk.method({
  171. selector: "temps",
  172. fn: function () {
  173. var self=this;
  174. return (($receiver = self['@temps']) == nil || $receiver == undefined) ? (function(){return (self['@temps']=smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));})() : $receiver;
  175. return self;}
  176. }),
  177. smalltalk.LexicalScope);
  178. smalltalk.addClass('MethodLexicalScope', smalltalk.LexicalScope, ['iVars', 'unknownVariables', 'localReturn', 'nonLocalReturns'], 'Compiler-Semantic');
  179. smalltalk.addMethod(
  180. "_addIVar_",
  181. smalltalk.method({
  182. selector: "addIVar:",
  183. fn: function (aString){
  184. var self=this;
  185. smalltalk.send(smalltalk.send(self, "_iVars", []), "_at_put_", [aString, smalltalk.send((smalltalk.InstanceVar || InstanceVar), "_on_", [aString])]);
  186. smalltalk.send(smalltalk.send(smalltalk.send(self, "_iVars", []), "_at_", [aString]), "_scope_", [self]);
  187. return self;}
  188. }),
  189. smalltalk.MethodLexicalScope);
  190. smalltalk.addMethod(
  191. "_addNonLocalReturn_",
  192. smalltalk.method({
  193. selector: "addNonLocalReturn:",
  194. fn: function (aNode){
  195. var self=this;
  196. smalltalk.send(smalltalk.send(self, "_nonLocalReturns", []), "_add_", [aNode]);
  197. return self;}
  198. }),
  199. smalltalk.MethodLexicalScope);
  200. smalltalk.addMethod(
  201. "_allVariableNames",
  202. smalltalk.method({
  203. selector: "allVariableNames",
  204. fn: function () {
  205. var self=this;
  206. return smalltalk.send(smalltalk.send(self, "_allVariableNames", [], smalltalk.MethodLexicalScope.superclass || nil), "__comma", [smalltalk.send(smalltalk.send(self, "_iVars", []), "_keys", [])]);
  207. return self;}
  208. }),
  209. smalltalk.MethodLexicalScope);
  210. smalltalk.addMethod(
  211. "_bindingFor_",
  212. smalltalk.method({
  213. selector: "bindingFor:",
  214. fn: function (aNode) {
  215. var self=this;
  216. return (($receiver = smalltalk.send(self, "_bindingFor_", [aNode], smalltalk.MethodLexicalScope.superclass || nil)) == nil || $receiver == undefined) ? (function(){return smalltalk.send(smalltalk.send(self, "_iVars", []), "_at_ifAbsent_", [smalltalk.send(aNode, "_value", []), (function(){return nil;})]);})() : $receiver;
  217. return self;}
  218. }),
  219. smalltalk.MethodLexicalScope);
  220. smalltalk.addMethod(
  221. "_hasLocalReturn",
  222. smalltalk.method({
  223. selector: "hasLocalReturn",
  224. fn: function () {
  225. var self=this;
  226. return smalltalk.send(self, "_localReturn", []);
  227. return self;}
  228. }),
  229. smalltalk.MethodLexicalScope);
  230. smalltalk.addMethod(
  231. "_hasNonLocalReturn",
  232. smalltalk.method({
  233. selector: "hasNonLocalReturn",
  234. fn: function (){
  235. var self=this;
  236. return smalltalk.send(smalltalk.send(self, "_nonLocalReturns", []), "_notEmpty", []);
  237. return self;}
  238. }),
  239. smalltalk.MethodLexicalScope);
  240. smalltalk.addMethod(
  241. "_iVars",
  242. smalltalk.method({
  243. selector: "iVars",
  244. fn: function () {
  245. var self=this;
  246. return (($receiver = self['@iVars']) == nil || $receiver == undefined) ? (function(){return (self['@iVars']=smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));})() : $receiver;
  247. return self;}
  248. }),
  249. smalltalk.MethodLexicalScope);
  250. smalltalk.addMethod(
  251. "_isMethodScope",
  252. smalltalk.method({
  253. selector: "isMethodScope",
  254. fn: function () {
  255. var self=this;
  256. return true;
  257. return self;}
  258. }),
  259. smalltalk.MethodLexicalScope);
  260. smalltalk.addMethod(
  261. "_localReturn",
  262. smalltalk.method({
  263. selector: "localReturn",
  264. fn: function () {
  265. var self=this;
  266. return (($receiver = self['@localReturn']) == nil || $receiver == undefined) ? (function(){return false;})() : $receiver;
  267. return self;}
  268. }),
  269. smalltalk.MethodLexicalScope);
  270. smalltalk.addMethod(
  271. "_localReturn_",
  272. smalltalk.method({
  273. selector: "localReturn:",
  274. fn: function (aBoolean) {
  275. var self=this;
  276. (self['@localReturn']=aBoolean);
  277. return self;}
  278. }),
  279. smalltalk.MethodLexicalScope);
  280. smalltalk.addMethod(
  281. "_methodScope",
  282. smalltalk.method({
  283. selector: "methodScope",
  284. fn: function () {
  285. var self=this;
  286. return self;
  287. return self;}
  288. }),
  289. smalltalk.MethodLexicalScope);
  290. smalltalk.addMethod(
  291. "_nonLocalReturn",
  292. smalltalk.method({
  293. selector: "nonLocalReturn",
  294. fn: function () {
  295. var self=this;
  296. return (($receiver = self['@nonLocalReturn']) == nil || $receiver == undefined) ? (function(){return false;})() : $receiver;
  297. return self;}
  298. }),
  299. smalltalk.MethodLexicalScope);
  300. smalltalk.addMethod(
  301. "_nonLocalReturn_",
  302. smalltalk.method({
  303. selector: "nonLocalReturn:",
  304. fn: function (aBoolean) {
  305. var self=this;
  306. (self['@nonLocalReturn']=aBoolean);
  307. return self;}
  308. }),
  309. smalltalk.MethodLexicalScope);
  310. smalltalk.addMethod(
  311. "_nonLocalReturns",
  312. smalltalk.method({
  313. selector: "nonLocalReturns",
  314. fn: function (){
  315. var self=this;
  316. return (($receiver = self['@nonLocalReturns']) == nil || $receiver == undefined) ? (function(){return (self['@nonLocalReturns']=smalltalk.send((smalltalk.OrderedCollection || OrderedCollection), "_new", []));})() : $receiver;
  317. return self;}
  318. }),
  319. smalltalk.MethodLexicalScope);
  320. smalltalk.addMethod(
  321. "_pseudoVars",
  322. smalltalk.method({
  323. selector: "pseudoVars",
  324. fn: function () {
  325. var self=this;
  326. (($receiver = (typeof pseudoVars == 'undefined' ? nil : pseudoVars)) == nil || $receiver == undefined) ? (function(){(pseudoVars=smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));return smalltalk.send(smalltalk.send(smalltalk.send((smalltalk.Smalltalk || Smalltalk), "_current", []), "_pseudoVariableNames", []), "_do_", [(function(each){return smalltalk.send((typeof pseudoVars == 'undefined' ? nil : pseudoVars), "_at_put_", [each, (function($rec){smalltalk.send($rec, "_scope_", [smalltalk.send(self, "_methodScope", [])]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send((smalltalk.PseudoVar || PseudoVar), "_on_", [each]))]);})]);})() : $receiver;
  327. return (typeof pseudoVars == 'undefined' ? nil : pseudoVars);
  328. return self;}
  329. }),
  330. smalltalk.MethodLexicalScope);
  331. smalltalk.addMethod(
  332. "_removeNonLocalReturn_",
  333. smalltalk.method({
  334. selector: "removeNonLocalReturn:",
  335. fn: function (aNode){
  336. var self=this;
  337. smalltalk.send(smalltalk.send(self, "_nonLocalReturns", []), "_remove_ifAbsent_", [aNode, (function(){return nil;})]);
  338. return self;}
  339. }),
  340. smalltalk.MethodLexicalScope);
  341. smalltalk.addMethod(
  342. "_unknownVariables",
  343. smalltalk.method({
  344. selector: "unknownVariables",
  345. fn: function () {
  346. var self=this;
  347. return (($receiver = self['@unknownVariables']) == nil || $receiver == undefined) ? (function(){return (self['@unknownVariables']=smalltalk.send((smalltalk.OrderedCollection || OrderedCollection), "_new", []));})() : $receiver;
  348. return self;}
  349. }),
  350. smalltalk.MethodLexicalScope);
  351. smalltalk.addClass('ScopeVar', smalltalk.Object, ['scope', 'name'], 'Compiler-Semantic');
  352. smalltalk.addMethod(
  353. "_alias",
  354. smalltalk.method({
  355. selector: "alias",
  356. fn: function () {
  357. var self=this;
  358. return smalltalk.send(smalltalk.send(self, "_name", []), "_asVariableName", []);
  359. return self;}
  360. }),
  361. smalltalk.ScopeVar);
  362. smalltalk.addMethod(
  363. "_isArgVar",
  364. smalltalk.method({
  365. selector: "isArgVar",
  366. fn: function () {
  367. var self=this;
  368. return false;
  369. return self;}
  370. }),
  371. smalltalk.ScopeVar);
  372. smalltalk.addMethod(
  373. "_isClassRefVar",
  374. smalltalk.method({
  375. selector: "isClassRefVar",
  376. fn: function (){
  377. var self=this;
  378. return false;
  379. return self;}
  380. }),
  381. smalltalk.ScopeVar);
  382. smalltalk.addMethod(
  383. "_isInstanceVar",
  384. smalltalk.method({
  385. selector: "isInstanceVar",
  386. fn: function () {
  387. var self=this;
  388. return false;
  389. return self;}
  390. }),
  391. smalltalk.ScopeVar);
  392. smalltalk.addMethod(
  393. "_isPseudoVar",
  394. smalltalk.method({
  395. selector: "isPseudoVar",
  396. fn: function () {
  397. var self=this;
  398. return false;
  399. return self;}
  400. }),
  401. smalltalk.ScopeVar);
  402. smalltalk.addMethod(
  403. "_isTempVar",
  404. smalltalk.method({
  405. selector: "isTempVar",
  406. fn: function () {
  407. var self=this;
  408. return false;
  409. return self;}
  410. }),
  411. smalltalk.ScopeVar);
  412. smalltalk.addMethod(
  413. "_isUnknownVar",
  414. smalltalk.method({
  415. selector: "isUnknownVar",
  416. fn: function () {
  417. var self=this;
  418. return false;
  419. return self;}
  420. }),
  421. smalltalk.ScopeVar);
  422. smalltalk.addMethod(
  423. "_name",
  424. smalltalk.method({
  425. selector: "name",
  426. fn: function () {
  427. var self=this;
  428. return self['@name'];
  429. return self;}
  430. }),
  431. smalltalk.ScopeVar);
  432. smalltalk.addMethod(
  433. "_name_",
  434. smalltalk.method({
  435. selector: "name:",
  436. fn: function (aString) {
  437. var self=this;
  438. (self['@name']=aString);
  439. return self;}
  440. }),
  441. smalltalk.ScopeVar);
  442. smalltalk.addMethod(
  443. "_scope",
  444. smalltalk.method({
  445. selector: "scope",
  446. fn: function () {
  447. var self=this;
  448. return self['@scope'];
  449. return self;}
  450. }),
  451. smalltalk.ScopeVar);
  452. smalltalk.addMethod(
  453. "_scope_",
  454. smalltalk.method({
  455. selector: "scope:",
  456. fn: function (aScope) {
  457. var self=this;
  458. (self['@scope']=aScope);
  459. return self;}
  460. }),
  461. smalltalk.ScopeVar);
  462. smalltalk.addMethod(
  463. "_validateAssignment",
  464. smalltalk.method({
  465. selector: "validateAssignment",
  466. fn: function () {
  467. var self=this;
  468. ((($receiver = smalltalk.send(smalltalk.send(self, "_isArgVar", []), "_or_", [(function(){return smalltalk.send(self, "_isPseudoVar", []);})])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return (function($rec){smalltalk.send($rec, "_variableName_", [smalltalk.send(self, "_name", [])]);return smalltalk.send($rec, "_signal", []);})(smalltalk.send((smalltalk.InvalidAssignmentError || InvalidAssignmentError), "_new", []));})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return (function($rec){smalltalk.send($rec, "_variableName_", [smalltalk.send(self, "_name", [])]);return smalltalk.send($rec, "_signal", []);})(smalltalk.send((smalltalk.InvalidAssignmentError || InvalidAssignmentError), "_new", []));})]));
  469. return self;}
  470. }),
  471. smalltalk.ScopeVar);
  472. smalltalk.addMethod(
  473. "_on_",
  474. smalltalk.method({
  475. selector: "on:",
  476. fn: function (aString) {
  477. var self=this;
  478. return (function($rec){smalltalk.send($rec, "_name_", [aString]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send(self, "_new", []));
  479. return self;}
  480. }),
  481. smalltalk.ScopeVar.klass);
  482. smalltalk.addClass('AliasVar', smalltalk.ScopeVar, ['node'], 'Compiler-Semantic');
  483. smalltalk.addMethod(
  484. "_node",
  485. smalltalk.method({
  486. selector: "node",
  487. fn: function () {
  488. var self=this;
  489. return self['@node'];
  490. return self;}
  491. }),
  492. smalltalk.AliasVar);
  493. smalltalk.addMethod(
  494. "_node_",
  495. smalltalk.method({
  496. selector: "node:",
  497. fn: function (aNode) {
  498. var self=this;
  499. (self['@node']=aNode);
  500. return self;}
  501. }),
  502. smalltalk.AliasVar);
  503. smalltalk.addClass('ArgVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');
  504. smalltalk.addMethod(
  505. "_isArgVar",
  506. smalltalk.method({
  507. selector: "isArgVar",
  508. fn: function () {
  509. var self=this;
  510. return true;
  511. return self;}
  512. }),
  513. smalltalk.ArgVar);
  514. smalltalk.addClass('ClassRefVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');
  515. smalltalk.addMethod(
  516. "_alias",
  517. smalltalk.method({
  518. selector: "alias",
  519. fn: function (){
  520. var self=this;
  521. return smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send("(smalltalk.", "__comma", [smalltalk.send(self, "_name", [])]), "__comma", [" || "]), "__comma", [smalltalk.send(self, "_name", [])]), "__comma", [")"]);
  522. return self;}
  523. }),
  524. smalltalk.ClassRefVar);
  525. smalltalk.addMethod(
  526. "_isClassRefVar",
  527. smalltalk.method({
  528. selector: "isClassRefVar",
  529. fn: function (){
  530. var self=this;
  531. return true;
  532. return self;}
  533. }),
  534. smalltalk.ClassRefVar);
  535. smalltalk.addClass('InstanceVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');
  536. smalltalk.addMethod(
  537. "_alias",
  538. smalltalk.method({
  539. selector: "alias",
  540. fn: function (){
  541. var self=this;
  542. return smalltalk.send(smalltalk.send("self[\x22@", "__comma", [smalltalk.send(self, "_name", [])]), "__comma", ["\x22]"]);
  543. return self;}
  544. }),
  545. smalltalk.InstanceVar);
  546. smalltalk.addMethod(
  547. "_isInstanceVar",
  548. smalltalk.method({
  549. selector: "isInstanceVar",
  550. fn: function () {
  551. var self=this;
  552. return true;
  553. return self;}
  554. }),
  555. smalltalk.InstanceVar);
  556. smalltalk.addClass('PseudoVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');
  557. smalltalk.addMethod(
  558. "_alias",
  559. smalltalk.method({
  560. selector: "alias",
  561. fn: function () {
  562. var self=this;
  563. return smalltalk.send(self, "_name", []);
  564. return self;}
  565. }),
  566. smalltalk.PseudoVar);
  567. smalltalk.addMethod(
  568. "_isPseudoVar",
  569. smalltalk.method({
  570. selector: "isPseudoVar",
  571. fn: function () {
  572. var self=this;
  573. return true;
  574. return self;}
  575. }),
  576. smalltalk.PseudoVar);
  577. smalltalk.addClass('TempVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');
  578. smalltalk.addMethod(
  579. "_isTempVar",
  580. smalltalk.method({
  581. selector: "isTempVar",
  582. fn: function () {
  583. var self=this;
  584. return true;
  585. return self;}
  586. }),
  587. smalltalk.TempVar);
  588. smalltalk.addClass('UnknownVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');
  589. smalltalk.addMethod(
  590. "_isUnknownVar",
  591. smalltalk.method({
  592. selector: "isUnknownVar",
  593. fn: function () {
  594. var self=this;
  595. return true;
  596. return self;}
  597. }),
  598. smalltalk.UnknownVar);
  599. smalltalk.addClass('SemanticAnalyzer', smalltalk.NodeVisitor, ['currentScope', 'theClass', 'classReferences', 'messageSends'], 'Compiler-Semantic');
  600. smalltalk.addMethod(
  601. "_allowUnknownVariables",
  602. smalltalk.method({
  603. selector: "allowUnknownVariables",
  604. fn: function () {
  605. var self=this;
  606. return true;
  607. return self;}
  608. }),
  609. smalltalk.SemanticAnalyzer);
  610. smalltalk.addMethod(
  611. "_classReferences",
  612. smalltalk.method({
  613. selector: "classReferences",
  614. fn: function () {
  615. var self=this;
  616. return (($receiver = self['@classReferences']) == nil || $receiver == undefined) ? (function(){return (self['@classReferences']=smalltalk.send((smalltalk.Set || Set), "_new", []));})() : $receiver;
  617. return self;}
  618. }),
  619. smalltalk.SemanticAnalyzer);
  620. smalltalk.addMethod(
  621. "_errorShadowingVariable_",
  622. smalltalk.method({
  623. selector: "errorShadowingVariable:",
  624. fn: function (aString) {
  625. var self=this;
  626. (function($rec){smalltalk.send($rec, "_variableName_", [aString]);return smalltalk.send($rec, "_signal", []);})(smalltalk.send((smalltalk.ShadowingVariableError || ShadowingVariableError), "_new", []));
  627. return self;}
  628. }),
  629. smalltalk.SemanticAnalyzer);
  630. smalltalk.addMethod(
  631. "_errorUnknownVariable_",
  632. smalltalk.method({
  633. selector: "errorUnknownVariable:",
  634. fn: function (aNode) {
  635. var self=this;
  636. ((($receiver = smalltalk.send(self, "_allowUnknownVariables", [])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(smalltalk.send(smalltalk.send(self['@currentScope'], "_methodScope", []), "_unknownVariables", []), "_add_", [smalltalk.send(aNode, "_value", [])]);})() : (function(){return (function($rec){smalltalk.send($rec, "_variableName_", [smalltalk.send(aNode, "_value", [])]);return smalltalk.send($rec, "_signal", []);})(smalltalk.send((smalltalk.UnknownVariableError || UnknownVariableError), "_new", []));})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return smalltalk.send(smalltalk.send(smalltalk.send(self['@currentScope'], "_methodScope", []), "_unknownVariables", []), "_add_", [smalltalk.send(aNode, "_value", [])]);}), (function(){return (function($rec){smalltalk.send($rec, "_variableName_", [smalltalk.send(aNode, "_value", [])]);return smalltalk.send($rec, "_signal", []);})(smalltalk.send((smalltalk.UnknownVariableError || UnknownVariableError), "_new", []));})]));
  637. return self;}
  638. }),
  639. smalltalk.SemanticAnalyzer);
  640. smalltalk.addMethod(
  641. "_messageSends",
  642. smalltalk.method({
  643. selector: "messageSends",
  644. fn: function () {
  645. var self=this;
  646. return (($receiver = self['@messageSends']) == nil || $receiver == undefined) ? (function(){return (self['@messageSends']=smalltalk.send((smalltalk.Set || Set), "_new", []));})() : $receiver;
  647. return self;}
  648. }),
  649. smalltalk.SemanticAnalyzer);
  650. smalltalk.addMethod(
  651. "_newBlockScope",
  652. smalltalk.method({
  653. selector: "newBlockScope",
  654. fn: function () {
  655. var self=this;
  656. return smalltalk.send(self, "_newScopeOfClass_", [(smalltalk.LexicalScope || LexicalScope)]);
  657. return self;}
  658. }),
  659. smalltalk.SemanticAnalyzer);
  660. smalltalk.addMethod(
  661. "_newMethodScope",
  662. smalltalk.method({
  663. selector: "newMethodScope",
  664. fn: function () {
  665. var self=this;
  666. return smalltalk.send(self, "_newScopeOfClass_", [(smalltalk.MethodLexicalScope || MethodLexicalScope)]);
  667. return self;}
  668. }),
  669. smalltalk.SemanticAnalyzer);
  670. smalltalk.addMethod(
  671. "_newScopeOfClass_",
  672. smalltalk.method({
  673. selector: "newScopeOfClass:",
  674. fn: function (aLexicalScopeClass) {
  675. var self=this;
  676. return (function($rec){smalltalk.send($rec, "_outerScope_", [self['@currentScope']]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send(aLexicalScopeClass, "_new", []));
  677. return self;}
  678. }),
  679. smalltalk.SemanticAnalyzer);
  680. smalltalk.addMethod(
  681. "_popScope",
  682. smalltalk.method({
  683. selector: "popScope",
  684. fn: function () {
  685. var self=this;
  686. (($receiver = self['@currentScope']) != nil && $receiver != undefined) ? (function(){return (self['@currentScope']=smalltalk.send(self['@currentScope'], "_outerScope", []));})() : nil;
  687. return self;}
  688. }),
  689. smalltalk.SemanticAnalyzer);
  690. smalltalk.addMethod(
  691. "_pseudoVariables",
  692. smalltalk.method({
  693. selector: "pseudoVariables",
  694. fn: function () {
  695. var self=this;
  696. return ["self", "super", "true", "false", "nil", "thisContext"];
  697. return self;}
  698. }),
  699. smalltalk.SemanticAnalyzer);
  700. smalltalk.addMethod(
  701. "_pushScope_",
  702. smalltalk.method({
  703. selector: "pushScope:",
  704. fn: function (aScope) {
  705. var self=this;
  706. smalltalk.send(aScope, "_outerScope_", [self['@currentScope']]);
  707. (self['@currentScope']=aScope);
  708. return self;}
  709. }),
  710. smalltalk.SemanticAnalyzer);
  711. smalltalk.addMethod(
  712. "_theClass",
  713. smalltalk.method({
  714. selector: "theClass",
  715. fn: function () {
  716. var self=this;
  717. return self['@theClass'];
  718. return self;}
  719. }),
  720. smalltalk.SemanticAnalyzer);
  721. smalltalk.addMethod(
  722. "_theClass_",
  723. smalltalk.method({
  724. selector: "theClass:",
  725. fn: function (aClass) {
  726. var self=this;
  727. (self['@theClass']=aClass);
  728. return self;}
  729. }),
  730. smalltalk.SemanticAnalyzer);
  731. smalltalk.addMethod(
  732. "_validateVariableScope_",
  733. smalltalk.method({
  734. selector: "validateVariableScope:",
  735. fn: function (aString) {
  736. var self=this;
  737. (($receiver = smalltalk.send(self['@currentScope'], "_lookupVariable_", [aString])) != nil && $receiver != undefined) ? (function(){return smalltalk.send(self, "_errorShadowingVariable_", [aString]);})() : nil;
  738. return self;}
  739. }),
  740. smalltalk.SemanticAnalyzer);
  741. smalltalk.addMethod(
  742. "_visitAssignmentNode_",
  743. smalltalk.method({
  744. selector: "visitAssignmentNode:",
  745. fn: function (aNode) {
  746. var self=this;
  747. smalltalk.send(self, "_visitAssignmentNode_", [aNode], smalltalk.SemanticAnalyzer.superclass || nil);
  748. smalltalk.send(smalltalk.send(aNode, "_left", []), "_beAssigned", []);
  749. smalltalk.send(smalltalk.send(aNode, "_right", []), "_beUsed", []);
  750. return self;}
  751. }),
  752. smalltalk.SemanticAnalyzer);
  753. smalltalk.addMethod(
  754. "_visitBlockNode_",
  755. smalltalk.method({
  756. selector: "visitBlockNode:",
  757. fn: function (aNode){
  758. var self=this;
  759. smalltalk.send(self, "_pushScope_", [smalltalk.send(self, "_newBlockScope", [])]);
  760. smalltalk.send(aNode, "_scope_", [self['@currentScope']]);
  761. smalltalk.send(self['@currentScope'], "_node_", [aNode]);
  762. smalltalk.send(smalltalk.send(aNode, "_parameters", []), "_do_", [(function(each){smalltalk.send(self, "_validateVariableScope_", [each]);return smalltalk.send(self['@currentScope'], "_addArg_", [each]);})]);
  763. smalltalk.send(self, "_visitBlockNode_", [aNode], smalltalk.SemanticAnalyzer.superclass || nil);
  764. smalltalk.send(self, "_popScope", []);
  765. return self;}
  766. }),
  767. smalltalk.SemanticAnalyzer);
  768. smalltalk.addMethod(
  769. "_visitCascadeNode_",
  770. smalltalk.method({
  771. selector: "visitCascadeNode:",
  772. fn: function (aNode){
  773. var self=this;
  774. var $1,$2,$3,$4,$5,$6,$7,$8,$9;
  775. $1=(function(each){
  776. $2=smalltalk.send(aNode,"_receiver",[]);
  777. return smalltalk.send(each,"_receiver_",[$2]);
  778. });
  779. $3=smalltalk.send(aNode,"_nodes",[]);
  780. smalltalk.send($3,"_do_",[$1]);
  781. smalltalk.send(self,"_visitCascadeNode_",[aNode],smalltalk.NodeVisitor);
  782. $4=(function(){
  783. $5=(function(each){
  784. return smalltalk.send(each,"_superSend_",[true]);
  785. });
  786. $6=smalltalk.send(aNode,"_nodes",[]);
  787. return smalltalk.send($6,"_do_",[$5]);
  788. });
  789. $7=smalltalk.send(aNode,"_nodes",[]);
  790. $8=smalltalk.send($7,"_first",[]);
  791. $9=smalltalk.send($8,"_superSend",[]);
  792. smalltalk.send($9,"_ifTrue_",[$4]);
  793. return self}
  794. }),
  795. smalltalk.SemanticAnalyzer);
  796. smalltalk.addMethod(
  797. "_visitClassReferenceNode_",
  798. smalltalk.method({
  799. selector: "visitClassReferenceNode:",
  800. fn: function (aNode) {
  801. var self=this;
  802. smalltalk.send(smalltalk.send(self, "_classReferences", []), "_add_", [smalltalk.send(aNode, "_value", [])]);
  803. smalltalk.send(aNode, "_binding_", [(function($rec){smalltalk.send($rec, "_name_", [smalltalk.send(aNode, "_value", [])]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send((smalltalk.ClassRefVar || ClassRefVar), "_new", []))]);
  804. return self;}
  805. }),
  806. smalltalk.SemanticAnalyzer);
  807. smalltalk.addMethod(
  808. "_visitMethodNode_",
  809. smalltalk.method({
  810. selector: "visitMethodNode:",
  811. fn: function (aNode){
  812. var self=this;
  813. smalltalk.send(self, "_pushScope_", [smalltalk.send(self, "_newMethodScope", [])]);
  814. smalltalk.send(aNode, "_scope_", [self['@currentScope']]);
  815. smalltalk.send(self['@currentScope'], "_node_", [aNode]);
  816. smalltalk.send(smalltalk.send(smalltalk.send(self, "_theClass", []), "_allInstanceVariableNames", []), "_do_", [(function(each){return smalltalk.send(self['@currentScope'], "_addIVar_", [each]);})]);
  817. smalltalk.send(smalltalk.send(aNode, "_arguments", []), "_do_", [(function(each){smalltalk.send(self, "_validateVariableScope_", [each]);return smalltalk.send(self['@currentScope'], "_addArg_", [each]);})]);
  818. smalltalk.send(self, "_visitMethodNode_", [aNode], smalltalk.SemanticAnalyzer.superclass || nil);
  819. (function($rec){smalltalk.send($rec, "_classReferences_", [smalltalk.send(self, "_classReferences", [])]);return smalltalk.send($rec, "_messageSends_", [smalltalk.send(self, "_messageSends", [])]);})(aNode);
  820. smalltalk.send(self, "_popScope", []);
  821. return self;}
  822. }),
  823. smalltalk.SemanticAnalyzer);
  824. smalltalk.addMethod(
  825. "_visitReturnNode_",
  826. smalltalk.method({
  827. selector: "visitReturnNode:",
  828. fn: function (aNode){
  829. var self=this;
  830. ((($receiver = smalltalk.send(self['@currentScope'], "_isMethodScope", [])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(self['@currentScope'], "_localReturn_", [true]);})() : (function(){smalltalk.send(smalltalk.send(self['@currentScope'], "_methodScope", []), "_addNonLocalReturn_", [aNode]);return smalltalk.send(aNode, "_nonLocalReturn_", [true]);})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return smalltalk.send(self['@currentScope'], "_localReturn_", [true]);}), (function(){smalltalk.send(smalltalk.send(self['@currentScope'], "_methodScope", []), "_addNonLocalReturn_", [aNode]);return smalltalk.send(aNode, "_nonLocalReturn_", [true]);})]));
  831. smalltalk.send(smalltalk.send(smalltalk.send(aNode, "_nodes", []), "_first", []), "_beUsed", []);
  832. smalltalk.send(self, "_visitReturnNode_", [aNode], smalltalk.SemanticAnalyzer.superclass || nil);
  833. return self;}
  834. }),
  835. smalltalk.SemanticAnalyzer);
  836. smalltalk.addMethod(
  837. "_visitSendNode_",
  838. smalltalk.method({
  839. selector: "visitSendNode:",
  840. fn: function (aNode){
  841. var self=this;
  842. ((($receiver = smalltalk.send(smalltalk.send(smalltalk.send(aNode, "_receiver", []), "_value", []), "__eq", ["super"])).klass === smalltalk.Boolean) ? ($receiver ? (function(){smalltalk.send(aNode, "_superSend_", [true]);return smalltalk.send(smalltalk.send(aNode, "_receiver", []), "_value_", ["self"]);})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){smalltalk.send(aNode, "_superSend_", [true]);return smalltalk.send(smalltalk.send(aNode, "_receiver", []), "_value_", ["self"]);})]));
  843. smalltalk.send(smalltalk.send(self, "_messageSends", []), "_add_", [smalltalk.send(aNode, "_selector", [])]);
  844. (($receiver = smalltalk.send(aNode, "_receiver", [])) != nil && $receiver != undefined) ? (function(){return smalltalk.send(smalltalk.send(aNode, "_receiver", []), "_beUsed", []);})() : nil;
  845. smalltalk.send(smalltalk.send(aNode, "_arguments", []), "_do_", [(function(each){return ((($receiver = smalltalk.send(each, "_isSendNode", [])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(each, "_beUsed", []);})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return smalltalk.send(each, "_beUsed", []);})]));})]);
  846. smalltalk.send(self, "_visitSendNode_", [aNode], smalltalk.SemanticAnalyzer.superclass || nil);
  847. return self;}
  848. }),
  849. smalltalk.SemanticAnalyzer);
  850. smalltalk.addMethod(
  851. "_visitSequenceNode_",
  852. smalltalk.method({
  853. selector: "visitSequenceNode:",
  854. fn: function (aNode) {
  855. var self=this;
  856. smalltalk.send(smalltalk.send(aNode, "_temps", []), "_do_", [(function(each){smalltalk.send(self, "_validateVariableScope_", [each]);return smalltalk.send(self['@currentScope'], "_addTemp_", [each]);})]);
  857. smalltalk.send(self, "_visitSequenceNode_", [aNode], smalltalk.SemanticAnalyzer.superclass || nil);
  858. return self;}
  859. }),
  860. smalltalk.SemanticAnalyzer);
  861. smalltalk.addMethod(
  862. "_visitVariableNode_",
  863. smalltalk.method({
  864. selector: "visitVariableNode:",
  865. fn: function (aNode) {
  866. var self=this;
  867. smalltalk.send(aNode, "_binding_", [(($receiver = smalltalk.send(self['@currentScope'], "_lookupVariable_", [aNode])) == nil || $receiver == undefined) ? (function(){smalltalk.send(self, "_errorUnknownVariable_", [aNode]);return (function($rec){smalltalk.send($rec, "_name_", [smalltalk.send(aNode, "_value", [])]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send((smalltalk.UnknownVar || UnknownVar), "_new", []));})() : $receiver]);
  868. return self;}
  869. }),
  870. smalltalk.SemanticAnalyzer);
  871. smalltalk.addMethod(
  872. "_on_",
  873. smalltalk.method({
  874. selector: "on:",
  875. fn: function (aClass) {
  876. var self=this;
  877. return (function($rec){smalltalk.send($rec, "_theClass_", [aClass]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send(self, "_new", []));
  878. return self;}
  879. }),
  880. smalltalk.SemanticAnalyzer.klass);