Compiler-Semantic.js 48 KB

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