1
0

Compiler-Semantic.js 46 KB

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