Compiler-Semantic.js 48 KB

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