Compiler-Semantic.js 53 KB

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