2
0

Compiler-Semantic.js 65 KB

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