Compiler-Semantic.js 61 KB

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