1
0

Compiler-Semantic.js 54 KB

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