2
0

Compiler-Semantic.js 59 KB

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