Compiler-Semantic.js 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420
  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.Dictionary || Dictionary), "_new", []));})() : $receiver;
  984. return self;},
  985. args: [],
  986. source: "messageSends\x0a\x09^ messageSends ifNil: [ messageSends := Dictionary new ]",
  987. messageSends: ["ifNil:", "new"],
  988. referencedClasses: ["Dictionary"]
  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(smalltalk.send(self, "_messageSends", []), "_keys", [])]);})(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 keys.\x0a\x09self popScope",
  1230. messageSends: ["pushScope:", "newMethodScope", "scope:", "node:", "do:", "allInstanceVariableNames", "theClass", "addIVar:", "arguments", "validateVariableScope:", "addArg:", "visitMethodNode:", "classReferences:", "classReferences", "messageSends:", "keys", "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(self['@currentScope'], "_localReturn_", [true]);})() : (function(){return smalltalk.send(smalltalk.send(self['@currentScope'], "_methodScope", []), "_addNonLocalReturn_", [self['@currentScope']]);})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return smalltalk.send(self['@currentScope'], "_localReturn_", [true]);}), (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\x09ifTrue: [ currentScope localReturn: true ]\x0a\x09\x09ifFalse: [ currentScope methodScope addNonLocalReturn: currentScope ].\x0a\x09super visitReturnNode: aNode",
  1247. messageSends: ["scope:", "ifTrue:ifFalse:", "isMethodScope", "localReturn:", "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"]);})() : (function(){return ((($receiver = smalltalk.send(smalltalk.send((smalltalk.IRSendInliner || IRSendInliner), "_inlinedSelectors", []), "_includes_", [smalltalk.send(aNode, "_selector", [])])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(aNode, "_shouldBeInlined_", [true]);})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return smalltalk.send(aNode, "_shouldBeInlined_", [true]);})]));})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){smalltalk.send(aNode, "_superSend_", [true]);return smalltalk.send(smalltalk.send(aNode, "_receiver", []), "_value_", ["self"]);}), (function(){return ((($receiver = smalltalk.send(smalltalk.send((smalltalk.IRSendInliner || IRSendInliner), "_inlinedSelectors", []), "_includes_", [smalltalk.send(aNode, "_selector", [])])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(aNode, "_shouldBeInlined_", [true]);})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return smalltalk.send(aNode, "_shouldBeInlined_", [true]);})]));})]));
  1259. smalltalk.send(smalltalk.send(self, "_messageSends", []), "_at_ifAbsentPut_", [smalltalk.send(aNode, "_selector", []), (function(){return smalltalk.send((smalltalk.Set || Set), "_new", []);})]);
  1260. smalltalk.send(smalltalk.send(smalltalk.send(self, "_messageSends", []), "_at_", [smalltalk.send(aNode, "_selector", [])]), "_add_", [aNode]);
  1261. smalltalk.send(aNode, "_index_", [smalltalk.send(smalltalk.send(smalltalk.send(self, "_messageSends", []), "_at_", [smalltalk.send(aNode, "_selector", [])]), "_size", [])]);
  1262. smalltalk.send(self, "_visitSendNode_", [aNode], smalltalk.SemanticAnalyzer.superclass || nil);
  1263. return self;},
  1264. args: ["aNode"],
  1265. source: "visitSendNode: aNode\x0a\x0a\x09aNode receiver value = 'super' \x0a\x09\x09ifTrue: [\x0a\x09\x09\x09aNode superSend: true.\x0a\x09\x09\x09aNode receiver value: 'self' ]\x0a\x09\x09ifFalse: [ (IRSendInliner inlinedSelectors includes: aNode selector) ifTrue: [\x0a\x09\x09\x09aNode shouldBeInlined: true ]].\x0a\x0a\x09self messageSends at: aNode selector ifAbsentPut: [ Set new ].\x0a\x09(self messageSends at: aNode selector) add: aNode.\x0a\x0a\x09aNode index: (self messageSends at: aNode selector) size.\x0a\x0a\x09super visitSendNode: aNode",
  1266. messageSends: ["ifTrue:ifFalse:", "=", "value", "receiver", "superSend:", "value:", "ifTrue:", "includes:", "inlinedSelectors", "selector", "shouldBeInlined:", "at:ifAbsentPut:", "messageSends", "new", "add:", "at:", "index:", "size", "visitSendNode:"],
  1267. referencedClasses: ["IRSendInliner", "Set"]
  1268. }),
  1269. smalltalk.SemanticAnalyzer);
  1270. smalltalk.addMethod(
  1271. "_visitSequenceNode_",
  1272. smalltalk.method({
  1273. selector: "visitSequenceNode:",
  1274. category: 'visiting',
  1275. fn: function (aNode) {
  1276. var self=this;
  1277. smalltalk.send(smalltalk.send(aNode, "_temps", []), "_do_", [(function(each){smalltalk.send(self, "_validateVariableScope_", [each]);return smalltalk.send(self['@currentScope'], "_addTemp_", [each]);})]);
  1278. smalltalk.send(self, "_visitSequenceNode_", [aNode], smalltalk.SemanticAnalyzer.superclass || nil);
  1279. return self;},
  1280. args: ["aNode"],
  1281. source: "visitSequenceNode: aNode\x0a\x09aNode temps do: [ :each | \x0a\x09\x09self validateVariableScope: each.\x0a\x09\x09currentScope addTemp: each ].\x0a\x0a\x09super visitSequenceNode: aNode",
  1282. messageSends: ["do:", "temps", "validateVariableScope:", "addTemp:", "visitSequenceNode:"],
  1283. referencedClasses: []
  1284. }),
  1285. smalltalk.SemanticAnalyzer);
  1286. smalltalk.addMethod(
  1287. "_visitVariableNode_",
  1288. smalltalk.method({
  1289. selector: "visitVariableNode:",
  1290. category: 'visiting',
  1291. fn: function (aNode) {
  1292. var self=this;
  1293. 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]);
  1294. return self;},
  1295. args: ["aNode"],
  1296. 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 ])",
  1297. messageSends: ["binding:", "ifNil:", "lookupVariable:", "errorUnknownVariable:", "name:", "value", "yourself", "new"],
  1298. referencedClasses: ["UnknownVar"]
  1299. }),
  1300. smalltalk.SemanticAnalyzer);
  1301. smalltalk.addMethod(
  1302. "_on_",
  1303. smalltalk.method({
  1304. selector: "on:",
  1305. category: 'instance creation',
  1306. fn: function (aClass) {
  1307. var self=this;
  1308. return (function($rec){smalltalk.send($rec, "_theClass_", [aClass]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send(self, "_new", []));
  1309. return self;},
  1310. args: ["aClass"],
  1311. source: "on: aClass\x0a\x09^ self new\x0a\x09\x09theClass: aClass;\x0a\x09\x09yourself",
  1312. messageSends: ["theClass:", "yourself", "new"],
  1313. referencedClasses: []
  1314. }),
  1315. smalltalk.SemanticAnalyzer.klass);