Compiler-Semantic.js 59 KB

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