Compiler-Semantic.js 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664
  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;
  1116. var notDefined;
  1117. notDefined=eval('typeof ' + aNode._value() + ' == "undefined"');
  1118. ;
  1119. if(smalltalk.assert(notDefined)){
  1120. $1=_st((smalltalk.UnknownVariableError || UnknownVariableError))._new();
  1121. _st($1)._variableName_(_st(aNode)._value());
  1122. $2=_st($1)._signal();
  1123. $2;
  1124. } else {
  1125. _st(_st(_st(self["@currentScope"])._methodScope())._unknownVariables())._add_(_st(aNode)._value());
  1126. };
  1127. return self}, self, "errorUnknownVariable:", [aNode], smalltalk.SemanticAnalyzer)},
  1128. args: ["aNode"],
  1129. 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| notDefined |\x0a\x0a\x09notDefined := <eval('typeof ' + aNode._value() + ' == \x22undefined\x22')>.\x0a\x0a\x09notDefined\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. ]",
  1130. messageSends: ["ifTrue:ifFalse:", "variableName:", "value", "new", "signal", "add:", "unknownVariables", "methodScope"],
  1131. referencedClasses: ["UnknownVariableError"]
  1132. }),
  1133. smalltalk.SemanticAnalyzer);
  1134. smalltalk.addMethod(
  1135. "_messageSends",
  1136. smalltalk.method({
  1137. selector: "messageSends",
  1138. category: 'accessing',
  1139. fn: function (){
  1140. var self=this;
  1141. return smalltalk.withContext(function($ctx) { var $1;
  1142. if(($receiver = self["@messageSends"]) == nil || $receiver == undefined){
  1143. self["@messageSends"]=_st((smalltalk.Dictionary || Dictionary))._new();
  1144. $1=self["@messageSends"];
  1145. } else {
  1146. $1=self["@messageSends"];
  1147. };
  1148. return $1;
  1149. }, self, "messageSends", [], smalltalk.SemanticAnalyzer)},
  1150. args: [],
  1151. source: "messageSends\x0a\x09^ messageSends ifNil: [ messageSends := Dictionary new ]",
  1152. messageSends: ["ifNil:", "new"],
  1153. referencedClasses: ["Dictionary"]
  1154. }),
  1155. smalltalk.SemanticAnalyzer);
  1156. smalltalk.addMethod(
  1157. "_newBlockScope",
  1158. smalltalk.method({
  1159. selector: "newBlockScope",
  1160. category: 'factory',
  1161. fn: function (){
  1162. var self=this;
  1163. return smalltalk.withContext(function($ctx) { var $1;
  1164. $1=_st(self)._newScopeOfClass_((smalltalk.LexicalScope || LexicalScope));
  1165. return $1;
  1166. }, self, "newBlockScope", [], smalltalk.SemanticAnalyzer)},
  1167. args: [],
  1168. source: "newBlockScope\x0a\x09^ self newScopeOfClass: LexicalScope",
  1169. messageSends: ["newScopeOfClass:"],
  1170. referencedClasses: ["LexicalScope"]
  1171. }),
  1172. smalltalk.SemanticAnalyzer);
  1173. smalltalk.addMethod(
  1174. "_newMethodScope",
  1175. smalltalk.method({
  1176. selector: "newMethodScope",
  1177. category: 'factory',
  1178. fn: function (){
  1179. var self=this;
  1180. return smalltalk.withContext(function($ctx) { var $1;
  1181. $1=_st(self)._newScopeOfClass_((smalltalk.MethodLexicalScope || MethodLexicalScope));
  1182. return $1;
  1183. }, self, "newMethodScope", [], smalltalk.SemanticAnalyzer)},
  1184. args: [],
  1185. source: "newMethodScope\x0a\x09^ self newScopeOfClass: MethodLexicalScope",
  1186. messageSends: ["newScopeOfClass:"],
  1187. referencedClasses: ["MethodLexicalScope"]
  1188. }),
  1189. smalltalk.SemanticAnalyzer);
  1190. smalltalk.addMethod(
  1191. "_newScopeOfClass_",
  1192. smalltalk.method({
  1193. selector: "newScopeOfClass:",
  1194. category: 'factory',
  1195. fn: function (aLexicalScopeClass){
  1196. var self=this;
  1197. return smalltalk.withContext(function($ctx) { var $2,$3,$1;
  1198. $2=_st(aLexicalScopeClass)._new();
  1199. _st($2)._outerScope_(self["@currentScope"]);
  1200. $3=_st($2)._yourself();
  1201. $1=$3;
  1202. return $1;
  1203. }, self, "newScopeOfClass:", [aLexicalScopeClass], smalltalk.SemanticAnalyzer)},
  1204. args: ["aLexicalScopeClass"],
  1205. source: "newScopeOfClass: aLexicalScopeClass\x0a\x09^ aLexicalScopeClass new \x0a\x09\x09outerScope: currentScope;\x0a\x09\x09yourself",
  1206. messageSends: ["outerScope:", "new", "yourself"],
  1207. referencedClasses: []
  1208. }),
  1209. smalltalk.SemanticAnalyzer);
  1210. smalltalk.addMethod(
  1211. "_popScope",
  1212. smalltalk.method({
  1213. selector: "popScope",
  1214. category: 'scope',
  1215. fn: function (){
  1216. var self=this;
  1217. return smalltalk.withContext(function($ctx) { if(($receiver = self["@currentScope"]) == nil || $receiver == undefined){
  1218. self["@currentScope"];
  1219. } else {
  1220. self["@currentScope"]=_st(self["@currentScope"])._outerScope();
  1221. self["@currentScope"];
  1222. };
  1223. return self}, self, "popScope", [], smalltalk.SemanticAnalyzer)},
  1224. args: [],
  1225. source: "popScope\x0a\x09currentScope ifNotNil: [\x0a\x09\x09currentScope := currentScope outerScope ]",
  1226. messageSends: ["ifNotNil:", "outerScope"],
  1227. referencedClasses: []
  1228. }),
  1229. smalltalk.SemanticAnalyzer);
  1230. smalltalk.addMethod(
  1231. "_pushScope_",
  1232. smalltalk.method({
  1233. selector: "pushScope:",
  1234. category: 'scope',
  1235. fn: function (aScope){
  1236. var self=this;
  1237. return smalltalk.withContext(function($ctx) { _st(aScope)._outerScope_(self["@currentScope"]);
  1238. self["@currentScope"]=aScope;
  1239. return self}, self, "pushScope:", [aScope], smalltalk.SemanticAnalyzer)},
  1240. args: ["aScope"],
  1241. source: "pushScope: aScope\x0a\x09aScope outerScope: currentScope.\x0a\x09currentScope := aScope",
  1242. messageSends: ["outerScope:"],
  1243. referencedClasses: []
  1244. }),
  1245. smalltalk.SemanticAnalyzer);
  1246. smalltalk.addMethod(
  1247. "_superSends",
  1248. smalltalk.method({
  1249. selector: "superSends",
  1250. category: 'accessing',
  1251. fn: function (){
  1252. var self=this;
  1253. return smalltalk.withContext(function($ctx) { var $1;
  1254. if(($receiver = self["@superSends"]) == nil || $receiver == undefined){
  1255. self["@superSends"]=_st((smalltalk.Dictionary || Dictionary))._new();
  1256. $1=self["@superSends"];
  1257. } else {
  1258. $1=self["@superSends"];
  1259. };
  1260. return $1;
  1261. }, self, "superSends", [], smalltalk.SemanticAnalyzer)},
  1262. args: [],
  1263. source: "superSends\x0a\x09^ superSends ifNil: [ superSends := Dictionary new ]",
  1264. messageSends: ["ifNil:", "new"],
  1265. referencedClasses: ["Dictionary"]
  1266. }),
  1267. smalltalk.SemanticAnalyzer);
  1268. smalltalk.addMethod(
  1269. "_theClass",
  1270. smalltalk.method({
  1271. selector: "theClass",
  1272. category: 'accessing',
  1273. fn: function (){
  1274. var self=this;
  1275. return smalltalk.withContext(function($ctx) { return self["@theClass"];
  1276. }, self, "theClass", [], smalltalk.SemanticAnalyzer)},
  1277. args: [],
  1278. source: "theClass\x0a\x09^ theClass",
  1279. messageSends: [],
  1280. referencedClasses: []
  1281. }),
  1282. smalltalk.SemanticAnalyzer);
  1283. smalltalk.addMethod(
  1284. "_theClass_",
  1285. smalltalk.method({
  1286. selector: "theClass:",
  1287. category: 'accessing',
  1288. fn: function (aClass){
  1289. var self=this;
  1290. return smalltalk.withContext(function($ctx) { self["@theClass"]=aClass;
  1291. return self}, self, "theClass:", [aClass], smalltalk.SemanticAnalyzer)},
  1292. args: ["aClass"],
  1293. source: "theClass: aClass\x0a\x09theClass := aClass",
  1294. messageSends: [],
  1295. referencedClasses: []
  1296. }),
  1297. smalltalk.SemanticAnalyzer);
  1298. smalltalk.addMethod(
  1299. "_validateVariableScope_",
  1300. smalltalk.method({
  1301. selector: "validateVariableScope:",
  1302. category: 'scope',
  1303. fn: function (aString){
  1304. var self=this;
  1305. return smalltalk.withContext(function($ctx) { var $1;
  1306. $1=_st(self["@currentScope"])._lookupVariable_(aString);
  1307. if(($receiver = $1) == nil || $receiver == undefined){
  1308. $1;
  1309. } else {
  1310. _st(self)._errorShadowingVariable_(aString);
  1311. };
  1312. return self}, self, "validateVariableScope:", [aString], smalltalk.SemanticAnalyzer)},
  1313. args: ["aString"],
  1314. 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 ]",
  1315. messageSends: ["ifNotNil:", "errorShadowingVariable:", "lookupVariable:"],
  1316. referencedClasses: []
  1317. }),
  1318. smalltalk.SemanticAnalyzer);
  1319. smalltalk.addMethod(
  1320. "_visitAssignmentNode_",
  1321. smalltalk.method({
  1322. selector: "visitAssignmentNode:",
  1323. category: 'visiting',
  1324. fn: function (aNode){
  1325. var self=this;
  1326. return smalltalk.withContext(function($ctx) { smalltalk.NodeVisitor.fn.prototype._visitAssignmentNode_.apply(_st(self), [aNode]);
  1327. _st(_st(aNode)._left())._beAssigned();
  1328. return self}, self, "visitAssignmentNode:", [aNode], smalltalk.SemanticAnalyzer)},
  1329. args: ["aNode"],
  1330. source: "visitAssignmentNode: aNode\x0a\x09super visitAssignmentNode: aNode.\x0a\x09aNode left beAssigned",
  1331. messageSends: ["visitAssignmentNode:", "beAssigned", "left"],
  1332. referencedClasses: []
  1333. }),
  1334. smalltalk.SemanticAnalyzer);
  1335. smalltalk.addMethod(
  1336. "_visitBlockNode_",
  1337. smalltalk.method({
  1338. selector: "visitBlockNode:",
  1339. category: 'visiting',
  1340. fn: function (aNode){
  1341. var self=this;
  1342. return smalltalk.withContext(function($ctx) { _st(self)._pushScope_(_st(self)._newBlockScope());
  1343. _st(aNode)._scope_(self["@currentScope"]);
  1344. _st(self["@currentScope"])._node_(aNode);
  1345. _st(_st(aNode)._parameters())._do_((function(each){
  1346. _st(self)._validateVariableScope_(each);
  1347. return _st(self["@currentScope"])._addArg_(each);
  1348. }));
  1349. smalltalk.NodeVisitor.fn.prototype._visitBlockNode_.apply(_st(self), [aNode]);
  1350. _st(self)._popScope();
  1351. return self}, self, "visitBlockNode:", [aNode], smalltalk.SemanticAnalyzer)},
  1352. args: ["aNode"],
  1353. 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",
  1354. messageSends: ["pushScope:", "newBlockScope", "scope:", "node:", "do:", "validateVariableScope:", "addArg:", "parameters", "visitBlockNode:", "popScope"],
  1355. referencedClasses: []
  1356. }),
  1357. smalltalk.SemanticAnalyzer);
  1358. smalltalk.addMethod(
  1359. "_visitCascadeNode_",
  1360. smalltalk.method({
  1361. selector: "visitCascadeNode:",
  1362. category: 'visiting',
  1363. fn: function (aNode){
  1364. var self=this;
  1365. return smalltalk.withContext(function($ctx) { var $1;
  1366. _st(_st(aNode)._nodes())._do_((function(each){
  1367. return _st(each)._receiver_(_st(aNode)._receiver());
  1368. }));
  1369. smalltalk.NodeVisitor.fn.prototype._visitCascadeNode_.apply(_st(self), [aNode]);
  1370. $1=_st(_st(_st(aNode)._nodes())._first())._superSend();
  1371. if(smalltalk.assert($1)){
  1372. _st(_st(aNode)._nodes())._do_((function(each){
  1373. return _st(each)._superSend_(true);
  1374. }));
  1375. };
  1376. return self}, self, "visitCascadeNode:", [aNode], smalltalk.SemanticAnalyzer)},
  1377. args: ["aNode"],
  1378. 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 ]]",
  1379. messageSends: ["do:", "receiver:", "receiver", "nodes", "visitCascadeNode:", "ifTrue:", "superSend:", "superSend", "first"],
  1380. referencedClasses: []
  1381. }),
  1382. smalltalk.SemanticAnalyzer);
  1383. smalltalk.addMethod(
  1384. "_visitClassReferenceNode_",
  1385. smalltalk.method({
  1386. selector: "visitClassReferenceNode:",
  1387. category: 'visiting',
  1388. fn: function (aNode){
  1389. var self=this;
  1390. return smalltalk.withContext(function($ctx) { var $1,$2;
  1391. _st(_st(self)._classReferences())._add_(_st(aNode)._value());
  1392. $1=_st((smalltalk.ClassRefVar || ClassRefVar))._new();
  1393. _st($1)._name_(_st(aNode)._value());
  1394. $2=_st($1)._yourself();
  1395. _st(aNode)._binding_($2);
  1396. return self}, self, "visitClassReferenceNode:", [aNode], smalltalk.SemanticAnalyzer)},
  1397. args: ["aNode"],
  1398. source: "visitClassReferenceNode: aNode\x0a\x09self classReferences add: aNode value.\x0a\x09aNode binding: (ClassRefVar new name: aNode value; yourself)",
  1399. messageSends: ["add:", "value", "classReferences", "binding:", "name:", "new", "yourself"],
  1400. referencedClasses: ["ClassRefVar"]
  1401. }),
  1402. smalltalk.SemanticAnalyzer);
  1403. smalltalk.addMethod(
  1404. "_visitMethodNode_",
  1405. smalltalk.method({
  1406. selector: "visitMethodNode:",
  1407. category: 'visiting',
  1408. fn: function (aNode){
  1409. var self=this;
  1410. return smalltalk.withContext(function($ctx) { var $1;
  1411. _st(self)._pushScope_(_st(self)._newMethodScope());
  1412. _st(aNode)._scope_(self["@currentScope"]);
  1413. _st(self["@currentScope"])._node_(aNode);
  1414. _st(_st(_st(self)._theClass())._allInstanceVariableNames())._do_((function(each){
  1415. return _st(self["@currentScope"])._addIVar_(each);
  1416. }));
  1417. _st(_st(aNode)._arguments())._do_((function(each){
  1418. _st(self)._validateVariableScope_(each);
  1419. return _st(self["@currentScope"])._addArg_(each);
  1420. }));
  1421. smalltalk.NodeVisitor.fn.prototype._visitMethodNode_.apply(_st(self), [aNode]);
  1422. _st(aNode)._classReferences_(_st(self)._classReferences());
  1423. _st(aNode)._messageSends_(_st(_st(self)._messageSends())._keys());
  1424. $1=_st(aNode)._superSends_(_st(_st(self)._superSends())._keys());
  1425. _st(self)._popScope();
  1426. return self}, self, "visitMethodNode:", [aNode], smalltalk.SemanticAnalyzer)},
  1427. args: ["aNode"],
  1428. 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",
  1429. messageSends: ["pushScope:", "newMethodScope", "scope:", "node:", "do:", "addIVar:", "allInstanceVariableNames", "theClass", "validateVariableScope:", "addArg:", "arguments", "visitMethodNode:", "classReferences:", "classReferences", "messageSends:", "keys", "messageSends", "superSends:", "superSends", "popScope"],
  1430. referencedClasses: []
  1431. }),
  1432. smalltalk.SemanticAnalyzer);
  1433. smalltalk.addMethod(
  1434. "_visitReturnNode_",
  1435. smalltalk.method({
  1436. selector: "visitReturnNode:",
  1437. category: 'visiting',
  1438. fn: function (aNode){
  1439. var self=this;
  1440. return smalltalk.withContext(function($ctx) { var $1;
  1441. _st(aNode)._scope_(self["@currentScope"]);
  1442. $1=_st(self["@currentScope"])._isMethodScope();
  1443. if(smalltalk.assert($1)){
  1444. _st(self["@currentScope"])._localReturn_(true);
  1445. } else {
  1446. _st(_st(self["@currentScope"])._methodScope())._addNonLocalReturn_(self["@currentScope"]);
  1447. };
  1448. smalltalk.NodeVisitor.fn.prototype._visitReturnNode_.apply(_st(self), [aNode]);
  1449. return self}, self, "visitReturnNode:", [aNode], smalltalk.SemanticAnalyzer)},
  1450. args: ["aNode"],
  1451. 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",
  1452. messageSends: ["scope:", "ifTrue:ifFalse:", "localReturn:", "addNonLocalReturn:", "methodScope", "isMethodScope", "visitReturnNode:"],
  1453. referencedClasses: []
  1454. }),
  1455. smalltalk.SemanticAnalyzer);
  1456. smalltalk.addMethod(
  1457. "_visitSendNode_",
  1458. smalltalk.method({
  1459. selector: "visitSendNode:",
  1460. category: 'visiting',
  1461. fn: function (aNode){
  1462. var self=this;
  1463. return smalltalk.withContext(function($ctx) { var $1,$2,$3;
  1464. $1=_st(_st(_st(aNode)._receiver())._value()).__eq("super");
  1465. if(smalltalk.assert($1)){
  1466. _st(aNode)._superSend_(true);
  1467. _st(_st(aNode)._receiver())._value_("self");
  1468. _st(_st(self)._superSends())._at_ifAbsentPut_(_st(aNode)._selector(),(function(){
  1469. return _st((smalltalk.Set || Set))._new();
  1470. }));
  1471. _st(_st(_st(self)._superSends())._at_(_st(aNode)._selector()))._add_(aNode);
  1472. } else {
  1473. $2=_st(_st((smalltalk.IRSendInliner || IRSendInliner))._inlinedSelectors())._includes_(_st(aNode)._selector());
  1474. if(smalltalk.assert($2)){
  1475. _st(aNode)._shouldBeInlined_(true);
  1476. $3=_st(_st(aNode)._receiver())._isValueNode();
  1477. if(! smalltalk.assert($3)){
  1478. _st(_st(aNode)._receiver())._shouldBeAliased_(true);
  1479. };
  1480. };
  1481. };
  1482. _st(_st(self)._messageSends())._at_ifAbsentPut_(_st(aNode)._selector(),(function(){
  1483. return _st((smalltalk.Set || Set))._new();
  1484. }));
  1485. _st(_st(_st(self)._messageSends())._at_(_st(aNode)._selector()))._add_(aNode);
  1486. _st(aNode)._index_(_st(_st(_st(self)._messageSends())._at_(_st(aNode)._selector()))._size());
  1487. smalltalk.NodeVisitor.fn.prototype._visitSendNode_.apply(_st(self), [aNode]);
  1488. return self}, self, "visitSendNode:", [aNode], smalltalk.SemanticAnalyzer)},
  1489. args: ["aNode"],
  1490. 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",
  1491. 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:"],
  1492. referencedClasses: ["Set", "IRSendInliner"]
  1493. }),
  1494. smalltalk.SemanticAnalyzer);
  1495. smalltalk.addMethod(
  1496. "_visitSequenceNode_",
  1497. smalltalk.method({
  1498. selector: "visitSequenceNode:",
  1499. category: 'visiting',
  1500. fn: function (aNode){
  1501. var self=this;
  1502. return smalltalk.withContext(function($ctx) { _st(_st(aNode)._temps())._do_((function(each){
  1503. _st(self)._validateVariableScope_(each);
  1504. return _st(self["@currentScope"])._addTemp_(each);
  1505. }));
  1506. smalltalk.NodeVisitor.fn.prototype._visitSequenceNode_.apply(_st(self), [aNode]);
  1507. return self}, self, "visitSequenceNode:", [aNode], smalltalk.SemanticAnalyzer)},
  1508. args: ["aNode"],
  1509. source: "visitSequenceNode: aNode\x0a\x09aNode temps do: [ :each | \x0a\x09\x09self validateVariableScope: each.\x0a\x09\x09currentScope addTemp: each ].\x0a\x0a\x09super visitSequenceNode: aNode",
  1510. messageSends: ["do:", "validateVariableScope:", "addTemp:", "temps", "visitSequenceNode:"],
  1511. referencedClasses: []
  1512. }),
  1513. smalltalk.SemanticAnalyzer);
  1514. smalltalk.addMethod(
  1515. "_visitVariableNode_",
  1516. smalltalk.method({
  1517. selector: "visitVariableNode:",
  1518. category: 'visiting',
  1519. fn: function (aNode){
  1520. var self=this;
  1521. return smalltalk.withContext(function($ctx) { var $2,$3,$4,$1;
  1522. $2=_st(self["@currentScope"])._lookupVariable_(aNode);
  1523. if(($receiver = $2) == nil || $receiver == undefined){
  1524. _st(self)._errorUnknownVariable_(aNode);
  1525. $3=_st((smalltalk.UnknownVar || UnknownVar))._new();
  1526. _st($3)._name_(_st(aNode)._value());
  1527. $4=_st($3)._yourself();
  1528. $1=$4;
  1529. } else {
  1530. $1=$2;
  1531. };
  1532. _st(aNode)._binding_($1);
  1533. return self}, self, "visitVariableNode:", [aNode], smalltalk.SemanticAnalyzer)},
  1534. args: ["aNode"],
  1535. 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 ])",
  1536. messageSends: ["binding:", "ifNil:", "errorUnknownVariable:", "name:", "value", "new", "yourself", "lookupVariable:"],
  1537. referencedClasses: ["UnknownVar"]
  1538. }),
  1539. smalltalk.SemanticAnalyzer);
  1540. smalltalk.addMethod(
  1541. "_on_",
  1542. smalltalk.method({
  1543. selector: "on:",
  1544. category: 'instance creation',
  1545. fn: function (aClass){
  1546. var self=this;
  1547. return smalltalk.withContext(function($ctx) { var $2,$3,$1;
  1548. $2=_st(self)._new();
  1549. _st($2)._theClass_(aClass);
  1550. $3=_st($2)._yourself();
  1551. $1=$3;
  1552. return $1;
  1553. }, self, "on:", [aClass], smalltalk.SemanticAnalyzer.klass)},
  1554. args: ["aClass"],
  1555. source: "on: aClass\x0a\x09^ self new\x0a\x09\x09theClass: aClass;\x0a\x09\x09yourself",
  1556. messageSends: ["theClass:", "new", "yourself"],
  1557. referencedClasses: []
  1558. }),
  1559. smalltalk.SemanticAnalyzer.klass);