Compiler-Semantic.js 64 KB

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