Compiler-Semantic.js 61 KB

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