Compiler-Semantic.js 47 KB

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