Compiler-Semantic.js 60 KB

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