Compiler-Semantic.js 50 KB

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