2
0

Compiler-Semantic.js 60 KB

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