Compiler-Semantic.js 61 KB

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