1
0

Compiler-Semantic.deploy.js 27 KB

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