Compiler-Semantic.js 56 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739
  1. smalltalk.addPackage('Compiler-Semantic', {});
  2. smalltalk.addClass('LexicalScope', smalltalk.Object, ['node', 'instruction', 'temps', 'args', 'outerScope'], 'Compiler-Semantic');
  3. smalltalk.LexicalScope.comment="I represent a lexical scope where variable names are associated with ScopeVars\x0aInstances are used for block scopes. Method scopes are instances of MethodLexicalScope.\x0a\x0aI am attached to a ScopeVar and method/block nodes.\x0aEach context (method/closure) get a fresh scope that inherits from its outer scope."
  4. smalltalk.addMethod(
  5. "_addArg_",
  6. smalltalk.method({
  7. selector: "addArg:",
  8. category: 'adding',
  9. fn: function (aString){
  10. var self=this;
  11. return smalltalk.withContext(function($ctx1) { _st(_st(self)._args())._at_put_(aString,_st((smalltalk.ArgVar || ArgVar))._on_(aString));
  12. _st(_st(_st(self)._args())._at_(aString))._scope_(self);
  13. return self}, self, "addArg:", [aString], smalltalk.LexicalScope)},
  14. args: ["aString"],
  15. source: "addArg: aString\x0a\x09self args at: aString put: (ArgVar on: aString).\x0a\x09(self args at: aString) scope: self",
  16. messageSends: ["at:put:", "on:", "args", "scope:", "at:"],
  17. referencedClasses: ["ArgVar"]
  18. }),
  19. smalltalk.LexicalScope);
  20. smalltalk.addMethod(
  21. "_addTemp_",
  22. smalltalk.method({
  23. selector: "addTemp:",
  24. category: 'adding',
  25. fn: function (aString){
  26. var self=this;
  27. return smalltalk.withContext(function($ctx1) { _st(_st(self)._temps())._at_put_(aString,_st((smalltalk.TempVar || TempVar))._on_(aString));
  28. _st(_st(_st(self)._temps())._at_(aString))._scope_(self);
  29. return self}, self, "addTemp:", [aString], smalltalk.LexicalScope)},
  30. args: ["aString"],
  31. source: "addTemp: aString\x0a\x09self temps at: aString put: (TempVar on: aString).\x0a\x09(self temps at: aString) scope: self",
  32. messageSends: ["at:put:", "on:", "temps", "scope:", "at:"],
  33. referencedClasses: ["TempVar"]
  34. }),
  35. smalltalk.LexicalScope);
  36. smalltalk.addMethod(
  37. "_alias",
  38. smalltalk.method({
  39. selector: "alias",
  40. category: 'accessing',
  41. fn: function (){
  42. var self=this;
  43. return smalltalk.withContext(function($ctx1) { var $1;
  44. $1=_st("$ctx").__comma(_st(_st(self)._scopeLevel())._asString());
  45. return $1;
  46. }, self, "alias", [], smalltalk.LexicalScope)},
  47. args: [],
  48. source: "alias\x0a\x09^ '$ctx', self scopeLevel asString",
  49. messageSends: [",", "asString", "scopeLevel"],
  50. referencedClasses: []
  51. }),
  52. smalltalk.LexicalScope);
  53. smalltalk.addMethod(
  54. "_allVariableNames",
  55. smalltalk.method({
  56. selector: "allVariableNames",
  57. category: 'accessing',
  58. fn: function (){
  59. var self=this;
  60. return smalltalk.withContext(function($ctx1) { var $1;
  61. $1=_st(_st(_st(self)._args())._keys()).__comma(_st(_st(self)._temps())._keys());
  62. return $1;
  63. }, self, "allVariableNames", [], smalltalk.LexicalScope)},
  64. args: [],
  65. source: "allVariableNames\x0a\x09^ self args keys, self temps keys",
  66. messageSends: [",", "keys", "temps", "args"],
  67. referencedClasses: []
  68. }),
  69. smalltalk.LexicalScope);
  70. smalltalk.addMethod(
  71. "_args",
  72. smalltalk.method({
  73. selector: "args",
  74. category: 'accessing',
  75. fn: function (){
  76. var self=this;
  77. return smalltalk.withContext(function($ctx1) { var $1;
  78. if(($receiver = self["@args"]) == nil || $receiver == undefined){
  79. self["@args"]=_st((smalltalk.Dictionary || Dictionary))._new();
  80. $1=self["@args"];
  81. } else {
  82. $1=self["@args"];
  83. };
  84. return $1;
  85. }, self, "args", [], smalltalk.LexicalScope)},
  86. args: [],
  87. source: "args\x0a\x09^ args ifNil: [ args := Dictionary new ]",
  88. messageSends: ["ifNil:", "new"],
  89. referencedClasses: ["Dictionary"]
  90. }),
  91. smalltalk.LexicalScope);
  92. smalltalk.addMethod(
  93. "_bindingFor_",
  94. smalltalk.method({
  95. selector: "bindingFor:",
  96. category: 'accessing',
  97. fn: function (aStringOrNode){
  98. var self=this;
  99. return smalltalk.withContext(function($ctx1) { var $1;
  100. $1=_st(_st(self)._pseudoVars())._at_ifAbsent_(_st(aStringOrNode)._value(),(function(){
  101. return smalltalk.withContext(function($ctx2) { return _st(_st(self)._args())._at_ifAbsent_(_st(aStringOrNode)._value(),(function(){
  102. return smalltalk.withContext(function($ctx3) { return _st(_st(self)._temps())._at_ifAbsent_(_st(aStringOrNode)._value(),(function(){
  103. return smalltalk.withContext(function($ctx4) { return nil;
  104. })}));
  105. })}));
  106. })}));
  107. return $1;
  108. }, self, "bindingFor:", [aStringOrNode], smalltalk.LexicalScope)},
  109. args: ["aStringOrNode"],
  110. source: "bindingFor: aStringOrNode\x0a\x09^ self pseudoVars at: aStringOrNode value ifAbsent: [ \x0a\x09\x09self args at: aStringOrNode value ifAbsent: [\x0a\x09\x09\x09self temps at: aStringOrNode value ifAbsent: [ nil ]]]",
  111. messageSends: ["at:ifAbsent:", "value", "temps", "args", "pseudoVars"],
  112. referencedClasses: []
  113. }),
  114. smalltalk.LexicalScope);
  115. smalltalk.addMethod(
  116. "_canInlineNonLocalReturns",
  117. smalltalk.method({
  118. selector: "canInlineNonLocalReturns",
  119. category: 'testing',
  120. fn: function (){
  121. var self=this;
  122. return smalltalk.withContext(function($ctx1) { var $1;
  123. $1=_st(_st(self)._isInlined())._and_((function(){
  124. return smalltalk.withContext(function($ctx2) { return _st(_st(self)._outerScope())._canInlineNonLocalReturns();
  125. })}));
  126. return $1;
  127. }, self, "canInlineNonLocalReturns", [], smalltalk.LexicalScope)},
  128. args: [],
  129. source: "canInlineNonLocalReturns\x0a\x09^ self isInlined and: [ self outerScope canInlineNonLocalReturns ]",
  130. messageSends: ["and:", "canInlineNonLocalReturns", "outerScope", "isInlined"],
  131. referencedClasses: []
  132. }),
  133. smalltalk.LexicalScope);
  134. smalltalk.addMethod(
  135. "_instruction",
  136. smalltalk.method({
  137. selector: "instruction",
  138. category: 'accessing',
  139. fn: function (){
  140. var self=this;
  141. return smalltalk.withContext(function($ctx1) { var $1;
  142. $1=self["@instruction"];
  143. return $1;
  144. }, self, "instruction", [], smalltalk.LexicalScope)},
  145. args: [],
  146. source: "instruction\x0a\x09^ instruction",
  147. messageSends: [],
  148. referencedClasses: []
  149. }),
  150. smalltalk.LexicalScope);
  151. smalltalk.addMethod(
  152. "_instruction_",
  153. smalltalk.method({
  154. selector: "instruction:",
  155. category: 'accessing',
  156. fn: function (anIRInstruction){
  157. var self=this;
  158. return smalltalk.withContext(function($ctx1) { self["@instruction"]=anIRInstruction;
  159. return self}, self, "instruction:", [anIRInstruction], smalltalk.LexicalScope)},
  160. args: ["anIRInstruction"],
  161. source: "instruction: anIRInstruction\x0a\x09instruction := anIRInstruction",
  162. messageSends: [],
  163. referencedClasses: []
  164. }),
  165. smalltalk.LexicalScope);
  166. smalltalk.addMethod(
  167. "_isBlockScope",
  168. smalltalk.method({
  169. selector: "isBlockScope",
  170. category: 'testing',
  171. fn: function (){
  172. var self=this;
  173. return smalltalk.withContext(function($ctx1) { var $1;
  174. $1=_st(_st(self)._isMethodScope())._not();
  175. return $1;
  176. }, self, "isBlockScope", [], smalltalk.LexicalScope)},
  177. args: [],
  178. source: "isBlockScope\x0a\x09^ self isMethodScope not",
  179. messageSends: ["not", "isMethodScope"],
  180. referencedClasses: []
  181. }),
  182. smalltalk.LexicalScope);
  183. smalltalk.addMethod(
  184. "_isInlined",
  185. smalltalk.method({
  186. selector: "isInlined",
  187. category: 'testing',
  188. fn: function (){
  189. var self=this;
  190. return smalltalk.withContext(function($ctx1) { var $1;
  191. $1=_st(_st(_st(self)._instruction())._notNil())._and_((function(){
  192. return smalltalk.withContext(function($ctx2) { return _st(_st(self)._instruction())._isInlined();
  193. })}));
  194. return $1;
  195. }, self, "isInlined", [], smalltalk.LexicalScope)},
  196. args: [],
  197. source: "isInlined\x0a\x09^ self instruction notNil and: [\x0a \x09self instruction isInlined ]",
  198. messageSends: ["and:", "isInlined", "instruction", "notNil"],
  199. referencedClasses: []
  200. }),
  201. smalltalk.LexicalScope);
  202. smalltalk.addMethod(
  203. "_isMethodScope",
  204. smalltalk.method({
  205. selector: "isMethodScope",
  206. category: 'testing',
  207. fn: function (){
  208. var self=this;
  209. return smalltalk.withContext(function($ctx1) { return false;
  210. }, self, "isMethodScope", [], smalltalk.LexicalScope)},
  211. args: [],
  212. source: "isMethodScope\x0a\x09^ false",
  213. messageSends: [],
  214. referencedClasses: []
  215. }),
  216. smalltalk.LexicalScope);
  217. smalltalk.addMethod(
  218. "_lookupVariable_",
  219. smalltalk.method({
  220. selector: "lookupVariable:",
  221. category: 'accessing',
  222. fn: function (aNode){
  223. var self=this;
  224. return smalltalk.withContext(function($ctx1) { var $1,$2;
  225. $ctx1.locals.lookup=nil;
  226. $ctx1.locals.lookup=_st(self)._bindingFor_(aNode);
  227. if(($receiver = $ctx1.locals.lookup) == nil || $receiver == undefined){
  228. $1=_st(self)._outerScope();
  229. if(($receiver = $1) == nil || $receiver == undefined){
  230. $ctx1.locals.lookup=$1;
  231. } else {
  232. $ctx1.locals.lookup=_st(_st(self)._outerScope())._lookupVariable_(aNode);
  233. };
  234. $ctx1.locals.lookup;
  235. } else {
  236. $ctx1.locals.lookup;
  237. };
  238. $2=$ctx1.locals.lookup;
  239. return $2;
  240. }, self, "lookupVariable:", [aNode], smalltalk.LexicalScope)},
  241. args: ["aNode"],
  242. source: "lookupVariable: aNode\x0a\x09| lookup |\x0a\x09lookup := (self bindingFor: aNode).\x0a\x09lookup ifNil: [\x0a\x09\x09lookup := self outerScope ifNotNil: [ \x0a\x09\x09\x09(self outerScope lookupVariable: aNode) ]].\x0a\x09^ lookup",
  243. messageSends: ["bindingFor:", "ifNil:", "ifNotNil:", "lookupVariable:", "outerScope"],
  244. referencedClasses: []
  245. }),
  246. smalltalk.LexicalScope);
  247. smalltalk.addMethod(
  248. "_methodScope",
  249. smalltalk.method({
  250. selector: "methodScope",
  251. category: 'accessing',
  252. fn: function (){
  253. var self=this;
  254. return smalltalk.withContext(function($ctx1) { var $2,$1;
  255. $2=_st(self)._outerScope();
  256. if(($receiver = $2) == nil || $receiver == undefined){
  257. $1=$2;
  258. } else {
  259. $1=_st(_st(self)._outerScope())._methodScope();
  260. };
  261. return $1;
  262. }, self, "methodScope", [], smalltalk.LexicalScope)},
  263. args: [],
  264. source: "methodScope\x0a\x09^ self outerScope ifNotNil: [\x0a\x09\x09self outerScope methodScope ]",
  265. messageSends: ["ifNotNil:", "methodScope", "outerScope"],
  266. referencedClasses: []
  267. }),
  268. smalltalk.LexicalScope);
  269. smalltalk.addMethod(
  270. "_node",
  271. smalltalk.method({
  272. selector: "node",
  273. category: 'accessing',
  274. fn: function (){
  275. var self=this;
  276. return smalltalk.withContext(function($ctx1) { var $1;
  277. $1=self["@node"];
  278. return $1;
  279. }, self, "node", [], smalltalk.LexicalScope)},
  280. args: [],
  281. source: "node\x0a\x09\x22Answer the node in which I am defined\x22\x0a\x09\x0a\x09^ node",
  282. messageSends: [],
  283. referencedClasses: []
  284. }),
  285. smalltalk.LexicalScope);
  286. smalltalk.addMethod(
  287. "_node_",
  288. smalltalk.method({
  289. selector: "node:",
  290. category: 'accessing',
  291. fn: function (aNode){
  292. var self=this;
  293. return smalltalk.withContext(function($ctx1) { self["@node"]=aNode;
  294. return self}, self, "node:", [aNode], smalltalk.LexicalScope)},
  295. args: ["aNode"],
  296. source: "node: aNode\x0a\x09node := aNode",
  297. messageSends: [],
  298. referencedClasses: []
  299. }),
  300. smalltalk.LexicalScope);
  301. smalltalk.addMethod(
  302. "_outerScope",
  303. smalltalk.method({
  304. selector: "outerScope",
  305. category: 'accessing',
  306. fn: function (){
  307. var self=this;
  308. return smalltalk.withContext(function($ctx1) { var $1;
  309. $1=self["@outerScope"];
  310. return $1;
  311. }, self, "outerScope", [], smalltalk.LexicalScope)},
  312. args: [],
  313. source: "outerScope\x0a\x09^ outerScope",
  314. messageSends: [],
  315. referencedClasses: []
  316. }),
  317. smalltalk.LexicalScope);
  318. smalltalk.addMethod(
  319. "_outerScope_",
  320. smalltalk.method({
  321. selector: "outerScope:",
  322. category: 'accessing',
  323. fn: function (aLexicalScope){
  324. var self=this;
  325. return smalltalk.withContext(function($ctx1) { self["@outerScope"]=aLexicalScope;
  326. return self}, self, "outerScope:", [aLexicalScope], smalltalk.LexicalScope)},
  327. args: ["aLexicalScope"],
  328. source: "outerScope: aLexicalScope\x0a\x09outerScope := aLexicalScope",
  329. messageSends: [],
  330. referencedClasses: []
  331. }),
  332. smalltalk.LexicalScope);
  333. smalltalk.addMethod(
  334. "_pseudoVars",
  335. smalltalk.method({
  336. selector: "pseudoVars",
  337. category: 'accessing',
  338. fn: function (){
  339. var self=this;
  340. return smalltalk.withContext(function($ctx1) { var $1;
  341. $1=_st(_st(self)._methodScope())._pseudoVars();
  342. return $1;
  343. }, self, "pseudoVars", [], smalltalk.LexicalScope)},
  344. args: [],
  345. source: "pseudoVars\x0a\x09^ self methodScope pseudoVars",
  346. messageSends: ["pseudoVars", "methodScope"],
  347. referencedClasses: []
  348. }),
  349. smalltalk.LexicalScope);
  350. smalltalk.addMethod(
  351. "_scopeLevel",
  352. smalltalk.method({
  353. selector: "scopeLevel",
  354. category: 'accessing',
  355. fn: function (){
  356. var self=this;
  357. return smalltalk.withContext(function($ctx1) { var $1,$2,$3,$4;
  358. $1=_st(self)._outerScope();
  359. if(($receiver = $1) == nil || $receiver == undefined){
  360. return (1);
  361. } else {
  362. $1;
  363. };
  364. $2=_st(self)._isInlined();
  365. if(smalltalk.assert($2)){
  366. $3=_st(_st(self)._outerScope())._scopeLevel();
  367. return $3;
  368. };
  369. $4=_st(_st(_st(self)._outerScope())._scopeLevel()).__plus((1));
  370. return $4;
  371. }, self, "scopeLevel", [], smalltalk.LexicalScope)},
  372. args: [],
  373. source: "scopeLevel\x0a\x09self outerScope ifNil: [ ^ 1 ].\x0a\x09self isInlined ifTrue: [ ^ self outerScope scopeLevel ].\x0a \x0a\x09^ self outerScope scopeLevel + 1",
  374. messageSends: ["ifNil:", "outerScope", "ifTrue:", "scopeLevel", "isInlined", "+"],
  375. referencedClasses: []
  376. }),
  377. smalltalk.LexicalScope);
  378. smalltalk.addMethod(
  379. "_temps",
  380. smalltalk.method({
  381. selector: "temps",
  382. category: 'accessing',
  383. fn: function (){
  384. var self=this;
  385. return smalltalk.withContext(function($ctx1) { var $1;
  386. if(($receiver = self["@temps"]) == nil || $receiver == undefined){
  387. self["@temps"]=_st((smalltalk.Dictionary || Dictionary))._new();
  388. $1=self["@temps"];
  389. } else {
  390. $1=self["@temps"];
  391. };
  392. return $1;
  393. }, self, "temps", [], smalltalk.LexicalScope)},
  394. args: [],
  395. source: "temps\x0a\x09^ temps ifNil: [ temps := Dictionary new ]",
  396. messageSends: ["ifNil:", "new"],
  397. referencedClasses: ["Dictionary"]
  398. }),
  399. smalltalk.LexicalScope);
  400. smalltalk.addClass('MethodLexicalScope', smalltalk.LexicalScope, ['iVars', 'pseudoVars', 'unknownVariables', 'localReturn', 'nonLocalReturns'], 'Compiler-Semantic');
  401. smalltalk.MethodLexicalScope.comment="I represent a method scope."
  402. smalltalk.addMethod(
  403. "_addIVar_",
  404. smalltalk.method({
  405. selector: "addIVar:",
  406. category: 'adding',
  407. fn: function (aString){
  408. var self=this;
  409. return smalltalk.withContext(function($ctx1) { _st(_st(self)._iVars())._at_put_(aString,_st((smalltalk.InstanceVar || InstanceVar))._on_(aString));
  410. _st(_st(_st(self)._iVars())._at_(aString))._scope_(self);
  411. return self}, self, "addIVar:", [aString], smalltalk.MethodLexicalScope)},
  412. args: ["aString"],
  413. source: "addIVar: aString\x0a\x09self iVars at: aString put: (InstanceVar on: aString).\x0a\x09(self iVars at: aString) scope: self",
  414. messageSends: ["at:put:", "on:", "iVars", "scope:", "at:"],
  415. referencedClasses: ["InstanceVar"]
  416. }),
  417. smalltalk.MethodLexicalScope);
  418. smalltalk.addMethod(
  419. "_addNonLocalReturn_",
  420. smalltalk.method({
  421. selector: "addNonLocalReturn:",
  422. category: 'adding',
  423. fn: function (aScope){
  424. var self=this;
  425. return smalltalk.withContext(function($ctx1) { _st(_st(self)._nonLocalReturns())._add_(aScope);
  426. return self}, self, "addNonLocalReturn:", [aScope], smalltalk.MethodLexicalScope)},
  427. args: ["aScope"],
  428. source: "addNonLocalReturn: aScope\x0a\x09self nonLocalReturns add: aScope",
  429. messageSends: ["add:", "nonLocalReturns"],
  430. referencedClasses: []
  431. }),
  432. smalltalk.MethodLexicalScope);
  433. smalltalk.addMethod(
  434. "_allVariableNames",
  435. smalltalk.method({
  436. selector: "allVariableNames",
  437. category: 'accessing',
  438. fn: function (){
  439. var self=this;
  440. return smalltalk.withContext(function($ctx1) { var $1;
  441. $1=_st(smalltalk.LexicalScope.fn.prototype._allVariableNames.apply(_st(self), [])).__comma(_st(_st(self)._iVars())._keys());
  442. return $1;
  443. }, self, "allVariableNames", [], smalltalk.MethodLexicalScope)},
  444. args: [],
  445. source: "allVariableNames\x0a\x09^ super allVariableNames, self iVars keys",
  446. messageSends: [",", "keys", "iVars", "allVariableNames"],
  447. referencedClasses: []
  448. }),
  449. smalltalk.MethodLexicalScope);
  450. smalltalk.addMethod(
  451. "_bindingFor_",
  452. smalltalk.method({
  453. selector: "bindingFor:",
  454. category: 'accessing',
  455. fn: function (aNode){
  456. var self=this;
  457. return smalltalk.withContext(function($ctx1) { var $2,$1;
  458. $2=smalltalk.LexicalScope.fn.prototype._bindingFor_.apply(_st(self), [aNode]);
  459. if(($receiver = $2) == nil || $receiver == undefined){
  460. $1=_st(_st(self)._iVars())._at_ifAbsent_(_st(aNode)._value(),(function(){
  461. return smalltalk.withContext(function($ctx2) { return nil;
  462. })}));
  463. } else {
  464. $1=$2;
  465. };
  466. return $1;
  467. }, self, "bindingFor:", [aNode], smalltalk.MethodLexicalScope)},
  468. args: ["aNode"],
  469. source: "bindingFor: aNode\x0a\x09^ (super bindingFor: aNode) ifNil: [\x0a\x09\x09self iVars at: aNode value ifAbsent: [ nil ]]",
  470. messageSends: ["ifNil:", "at:ifAbsent:", "value", "iVars", "bindingFor:"],
  471. referencedClasses: []
  472. }),
  473. smalltalk.MethodLexicalScope);
  474. smalltalk.addMethod(
  475. "_canInlineNonLocalReturns",
  476. smalltalk.method({
  477. selector: "canInlineNonLocalReturns",
  478. category: 'testing',
  479. fn: function (){
  480. var self=this;
  481. return smalltalk.withContext(function($ctx1) { return true;
  482. }, self, "canInlineNonLocalReturns", [], smalltalk.MethodLexicalScope)},
  483. args: [],
  484. source: "canInlineNonLocalReturns\x0a\x09^ true",
  485. messageSends: [],
  486. referencedClasses: []
  487. }),
  488. smalltalk.MethodLexicalScope);
  489. smalltalk.addMethod(
  490. "_hasLocalReturn",
  491. smalltalk.method({
  492. selector: "hasLocalReturn",
  493. category: 'testing',
  494. fn: function (){
  495. var self=this;
  496. return smalltalk.withContext(function($ctx1) { var $1;
  497. $1=_st(self)._localReturn();
  498. return $1;
  499. }, self, "hasLocalReturn", [], smalltalk.MethodLexicalScope)},
  500. args: [],
  501. source: "hasLocalReturn\x0a\x09^ self localReturn",
  502. messageSends: ["localReturn"],
  503. referencedClasses: []
  504. }),
  505. smalltalk.MethodLexicalScope);
  506. smalltalk.addMethod(
  507. "_hasNonLocalReturn",
  508. smalltalk.method({
  509. selector: "hasNonLocalReturn",
  510. category: 'testing',
  511. fn: function (){
  512. var self=this;
  513. return smalltalk.withContext(function($ctx1) { var $1;
  514. $1=_st(_st(self)._nonLocalReturns())._notEmpty();
  515. return $1;
  516. }, self, "hasNonLocalReturn", [], smalltalk.MethodLexicalScope)},
  517. args: [],
  518. source: "hasNonLocalReturn\x0a\x09^ self nonLocalReturns notEmpty",
  519. messageSends: ["notEmpty", "nonLocalReturns"],
  520. referencedClasses: []
  521. }),
  522. smalltalk.MethodLexicalScope);
  523. smalltalk.addMethod(
  524. "_iVars",
  525. smalltalk.method({
  526. selector: "iVars",
  527. category: 'accessing',
  528. fn: function (){
  529. var self=this;
  530. return smalltalk.withContext(function($ctx1) { var $1;
  531. if(($receiver = self["@iVars"]) == nil || $receiver == undefined){
  532. self["@iVars"]=_st((smalltalk.Dictionary || Dictionary))._new();
  533. $1=self["@iVars"];
  534. } else {
  535. $1=self["@iVars"];
  536. };
  537. return $1;
  538. }, self, "iVars", [], smalltalk.MethodLexicalScope)},
  539. args: [],
  540. source: "iVars\x0a\x09^ iVars ifNil: [ iVars := Dictionary new ]",
  541. messageSends: ["ifNil:", "new"],
  542. referencedClasses: ["Dictionary"]
  543. }),
  544. smalltalk.MethodLexicalScope);
  545. smalltalk.addMethod(
  546. "_isMethodScope",
  547. smalltalk.method({
  548. selector: "isMethodScope",
  549. category: 'testing',
  550. fn: function (){
  551. var self=this;
  552. return smalltalk.withContext(function($ctx1) { return true;
  553. }, self, "isMethodScope", [], smalltalk.MethodLexicalScope)},
  554. args: [],
  555. source: "isMethodScope\x0a\x09^ true",
  556. messageSends: [],
  557. referencedClasses: []
  558. }),
  559. smalltalk.MethodLexicalScope);
  560. smalltalk.addMethod(
  561. "_localReturn",
  562. smalltalk.method({
  563. selector: "localReturn",
  564. category: 'accessing',
  565. fn: function (){
  566. var self=this;
  567. return smalltalk.withContext(function($ctx1) { var $1;
  568. if(($receiver = self["@localReturn"]) == nil || $receiver == undefined){
  569. $1=false;
  570. } else {
  571. $1=self["@localReturn"];
  572. };
  573. return $1;
  574. }, self, "localReturn", [], smalltalk.MethodLexicalScope)},
  575. args: [],
  576. source: "localReturn\x0a\x09^ localReturn ifNil: [ false ]",
  577. messageSends: ["ifNil:"],
  578. referencedClasses: []
  579. }),
  580. smalltalk.MethodLexicalScope);
  581. smalltalk.addMethod(
  582. "_localReturn_",
  583. smalltalk.method({
  584. selector: "localReturn:",
  585. category: 'accessing',
  586. fn: function (aBoolean){
  587. var self=this;
  588. return smalltalk.withContext(function($ctx1) { self["@localReturn"]=aBoolean;
  589. return self}, self, "localReturn:", [aBoolean], smalltalk.MethodLexicalScope)},
  590. args: ["aBoolean"],
  591. source: "localReturn: aBoolean\x0a\x09localReturn := aBoolean",
  592. messageSends: [],
  593. referencedClasses: []
  594. }),
  595. smalltalk.MethodLexicalScope);
  596. smalltalk.addMethod(
  597. "_methodScope",
  598. smalltalk.method({
  599. selector: "methodScope",
  600. category: 'accessing',
  601. fn: function (){
  602. var self=this;
  603. return smalltalk.withContext(function($ctx1) { var $1;
  604. $1=self;
  605. return $1;
  606. }, self, "methodScope", [], smalltalk.MethodLexicalScope)},
  607. args: [],
  608. source: "methodScope\x0a\x09^ self",
  609. messageSends: [],
  610. referencedClasses: []
  611. }),
  612. smalltalk.MethodLexicalScope);
  613. smalltalk.addMethod(
  614. "_nonLocalReturns",
  615. smalltalk.method({
  616. selector: "nonLocalReturns",
  617. category: 'accessing',
  618. fn: function (){
  619. var self=this;
  620. return smalltalk.withContext(function($ctx1) { var $1;
  621. if(($receiver = self["@nonLocalReturns"]) == nil || $receiver == undefined){
  622. self["@nonLocalReturns"]=_st((smalltalk.OrderedCollection || OrderedCollection))._new();
  623. $1=self["@nonLocalReturns"];
  624. } else {
  625. $1=self["@nonLocalReturns"];
  626. };
  627. return $1;
  628. }, self, "nonLocalReturns", [], smalltalk.MethodLexicalScope)},
  629. args: [],
  630. source: "nonLocalReturns\x0a\x09^ nonLocalReturns ifNil: [ nonLocalReturns := OrderedCollection new ]",
  631. messageSends: ["ifNil:", "new"],
  632. referencedClasses: ["OrderedCollection"]
  633. }),
  634. smalltalk.MethodLexicalScope);
  635. smalltalk.addMethod(
  636. "_pseudoVars",
  637. smalltalk.method({
  638. selector: "pseudoVars",
  639. category: 'accessing',
  640. fn: function (){
  641. var self=this;
  642. return smalltalk.withContext(function($ctx1) { var $1,$2,$3;
  643. if(($receiver = self["@pseudoVars"]) == nil || $receiver == undefined){
  644. self["@pseudoVars"]=_st((smalltalk.Dictionary || Dictionary))._new();
  645. self["@pseudoVars"];
  646. _st(_st(_st((smalltalk.Smalltalk || Smalltalk))._current())._pseudoVariableNames())._do_((function(each){
  647. return smalltalk.withContext(function($ctx2) { $1=_st((smalltalk.PseudoVar || PseudoVar))._on_(each);
  648. _st($1)._scope_(_st(self)._methodScope());
  649. $2=_st($1)._yourself();
  650. return _st(self["@pseudoVars"])._at_put_(each,$2);
  651. })}));
  652. } else {
  653. self["@pseudoVars"];
  654. };
  655. $3=self["@pseudoVars"];
  656. return $3;
  657. }, self, "pseudoVars", [], smalltalk.MethodLexicalScope)},
  658. args: [],
  659. source: "pseudoVars\x0a\x09pseudoVars ifNil: [\x0a\x09\x09pseudoVars := Dictionary new.\x0a\x09\x09Smalltalk current pseudoVariableNames do: [ :each |\x0a\x09\x09\x09pseudoVars at: each put: ((PseudoVar on: each)\x0a\x09\x09\x09\x09scope: self methodScope;\x0a\x09\x09\x09\x09yourself) ]].\x0a\x09^ pseudoVars",
  660. messageSends: ["ifNil:", "new", "do:", "at:put:", "scope:", "methodScope", "on:", "yourself", "pseudoVariableNames", "current"],
  661. referencedClasses: ["Dictionary", "PseudoVar", "Smalltalk"]
  662. }),
  663. smalltalk.MethodLexicalScope);
  664. smalltalk.addMethod(
  665. "_removeNonLocalReturn_",
  666. smalltalk.method({
  667. selector: "removeNonLocalReturn:",
  668. category: 'adding',
  669. fn: function (aScope){
  670. var self=this;
  671. return smalltalk.withContext(function($ctx1) { _st(_st(self)._nonLocalReturns())._remove_ifAbsent_(aScope,(function(){
  672. return smalltalk.withContext(function($ctx2) { })}));
  673. return self}, self, "removeNonLocalReturn:", [aScope], smalltalk.MethodLexicalScope)},
  674. args: ["aScope"],
  675. source: "removeNonLocalReturn: aScope\x0a\x09self nonLocalReturns remove: aScope ifAbsent: []",
  676. messageSends: ["remove:ifAbsent:", "nonLocalReturns"],
  677. referencedClasses: []
  678. }),
  679. smalltalk.MethodLexicalScope);
  680. smalltalk.addMethod(
  681. "_unknownVariables",
  682. smalltalk.method({
  683. selector: "unknownVariables",
  684. category: 'accessing',
  685. fn: function (){
  686. var self=this;
  687. return smalltalk.withContext(function($ctx1) { var $1;
  688. if(($receiver = self["@unknownVariables"]) == nil || $receiver == undefined){
  689. self["@unknownVariables"]=_st((smalltalk.OrderedCollection || OrderedCollection))._new();
  690. $1=self["@unknownVariables"];
  691. } else {
  692. $1=self["@unknownVariables"];
  693. };
  694. return $1;
  695. }, self, "unknownVariables", [], smalltalk.MethodLexicalScope)},
  696. args: [],
  697. source: "unknownVariables\x0a\x09^ unknownVariables ifNil: [ unknownVariables := OrderedCollection new ]",
  698. messageSends: ["ifNil:", "new"],
  699. referencedClasses: ["OrderedCollection"]
  700. }),
  701. smalltalk.MethodLexicalScope);
  702. smalltalk.addClass('ScopeVar', smalltalk.Object, ['scope', 'name'], 'Compiler-Semantic');
  703. smalltalk.ScopeVar.comment="I am an entry in a LexicalScope that gets associated with variable nodes of the same name. \x0aThere are 4 different subclasses of vars: temp vars, local vars, args, and unknown/global vars."
  704. smalltalk.addMethod(
  705. "_alias",
  706. smalltalk.method({
  707. selector: "alias",
  708. category: 'accessing',
  709. fn: function (){
  710. var self=this;
  711. return smalltalk.withContext(function($ctx1) { var $1;
  712. $1=_st(_st(self)._name())._asVariableName();
  713. return $1;
  714. }, self, "alias", [], smalltalk.ScopeVar)},
  715. args: [],
  716. source: "alias\x0a\x09^ self name asVariableName",
  717. messageSends: ["asVariableName", "name"],
  718. referencedClasses: []
  719. }),
  720. smalltalk.ScopeVar);
  721. smalltalk.addMethod(
  722. "_isArgVar",
  723. smalltalk.method({
  724. selector: "isArgVar",
  725. category: 'testing',
  726. fn: function (){
  727. var self=this;
  728. return smalltalk.withContext(function($ctx1) { return false;
  729. }, self, "isArgVar", [], smalltalk.ScopeVar)},
  730. args: [],
  731. source: "isArgVar\x0a\x09^ false",
  732. messageSends: [],
  733. referencedClasses: []
  734. }),
  735. smalltalk.ScopeVar);
  736. smalltalk.addMethod(
  737. "_isClassRefVar",
  738. smalltalk.method({
  739. selector: "isClassRefVar",
  740. category: 'testing',
  741. fn: function (){
  742. var self=this;
  743. return smalltalk.withContext(function($ctx1) { return false;
  744. }, self, "isClassRefVar", [], smalltalk.ScopeVar)},
  745. args: [],
  746. source: "isClassRefVar\x0a\x09^ false",
  747. messageSends: [],
  748. referencedClasses: []
  749. }),
  750. smalltalk.ScopeVar);
  751. smalltalk.addMethod(
  752. "_isInstanceVar",
  753. smalltalk.method({
  754. selector: "isInstanceVar",
  755. category: 'testing',
  756. fn: function (){
  757. var self=this;
  758. return smalltalk.withContext(function($ctx1) { return false;
  759. }, self, "isInstanceVar", [], smalltalk.ScopeVar)},
  760. args: [],
  761. source: "isInstanceVar\x0a\x09^ false",
  762. messageSends: [],
  763. referencedClasses: []
  764. }),
  765. smalltalk.ScopeVar);
  766. smalltalk.addMethod(
  767. "_isPseudoVar",
  768. smalltalk.method({
  769. selector: "isPseudoVar",
  770. category: 'testing',
  771. fn: function (){
  772. var self=this;
  773. return smalltalk.withContext(function($ctx1) { return false;
  774. }, self, "isPseudoVar", [], smalltalk.ScopeVar)},
  775. args: [],
  776. source: "isPseudoVar\x0a\x09^ false",
  777. messageSends: [],
  778. referencedClasses: []
  779. }),
  780. smalltalk.ScopeVar);
  781. smalltalk.addMethod(
  782. "_isTempVar",
  783. smalltalk.method({
  784. selector: "isTempVar",
  785. category: 'testing',
  786. fn: function (){
  787. var self=this;
  788. return smalltalk.withContext(function($ctx1) { return false;
  789. }, self, "isTempVar", [], smalltalk.ScopeVar)},
  790. args: [],
  791. source: "isTempVar\x0a\x09^ false",
  792. messageSends: [],
  793. referencedClasses: []
  794. }),
  795. smalltalk.ScopeVar);
  796. smalltalk.addMethod(
  797. "_isUnknownVar",
  798. smalltalk.method({
  799. selector: "isUnknownVar",
  800. category: 'testing',
  801. fn: function (){
  802. var self=this;
  803. return smalltalk.withContext(function($ctx1) { return false;
  804. }, self, "isUnknownVar", [], smalltalk.ScopeVar)},
  805. args: [],
  806. source: "isUnknownVar\x0a\x09^ false",
  807. messageSends: [],
  808. referencedClasses: []
  809. }),
  810. smalltalk.ScopeVar);
  811. smalltalk.addMethod(
  812. "_name",
  813. smalltalk.method({
  814. selector: "name",
  815. category: 'accessing',
  816. fn: function (){
  817. var self=this;
  818. return smalltalk.withContext(function($ctx1) { var $1;
  819. $1=self["@name"];
  820. return $1;
  821. }, self, "name", [], smalltalk.ScopeVar)},
  822. args: [],
  823. source: "name\x0a\x09^ name",
  824. messageSends: [],
  825. referencedClasses: []
  826. }),
  827. smalltalk.ScopeVar);
  828. smalltalk.addMethod(
  829. "_name_",
  830. smalltalk.method({
  831. selector: "name:",
  832. category: 'accessing',
  833. fn: function (aString){
  834. var self=this;
  835. return smalltalk.withContext(function($ctx1) { self["@name"]=aString;
  836. return self}, self, "name:", [aString], smalltalk.ScopeVar)},
  837. args: ["aString"],
  838. source: "name: aString\x0a\x09name := aString",
  839. messageSends: [],
  840. referencedClasses: []
  841. }),
  842. smalltalk.ScopeVar);
  843. smalltalk.addMethod(
  844. "_scope",
  845. smalltalk.method({
  846. selector: "scope",
  847. category: 'accessing',
  848. fn: function (){
  849. var self=this;
  850. return smalltalk.withContext(function($ctx1) { var $1;
  851. $1=self["@scope"];
  852. return $1;
  853. }, self, "scope", [], smalltalk.ScopeVar)},
  854. args: [],
  855. source: "scope\x0a\x09^ scope",
  856. messageSends: [],
  857. referencedClasses: []
  858. }),
  859. smalltalk.ScopeVar);
  860. smalltalk.addMethod(
  861. "_scope_",
  862. smalltalk.method({
  863. selector: "scope:",
  864. category: 'accessing',
  865. fn: function (aScope){
  866. var self=this;
  867. return smalltalk.withContext(function($ctx1) { self["@scope"]=aScope;
  868. return self}, self, "scope:", [aScope], smalltalk.ScopeVar)},
  869. args: ["aScope"],
  870. source: "scope: aScope\x0a\x09scope := aScope",
  871. messageSends: [],
  872. referencedClasses: []
  873. }),
  874. smalltalk.ScopeVar);
  875. smalltalk.addMethod(
  876. "_validateAssignment",
  877. smalltalk.method({
  878. selector: "validateAssignment",
  879. category: 'testing',
  880. fn: function (){
  881. var self=this;
  882. return smalltalk.withContext(function($ctx1) { var $1,$2,$3;
  883. $1=_st(_st(self)._isArgVar())._or_((function(){
  884. return smalltalk.withContext(function($ctx2) { return _st(self)._isPseudoVar();
  885. })}));
  886. if(smalltalk.assert($1)){
  887. $2=_st((smalltalk.InvalidAssignmentError || InvalidAssignmentError))._new();
  888. _st($2)._variableName_(_st(self)._name());
  889. $3=_st($2)._signal();
  890. $3;
  891. };
  892. return self}, self, "validateAssignment", [], smalltalk.ScopeVar)},
  893. args: [],
  894. source: "validateAssignment\x0a\x09(self isArgVar or: [ self isPseudoVar ]) ifTrue: [\x0a\x09\x09InvalidAssignmentError new\x0a\x09\x09\x09variableName: self name;\x0a\x09\x09\x09signal]",
  895. messageSends: ["ifTrue:", "variableName:", "name", "new", "signal", "or:", "isPseudoVar", "isArgVar"],
  896. referencedClasses: ["InvalidAssignmentError"]
  897. }),
  898. smalltalk.ScopeVar);
  899. smalltalk.addMethod(
  900. "_on_",
  901. smalltalk.method({
  902. selector: "on:",
  903. category: 'instance creation',
  904. fn: function (aString){
  905. var self=this;
  906. return smalltalk.withContext(function($ctx1) { var $2,$3,$1;
  907. $2=_st(self)._new();
  908. _st($2)._name_(aString);
  909. $3=_st($2)._yourself();
  910. $1=$3;
  911. return $1;
  912. }, self, "on:", [aString], smalltalk.ScopeVar.klass)},
  913. args: ["aString"],
  914. source: "on: aString\x0a\x09^ self new \x0a\x09\x09name: aString;\x0a\x09\x09yourself",
  915. messageSends: ["name:", "new", "yourself"],
  916. referencedClasses: []
  917. }),
  918. smalltalk.ScopeVar.klass);
  919. smalltalk.addClass('AliasVar', smalltalk.ScopeVar, ['node'], 'Compiler-Semantic');
  920. smalltalk.AliasVar.comment="I am an internally defined variable by the compiler"
  921. smalltalk.addMethod(
  922. "_node",
  923. smalltalk.method({
  924. selector: "node",
  925. category: 'accessing',
  926. fn: function (){
  927. var self=this;
  928. return smalltalk.withContext(function($ctx1) { var $1;
  929. $1=self["@node"];
  930. return $1;
  931. }, self, "node", [], smalltalk.AliasVar)},
  932. args: [],
  933. source: "node\x0a\x09^ node",
  934. messageSends: [],
  935. referencedClasses: []
  936. }),
  937. smalltalk.AliasVar);
  938. smalltalk.addMethod(
  939. "_node_",
  940. smalltalk.method({
  941. selector: "node:",
  942. category: 'accessing',
  943. fn: function (aNode){
  944. var self=this;
  945. return smalltalk.withContext(function($ctx1) { self["@node"]=aNode;
  946. return self}, self, "node:", [aNode], smalltalk.AliasVar)},
  947. args: ["aNode"],
  948. source: "node: aNode\x0a\x09node := aNode",
  949. messageSends: [],
  950. referencedClasses: []
  951. }),
  952. smalltalk.AliasVar);
  953. smalltalk.addClass('ArgVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');
  954. smalltalk.ArgVar.comment="I am an argument of a method or block."
  955. smalltalk.addMethod(
  956. "_isArgVar",
  957. smalltalk.method({
  958. selector: "isArgVar",
  959. category: 'testing',
  960. fn: function (){
  961. var self=this;
  962. return smalltalk.withContext(function($ctx1) { return true;
  963. }, self, "isArgVar", [], smalltalk.ArgVar)},
  964. args: [],
  965. source: "isArgVar\x0a\x09^ true",
  966. messageSends: [],
  967. referencedClasses: []
  968. }),
  969. smalltalk.ArgVar);
  970. smalltalk.addClass('ClassRefVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');
  971. smalltalk.ClassRefVar.comment="I am an class reference variable"
  972. smalltalk.addMethod(
  973. "_alias",
  974. smalltalk.method({
  975. selector: "alias",
  976. category: 'accessing',
  977. fn: function (){
  978. var self=this;
  979. return smalltalk.withContext(function($ctx1) { var $1;
  980. $1=_st(_st(_st(_st("(smalltalk.").__comma(_st(self)._name())).__comma(" || ")).__comma(_st(self)._name())).__comma(")");
  981. return $1;
  982. }, self, "alias", [], smalltalk.ClassRefVar)},
  983. args: [],
  984. source: "alias\x0a\x09^ '(smalltalk.', self name, ' || ', self name, ')'",
  985. messageSends: [",", "name"],
  986. referencedClasses: []
  987. }),
  988. smalltalk.ClassRefVar);
  989. smalltalk.addMethod(
  990. "_isClassRefVar",
  991. smalltalk.method({
  992. selector: "isClassRefVar",
  993. category: 'testing',
  994. fn: function (){
  995. var self=this;
  996. return smalltalk.withContext(function($ctx1) { return true;
  997. }, self, "isClassRefVar", [], smalltalk.ClassRefVar)},
  998. args: [],
  999. source: "isClassRefVar\x0a\x09^ true",
  1000. messageSends: [],
  1001. referencedClasses: []
  1002. }),
  1003. smalltalk.ClassRefVar);
  1004. smalltalk.addClass('InstanceVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');
  1005. smalltalk.InstanceVar.comment="I am an instance variable of a method or block."
  1006. smalltalk.addMethod(
  1007. "_alias",
  1008. smalltalk.method({
  1009. selector: "alias",
  1010. category: 'testing',
  1011. fn: function (){
  1012. var self=this;
  1013. return smalltalk.withContext(function($ctx1) { var $1;
  1014. $1=_st(_st("self[\x22@").__comma(_st(self)._name())).__comma("\x22]");
  1015. return $1;
  1016. }, self, "alias", [], smalltalk.InstanceVar)},
  1017. args: [],
  1018. source: "alias\x0a\x09^ 'self[\x22@', self name, '\x22]'",
  1019. messageSends: [",", "name"],
  1020. referencedClasses: []
  1021. }),
  1022. smalltalk.InstanceVar);
  1023. smalltalk.addMethod(
  1024. "_isInstanceVar",
  1025. smalltalk.method({
  1026. selector: "isInstanceVar",
  1027. category: 'testing',
  1028. fn: function (){
  1029. var self=this;
  1030. return smalltalk.withContext(function($ctx1) { return true;
  1031. }, self, "isInstanceVar", [], smalltalk.InstanceVar)},
  1032. args: [],
  1033. source: "isInstanceVar\x0a\x09^ true",
  1034. messageSends: [],
  1035. referencedClasses: []
  1036. }),
  1037. smalltalk.InstanceVar);
  1038. smalltalk.addClass('PseudoVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');
  1039. smalltalk.PseudoVar.comment="I am an pseudo variable.\x0a\x0aThe five Smalltalk pseudo variables are: 'self', 'super', 'nil', 'true' and 'false'"
  1040. smalltalk.addMethod(
  1041. "_alias",
  1042. smalltalk.method({
  1043. selector: "alias",
  1044. category: 'accessing',
  1045. fn: function (){
  1046. var self=this;
  1047. return smalltalk.withContext(function($ctx1) { var $1;
  1048. $1=_st(self)._name();
  1049. return $1;
  1050. }, self, "alias", [], smalltalk.PseudoVar)},
  1051. args: [],
  1052. source: "alias\x0a\x09^ self name",
  1053. messageSends: ["name"],
  1054. referencedClasses: []
  1055. }),
  1056. smalltalk.PseudoVar);
  1057. smalltalk.addMethod(
  1058. "_isPseudoVar",
  1059. smalltalk.method({
  1060. selector: "isPseudoVar",
  1061. category: 'testing',
  1062. fn: function (){
  1063. var self=this;
  1064. return smalltalk.withContext(function($ctx1) { return true;
  1065. }, self, "isPseudoVar", [], smalltalk.PseudoVar)},
  1066. args: [],
  1067. source: "isPseudoVar\x0a\x09^ true",
  1068. messageSends: [],
  1069. referencedClasses: []
  1070. }),
  1071. smalltalk.PseudoVar);
  1072. smalltalk.addClass('TempVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');
  1073. smalltalk.TempVar.comment="I am an temporary variable of a method or block."
  1074. smalltalk.addMethod(
  1075. "_alias",
  1076. smalltalk.method({
  1077. selector: "alias",
  1078. category: 'accessing',
  1079. fn: function (){
  1080. var self=this;
  1081. return smalltalk.withContext(function($ctx1) { var $1;
  1082. $1=_st(_st(_st(_st(self)._scope())._alias()).__comma(".locals.")).__comma(smalltalk.ScopeVar.fn.prototype._alias.apply(_st(self), []));
  1083. return $1;
  1084. }, self, "alias", [], smalltalk.TempVar)},
  1085. args: [],
  1086. source: "alias\x0a\x09^ self scope alias, '.locals.', super alias",
  1087. messageSends: [",", "alias", "scope"],
  1088. referencedClasses: []
  1089. }),
  1090. smalltalk.TempVar);
  1091. smalltalk.addMethod(
  1092. "_isTempVar",
  1093. smalltalk.method({
  1094. selector: "isTempVar",
  1095. category: 'testing',
  1096. fn: function (){
  1097. var self=this;
  1098. return smalltalk.withContext(function($ctx1) { return true;
  1099. }, self, "isTempVar", [], smalltalk.TempVar)},
  1100. args: [],
  1101. source: "isTempVar\x0a\x09^ true",
  1102. messageSends: [],
  1103. referencedClasses: []
  1104. }),
  1105. smalltalk.TempVar);
  1106. smalltalk.addClass('UnknownVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');
  1107. smalltalk.UnknownVar.comment="I am an unknown variable. Amber uses unknown variables as JavaScript globals"
  1108. smalltalk.addMethod(
  1109. "_isUnknownVar",
  1110. smalltalk.method({
  1111. selector: "isUnknownVar",
  1112. category: 'testing',
  1113. fn: function (){
  1114. var self=this;
  1115. return smalltalk.withContext(function($ctx1) { return true;
  1116. }, self, "isUnknownVar", [], smalltalk.UnknownVar)},
  1117. args: [],
  1118. source: "isUnknownVar\x0a\x09^ true",
  1119. messageSends: [],
  1120. referencedClasses: []
  1121. }),
  1122. smalltalk.UnknownVar);
  1123. smalltalk.addClass('SemanticAnalyzer', smalltalk.NodeVisitor, ['currentScope', 'theClass', 'classReferences', 'messageSends', 'superSends'], 'Compiler-Semantic');
  1124. smalltalk.SemanticAnalyzer.comment="I semantically analyze the abstract syntax tree and annotate it with informations such as non local returns and variable scopes."
  1125. smalltalk.addMethod(
  1126. "_classReferences",
  1127. smalltalk.method({
  1128. selector: "classReferences",
  1129. category: 'accessing',
  1130. fn: function (){
  1131. var self=this;
  1132. return smalltalk.withContext(function($ctx1) { var $1;
  1133. if(($receiver = self["@classReferences"]) == nil || $receiver == undefined){
  1134. self["@classReferences"]=_st((smalltalk.Set || Set))._new();
  1135. $1=self["@classReferences"];
  1136. } else {
  1137. $1=self["@classReferences"];
  1138. };
  1139. return $1;
  1140. }, self, "classReferences", [], smalltalk.SemanticAnalyzer)},
  1141. args: [],
  1142. source: "classReferences\x0a\x09^ classReferences ifNil: [ classReferences := Set new ]",
  1143. messageSends: ["ifNil:", "new"],
  1144. referencedClasses: ["Set"]
  1145. }),
  1146. smalltalk.SemanticAnalyzer);
  1147. smalltalk.addMethod(
  1148. "_errorShadowingVariable_",
  1149. smalltalk.method({
  1150. selector: "errorShadowingVariable:",
  1151. category: 'error handling',
  1152. fn: function (aString){
  1153. var self=this;
  1154. return smalltalk.withContext(function($ctx1) { var $1,$2;
  1155. $1=_st((smalltalk.ShadowingVariableError || ShadowingVariableError))._new();
  1156. _st($1)._variableName_(aString);
  1157. $2=_st($1)._signal();
  1158. return self}, self, "errorShadowingVariable:", [aString], smalltalk.SemanticAnalyzer)},
  1159. args: ["aString"],
  1160. source: "errorShadowingVariable: aString\x0a\x09ShadowingVariableError new\x0a\x09\x09variableName: aString;\x0a\x09\x09signal",
  1161. messageSends: ["variableName:", "new", "signal"],
  1162. referencedClasses: ["ShadowingVariableError"]
  1163. }),
  1164. smalltalk.SemanticAnalyzer);
  1165. smalltalk.addMethod(
  1166. "_errorUnknownVariable_",
  1167. smalltalk.method({
  1168. selector: "errorUnknownVariable:",
  1169. category: 'error handling',
  1170. fn: function (aNode){
  1171. var self=this;
  1172. return smalltalk.withContext(function($ctx1) { var $1,$2,$3;
  1173. $1=_st(self)._isVariableGloballyUndefined_(_st(aNode)._value());
  1174. if(smalltalk.assert($1)){
  1175. $2=_st((smalltalk.UnknownVariableError || UnknownVariableError))._new();
  1176. _st($2)._variableName_(_st(aNode)._value());
  1177. $3=_st($2)._signal();
  1178. $3;
  1179. } else {
  1180. _st(_st(_st(self["@currentScope"])._methodScope())._unknownVariables())._add_(_st(aNode)._value());
  1181. };
  1182. return self}, self, "errorUnknownVariable:", [aNode], smalltalk.SemanticAnalyzer)},
  1183. args: ["aNode"],
  1184. source: "errorUnknownVariable: aNode\x0a\x09\x22Throw an error if the variable is undeclared in the global JS scope (i.e. window)\x22\x0a\x0a\x09(self isVariableGloballyUndefined: aNode value)\x0a\x09\x09ifTrue: [ \x0a\x09\x09\x09UnknownVariableError new\x0a\x09\x09\x09\x09variableName: aNode value;\x0a\x09\x09\x09\x09signal ]\x0a\x09\x09ifFalse: [\x0a\x09\x09\x09currentScope methodScope unknownVariables add: aNode value. ]",
  1185. messageSends: ["ifTrue:ifFalse:", "variableName:", "value", "new", "signal", "add:", "unknownVariables", "methodScope", "isVariableGloballyUndefined:"],
  1186. referencedClasses: ["UnknownVariableError"]
  1187. }),
  1188. smalltalk.SemanticAnalyzer);
  1189. smalltalk.addMethod(
  1190. "_isVariableGloballyUndefined_",
  1191. smalltalk.method({
  1192. selector: "isVariableGloballyUndefined:",
  1193. category: 'testing',
  1194. fn: function (aString){
  1195. var self=this;
  1196. return smalltalk.withContext(function($ctx1) { return eval('typeof ' + aString + ' == "undefined"');
  1197. ;
  1198. return self}, self, "isVariableGloballyUndefined:", [aString], smalltalk.SemanticAnalyzer)},
  1199. args: ["aString"],
  1200. source: "isVariableGloballyUndefined: aString\x0a\x09<return eval('typeof ' + aString + ' == \x22undefined\x22')>",
  1201. messageSends: [],
  1202. referencedClasses: []
  1203. }),
  1204. smalltalk.SemanticAnalyzer);
  1205. smalltalk.addMethod(
  1206. "_messageSends",
  1207. smalltalk.method({
  1208. selector: "messageSends",
  1209. category: 'accessing',
  1210. fn: function (){
  1211. var self=this;
  1212. return smalltalk.withContext(function($ctx1) { var $1;
  1213. if(($receiver = self["@messageSends"]) == nil || $receiver == undefined){
  1214. self["@messageSends"]=_st((smalltalk.Dictionary || Dictionary))._new();
  1215. $1=self["@messageSends"];
  1216. } else {
  1217. $1=self["@messageSends"];
  1218. };
  1219. return $1;
  1220. }, self, "messageSends", [], smalltalk.SemanticAnalyzer)},
  1221. args: [],
  1222. source: "messageSends\x0a\x09^ messageSends ifNil: [ messageSends := Dictionary new ]",
  1223. messageSends: ["ifNil:", "new"],
  1224. referencedClasses: ["Dictionary"]
  1225. }),
  1226. smalltalk.SemanticAnalyzer);
  1227. smalltalk.addMethod(
  1228. "_newBlockScope",
  1229. smalltalk.method({
  1230. selector: "newBlockScope",
  1231. category: 'factory',
  1232. fn: function (){
  1233. var self=this;
  1234. return smalltalk.withContext(function($ctx1) { var $1;
  1235. $1=_st(self)._newScopeOfClass_((smalltalk.LexicalScope || LexicalScope));
  1236. return $1;
  1237. }, self, "newBlockScope", [], smalltalk.SemanticAnalyzer)},
  1238. args: [],
  1239. source: "newBlockScope\x0a\x09^ self newScopeOfClass: LexicalScope",
  1240. messageSends: ["newScopeOfClass:"],
  1241. referencedClasses: ["LexicalScope"]
  1242. }),
  1243. smalltalk.SemanticAnalyzer);
  1244. smalltalk.addMethod(
  1245. "_newMethodScope",
  1246. smalltalk.method({
  1247. selector: "newMethodScope",
  1248. category: 'factory',
  1249. fn: function (){
  1250. var self=this;
  1251. return smalltalk.withContext(function($ctx1) { var $1;
  1252. $1=_st(self)._newScopeOfClass_((smalltalk.MethodLexicalScope || MethodLexicalScope));
  1253. return $1;
  1254. }, self, "newMethodScope", [], smalltalk.SemanticAnalyzer)},
  1255. args: [],
  1256. source: "newMethodScope\x0a\x09^ self newScopeOfClass: MethodLexicalScope",
  1257. messageSends: ["newScopeOfClass:"],
  1258. referencedClasses: ["MethodLexicalScope"]
  1259. }),
  1260. smalltalk.SemanticAnalyzer);
  1261. smalltalk.addMethod(
  1262. "_newScopeOfClass_",
  1263. smalltalk.method({
  1264. selector: "newScopeOfClass:",
  1265. category: 'factory',
  1266. fn: function (aLexicalScopeClass){
  1267. var self=this;
  1268. return smalltalk.withContext(function($ctx1) { var $2,$3,$1;
  1269. $2=_st(aLexicalScopeClass)._new();
  1270. _st($2)._outerScope_(self["@currentScope"]);
  1271. $3=_st($2)._yourself();
  1272. $1=$3;
  1273. return $1;
  1274. }, self, "newScopeOfClass:", [aLexicalScopeClass], smalltalk.SemanticAnalyzer)},
  1275. args: ["aLexicalScopeClass"],
  1276. source: "newScopeOfClass: aLexicalScopeClass\x0a\x09^ aLexicalScopeClass new \x0a\x09\x09outerScope: currentScope;\x0a\x09\x09yourself",
  1277. messageSends: ["outerScope:", "new", "yourself"],
  1278. referencedClasses: []
  1279. }),
  1280. smalltalk.SemanticAnalyzer);
  1281. smalltalk.addMethod(
  1282. "_popScope",
  1283. smalltalk.method({
  1284. selector: "popScope",
  1285. category: 'scope',
  1286. fn: function (){
  1287. var self=this;
  1288. return smalltalk.withContext(function($ctx1) { if(($receiver = self["@currentScope"]) == nil || $receiver == undefined){
  1289. self["@currentScope"];
  1290. } else {
  1291. self["@currentScope"]=_st(self["@currentScope"])._outerScope();
  1292. self["@currentScope"];
  1293. };
  1294. return self}, self, "popScope", [], smalltalk.SemanticAnalyzer)},
  1295. args: [],
  1296. source: "popScope\x0a\x09currentScope ifNotNil: [\x0a\x09\x09currentScope := currentScope outerScope ]",
  1297. messageSends: ["ifNotNil:", "outerScope"],
  1298. referencedClasses: []
  1299. }),
  1300. smalltalk.SemanticAnalyzer);
  1301. smalltalk.addMethod(
  1302. "_pushScope_",
  1303. smalltalk.method({
  1304. selector: "pushScope:",
  1305. category: 'scope',
  1306. fn: function (aScope){
  1307. var self=this;
  1308. return smalltalk.withContext(function($ctx1) { _st(aScope)._outerScope_(self["@currentScope"]);
  1309. self["@currentScope"]=aScope;
  1310. return self}, self, "pushScope:", [aScope], smalltalk.SemanticAnalyzer)},
  1311. args: ["aScope"],
  1312. source: "pushScope: aScope\x0a\x09aScope outerScope: currentScope.\x0a\x09currentScope := aScope",
  1313. messageSends: ["outerScope:"],
  1314. referencedClasses: []
  1315. }),
  1316. smalltalk.SemanticAnalyzer);
  1317. smalltalk.addMethod(
  1318. "_superSends",
  1319. smalltalk.method({
  1320. selector: "superSends",
  1321. category: 'accessing',
  1322. fn: function (){
  1323. var self=this;
  1324. return smalltalk.withContext(function($ctx1) { var $1;
  1325. if(($receiver = self["@superSends"]) == nil || $receiver == undefined){
  1326. self["@superSends"]=_st((smalltalk.Dictionary || Dictionary))._new();
  1327. $1=self["@superSends"];
  1328. } else {
  1329. $1=self["@superSends"];
  1330. };
  1331. return $1;
  1332. }, self, "superSends", [], smalltalk.SemanticAnalyzer)},
  1333. args: [],
  1334. source: "superSends\x0a\x09^ superSends ifNil: [ superSends := Dictionary new ]",
  1335. messageSends: ["ifNil:", "new"],
  1336. referencedClasses: ["Dictionary"]
  1337. }),
  1338. smalltalk.SemanticAnalyzer);
  1339. smalltalk.addMethod(
  1340. "_theClass",
  1341. smalltalk.method({
  1342. selector: "theClass",
  1343. category: 'accessing',
  1344. fn: function (){
  1345. var self=this;
  1346. return smalltalk.withContext(function($ctx1) { var $1;
  1347. $1=self["@theClass"];
  1348. return $1;
  1349. }, self, "theClass", [], smalltalk.SemanticAnalyzer)},
  1350. args: [],
  1351. source: "theClass\x0a\x09^ theClass",
  1352. messageSends: [],
  1353. referencedClasses: []
  1354. }),
  1355. smalltalk.SemanticAnalyzer);
  1356. smalltalk.addMethod(
  1357. "_theClass_",
  1358. smalltalk.method({
  1359. selector: "theClass:",
  1360. category: 'accessing',
  1361. fn: function (aClass){
  1362. var self=this;
  1363. return smalltalk.withContext(function($ctx1) { self["@theClass"]=aClass;
  1364. return self}, self, "theClass:", [aClass], smalltalk.SemanticAnalyzer)},
  1365. args: ["aClass"],
  1366. source: "theClass: aClass\x0a\x09theClass := aClass",
  1367. messageSends: [],
  1368. referencedClasses: []
  1369. }),
  1370. smalltalk.SemanticAnalyzer);
  1371. smalltalk.addMethod(
  1372. "_validateVariableScope_",
  1373. smalltalk.method({
  1374. selector: "validateVariableScope:",
  1375. category: 'scope',
  1376. fn: function (aString){
  1377. var self=this;
  1378. return smalltalk.withContext(function($ctx1) { var $1;
  1379. $1=_st(self["@currentScope"])._lookupVariable_(aString);
  1380. if(($receiver = $1) == nil || $receiver == undefined){
  1381. $1;
  1382. } else {
  1383. _st(self)._errorShadowingVariable_(aString);
  1384. };
  1385. return self}, self, "validateVariableScope:", [aString], smalltalk.SemanticAnalyzer)},
  1386. args: ["aString"],
  1387. source: "validateVariableScope: aString\x0a\x09\x22Validate the variable scope in by doing a recursive lookup, up to the method scope\x22\x0a\x0a\x09(currentScope lookupVariable: aString) ifNotNil: [\x0a\x09\x09self errorShadowingVariable: aString ]",
  1388. messageSends: ["ifNotNil:", "errorShadowingVariable:", "lookupVariable:"],
  1389. referencedClasses: []
  1390. }),
  1391. smalltalk.SemanticAnalyzer);
  1392. smalltalk.addMethod(
  1393. "_visitAssignmentNode_",
  1394. smalltalk.method({
  1395. selector: "visitAssignmentNode:",
  1396. category: 'visiting',
  1397. fn: function (aNode){
  1398. var self=this;
  1399. return smalltalk.withContext(function($ctx1) { smalltalk.NodeVisitor.fn.prototype._visitAssignmentNode_.apply(_st(self), [aNode]);
  1400. _st(_st(aNode)._left())._beAssigned();
  1401. return self}, self, "visitAssignmentNode:", [aNode], smalltalk.SemanticAnalyzer)},
  1402. args: ["aNode"],
  1403. source: "visitAssignmentNode: aNode\x0a\x09super visitAssignmentNode: aNode.\x0a\x09aNode left beAssigned",
  1404. messageSends: ["visitAssignmentNode:", "beAssigned", "left"],
  1405. referencedClasses: []
  1406. }),
  1407. smalltalk.SemanticAnalyzer);
  1408. smalltalk.addMethod(
  1409. "_visitBlockNode_",
  1410. smalltalk.method({
  1411. selector: "visitBlockNode:",
  1412. category: 'visiting',
  1413. fn: function (aNode){
  1414. var self=this;
  1415. return smalltalk.withContext(function($ctx1) { _st(self)._pushScope_(_st(self)._newBlockScope());
  1416. _st(aNode)._scope_(self["@currentScope"]);
  1417. _st(self["@currentScope"])._node_(aNode);
  1418. _st(_st(aNode)._parameters())._do_((function(each){
  1419. return smalltalk.withContext(function($ctx2) { _st(self)._validateVariableScope_(each);
  1420. return _st(self["@currentScope"])._addArg_(each);
  1421. })}));
  1422. smalltalk.NodeVisitor.fn.prototype._visitBlockNode_.apply(_st(self), [aNode]);
  1423. _st(self)._popScope();
  1424. return self}, self, "visitBlockNode:", [aNode], smalltalk.SemanticAnalyzer)},
  1425. args: ["aNode"],
  1426. source: "visitBlockNode: aNode\x0a\x09self pushScope: self newBlockScope.\x0a\x09aNode scope: currentScope.\x0a\x09currentScope node: aNode.\x0a\x09\x0a\x09aNode parameters do: [ :each | \x0a\x09\x09self validateVariableScope: each.\x0a\x09\x09currentScope addArg: each ].\x0a\x0a\x09super visitBlockNode: aNode.\x0a\x09self popScope",
  1427. messageSends: ["pushScope:", "newBlockScope", "scope:", "node:", "do:", "validateVariableScope:", "addArg:", "parameters", "visitBlockNode:", "popScope"],
  1428. referencedClasses: []
  1429. }),
  1430. smalltalk.SemanticAnalyzer);
  1431. smalltalk.addMethod(
  1432. "_visitCascadeNode_",
  1433. smalltalk.method({
  1434. selector: "visitCascadeNode:",
  1435. category: 'visiting',
  1436. fn: function (aNode){
  1437. var self=this;
  1438. return smalltalk.withContext(function($ctx1) { var $1;
  1439. _st(_st(aNode)._nodes())._do_((function(each){
  1440. return smalltalk.withContext(function($ctx2) { return _st(each)._receiver_(_st(aNode)._receiver());
  1441. })}));
  1442. smalltalk.NodeVisitor.fn.prototype._visitCascadeNode_.apply(_st(self), [aNode]);
  1443. $1=_st(_st(_st(aNode)._nodes())._first())._superSend();
  1444. if(smalltalk.assert($1)){
  1445. _st(_st(aNode)._nodes())._do_((function(each){
  1446. return smalltalk.withContext(function($ctx2) { return _st(each)._superSend_(true);
  1447. })}));
  1448. };
  1449. return self}, self, "visitCascadeNode:", [aNode], smalltalk.SemanticAnalyzer)},
  1450. args: ["aNode"],
  1451. source: "visitCascadeNode: aNode\x0a\x09\x22Populate the receiver into all children\x22\x0a\x09aNode nodes do: [ :each | \x0a\x09\x09each receiver: aNode receiver ].\x0a\x09super visitCascadeNode: aNode.\x0a\x09aNode nodes first superSend ifTrue: [\x0a\x09\x09aNode nodes do: [ :each | each superSend: true ]]",
  1452. messageSends: ["do:", "receiver:", "receiver", "nodes", "visitCascadeNode:", "ifTrue:", "superSend:", "superSend", "first"],
  1453. referencedClasses: []
  1454. }),
  1455. smalltalk.SemanticAnalyzer);
  1456. smalltalk.addMethod(
  1457. "_visitClassReferenceNode_",
  1458. smalltalk.method({
  1459. selector: "visitClassReferenceNode:",
  1460. category: 'visiting',
  1461. fn: function (aNode){
  1462. var self=this;
  1463. return smalltalk.withContext(function($ctx1) { var $1,$2;
  1464. _st(_st(self)._classReferences())._add_(_st(aNode)._value());
  1465. $1=_st((smalltalk.ClassRefVar || ClassRefVar))._new();
  1466. _st($1)._name_(_st(aNode)._value());
  1467. $2=_st($1)._yourself();
  1468. _st(aNode)._binding_($2);
  1469. return self}, self, "visitClassReferenceNode:", [aNode], smalltalk.SemanticAnalyzer)},
  1470. args: ["aNode"],
  1471. source: "visitClassReferenceNode: aNode\x0a\x09self classReferences add: aNode value.\x0a\x09aNode binding: (ClassRefVar new name: aNode value; yourself)",
  1472. messageSends: ["add:", "value", "classReferences", "binding:", "name:", "new", "yourself"],
  1473. referencedClasses: ["ClassRefVar"]
  1474. }),
  1475. smalltalk.SemanticAnalyzer);
  1476. smalltalk.addMethod(
  1477. "_visitMethodNode_",
  1478. smalltalk.method({
  1479. selector: "visitMethodNode:",
  1480. category: 'visiting',
  1481. fn: function (aNode){
  1482. var self=this;
  1483. return smalltalk.withContext(function($ctx1) { var $1,$2;
  1484. _st(self)._pushScope_(_st(self)._newMethodScope());
  1485. _st(aNode)._scope_(self["@currentScope"]);
  1486. _st(self["@currentScope"])._node_(aNode);
  1487. _st(_st(_st(self)._theClass())._allInstanceVariableNames())._do_((function(each){
  1488. return smalltalk.withContext(function($ctx2) { return _st(self["@currentScope"])._addIVar_(each);
  1489. })}));
  1490. _st(_st(aNode)._arguments())._do_((function(each){
  1491. return smalltalk.withContext(function($ctx2) { _st(self)._validateVariableScope_(each);
  1492. return _st(self["@currentScope"])._addArg_(each);
  1493. })}));
  1494. smalltalk.NodeVisitor.fn.prototype._visitMethodNode_.apply(_st(self), [aNode]);
  1495. $1=aNode;
  1496. _st($1)._classReferences_(_st(self)._classReferences());
  1497. _st($1)._messageSends_(_st(_st(self)._messageSends())._keys());
  1498. $2=_st($1)._superSends_(_st(_st(self)._superSends())._keys());
  1499. _st(self)._popScope();
  1500. return self}, self, "visitMethodNode:", [aNode], smalltalk.SemanticAnalyzer)},
  1501. args: ["aNode"],
  1502. source: "visitMethodNode: aNode\x0a\x09self pushScope: self newMethodScope.\x0a\x09aNode scope: currentScope.\x0a\x09currentScope node: aNode.\x0a\x0a\x09self theClass allInstanceVariableNames do: [:each | \x0a\x09\x09currentScope addIVar: each ].\x0a\x09aNode arguments do: [ :each | \x0a\x09\x09self validateVariableScope: each.\x0a\x09\x09currentScope addArg: each ].\x0a\x0a\x09super visitMethodNode: aNode.\x0a\x0a\x09aNode \x0a\x09\x09classReferences: self classReferences;\x0a\x09\x09messageSends: self messageSends keys;\x0a superSends: self superSends keys.\x0a\x09self popScope",
  1503. messageSends: ["pushScope:", "newMethodScope", "scope:", "node:", "do:", "addIVar:", "allInstanceVariableNames", "theClass", "validateVariableScope:", "addArg:", "arguments", "visitMethodNode:", "classReferences:", "classReferences", "messageSends:", "keys", "messageSends", "superSends:", "superSends", "popScope"],
  1504. referencedClasses: []
  1505. }),
  1506. smalltalk.SemanticAnalyzer);
  1507. smalltalk.addMethod(
  1508. "_visitReturnNode_",
  1509. smalltalk.method({
  1510. selector: "visitReturnNode:",
  1511. category: 'visiting',
  1512. fn: function (aNode){
  1513. var self=this;
  1514. return smalltalk.withContext(function($ctx1) { var $1;
  1515. _st(aNode)._scope_(self["@currentScope"]);
  1516. $1=_st(self["@currentScope"])._isMethodScope();
  1517. if(smalltalk.assert($1)){
  1518. _st(self["@currentScope"])._localReturn_(true);
  1519. } else {
  1520. _st(_st(self["@currentScope"])._methodScope())._addNonLocalReturn_(self["@currentScope"]);
  1521. };
  1522. smalltalk.NodeVisitor.fn.prototype._visitReturnNode_.apply(_st(self), [aNode]);
  1523. return self}, self, "visitReturnNode:", [aNode], smalltalk.SemanticAnalyzer)},
  1524. args: ["aNode"],
  1525. source: "visitReturnNode: aNode\x0a\x09aNode scope: currentScope.\x0a\x09currentScope isMethodScope\x0a\x09\x09ifTrue: [ currentScope localReturn: true ]\x0a\x09\x09ifFalse: [ currentScope methodScope addNonLocalReturn: currentScope ].\x0a\x09super visitReturnNode: aNode",
  1526. messageSends: ["scope:", "ifTrue:ifFalse:", "localReturn:", "addNonLocalReturn:", "methodScope", "isMethodScope", "visitReturnNode:"],
  1527. referencedClasses: []
  1528. }),
  1529. smalltalk.SemanticAnalyzer);
  1530. smalltalk.addMethod(
  1531. "_visitSendNode_",
  1532. smalltalk.method({
  1533. selector: "visitSendNode:",
  1534. category: 'visiting',
  1535. fn: function (aNode){
  1536. var self=this;
  1537. return smalltalk.withContext(function($ctx1) { var $1,$2;
  1538. $1=_st(_st(_st(aNode)._receiver())._value()).__eq("super");
  1539. if(smalltalk.assert($1)){
  1540. _st(aNode)._superSend_(true);
  1541. _st(_st(aNode)._receiver())._value_("self");
  1542. _st(_st(self)._superSends())._at_ifAbsentPut_(_st(aNode)._selector(),(function(){
  1543. return smalltalk.withContext(function($ctx2) { return _st((smalltalk.Set || Set))._new();
  1544. })}));
  1545. _st(_st(_st(self)._superSends())._at_(_st(aNode)._selector()))._add_(aNode);
  1546. } else {
  1547. $2=_st(_st((smalltalk.IRSendInliner || IRSendInliner))._inlinedSelectors())._includes_(_st(aNode)._selector());
  1548. if(smalltalk.assert($2)){
  1549. _st(aNode)._shouldBeInlined_(true);
  1550. _st(_st(aNode)._receiver())._shouldBeAliased_(true);
  1551. };
  1552. };
  1553. _st(_st(self)._messageSends())._at_ifAbsentPut_(_st(aNode)._selector(),(function(){
  1554. return smalltalk.withContext(function($ctx2) { return _st((smalltalk.Set || Set))._new();
  1555. })}));
  1556. _st(_st(_st(self)._messageSends())._at_(_st(aNode)._selector()))._add_(aNode);
  1557. _st(aNode)._index_(_st(_st(_st(self)._messageSends())._at_(_st(aNode)._selector()))._size());
  1558. smalltalk.NodeVisitor.fn.prototype._visitSendNode_.apply(_st(self), [aNode]);
  1559. return self}, self, "visitSendNode:", [aNode], smalltalk.SemanticAnalyzer)},
  1560. args: ["aNode"],
  1561. source: "visitSendNode: aNode\x0a\x0a\x09aNode receiver value = 'super' \x0a\x09\x09ifTrue: [\x0a\x09\x09\x09aNode superSend: true.\x0a\x09\x09\x09aNode receiver value: 'self'.\x0a\x09\x09\x09self superSends at: aNode selector ifAbsentPut: [ Set new ].\x0a\x09\x09\x09(self superSends at: aNode selector) add: aNode ]\x0a \x0a\x09\x09ifFalse: [ (IRSendInliner inlinedSelectors includes: aNode selector) ifTrue: [\x0a\x09\x09\x09aNode shouldBeInlined: true.\x0a\x09\x09\x09aNode receiver shouldBeAliased: true ] ].\x0a\x0a\x09self messageSends at: aNode selector ifAbsentPut: [ Set new ].\x0a\x09(self messageSends at: aNode selector) add: aNode.\x0a\x0a\x09aNode index: (self messageSends at: aNode selector) size.\x0a\x0a\x09super visitSendNode: aNode",
  1562. messageSends: ["ifTrue:ifFalse:", "superSend:", "value:", "receiver", "at:ifAbsentPut:", "selector", "new", "superSends", "add:", "at:", "ifTrue:", "shouldBeInlined:", "shouldBeAliased:", "includes:", "inlinedSelectors", "=", "value", "messageSends", "index:", "size", "visitSendNode:"],
  1563. referencedClasses: ["Set", "IRSendInliner"]
  1564. }),
  1565. smalltalk.SemanticAnalyzer);
  1566. smalltalk.addMethod(
  1567. "_visitSequenceNode_",
  1568. smalltalk.method({
  1569. selector: "visitSequenceNode:",
  1570. category: 'visiting',
  1571. fn: function (aNode){
  1572. var self=this;
  1573. return smalltalk.withContext(function($ctx1) { _st(_st(aNode)._temps())._do_((function(each){
  1574. return smalltalk.withContext(function($ctx2) { _st(self)._validateVariableScope_(each);
  1575. return _st(self["@currentScope"])._addTemp_(each);
  1576. })}));
  1577. smalltalk.NodeVisitor.fn.prototype._visitSequenceNode_.apply(_st(self), [aNode]);
  1578. return self}, self, "visitSequenceNode:", [aNode], smalltalk.SemanticAnalyzer)},
  1579. args: ["aNode"],
  1580. source: "visitSequenceNode: aNode\x0a\x09aNode temps do: [ :each | \x0a\x09\x09self validateVariableScope: each.\x0a\x09\x09currentScope addTemp: each ].\x0a\x0a\x09super visitSequenceNode: aNode",
  1581. messageSends: ["do:", "validateVariableScope:", "addTemp:", "temps", "visitSequenceNode:"],
  1582. referencedClasses: []
  1583. }),
  1584. smalltalk.SemanticAnalyzer);
  1585. smalltalk.addMethod(
  1586. "_visitVariableNode_",
  1587. smalltalk.method({
  1588. selector: "visitVariableNode:",
  1589. category: 'visiting',
  1590. fn: function (aNode){
  1591. var self=this;
  1592. return smalltalk.withContext(function($ctx1) { var $1,$3,$4,$5,$2;
  1593. $1=aNode;
  1594. $3=_st(self["@currentScope"])._lookupVariable_(aNode);
  1595. if(($receiver = $3) == nil || $receiver == undefined){
  1596. _st(self)._errorUnknownVariable_(aNode);
  1597. $4=_st((smalltalk.UnknownVar || UnknownVar))._new();
  1598. _st($4)._name_(_st(aNode)._value());
  1599. $5=_st($4)._yourself();
  1600. $2=$5;
  1601. } else {
  1602. $2=$3;
  1603. };
  1604. _st($1)._binding_($2);
  1605. return self}, self, "visitVariableNode:", [aNode], smalltalk.SemanticAnalyzer)},
  1606. args: ["aNode"],
  1607. source: "visitVariableNode: aNode\x0a\x09\x22Bind a ScopeVar to aNode by doing a lookup in the current scope.\x0a\x09If no ScopeVar is found, bind a UnknowVar and throw an error\x22\x0a\x0a\x09aNode binding: ((currentScope lookupVariable: aNode) ifNil: [ \x0a\x09\x09self errorUnknownVariable: aNode.\x0a\x09\x09UnknownVar new name: aNode value; yourself ])",
  1608. messageSends: ["binding:", "ifNil:", "errorUnknownVariable:", "name:", "value", "new", "yourself", "lookupVariable:"],
  1609. referencedClasses: ["UnknownVar"]
  1610. }),
  1611. smalltalk.SemanticAnalyzer);
  1612. smalltalk.addMethod(
  1613. "_on_",
  1614. smalltalk.method({
  1615. selector: "on:",
  1616. category: 'instance creation',
  1617. fn: function (aClass){
  1618. var self=this;
  1619. return smalltalk.withContext(function($ctx1) { var $2,$3,$1;
  1620. $2=_st(self)._new();
  1621. _st($2)._theClass_(aClass);
  1622. $3=_st($2)._yourself();
  1623. $1=$3;
  1624. return $1;
  1625. }, self, "on:", [aClass], smalltalk.SemanticAnalyzer.klass)},
  1626. args: ["aClass"],
  1627. source: "on: aClass\x0a\x09^ self new\x0a\x09\x09theClass: aClass;\x0a\x09\x09yourself",
  1628. messageSends: ["theClass:", "new", "yourself"],
  1629. referencedClasses: []
  1630. }),
  1631. smalltalk.SemanticAnalyzer.klass);