Compiler-Semantic.deploy.js 28 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235
  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. "_allowUnknownVariables",
  759. smalltalk.method({
  760. selector: "allowUnknownVariables",
  761. fn: function (){
  762. var self=this;
  763. return true;
  764. }
  765. }),
  766. smalltalk.SemanticAnalyzer);
  767. smalltalk.addMethod(
  768. "_classReferences",
  769. smalltalk.method({
  770. selector: "classReferences",
  771. fn: function (){
  772. var self=this;
  773. var $1;
  774. if(($receiver = self["@classReferences"]) == nil || $receiver == undefined){
  775. self["@classReferences"]=smalltalk.send((smalltalk.Set || Set),"_new",[]);
  776. $1=self["@classReferences"];
  777. } else {
  778. $1=self["@classReferences"];
  779. };
  780. return $1;
  781. }
  782. }),
  783. smalltalk.SemanticAnalyzer);
  784. smalltalk.addMethod(
  785. "_errorShadowingVariable_",
  786. smalltalk.method({
  787. selector: "errorShadowingVariable:",
  788. fn: function (aString){
  789. var self=this;
  790. var $1,$2;
  791. $1=smalltalk.send((smalltalk.ShadowingVariableError || ShadowingVariableError),"_new",[]);
  792. smalltalk.send($1,"_variableName_",[aString]);
  793. $2=smalltalk.send($1,"_signal",[]);
  794. return self}
  795. }),
  796. smalltalk.SemanticAnalyzer);
  797. smalltalk.addMethod(
  798. "_errorUnknownVariable_",
  799. smalltalk.method({
  800. selector: "errorUnknownVariable:",
  801. fn: function (aNode){
  802. var self=this;
  803. var $1,$2,$3;
  804. $1=smalltalk.send(self,"_allowUnknownVariables",[]);
  805. if(smalltalk.assert($1)){
  806. smalltalk.send(smalltalk.send(smalltalk.send(self["@currentScope"],"_methodScope",[]),"_unknownVariables",[]),"_add_",[smalltalk.send(aNode,"_value",[])]);
  807. } else {
  808. $2=smalltalk.send((smalltalk.UnknownVariableError || UnknownVariableError),"_new",[]);
  809. smalltalk.send($2,"_variableName_",[smalltalk.send(aNode,"_value",[])]);
  810. $3=smalltalk.send($2,"_signal",[]);
  811. $3;
  812. };
  813. return self}
  814. }),
  815. smalltalk.SemanticAnalyzer);
  816. smalltalk.addMethod(
  817. "_messageSends",
  818. smalltalk.method({
  819. selector: "messageSends",
  820. fn: function (){
  821. var self=this;
  822. var $1;
  823. if(($receiver = self["@messageSends"]) == nil || $receiver == undefined){
  824. self["@messageSends"]=smalltalk.send((smalltalk.Dictionary || Dictionary),"_new",[]);
  825. $1=self["@messageSends"];
  826. } else {
  827. $1=self["@messageSends"];
  828. };
  829. return $1;
  830. }
  831. }),
  832. smalltalk.SemanticAnalyzer);
  833. smalltalk.addMethod(
  834. "_newBlockScope",
  835. smalltalk.method({
  836. selector: "newBlockScope",
  837. fn: function (){
  838. var self=this;
  839. var $1;
  840. $1=smalltalk.send(self,"_newScopeOfClass_",[(smalltalk.LexicalScope || LexicalScope)]);
  841. return $1;
  842. }
  843. }),
  844. smalltalk.SemanticAnalyzer);
  845. smalltalk.addMethod(
  846. "_newMethodScope",
  847. smalltalk.method({
  848. selector: "newMethodScope",
  849. fn: function (){
  850. var self=this;
  851. var $1;
  852. $1=smalltalk.send(self,"_newScopeOfClass_",[(smalltalk.MethodLexicalScope || MethodLexicalScope)]);
  853. return $1;
  854. }
  855. }),
  856. smalltalk.SemanticAnalyzer);
  857. smalltalk.addMethod(
  858. "_newScopeOfClass_",
  859. smalltalk.method({
  860. selector: "newScopeOfClass:",
  861. fn: function (aLexicalScopeClass){
  862. var self=this;
  863. var $2,$3,$1;
  864. $2=smalltalk.send(aLexicalScopeClass,"_new",[]);
  865. smalltalk.send($2,"_outerScope_",[self["@currentScope"]]);
  866. $3=smalltalk.send($2,"_yourself",[]);
  867. $1=$3;
  868. return $1;
  869. }
  870. }),
  871. smalltalk.SemanticAnalyzer);
  872. smalltalk.addMethod(
  873. "_popScope",
  874. smalltalk.method({
  875. selector: "popScope",
  876. fn: function (){
  877. var self=this;
  878. if(($receiver = self["@currentScope"]) == nil || $receiver == undefined){
  879. self["@currentScope"];
  880. } else {
  881. self["@currentScope"]=smalltalk.send(self["@currentScope"],"_outerScope",[]);
  882. self["@currentScope"];
  883. };
  884. return self}
  885. }),
  886. smalltalk.SemanticAnalyzer);
  887. smalltalk.addMethod(
  888. "_pseudoVariables",
  889. smalltalk.method({
  890. selector: "pseudoVariables",
  891. fn: function (){
  892. var self=this;
  893. return ["self", "super", "true", "false", "nil", "thisContext"];
  894. }
  895. }),
  896. smalltalk.SemanticAnalyzer);
  897. smalltalk.addMethod(
  898. "_pushScope_",
  899. smalltalk.method({
  900. selector: "pushScope:",
  901. fn: function (aScope){
  902. var self=this;
  903. smalltalk.send(aScope,"_outerScope_",[self["@currentScope"]]);
  904. self["@currentScope"]=aScope;
  905. return self}
  906. }),
  907. smalltalk.SemanticAnalyzer);
  908. smalltalk.addMethod(
  909. "_theClass",
  910. smalltalk.method({
  911. selector: "theClass",
  912. fn: function (){
  913. var self=this;
  914. return self["@theClass"];
  915. }
  916. }),
  917. smalltalk.SemanticAnalyzer);
  918. smalltalk.addMethod(
  919. "_theClass_",
  920. smalltalk.method({
  921. selector: "theClass:",
  922. fn: function (aClass){
  923. var self=this;
  924. self["@theClass"]=aClass;
  925. return self}
  926. }),
  927. smalltalk.SemanticAnalyzer);
  928. smalltalk.addMethod(
  929. "_validateVariableScope_",
  930. smalltalk.method({
  931. selector: "validateVariableScope:",
  932. fn: function (aString){
  933. var self=this;
  934. var $1;
  935. $1=smalltalk.send(self["@currentScope"],"_lookupVariable_",[aString]);
  936. if(($receiver = $1) == nil || $receiver == undefined){
  937. $1;
  938. } else {
  939. smalltalk.send(self,"_errorShadowingVariable_",[aString]);
  940. };
  941. return self}
  942. }),
  943. smalltalk.SemanticAnalyzer);
  944. smalltalk.addMethod(
  945. "_visitAssignmentNode_",
  946. smalltalk.method({
  947. selector: "visitAssignmentNode:",
  948. fn: function (aNode){
  949. var self=this;
  950. smalltalk.send(self,"_visitAssignmentNode_",[aNode],smalltalk.NodeVisitor);
  951. smalltalk.send(smalltalk.send(aNode,"_left",[]),"_beAssigned",[]);
  952. return self}
  953. }),
  954. smalltalk.SemanticAnalyzer);
  955. smalltalk.addMethod(
  956. "_visitBlockNode_",
  957. smalltalk.method({
  958. selector: "visitBlockNode:",
  959. fn: function (aNode){
  960. var self=this;
  961. smalltalk.send(self,"_pushScope_",[smalltalk.send(self,"_newBlockScope",[])]);
  962. smalltalk.send(aNode,"_scope_",[self["@currentScope"]]);
  963. smalltalk.send(self["@currentScope"],"_node_",[aNode]);
  964. smalltalk.send(smalltalk.send(aNode,"_parameters",[]),"_do_",[(function(each){
  965. smalltalk.send(self,"_validateVariableScope_",[each]);
  966. return smalltalk.send(self["@currentScope"],"_addArg_",[each]);
  967. })]);
  968. smalltalk.send(self,"_visitBlockNode_",[aNode],smalltalk.NodeVisitor);
  969. smalltalk.send(self,"_popScope",[]);
  970. return self}
  971. }),
  972. smalltalk.SemanticAnalyzer);
  973. smalltalk.addMethod(
  974. "_visitCascadeNode_",
  975. smalltalk.method({
  976. selector: "visitCascadeNode:",
  977. fn: function (aNode){
  978. var self=this;
  979. var $1;
  980. smalltalk.send(smalltalk.send(aNode,"_nodes",[]),"_do_",[(function(each){
  981. return smalltalk.send(each,"_receiver_",[smalltalk.send(aNode,"_receiver",[])]);
  982. })]);
  983. smalltalk.send(self,"_visitCascadeNode_",[aNode],smalltalk.NodeVisitor);
  984. $1=smalltalk.send(smalltalk.send(smalltalk.send(aNode,"_nodes",[]),"_first",[]),"_superSend",[]);
  985. if(smalltalk.assert($1)){
  986. smalltalk.send(smalltalk.send(aNode,"_nodes",[]),"_do_",[(function(each){
  987. return smalltalk.send(each,"_superSend_",[true]);
  988. })]);
  989. };
  990. return self}
  991. }),
  992. smalltalk.SemanticAnalyzer);
  993. smalltalk.addMethod(
  994. "_visitClassReferenceNode_",
  995. smalltalk.method({
  996. selector: "visitClassReferenceNode:",
  997. fn: function (aNode){
  998. var self=this;
  999. var $1,$2;
  1000. smalltalk.send(smalltalk.send(self,"_classReferences",[]),"_add_",[smalltalk.send(aNode,"_value",[])]);
  1001. $1=smalltalk.send((smalltalk.ClassRefVar || ClassRefVar),"_new",[]);
  1002. smalltalk.send($1,"_name_",[smalltalk.send(aNode,"_value",[])]);
  1003. $2=smalltalk.send($1,"_yourself",[]);
  1004. smalltalk.send(aNode,"_binding_",[$2]);
  1005. return self}
  1006. }),
  1007. smalltalk.SemanticAnalyzer);
  1008. smalltalk.addMethod(
  1009. "_visitMethodNode_",
  1010. smalltalk.method({
  1011. selector: "visitMethodNode:",
  1012. fn: function (aNode){
  1013. var self=this;
  1014. var $1;
  1015. smalltalk.send(self,"_pushScope_",[smalltalk.send(self,"_newMethodScope",[])]);
  1016. smalltalk.send(aNode,"_scope_",[self["@currentScope"]]);
  1017. smalltalk.send(self["@currentScope"],"_node_",[aNode]);
  1018. smalltalk.send(smalltalk.send(smalltalk.send(self,"_theClass",[]),"_allInstanceVariableNames",[]),"_do_",[(function(each){
  1019. return smalltalk.send(self["@currentScope"],"_addIVar_",[each]);
  1020. })]);
  1021. smalltalk.send(smalltalk.send(aNode,"_arguments",[]),"_do_",[(function(each){
  1022. smalltalk.send(self,"_validateVariableScope_",[each]);
  1023. return smalltalk.send(self["@currentScope"],"_addArg_",[each]);
  1024. })]);
  1025. smalltalk.send(self,"_visitMethodNode_",[aNode],smalltalk.NodeVisitor);
  1026. smalltalk.send(aNode,"_classReferences_",[smalltalk.send(self,"_classReferences",[])]);
  1027. $1=smalltalk.send(aNode,"_messageSends_",[smalltalk.send(smalltalk.send(self,"_messageSends",[]),"_keys",[])]);
  1028. smalltalk.send(self,"_popScope",[]);
  1029. return self}
  1030. }),
  1031. smalltalk.SemanticAnalyzer);
  1032. smalltalk.addMethod(
  1033. "_visitReturnNode_",
  1034. smalltalk.method({
  1035. selector: "visitReturnNode:",
  1036. fn: function (aNode){
  1037. var self=this;
  1038. var $1;
  1039. smalltalk.send(aNode,"_scope_",[self["@currentScope"]]);
  1040. $1=smalltalk.send(self["@currentScope"],"_isMethodScope",[]);
  1041. if(smalltalk.assert($1)){
  1042. smalltalk.send(self["@currentScope"],"_localReturn_",[true]);
  1043. } else {
  1044. smalltalk.send(smalltalk.send(self["@currentScope"],"_methodScope",[]),"_addNonLocalReturn_",[self["@currentScope"]]);
  1045. };
  1046. smalltalk.send(self,"_visitReturnNode_",[aNode],smalltalk.NodeVisitor);
  1047. return self}
  1048. }),
  1049. smalltalk.SemanticAnalyzer);
  1050. smalltalk.addMethod(
  1051. "_visitSendNode_",
  1052. smalltalk.method({
  1053. selector: "visitSendNode:",
  1054. fn: function (aNode){
  1055. var self=this;
  1056. var $1,$2,$3;
  1057. $1=smalltalk.send(smalltalk.send(smalltalk.send(aNode,"_receiver",[]),"_value",[]),"__eq",["super"]);
  1058. if(smalltalk.assert($1)){
  1059. smalltalk.send(aNode,"_superSend_",[true]);
  1060. smalltalk.send(smalltalk.send(aNode,"_receiver",[]),"_value_",["self"]);
  1061. } else {
  1062. $2=smalltalk.send(smalltalk.send((smalltalk.IRSendInliner || IRSendInliner),"_inlinedSelectors",[]),"_includes_",[smalltalk.send(aNode,"_selector",[])]);
  1063. if(smalltalk.assert($2)){
  1064. smalltalk.send(aNode,"_shouldBeInlined_",[true]);
  1065. $3=smalltalk.send(smalltalk.send(aNode,"_receiver",[]),"_isValueNode",[]);
  1066. if(! smalltalk.assert($3)){
  1067. smalltalk.send(smalltalk.send(aNode,"_receiver",[]),"_shouldBeAliased_",[true]);
  1068. };
  1069. };
  1070. };
  1071. smalltalk.send(smalltalk.send(self,"_messageSends",[]),"_at_ifAbsentPut_",[smalltalk.send(aNode,"_selector",[]),(function(){
  1072. return smalltalk.send((smalltalk.Set || Set),"_new",[]);
  1073. })]);
  1074. smalltalk.send(smalltalk.send(smalltalk.send(self,"_messageSends",[]),"_at_",[smalltalk.send(aNode,"_selector",[])]),"_add_",[aNode]);
  1075. smalltalk.send(aNode,"_index_",[smalltalk.send(smalltalk.send(smalltalk.send(self,"_messageSends",[]),"_at_",[smalltalk.send(aNode,"_selector",[])]),"_size",[])]);
  1076. smalltalk.send(self,"_visitSendNode_",[aNode],smalltalk.NodeVisitor);
  1077. return self}
  1078. }),
  1079. smalltalk.SemanticAnalyzer);
  1080. smalltalk.addMethod(
  1081. "_visitSequenceNode_",
  1082. smalltalk.method({
  1083. selector: "visitSequenceNode:",
  1084. fn: function (aNode){
  1085. var self=this;
  1086. smalltalk.send(smalltalk.send(aNode,"_temps",[]),"_do_",[(function(each){
  1087. smalltalk.send(self,"_validateVariableScope_",[each]);
  1088. return smalltalk.send(self["@currentScope"],"_addTemp_",[each]);
  1089. })]);
  1090. smalltalk.send(self,"_visitSequenceNode_",[aNode],smalltalk.NodeVisitor);
  1091. return self}
  1092. }),
  1093. smalltalk.SemanticAnalyzer);
  1094. smalltalk.addMethod(
  1095. "_visitVariableNode_",
  1096. smalltalk.method({
  1097. selector: "visitVariableNode:",
  1098. fn: function (aNode){
  1099. var self=this;
  1100. var $2,$3,$4,$1;
  1101. $2=smalltalk.send(self["@currentScope"],"_lookupVariable_",[aNode]);
  1102. if(($receiver = $2) == nil || $receiver == undefined){
  1103. smalltalk.send(self,"_errorUnknownVariable_",[aNode]);
  1104. $3=smalltalk.send((smalltalk.UnknownVar || UnknownVar),"_new",[]);
  1105. smalltalk.send($3,"_name_",[smalltalk.send(aNode,"_value",[])]);
  1106. $4=smalltalk.send($3,"_yourself",[]);
  1107. $1=$4;
  1108. } else {
  1109. $1=$2;
  1110. };
  1111. smalltalk.send(aNode,"_binding_",[$1]);
  1112. return self}
  1113. }),
  1114. smalltalk.SemanticAnalyzer);
  1115. smalltalk.addMethod(
  1116. "_on_",
  1117. smalltalk.method({
  1118. selector: "on:",
  1119. fn: function (aClass){
  1120. var self=this;
  1121. var $2,$3,$1;
  1122. $2=smalltalk.send(self,"_new",[]);
  1123. smalltalk.send($2,"_theClass_",[aClass]);
  1124. $3=smalltalk.send($2,"_yourself",[]);
  1125. $1=$3;
  1126. return $1;
  1127. }
  1128. }),
  1129. smalltalk.SemanticAnalyzer.klass);